--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.toolchain.llvm.clang.macosx.base.835953277">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.llvm.clang.macosx.base.835953277" moduleId="org.eclipse.cdt.core.settings" name="Default">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration buildProperties="" description="" id="cdt.managedbuild.toolchain.llvm.clang.macosx.base.835953277" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
+ <folderInfo id="cdt.managedbuild.toolchain.llvm.clang.macosx.base.835953277.2072262777" name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.llvm.clang.macosx.base.1440061656" name="LLVM with Clang (MacOSX)" superClass="cdt.managedbuild.toolchain.llvm.clang.macosx.base">
+ <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.MachO64" id="cdt.managedbuild.target.llvm.macosx.platform.base.220063451" isAbstract="true" name="Debug Platform" osList="macosx" superClass="cdt.managedbuild.target.llvm.macosx.platform.base"/>
+ <builder buildPath="${workspace_loc:/NetRadiant}/Default" id="cdt.managedbuild.target.llvm.builder.base.1826435543" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="CDT Internal Builder" superClass="cdt.managedbuild.target.llvm.builder.base"/>
+ <tool id="cdt.managedbuild.tool.llvm.assembler.base.1540137577" name="LLVM assembler" superClass="cdt.managedbuild.tool.llvm.assembler.base"/>
+ <tool id="cdt.managedbuild.tool.llvm.archiver.base.726448752" name="LLVM archiver" superClass="cdt.managedbuild.tool.llvm.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.llvm.c.compiler.base.423406515" name="LLVM Clang" superClass="cdt.managedbuild.tool.llvm.c.compiler.base">
+ <option id="llvm.c_cpp.compiler.option.include.paths.1177478676" name="Include paths (-I)" superClass="llvm.c_cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/opt/local/include"/>
+ <listOptionValue builtIn="false" value="/opt/local/include/glib-2.0"/>
+ <listOptionValue builtIn="false" value="/opt/local/include/gtk-2.0"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.llvm.c.compiler.input.1702833029" superClass="cdt.managedbuild.tool.llvm.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.llvm.cpp.compiler.base.1130692273" name="LLVM Clang++" superClass="cdt.managedbuild.tool.llvm.cpp.compiler.base">
+ <option id="llvm.c_cpp.compiler.option.include.paths.1703680230" name="Include paths (-I)" superClass="llvm.c_cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/opt/local/include"/>
+ <listOptionValue builtIn="false" value="/opt/local/include/gtk-2.0"/>
+ <listOptionValue builtIn="false" value="/opt/local/include/glib-2.0"/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/NetRadiant/plugins}""/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/NetRadiant/include}""/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/NetRadiant/radiant}""/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.llvm.cpp.compiler.input.1553525897" superClass="cdt.managedbuild.tool.llvm.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.llvm.c.linker.base.391098519" name="LLVM Clang C linker" superClass="cdt.managedbuild.tool.llvm.c.linker.base"/>
+ <tool id="cdt.managedbuild.tool.llvm.cpp.linker.base.2079349783" name="LLVM Clang C++ linker" superClass="cdt.managedbuild.tool.llvm.cpp.linker.base">
+ <inputType id="cdt.managedbuild.tool.llvm.c.linker.input.1496404439" superClass="cdt.managedbuild.tool.llvm.c.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ <sourceEntries>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
+ </sourceEntries>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="NetRadiant.null.969150560" name="NetRadiant"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Default">
+ <resource resourceType="PROJECT" workspacePath="/NetRadiant"/>
+ </configuration>
+ </storageModule>
+</cproject>
--- /dev/null
+build:
+ image: teaci/msys32
+ shell: mingw32
+ pull: true
+ commands:
+ - pacman -S --needed --noconfirm --noprogressbar mingw-w64-i686-{toolchain,cmake,gtk2,gtkglext}
+ - cmake -G "MSYS Makefiles" .
+ - make
*.[oda]
-install
-games
+.idea/
+.settings
+build/
+games/
+install/
--- /dev/null
+[submodule "libs/crunch"]
+ path = libs/crunch
+ url = https://github.com/DaemonEngine/crunch.git
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>NetRadiant</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+language: c++
+
+sudo: required
+
+services:
+ - docker
+
+os:
+ - linux
+ - osx
+
+compiler:
+ - clang
+ - gcc
+
+before_script:
+ - cmake --version
+ - if [ "$TRAVIS_OS_NAME" == "linux" ]; then
+ sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe" &&
+ sudo apt-get -qq update &&
+ sudo apt-get -qq -f install &&
+ sudo apt-get -qq install libgtk2.0-dev libgtkglext1-dev libminizip-dev;
+ fi
+ - if [ "$TRAVIS_OS_NAME" == "osx" ]; then
+ brew update &&
+ brew install gtkglext &&
+ brew link --force gettext;
+ fi
+
+script:
+ - cmake -H. -Bbuild
+ - cmake --build build -- -j4
--- /dev/null
+cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
+project(NetRadiant C CXX)
+
+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)
+endif ()
+
+#-----------------------------------------------------------------------
+# Version
+#-----------------------------------------------------------------------
+
+# CMake 3.0+ would allow this in project()
+set(NetRadiant_VERSION_MAJOR 1)
+set(NetRadiant_VERSION_MINOR 5)
+set(NetRadiant_VERSION_PATCH 0)
+set(NetRadiant_VERSION "${NetRadiant_VERSION_MAJOR}.${NetRadiant_VERSION_MINOR}.${NetRadiant_VERSION_PATCH}")
+
+file(WRITE "${PROJECT_BINARY_DIR}/RADIANT_MAJOR" ${NetRadiant_VERSION_MAJOR})
+file(WRITE "${PROJECT_BINARY_DIR}/RADIANT_MINOR" ${NetRadiant_VERSION_MINOR})
+file(WRITE "${PROJECT_BINARY_DIR}/RADIANT_PATCH" ${NetRadiant_VERSION_PATCH})
+
+set(RADIANT_ABOUTMSG "Custom build" CACHE STRING "About message")
+
+find_package(Git REQUIRED)
+execute_process(
+ COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ OUTPUT_VARIABLE GIT_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+set(RADIANT_VERSION_STRING "${NetRadiant_VERSION}n")
+if (GIT_VERSION)
+ set(RADIANT_VERSION_STRING "${RADIANT_VERSION_STRING}-git-${GIT_VERSION}")
+endif ()
+
+message(STATUS "Building ${PROJECT_NAME} ${RADIANT_VERSION_STRING} ${RADIANT_ABOUTMSG}")
+
+#-----------------------------------------------------------------------
+# Language standard
+#-----------------------------------------------------------------------
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+if (CMAKE_VERSION VERSION_LESS "3.1")
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
+ include(CheckCXXCompilerFlag)
+ check_cxx_compiler_flag(--std=c++${CMAKE_CXX_STANDARD} STD_CXX)
+ if (STD_CXX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++${CMAKE_CXX_STANDARD}")
+ else ()
+ message(SEND_ERROR "Requires C++${CMAKE_CXX_STANDARD} or better")
+ endif ()
+ else ()
+ message(WARNING "Unrecognized compiler: ${CMAKE_CXX_COMPILER_ID}, make sure it supports C++${CMAKE_CXX_STANDARD}")
+ endif ()
+endif ()
+
+#-----------------------------------------------------------------------
+# Flags
+#-----------------------------------------------------------------------
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
+macro(addflags_c args)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${args}")
+endmacro()
+macro(addflags_cxx args)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${args}")
+endmacro()
+macro(addflags args)
+ addflags_c("${args}")
+ addflags_cxx("${args}")
+endmacro()
+addflags("-fno-strict-aliasing")
+if (NOT WIN32)
+ addflags("-fvisibility=hidden")
+endif ()
+
+if (USE_WERROR)
+ addflags("-Werror")
+ addflags("-pedantic-errors")
+endif ()
+
+addflags("-Wall")
+addflags("-Wextra")
+addflags("-pedantic")
+
+addflags_c("-Wno-deprecated-declarations") # vfs.c: g_strdown
+
+addflags("-Wno-unused-function")
+addflags("-Wno-unused-variable")
+addflags("-Wno-unused-parameter")
+
+set(CMAKE_POSITION_INDEPENDENT_CODE 1)
+set(GTK_TARGET 2 CACHE STRING "GTK target")
+add_definitions(-DGTK_TARGET=${GTK_TARGET})
+
+#-----------------------------------------------------------------------
+# Defs
+#-----------------------------------------------------------------------
+
+add_definitions(-DRADIANT_VERSION="${NetRadiant_VERSION}")
+add_definitions(-DRADIANT_MAJOR_VERSION="${NetRadiant_VERSION_MAJOR}")
+add_definitions(-DRADIANT_MINOR_VERSION="${NetRadiant_VERSION_MINOR}")
+add_definitions(-DRADIANT_PATCH_VERSION="${NetRadiant_VERSION_PATCH}")
+
+add_definitions(-DRADIANT_ABOUTMSG="${NetRadiant_ABOUT}")
+
+if (NOT CMAKE_BUILD_TYPE MATCHES Release)
+ add_definitions(-D_DEBUG=1)
+endif ()
+
+macro(disable_deprecated name gtk2only)
+ add_definitions(-D${name}_DISABLE_SINGLE_INCLUDES)
+ if ((${gtk2only} EQUAL 0) OR (GTK_TARGET EQUAL 2))
+ add_definitions(-D${name}_DISABLE_DEPRECATED)
+ endif ()
+endmacro()
+
+disable_deprecated(ATK 0)
+disable_deprecated(G 0)
+disable_deprecated(GDK 0)
+disable_deprecated(GDK_PIXBUF 0)
+disable_deprecated(GTK 1)
+disable_deprecated(PANGO 0)
+
+if (APPLE)
+ option(XWINDOWS "Build against X11" ON)
+ add_definitions(
+ -DPOSIX=1
+ )
+elseif (WIN32)
+ add_definitions(
+ -DWIN32=1
+ -D_WIN32=1
+ )
+else ()
+ set(XWINDOWS ON)
+ add_definitions(
+ -DPOSIX=1
+ )
+endif ()
+
+if (XWINDOWS)
+ find_package(X11 REQUIRED)
+ include_directories(${X11_INCLUDE_DIR})
+ add_definitions(-DXWINDOWS=1)
+endif ()
+
+include_directories("${PROJECT_SOURCE_DIR}/include")
+include_directories("${PROJECT_SOURCE_DIR}/libs")
+
+if (WIN32 AND NOT CMAKE_CROSSCOMPILING)
+ set(BUNDLE_LIBRARIES_DEFAULT ON)
+else ()
+ set(BUNDLE_LIBRARIES_DEFAULT OFF)
+endif ()
+option(BUNDLE_LIBRARIES "Bundle libraries" ${BUNDLE_LIBRARIES_DEFAULT})
+
+macro(copy_dlls target)
+ if (BUNDLE_LIBRARIES)
+ add_custom_command(TARGET ${target} POST_BUILD
+ COMMAND bash
+ ARGS -c "ldd '$<TARGET_FILE:${target}>' | grep -v /c/Windows | awk '{ print $1 }' | while read dll; do cp \"$(which $dll)\" '${PROJECT_BINARY_DIR}'; done"
+ VERBATIM
+ )
+ endif ()
+endmacro()
+
+#-----------------------------------------------------------------------
+# Libraries
+#-----------------------------------------------------------------------
+
+add_subdirectory(libs)
+add_subdirectory(include)
+
+#-----------------------------------------------------------------------
+# Plugins
+#-----------------------------------------------------------------------
+
+if (BUILD_RADIANT)
+ add_subdirectory(contrib)
+endif ()
+
+#-----------------------------------------------------------------------
+# Modules
+#-----------------------------------------------------------------------
+
+if (BUILD_RADIANT)
+ add_subdirectory(plugins)
+endif ()
+
+#-----------------------------------------------------------------------
+# Radiant
+#-----------------------------------------------------------------------
+
+if (CMAKE_EXECUTABLE_SUFFIX)
+ string(REGEX REPLACE "^[.]" "" RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
+else ()
+ execute_process(
+ COMMAND uname -m
+ OUTPUT_VARIABLE RADIANT_EXECUTABLE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+endif ()
+
+macro(radiant_tool name)
+ add_executable(${name} ${ARGN})
+ install(
+ TARGETS ${name}
+ RUNTIME DESTINATION .
+ )
+ if (NOT (CMAKE_EXECUTABLE_SUFFIX STREQUAL ".${RADIANT_EXECUTABLE}"))
+ add_custom_command(TARGET ${name} POST_BUILD
+ COMMAND ln -f -s "$<TARGET_FILE_NAME:${name}>" "${PROJECT_BINARY_DIR}/${name}.${RADIANT_EXECUTABLE}"
+ VERBATIM
+ )
+ install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
+ ${name}${CMAKE_EXECUTABLE_SUFFIX} ${CMAKE_INSTALL_PREFIX}/${name}.${RADIANT_EXECUTABLE})
+ ")
+ endif ()
+endmacro()
+
+if (BUILD_RADIANT)
+ add_subdirectory(radiant _radiant)
+ set_target_properties(radiant PROPERTIES
+ COMPILE_DEFINITIONS RADIANT_EXECUTABLE="${RADIANT_EXECUTABLE}"
+ )
+endif ()
+
+#-----------------------------------------------------------------------
+# Tools
+#-----------------------------------------------------------------------
+
+add_subdirectory(tools)
+
+file(GLOB DATA_FILES "${PROJECT_SOURCE_DIR}/setup/data/tools/*")
+
+if (NOT (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR))
+ # Copy data files from sources to the build directory
+ message(STATUS "Copying data files")
+ file(COPY ${DATA_FILES} DESTINATION "${PROJECT_BINARY_DIR}")
+endif ()
+
+#-----------------------------------------------------------------------
+# Game packs
+#-----------------------------------------------------------------------
+
+option(DOWNLOAD_GAMEPACKS "Download game packs" ON)
+
+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)
+ 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()
+
+#-----------------------------------------------------------------------
+# Install
+#-----------------------------------------------------------------------
+
+install(
+ FILES
+ "${PROJECT_BINARY_DIR}/RADIANT_MAJOR"
+ "${PROJECT_BINARY_DIR}/RADIANT_MINOR"
+ "${PROJECT_BINARY_DIR}/RADIANT_PATCH"
+ DESTINATION .
+)
+
+install(
+ DIRECTORY
+ setup/data/tools/
+ docs
+ DESTINATION .
+)
+
+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)
- OS X 10.5 or 10.6
- Xcode developer tools installed (OSX DVD)
- X11 (from the OS X DVD)
-- MacPorts or fink installed
+- MacPorts or fink or homebrew installed
- the following packages installed:
Macports:
gtkglext pkgconfig glib2-devel libxml2 gtk2 pango atk gettext wget
Fink:
gtkglext1 pkgconfig glib2-dev libxml2 gtk+2 gtk+2-dev pango1-xft2-ft219-dev atk1 gettext-dev wget
+ homebrew:
+ gtk+ gtkglext
build:
run 'make'
+homebrew build:
+run 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
+make'
+
run:
Switch into the install folder, and run NetRadiant.app
# 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))
CPPFLAGS_DL ?=
LIBS_DL ?= -ldl # nothing on Win32
CPPFLAGS_ZLIB ?=
-LIBS_ZLIB ?= -lz
+LIBS_ZLIB ?= -lz -lminizip
CPPFLAGS_JPEG ?=
LIBS_JPEG ?= -ljpeg
DEPEND_ON_MAKEFILE ?= yes
CPPFLAGS_COMMON =
LDFLAGS_COMMON =
LIBS_COMMON =
-CXXFLAGS_COMMON = -Wno-non-virtual-dtor -Wreorder -fno-exceptions -fno-rtti
+CXXFLAGS_COMMON = -std=c++11 -Wno-non-virtual-dtor -Wreorder -fno-exceptions -fno-rtti
ifeq ($(BUILD),debug)
ifeq ($(findstring $(CFLAGS),-g),)
CFLAGS_COMMON += -O3
# only add -O3 if no -O flag is in $(CFLAGS)
endif
- CFLAGS_COMMON += -march=native -mcpu=native
+ CFLAGS_COMMON += -march=native -mtune=native
CPPFLAGS_COMMON +=
LDFLAGS_COMMON += -s
else
# workaround: we have no "ldd" for OS X, so...
LDD =
OTOOL = otool
-
- INSTALLDIR := $(INSTALLDIR_BASE)/NetRadiant.app/Contents/MacOS/install
else
$(error Unsupported build OS: $(OS))
endif
# VERSION!
-RADIANT_VERSION_NUMBER = 1.5.0
+RADIANT_MAJOR_VERSION = 1
+RADIANT_MINOR_VERSION = 5
+RADIANT_PATCH_VERSION = 0
+RADIANT_VERSION_NUMBER = $(RADIANT_MAJOR_VERSION).$(RADIANT_MINOR_VERSION).$(RADIANT_PATCH_VERSION)
RADIANT_VERSION = $(RADIANT_VERSION_NUMBER)n
-RADIANT_MAJOR_VERSION = 5
-RADIANT_MINOR_VERSION = 0
Q3MAP_VERSION = 2.5.17n
# Executable extension
Q3MAP_VERSION := $(Q3MAP_VERSION)-git-$(GIT_VERSION)
endif
-CPPFLAGS += -DRADIANT_VERSION="\"$(RADIANT_VERSION)\"" -DRADIANT_MAJOR_VERSION="\"$(RADIANT_MAJOR_VERSION)\"" -DRADIANT_MINOR_VERSION="\"$(RADIANT_MINOR_VERSION)\"" -DRADIANT_ABOUTMSG="\"$(RADIANT_ABOUTMSG)\"" -DQ3MAP_VERSION="\"$(Q3MAP_VERSION)\"" -DRADIANT_EXECUTABLE="\"$(RADIANT_EXECUTABLE)\""
+CPPFLAGS += -DRADIANT_VERSION="\"$(RADIANT_VERSION)\"" -DRADIANT_MAJOR_VERSION="\"$(RADIANT_MAJOR_VERSION)\"" -DRADIANT_MINOR_VERSION="\"$(RADIANT_MINOR_VERSION)\"" -DRADIANT_PATCH_VERSION="\"$(RADIANT_PATCH_VERSION)\"" -DRADIANT_ABOUTMSG="\"$(RADIANT_ABOUTMSG)\"" -DQ3MAP_VERSION="\"$(Q3MAP_VERSION)\"" -DRADIANT_EXECUTABLE="\"$(RADIANT_EXECUTABLE)\""
+CPPFLAGS += -DGTK_TARGET=2
.PHONY: all
all: \
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) \
$(INSTALLDIR)/plugins/shaderplug.$(DLL) \
$(INSTALLDIR)/plugins/sunplug.$(DLL) \
$(INSTALLDIR)/plugins/ufoaiplug.$(DLL) \
- $(INSTALLDIR)/plugins/meshtex.$(DLL) \
.PHONY: binaries-radiant
binaries-radiant-core: \
.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
ifeq ($(OS),Win32)
$(INSTALLDIR)/q3map2.$(EXE): LDFLAGS_EXTRA := -Wl,--large-address-aware,--stack,4194304
endif
-$(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 \
tools/quake3/common/polylib.o \
tools/quake3/common/scriplib.o \
tools/quake3/common/threads.o \
- tools/quake3/common/unzip.o \
tools/quake3/common/vfs.o \
tools/quake3/common/miniz.o \
tools/quake3/q3map2/brush.o \
tools/quake3/q3map2/bspfile_ibsp.o \
tools/quake3/q3map2/bspfile_rbsp.o \
tools/quake3/q3map2/bsp.o \
+ tools/quake3/q3map2/bsp_analyze.o \
+ tools/quake3/q3map2/bsp_scale.o \
+ tools/quake3/q3map2/bsp_info.o \
tools/quake3/q3map2/convert_ase.o \
+ tools/quake3/q3map2/convert_bsp.o \
tools/quake3/q3map2/convert_obj.o \
tools/quake3/q3map2/convert_map.o \
tools/quake3/q3map2/decals.o \
tools/quake3/q3map2/exportents.o \
tools/quake3/q3map2/facebsp.o \
+ tools/quake3/q3map2/fixaas.o \
tools/quake3/q3map2/fog.o \
tools/quake3/q3map2/help.o \
tools/quake3/q3map2/image.o \
tools/quake3/q3map2/light_ydnar.o \
tools/quake3/q3map2/main.o \
tools/quake3/q3map2/map.o \
+ tools/quake3/q3map2/minimap.o \
tools/quake3/q3map2/mesh.o \
tools/quake3/q3map2/model.o \
tools/quake3/q3map2/patch.o \
tools/quake3/q3map2/vis.o \
tools/quake3/q3map2/writebsp.o \
libddslib.$(A) \
+ libetclib.$(A) \
libfilematch.$(A) \
libl_net.$(A) \
libmathlib.$(A) \
libddslib.$(A): \
libs/ddslib/ddslib.o \
+libetclib.$(A): CPPFLAGS_EXTRA := -Ilibs
+libetclib.$(A): \
+ libs/etclib.o \
+
$(INSTALLDIR)/q3data.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_ZLIB)
$(INSTALLDIR)/q3data.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_ZLIB) -Itools/quake3/common -Ilibs -Iinclude
$(INSTALLDIR)/q3data.$(EXE): \
tools/quake3/common/md4.o \
tools/quake3/common/scriplib.o \
tools/quake3/common/trilib.o \
- tools/quake3/common/unzip.o \
tools/quake3/common/vfs.o \
tools/quake3/common/miniz.o \
tools/quake3/q3data/3dslib.o \
tools/quake3/q3data/stripper.o \
tools/quake3/q3data/video.o \
libfilematch.$(A) \
+ libetclib.$(A) \
libl_net.$(A) \
libmathlib.$(A) \
$(if $(findstring $(OS),Win32),icons/q3data.o,) \
radiant/stacktrace.o \
radiant/surfacedialog.o \
radiant/texmanip.o \
+ radiant/textureentry.o \
radiant/textures.o \
radiant/texwindow.o \
radiant/timer.o \
radiant/xywindow.o \
libcmdlib.$(A) \
libgtkutil.$(A) \
+ libuilib.$(A) \
libl_net.$(A) \
libmathlib.$(A) \
libprofile.$(A) \
libs/gtkutil/accelerator.o \
libs/gtkutil/button.o \
libs/gtkutil/clipboard.o \
- libs/gtkutil/closure.o \
- libs/gtkutil/container.o \
libs/gtkutil/cursor.o \
libs/gtkutil/dialog.o \
libs/gtkutil/entry.o \
libs/gtkutil/frame.o \
libs/gtkutil/glfont.o \
libs/gtkutil/glwidget.o \
- libs/gtkutil/idledraw.o \
libs/gtkutil/image.o \
libs/gtkutil/menu.o \
libs/gtkutil/messagebox.o \
libs/gtkutil/nonmodal.o \
libs/gtkutil/paned.o \
- libs/gtkutil/pointer.o \
libs/gtkutil/toolbar.o \
libs/gtkutil/widget.o \
libs/gtkutil/window.o \
libs/gtkutil/xorrectangle.o \
+libuilib.$(A): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) -Ilibs -Iinclude
+libuilib.$(A): \
+ libs/uilib/uilib.o \
+
libxmllib.$(A): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) -Ilibs -Iinclude
libxmllib.$(A): \
- libs/xml/ixml.o \
- libs/xml/xmlelement.o \
- libs/xml/xmlparser.o \
libs/xml/xmltextags.o \
- libs/xml/xmlwriter.o \
$(INSTALLDIR)/modules/archivezip.$(DLL): LIBS_EXTRA := $(LIBS_ZLIB)
$(INSTALLDIR)/modules/archivezip.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_ZLIB) -Ilibs -Iinclude
$(INSTALLDIR)/modules/archivezip.$(DLL): \
plugins/archivezip/archive.o \
- plugins/archivezip/pkzip.o \
plugins/archivezip/plugin.o \
- plugins/archivezip/zlibstream.o \
$(INSTALLDIR)/modules/archivewad.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
$(INSTALLDIR)/modules/archivewad.$(DLL): \
plugins/archivewad/archive.o \
plugins/archivewad/plugin.o \
- plugins/archivewad/wad.o \
$(INSTALLDIR)/modules/archivepak.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
$(INSTALLDIR)/modules/archivepak.$(DLL): \
plugins/archivepak/archive.o \
- plugins/archivepak/pak.o \
plugins/archivepak/plugin.o \
-$(INSTALLDIR)/modules/entity.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
+$(INSTALLDIR)/modules/entity.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) -Ilibs -Iinclude
$(INSTALLDIR)/modules/entity.$(DLL): \
- plugins/entity/angle.o \
- plugins/entity/angles.o \
- plugins/entity/colour.o \
plugins/entity/doom3group.o \
plugins/entity/eclassmodel.o \
plugins/entity/entity.o \
plugins/entity/group.o \
plugins/entity/light.o \
plugins/entity/miscmodel.o \
- plugins/entity/model.o \
- plugins/entity/modelskinkey.o \
- plugins/entity/namedentity.o \
- plugins/entity/origin.o \
plugins/entity/plugin.o \
- plugins/entity/rotation.o \
- plugins/entity/scale.o \
plugins/entity/skincache.o \
plugins/entity/targetable.o \
plugins/image/dds.o \
plugins/image/image.o \
plugins/image/jpeg.o \
+ plugins/image/ktx.o \
plugins/image/pcx.o \
plugins/image/tga.o \
libddslib.$(A) \
+ libetclib.$(A) \
$(INSTALLDIR)/modules/imageq2.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
$(INSTALLDIR)/modules/imageq2.$(DLL): \
$(INSTALLDIR)/modules/imagepng.$(DLL): \
plugins/imagepng/plugin.o \
-$(INSTALLDIR)/modules/mapq3.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
+$(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 \
plugins/mapq3/plugin.o \
contrib/ufoaiplug/ufoai_level.o \
contrib/ufoaiplug/ufoai.o \
-$(INSTALLDIR)/plugins/meshtex.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
-$(INSTALLDIR)/plugins/meshtex.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
-$(INSTALLDIR)/plugins/meshtex.$(DLL): \
- contrib/meshtex/GeneralFunctionDialog.o \
- contrib/meshtex/GenericDialog.o \
- contrib/meshtex/GenericMainMenu.o \
- contrib/meshtex/GenericPluginUI.o \
- contrib/meshtex/GetInfoDialog.o \
- contrib/meshtex/MainMenu.o \
- contrib/meshtex/MeshEntity.o \
- contrib/meshtex/MeshVisitor.o \
- contrib/meshtex/PluginModule.o \
- contrib/meshtex/PluginRegistration.o \
- contrib/meshtex/PluginUI.o \
- contrib/meshtex/RefCounted.o \
- contrib/meshtex/SetScaleDialog.o \
-
$(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
$(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
$(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): \
.PHONY: install-data
install-data: binaries
$(MKDIR) $(INSTALLDIR)/games
- $(FIND) $(INSTALLDIR_BASE)/ -name .svn -exec $(RM_R) {} \; -prune
- [ "$(OS)" != "Darwin" ] || $(CP_R) setup/data/osx/NetRadiant.app/* $(INSTALLDIR_BASE)/NetRadiant.app/
- 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)"
- $(ECHO) $(RADIANT_MINOR_VERSION) > $(INSTALLDIR)/RADIANT_MINOR
+ 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)
install-dll: binaries
MKDIR="$(MKDIR)" CP="$(CP)" CAT="$(CAT)" GTKDIR="$(GTKDIR)" WHICHDLL="$(WHICHDLL)" INSTALLDIR="$(INSTALLDIR)" $(SH) $(DLLINSTALL)
else
-ifeq ($(OS),Darwin)
-install-dll: binaries
- EXE="$(EXE)" MACLIBDIR="$(MACLIBDIR)" CP="$(CP)" OTOOL="$(OTOOL)" INSTALLDIR="$(INSTALLDIR)" $(SH) install-dylibs.sh
-else
install-dll: binaries
@$(ECHO) No DLL inclusion implemented for this target.
endif
-endif
# release building... NOT for general users
# these may use tools not in the list that is checked by the build system
--- /dev/null
+NetRadiant
+==========
+
+![NetRadiant logo](setup/data/tools/bitmaps/splash.png)
+
+The open source, cross platform level editor for idtech games (Radiant fork).
+
+# Getting the Sources
+
+The latest source is available from the git repository:
+https://gitlab.com/xonotic/netradiant.git
+
+The git client can be obtained from the Git website:
+http://git-scm.org
+
+To get a copy of the source using the command line git client:
+
+```
+git clone --recursive https://gitlab.com/xonotic/netradiant.git
+cd netradiant
+```
+
+See also https://gitlab.com/xonotic/netradiant/ for a source browser, issues and more.
+
+# Dependencies
+
+ * OpenGL
+ * LibXml2
+ * GTK2
+ * GtkGLExt
+ * LibJpeg
+ * LibPng
+ * LibWebp
+ * Minizip
+ * ZLib
+
+## msys2
+
+Under MSYS2, the mingw shell must be used
+
+### 32 bit:
+
+```
+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,libwebp}
+```
+
+## OS X:
+
+```
+brew install gtkglext
+brew install webp
+brew install Caskroom/cask/xquartz
+brew link --force gettext
+```
+
+# Submodules
+
+ * Crunch (optional, disabled by default, only supported with CMake build)
+
+If you have not used `--recursive` option at `git clone` time, you can fetch Crunch this way (run it within the NetRadiant repository):
+
+
+```
+git submodule update --init --recursive
+```
+
+# Compiling
+
+This project uses the usual CMake workflow:
+
+## Debug
+
+```
+cmake -G "Unix Makefiles" -H. -Bbuild && cmake --build build -- -j$(nproc)
+```
+
+## Release
+
+```
+cmake -G "Unix Makefiles" -H. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build -- -j$(nproc)
+```
+
+## More Compilation Details
+
+options:
+
+ * `DOWNLOAD_GAMEPACKS=ON`
+ Automatically download the gamepack data during the first compilation
+ * `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)
+ * `game_packs` Downloads the game pack data
+ * `quake3` Compiles all the Quake3 tools
+ - `q3map2` Quake3 map compiler
+ - `q3data`
+
+## Note about Crunch
+
+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
-[-z-]: make rotate dialog non-modal
-
-
-
-BUGS
-
-MSI: installer bug with new folders? : create custom dir, click New Folder icon, type "FOLDER\" - gets stuck
-GTK2: gtk2 crashes when trying to use bitmap fonts such as MS Sans Serif http://bugzilla.gnome.org/show_bug.cgi?id=142579
-GTK2: alt+tab while mouse button is held down: see http://bugzilla.gnome.org/show_bug.cgi?id=145156
-UI: changing resolution in floating-windows mode can screw up window positions.
-HalfLife: half-life maps saved in q1 map format are not supported - currently have to convert them to hammer map format using hammer editor. And vice versa.
-Entity: creating a new entity with all the brushes of another entity selected results in the latter entity having no brushes.
-SConscript: build fails if SETUP=1
-SConscript: svn.py fails if not using C locale - set LC_ALL?
-GUI: can't use arrow keys to navigate in camera view when capslock is enabled
-GUI: screensaver causes: gdkgc-win32.c: line 905 (gdk_win32_hdc_get): assertion failed: (win32_gc->hdc == NULL)
-
-
-FEATURES
-
-- paint-select or equivalent (e.g. area-selection with occlusion)
-- select-complete-tall or equivalent (e.g. subtract-from-selection modifier key)
-- texture pane names are often illegible, becuase 1. they are long and overlap each other and 2. they overlap the outline rectangles around the images themselves.
-
-
-Build: document build-menu xml format.
-The build menu in GtkRadiant 1.5 is entirely customisable - you can make it run qbsp3/qvis3/arghrad or any tool you want. Use 'Build > Customize...' to edit the menu.
-
-Menu commands are the shell commands that Radiant will execute when you choose the menu item. You can add as many commands as you want to a single menu item, and they will be executed in sequence. The commands contain variables, specified using []. The values of variables will be substituted when the command is executed.
-
-For example:
-<pre>[q2map] -bsp "[MapFile]"</pre>
-becomes:
-<pre>"C:\Program Files\GtkRadiant 1.5.0\q2map" -fs_basepath "c:\quake2" -bsp "c:\quake2\baseq2\maps\blah.map"</pre>
-This uses the predefined variable 'MapFile' and the custom variable 'q2map'. 'q2map' is defined in the XML file, and 'MapFile' is the full path to your map.
-The 'MapFile' variable is enclosed in quotes, because the path to your map may contain spaces.
-At the moment you can only create custom variables by editing the XML file. A custom variable for arghrad would look something like this:
-<pre><var name="arghrad">"[RadiantPath]arghrad"</var></pre>
-This variable could then be used in a command like this:
-<pre>[arghrad] "[MapFile]"</pre>
-
-Entity: option to filter non-world entities (e.g. not func_group or func_static)
-Rotate Tool: if more than one object is selected, with different local orientations, use parent-space rotation pivot instead of local-space
-Brush: MMB+ctrl to paint texture on whole brush/patch.
-Camera: add alternative highlighting styles (used to be J).
-Doom3: filter func_splinemovers
-Entity: draw arrowheads to show direction of connection-lines.
-? MMB to select a texture should also apply that texture to all selected faces.
-Mouse: support 2-button mouse.
-Grid: background colour should be different when the smallest grid is invisible due to being zoomed out.
-Brush: option to disable dots on selected faces when not in face mode.
-Entity: draw direction arrow for func_door and func_button angle.
-Build Menu: support for editing variables.
-Shaders: handle doom3 materials with multiple bumpmaps stage - use first stage, ignore later stages.
-Brush: warn when a brush is dragged into a configuration with <0 volume
-Textures: add option to give new brushes a specific texture instead of the last selected.
-? QE-tool: click anywhere on xy view to drag entity instead of requiring clicking directly on entity.
-UserDocs: how to use multi-vertex selection - replaces vertex-edit-splits-faces option:
-UserDocs: how to use parent-selection:
- Parent-selection works like Maya: it allows you to 'reparent' brushes
- onto other entities than the one they're currently part of. To use it,
- select some brushes, select an entity, Edit -> Parent.
-Textures: add anisotropic filtering.
-Preferences: allow preference settings to be shared across games.
-Preferences: add colour 'theme' files using prefs format.
-Preferences: sensible default size for prefs window.
-Doom3: add model browser.
-Doom3: s_diversity light key.
-HalfLife: enable HL-mode on linux/osx.
-Renderer: doom3 'parallel' and 'spot' light support.
-Entity: add mouse-editing for doom3 light_center key
-Shaders: add support for texture transforms.
-Shaders: add support for 'addnormals' keyword - e.g. models/mapobjects/healthgui/healthguidirty
-TGA Loader: check that true-colour images with palettes are properly handled.
-Module System: reinstate 'refresh' feature.
-Surface Inspector: add button for 'axial' projection for doom3.
-Build: fix hardcoded engine-launch commands - use similar system to build-menu command description.
-Filters: use q2/heretic2 content flags to filter brushes.
-? Surface Inspector: allow material names not relative to 'textures/' for doom3
-Module System: add versioning for module-system api.
-svn: remove install/ dir, create it during build process on win32
-Editing: add option to choose the default startup tool mode.
-Renderer: lighting for doom3 materials without bumpmaps (e.g. mcity/mchangar2)
-Renderer: realtime doom3 materials preview
-Renderer: realtime doom3 shadows preview
-Linux: Provide .tar.gz of example-map data for et/wolf.
-Textures Window: add inner dark outline to distinguish 'is-shader' outline from white textures.
-HalfLife2: add HL2 map load/save.
-Selection: add move-pivot mode to allow rotation/scale around a custom pivot-point.
-Selection: add rotate increment for rotate manipulator.
-Selection: visibly distinguish between entity and brush selections
-Selection: need 'add to selection' and 'subtract from selection' modifiers
-Selection: Finish scale manipulator.
-FaceCopy/PasteTexture: Make face-copy/paste-texture shortcuts customisable.
-Manual: add documentation about search paths for .ent/.def/.fgd, shaders etc for each game.
-Halflife: add support for cstrike fgd.
-HalfLife: disable patches
-HalfLife: add HL .mdl model loader.
-HalfLife: add HL .spr support.
-HalfLife: support fgd 'flags' attributes.
-Model: add support for doom3 md5anim format
-Model: support doom3 ragdolls
-VFS: add ability to browse VFS from file-open dialogs.
-Installer: enable q3 brush-primitives map support.
-Installer: add editor manual to linux installer
-Map: add conversion between map formats
-Map: add conversion between entity definition formats
-Build: add build-menu dmap support (doom3)
-Entity: optionally draw target connection lines thicker than one pixel.
-Entity: add specialised attribute-entry in entity-inspector for integer/real/color attribute types.
-Patch: add cap-texture, fit-texture and natural-texture toolbar buttons
-Patch: draw patches in wireframe from the back, make patches selectable from the back
-Patch: add option for convert-selection-to-new-brush/patch
-Patch: fix bobtoolz merge-patches feature
-Patch: fix insert/remove rows/cols indicated by current selected patch vertices.
-Autosave/Snapshots: Add support for multi-file maps.
-Quake2: Q2 hint transparency support
-Shortcuts: make shortcut list editable within radiant.
-Shortcuts: convert shortcuts.ini to xml.
-Shortcuts: warn when duplicate shortcuts are registered
-Shortcuts: rename commands in order to group shortcuts list better.
-upgrade to new API for SymGetModuleInfo - required for compiling with Visual Studio 8.0
-Doom3: lights should stay in place while resizing
-
-
-LOW priority features
-
-Selection: Add shear manipulator?
-Textures Window: Improve texture-manipulation and texture-browsing tools.
-Undo: make selections undoable?
-Win32 Installer: Automatically upgrade existing installation.
-General: refactor game-specific hacks to be parameterised by .game file
-Patch: Overlays, Bend Mode, Thicken.
-Brush: Add brush-specific plugin API.
-Entity: Draw light style numbers.
-... Entity: Show models with model2 key.
-Entity: Interpret _remap* key (_MindLink_).
-Entity: Support _origin _angles _scale on groups.
-Selection: Add Primitive-mode shortcut key/button.
-Selection: Customisable manipulator size - +/- to change the size of the translate/rotate tool.
-Selection: Add optional screen-relative control for constrained rotations.
-Clipper: Change selection/manipulation to be consistent with other component editing.
-Filtering: Either deselect filtered nodes, or render filtered nodes that are selected.
-Filtering: Add customisable filter presets to set/unset multiple filters at once.
-Texdef: Make texdef formats abstract, add conversion between texdef formats (use generic affine-texture-matrix format for conversions).
-Textures Window: Precise display of texture size when selecting. (tooltip, possibly)
-Status: 'Size of brush' display on status bar.
-Colours: maya scheme default?
-Quake: add support for adjusting gamma on quake palette?
--- /dev/null
+[-z-]: make rotate dialog non-modal
+
+
+
+BUGS
+
+MSI: installer bug with new folders? : create custom dir, click New Folder icon, type "FOLDER\" - gets stuck
+GTK2: gtk2 crashes when trying to use bitmap fonts such as MS Sans Serif http://bugzilla.gnome.org/show_bug.cgi?id=142579
+GTK2: alt+tab while mouse button is held down: see http://bugzilla.gnome.org/show_bug.cgi?id=145156
+UI: changing resolution in floating-windows mode can screw up window positions.
+HalfLife: half-life maps saved in q1 map format are not supported - currently have to convert them to hammer map format using hammer editor. And vice versa.
+Entity: creating a new entity with all the brushes of another entity selected results in the latter entity having no brushes.
+SConscript: build fails if SETUP=1
+SConscript: svn.py fails if not using C locale - set LC_ALL?
+GUI: can't use arrow keys to navigate in camera view when capslock is enabled
+GUI: screensaver causes: gdkgc-win32.c: line 905 (gdk_win32_hdc_get): assertion failed: (win32_gc->hdc == NULL)
+
+
+FEATURES
+
+- paint-select or equivalent (e.g. area-selection with occlusion)
+- select-complete-tall or equivalent (e.g. subtract-from-selection modifier key)
+- texture pane names are often illegible, becuase 1. they are long and overlap each other and 2. they overlap the outline rectangles around the images themselves.
+
+
+Build: document build-menu xml format.
+The build menu in GtkRadiant 1.5 is entirely customisable - you can make it run qbsp3/qvis3/arghrad or any tool you want. Use 'Build > Customize...' to edit the menu.
+
+Menu commands are the shell commands that Radiant will execute when you choose the menu item. You can add as many commands as you want to a single menu item, and they will be executed in sequence. The commands contain variables, specified using []. The values of variables will be substituted when the command is executed.
+
+For example:
+<pre>[q2map] -bsp "[MapFile]"</pre>
+becomes:
+<pre>"C:\Program Files\GtkRadiant 1.5.0\q2map" -fs_basepath "c:\quake2" -bsp "c:\quake2\baseq2\maps\blah.map"</pre>
+This uses the predefined variable 'MapFile' and the custom variable 'q2map'. 'q2map' is defined in the XML file, and 'MapFile' is the full path to your map.
+The 'MapFile' variable is enclosed in quotes, because the path to your map may contain spaces.
+At the moment you can only create custom variables by editing the XML file. A custom variable for arghrad would look something like this:
+<pre><var name="arghrad">"[RadiantPath]arghrad"</var></pre>
+This variable could then be used in a command like this:
+<pre>[arghrad] "[MapFile]"</pre>
+
+Entity: option to filter non-world entities (e.g. not func_group or func_static)
+Rotate Tool: if more than one object is selected, with different local orientations, use parent-space rotation pivot instead of local-space
+Brush: MMB+ctrl to paint texture on whole brush/patch.
+Camera: add alternative highlighting styles (used to be J).
+Doom3: filter func_splinemovers
+Entity: draw arrowheads to show direction of connection-lines.
+? MMB to select a texture should also apply that texture to all selected faces.
+Mouse: support 2-button mouse.
+Grid: background colour should be different when the smallest grid is invisible due to being zoomed out.
+Brush: option to disable dots on selected faces when not in face mode.
+Entity: draw direction arrow for func_door and func_button angle.
+Build Menu: support for editing variables.
+Shaders: handle doom3 materials with multiple bumpmaps stage - use first stage, ignore later stages.
+Brush: warn when a brush is dragged into a configuration with <0 volume
+Textures: add option to give new brushes a specific texture instead of the last selected.
+? QE-tool: click anywhere on xy view to drag entity instead of requiring clicking directly on entity.
+UserDocs: how to use multi-vertex selection - replaces vertex-edit-splits-faces option:
+UserDocs: how to use parent-selection:
+ Parent-selection works like Maya: it allows you to 'reparent' brushes
+ onto other entities than the one they're currently part of. To use it,
+ select some brushes, select an entity, Edit -> Parent.
+Textures: add anisotropic filtering.
+Preferences: allow preference settings to be shared across games.
+Preferences: add colour 'theme' files using prefs format.
+Preferences: sensible default size for prefs window.
+Doom3: add model browser.
+Doom3: s_diversity light key.
+HalfLife: enable HL-mode on linux/osx.
+Renderer: doom3 'parallel' and 'spot' light support.
+Entity: add mouse-editing for doom3 light_center key
+Shaders: add support for texture transforms.
+Shaders: add support for 'addnormals' keyword - e.g. models/mapobjects/healthgui/healthguidirty
+TGA Loader: check that true-colour images with palettes are properly handled.
+Module System: reinstate 'refresh' feature.
+Surface Inspector: add button for 'axial' projection for doom3.
+Build: fix hardcoded engine-launch commands - use similar system to build-menu command description.
+Filters: use q2/heretic2 content flags to filter brushes.
+? Surface Inspector: allow material names not relative to 'textures/' for doom3
+Module System: add versioning for module-system api.
+svn: remove install/ dir, create it during build process on win32
+Editing: add option to choose the default startup tool mode.
+Renderer: lighting for doom3 materials without bumpmaps (e.g. mcity/mchangar2)
+Renderer: realtime doom3 materials preview
+Renderer: realtime doom3 shadows preview
+Linux: Provide .tar.gz of example-map data for et/wolf.
+Textures Window: add inner dark outline to distinguish 'is-shader' outline from white textures.
+HalfLife2: add HL2 map load/save.
+Selection: add move-pivot mode to allow rotation/scale around a custom pivot-point.
+Selection: add rotate increment for rotate manipulator.
+Selection: visibly distinguish between entity and brush selections
+Selection: need 'add to selection' and 'subtract from selection' modifiers
+Selection: Finish scale manipulator.
+FaceCopy/PasteTexture: Make face-copy/paste-texture shortcuts customisable.
+Manual: add documentation about search paths for .ent/.def/.fgd, shaders etc for each game.
+Halflife: add support for cstrike fgd.
+HalfLife: disable patches
+HalfLife: add HL .mdl model loader.
+HalfLife: add HL .spr support.
+HalfLife: support fgd 'flags' attributes.
+Model: add support for doom3 md5anim format
+Model: support doom3 ragdolls
+VFS: add ability to browse VFS from file-open dialogs.
+Installer: enable q3 brush-primitives map support.
+Installer: add editor manual to linux installer
+Map: add conversion between map formats
+Map: add conversion between entity definition formats
+Build: add build-menu dmap support (doom3)
+Entity: optionally draw target connection lines thicker than one pixel.
+Entity: add specialised attribute-entry in entity-inspector for integer/real/color attribute types.
+Patch: add cap-texture, fit-texture and natural-texture toolbar buttons
+Patch: draw patches in wireframe from the back, make patches selectable from the back
+Patch: add option for convert-selection-to-new-brush/patch
+Patch: fix bobtoolz merge-patches feature
+Patch: fix insert/remove rows/cols indicated by current selected patch vertices.
+Autosave/Snapshots: Add support for multi-file maps.
+Quake2: Q2 hint transparency support
+Shortcuts: make shortcut list editable within radiant.
+Shortcuts: convert shortcuts.ini to xml.
+Shortcuts: warn when duplicate shortcuts are registered
+Shortcuts: rename commands in order to group shortcuts list better.
+upgrade to new API for SymGetModuleInfo - required for compiling with Visual Studio 8.0
+Doom3: lights should stay in place while resizing
+
+
+LOW priority features
+
+Selection: Add shear manipulator?
+Textures Window: Improve texture-manipulation and texture-browsing tools.
+Undo: make selections undoable?
+Win32 Installer: Automatically upgrade existing installation.
+General: refactor game-specific hacks to be parameterised by .game file
+Patch: Overlays, Bend Mode, Thicken.
+Brush: Add brush-specific plugin API.
+Entity: Draw light style numbers.
+... Entity: Show models with model2 key.
+Entity: Interpret _remap* key (_MindLink_).
+Entity: Support _origin _angles _scale on groups.
+Selection: Add Primitive-mode shortcut key/button.
+Selection: Customisable manipulator size - +/- to change the size of the translate/rotate tool.
+Selection: Add optional screen-relative control for constrained rotations.
+Clipper: Change selection/manipulation to be consistent with other component editing.
+Filtering: Either deselect filtered nodes, or render filtered nodes that are selected.
+Filtering: Add customisable filter presets to set/unset multiple filters at once.
+Texdef: Make texdef formats abstract, add conversion between texdef formats (use generic affine-texture-matrix format for conversions).
+Textures Window: Precise display of texture size when selecting. (tooltip, possibly)
+Status: 'Size of brush' display on status bar.
+Colours: maya scheme default?
+Quake: add support for adjusting gamma on quake palette?
--- /dev/null
+platform: x64
+
+shallow_clone: true
+
+install:
+ - set "PATH=C:\msys64\usr\bin;%PATH%"
+ - bash -lc "pacman --noconfirm --needed -Sy bash pacman pacman-mirrors msys2-runtime msys2-runtime-devel"
+ - ps: >-
+ bash -lc @"
+ exec 0</dev/null 2>&1
+ pacman --noconfirm -Su
+ pacman --noconfirm --needed -S base-devel mingw-w64-x86_64-{toolchain,clang,cmake,gtk2,gtkglext}
+ "@
+
+build_script:
+ - set HOME=.
+ - set MSYSTEM=MINGW64
+ - ps: >-
+ bash -lc @"
+ set -e
+ exec 0</dev/null 2>&1
+ # export CC=clang
+ # export CXX=clang++
+ cmake --version
+ cmake -H. -Bbuild -G 'MSYS Makefiles' -DGTK2_GLIBCONFIG_INCLUDE_DIR=/mingw64/lib/glib-2.0/include -DGTK2_GDKCONFIG_INCLUDE_DIR=/mingw64/lib/gtk-2.0/include
+ cmake --build build
+ "@
--- /dev/null
+find_package(PkgConfig)
+if (PKG_CONFIG_FOUND)
+ if (GLIB_FIND_REQUIRED)
+ set(_pkgconfig_REQUIRED REQUIRED)
+ endif ()
+ pkg_check_modules(GLIB ${_pkgconfig_REQUIRED} glib-2.0)
+else ()
+ find_path(GLIB_INCLUDE_DIRS glib.h)
+ find_library(GLIB_LIBRARIES glib-2.0)
+ if (GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
+ set(GLIB_FOUND 1)
+ if (NOT GLIB_FIND_QUIETLY)
+ message(STATUS "Found GLIB: ${GLIB_LIBRARIES}")
+ endif ()
+ elseif (GLIB_FIND_REQUIRED)
+ message(SEND_ERROR "Could not find GLIB")
+ elseif (NOT GLIB_FIND_QUIETLY)
+ message(STATUS "Could not find GLIB")
+ endif ()
+endif ()
+mark_as_advanced(GLIB_INCLUDE_DIRS GLIB_LIBRARIES)
--- /dev/null
+find_package(PkgConfig)
+if (PKG_CONFIG_FOUND)
+ if (GTK2_FIND_REQUIRED)
+ set(_pkgconfig_REQUIRED REQUIRED)
+ endif ()
+ pkg_check_modules(GTK2 ${_pkgconfig_REQUIRED} gtk+-2.0)
+else ()
+ find_path(GTK2_INCLUDE_DIRS gtk.h)
+ # find_library(GTK2_LIBRARIES)
+ if (GTK2_INCLUDE_DIRS AND GTK2_LIBRARIES)
+ set(GTK2_FOUND 1)
+ if (NOT GTK2_FIND_QUIETLY)
+ message(STATUS "Found GTK2: ${GTK2_LIBRARIES}")
+ endif ()
+ elseif (GTK2_FIND_REQUIRED)
+ message(SEND_ERROR "Could not find GTK2")
+ elseif (NOT GTK2_FIND_QUIETLY)
+ message(STATUS "Could not find GTK2")
+ endif ()
+endif ()
+mark_as_advanced(GTK2_INCLUDE_DIRS GTK2_LIBRARIES)
--- /dev/null
+find_package(PkgConfig)
+if (PKG_CONFIG_FOUND)
+ if (GTK3_FIND_REQUIRED)
+ set(_pkgconfig_REQUIRED REQUIRED)
+ endif ()
+ pkg_check_modules(GTK3 ${_pkgconfig_REQUIRED} gtk+-3.0)
+else ()
+ find_path(GTK3_INCLUDE_DIRS gtk.h)
+ # find_library(GTK3_LIBRARIES)
+ if (GTK3_INCLUDE_DIRS AND GTK3_LIBRARIES)
+ set(GTK3_FOUND 1)
+ if (NOT GTK3_FIND_QUIETLY)
+ message(STATUS "Found GTK3: ${GTK3_LIBRARIES}")
+ endif ()
+ elseif (GTK3_FIND_REQUIRED)
+ message(SEND_ERROR "Could not find GTK3")
+ elseif (NOT GTK3_FIND_QUIETLY)
+ message(STATUS "Could not find GTK3")
+ endif ()
+endif ()
+mark_as_advanced(GTK3_INCLUDE_DIRS GTK3_LIBRARIES)
--- /dev/null
+find_package(PkgConfig)
+if (PKG_CONFIG_FOUND)
+ if (GtkGLExt_FIND_REQUIRED)
+ set(_pkgconfig_REQUIRED REQUIRED)
+ endif ()
+ if (XWINDOWS)
+ pkg_check_modules(GtkGLExt ${_pkgconfig_REQUIRED} gtkglext-x11-1.0)
+ elseif (WIN32)
+ pkg_check_modules(GtkGLExt ${_pkgconfig_REQUIRED} gtkglext-win32-1.0)
+ else ()
+ pkg_check_modules(GtkGLExt ${_pkgconfig_REQUIRED} gtkglext-quartz-1.0)
+ endif ()
+else ()
+ find_path(GtkGLExt_INCLUDE_DIRS gtkglwidget.h)
+ # find_library(GtkGLExt_LIBRARIES)
+ if (GtkGLExt_INCLUDE_DIRS AND GtkGLExt_LIBRARIES)
+ set(GtkGLExt_FOUND 1)
+ if (NOT GtkGLExt_FIND_QUIETLY)
+ message(STATUS "Found GtkGLExt: ${GtkGLExt_LIBRARIES}")
+ endif ()
+ elseif (GtkGLExt_FIND_REQUIRED)
+ message(SEND_ERROR "Could not find GtkGLExt")
+ elseif (NOT GtkGLExt_FIND_QUIETLY)
+ message(STATUS "Could not find GtkGLExt")
+ endif ()
+endif ()
+mark_as_advanced(GtkGLExt_INCLUDE_DIRS GtkGLExt_LIBRARIES)
--- /dev/null
+find_package(PkgConfig)
+if (PKG_CONFIG_FOUND)
+ if (Minizip_FIND_REQUIRED)
+ set(_pkgconfig_REQUIRED REQUIRED)
+ endif ()
+ pkg_check_modules(Minizip ${_pkgconfig_REQUIRED} minizip)
+else ()
+ find_path(Minizip_INCLUDE_DIRS unzip.h)
+ # find_library(Minizip_LIBRARIES)
+ if (Minizip_INCLUDE_DIRS AND Minizip_LIBRARIES)
+ set(Minizip_FOUND 1)
+ if (NOT Minizip_FIND_QUIETLY)
+ message(STATUS "Found Minizip: ${Minizip_LIBRARIES}")
+ endif ()
+ elseif (Minizip_FIND_REQUIRED)
+ message(SEND_ERROR "Could not find Minizip")
+ elseif (NOT Minizip_FIND_QUIETLY)
+ message(STATUS "Could not find Minizip")
+ endif ()
+endif ()
+mark_as_advanced(Minizip_INCLUDE_DIRS Minizip_LIBRARIES)
--- /dev/null
+find_package(PkgConfig)
+if (PKG_CONFIG_FOUND)
+ if (Pango_FIND_REQUIRED)
+ set(_pkgconfig_REQUIRED REQUIRED)
+ endif ()
+ pkg_search_module(Pango ${_pkgconfig_REQUIRED} pango pangocairo)
+ pkg_search_module(PangoFT2 ${_pkgconfig_REQUIRED} pangoft2)
+else ()
+ # find_path(Pango_INCLUDE_DIRS)
+ # find_library(Pango_LIBRARIES)
+ if (Pango_INCLUDE_DIRS AND Pango_LIBRARIES)
+ set(Pango_FOUND 1)
+ if (NOT Pango_FIND_QUIETLY)
+ message(STATUS "Found Pango: ${Pango_LIBRARIES}")
+ endif ()
+ elseif (Pango_FIND_REQUIRED)
+ message(SEND_ERROR "Could not find Pango")
+ elseif (NOT Pango_FIND_QUIETLY)
+ message(STATUS "Could not find Pango")
+ endif ()
+endif ()
+mark_as_advanced(Pango_INCLUDE_DIRS Pango_LIBRARIES)
+mark_as_advanced(PangoFT2_INCLUDE_DIRS PangoFT2_LIBRARIES)
--- /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
+set(CPACK_PACKAGE_NAME "NetRadiant")
+set(CPACK_PACKAGE_VERSION_MAJOR "${NetRadiant_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${NetRadiant_VERSION_MINOR}")
+set(CPACK_PACKAGE_VERSION_PATCH "${NetRadiant_VERSION_PATCH}")
+
+# binary: --target package
+set(CPACK_GENERATOR "ZIP")
+set(CPACK_STRIP_FILES 1)
+
+# source: --target package_source
+set(CPACK_SOURCE_GENERATOR "ZIP")
+set(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;/build/;/install/")
+
+# configure
+include(InstallRequiredSystemLibraries)
+include(CPack)
--- /dev/null
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/plugins")
+
+add_custom_target(plugins)
+macro(radiant_plugin name)
+ message(STATUS "Found Plugin ${name}")
+ add_library(${name} MODULE ${ARGN})
+ add_dependencies(plugins ${name})
+ copy_dlls(${name})
+ install(
+ TARGETS ${name}
+ LIBRARY DESTINATION plugins
+ )
+endmacro()
+
+add_subdirectory(bobtoolz)
+add_subdirectory(brushexport)
+add_subdirectory(prtview)
+add_subdirectory(shaderplug)
+add_subdirectory(sunplug)
+add_subdirectory(ufoaiplug)
// spaces to make label nice and big
#define NO_FILE_MSG " (no file loaded) "
-static GtkWidget *pDialogWnd;
+static ui::Window pDialogWnd{ui::null};
static GtkWidget *pNotebook;
static GtkTooltips *pTooltips;
private:
GtkWidget *m_pWidget;
GtkWidget *m_pTabLabel;
-GtkWidget *m_pFileLabel;
+ui::Label m_pFileLabel;
GtkWidget *m_pPosLabel;
VIEWTYPE m_vt;
bool m_bValidFile;
if ( m_pImage->Load( newfile ) ) {
m_bValidFile = true;
- gtk_label_set_text( GTK_LABEL( m_pFileLabel ),newfile );
+ m_pFileLabel.text(newfile);
}
}
// TODO no snprintf ?
sprintf( s, "Size/Position (%d,%d) (%d,%d)",(int)( m_pImage->m_xmin ),
(int)( m_pImage->m_ymin ),(int)( m_pImage->m_xmax ),(int)( m_pImage->m_ymax ) );
- gtk_label_set_text( GTK_LABEL( m_pPosLabel ),s );
+ m_pPosLabel.text(s);
}
CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){
- GtkWidget *frame;
- GtkWidget *hbox;
GtkWidget *w;
m_vt = vt;
switch ( m_vt )
{
case XY:
- m_pTabLabel = gtk_label_new( "X/Y" );
+ m_pTabLabel = ui::Label( "X/Y" );
m_pImage = &backgroundXY;
break;
case XZ:
- m_pTabLabel = gtk_label_new( "X/Z" );
+ m_pTabLabel = ui::Label( "X/Z" );
m_pImage = &backgroundXZ;
break;
case YZ:
- m_pTabLabel = gtk_label_new( "Y/Z" );
+ m_pTabLabel = ui::Label( "Y/Z" );
m_pImage = &backgroundYZ;
break;
}
// A vbox to hold everything
- m_pWidget = gtk_vbox_new( FALSE,0 );
+ m_pWidget = ui::VBox( FALSE,0 );
// Frame for file row
- frame = gtk_frame_new( "File" );
- gtk_box_pack_start( GTK_BOX( m_pWidget ),frame, FALSE, FALSE, 2 );
+ auto frame = ui::Frame( "File" );
+ m_pWidget.pack_start(frame, FALSE, FALSE, 2 );
// hbox for first row
- hbox = gtk_hbox_new( FALSE,5 );
+ auto hbox = ui::HBox( FALSE,5 );
gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 );
- gtk_container_add( GTK_CONTAINER( frame ), hbox );
+ frame.add(hbox);
// label to display filename
- m_pFileLabel = gtk_label_new( NO_FILE_MSG );
+ m_pFileLabel = ui::Label( NO_FILE_MSG );
gtk_label_set_selectable( GTK_LABEL( m_pFileLabel ),TRUE );
//TODO set min size ? done with spaces right now
- gtk_box_pack_start( GTK_BOX( hbox ),m_pFileLabel, TRUE, TRUE, 5 );
+ hbox.pack_start(m_pFileLabel, TRUE, TRUE, 5 );
- gtk_widget_show( m_pFileLabel );
+ m_pFileLabel.show();
- w = gtk_button_new_with_label( "Browse..." );
- g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( browse_callback ),
- ( gpointer ) this );
- gtk_box_pack_start( GTK_BOX( hbox ),w, FALSE, FALSE, 5 );
+ w = ui::Button( "Browse..." );
+ w.connect( "clicked", G_CALLBACK( browse_callback ), ( gpointer ) this );
+ hbox.pack_start(w, FALSE, FALSE, 5 );
gtk_tooltips_set_tip( pTooltips, w, "Select a file", NULL );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Reload" );
- g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( reload_callback ),
- ( gpointer ) this );
+ w = ui::Button( "Reload" );
+ w.connect( "clicked", G_CALLBACK( reload_callback ), ( gpointer ) this );
// TODO disable until we have file
// gtk_widget_set_sensitive(w,FALSE);
gtk_tooltips_set_tip( pTooltips, w, "Reload current file", NULL );
- gtk_box_pack_start( GTK_BOX( hbox ),w, FALSE, FALSE, 5 );
- gtk_widget_show( w );
+ hbox.pack_start(w, FALSE, FALSE, 5 );
+ w.show();
- gtk_widget_show( hbox );
- gtk_widget_show( frame );
+ hbox.show();
+ frame.show();
// second row (rendering options)
- frame = gtk_frame_new( "Rendering" );
- gtk_box_pack_start( GTK_BOX( m_pWidget ),frame, FALSE, FALSE, 2 );
+ frame = ui::Frame( "Rendering" );
+ m_pWidget.pack_start(frame, FALSE, FALSE, 2 );
- hbox = gtk_hbox_new( FALSE,5 );
+ hbox = ui::HBox( FALSE,5 );
gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 );
- gtk_container_add( GTK_CONTAINER( frame ), hbox );
+ frame.add(hbox);
- w = gtk_label_new( "Vertex alpha:" );
- gtk_box_pack_start( GTK_BOX( hbox ),w, FALSE, FALSE, 5 );
- gtk_widget_show( w );
+ w = ui::Label( "Vertex alpha:" );
+ hbox.pack_start(w, FALSE, FALSE, 5 );
+ w.show();
- w = gtk_hscale_new_with_range( 0.0,1.0,0.01 );
+ w = ui::HScale( 0.0, 1.0, 0.01 );
gtk_range_set_value( GTK_RANGE( w ),0.5 );
gtk_scale_set_value_pos( GTK_SCALE( w ),GTK_POS_LEFT );
- g_signal_connect( G_OBJECT( w ), "value-changed",
- G_CALLBACK( alpha_adjust_callback ), ( gpointer ) this );
- gtk_box_pack_start( GTK_BOX( hbox ),w, TRUE, TRUE, 5 );
+ w.connect( "value-changed", G_CALLBACK( alpha_adjust_callback ), ( gpointer ) this );
+ hbox.pack_start(w, TRUE, TRUE, 5 );
gtk_tooltips_set_tip( pTooltips, w, "Set image transparancy", NULL );
- gtk_widget_show( w );
+ w.show();
- gtk_widget_show( hbox );
- gtk_widget_show( frame );
+ hbox.show();
+ frame.show();
// Third row (size and position)
- frame = gtk_frame_new( "Size/Position (undefined)" );
+ frame = ui::Frame( "Size/Position (undefined)" );
m_pPosLabel = gtk_frame_get_label_widget( GTK_FRAME( frame ) );
- gtk_box_pack_start( GTK_BOX( m_pWidget ), frame, FALSE, FALSE, 2 );
+ m_pWidget.pack_start( frame, FALSE, FALSE, 2 );
- hbox = gtk_hbox_new( FALSE,5 );
- gtk_container_add( GTK_CONTAINER( frame ), hbox );
+ hbox = ui::HBox( FALSE,5 );
+ frame.add(hbox);
gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 );
- w = gtk_button_new_with_label( "from selection" );
- gtk_box_pack_start( GTK_BOX( hbox ),w, TRUE, FALSE, 5 );
- g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( size_sel_callback ),
- ( gpointer ) this );
+ w = ui::Button( "from selection" );
+ hbox.pack_start(w, TRUE, FALSE, 5 );
+ w.connect( "clicked", G_CALLBACK( size_sel_callback ), ( gpointer ) this );
gtk_tooltips_set_tip( pTooltips, w, "Set the size of the image to the bounding rectangle of all selected brushes and entities", NULL );
- gtk_widget_show( w );
+ w.show();
if ( m_vt == XY ) {
- w = gtk_button_new_with_label( "from map mins/maxs" );
- gtk_box_pack_start( GTK_BOX( hbox ),w, TRUE, FALSE, 2 );
- g_signal_connect( G_OBJECT( w ), "clicked", G_CALLBACK( size_mm_callback ),
- ( gpointer ) this );
+ w = ui::Button( "from map mins/maxs" );
+ hbox.pack_start(w, TRUE, FALSE, 2 );
+ w.connect( "clicked", G_CALLBACK( size_mm_callback ), ( gpointer ) this );
gtk_tooltips_set_tip( pTooltips, w, "Set the size of the image using the mapcoordsmins and mapcoordsmaxs keys of the worldspawn entity", NULL );
- gtk_widget_show( w );
+ w.show();
}
- gtk_widget_show( hbox );
- gtk_widget_show( frame );
+ hbox.show();
+ frame.show();
- gtk_widget_show( m_pWidget );
+ m_pWidget.show();
}
void CBackgroundDialogPage::Append( GtkWidget *notebook ){
CBackgroundDialogPage *pPage;
pDialogWnd = gtk_dialog_new_with_buttons( "Background Images",
- GTK_WINDOW( g_pMainWidget ),
+ g_pMainWidget,
(GtkDialogFlags)( GTK_DIALOG_DESTROY_WITH_PARENT ),
// TODO dialog with no buttons
// GTK_STOCK_CLOSE,
// GTK_RESPONSE_CLOSE,
NULL );
- gtk_signal_connect( GTK_OBJECT( pDialogWnd ), "delete_event",
- GTK_SIGNAL_FUNC( close_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( pDialogWnd ), "response",
- GTK_SIGNAL_FUNC( response_callback ), NULL );
-// gtk_signal_connect( GTK_OBJECT (pDialogWnd), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL );
+ pDialogWnd.connect( "delete_event", G_CALLBACK( close_callback ), NULL );
+ pDialogWnd.connect( "response", G_CALLBACK( response_callback ), NULL );
+// pDialogWnd.connect( "expose_event", G_CALLBACK( ci_expose ), NULL );
pTooltips = gtk_tooltips_new();
gtk_box_pack_start( GTK_BOX( GTK_DIALOG( pDialogWnd )->vbox ), pNotebook, TRUE, TRUE, 0 );
- gtk_widget_show( pNotebook );
+ pNotebook.show();
gtk_widget_realize( pDialogWnd );
}
void ShowBackgroundDialog(){
- gtk_window_present( GTK_WINDOW( pDialogWnd ) );
+ gtk_window_present( pDialogWnd );
}
void ShowBackgroundDialogPG( int page ){
--- /dev/null
+radiant_plugin(bobtoolz
+ dialogs/dialogs-gtk.cpp dialogs/dialogs-gtk.h
+
+ bobToolz.h
+ bobToolz-GTK.cpp
+ bsploader.cpp bsploader.h
+ cportals.cpp CPortals.h
+ ctfresource_gtk.h
+ DBobView.cpp DBobView.h
+ DBrush.cpp DBrush.h
+ DEntity.cpp DEntity.h
+ DEPair.cpp DEPair.h
+ DMap.cpp DMap.h
+ DPatch.cpp DPatch.h
+ DPlane.cpp DPlane.h
+ DPoint.cpp DPoint.h
+ DShape.cpp DShape.h
+ DTrainDrawer.cpp DTrainDrawer.h
+ DTreePlanter.cpp DTreePlanter.h
+ DVisDrawer.cpp DVisDrawer.h
+ DWinding.cpp DWinding.h
+ funchandlers-GTK.cpp
+ lists.cpp lists.h
+ misc.cpp misc.h
+ resource.h
+ resource-gtk.h
+ ScriptParser.cpp ScriptParser.h
+ shapes.cpp shapes.h
+ visfind.cpp visfind.h
+ )
+
+target_include_directories(bobtoolz PRIVATE uilib)
+target_link_libraries(bobtoolz PRIVATE uilib)
+
+target_include_directories(bobtoolz PRIVATE mathlib)
+target_link_libraries(bobtoolz PRIVATE mathlib)
path = pPath;
}
-#define LOCAL_GRAVITY -800.0f
+const float LOCAL_GRAVITY = -800.0f;
bool DBobView::CalculateTrajectory( vec3_t start, vec3_t apex, float multiplier, int points, float varGravity ){
if ( apex[2] <= start[2] ) {
globalErrorStream() << "bobToolz PathPlotter: Entity must have a targetname.\n";
}
return;
-}
\ No newline at end of file
+}
class DListener;
class Shader;
-#define BOUNDS_ALL 0
-#define BOUNDS_APEX 1
+const int BOUNDS_ALL = 0;
+const int BOUNDS_APEX = 1;
#if _MSC_VER > 1000
#pragma once
void valueChanged( const char* value ){
UpdatePath();
}
-typedef MemberCaller1<DBobView, const char*, &DBobView::valueChanged> ValueChangedCaller;
+typedef MemberCaller<DBobView, void(const char*), &DBobView::valueChanged> ValueChangedCaller;
void insert( const char* key, EntityKeyValue& value ){
value.attach( ValueChangedCaller( *this ) );
}
//////////////////////////////////////////////////////////////////////
#include "DBrush.h"
+#include "globaldefs.h"
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4786)
#endif
//////////////////////////////////////////////////////////////////////
DPlane* DBrush::AddFace( const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData ){
-#ifdef _DEBUG
+#if GDEF_DEBUG
// Sys_Printf("(%f %f %f) (%f %f %f) (%f %f %f)\n", va[0], va[1], va[2], vb[0], vb[1], vb[2], vc[0], vc[1], vc[2]);
#endif
bBoundsBuilt = false;
}
}
-#ifdef _DEBUG
+#if GDEF_DEBUG
// Sys_Printf("%i points on brush\n", pointList.size());
#endif
void DBrush_addFace( DBrush& brush, const _QERFaceData& faceData ){
brush.AddFace( vector3_to_array( faceData.m_p0 ), vector3_to_array( faceData.m_p1 ), vector3_to_array( faceData.m_p2 ), 0 );
}
-typedef ReferenceCaller1<DBrush, const _QERFaceData&, DBrush_addFace> DBrushAddFaceCaller;
+typedef ReferenceCaller<DBrush, void(const _QERFaceData&), DBrush_addFace> DBrushAddFaceCaller;
void DBrush_addFaceTextured( DBrush& brush, const _QERFaceData& faceData ){
brush.AddFace( vector3_to_array( faceData.m_p0 ), vector3_to_array( faceData.m_p1 ), vector3_to_array( faceData.m_p2 ), &faceData );
}
-typedef ReferenceCaller1<DBrush, const _QERFaceData&, DBrush_addFaceTextured> DBrushAddFaceTexturedCaller;
+typedef ReferenceCaller<DBrush, void(const _QERFaceData&), DBrush_addFaceTextured> DBrushAddFaceTexturedCaller;
void DBrush::LoadFromBrush( scene::Instance& brush, bool textured ){
ClearFaces();
class Instance;
}
-#define POINT_IN_BRUSH 0
-#define POINT_ON_BRUSH 1
-#define POINT_OUT_BRUSH 2
+const int POINT_IN_BRUSH = 0;
+const int POINT_ON_BRUSH = 1;
+const int POINT_OUT_BRUSH = 2;
class DBrush
{
//////////////////////////////////////////////////////////////////////
#include "DEntity.h"
+#include "globaldefs.h"
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4786)
#endif
{
for ( unsigned int k = 0; k < portals.node[i].portal[j].point_count - 2; k++ )
{
- vec3_t v1, v2, normal, n;
+ vec3_t v1{}, v2{}, normal{}, n{};
VectorSubtract( portals.node[i].portal[j].point[k + 2].p, portals.node[i].portal[j].point[k + 1].p, v1 );
VectorSubtract( portals.node[i].portal[j].point[k].p, portals.node[i].portal[j].point[k + 1].p, v2 );
CrossProduct( v1, v2, n );
DBrush* loadBrush = entity.NewBrush( static_cast<int>( entity.brushList.size() ) );
loadBrush->LoadFromBrush( brush, true );
}
-typedef ReferenceCaller1<DEntity, scene::Instance&, DEntity_loadBrush> DEntityLoadBrushCaller;
+
+typedef ReferenceCaller<DEntity, void ( scene::Instance & ), DEntity_loadBrush> DEntityLoadBrushCaller;
void DEntity::LoadSelectedBrushes(){
ClearBrushes();
DPatch* loadPatch = entity.NewPatch();
loadPatch->LoadFromPatch( patch );
}
-typedef ReferenceCaller1<DEntity, scene::Instance&, DEntity_loadPatch> DEntityLoadPatchCaller;
+
+typedef ReferenceCaller<DEntity, void ( scene::Instance & ), DEntity_loadPatch> DEntityLoadPatchCaller;
void DEntity::LoadSelectedPatches(){
ClearPatches();
load_brushes_t( DEntity* entity )
: m_entity( entity ), m_count( 0 ){
}
+
bool pre( scene::Node& node ) const {
scene::Path path( NodeReference( GlobalSceneGraph().root() ) );
path.push( NodeReference( *m_entity->QER_Entity ) );
}
}
-
-
int DEntity::GetIDMax( void ) {
int max = -1;
for ( std::list<DBrush *>::const_iterator cntBrush = brushList.begin(); cntBrush != brushList.end(); cntBrush++ ) {
ClearEntities();
}
-DEntity* DMap::AddEntity( char *classname, int ID ){
+DEntity* DMap::AddEntity( const char *classname, int ID ){
DEntity* newEntity;
if ( ID == -1 ) {
newEntity = new DEntity( classname, m_nNextEntity++ );
void ClearEntities();
DEntity* GetEntityForID( int ID );
-DEntity* AddEntity( char* classname = "worldspawn", int ID = -1 );
+DEntity* AddEntity( const char* classname = "worldspawn", int ID = -1 );
std::list<DEntity*> entityList;
int newHeight = p1->height + p2->height - 1;
if ( newHeight > MAX_PATCH_HEIGHT ) {
- return false;
+ return NULL;
}
DPatch* newPatch = new DPatch();
class Instance;
}
-#define MAX_PATCH_WIDTH 32
-#define MAX_PATCH_HEIGHT 32
-#define MIN_PATCH_WIDTH 3
-#define MIN_PATCH_HEIGHT 3
+const int MAX_PATCH_WIDTH = 32;
+const int MAX_PATCH_HEIGHT = 32;
+const int MIN_PATCH_WIDTH = 3;
+const int MIN_PATCH_HEIGHT = 3;
class DPatch
{
bool operator ==( DPlane& other );
bool IsRedundant( std::list<DPoint*>& pointList );
-bool PlaneIntersection( DPlane* pl1, DPlane* pl2, vec3_t out );;
+bool PlaneIntersection( DPlane* pl1, DPlane* pl2, vec3_t out );
vec_t DistanceToPoint( vec3_t pnt );
class DEntity;
// defines for polygon stuff
-#define MAX_POLYGON_FACES 128
+const int MAX_POLYGON_FACES = 128;
extern bool bFacesAll[];
#include "mathlib.h"
#include "misc.h"
-#define MAX_QPATH 64
+const int MAX_QPATH = 64;
typedef struct treeModel_s {
char name[MAX_QPATH];
} treeModel_t;
-#define MAX_TP_MODELS 256
+const int MAX_TP_MODELS = 256;
class DTreePlanter {
MouseEventHandlerId m_mouseDown;
SignalHandlerId m_destroyed;
public:
SignalHandlerResult mouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers );
-typedef Member3<DTreePlanter, const WindowVector&, ButtonIdentifier, ModifierFlags, SignalHandlerResult, &DTreePlanter::mouseDown> MouseDownCaller;
+typedef Member<DTreePlanter, SignalHandlerResult(const WindowVector&, ButtonIdentifier, ModifierFlags), &DTreePlanter::mouseDown> MouseDownCaller;
void destroyed(){
m_mouseDown = MouseEventHandlerId();
m_destroyed = SignalHandlerId();
}
-typedef Member<DTreePlanter, void, &DTreePlanter::destroyed> DestroyedCaller;
+typedef Member<DTreePlanter, void(), &DTreePlanter::destroyed> DestroyedCaller;
DTreePlanter() {
m_numModels = 0;
// Implementation
//////////////////////////////////////////////////////////////////////
-#define BOGUS_RANGE 4096
+const int BOGUS_RANGE = 4096;
void DWinding::AllocWinding( int points ){
numpoints = points;
vec3_t clr;
};
-#define MAX_POINTS_ON_WINDING 64
+const int MAX_POINTS_ON_WINDING = 64;
-#define ON_EPSILON 0.01
+const double ON_EPSILON = 0.01;
#endif // !defined(AFX_DWINDING_H__35B2C524_F0A7_11D4_ACF7_004095A18133__INCLUDED_)
return m_pToken;
}
-#define MAX_TOKEN_STRING 1024
+const int MAX_TOKEN_STRING = 1024;
// Should NEVER return NULL
const char* CScriptParser::GetToken( bool bAllowLinebreaks ) {
int c = 0, len;
//#include "interfaces/IScriptParser.h"
-#define SP_MAX_BREAKCHARS 16
+const int SP_MAX_BREAKCHARS = 16;
class CScriptParser //: public IScriptParser
{
+++ /dev/null
-/*
- BobToolz plugin for GtkRadiant
- Copyright (C) 2001 Gordon Biggans
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-// stdafx.cpp : source file that includes just the standard includes
-// plugin.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "StdAfx.h"
+++ /dev/null
-/*
- BobToolz plugin for GtkRadiant
- Copyright (C) 2001 Gordon Biggans
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __STDAFX_BOBTOOLZ__
-#define __STDAFX_BOBTOOLZ__
-
-
-
-#endif
}
// plugin name
-char* PLUGIN_NAME = "bobToolz";
+const char* PLUGIN_NAME = "bobToolz";
// commands in the menu
-static char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge";
-
-// globals
-GtkWidget *g_pRadiantWnd = NULL;
+static const char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge";
static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n"
"by digibob (digibob@splashdamage.com)\n"
"MarsMattel, RR2DO2\n";
extern "C" const char* QERPlug_Init( void* hApp, void* pMainWidget ) {
- g_pRadiantWnd = (GtkWidget*)pMainWidget;
+ g_pRadiantWnd = ui::Window::from(pMainWidget);
return "bobToolz for GTKradiant";
}
}
-#define NUM_TOOLBARBUTTONS 13
+const int NUM_TOOLBARBUTTONS = 13;
std::size_t ToolbarButtonCount( void ) {
return NUM_TOOLBARBUTTONS;
public:
BobToolzPluginDependencies() :
GlobalEntityModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entities" ) ),
+ GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ),
GlobalShadersModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "shaders" ) ),
GlobalBrushModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "brushtypes" ) ),
- GlobalPatchModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "patchtypes" ) ),
- GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ){
+ GlobalPatchModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "patchtypes" ) ){
}
};
-
#if !defined(INCLUDED_BOBTOOLZGTK_H)
#define INCLUDED_BOBTOOLZGTK_H
-extern GtkWidget *g_pRadiantWnd;
+#include <uilib/uilib.h>
+
+extern ui::Widget g_pRadiantWnd;
#endif
+#include <globaldefs.h>
#include "bsploader.h"
#include "dialogs/dialogs-gtk.h"
#include "cmdlib.h"
dbrushside_t *dbrushsides = NULL;
int *dleafbrushes = NULL;
-#define BSP_IDENT ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' )
-#define Q3_BSP_VERSION 46
-#define WOLF_BSP_VERSION 47
+const int BSP_IDENT = ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' );
+const int Q3_BSP_VERSION = 46;
+const int WOLF_BSP_VERSION = 47;
/*
================
}
int LittleLong( int l ){
-#if defined( __BIG_ENDIAN__ )
- std::reverse( reinterpret_cast<unsigned char*>( &l ), reinterpret_cast<unsigned char*>( &l ) + sizeof( int ) );
-#endif
+ if (GDEF_ARCH_ENDIAN_BIG) {
+ std::reverse(reinterpret_cast<unsigned char *>( &l ), reinterpret_cast<unsigned char *>( &l ) + sizeof(int));
+ }
return l;
}
float LittleFloat( float l ){
-#if defined( __BIG_ENDIAN__ )
- std::reverse( reinterpret_cast<unsigned char*>( &l ), reinterpret_cast<unsigned char*>( &l ) + sizeof( float ) );
-#endif
+ if (GDEF_ARCH_ENDIAN_BIG) {
+ std::reverse( reinterpret_cast<unsigned char*>( &l ), reinterpret_cast<unsigned char*>( &l ) + sizeof( float ) );
+ }
return l;
}
#include "mathlib.h"
-#define LUMP_ENTITIES 0
-#define LUMP_SHADERS 1
-#define LUMP_PLANES 2
-#define LUMP_NODES 3
-#define LUMP_LEAFS 4
-#define LUMP_LEAFSURFACES 5
-#define LUMP_LEAFBRUSHES 6
-#define LUMP_MODELS 7
-#define LUMP_BRUSHES 8
-#define LUMP_BRUSHSIDES 9
-#define LUMP_DRAWVERTS 10
-#define LUMP_DRAWINDEXES 11
-#define LUMP_FOGS 12
-#define LUMP_SURFACES 13
-#define LUMP_LIGHTMAPS 14
-#define LUMP_LIGHTGRID 15
-#define LUMP_VISIBILITY 16
-#define HEADER_LUMPS 17
+const int LUMP_ENTITIES = 0;
+const int LUMP_SHADERS = 1;
+const int LUMP_PLANES = 2;
+const int LUMP_NODES = 3;
+const int LUMP_LEAFS = 4;
+const int LUMP_LEAFSURFACES = 5;
+const int LUMP_LEAFBRUSHES = 6;
+const int LUMP_MODELS = 7;
+const int LUMP_BRUSHES = 8;
+const int LUMP_BRUSHSIDES = 9;
+const int LUMP_DRAWVERTS = 10;
+const int LUMP_DRAWINDEXES = 11;
+const int LUMP_FOGS = 12;
+const int LUMP_SURFACES = 13;
+const int LUMP_LIGHTMAPS = 14;
+const int LUMP_LIGHTGRID = 15;
+const int LUMP_VISIBILITY = 16;
+const int HEADER_LUMPS = 17;
typedef struct {
int fileofs, filelen;
MST_FLARE
} mapSurfaceType_t;
-#define MAX_MAP_VISIBILITY 0x200000
-#define MAX_MAP_NODES 0x20000
-#define MAX_MAP_PLANES 0x20000
-#define MAX_MAP_LEAFS 0x20000
+const int MAX_MAP_VISIBILITY = 0x200000;
+const int MAX_MAP_NODES = 0x20000;
+const int MAX_MAP_PLANES = 0x20000;
+const int MAX_MAP_LEAFS = 0x20000;
extern int numVisBytes;
extern int numleafs;
#include "misc.h"
-#define LINE_BUF 1000
-#define MSG_PREFIX "bobToolz plugin: "
+const int LINE_BUF = 1000;
+const char *MSG_PREFIX = "bobToolz plugin: ";
// these classes are far less of a mess than my code was,
// thanq to G.DeWan 4 the prtview source on which it was based
Purge();
- globalOutputStream() << MSG_PREFIX "Loading portal file " << fn << ".\n";
+ globalOutputStream() << MSG_PREFIX << "Loading portal file " << fn << ".\n";
FILE *in;
#include "../StdAfx.h"
#include "AboutDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-//static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CAboutDialog dialog
#include "../bobtoolz.h"
#include "AutoCaulkDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkDialog dialog
#include "../bobtoolz.h"
#include "AutoCaulkStartDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkStartDialog dialog
// AutoCaulkStartDialog.h : header file
//
-#define MODE_AC_NORMAL 0
-#define MODE_AC_BUILD_MINI_PRT 1
-#define MODE_AC_SUPER 2
+const int MODE_AC_NORMAL = 0;
+const int MODE_AC_BUILD_MINI_PRT = 1;
+const int MODE_AC_SUPER = 2;
/////////////////////////////////////////////////////////////////////////////
// CAutoCaulkStartDialog dialog
#include "../StdAfx.h"
#include "DoorDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CDoorDialog dialog
#include "../StdAfx.h"
#include "IntersectDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CIntersectDialog dialog
// IntersectDialog.h : header file
//
-#define BRUSH_OPT_WHOLE_MAP 0
-#define BRUSH_OPT_SELECTED 1
+const int BRUSH_OPT_WHOLE_MAP = 0;
+const int BRUSH_OPT_SELECTED = 1;
/////////////////////////////////////////////////////////////////////////////
// CIntersectDialog dialog
#include "../bobtoolz.h"
#include "IntersectInfoDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CIntersectInfoDialog dialog
#include "PolygonDialog.h"
#include "../shapes.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CPolygonDialog dialog
#include "../StdAfx.h"
#include "StairDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CStairDialog dialog
#include "../bobtoolz.h"
#include "TextureResetDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CTextureResetDialog dialog
#include "../bobtoolz.h"
#include "BrushCheckDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CBrushCheckDialog dialog
---------------------------------*/
typedef struct {
- GtkWidget *cbTexChange;
- GtkWidget *editTexOld, *editTexNew;
+ ui::Widget cbTexChange{ui::null};
+ ui::Widget editTexOld{ui::null}, editTexNew{ui::null};
- GtkWidget *cbScaleHor, *cbScaleVert;
- GtkWidget *editScaleHor, *editScaleVert;
+ ui::Widget cbScaleHor{ui::null}, cbScaleVert{ui::null};
+ ui::Widget editScaleHor{ui::null}, editScaleVert{ui::null};
- GtkWidget *cbShiftHor, *cbShiftVert;
- GtkWidget *editShiftHor, *editShiftVert;
+ ui::Widget cbShiftHor{ui::null}, cbShiftVert{ui::null};
+ ui::Widget editShiftHor{ui::null}, editShiftVert{ui::null};
- GtkWidget *cbRotation;
- GtkWidget *editRotation;
+ ui::Widget cbRotation{ui::null};
+ ui::Widget editRotation{ui::null};
}dlg_texReset_t;
dlg_texReset_t dlgTexReset;
void Update_TextureReseter();
-static void dialog_button_callback_texreset_update( GtkWidget *widget, gpointer data ){
+static void dialog_button_callback_texreset_update(ui::Widget widget, gpointer data ){
Update_TextureReseter();
}
gboolean check;
check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) );
- gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editTexNew ), check );
- gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editTexOld ), check );
+ gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editTexNew ), check );
+ gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editTexOld ), check );
check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
- gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editScaleHor ), check );
+ gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleHor ), check );
check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
- gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editScaleVert ), check );
+ gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleVert ), check );
check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
- gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editShiftHor ), check );
+ gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftHor ), check );
check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
- gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editShiftVert ), check );
+ gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftVert ), check );
check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
- gtk_entry_set_editable( GTK_ENTRY( dlgTexReset.editRotation ), check );
+ gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editRotation ), check );
}
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop;
EMessageBoxReturn *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (EMessageBoxReturn*)g_object_get_data( G_OBJECT( parent ), "ret" );
*ret = (EMessageBoxReturn)gpointer_to_int( data );
}
-static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
- int *loop;
-
- gtk_widget_hide( widget );
- loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" );
+static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
+ widget.hide();
+ int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
*loop = 0;
-
return TRUE;
}
-static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){
+static void dialog_button_callback_settex(ui::Widget widget, gpointer data ){
TwinWidget* tw = (TwinWidget*)data;
- GtkEntry* entry = GTK_ENTRY( tw->one );
- GtkCombo* combo = GTK_COMBO( tw->two );
+ auto entry = ui::Entry::from( tw->one );
+ auto combo = tw->two;
- const gchar* tex = gtk_entry_get_text( GTK_ENTRY( combo->entry ) );
+ const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo)));
gtk_entry_set_text( entry, tex );
}
Data validation Routines
---------------------------------*/
-bool ValidateTextFloat( const char* pData, char* error_title, float* value ){
+bool ValidateTextFloat( const char* pData, const char* error_title, float* value ){
if ( pData ) {
float testNum = (float)atof( pData );
return FALSE;
}
-bool ValidateTextFloatRange( const char* pData, float min, float max, char* error_title, float* value ){
+bool ValidateTextFloatRange( const char* pData, float min, float max, const char* error_title, float* value ){
char error_buffer[256];
sprintf( error_buffer, "Please Enter A Floating Point Number Between %.3f and %.3f", min, max );
return FALSE;
}
-bool ValidateTextIntRange( const char* pData, int min, int max, char* error_title, int* value ){
+bool ValidateTextIntRange( const char* pData, int min, int max, const char* error_title, int* value ){
char error_buffer[256];
sprintf( error_buffer, "Please Enter An Integer Between %i and %i", min, max );
return FALSE;
}
-bool ValidateTextInt( const char* pData, char* error_title, int* value ){
+bool ValidateTextInt( const char* pData, const char* error_title, int* value ){
if ( pData ) {
int testNum = atoi( pData );
*/
EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){
- GtkWidget *window, *w, *vbox, *hbox;
+ ui::Widget w{ui::null};
EMessageBoxReturn ret;
int loop = 1;
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto window = ui::Window( ui::window_type::TOP );
gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) );
- gtk_window_set_modal( GTK_WINDOW( window ), TRUE );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event",
- GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy",
- GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), lpCaption );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
+ gtk_window_set_title( window, lpCaption );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
- w = gtk_label_new( lpText );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
+ w = ui::Label( lpText );
+ vbox.pack_start( w, FALSE, FALSE, 2 );
gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
- gtk_widget_show( w );
+ w.show();
- w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
- gtk_widget_show( w );
+ w = ui::Widget::from(gtk_hseparator_new());
+ vbox.pack_start( w, FALSE, FALSE, 2 );
+ w.show();
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
if ( type == eMB_OK ) {
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ gtk_widget_set_can_default(w, true);
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
ret = eIDOK;
}
else if ( type == eMB_OKCANCEL ) {
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
}
else if ( type == eMB_YESNOCANCEL ) {
- w = gtk_button_new_with_label( "Yes" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Yes" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
-
- w = gtk_button_new_with_label( "No" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
- gtk_widget_show( w );
-
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w.show();
+
+ w = ui::Button( "No" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
+ w.show();
+
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
}
else /* if (mode == MB_YESNO) */
{
- w = gtk_button_new_with_label( "Yes" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Yes" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "No" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
- gtk_widget_show( w );
+ w = ui::Button( "No" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
+ w.show();
ret = eIDNO;
}
gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER_ON_PARENT );
- gtk_widget_show( window );
+ window.show();
gtk_grab_add( window );
while ( loop )
gtk_main_iteration();
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
}
EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
- GtkWidget *window, *w, *vbox, *hbox;
- GtkWidget *radio1, *radio2;
- GtkWidget *check1, *check2;
EMessageBoxReturn ret;
int loop = 1;
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto window = ui::Window( ui::window_type::TOP );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Intersect" );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ gtk_window_set_title( window, "Intersect" );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
// ---- vbox ----
- radio1 = gtk_radio_button_new_with_label( NULL, "Use Whole Map" );
- gtk_box_pack_start( GTK_BOX( vbox ), radio1, FALSE, FALSE, 2 );
- gtk_widget_show( radio1 );
+ auto radio1 = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Use Whole Map" ));
+ vbox.pack_start( radio1, FALSE, FALSE, 2 );
+ radio1.show();
- radio2 = gtk_radio_button_new_with_label( ( (GtkRadioButton*)radio1 )->group, "Use Selected Brushes" );
- gtk_box_pack_start( GTK_BOX( vbox ), radio2, FALSE, FALSE, 2 );
- gtk_widget_show( radio2 );
+ auto radio2 = ui::Widget::from(gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" ));
+ vbox.pack_start( radio2, FALSE, FALSE, 2 );
+ radio2.show();
- w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
- gtk_widget_show( w );
+ auto hsep = ui::Widget::from(gtk_hseparator_new());
+ vbox.pack_start( hsep, FALSE, FALSE, 2 );
+ hsep.show();
- check1 = gtk_check_button_new_with_label( "Include Detail Brushes" );
- gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 );
- gtk_widget_show( check1 );
+ auto check1 = ui::CheckButton( "Include Detail Brushes" );
+ vbox.pack_start( check1, FALSE, FALSE, 0 );
+ check1.show();
- check2 = gtk_check_button_new_with_label( "Select Duplicate Brushes Only" );
- gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 );
- gtk_widget_show( check2 );
+ auto check2 = ui::CheckButton( "Select Duplicate Brushes Only" );
+ vbox.pack_start( check2, FALSE, FALSE, 0 );
+ check2.show();
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
// ---- hbox ---- ok/cancel buttons
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ auto w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// ---- /hbox ----
// ---- /vbox ----
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
while ( loop )
gtk_main_iteration();
- if ( gtk_toggle_button_get_active( (GtkToggleButton*)radio1 ) ) {
+ if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radio1) ) ) {
rs->nBrushOptions = BRUSH_OPT_WHOLE_MAP;
}
- else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radio2 ) ) {
+ else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radio2) ) ) {
rs->nBrushOptions = BRUSH_OPT_SELECTED;
}
- rs->bUseDetail = gtk_toggle_button_get_active( (GtkToggleButton*)check1 ) ? true : false;
- rs->bDuplicateOnly = gtk_toggle_button_get_active( (GtkToggleButton*)check2 ) ? true : false;
+ rs->bUseDetail = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check1) ) ? true : false;
+ rs->bDuplicateOnly = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check2) ) ? true : false;
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
}
EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
- GtkWidget *window, *w, *vbox, *hbox, *vbox2, *hbox2;
-
- GtkWidget *check1, *check2, *check3;
- GtkWidget *text1, *text2;
-
EMessageBoxReturn ret;
int loop = 1;
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto window = ui::Window( ui::window_type::TOP );
gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Polygon Builder" );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ gtk_window_set_title( window, "Polygon Builder" );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
// ---- vbox ----
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
// ---- hbox ----
- vbox2 = gtk_vbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 );
- gtk_widget_show( vbox2 );
+ auto vbox2 = ui::VBox( FALSE, 10 );
+ hbox.pack_start( vbox2, FALSE, FALSE, 2 );
+ vbox2.show();
// ---- vbox2 ----
- hbox2 = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 );
- gtk_widget_show( hbox2 );
+ auto hbox2 = ui::HBox( FALSE, 10 );
+ vbox2.pack_start( hbox2, FALSE, FALSE, 2 );
+ hbox2.show();
// ---- hbox2 ----
- text1 = gtk_entry_new_with_max_length( 256 );
- gtk_entry_set_text( (GtkEntry*)text1, "3" );
- gtk_box_pack_start( GTK_BOX( hbox2 ), text1, FALSE, FALSE, 2 );
- gtk_widget_show( text1 );
+ auto text1 = ui::Entry( 256 );
+ gtk_entry_set_text( text1, "3" );
+ hbox2.pack_start( text1, FALSE, FALSE, 2 );
+ text1.show();
- w = gtk_label_new( "Number Of Sides" );
- gtk_box_pack_start( GTK_BOX( hbox2 ), w, FALSE, FALSE, 2 );
- gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
- gtk_widget_show( w );
+ auto l = ui::Label( "Number Of Sides" );
+ hbox2.pack_start( l, FALSE, FALSE, 2 );
+ gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT );
+ l.show();
// ---- /hbox2 ----
- hbox2 = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 );
- gtk_widget_show( hbox2 );
+ hbox2 = ui::HBox( FALSE, 10 );
+ vbox2.pack_start( hbox2, FALSE, FALSE, 2 );
+ hbox2.show();
// ---- hbox2 ----
- text2 = gtk_entry_new_with_max_length( 256 );
- gtk_entry_set_text( (GtkEntry*)text2, "8" );
- gtk_box_pack_start( GTK_BOX( hbox2 ), text2, FALSE, FALSE, 2 );
- gtk_widget_show( text2 );
+ auto text2 = ui::Entry( 256 );
+ gtk_entry_set_text( text2, "8" );
+ hbox2.pack_start( text2, FALSE, FALSE, 2 );
+ text2.show();
- w = gtk_label_new( "Border Width" );
- gtk_box_pack_start( GTK_BOX( hbox2 ), w, FALSE, FALSE, 2 );
- gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
- gtk_widget_show( w );
+ l = ui::Label( "Border Width" );
+ hbox2.pack_start( l, FALSE, FALSE, 2 );
+ gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT );
+ l.show();
// ---- /hbox2 ----
- vbox2 = gtk_vbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 );
- gtk_widget_show( vbox2 );
+ vbox2 = ui::VBox( FALSE, 10 );
+ hbox.pack_start( vbox2, FALSE, FALSE, 2 );
+ vbox2.show();
// ---- vbox2 ----
- check1 = gtk_check_button_new_with_label( "Use Border" );
- gtk_box_pack_start( GTK_BOX( vbox2 ), check1, FALSE, FALSE, 0 );
- gtk_widget_show( check1 );
+ auto check1 = ui::CheckButton( "Use Border" );
+ vbox2.pack_start( check1, FALSE, FALSE, 0 );
+ check1.show();
- check2 = gtk_check_button_new_with_label( "Inverse Polygon" );
- gtk_box_pack_start( GTK_BOX( vbox2 ), check2, FALSE, FALSE, 0 );
- gtk_widget_show( check2 );
+ auto check2 = ui::CheckButton( "Inverse Polygon" );
+ vbox2.pack_start( check2, FALSE, FALSE, 0 );
+ check2.show();
- check3 = gtk_check_button_new_with_label( "Align Top Edge" );
- gtk_box_pack_start( GTK_BOX( vbox2 ), check3, FALSE, FALSE, 0 );
- gtk_widget_show( check3 );
+ auto check3 = ui::CheckButton( "Align Top Edge" );
+ vbox2.pack_start( check3, FALSE, FALSE, 0 );
+ check3.show();
// ---- /vbox2 ----
// ---- /hbox ----
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
// ---- hbox ----
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ auto w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// ---- /hbox ----
gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER_ON_PARENT );
gtk_window_set_modal( GTK_WINDOW( window ), TRUE );
- gtk_widget_show( window );
+ window.show();
gtk_grab_add( window );
bool dialogError = TRUE;
dialogError = FALSE;
if ( ret == eIDOK ) {
- rs->bUseBorder = gtk_toggle_button_get_active( (GtkToggleButton*)check1 ) ? true : false;
- rs->bInverse = gtk_toggle_button_get_active( (GtkToggleButton*)check2 ) ? true : false;
- rs->bAlignTop = gtk_toggle_button_get_active( (GtkToggleButton*)check3 ) ? true : false;
+ rs->bUseBorder = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check1) ) ? true : false;
+ rs->bInverse = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check2) ) ? true : false;
+ rs->bAlignTop = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check3) ) ? true : false;
- if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
+ if ( !ValidateTextIntRange( gtk_entry_get_text( text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
dialogError = TRUE;
}
if ( rs->bUseBorder ) {
- if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
+ if ( !ValidateTextIntRange( gtk_entry_get_text( text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
dialogError = TRUE;
}
}
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
}
// for stair builder stuck as close as i could to the MFC version
// obviously feel free to change it at will :)
EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
- // i made widgets for just about everything ... i think that's what i need to do dunno tho
- GtkWidget *window, *w, *vbox, *hbox;
- GtkWidget *textStairHeight, *textRiserTex, *textMainTex;
- GtkWidget *radioNorth, *radioSouth, *radioEast, *radioWest; // i'm guessing we can't just abuse 'w' for these if we're getting a value
- GtkWidget *radioOldStyle, *radioBobStyle, *radioCornerStyle;
- GtkWidget *checkUseDetail;
GSList *radioDirection, *radioStyle;
EMessageBoxReturn ret;
int loop = 1;
- char *text = "Please set a value in the boxes below and press 'OK' to build the stairs";
+ const char *text = "Please set a value in the boxes below and press 'OK' to build the stairs";
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto window = ui::Window( ui::window_type::TOP );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Stair Builder" );
+ gtk_window_set_title( window, "Stair Builder" );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
// new vbox
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( vbox ), hbox );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 10 );
+ vbox.add(hbox);
+ hbox.show();
// dunno if you want this text or not ...
- w = gtk_label_new( text );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ...
- gtk_widget_show( w );
+ ui::Widget w = ui::Label( text );
+ hbox.pack_start( w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ...
+ w.show();
- w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Widget::from(gtk_hseparator_new());
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
// ------------------------- // indenting == good way of keeping track of lines :)
// new hbox
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- textStairHeight = gtk_entry_new_with_max_length( 256 );
- gtk_box_pack_start( GTK_BOX( hbox ), textStairHeight, FALSE, FALSE, 1 );
- gtk_widget_show( textStairHeight );
+ auto textStairHeight = ui::Entry( 256 );
+ hbox.pack_start( textStairHeight, FALSE, FALSE, 1 );
+ textStairHeight.show();
- w = gtk_label_new( "Stair Height" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
- gtk_widget_show( w );
+ w = ui::Label( "Stair Height" );
+ hbox.pack_start( w, FALSE, FALSE, 1 );
+ w.show();
// ------------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Direction:" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 );
- gtk_widget_show( w );
+ w = ui::Label( "Direction:" );
+ hbox.pack_start( w, FALSE, FALSE, 5 );
+ w.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
// radio buttons confuse me ...
// but this _looks_ right
// djbob: actually it looks very nice :), slightly better than the way i did it
// edit: actually it doesn't work :P, you must pass the last radio item each time, ugh
- radioNorth = gtk_radio_button_new_with_label( NULL, "North" );
- gtk_box_pack_start( GTK_BOX( hbox ), radioNorth, FALSE, FALSE, 3 );
- gtk_widget_show( radioNorth );
+ auto radioNorth = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North" ));
+ hbox.pack_start( radioNorth, FALSE, FALSE, 3 );
+ radioNorth.show();
- radioDirection = gtk_radio_button_group( GTK_RADIO_BUTTON( radioNorth ) );
+ radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) );
- radioSouth = gtk_radio_button_new_with_label( radioDirection, "South" );
- gtk_box_pack_start( GTK_BOX( hbox ), radioSouth, FALSE, FALSE, 2 );
- gtk_widget_show( radioSouth );
+ auto radioSouth = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "South" ));
+ hbox.pack_start( radioSouth, FALSE, FALSE, 2 );
+ radioSouth.show();
- radioDirection = gtk_radio_button_group( GTK_RADIO_BUTTON( radioSouth ) );
+ radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) );
- radioEast = gtk_radio_button_new_with_label( radioDirection, "East" );
- gtk_box_pack_start( GTK_BOX( hbox ), radioEast, FALSE, FALSE, 1 );
- gtk_widget_show( radioEast );
+ auto radioEast = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "East" ));
+ hbox.pack_start( radioEast, FALSE, FALSE, 1 );
+ radioEast.show();
- radioDirection = gtk_radio_button_group( GTK_RADIO_BUTTON( radioEast ) );
+ radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) );
- radioWest = gtk_radio_button_new_with_label( radioDirection, "West" );
- gtk_box_pack_start( GTK_BOX( hbox ), radioWest, FALSE, FALSE, 0 );
- gtk_widget_show( radioWest );
+ auto radioWest = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "West" ));
+ hbox.pack_start( radioWest, FALSE, FALSE, 0 );
+ radioWest.show();
// --------------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Style:" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 );
- gtk_widget_show( w );
+ w = ui::Label( "Style:" );
+ hbox.pack_start( w, FALSE, FALSE, 5 );
+ w.show();
// --------------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- radioOldStyle = gtk_radio_button_new_with_label( NULL, "Original" );
- gtk_box_pack_start( GTK_BOX( hbox ), radioOldStyle, FALSE, FALSE, 0 );
- gtk_widget_show( radioOldStyle );
+ auto radioOldStyle = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Original" ));
+ hbox.pack_start( radioOldStyle, FALSE, FALSE, 0 );
+ radioOldStyle.show();
- radioStyle = gtk_radio_button_group( GTK_RADIO_BUTTON( radioOldStyle ) );
+ radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) );
- radioBobStyle = gtk_radio_button_new_with_label( radioStyle, "Bob's Style" );
- gtk_box_pack_start( GTK_BOX( hbox ), radioBobStyle, FALSE, FALSE, 0 );
- gtk_widget_show( radioBobStyle );
+ auto radioBobStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Bob's Style" ));
+ hbox.pack_start( radioBobStyle, FALSE, FALSE, 0 );
+ radioBobStyle.show();
- radioStyle = gtk_radio_button_group( GTK_RADIO_BUTTON( radioBobStyle ) );
+ radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) );
- radioCornerStyle = gtk_radio_button_new_with_label( radioStyle, "Corner Style" );
- gtk_box_pack_start( GTK_BOX( hbox ), radioCornerStyle, FALSE, FALSE, 0 );
- gtk_widget_show( radioCornerStyle );
+ auto radioCornerStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Corner Style" ));
+ hbox.pack_start( radioCornerStyle, FALSE, FALSE, 0 );
+ radioCornerStyle.show();
// err, the q3r has an if or something so you need bob style checked before this
// is "ungreyed out" but you'll need to do that, as i suck :)
// djbob: think we need some button callback functions or smuffin
// FIXME: actually get around to doing what i suggested!!!!
- checkUseDetail = gtk_check_button_new_with_label( "Use Detail Brushes" );
- gtk_box_pack_start( GTK_BOX( hbox ), checkUseDetail, FALSE, FALSE, 0 );
- gtk_widget_show( checkUseDetail );
+ auto checkUseDetail = ui::CheckButton( "Use Detail Brushes" );
+ hbox.pack_start( checkUseDetail, FALSE, FALSE, 0 );
+ checkUseDetail.show();
// --------------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- textMainTex = gtk_entry_new_with_max_length( 512 );
+ auto textMainTex = ui::Entry( 512 );
gtk_entry_set_text( GTK_ENTRY( textMainTex ), rs->mainTexture );
- gtk_box_pack_start( GTK_BOX( hbox ), textMainTex, FALSE, FALSE, 0 );
- gtk_widget_show( textMainTex );
+ hbox.pack_start( textMainTex, FALSE, FALSE, 0 );
+ textMainTex.show();
- w = gtk_label_new( "Main Texture" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
- gtk_widget_show( w );
+ w = ui::Label( "Main Texture" );
+ hbox.pack_start( w, FALSE, FALSE, 1 );
+ w.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- textRiserTex = gtk_entry_new_with_max_length( 512 );
- gtk_box_pack_start( GTK_BOX( hbox ), textRiserTex, FALSE, FALSE, 0 );
- gtk_widget_show( textRiserTex );
+ auto textRiserTex = ui::Entry( 512 );
+ hbox.pack_start( textRiserTex, FALSE, FALSE, 0 );
+ textRiserTex.show();
- w = gtk_label_new( "Riser Texture" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
- gtk_widget_show( w );
+ w = ui::Label( "Riser Texture" );
+ hbox.pack_start( w, FALSE, FALSE, 1 );
+ w.show();
// -------------------------- //
- w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
-
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
-
- w = gtk_button_new_with_label( "OK" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Widget::from(gtk_hseparator_new());
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
+
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
+
+ w = ui::Button( "OK" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// +djbob: need our "little" modal loop mars :P
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
bool dialogError = TRUE;
dialogError = FALSE;
if ( ret == eIDOK ) {
- rs->bUseDetail = gtk_toggle_button_get_active( (GtkToggleButton*)checkUseDetail ) ? true : false;
+ rs->bUseDetail = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(checkUseDetail) ) ? true : false;
- strcpy( rs->riserTexture, gtk_entry_get_text( (GtkEntry*)textRiserTex ) );
- strcpy( rs->mainTexture, gtk_entry_get_text( (GtkEntry*)textMainTex ) );
+ strcpy( rs->riserTexture, gtk_entry_get_text( textRiserTex ) );
+ strcpy( rs->mainTexture, gtk_entry_get_text( textMainTex ) );
- if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioNorth ) ) {
+ if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioNorth) ) ) {
rs->direction = MOVE_NORTH;
}
- else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioSouth ) ) {
+ else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioSouth) ) ) {
rs->direction = MOVE_SOUTH;
}
- else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioEast ) ) {
+ else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioEast) ) ) {
rs->direction = MOVE_EAST;
}
- else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioWest ) ) {
+ else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioWest) ) ) {
rs->direction = MOVE_WEST;
}
- if ( !ValidateTextInt( gtk_entry_get_text( (GtkEntry*)textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
+ if ( !ValidateTextInt( gtk_entry_get_text( textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
dialogError = TRUE;
}
- if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioOldStyle ) ) {
+ if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioOldStyle) ) ) {
rs->style = STYLE_ORIGINAL;
}
- else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioBobStyle ) ) {
+ else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioBobStyle) ) ) {
rs->style = STYLE_BOB;
}
- else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioCornerStyle ) ) {
+ else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioCornerStyle) ) ) {
rs->style = STYLE_CORNER;
}
}
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
// -djbob
}
EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
- GtkWidget *window, *hbox, *vbox, *w;
- GtkWidget *textFrontBackTex, *textTrimTex;
- GtkWidget *checkScaleMainH, *checkScaleMainV, *checkScaleTrimH, *checkScaleTrimV;
- GtkWidget *comboMain, *comboTrim;
- GtkWidget *buttonSetMain, *buttonSetTrim;
- GtkWidget *radioNS, *radioEW;
GSList *radioOrientation;
TwinWidget tw1, tw2;
EMessageBoxReturn ret;
int loop = 1;
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto window = ui::Window( ui::window_type::TOP );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Door Builder" );
+ gtk_window_set_title( window, "Door Builder" );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
char buffer[256];
- GList *listMainTextures = NULL;
- GList *listTrimTextures = NULL;
- LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), &listMainTextures );
- LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), &listTrimTextures );
+ auto listMainTextures = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
+ auto listTrimTextures = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
+ LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures );
+ LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- textFrontBackTex = gtk_entry_new_with_max_length( 512 );
+ auto textFrontBackTex = ui::Entry( 512 );
gtk_entry_set_text( GTK_ENTRY( textFrontBackTex ), rs->mainTexture );
- gtk_box_pack_start( GTK_BOX( hbox ), textFrontBackTex, FALSE, FALSE, 0 );
- gtk_widget_show( textFrontBackTex );
+ hbox.pack_start( textFrontBackTex, FALSE, FALSE, 0 );
+ textFrontBackTex.show();
- w = gtk_label_new( "Door Front/Back Texture" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ ui::Widget w = ui::Label( "Door Front/Back Texture" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
// ------------------------ //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- textTrimTex = gtk_entry_new_with_max_length( 512 );
- gtk_box_pack_start( GTK_BOX( hbox ), textTrimTex, FALSE, FALSE, 0 );
- gtk_widget_show( textTrimTex );
+ auto textTrimTex = ui::Entry( 512 );
+ hbox.pack_start( textTrimTex, FALSE, FALSE, 0 );
+ textTrimTex.show();
- w = gtk_label_new( "Door Trim Texture" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Door Trim Texture" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
// ----------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
// sp: horizontally ????
// djbob: yes mars, u can spell :]
- checkScaleMainH = gtk_check_button_new_with_label( "Scale Main Texture Horizontally" );
+ auto checkScaleMainH = ui::CheckButton( "Scale Main Texture Horizontally" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainH ), TRUE );
- gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainH, FALSE, FALSE, 0 );
- gtk_widget_show( checkScaleMainH );
+ hbox.pack_start( checkScaleMainH, FALSE, FALSE, 0 );
+ checkScaleMainH.show();
- checkScaleTrimH = gtk_check_button_new_with_label( "Scale Trim Texture Horizontally" );
+ auto checkScaleTrimH = ui::CheckButton( "Scale Trim Texture Horizontally" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ), TRUE );
- gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimH, FALSE, FALSE, 0 );
- gtk_widget_show( checkScaleTrimH );
+ hbox.pack_start( checkScaleTrimH, FALSE, FALSE, 0 );
+ checkScaleTrimH.show();
// ---------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- checkScaleMainV = gtk_check_button_new_with_label( "Scale Main Texture Vertically" );
+ auto checkScaleMainV = ui::CheckButton( "Scale Main Texture Vertically" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainV ), TRUE );
- gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainV, FALSE, FALSE, 0 );
- gtk_widget_show( checkScaleMainV );
+ hbox.pack_start( checkScaleMainV, FALSE, FALSE, 0 );
+ checkScaleMainV.show();
- checkScaleTrimV = gtk_check_button_new_with_label( "Scale Trim Texture Vertically" );
- gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimV, FALSE, FALSE, 0 );
- gtk_widget_show( checkScaleTrimV );
+ auto checkScaleTrimV = ui::CheckButton( "Scale Trim Texture Vertically" );
+ hbox.pack_start( checkScaleTrimV, FALSE, FALSE, 0 );
+ checkScaleTrimV.show();
// --------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
// djbob: lists added
- comboMain = gtk_combo_new();
- gtk_box_pack_start( GTK_BOX( hbox ), comboMain, FALSE, FALSE, 0 );
- gtk_combo_set_popdown_strings( GTK_COMBO( comboMain ), listMainTextures );
- gtk_combo_set_use_arrows( GTK_COMBO( comboMain ), 1 );
- gtk_widget_show( comboMain );
+ auto comboMain = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listMainTextures));
+ gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
+ hbox.pack_start( comboMain, FALSE, FALSE, 0 );
+ comboMain.show();
tw1.one = textFrontBackTex;
tw1.two = comboMain;
- buttonSetMain = gtk_button_new_with_label( "Set As Main Texture" );
- gtk_signal_connect( GTK_OBJECT( buttonSetMain ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback_settex ), &tw1 );
- gtk_box_pack_start( GTK_BOX( hbox ), buttonSetMain, FALSE, FALSE, 0 );
- gtk_widget_show( buttonSetMain );
+ auto buttonSetMain = ui::Button( "Set As Main Texture" );
+ buttonSetMain.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw1 );
+ hbox.pack_start( buttonSetMain, FALSE, FALSE, 0 );
+ buttonSetMain.show();
// ------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- comboTrim = gtk_combo_new();
- gtk_box_pack_start( GTK_BOX( hbox ), comboTrim, FALSE, FALSE, 0 );
- gtk_combo_set_popdown_strings( GTK_COMBO( comboTrim ), listTrimTextures );
- gtk_combo_set_use_arrows( GTK_COMBO( comboMain ), 1 );
- gtk_widget_show( comboTrim );
+ auto comboTrim = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listTrimTextures));
+ gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
+ hbox.pack_start( comboTrim, FALSE, FALSE, 0 );
+ comboTrim.show();
tw2.one = textTrimTex;
tw2.two = comboTrim;
- buttonSetTrim = gtk_button_new_with_label( "Set As Trim Texture" );
- gtk_signal_connect( GTK_OBJECT( buttonSetTrim ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback_settex ), &tw2 );
- gtk_box_pack_start( GTK_BOX( hbox ), buttonSetTrim, FALSE, FALSE, 0 );
- gtk_widget_show( buttonSetTrim );
+ auto buttonSetTrim = ui::Button( "Set As Trim Texture" );
+ buttonSetTrim.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw2 );
+ hbox.pack_start( buttonSetTrim, FALSE, FALSE, 0 );
+ buttonSetTrim.show();
// ------------------ //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Orientation" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Orientation" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
// argh more radio buttons!
- radioNS = gtk_radio_button_new_with_label( NULL, "North - South" );
- gtk_box_pack_start( GTK_BOX( hbox ), radioNS, FALSE, FALSE, 0 );
- gtk_widget_show( radioNS );
+ auto radioNS = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North - South" ));
+ hbox.pack_start( radioNS, FALSE, FALSE, 0 );
+ radioNS.show();
- radioOrientation = gtk_radio_button_group( GTK_RADIO_BUTTON( radioNS ) );
+ radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) );
- radioEW = gtk_radio_button_new_with_label( radioOrientation, "East - West" );
- gtk_box_pack_start( GTK_BOX( hbox ), radioEW, FALSE, FALSE, 0 );
- gtk_widget_show( radioEW );
+ auto radioEW = ui::Widget::from(gtk_radio_button_new_with_label( radioOrientation, "East - West" ));
+ hbox.pack_start( radioEW, FALSE, FALSE, 0 );
+ radioEW.show();
// ----------------- //
- w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Widget::from(gtk_hseparator_new());
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
// ----------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_button_new_with_label( "OK" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "OK" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// ----------------- //
//+djbob
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
while ( loop )
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
//-djbob
}
EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
- GtkWidget *window, *w, *vbox, *hbox;
-
- GtkWidget *text1, *text2, *text3;
- GtkWidget *check1, *check2;
+ ui::Widget w{ui::null};
EMessageBoxReturn ret;
int loop = 1;
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto window = ui::Window( ui::window_type::TOP );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ gtk_window_set_title( window, "Texture Reset" );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
// ---- vbox ----
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
// ---- hbox ----
- text1 = gtk_entry_new_with_max_length( 256 );
- gtk_entry_set_text( (GtkEntry*)text1, "25" );
- gtk_box_pack_start( GTK_BOX( hbox ), text1, FALSE, FALSE, 2 );
- gtk_widget_show( text1 );
+ auto text1 = ui::Entry( 256 );
+ gtk_entry_set_text( text1, "25" );
+ hbox.pack_start( text1, FALSE, FALSE, 2 );
+ text1.show();
- w = gtk_label_new( "Number Of Points" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
+ w = ui::Label( "Number Of Points" );
+ hbox.pack_start( w, FALSE, FALSE, 2 );
gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
- gtk_widget_show( w );
+ w.show();
// ---- /hbox ----
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
// ---- hbox ----
- text2 = gtk_entry_new_with_max_length( 256 );
- gtk_entry_set_text( (GtkEntry*)text2, "3" );
- gtk_box_pack_start( GTK_BOX( hbox ), text2, FALSE, FALSE, 2 );
- gtk_widget_show( text2 );
+ auto text2 = ui::Entry( 256 );
+ gtk_entry_set_text( text2, "3" );
+ hbox.pack_start( text2, FALSE, FALSE, 2 );
+ text2.show();
- w = gtk_label_new( "Multipler" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
+ w = ui::Label( "Multipler" );
+ hbox.pack_start( w, FALSE, FALSE, 2 );
gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
- gtk_widget_show( w );
+ w.show();
// ---- /hbox ----
- w = gtk_label_new( "Path Distance = dist(start -> apex) * multiplier" );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
+ w = ui::Label( "Path Distance = dist(start -> apex) * multiplier" );
+ vbox.pack_start( w, FALSE, FALSE, 0 );
gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
- gtk_widget_show( w );
+ w.show();
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
// ---- hbox ----
- text3 = gtk_entry_new_with_max_length( 256 );
- gtk_entry_set_text( (GtkEntry*)text3, "-800" );
- gtk_box_pack_start( GTK_BOX( hbox ), text3, FALSE, FALSE, 2 );
- gtk_widget_show( text3 );
+ auto text3 = ui::Entry( 256 );
+ gtk_entry_set_text( text3, "-800" );
+ hbox.pack_start( text3, FALSE, FALSE, 2 );
+ text3.show();
- w = gtk_label_new( "Gravity" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
+ w = ui::Label( "Gravity" );
+ hbox.pack_start( w, FALSE, FALSE, 2 );
gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
- gtk_widget_show( w );
+ w.show();
// ---- /hbox ----
- w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Widget::from(gtk_hseparator_new());
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- check1 = gtk_check_button_new_with_label( "No Dynamic Update" );
- gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 );
- gtk_widget_show( check1 );
+ auto check1 = ui::CheckButton( "No Dynamic Update" );
+ vbox.pack_start( check1, FALSE, FALSE, 0 );
+ check1.show();
- check2 = gtk_check_button_new_with_label( "Show Bounding Lines" );
- gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 );
- gtk_widget_show( check2 );
+ auto check2 = ui::CheckButton( "Show Bounding Lines" );
+ vbox.pack_start( check2, FALSE, FALSE, 0 );
+ check2.show();
// ---- /vbox ----
// ----------------- //
- w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Widget::from(gtk_hseparator_new());
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
// ----------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_button_new_with_label( "Enable" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
- gtk_widget_show( w );
+ w = ui::Button( "Enable" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
+ w.show();
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- w = gtk_button_new_with_label( "Disable" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
- gtk_widget_show( w );
+ w = ui::Button( "Disable" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// ----------------- //
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
bool dialogError = TRUE;
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
}
EMessageBoxReturn DoCTFColourChangeBox(){
- GtkWidget *window, *w, *vbox, *hbox;
+ ui::Widget w{ui::null};
EMessageBoxReturn ret;
int loop = 1;
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto window = ui::Window( ui::window_type::TOP );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "CTF Colour Changer" );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ gtk_window_set_title( window, "CTF Colour Changer" );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
// ---- vbox ----
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, TRUE, TRUE, 0 );
+ hbox.show();
// ---- hbox ---- ok/cancel buttons
- w = gtk_button_new_with_label( "Red->Blue" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ w = ui::Button( "Red->Blue" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Blue->Red" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
- gtk_widget_show( w );
+ w = ui::Button( "Blue->Red" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// ---- /hbox ----
// ---- /vbox ----
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
while ( loop )
gtk_main_iteration();
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
}
EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
Str texSelected;
- GtkWidget *window, *w, *vbox, *hbox, *frame, *table;
+ ui::Widget w{ui::null};
EMessageBoxReturn ret;
int loop = 1;
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto window = ui::Window( ui::window_type::TOP );
gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) );
gtk_window_set_modal( GTK_WINDOW( window ), TRUE );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ gtk_window_set_title( window, "Texture Reset" );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
// ---- vbox ----
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
// ---- hbox ----
texSelected = "Currently Selected Texture: ";
texSelected += GetCurrentTexture();
- w = gtk_label_new( texSelected );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
+ w = ui::Label( texSelected );
+ hbox.pack_start( w, FALSE, FALSE, 2 );
gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
- gtk_widget_show( w );
+ w.show();
// ---- /hbox ----
- frame = gtk_frame_new( "Reset Texture Names" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
+ auto frame = ui::Frame( "Reset Texture Names" );
+ frame.show();
+ vbox.pack_start( frame, FALSE, TRUE, 0 );
- table = gtk_table_new( 2, 3, TRUE );
- gtk_widget_show( table );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ auto table = ui::Table( 2, 3, TRUE );
+ table.show();
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
// ---- frame ----
- dlgTexReset.cbTexChange = gtk_check_button_new_with_label( "Enabled" );
- gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbTexChange ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL );
- gtk_widget_show( dlgTexReset.cbTexChange );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbTexChange, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ dlgTexReset.cbTexChange = ui::CheckButton( "Enabled" );
+ dlgTexReset.cbTexChange.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
+ dlgTexReset.cbTexChange.show();
+ table.attach(dlgTexReset.cbTexChange, {0, 1, 0, 1}, {GTK_FILL, 0});
- w = gtk_label_new( "Old Name: " );
- gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Old Name: " );
+ table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
+ w.show();
- dlgTexReset.editTexOld = gtk_entry_new_with_max_length( 256 );
+ dlgTexReset.editTexOld = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexOld, 2, 3, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( dlgTexReset.editTexOld );
-
- w = gtk_label_new( "New Name: " );
- gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
-
- dlgTexReset.editTexNew = gtk_entry_new_with_max_length( 256 );
+ table.attach(dlgTexReset.editTexOld, {2, 3, 0, 1}, {GTK_FILL, 0});
+ dlgTexReset.editTexOld.show();
+
+ w = ui::Label( "New Name: " );
+ table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
+ w.show();
+
+ dlgTexReset.editTexNew = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexNew, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( dlgTexReset.editTexNew );
+ table.attach(dlgTexReset.editTexNew, {2, 3, 1, 2}, {GTK_FILL, 0});
+ dlgTexReset.editTexNew.show();
// ---- /frame ----
- frame = gtk_frame_new( "Reset Scales" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
+ frame = ui::Frame( "Reset Scales" );
+ frame.show();
+ vbox.pack_start( frame, FALSE, TRUE, 0 );
- table = gtk_table_new( 2, 3, TRUE );
- gtk_widget_show( table );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ table = ui::Table( 2, 3, TRUE );
+ table.show();
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
// ---- frame ----
- dlgTexReset.cbScaleHor = gtk_check_button_new_with_label( "Enabled" );
- gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbScaleHor ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL );
- gtk_widget_show( dlgTexReset.cbScaleHor );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleHor, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" );
+ dlgTexReset.cbScaleHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
+ dlgTexReset.cbScaleHor.show();
+ table.attach(dlgTexReset.cbScaleHor, {0, 1, 0, 1}, {GTK_FILL, 0});
- w = gtk_label_new( "New Horizontal Scale: " );
- gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "New Horizontal Scale: " );
+ table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
+ w.show();
- dlgTexReset.editScaleHor = gtk_entry_new_with_max_length( 256 );
+ dlgTexReset.editScaleHor = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleHor, 2, 3, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( dlgTexReset.editScaleHor );
-
-
- dlgTexReset.cbScaleVert = gtk_check_button_new_with_label( "Enabled" );
- gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbScaleVert ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL );
- gtk_widget_show( dlgTexReset.cbScaleVert );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleVert, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
-
- w = gtk_label_new( "New Vertical Scale: " );
- gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
-
- dlgTexReset.editScaleVert = gtk_entry_new_with_max_length( 256 );
+ table.attach(dlgTexReset.editScaleHor, {2, 3, 0, 1}, {GTK_FILL, 0});
+ dlgTexReset.editScaleHor.show();
+
+
+ dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" );
+ dlgTexReset.cbScaleVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
+ dlgTexReset.cbScaleVert.show();
+ table.attach(dlgTexReset.cbScaleVert, {0, 1, 1, 2}, {GTK_FILL, 0});
+
+ w = ui::Label( "New Vertical Scale: " );
+ table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
+ w.show();
+
+ dlgTexReset.editScaleVert = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleVert, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( dlgTexReset.editScaleVert );
+ table.attach(dlgTexReset.editScaleVert, {2, 3, 1, 2}, {GTK_FILL, 0});
+ dlgTexReset.editScaleVert.show();
// ---- /frame ----
- frame = gtk_frame_new( "Reset Shift" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
+ frame = ui::Frame( "Reset Shift" );
+ frame.show();
+ vbox.pack_start( frame, FALSE, TRUE, 0 );
- table = gtk_table_new( 2, 3, TRUE );
- gtk_widget_show( table );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ table = ui::Table( 2, 3, TRUE );
+ table.show();
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
// ---- frame ----
- dlgTexReset.cbShiftHor = gtk_check_button_new_with_label( "Enabled" );
- gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbShiftHor ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL );
- gtk_widget_show( dlgTexReset.cbShiftHor );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftHor, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" );
+ dlgTexReset.cbShiftHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
+ dlgTexReset.cbShiftHor.show();
+ table.attach(dlgTexReset.cbShiftHor, {0, 1, 0, 1}, {GTK_FILL, 0});
- w = gtk_label_new( "New Horizontal Shift: " );
- gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "New Horizontal Shift: " );
+ table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
+ w.show();
- dlgTexReset.editShiftHor = gtk_entry_new_with_max_length( 256 );
+ dlgTexReset.editShiftHor = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftHor, 2, 3, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( dlgTexReset.editShiftHor );
-
-
- dlgTexReset.cbShiftVert = gtk_check_button_new_with_label( "Enabled" );
- gtk_signal_connect( GTK_OBJECT( dlgTexReset.cbShiftVert ), "toggled", GTK_SIGNAL_FUNC( dialog_button_callback_texreset_update ), NULL );
- gtk_widget_show( dlgTexReset.cbShiftVert );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftVert, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
-
- w = gtk_label_new( "New Vertical Shift: " );
- gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
-
- dlgTexReset.editShiftVert = gtk_entry_new_with_max_length( 256 );
+ table.attach(dlgTexReset.editShiftHor, {2, 3, 0, 1}, {GTK_FILL, 0});
+ dlgTexReset.editShiftHor.show();
+
+
+ dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" );
+ dlgTexReset.cbShiftVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
+ dlgTexReset.cbShiftVert.show();
+ table.attach(dlgTexReset.cbShiftVert, {0, 1, 1, 2}, {GTK_FILL, 0});
+
+ w = ui::Label( "New Vertical Shift: " );
+ table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
+ w.show();
+
+ dlgTexReset.editShiftVert = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftVert, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( dlgTexReset.editShiftVert );
+ table.attach(dlgTexReset.editShiftVert, {2, 3, 1, 2}, {GTK_FILL, 0});
+ dlgTexReset.editShiftVert.show();
// ---- /frame ----
- frame = gtk_frame_new( "Reset Rotation" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
+ frame = ui::Frame( "Reset Rotation" );
+ frame.show();
+ vbox.pack_start( frame, FALSE, TRUE, 0 );
- table = gtk_table_new( 1, 3, TRUE );
- gtk_widget_show( table );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ table = ui::Table( 1, 3, TRUE );
+ table.show();
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
// ---- frame ----
- dlgTexReset.cbRotation = gtk_check_button_new_with_label( "Enabled" );
- gtk_widget_show( dlgTexReset.cbRotation );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbRotation, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ dlgTexReset.cbRotation = ui::CheckButton( "Enabled" );
+ dlgTexReset.cbRotation.show();
+ table.attach(dlgTexReset.cbRotation, {0, 1, 0, 1}, {GTK_FILL, 0});
- w = gtk_label_new( "New Rotation Value: " );
- gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "New Rotation Value: " );
+ table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
+ w.show();
- dlgTexReset.editRotation = gtk_entry_new_with_max_length( 256 );
+ dlgTexReset.editRotation = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" );
- gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editRotation, 2, 3, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( dlgTexReset.editRotation );
+ table.attach(dlgTexReset.editRotation, {2, 3, 0, 1}, {GTK_FILL, 0});
+ dlgTexReset.editRotation.show();
// ---- /frame ----
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
// ---- hbox ----
- w = gtk_button_new_with_label( "Use Selected Brushes" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ w = ui::Button( "Use Selected Brushes" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Use All Brushes" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
- gtk_widget_show( w );
+ w = ui::Button( "Use All Brushes" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// ---- /hbox ----
// ---- /vbox ----
gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER_ON_PARENT );
- gtk_widget_show( window );
+ window.show();
gtk_grab_add( window );
Update_TextureReseter();
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
}
EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
Str texSelected;
- GtkWidget *window, *w, *vbox, *hbox, *frame, *table;
+ ui::Widget w{ui::null};
- GtkWidget *radiusX, *radiusY;
- GtkWidget *angleStart, *angleEnd;
- GtkWidget *heightStart, *heightEnd;
- GtkWidget *numPoints;
+ ui::Widget radiusX{ui::null}, radiusY{ui::null};
+ ui::Widget angleStart{ui::null}, angleEnd{ui::null};
+ ui::Widget heightStart{ui::null}, heightEnd{ui::null};
+ ui::Widget numPoints{ui::null};
EMessageBoxReturn ret;
int loop = 1;
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto window = ui::Window( ui::window_type::TOP );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Train Thing" );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ gtk_window_set_title( window, "Train Thing" );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
- gtk_object_set_data( GTK_OBJECT( window ), "loop", &loop );
- gtk_object_set_data( GTK_OBJECT( window ), "ret", &ret );
+ g_object_set_data( G_OBJECT( window ), "loop", &loop );
+ g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
// ---- vbox ----
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
// ---- /hbox ----
- frame = gtk_frame_new( "Radii" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
+ auto frame = ui::Frame( "Radii" );
+ frame.show();
+ vbox.pack_start( frame, FALSE, TRUE, 0 );
- table = gtk_table_new( 2, 3, TRUE );
- gtk_widget_show( table );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ auto table = ui::Table( 2, 3, TRUE );
+ table.show();
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
// ---- frame ----
- w = gtk_label_new( "X: " );
- gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "X: " );
+ table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
+ w.show();
- radiusX = gtk_entry_new_with_max_length( 256 );
+ radiusX = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" );
- gtk_table_attach( GTK_TABLE( table ), radiusX, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( radiusX );
+ table.attach(radiusX, {1, 2, 0, 1}, {GTK_FILL, 0});
+ radiusX.show();
- w = gtk_label_new( "Y: " );
- gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Y: " );
+ table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
+ w.show();
- radiusY = gtk_entry_new_with_max_length( 256 );
+ radiusY = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" );
- gtk_table_attach( GTK_TABLE( table ), radiusY, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( radiusY );
+ table.attach(radiusY, {1, 2, 1, 2}, {GTK_FILL, 0});
+ radiusY.show();
- frame = gtk_frame_new( "Angles" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
+ frame = ui::Frame( "Angles" );
+ frame.show();
+ vbox.pack_start( frame, FALSE, TRUE, 0 );
- table = gtk_table_new( 2, 3, TRUE );
- gtk_widget_show( table );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ table = ui::Table( 2, 3, TRUE );
+ table.show();
+ frame.add(table);
+ gtk_table_set_row_spacings((table), 5);
+ gtk_table_set_col_spacings((table), 5);
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
// ---- frame ----
- w = gtk_label_new( "Start: " );
- gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Start: " );
+ table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
+ w.show();
- angleStart = gtk_entry_new_with_max_length( 256 );
+ angleStart = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" );
- gtk_table_attach( GTK_TABLE( table ), angleStart, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( angleStart );
+ table.attach(angleStart, {1, 2, 0, 1}, {GTK_FILL, 0});
+ angleStart.show();
- w = gtk_label_new( "End: " );
- gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "End: " );
+ table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
+ w.show();
- angleEnd = gtk_entry_new_with_max_length( 256 );
+ angleEnd = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" );
- gtk_table_attach( GTK_TABLE( table ), angleEnd, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( angleEnd );
+ table.attach(angleEnd, {1, 2, 1, 2}, {GTK_FILL, 0});
+ angleEnd.show();
- frame = gtk_frame_new( "Height" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
+ frame = ui::Frame( "Height" );
+ frame.show();
+ vbox.pack_start( frame, FALSE, TRUE, 0 );
- table = gtk_table_new( 2, 3, TRUE );
- gtk_widget_show( table );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ table = ui::Table( 2, 3, TRUE );
+ table.show();
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
// ---- frame ----
- w = gtk_label_new( "Start: " );
- gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Start: " );
+ table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
+ w.show();
- heightStart = gtk_entry_new_with_max_length( 256 );
+ heightStart = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" );
- gtk_table_attach( GTK_TABLE( table ), heightStart, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( heightStart );
+ table.attach(heightStart, {1, 2, 0, 1}, {GTK_FILL, 0});
+ heightStart.show();
- w = gtk_label_new( "End: " );
- gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "End: " );
+ table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
+ w.show();
- heightEnd = gtk_entry_new_with_max_length( 256 );
+ heightEnd = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" );
- gtk_table_attach( GTK_TABLE( table ), heightEnd, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( heightEnd );
+ table.attach(heightEnd, {1, 2, 1, 2}, {GTK_FILL, 0});
+ heightEnd.show();
- frame = gtk_frame_new( "Points" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
+ frame = ui::Frame( "Points" );
+ frame.show();
+ vbox.pack_start( frame, FALSE, TRUE, 0 );
- table = gtk_table_new( 2, 3, TRUE );
- gtk_widget_show( table );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ table = ui::Table( 2, 3, TRUE );
+ table.show();
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
// ---- frame ----
- w = gtk_label_new( "Number: " );
- gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Number: " );
+ table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
+ w.show();
- numPoints = gtk_entry_new_with_max_length( 256 );
+ numPoints = ui::Entry( 256 );
gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" );
- gtk_table_attach( GTK_TABLE( table ), numPoints, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( numPoints );
+ table.attach(numPoints, {1, 2, 0, 1}, {GTK_FILL, 0});
+ numPoints.show();
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
// ---- hbox ----
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// ---- /hbox ----
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
bool dialogError = TRUE;
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
}
// ailmanki
// add a simple input for the MakeChain thing..
EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
- GtkWidget *window, *w, *vbox, *hbox;
- GtkWidget *textlinkNum, *textlinkName;
+ ui::Widget w{ui::null};
+ ui::Entry textlinkNum{ui::null}, textlinkName{ui::null};
EMessageBoxReturn ret;
int loop = 1;
- char *text = "Please set a value in the boxes below and press 'OK' to make a chain";
+ const char *text = "Please set a value in the boxes below and press 'OK' to make a chain";
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto window = ui::Window( ui::window_type::TOP );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), "Make Chain" );
+ gtk_window_set_title( window, "Make Chain" );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
// new vbox
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( vbox ), hbox );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 10 );
+ vbox.add(hbox);
+ hbox.show();
// dunno if you want this text or not ...
- w = gtk_label_new( text );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( text );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Widget::from(gtk_hseparator_new());
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
// ------------------------- //
// new hbox
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- textlinkNum = gtk_entry_new_with_max_length( 256 );
- gtk_box_pack_start( GTK_BOX( hbox ), textlinkNum, FALSE, FALSE, 1 );
- gtk_widget_show( textlinkNum );
+ textlinkNum = ui::Entry( 256 );
+ hbox.pack_start( textlinkNum, FALSE, FALSE, 1 );
+ textlinkNum.show();
- w = gtk_label_new( "Number of elements in chain" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
- gtk_widget_show( w );
+ w = ui::Label( "Number of elements in chain" );
+ hbox.pack_start( w, FALSE, FALSE, 1 );
+ w.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- textlinkName = gtk_entry_new_with_max_length( 256 );
- gtk_box_pack_start( GTK_BOX( hbox ), textlinkName, FALSE, FALSE, 0 );
- gtk_widget_show( textlinkName );
+ textlinkName = ui::Entry( 256 );
+ hbox.pack_start( textlinkName, FALSE, FALSE, 0 );
+ textlinkName.show();
- w = gtk_label_new( "Basename for chain's targetnames." );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
- gtk_widget_show( w );
+ w = ui::Label( "Basename for chain's targetnames." );
+ hbox.pack_start( w, FALSE, FALSE, 1 );
+ w.show();
- w = gtk_button_new_with_label( "OK" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "OK" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
bool dialogError = TRUE;
dialogError = FALSE;
if ( ret == eIDOK ) {
- strcpy( rs->linkName, gtk_entry_get_text( (GtkEntry*)textlinkName ) );
- if ( !ValidateTextInt( gtk_entry_get_text( (GtkEntry*)textlinkNum ), "Elements", &rs->linkNum ) ) {
+ strcpy( rs->linkName, gtk_entry_get_text( textlinkName ) );
+ if ( !ValidateTextInt( gtk_entry_get_text( textlinkNum ), "Elements", &rs->linkNum ) ) {
dialogError = TRUE;
}
}
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
}
int linkNum;
};
-typedef struct _GtkWidget GtkWidget;
-
struct TwinWidget {
- GtkWidget* one;
- GtkWidget* two;
+ ui::Widget one{ui::null};
+ ui::ComboBox two{ui::null};
};
EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type );
#include "../bobtoolz.h"
#include "PathPlotterDialog.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
/////////////////////////////////////////////////////////////////////////////
// CPathPlotterDialog dialog
*/
#include "funchandlers.h"
+#include "globaldefs.h"
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4786)
#endif
extern DTreePlanter* g_TreePlanter;
// intersect stuff
-#define BRUSH_OPT_WHOLE_MAP 0
-#define BRUSH_OPT_SELECTED 1
+const int BRUSH_OPT_WHOLE_MAP = 0;
+const int BRUSH_OPT_SELECTED = 1;
// defines for stairs
-#define MOVE_NORTH 0
-#define MOVE_SOUTH 1
-#define MOVE_EAST 2
-#define MOVE_WEST 3
+const int MOVE_NORTH = 0;
+const int MOVE_SOUTH = 1;
+const int MOVE_EAST = 2;
+const int MOVE_WEST = 3;
-#define STYLE_ORIGINAL 0
-#define STYLE_BOB 1
-#define STYLE_CORNER 2
+const int STYLE_ORIGINAL = 0;
+const int STYLE_BOB = 1;
+const int STYLE_CORNER = 2;
// defines for doors
-#define DIRECTION_NS 0
-#define DIRECTION_EW 1
+const int DIRECTION_NS = 0;
+const int DIRECTION_EW = 1;
// help
void LoadLists();
*/
#include "lists.h"
+#include "globaldefs.h"
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4786)
#endif
-#include <glib.h>
-
#include "misc.h"
bool LoadExclusionList( char* filename, std::list<Str>* exclusionList ){
return FALSE;
}
-bool LoadGList( char* filename, GList** loadlist ){
+bool LoadGList( char* filename, ui::ListStore loadlist ){
FILE* eFile = fopen( filename, "r" );
if ( eFile ) {
char buffer[256];
if ( strlen( buffer ) > 0 ) {
char* buffer2 = new char[strlen( buffer ) + 1];
strcpy( buffer2, buffer );
- *loadlist = g_list_append( *loadlist, buffer2 );
+ loadlist.append(0, buffer2);
}
else{
cnt++;
*/
#include <list>
+#include <uilib/uilib.h>
#include "str.h"
typedef struct _GList GList;
bool LoadExclusionList( char* filename, std::list<Str>* exclusionList );
-bool LoadGList( char* filename, GList** loadlist );
+bool LoadGList( char* filename, ui::ListStore loadlist );
*/
#include "misc.h"
+#include "globaldefs.h"
#include <list>
#include "str.h"
#include "funchandlers.h"
-#if defined ( POSIX )
+#if GDEF_OS_POSIX
#include <sys/types.h>
#include <unistd.h>
#endif
std::size_t l = strlen( buf );
char* out = buf2;
- for ( int i = 0 ; i < l ; i++ )
+ for ( std::size_t i = 0 ; i < l ; i++ )
{
if ( buf[i] == '\n' ) {
*out++ = '\r';
char* UnixToDosPath( char* path ){
-#ifndef WIN32
+#if !GDEF_OS_WINDOWS
return path;
#else
for ( char* p = path; *p; p++ )
return buffer;
}*/
-#if defined ( POSIX )
+#if GDEF_OS_POSIX
// the bCreateConsole parameter is ignored on linux ..
bool Q_Exec( const char *pCmd, bool bCreateConsole ){
switch ( fork() )
// Error ("CreateProcess failed");
break;
case 0:
-#ifdef _DEBUG
+#if GDEF_DEBUG
printf( "Running system...\n" );
printf( "Command: %s\n", pCmd );
#endif
}
#endif
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <windows.h>
#include "str.h"
#include "iscenegraph.h"
-#define MAX_ROUND_ERROR 0.05
+const double MAX_ROUND_ERROR = 0.05;
vec_t Min( vec_t a, vec_t b );
/ | / |
/ | / |
4 ----- 6 |
- | 2|_|___|8
- | / | /
- | / | / ----> WEST, definitely
+ | 2|_|___|8
+ | / | /
+ | / | / ----> WEST, definitely
||/ | /
1|_____|/3
--- /dev/null
+radiant_plugin(brushexport
+ callbacks.cpp callbacks.h
+ export.cpp export.h
+ interface.cpp
+ plugin.cpp plugin.h
+ support.cpp support.h
+ )
+
+target_include_directories(brushexport PRIVATE uilib)
+target_link_libraries(brushexport PRIVATE uilib)
namespace callbacks {
-void OnDestroy( GtkWidget* w, gpointer data ){
+void OnDestroy( ui::Widget w, gpointer data ){
DestroyWindow();
}
-void OnExportClicked( GtkButton* button, gpointer user_data ){
- GtkWidget* window = lookup_widget( GTK_WIDGET( button ), "w_plugplug2" );
- ASSERT_NOTNULL( window );
+void OnExportClicked( ui::Button button, gpointer user_data ){
+ auto window = ui::Window::from(lookup_widget( button , "w_plugplug2" ));
+ ASSERT_TRUE( window );
const char* cpath = GlobalRadiant().m_pfnFileDialog( window, false, "Save as Obj", 0, 0, false, false, true );
if ( !cpath ) {
return;
// get ignore list from ui
std::set<std::string> ignore;
- GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) );
- GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( view ) );
+ auto view = ui::TreeView::from(lookup_widget(button, "t_materialist"));
+ ui::ListStore list = ui::ListStore::from(gtk_tree_view_get_model( view ));
GtkTreeIter iter;
- gboolean valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( list ), &iter );
+ gboolean valid = gtk_tree_model_get_iter_first(list, &iter );
while ( valid )
{
gchar* data;
- gtk_tree_model_get( GTK_TREE_MODEL( list ), &iter, 0, &data, -1 );
+ gtk_tree_model_get(list, &iter, 0, &data, -1 );
globalOutputStream() << data << "\n";
ignore.insert( std::string( data ) );
g_free( data );
- valid = gtk_tree_model_iter_next( GTK_TREE_MODEL( list ), &iter );
+ valid = gtk_tree_model_iter_next(list, &iter );
}
for ( std::set<std::string>::iterator it( ignore.begin() ); it != ignore.end(); ++it )
// collapse mode
collapsemode mode = COLLAPSE_NONE;
- GtkWidget* radio = lookup_widget( GTK_WIDGET( button ), "r_collapse" );
- ASSERT_NOTNULL( radio );
+ auto radio = lookup_widget( button , "r_collapse" );
+ ASSERT_TRUE( radio );
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ) {
mode = COLLAPSE_ALL;
}
else
{
- radio = lookup_widget( GTK_WIDGET( button ), "r_collapsebymaterial" );
- ASSERT_NOTNULL( radio );
+ radio = lookup_widget( button , "r_collapsebymaterial" );
+ ASSERT_TRUE( radio );
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) ) {
mode = COLLAPSE_BY_MATERIAL;
}
else
{
- radio = lookup_widget( GTK_WIDGET( button ), "r_nocollapse" );
- ASSERT_NOTNULL( radio );
- ASSERT_NOTNULL( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) );
+ radio = lookup_widget( button , "r_nocollapse" );
+ ASSERT_TRUE( radio );
+ ASSERT_TRUE( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio ) ) );
mode = COLLAPSE_NONE;
}
}
// export materials?
- GtkWidget* toggle = lookup_widget( GTK_WIDGET( button ), "t_exportmaterials" );
- ASSERT_NOTNULL( toggle );
+ auto toggle = lookup_widget( button , "t_exportmaterials" );
+ ASSERT_TRUE( toggle );
bool exportmat = FALSE;
}
// limit material names?
- toggle = lookup_widget( GTK_WIDGET( button ), "t_limitmatnames" );
- ASSERT_NOTNULL( toggle );
+ toggle = lookup_widget( button , "t_limitmatnames" );
+ ASSERT_TRUE( toggle );
bool limitMatNames = FALSE;
}
// create objects instead of groups?
- toggle = lookup_widget( GTK_WIDGET( button ), "t_objects" );
- ASSERT_NOTNULL( toggle );
+ toggle = lookup_widget( button , "t_objects" );
+ ASSERT_TRUE( toggle );
bool objects = FALSE;
ExportSelection( ignore, mode, exportmat, path, limitMatNames, objects );
}
-void OnAddMaterial( GtkButton* button, gpointer user_data ){
- GtkEntry* edit = GTK_ENTRY( lookup_widget( GTK_WIDGET( button ), "ed_materialname" ) );
- ASSERT_NOTNULL( edit );
+void OnAddMaterial( ui::Button button, gpointer user_data ){
+ auto edit = ui::Entry::from( lookup_widget( button , "ed_materialname" ) );
+ ASSERT_TRUE( edit );
const gchar* name = gtk_entry_get_text( edit );
if ( g_utf8_strlen( name, -1 ) > 0 ) {
- GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) ) ) );
- GtkTreeIter iter;
- gtk_list_store_append( list, &iter );
- gtk_list_store_set( list, &iter, 0, name, -1 );
+ ui::ListStore list = ui::ListStore::from( gtk_tree_view_get_model(ui::TreeView::from(lookup_widget(button, "t_materialist") )) );
+ list.append(0, name);
gtk_entry_set_text( edit, "" );
}
}
-void OnRemoveMaterial( GtkButton* button, gpointer user_data ){
- GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( GTK_WIDGET( button ), "t_materialist" ) );
- GtkListStore* list = GTK_LIST_STORE( gtk_tree_view_get_model( view ) );
- GtkTreeSelection* sel = gtk_tree_view_get_selection( view );
+void OnRemoveMaterial( ui::Button button, gpointer user_data ){
+ ui::TreeView view = ui::TreeView::from(lookup_widget(button, "t_materialist"));
+ ui::ListStore list = ui::ListStore::from( gtk_tree_view_get_model( view ) );
+ auto sel = ui::TreeSelection::from(gtk_tree_view_get_selection( view ));
GtkTreeIter iter;
if ( gtk_tree_selection_get_selected( sel, 0, &iter ) ) {
}
}
-void OnExportMatClicked( GtkButton* button, gpointer user_data ){
- GtkWidget* toggleLimit = lookup_widget( GTK_WIDGET( button ), "t_limitmatnames" );
- GtkWidget* toggleObject = lookup_widget( GTK_WIDGET( button ), "t_objects" );
+void OnExportMatClicked( ui::Button button, gpointer user_data ){
+ ui::Widget toggleLimit = lookup_widget( button , "t_limitmatnames" );
+ ui::Widget toggleObject = lookup_widget( button , "t_objects" );
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ) ) ) {
- gtk_widget_set_sensitive( GTK_WIDGET( toggleLimit ), TRUE );
- gtk_widget_set_sensitive( GTK_WIDGET( toggleObject ), TRUE );
+ gtk_widget_set_sensitive( toggleLimit , TRUE );
+ gtk_widget_set_sensitive( toggleObject , TRUE );
}
else {
- gtk_widget_set_sensitive( GTK_WIDGET( toggleLimit ), FALSE );
- gtk_widget_set_sensitive( GTK_WIDGET( toggleObject ), FALSE );
+ gtk_widget_set_sensitive( toggleLimit , FALSE );
+ gtk_widget_set_sensitive( toggleObject , FALSE );
}
}
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkButton GtkButton;
+
+#include <uilib/uilib.h>
namespace callbacks {
-void OnDestroy( GtkWidget *, gpointer );
-void OnExportClicked( GtkButton *, gpointer );
-void OnAddMaterial( GtkButton *, gpointer );
-void OnRemoveMaterial( GtkButton *, gpointer );
-void OnExportMatClicked( GtkButton * button, gpointer );
+void OnDestroy( ui::Widget, gpointer );
+void OnExportClicked( ui::Button, gpointer );
+void OnAddMaterial( ui::Button, gpointer );
+void OnRemoveMaterial( ui::Button, gpointer );
+void OnExportMatClicked( ui::Button button, gpointer );
} // callbacks
#include "export.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
#include "ibrush.h"
#include "iscenegraph.h"
#include "../../radiant/brush.h"
// for limNames
-#define MAX_MATERIAL_NAME 20
+const int MAX_MATERIAL_NAME = 20;
/*
Abstract baseclass for modelexporters
// add face to current group
current->faces.push_back( &f );
-#ifdef _DEBUG
+#if GDEF_DEBUG
globalOutputStream() << "Added Face to group " << current->name.c_str() << "\n";
#endif
}
name = tmp.substr( last_slash + 1, tmp.length() - last_slash );
}
-#ifdef _DEBUG
+#if GDEF_DEBUG
globalOutputStream() << "Last: " << (const unsigned int) last_slash << " " << "length: " << (const unsigned int)tmp.length() << "Name: " << name.c_str() << "\n";
#endif
}
#define GLADE_HOOKUP_OBJECT( component,widget,name ) \
g_object_set_data_full( G_OBJECT( component ), name, \
- gtk_widget_ref( widget ), (GDestroyNotify) gtk_widget_unref )
+ g_object_ref( (void *) widget ), (GDestroyNotify) g_object_unref )
#define GLADE_HOOKUP_OBJECT_NO_REF( component,widget,name ) \
- g_object_set_data( G_OBJECT( component ), name, widget )
+ g_object_set_data( G_OBJECT( component ), name, (void *) widget )
// created by glade
-GtkWidget*
-create_w_plugplug2( void ){
- GtkWidget *w_plugplug2;
- GtkWidget *vbox1;
- GtkWidget *hbox2;
- GtkWidget *vbox4;
- GtkWidget *r_collapse;
+ui::Widget create_w_plugplug2( void ){
GSList *r_collapse_group = NULL;
- GtkWidget *r_collapsebymaterial;
- GtkWidget *r_nocollapse;
- GtkWidget *vbox3;
- GtkWidget *b_export;
- GtkWidget *b_close;
- GtkWidget *vbox2;
- GtkWidget *label1;
- GtkWidget *scrolledwindow1;
- GtkWidget *t_materialist;
- GtkWidget *ed_materialname;
- GtkWidget *hbox1;
- GtkWidget *b_addmaterial;
- GtkWidget *b_removematerial;
- GtkWidget *t_exportmaterials;
- GtkWidget *t_limitmatnames;
- GtkWidget *t_objects;
- GtkTooltips *tooltips;
-
- tooltips = gtk_tooltips_new();
-
- w_plugplug2 = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+
+ auto w_plugplug2 = ui::Window( ui::window_type::TOP );
gtk_widget_set_name( w_plugplug2, "w_plugplug2" );
- gtk_window_set_title( GTK_WINDOW( w_plugplug2 ), "BrushExport-Plugin 3.0 by namespace" );
+ gtk_window_set_title( w_plugplug2, "BrushExport-Plugin 3.0 by namespace" );
gtk_window_set_position( GTK_WINDOW( w_plugplug2 ), GTK_WIN_POS_CENTER_ON_PARENT );
gtk_window_set_transient_for( GTK_WINDOW( w_plugplug2 ), GTK_WINDOW( g_pRadiantWnd ) );
- gtk_window_set_destroy_with_parent( GTK_WINDOW( w_plugplug2 ), TRUE );
+ gtk_window_set_destroy_with_parent( w_plugplug2, TRUE );
- vbox1 = gtk_vbox_new( FALSE, 0 );
+ auto vbox1 = ui::VBox( FALSE, 0 );
gtk_widget_set_name( vbox1, "vbox1" );
- gtk_widget_show( vbox1 );
- gtk_container_add( GTK_CONTAINER( w_plugplug2 ), vbox1 );
+ vbox1.show();
+ w_plugplug2.add(vbox1);
gtk_container_set_border_width( GTK_CONTAINER( vbox1 ), 5 );
- hbox2 = gtk_hbox_new( TRUE, 5 );
+ auto hbox2 = ui::HBox( TRUE, 5 );
gtk_widget_set_name( hbox2, "hbox2" );
- gtk_widget_show( hbox2 );
- gtk_box_pack_start( GTK_BOX( vbox1 ), hbox2, FALSE, FALSE, 0 );
+ hbox2.show();
+ vbox1.pack_start( hbox2, FALSE, FALSE, 0 );
gtk_container_set_border_width( GTK_CONTAINER( hbox2 ), 5 );
- vbox4 = gtk_vbox_new( TRUE, 0 );
+ auto vbox4 = ui::VBox( TRUE, 0 );
gtk_widget_set_name( vbox4, "vbox4" );
- gtk_widget_show( vbox4 );
- gtk_box_pack_start( GTK_BOX( hbox2 ), vbox4, TRUE, FALSE, 0 );
+ vbox4.show();
+ hbox2.pack_start( vbox4, TRUE, FALSE, 0 );
- r_collapse = gtk_radio_button_new_with_mnemonic( NULL, "Collapse mesh" );
+ auto r_collapse = ui::Widget::from(gtk_radio_button_new_with_mnemonic( NULL, "Collapse mesh" ));
gtk_widget_set_name( r_collapse, "r_collapse" );
- gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), r_collapse, "Collapse all brushes into a single group", "Collapse all brushes into a single group" );
- gtk_widget_show( r_collapse );
- gtk_box_pack_start( GTK_BOX( vbox4 ), r_collapse, FALSE, FALSE, 0 );
+ gtk_widget_set_tooltip_text(r_collapse, "Collapse all brushes into a single group");
+ r_collapse.show();
+ vbox4.pack_start( r_collapse, FALSE, FALSE, 0 );
gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_collapse ), r_collapse_group );
r_collapse_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( r_collapse ) );
- r_collapsebymaterial = gtk_radio_button_new_with_mnemonic( NULL, "Collapse by material" );
+ auto r_collapsebymaterial = ui::Widget::from(gtk_radio_button_new_with_mnemonic( NULL, "Collapse by material" ));
gtk_widget_set_name( r_collapsebymaterial, "r_collapsebymaterial" );
- gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), r_collapsebymaterial, "Collapse into groups by material", "Collapse into groups by material" );
- gtk_widget_show( r_collapsebymaterial );
- gtk_box_pack_start( GTK_BOX( vbox4 ), r_collapsebymaterial, FALSE, FALSE, 0 );
+ gtk_widget_set_tooltip_text(r_collapsebymaterial, "Collapse into groups by material");
+ r_collapsebymaterial.show();
+ vbox4.pack_start( r_collapsebymaterial, FALSE, FALSE, 0 );
gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_collapsebymaterial ), r_collapse_group );
r_collapse_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( r_collapsebymaterial ) );
- r_nocollapse = gtk_radio_button_new_with_mnemonic( NULL, "Don't collapse" );
+ auto r_nocollapse = ui::Widget::from(gtk_radio_button_new_with_mnemonic( NULL, "Don't collapse" ));
gtk_widget_set_name( r_nocollapse, "r_nocollapse" );
- gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), r_nocollapse, "Every brush is stored in its own group", "Every brush is stored in its own group" );
- gtk_widget_show( r_nocollapse );
- gtk_box_pack_start( GTK_BOX( vbox4 ), r_nocollapse, FALSE, FALSE, 0 );
+ gtk_widget_set_tooltip_text(r_nocollapse, "Every brush is stored in its own group");
+ r_nocollapse.show();
+ vbox4.pack_start( r_nocollapse, FALSE, FALSE, 0 );
gtk_radio_button_set_group( GTK_RADIO_BUTTON( r_nocollapse ), r_collapse_group );
r_collapse_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( r_nocollapse ) );
- vbox3 = gtk_vbox_new( FALSE, 0 );
+ auto vbox3 = ui::VBox( FALSE, 0 );
gtk_widget_set_name( vbox3, "vbox3" );
- gtk_widget_show( vbox3 );
- gtk_box_pack_start( GTK_BOX( hbox2 ), vbox3, FALSE, FALSE, 0 );
+ vbox3.show();
+ hbox2.pack_start( vbox3, FALSE, FALSE, 0 );
- b_export = gtk_button_new_from_stock( "gtk-save" );
+ auto b_export = ui::Button::from(gtk_button_new_from_stock( "gtk-save" ));
gtk_widget_set_name( b_export, "b_export" );
- gtk_widget_show( b_export );
- gtk_box_pack_start( GTK_BOX( vbox3 ), b_export, TRUE, FALSE, 0 );
+ b_export.show();
+ vbox3.pack_start( b_export, TRUE, FALSE, 0 );
gtk_container_set_border_width( GTK_CONTAINER( b_export ), 5 );
- b_close = gtk_button_new_from_stock( "gtk-cancel" );
+ auto b_close = ui::Button::from(gtk_button_new_from_stock( "gtk-cancel" ));
gtk_widget_set_name( b_close, "b_close" );
- gtk_widget_show( b_close );
- gtk_box_pack_start( GTK_BOX( vbox3 ), b_close, TRUE, FALSE, 0 );
+ b_close.show();
+ vbox3.pack_start( b_close, TRUE, FALSE, 0 );
gtk_container_set_border_width( GTK_CONTAINER( b_close ), 5 );
- vbox2 = gtk_vbox_new( FALSE, 5 );
+ auto vbox2 = ui::VBox( FALSE, 5 );
gtk_widget_set_name( vbox2, "vbox2" );
- gtk_widget_show( vbox2 );
- gtk_box_pack_start( GTK_BOX( vbox1 ), vbox2, TRUE, TRUE, 0 );
+ vbox2.show();
+ vbox1.pack_start( vbox2, TRUE, TRUE, 0 );
gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 2 );
- label1 = gtk_label_new( "Ignored materials:" );
+ auto label1 = ui::Label( "Ignored materials:" );
gtk_widget_set_name( label1, "label1" );
- gtk_widget_show( label1 );
- gtk_box_pack_start( GTK_BOX( vbox2 ), label1, FALSE, FALSE, 0 );
+ label1.show();
+ vbox2.pack_start( label1, FALSE, FALSE, 0 );
- scrolledwindow1 = gtk_scrolled_window_new( NULL, NULL );
+ auto scrolledwindow1 = ui::ScrolledWindow(ui::New);
gtk_widget_set_name( scrolledwindow1, "scrolledwindow1" );
- gtk_widget_show( scrolledwindow1 );
- gtk_box_pack_start( GTK_BOX( vbox2 ), scrolledwindow1, TRUE, TRUE, 0 );
+ scrolledwindow1.show();
+ vbox2.pack_start( scrolledwindow1, TRUE, TRUE, 0 );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scrolledwindow1 ), GTK_SHADOW_IN );
- t_materialist = gtk_tree_view_new();
+ auto t_materialist = ui::TreeView(ui::New);
gtk_widget_set_name( t_materialist, "t_materialist" );
- gtk_widget_show( t_materialist );
- gtk_container_add( GTK_CONTAINER( scrolledwindow1 ), t_materialist );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( t_materialist ), FALSE );
- gtk_tree_view_set_enable_search( GTK_TREE_VIEW( t_materialist ), FALSE );
+ t_materialist.show();
+ scrolledwindow1.add(t_materialist);
+ gtk_tree_view_set_headers_visible(t_materialist, FALSE );
+ gtk_tree_view_set_enable_search(t_materialist, FALSE );
- ed_materialname = gtk_entry_new();
+ auto ed_materialname = ui::Entry(ui::New);
gtk_widget_set_name( ed_materialname, "ed_materialname" );
- gtk_widget_show( ed_materialname );
- gtk_box_pack_start( GTK_BOX( vbox2 ), ed_materialname, FALSE, FALSE, 0 );
+ ed_materialname.show();
+ vbox2.pack_start( ed_materialname, FALSE, FALSE, 0 );
- hbox1 = gtk_hbox_new( TRUE, 0 );
+ auto hbox1 = ui::HBox( TRUE, 0 );
gtk_widget_set_name( hbox1, "hbox1" );
- gtk_widget_show( hbox1 );
- gtk_box_pack_start( GTK_BOX( vbox2 ), hbox1, FALSE, FALSE, 0 );
+ hbox1.show();
+ vbox2.pack_start( hbox1, FALSE, FALSE, 0 );
- b_addmaterial = gtk_button_new_from_stock( "gtk-add" );
+ auto b_addmaterial = ui::Button::from(gtk_button_new_from_stock( "gtk-add" ));
gtk_widget_set_name( b_addmaterial, "b_addmaterial" );
- gtk_widget_show( b_addmaterial );
- gtk_box_pack_start( GTK_BOX( hbox1 ), b_addmaterial, FALSE, FALSE, 0 );
+ b_addmaterial.show();
+ hbox1.pack_start( b_addmaterial, FALSE, FALSE, 0 );
- b_removematerial = gtk_button_new_from_stock( "gtk-remove" );
+ auto b_removematerial = ui::Button::from(gtk_button_new_from_stock( "gtk-remove" ));
gtk_widget_set_name( b_removematerial, "b_removematerial" );
- gtk_widget_show( b_removematerial );
- gtk_box_pack_start( GTK_BOX( hbox1 ), b_removematerial, FALSE, FALSE, 0 );
+ b_removematerial.show();
+ hbox1.pack_start( b_removematerial, FALSE, FALSE, 0 );
- t_limitmatnames = gtk_check_button_new_with_mnemonic( "Use short material names (max. 20 chars)" );
+ auto t_limitmatnames = ui::Widget::from(gtk_check_button_new_with_mnemonic( "Use short material names (max. 20 chars)" ));
gtk_widget_set_name( t_limitmatnames, "t_limitmatnames" );
- gtk_widget_show( t_limitmatnames );
- gtk_box_pack_end( GTK_BOX( vbox2 ), t_limitmatnames, FALSE, FALSE, 0 );
+ t_limitmatnames.show();
+ vbox2.pack_end( t_limitmatnames, FALSE, FALSE, 0 );
- t_objects = gtk_check_button_new_with_mnemonic( "Create (o)bjects instead of (g)roups" );
+ auto t_objects = ui::Widget::from(gtk_check_button_new_with_mnemonic( "Create (o)bjects instead of (g)roups" ));
gtk_widget_set_name( t_objects, "t_objects" );
- gtk_widget_show( t_objects );
- gtk_box_pack_end( GTK_BOX( vbox2 ), t_objects, FALSE, FALSE, 0 );
+ t_objects.show();
+ vbox2.pack_end(t_objects, FALSE, FALSE, 0);
- t_exportmaterials = gtk_check_button_new_with_mnemonic( "Create material information (.mtl file)" );
+ auto t_exportmaterials = ui::CheckButton::from(gtk_check_button_new_with_mnemonic( "Create material information (.mtl file)" ));
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( t_exportmaterials ), true );
gtk_widget_set_name( t_exportmaterials, "t_exportmaterials" );
- gtk_widget_show( t_exportmaterials );
- gtk_box_pack_end( GTK_BOX( vbox2 ), t_exportmaterials, FALSE, FALSE, 10 );
+ t_exportmaterials.show();
+ vbox2.pack_end(t_exportmaterials, FALSE, FALSE, 10);
using namespace callbacks;
- g_signal_connect( G_OBJECT( w_plugplug2 ), "destroy", G_CALLBACK( OnDestroy ), NULL );
+ w_plugplug2.connect( "destroy", G_CALLBACK( OnDestroy ), NULL );
g_signal_connect_swapped( G_OBJECT( b_close ), "clicked", G_CALLBACK( OnDestroy ), NULL );
- g_signal_connect( ( gpointer )b_export, "clicked", G_CALLBACK( OnExportClicked ), NULL );
- g_signal_connect( ( gpointer )b_addmaterial, "clicked", G_CALLBACK( OnAddMaterial ), NULL );
- g_signal_connect( ( gpointer )b_removematerial, "clicked", G_CALLBACK( OnRemoveMaterial ), NULL );
- g_signal_connect( ( gpointer )t_exportmaterials, "clicked", G_CALLBACK( OnExportMatClicked ), NULL );
+ b_export.connect( "clicked", G_CALLBACK( OnExportClicked ), NULL );
+ b_addmaterial.connect( "clicked", G_CALLBACK( OnAddMaterial ), NULL );
+ b_removematerial.connect( "clicked", G_CALLBACK( OnRemoveMaterial ), NULL );
+ t_exportmaterials.connect( "clicked", G_CALLBACK( OnExportMatClicked ), NULL );
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF( w_plugplug2, w_plugplug2, "w_plugplug2" );
}
// global main window, is 0 when not created
-GtkWidget* g_brushexp_window = 0;
+ui::Widget g_brushexp_window{ui::null};
// spawn plugin window (and make sure it got destroyed first or never created)
void CreateWindow( void ){
- ASSERT_NOTNULL( !g_brushexp_window );
+ ASSERT_TRUE( !g_brushexp_window );
- GtkWidget* wnd = create_w_plugplug2();
+ ui::Widget wnd = create_w_plugplug2();
// column & renderer
- GtkTreeViewColumn* col = gtk_tree_view_column_new();
+ auto col = ui::TreeViewColumn::from(gtk_tree_view_column_new());
gtk_tree_view_column_set_title( col, "materials" );
- gtk_tree_view_append_column( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), col );
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), -1, "", renderer, "text", 0, NULL );
+ auto view = ui::TreeView::from(lookup_widget(wnd, "t_materialist"));
+ gtk_tree_view_append_column(view, col );
+ auto renderer = ui::CellRendererText(ui::New);
+ gtk_tree_view_insert_column_with_attributes(view, -1, "", renderer, "text", 0, NULL );
// list store
- GtkListStore* ignorelist = gtk_list_store_new( 1, G_TYPE_STRING );
- gtk_tree_view_set_model( GTK_TREE_VIEW( lookup_widget( wnd, "t_materialist" ) ), GTK_TREE_MODEL( ignorelist ) );
- g_object_unref( ignorelist );
+ auto ignorelist = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
+ gtk_tree_view_set_model(view, ignorelist );
+ ignorelist.unref();
gtk_widget_show_all( wnd );
g_brushexp_window = wnd;
}
-void DestroyWindow( void ){
- ASSERT_NOTNULL( g_brushexp_window );
- gtk_widget_destroy( g_brushexp_window );
- g_brushexp_window = 0;
+void DestroyWindow(){
+ ASSERT_TRUE( g_brushexp_window );
+ ui::Widget(g_brushexp_window).destroy();
+ g_brushexp_window = ui::Widget(ui::null);
}
-bool IsWindowOpen( void ){
- return g_brushexp_window != 0;
+bool IsWindowOpen(){
+ return g_brushexp_window;
}
#include "qerplugin.h"
#include <gtk/gtk.h>
-#include <gtk/gtktreeview.h>
#include "debugging/debugging.h"
#include "string/string.h"
void DestroyWindow( void );
bool IsWindowOpen( void );
-GtkWidget *g_pRadiantWnd = NULL;
+ui::Widget g_pRadiantWnd{ui::null};
namespace BrushExport
{
-GtkWindow* g_mainwnd;
+ui::Window g_mainwnd{ui::null};
const char* init( void* hApp, void* pMainWidget ){
- g_mainwnd = (GtkWindow*)pMainWidget;
- g_pRadiantWnd = (GtkWidget*)pMainWidget;
- ASSERT_NOTNULL( g_mainwnd );
+ g_mainwnd = ui::Window::from(pMainWidget);
+ g_pRadiantWnd = ui::Window::from(pMainWidget);
+ ASSERT_TRUE( g_mainwnd );
return "";
}
const char* getName(){
void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){
if ( string_equal( command, "About" ) ) {
- GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ), "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n"
+ GlobalRadiant().m_pfnMessageBox( g_mainwnd, "Brushexport plugin v 2.0 by namespace (www.codecreator.net)\n"
"Enjoy!\n\nSend feedback to spam@codecreator.net", "About me...",
eMB_OK,
eMB_ICONDEFAULT );
#if !defined( INCLUDED_BRUSH_EXPORT_H )
#define INCLUDED_BRUSH_EXPORT_H
-typedef struct _GtkWidget GtkWidget;
-extern GtkWidget *g_pRadiantWnd;
+#include <uilib/uilib.h>
+
+extern ui::Widget g_pRadiantWnd;
#endif
#include <gtk/gtk.h>
+#include <uilib/uilib.h>
#include "support.h"
-GtkWidget*
-lookup_widget( GtkWidget *widget,
+ui::Widget
+lookup_widget(ui::Widget widget,
const gchar *widget_name ){
- GtkWidget *parent, *found_widget;
+ ui::Widget parent{ui::null};
for (;; )
{
if ( GTK_IS_MENU( widget ) ) {
- parent = gtk_menu_get_attach_widget( GTK_MENU( widget ) );
+ parent = ui::Widget::from(gtk_menu_get_attach_widget( GTK_MENU( widget ) ));
}
else{
- parent = widget->parent;
+ parent = ui::Widget::from(gtk_widget_get_parent(widget));
}
if ( !parent ) {
- parent = (GtkWidget*) g_object_get_data( G_OBJECT( widget ), "GladeParentKey" );
+ parent = ui::Widget::from(g_object_get_data( G_OBJECT( widget ), "GladeParentKey" ));
}
if ( parent == NULL ) {
break;
widget = parent;
}
- found_widget = (GtkWidget*) g_object_get_data( G_OBJECT( widget ),
- widget_name );
+ auto found_widget = ui::Widget::from(g_object_get_data( G_OBJECT( widget ), widget_name ));
if ( !found_widget ) {
g_warning( "Widget not found: %s", widget_name );
}
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
-#include <gtk/gtk.h>
+#include <uilib/uilib.h>
/*
* Public Functions.
* or alternatively any widget in the component, and the name of the widget
* you want returned.
*/
-GtkWidget* lookup_widget( GtkWidget *widget,
+ui::Widget lookup_widget(ui::Widget widget,
const gchar *widget_name );
static const char *PLUGIN_COMMANDS = "About...,-,Load Camera...,-,Preview Camera,-,Camera Inspector...,-,New Spline Camera,New Interpolated Camera,New Fixed Camera";
// globals
-GtkWidget *g_pRadiantWnd = NULL;
-GtkWidget *g_pCameraInspectorWnd = NULL;
+ui::Window g_pRadiantWnd{ui::null};
+ui::Window g_pCameraInspectorWnd{ui::null};
CCamera *firstCam = NULL; // double linked list
CCamera *firstFreeCam = NULL; // single linked list
CCamera *currentCam = NULL; // single item
#include "bytebool.h"
class CCamera;
-#include <gtk/gtk.h>
#include "str.h"
CCamera *GetCurrentCam();
// globals
-extern GtkWidget *g_pRadiantWnd;
-extern GtkWidget *g_pCameraInspectorWnd;
+extern ui::Window g_pRadiantWnd;
+extern ui::Window g_pCameraInspectorWnd;
extern CCamera *firstCam;
extern bool g_bEditOn;
extern int g_iEditMode;
}*/
static gint ci_new( GtkWidget *widget, gpointer data ){
- GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame; //, *name;
+ GtkWidget *w, *hbox; //, *name;
GtkWidget *fixed, *interpolated, *spline;
EMessageBoxReturn ret;
int loop = 1;
// char buf[128];
// create the window
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_window_set_title( GTK_WINDOW( window ), "New Camera" );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
+ auto window = ui::Window( ui::window_type::TOP );
+ gtk_window_set_title( window, "New Camera" );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
+ gtk_window_set_transient_for( window, g_pCameraInspectorWnd );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
// fill the window
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 5 );
+ window.add(vbox);
+ vbox.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- frame = gtk_frame_new( "Type" );
- gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 );
- gtk_widget_show( frame );
+ auto frame = ui::Frame( "Type" );
+ hbox.pack_start( frame, TRUE, TRUE, 0 );
+ frame.show();
- vbox2 = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( frame ), vbox2 );
+ auto vbox2 = ui::VBox( FALSE, 5 );
+ frame.add(vbox2);
gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 );
- gtk_widget_show( vbox2 );
+ vbox2.show();
// -------------------------- //
fixed = gtk_radio_button_new_with_label( targetTypeRadio, "Fixed" );
- gtk_box_pack_start( GTK_BOX( vbox2 ), fixed, FALSE, FALSE, 3 );
- gtk_widget_show( fixed );
- targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( fixed ) );
+ vbox2.pack_start( fixed, FALSE, FALSE, 3 );
+ fixed.show();
+ targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( fixed ) );
interpolated = gtk_radio_button_new_with_label( targetTypeRadio, "Interpolated" );
- gtk_box_pack_start( GTK_BOX( vbox2 ), interpolated, FALSE, FALSE, 3 );
- gtk_widget_show( interpolated );
- targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( interpolated ) );
+ vbox2.pack_start( interpolated, FALSE, FALSE, 3 );
+ interpolated.show();
+ targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( interpolated ) );
spline = gtk_radio_button_new_with_label( targetTypeRadio, "Spline" );
- gtk_box_pack_start( GTK_BOX( vbox2 ), spline, FALSE, FALSE, 3 );
- gtk_widget_show( spline );
- targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( spline ) );
+ vbox2.pack_start( spline, FALSE, FALSE, 3 );
+ spline.show();
+ targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( spline ) );
// -------------------------- //
w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 2 );
+ w.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- gtk_widget_show( w );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ w.show();
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// -------------------------- //
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
bool dialogError = TRUE;
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return TRUE;
}
}
// start edit mode
- if ( g_pCameraInspectorWnd && GTK_WIDGET_VISIBLE( g_pCameraInspectorWnd ) ) {
+ if ( g_pCameraInspectorWnd && gtk_widget_get_visible( g_pCameraInspectorWnd ) ) {
DoStartEdit( GetCurrentCam() );
}
}
static gint ci_rename( GtkWidget *widget, gpointer data ){
- GtkWidget *window, *w, *vbox, *hbox, *name;
+ GtkWidget *w, *hbox, *name;
EMessageBoxReturn ret;
int loop = 1;
}
// create the window
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_window_set_title( GTK_WINDOW( window ), "Rename Path" );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
+ auto window = ui::Window( ui::window_type::TOP );
+ gtk_window_set_title( window, "Rename Path" );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
+ gtk_window_set_transient_for( window, g_pCameraInspectorWnd );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
// fill the window
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 5 );
+ window.add(vbox);
+ vbox.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Name:" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Name:" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- name = gtk_entry_new();
- gtk_box_pack_start( GTK_BOX( hbox ), name, FALSE, FALSE, 0 );
- gtk_widget_show( name );
+ name = ui::Entry();
+ hbox.pack_start( name, FALSE, FALSE, 0 );
+ name.show();
if ( g_iActiveTarget < 0 ) {
gtk_entry_set_text( GTK_ENTRY( name ), GetCurrentCam()->GetCam()->getPositionObj()->getName() );
// -------------------------- //
w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 2 );
+ w.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- gtk_widget_show( w );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ w.show();
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// -------------------------- //
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
bool dialogError = TRUE;
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return TRUE;
}
static gint ci_add_target( GtkWidget *widget, gpointer data ){
- GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame, *name;
+ GtkWidget *w, *hbox, *name;
GtkWidget *fixed, *interpolated, *spline;
EMessageBoxReturn ret;
int loop = 1;
}
// create the window
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_window_set_title( GTK_WINDOW( window ), "Add Target" );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
+ auto window = ui::Window( ui::window_type::TOP );
+ gtk_window_set_title( window, "Add Target" );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
+ gtk_window_set_transient_for( window, g_pCameraInspectorWnd );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
// fill the window
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 5 );
+ window.add(vbox);
+ vbox.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Name:" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Name:" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- name = gtk_entry_new();
- gtk_box_pack_start( GTK_BOX( hbox ), name, TRUE, TRUE, 0 );
- gtk_widget_show( name );
+ name = ui::Entry();
+ hbox.pack_start( name, TRUE, TRUE, 0 );
+ name.show();
sprintf( buf, "target%i", GetCurrentCam()->GetCam()->numTargets() + 1 );
gtk_entry_set_text( GTK_ENTRY( name ), buf );
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- frame = gtk_frame_new( "Type" );
- gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 );
- gtk_widget_show( frame );
+ auto frame = ui::Frame( "Type" );
+ hbox.pack_start( frame, TRUE, TRUE, 0 );
+ frame.show();
- vbox2 = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( frame ), vbox2 );
+ auto vbox2 = ui::VBox( FALSE, 5 );
+ frame.add(vbox2);
gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 );
- gtk_widget_show( vbox2 );
+ vbox2.show();
// -------------------------- //
fixed = gtk_radio_button_new_with_label( targetTypeRadio, "Fixed" );
- gtk_box_pack_start( GTK_BOX( vbox2 ), fixed, FALSE, FALSE, 3 );
- gtk_widget_show( fixed );
- targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( fixed ) );
+ vbox2.pack_start( fixed, FALSE, FALSE, 3 );
+ fixed.show();
+ targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( fixed ) );
interpolated = gtk_radio_button_new_with_label( targetTypeRadio, "Interpolated" );
- gtk_box_pack_start( GTK_BOX( vbox2 ), interpolated, FALSE, FALSE, 3 );
- gtk_widget_show( interpolated );
- targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( interpolated ) );
+ vbox2.pack_start( interpolated, FALSE, FALSE, 3 );
+ interpolated.show();
+ targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( interpolated ) );
spline = gtk_radio_button_new_with_label( targetTypeRadio, "Spline" );
- gtk_box_pack_start( GTK_BOX( vbox2 ), spline, FALSE, FALSE, 3 );
- gtk_widget_show( spline );
- targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( spline ) );
+ vbox2.pack_start( spline, FALSE, FALSE, 3 );
+ spline.show();
+ targetTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( spline ) );
// -------------------------- //
w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 2 );
+ w.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- gtk_widget_show( w );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ w.show();
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// -------------------------- //
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
bool dialogError = TRUE;
// Select the last item in the listbox
li = g_list_last( GTK_LIST( GTK_COMBO( g_pPathListCombo )->list )->children );
- gtk_list_select_child( GTK_LIST( GTK_COMBO( g_pPathListCombo )->list ), GTK_WIDGET( li->data ) );
+ gtk_list_select_child( GTK_LIST( GTK_COMBO( g_pPathListCombo )->list ), li->data );
// If this was the first one, refresh the event list
if ( GetCurrentCam()->GetCam()->numTargets() == 1 ) {
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return TRUE;
}
combo_cam = firstCam;
while ( li && combo_cam ) {
if ( combo_cam == GetCurrentCam() ) {
- gtk_list_select_child( GTK_LIST( GTK_COMBO( g_pCamListCombo )->list ), GTK_WIDGET( li->data ) );
+ gtk_list_select_child( GTK_LIST( GTK_COMBO( g_pCamListCombo )->list ), li->data );
break;
}
li = li->next;
// start edit mode
g_iActiveTarget = -1;
- if ( g_pCameraInspectorWnd && GTK_WIDGET_VISIBLE( g_pCameraInspectorWnd ) ) {
+ if ( g_pCameraInspectorWnd && gtk_widget_get_visible( g_pCameraInspectorWnd ) ) {
DoStartEdit( GetCurrentCam() );
}
};
static gint ci_add( GtkWidget *widget, gpointer data ){
- GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame, *parameters;
+ GtkWidget *w, *hbox, *parameters;
GtkWidget *eventWidget[EVENT_COUNT];
EMessageBoxReturn ret;
int i, loop = 1;
}
// create the window
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_window_set_title( GTK_WINDOW( window ), "Add Event" );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
+ auto window = ui::Window( ui::window_type::TOP );
+ gtk_window_set_title( window, "Add Event" );
+ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
+ gtk_window_set_transient_for( window, g_pCameraInspectorWnd );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
// fill the window
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 5 );
+ window.add(vbox);
+ vbox.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- frame = gtk_frame_new( "Type" );
- gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 );
- gtk_widget_show( frame );
+ auto frame = ui::Frame( "Type" );
+ hbox.pack_start( frame, TRUE, TRUE, 0 );
+ frame.show();
- vbox2 = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( frame ), vbox2 );
+ auto vbox2 = ui::VBox( FALSE, 5 );
+ frame.add(vbox2);
gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 );
- gtk_widget_show( vbox2 );
+ vbox2.show();
// -------------------------- //
for ( i = 1; i < EVENT_COUNT; i++ ) {
eventWidget[i] = gtk_radio_button_new_with_label( eventTypeRadio, camEventStr[i] );
- gtk_box_pack_start( GTK_BOX( vbox2 ), eventWidget[i], FALSE, FALSE, 3 );
- gtk_widget_show( eventWidget[i] );
- eventTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( eventWidget[i] ) );
+ vbox2.pack_start( eventWidget[i], FALSE, FALSE, 3 );
+ eventWidget[i].show();
+ eventTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( eventWidget[i] ) );
if ( camEventFlags[i][1] == false ) {
gtk_widget_set_sensitive( eventWidget[i], FALSE );
}
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Parameters:" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Parameters:" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- parameters = gtk_entry_new();
- gtk_box_pack_start( GTK_BOX( hbox ), parameters, TRUE, TRUE, 0 );
- gtk_widget_show( parameters );
+ parameters = ui::Entry();
+ hbox.pack_start( parameters, TRUE, TRUE, 0 );
+ parameters.show();
// -------------------------- //
w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 2 );
+ w.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
- gtk_widget_show( w );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
+ w.show();
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
+ w.show();
ret = eIDCANCEL;
// -------------------------- //
- gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
- gtk_widget_show( window );
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+ window.show();
gtk_grab_add( window );
bool dialogError = TRUE;
}
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return TRUE;
}
}
GtkWidget *CreateCameraInspectorDialog( void ){
- GtkWidget *window, *w, *vbox, *hbox, *table, *frame;
+ GtkWidget *w, *hbox;
// create the window
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_window_set_title( GTK_WINDOW( window ), "Camera Inspector" );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( ci_close ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL );
- // gtk_signal_connect( GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) );
+ auto window = ui::Window( ui::window_type::TOP );
+ gtk_window_set_title( window, "Camera Inspector" );
+ window.connect( "delete_event", G_CALLBACK( ci_close ), NULL );
+ window.connect( "expose_event", G_CALLBACK( ci_expose ), NULL );
+ // window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
+ gtk_window_set_transient_for( window, g_pRadiantWnd );
// don't use show, as you don't want to have it displayed on startup ;-)
gtk_widget_realize( window );
// the table
// -------------------------- //
- table = gtk_table_new( 3, 2, FALSE );
- gtk_widget_show( table );
- gtk_container_add( GTK_CONTAINER( window ), table );
+ auto table = ui::Table( 3, 2, FALSE );
+ table.show();
+ window.add(table);
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
// the properties column
// -------------------------- //
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
+ table.attach(vbox, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "File:" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "File:" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
g_pCamListCombo = gtk_combo_new();
- gtk_box_pack_start( GTK_BOX( hbox ), g_pCamListCombo, TRUE, TRUE, 0 );
- gtk_widget_show( g_pCamListCombo );
+ hbox.pack_start( g_pCamListCombo, TRUE, TRUE, 0 );
+ g_pCamListCombo.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Name:" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Name:" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- g_pCamName = gtk_entry_new();
- gtk_box_pack_start( GTK_BOX( hbox ), g_pCamName, FALSE, FALSE, 0 );
- gtk_widget_show( g_pCamName );
+ g_pCamName = ui::Entry();
+ hbox.pack_start( g_pCamName, FALSE, FALSE, 0 );
+ g_pCamName.show();
- w = gtk_label_new( "Type: " );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Type: " );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- w = gtk_label_new( "" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
g_pCamType = GTK_LABEL( w );
RefreshCamListCombo();
- gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO( g_pCamListCombo )->entry ), FALSE );
- gtk_signal_connect( GTK_OBJECT( GTK_COMBO( g_pCamListCombo )->entry ), "changed", GTK_SIGNAL_FUNC( ci_camlist_changed ), NULL );
+ gtk_editable_set_editable( GTK_EDITABLE( GTK_COMBO( g_pCamListCombo )->entry ), FALSE );
+ ( GTK_COMBO( g_pCamListCombo )->entry ).connect( "changed", G_CALLBACK( ci_camlist_changed ), NULL );
// -------------------------- //
- frame = gtk_frame_new( "Path and Target editing" );
- gtk_widget_show( frame );
- gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ auto frame = ui::Frame( "Path and Target editing" );
+ frame.show();
+ table.attach(frame, {0, 1, 1, 2}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( frame ), vbox );
+ auto vbox = ui::VBox( FALSE, 5 );
+ frame.add(vbox);
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- gtk_widget_show( vbox );
+ vbox.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Edit:" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Edit:" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
g_pPathListCombo = gtk_combo_new();
- gtk_box_pack_start( GTK_BOX( hbox ), g_pPathListCombo, TRUE, TRUE, 0 );
- gtk_widget_show( g_pPathListCombo );
+ hbox.pack_start( g_pPathListCombo, TRUE, TRUE, 0 );
+ g_pPathListCombo.show();
RefreshPathListCombo();
- gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO( g_pPathListCombo )->entry ), FALSE );
- gtk_signal_connect( GTK_OBJECT( GTK_COMBO( g_pPathListCombo )->entry ), "changed", GTK_SIGNAL_FUNC( ci_pathlist_changed ), NULL );
+ gtk_editable_set_editable( GTK_EDITABLE( GTK_COMBO( g_pPathListCombo )->entry ), FALSE );
+ ( GTK_COMBO( g_pPathListCombo )->entry ).connect( "changed", G_CALLBACK( ci_pathlist_changed ), NULL );
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
g_pEditModeEditRadioButton = gtk_radio_button_new_with_label( g_pEditTypeRadio, "Edit Points" );
- gtk_box_pack_start( GTK_BOX( hbox ), g_pEditModeEditRadioButton, FALSE, FALSE, 3 );
- gtk_widget_show( g_pEditModeEditRadioButton );
- g_pEditTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( g_pEditModeEditRadioButton ) );
+ hbox.pack_start( g_pEditModeEditRadioButton, FALSE, FALSE, 3 );
+ g_pEditModeEditRadioButton.show();
+ g_pEditTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( g_pEditModeEditRadioButton ) );
- gtk_signal_connect( GTK_OBJECT( g_pEditModeEditRadioButton ), "clicked", GTK_SIGNAL_FUNC( ci_editmode_edit ), NULL );
+ g_pEditModeEditRadioButton.connect( "clicked", G_CALLBACK( ci_editmode_edit ), NULL );
g_pEditModeAddRadioButton = gtk_radio_button_new_with_label( g_pEditTypeRadio, "Add Points" );
- gtk_box_pack_start( GTK_BOX( hbox ), g_pEditModeAddRadioButton, FALSE, FALSE, 3 );
- gtk_widget_show( g_pEditModeAddRadioButton );
- g_pEditTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( g_pEditModeAddRadioButton ) );
+ hbox.pack_start( g_pEditModeAddRadioButton, FALSE, FALSE, 3 );
+ g_pEditModeAddRadioButton.show();
+ g_pEditTypeRadio = gtk_radio_button_get_group( GTK_RADIO_BUTTON( g_pEditModeAddRadioButton ) );
- gtk_signal_connect( GTK_OBJECT( g_pEditModeAddRadioButton ), "clicked", GTK_SIGNAL_FUNC( ci_editmode_add ), NULL );
+ g_pEditModeAddRadioButton.connect( "clicked", G_CALLBACK( ci_editmode_add ), NULL );
// see if we should use a different default
if ( g_iEditMode == 1 ) {
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( g_pEditModeAddRadioButton ), TRUE );
}
- w = gtk_label_new( "Type: " );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Type: " );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- w = gtk_label_new( "" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
g_pPathType = GTK_LABEL( w );
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_button_new_with_label( "Rename..." );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_rename ), NULL );
- gtk_widget_show( w );
+ w = ui::Button( "Rename..." );
+ hbox.pack_start( w, FALSE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_rename ), NULL );
+ w.show();
- w = gtk_button_new_with_label( "Add Target..." );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_add_target ), NULL );
- gtk_widget_show( w );
+ w = ui::Button( "Add Target..." );
+ hbox.pack_start( w, FALSE, TRUE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_add_target ), NULL );
+ w.show();
// not available in splines library
/*w = gtk_button_new_with_label( "Delete Selected" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0);
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_delete_selected ), NULL );
- gtk_widget_show( w );
+ hbox.pack_start( w, FALSE, TRUE, 0);
+ w.connect( "clicked", G_CALLBACK( ci_delete_selected ), NULL );
+ w.show();
w = gtk_button_new_with_label( "Select All" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0);
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_select_all ), NULL );
- gtk_widget_show( w );*/
+ hbox.pack_start( w, FALSE, TRUE, 0);
+ w.connect( "clicked", G_CALLBACK( ci_select_all ), NULL );
+ w.show();*/
// -------------------------- //
- frame = gtk_frame_new( "Time" );
- gtk_widget_show( frame );
- gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ frame = ui::Frame( "Time" );
+ frame.show();
+ table.attach(frame, {0, 1, 2, 3}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( frame ), vbox );
+ vbox = ui::VBox( FALSE, 5 );
+ frame.add(vbox);
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- gtk_widget_show( vbox );
+ vbox.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Length (seconds):" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Length (seconds):" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- g_pSecondsEntry = gtk_entry_new();
- gtk_box_pack_start( GTK_BOX( hbox ), g_pSecondsEntry, FALSE, FALSE, 0 );
- gtk_widget_show( g_pSecondsEntry );
+ g_pSecondsEntry = ui::Entry();
+ hbox.pack_start( g_pSecondsEntry, FALSE, FALSE, 0 );
+ g_pSecondsEntry.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Current Time: " );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Current Time: " );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- w = gtk_label_new( "0.00" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "0.00" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
g_pCurrentTime = GTK_LABEL( w );
- w = gtk_label_new( " of " );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( " of " );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
- w = gtk_label_new( "0.00" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "0.00" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
g_pTotalTime = GTK_LABEL( w );
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
-
- g_pTimeLine = GTK_ADJUSTMENT( gtk_adjustment_new( 0, 0, 30000, 100, 250, 0 ) );
- gtk_signal_connect( GTK_OBJECT( g_pTimeLine ), "value_changed", GTK_SIGNAL_FUNC( ci_timeline_changed ), NULL );
- w = gtk_hscale_new( g_pTimeLine );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_widget_show( w );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
+
+ g_pTimeLine = ui::Adjustment( 0, 0, 30000, 100, 250, 0 );
+ g_pTimeLine.connect( "value_changed", G_CALLBACK( ci_timeline_changed ), NULL );
+ w = ui::HScale( g_pTimeLine );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.show();
gtk_scale_set_draw_value( GTK_SCALE( w ), FALSE );
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- g_pTrackCamera = gtk_check_button_new_with_label( "Track Camera" );
- gtk_box_pack_start( GTK_BOX( hbox ), g_pTrackCamera, FALSE, FALSE, 0 );
- gtk_widget_show( g_pTrackCamera );
+ g_pTrackCamera = ui::CheckButton( "Track Camera" );
+ hbox.pack_start( g_pTrackCamera, FALSE, FALSE, 0 );
+ g_pTrackCamera.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_label_new( "Events:" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
- gtk_widget_show( w );
+ w = ui::Label( "Events:" );
+ hbox.pack_start( w, FALSE, FALSE, 0 );
+ w.show();
// -------------------------- //
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 5 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+ hbox.show();
- w = gtk_scrolled_window_new( NULL, NULL );
- gtk_widget_set_usize( w, 0, 150 );
+ auto scr = w = ui::ScrolledWindow();
+ w.dimensions( 0, 150 );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( w ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_widget_show( w );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.show();
g_pEventsList = gtk_clist_new( 3 );
- gtk_container_add( GTK_CONTAINER( w ), g_pEventsList );
- //gtk_signal_connect( GTK_OBJECT(g_pEventsList), "select_row", GTK_SIGNAL_FUNC (proplist_select_row), NULL);
+ scr.add(g_pEventsList);
+ //g_pEventsList.connect( "select_row", G_CALLBACK (proplist_select_row), NULL);
gtk_clist_set_selection_mode( GTK_CLIST( g_pEventsList ), GTK_SELECTION_BROWSE );
gtk_clist_column_titles_hide( GTK_CLIST( g_pEventsList ) );
gtk_clist_set_column_auto_resize( GTK_CLIST( g_pEventsList ), 0, TRUE );
gtk_clist_set_column_auto_resize( GTK_CLIST( g_pEventsList ), 1, TRUE );
gtk_clist_set_column_auto_resize( GTK_CLIST( g_pEventsList ), 2, TRUE );
- gtk_widget_show( g_pEventsList );
+ g_pEventsList.show();
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, FALSE, 0 );
- gtk_widget_show( vbox );
+ vbox = ui::VBox( FALSE, 5 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
+ vbox.show();
- w = gtk_button_new_with_label( "Add..." );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_add ), NULL );
- gtk_widget_show( w );
+ w = ui::Button( "Add..." );
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_add ), NULL );
+ w.show();
- w = gtk_button_new_with_label( "Del" );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_del ), NULL );
- gtk_widget_show( w );
+ w = ui::Button( "Del" );
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_del ), NULL );
+ w.show();
// -------------------------- //
// -------------------------- //
vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_table_attach( GTK_TABLE( table ), vbox, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ vbox.show();
+ table.attach(vbox, {1, 2, 0, 1}, {GTK_FILL, GTK_FILL});
w = gtk_button_new_with_label( "New..." );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_new ), NULL );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_new ), NULL );
+ w.show();
w = gtk_button_new_with_label( "Load..." );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_load ), NULL );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_load ), NULL );
+ w.show();
// -------------------------- //
vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_table_attach( GTK_TABLE( table ), vbox, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ vbox.show();
+ table.attach( vbox, {1, 2, 1, 2}, {GTK_FILL, GTK_FILL});
w = gtk_button_new_with_label( "Save..." );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_save ), NULL );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_save ), NULL );
+ w.show();
w = gtk_button_new_with_label( "Unload" );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_unload ), NULL );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_unload ), NULL );
+ w.show();
hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 );
- gtk_widget_show( hbox );
+ vbox.pack_start( hbox, TRUE, TRUE, 0 );
+ hbox.show();
w = gtk_button_new_with_label( "Apply" );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_apply ), NULL );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_apply ), NULL );
+ w.show();
w = gtk_button_new_with_label( "Preview" );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_preview ), NULL );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_preview ), NULL );
+ w.show();
// -------------------------- //
vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_table_attach( GTK_TABLE( table ), vbox, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ vbox.show();
+ table.attach(vbox, {1, 2, 2, 3}, {GTK_FILL, GTK_FILL});
hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 );
- gtk_widget_show( hbox );
+ vbox.pack_start( hbox, TRUE, TRUE, 0 );
+ hbox.show();
w = gtk_button_new_with_label( "Close" );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_close ), NULL );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ vbox.pack_start( w, FALSE, FALSE, 0 );
+ w.connect( "clicked", G_CALLBACK( ci_close ), NULL );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
// -------------------------- //
#include "camera.h"
-void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
*/
#include "camera.h"
+#include "globaldefs.h"
extern GtkWidget *g_pEditModeAddRadioButton;
char* Q_realpath( const char *path, char *resolved_path, size_t size ){
-#if defined( POSIX )
+#if GDEF_OS_POSIX
return realpath( path, resolved_path );
-#elif defined( WIN32 )
+#elif GDEF_OS_WINDOWS
return _fullpath( resolved_path, path, size );
#else
#error "unsupported platform"
}
void DoCameraInspector(){
- gtk_widget_show( g_pCameraInspectorWnd );
+ g_pCameraInspectorWnd.show();
}
void DoPreviewCamera(){
*/
#include "camera.h"
+#include "globaldefs.h"
void Sys_ERROR( char* text, ... ){
va_list argptr;
}
char* UnixToDosPath( char* path ){
-#ifndef WIN32
+#if !GDEF_OS_WINDOWS
return path;
#else
for ( char* p = path; *p; p++ )
}
void CDECL Com_DPrintf( const char* msg, ... ){
-#ifdef _DEBUG
+#if GDEF_DEBUG
va_list argptr;
char buf[32768];
// Filesystem
//
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4311)
#pragma warning(disable : 4312)
#endif
Copyright (C) 2002 Splash Damage Ltd.
*/
+#include "globaldefs.h"
+
void Sys_ERROR( char* text, ... );
char* UnixToDosPath( char* path );
void ExtractFilePath( const char *path, char *dest );
// common
#ifndef CDECL
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#define CDECL __cdecl
#else
#define CDECL
if ( g_pWnd ) {
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_file" ) ), gbmp.name );
- gtk_widget_set_sensitive( GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_reload" ) ),
+ gtk_widget_set_sensitive( g_object_get_data( G_OBJECT( g_pWnd , "bmp_reload" ) ),
strlen( gbmp.name ) ? TRUE : FALSE );
UpdatePreview( true );
//#define BUFF_SIZE 32768
#define ENABLE_WIDGET( name,enable ) \
- gtk_widget_set_sensitive( GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), ( name ) ) ), ( enable ) )
+ gtk_widget_set_sensitive( g_object_get_data( G_OBJECT( g_pWnd , ( name ) ) ), ( enable ) )
#define CHECK_WIDGET( name,check ) \
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), name ) ), check )
case EXTENTS_TAB:
if ( Game != QUAKE3 ) {
- gtk_widget_hide( GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "use_patches" ) ) );
+ gtk_widget_hide( g_object_get_data( G_OBJECT( g_pWnd , "use_patches" ) ) );
ENABLE_WIDGET( "use_patches", FALSE );
}
else
{
- gtk_widget_show( GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "use_patches" ) ) );
+ gtk_widget_show( g_object_get_data( G_OBJECT( g_pWnd , "use_patches" ) ) );
ENABLE_WIDGET( "use_patches", TRUE );
}
Decimate );
if ( Game == QUAKE3 && UsePatches ) {
- gtk_widget_set_sensitive( GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "decimate" ) ), FALSE );
+ gtk_widget_set_sensitive( g_object_get_data( G_OBJECT( g_pWnd , "decimate" ) ), FALSE );
if ( NH % 2 ) {
NH++;
}
else
{
- gtk_widget_set_sensitive( GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "decimate" ) ), TRUE );
+ gtk_widget_set_sensitive( g_object_get_data( G_OBJECT( g_pWnd , "decimate" ) ), TRUE );
gpointer spin = g_object_get_data( G_OBJECT( g_pWnd ), "nh" );
GtkAdjustment *adj = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
}
static void main_go( GtkWidget *widget, gpointer data ){
- GtkWidget *notebook = GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "notebook" ) );
+ GtkWidget *notebook = g_object_get_data( G_OBJECT( g_pWnd , "notebook" ) );
char Text[256];
ReadDlgValues( current_tab );
"GenSurf", eMB_OK, eMB_ICONWARNING );
sprintf( Text, "%d", (int)xyz[Vertex[0].i][Vertex[0].j].fixed_value );
gtk_entry_set_text( GTK_ENTRY( widget ), Text );
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( widget ) ), widget );
+ gtk_window_set_focus( widget.window(), widget );
}
else if ( i != xyz[Vertex[0].i][Vertex[0].j].fixed_value ) {
for ( k = 0; k < NumVerticesSelected; k++ )
// Main
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "go" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "go" ) ),
"Accept all input and generate a surface in Q3Radiant",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "open" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "open" ) ),
"Open a previously saved GenSurf settings file.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "save" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "save" ) ),
"Save all settings to a file.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "defaults" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "defaults" ) ),
"Restore default values from DEFAULTS.SRF. If this file does not exist, GenSurf "
"initializes all input parameters to reasonable values. You can create your own "
"default surface by setting all parameters to your liking, then saving a settings "
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "main_preview" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "main_preview" ) ),
"View a wire-frame representation of the surface",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "main_antialiasing" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "main_antialiasing" ) ),
"The lines in the preview window are antialiased for better quality",
"" );
// General tab
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( wave_radios[0] ),
+ wave_radios[0] ,
"Builds a surface with alternating hills and valleys. Uses the general form Z=cos(X) "
"x sin(Y)",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( wave_radios[1] ),
+ wave_radios[1] ,
"Builds a surface with ridges parallel to the vertical axis.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( wave_radios[2] ),
+ wave_radios[2] ,
"Builds a surface with ridges parallel to the horizontal axis.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( wave_radios[3] ),
+ wave_radios[3] ,
"Builds a map from a bitmap image representing a contour plot. Click the \"Bitmap\" "
"tab to select the image. GenSurf only supports 256-color (8 bit) "
"bitmaps. GenSurf will work with any 256-color bitmap, but gray scale bitmaps are a bit "
"more intuitive.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( wave_radios[4] ),
+ wave_radios[4] ,
"Builds a random surface using the Plasma Cloud technique. Variance is controlled "
"by the Roughness input. To build a surface with completely random values not "
"dependent on neighboring vertices, use one of the other waveforms with 0 amplitude.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "wavelength" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "wavelength" ) ),
"Enter the wavelength (distance between crests). NOTE: Wavelengths equal to the grid "
"size or 2 times the grid size will result in 0 amplitudes. For best results, the "
"wavelength value should be at least 4 times the grid size (extents divided by the "
"number of divisions",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "amplitude" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "amplitude" ) ),
"Enter the height of hills/ridges.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "roughness" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "roughness" ) ),
"Enter the roughness value (noise) for the surface. For fractal surfaces, this value "
"is used as a variance in the fractal calculations.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "random" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "random" ) ),
"Seed value for the pseudo-random number generator.",
"" );
// Extents tab
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "hmin" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "hmin" ) ),
"Minimum horizontal coordinate of the surface, i.e. X for a surface parallel to "
"the XY or XZ planes, Y for a surface parallel to the YZ plane. For best results, "
"the extents (maximum-minimum values) in a given direction should be evenly "
"divisible by the number of divisions in that direction.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "hmax" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "hmax" ) ),
"Maximum horizontal coordinate of the surface, i.e. X for a surface parallel to "
"the XY or XZ planes, Y for a surface parallel to the YZ plane. For best results, "
"the extents (maximum-minimum values) in a given direction should be evenly "
"divisible by the number of divisions in that direction.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "vmin" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "vmin" ) ),
"Minimum vertical coordinate of the surface, i.e. Y for a surface parallel to "
"the XY plane, Z for a surface parallel to the XZ or YZ planes. For best results, "
"the extents (maximum-minimum values) in a given direction should be evenly "
"divisible by the number of divisions in that direction.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "vmax" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "vmax" ) ),
"Maximum vertical coordinate of the surface, i.e. Y for a surface parallel to "
"the XY plane, Z for a surface parallel to the XZ or YZ planes. For best results, "
"the extents (maximum-minimum values) in a given direction should be evenly "
"divisible by the number of divisions in that direction.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "nh" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "nh" ) ),
"Number of divisions in the horizontal direction. For best results, the extents "
"in a given direction should be evenly divisible by the number of divisions in "
"that direction.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "nv" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "nv" ) ),
"Number of divisions in the vertical direction. For best results, the extents "
"in a given direction should be evenly divisible by the number of divisions in "
"that direction.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "use_patches" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "use_patches" ) ),
"Produce one or more curved patches in the shape of your selected surface rather "
"than producing solid brushes. Depending on the size of your surface (and the "
"user's graphic detail settings, which you cannot control), curved surfaces will "
"concerning curved surfaces on the GenSurf web page before using this feature.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "decimate" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "decimate" ) ),
"Use the slider to control the number of vertices discarded by GenSurf. For many "
"surfaces, you can produce roughly the same shape surface with a high decimation "
"value. This will generally result in a map with lower polygon counts (and better "
"surfaces in Q3",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "z00" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "z00" ) ),
"Enter the height of the surface at the lower left corner. This value will likely "
"be modified unless \"Linear Borders\" is checked.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "z01" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "z01" ) ),
"Enter the height of the surface at the upper left corner. This value will likely "
"be modified unless \"Linear Borders\" is checked.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "z10" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "z10" ) ),
"Enter the height of the surface at the lower right corner. This value will likely "
"be modified unless \"Linear Borders\" is checked.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "z11" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "z11" ) ),
"Enter the height of the surface at the upper right corner. This value will likely "
"be modified unless \"Linear Borders\" is checked.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "linearborder" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "linearborder" ) ),
"Restrict the edges of the surface to a straight line. This will help match up "
"brush edges if you drop this surface into another map.",
"" );
// Bitmap tab
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_file" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "bmp_file" ) ),
"Type the name of an 8-bit bitmap image file, or click Browse to select an image "
"from a list of those available on your system.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_file_browse" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "bmp_file_browse" ) ),
"Select a bitmap image file from a list of those available on your system.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_reload" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "bmp_reload" ) ),
"Reload the selected bitmap file after making changes in an external image editor.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_black" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "bmp_black" ) ),
"Enter the value corresponding to color index 0 in the bitmap file. For gray scale "
"images, color 0 is normally black.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_white" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "bmp_white" ) ),
"Enter the value corresponding to color index 255 in the bitmap file. For gray scale "
"images, color 255 is normally white.",
"" );
// Fixpoints tab
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "fix_value" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "fix_value" ) ),
"Enter a value for the selected vertex. This value will not be adjusted when applying "
"a waveform or roughness to the surface. Unlock this vertex (so that it will be "
"adjusted normally) by clicking \"Free\". This vertex will influence vertices within "
"the \"Range affected\" of this vertex.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "fix_range" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "fix_range" ) ),
"Enter the range away from the selected vertex that other vertices will be affected. "
"Use 0 if you don't want other vertices to be influenced by the currently selected "
"one. Note: this box is disabled if you've chosen the fractal generator, as it uses "
"a completely different method for determining values.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "fix_rate" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "fix_rate" ) ),
"Enter a rate of change for the surface affected by the fixed value. 0 gives a smooth "
"sinusoidal curve, values less than 0 give progressively sharper spikes, and values "
"greater than 0 take on a square shape. Values less than -30 or greater than 30 are "
"you also specify a \"range affected\".",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "fix_free" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "fix_free" ) ),
"Click this to free (unlock the value of) the currently selected vertex.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "fix_freeall" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "fix_freeall" ) ),
"Click this to free (unlock the values of) all vertices.",
"" );
// Texture tab
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "texture1" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "texture1" ) ),
"Enter the name of the texture or shader used for the surface faces.",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "texture2" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "texture2" ) ),
"Enter the name of the texture or shader used for faces other than the surface. Under "
"normal circumstances this should be \"common/caulk\"",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "texture3" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "texture3" ) ),
"Enter the name of the texture or shader used for \"steep\" surface faces, where \"steep\" "
"is the angle specified below. If this entry is left blank or if the \"steep\" angle is 0, "
"all surface faces will use the texture specified by \"Surface\".",
"" );
gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ),
- GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "detail" ) ),
+ g_object_get_data( G_OBJECT( g_pWnd , "detail" ) ),
"Check this box to use the detail content property on the generated brushes. Compile "
"times will be considerably shorter if the detail property is used, though the surface "
"will not block visibility at all. If you use the detail property, you should make sure "
// create main dialog
GtkWidget* create_main_dialog(){
- GtkWidget *dlg, *vbox, *hbox, *hbox2, *button, *notebook, *frame, *table, *table2;
+ GtkWidget *hbox2, *button, *notebook, *table2;
GtkWidget *check, *spin, *radio, *label, *entry, *scale;
- GtkObject *adj;
+ ui::Adjustment adj;
GSList *group;
int i;
const char *games[] = { "Quake 2", "Half-Life", "SiN", "Heretic 2", "Kingpin", "Genesis3D", "Quake 3 Arena" };
const char *orientations[] = { "Ground surface", "Ceiling", "Wall facing 0", "Wall facing 90",
"Wall facing 180","Wall facing 270" };
- g_pWnd = dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_window_set_title( GTK_WINDOW( dlg ), gszCaption );
- g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( main_close ), NULL );
- // g_signal_connect (G_OBJECT (dlg), "destroy", G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) );
+ auto dlg = g_pWnd = ui::Window( ui::window_type::TOP );
+ gtk_window_set_title( dlg, gszCaption );
+ dlg.connect( "delete_event", G_CALLBACK( main_close ), NULL );
+ // dlg.connect( "destroy", G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_window_set_transient_for( dlg, g_pRadiantWnd );
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_container_add( GTK_CONTAINER( dlg ), hbox );
+ auto hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ dlg.add(hbox);
gtk_container_set_border_width( GTK_CONTAINER( hbox ), 5 );
notebook = gtk_notebook_new();
- gtk_widget_show( notebook );
- gtk_box_pack_start( GTK_BOX( hbox ), notebook, TRUE, TRUE, 0 );
- g_signal_connect( G_OBJECT( notebook ), "switch_page",
+ notebook.show();
+ hbox.pack_start( notebook, TRUE, TRUE, 0 );
+ notebook.connect( "switch_page",
G_CALLBACK( switch_page ), NULL );
gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_TOP );
g_object_set_data( G_OBJECT( dlg ), "notebook", notebook );
- table = gtk_table_new( 2, 2, FALSE );
- gtk_widget_show( table );
+ table = ui::Table( 2, 2, FALSE );
+ table.show();
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
- label = gtk_label_new( "General" );
- gtk_widget_show( label );
+ label = ui::Label( "General" );
+ label.show();
gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), table, label );
- frame = gtk_frame_new( "Game" );
- gtk_widget_show( frame );
- gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ auto frame = ui::Frame( "Game" );
+ frame.show();
+ table.attach(frame, {0, 1, 0, 1});
- vbox = gtk_vbox_new( TRUE, 5 );
- gtk_widget_show( vbox );
- gtk_container_add( GTK_CONTAINER( frame ), vbox );
+ auto vbox = ui::VBox( TRUE, 5 );
+ vbox.show();
+ frame.add(vbox);
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
for ( i = 0, group = NULL; i < NUMGAMES; i++ )
{
radio = gtk_radio_button_new_with_label( group, games[i] );
- gtk_widget_show( radio );
- gtk_box_pack_start( GTK_BOX( vbox ), radio, TRUE, TRUE, 0 );
- group = gtk_radio_button_group( GTK_RADIO_BUTTON( radio ) );
+ radio.show();
+ vbox.pack_start( radio, TRUE, TRUE, 0 );
+ group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) );
game_radios[i] = radio;
- g_signal_connect( G_OBJECT( radio ), "toggled", G_CALLBACK( general_game ), GINT_TO_POINTER( i ) );
+ radio.connect( "toggled", G_CALLBACK( general_game ), GINT_TO_POINTER( i ) );
}
- frame = gtk_frame_new( "Waveform" );
- gtk_widget_show( frame );
- gtk_table_attach( GTK_TABLE( table ), frame, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ frame = ui::Frame( "Waveform" );
+ frame.show();
+ table.attach(frame, {1, 2, 0, 1});
- vbox = gtk_vbox_new( TRUE, 5 );
- gtk_widget_show( vbox );
- gtk_container_add( GTK_CONTAINER( frame ), vbox );
+ vbox = ui::VBox( TRUE, 5 );
+ vbox.show();
+ frame.add(vbox);
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
for ( i = 0, group = NULL; i < 5; i++ )
{
radio = gtk_radio_button_new_with_label( group, waveforms[i] );
- gtk_widget_show( radio );
- gtk_box_pack_start( GTK_BOX( vbox ), radio, TRUE, TRUE, 0 );
- group = gtk_radio_button_group( GTK_RADIO_BUTTON( radio ) );
+ radio.show();
+ vbox.pack_start( radio, TRUE, TRUE, 0 );
+ group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) );
wave_radios[i] = radio;
- g_signal_connect( G_OBJECT( radio ), "toggled", G_CALLBACK( general_wave ), GINT_TO_POINTER( i ) );
+ radio.connect( "toggled", G_CALLBACK( general_wave ), GINT_TO_POINTER( i ) );
}
- frame = gtk_frame_new( "Orientation" );
- gtk_widget_show( frame );
- gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ frame = ui::Frame( "Orientation" );
+ frame.show();
+ table.attach(frame, {0, 1, 1, 2});
- vbox = gtk_vbox_new( TRUE, 5 );
- gtk_widget_show( vbox );
- gtk_container_add( GTK_CONTAINER( frame ), vbox );
+ vbox = ui::VBox( TRUE, 5 );
+ vbox.show();
+ frame.add(vbox);
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
for ( i = 0, group = NULL; i < 6; i++ )
{
radio = gtk_radio_button_new_with_label( group, orientations[i] );
- gtk_widget_show( radio );
- gtk_box_pack_start( GTK_BOX( vbox ), radio, TRUE, TRUE, 0 );
- group = gtk_radio_button_group( GTK_RADIO_BUTTON( radio ) );
+ radio.show();
+ vbox.pack_start( radio, TRUE, TRUE, 0 );
+ group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) );
plane_radios[i] = radio;
- g_signal_connect( G_OBJECT( radio ), "toggled", G_CALLBACK( general_plane ), GINT_TO_POINTER( i ) );
+ radio.connect( "toggled", G_CALLBACK( general_plane ), GINT_TO_POINTER( i ) );
}
- table2 = gtk_table_new( 4, 2, FALSE );
- gtk_widget_show( table2 );
- gtk_table_set_row_spacings( GTK_TABLE( table2 ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table2 ), 5 );
- gtk_table_attach( GTK_TABLE( table ), table2, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
-
- label = gtk_label_new( "Wavelength:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ table2 = ui::Table( 4, 2, FALSE );
+ table2.show();
+ gtk_table_set_row_spacings(table2, 5);
+ gtk_table_set_col_spacings(table2, 5);
+ table.attach(table2, {1, 2, 1, 2});
+
+ label = ui::Label( "Wavelength:" );
+ label.show();
+ table2.attach(label, {0, 1, 0, 1});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT );
- label = gtk_label_new( "Max. amplitude:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ label = ui::Label( "Max. amplitude:" );
+ label.show();
+ table2.attach(label, {0, 1, 1, 2});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT );
- label = gtk_label_new( "Roughness:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ label = ui::Label( "Roughness:" );
+ label.show();
+ table2.attach(label, {0, 1, 2, 3});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT );
- label = gtk_label_new( "Random seed:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table2 ), label, 0, 1, 3, 4,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ label = ui::Label( "Random seed:" );
+ label.show();
+ table2.attach(label, {0, 1, 3, 4});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT );
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table2 ), entry, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry = ui::Entry();
+ entry.show();
+ table2.attach(entry, {1, 2, 0, 1});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "wavelength", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &WaveLength );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table2 ), entry, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &WaveLength );
+
+ entry = ui::Entry();
+ entry.show();
+ table2.attach(entry, {1, 2, 1, 2});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "amplitude", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Amplitude );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table2 ), entry, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Amplitude );
+
+ entry = ui::Entry();
+ entry.show();
+ table2.attach(entry, {1, 2, 2, 3});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "roughness", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Roughness );
-
- adj = gtk_adjustment_new( 1, 1, 32767, 1, 10, 0 );
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( general_random ), NULL );
- spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 );
- gtk_widget_show( spin );
- gtk_table_attach( GTK_TABLE( table2 ), spin, 1, 2, 3, 4,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( spin, 60, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Roughness );
+
+ adj = ui::Adjustment( 1, 1, 32767, 1, 10, 0 );
+ adj.connect( "value_changed", G_CALLBACK( general_random ), NULL );
+ spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ table2.attach(spin, {1, 2, 3, 4});
+ spin.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "random", spin );
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
+ vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- label = gtk_label_new( "Extents" );
- gtk_widget_show( label );
+ label = ui::Label( "Extents" );
+ label.show();
gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label );
- hbox2 = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox2 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 );
+ hbox2 = ui::HBox( FALSE, 5 );
+ hbox2.show();
+ vbox.pack_start( hbox2, FALSE, TRUE, 0 );
- frame = gtk_frame_new( "Extents" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( hbox2 ), frame, TRUE, TRUE, 0 );
+ frame = ui::Frame( "Extents" );
+ frame.show();
+ hbox2.pack_start( frame, TRUE, TRUE, 0 );
- table = gtk_table_new( 3, 4, FALSE );
- gtk_widget_show( table );
+ auto table = ui::Table( 3, 4, FALSE );
+ table.show();
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- label = gtk_label_new( "X:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ label = ui::Label( "X:" );
+ label.show();
+ table.attach( label, {0, 1, 1, 2}, {GTK_FILL, GTK_FILL});
g_object_set_data( G_OBJECT( dlg ), "hmin_text", label );
- label = gtk_label_new( "X:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ label = ui::Label( "X:" );
+ label.show();
+ table.attach(label, {2, 3, 1, 2}, {GTK_FILL, GTK_FILL});
g_object_set_data( G_OBJECT( dlg ), "hmax_text", label );
- label = gtk_label_new( "Y:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ label = ui::Label( "Y:" );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {GTK_FILL, GTK_FILL});
g_object_set_data( G_OBJECT( dlg ), "vmin_text", label );
- label = gtk_label_new( "Y:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ label = ui::Label( "Y:" );
+ label.show();
+ table.attach(label, {2, 3, 2, 3}, {GTK_FILL, GTK_FILL});
g_object_set_data( G_OBJECT( dlg ), "vmax_text", label );
- label = gtk_label_new( "Lower-left" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
-
- label = gtk_label_new( "Upper-right" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ label = ui::Label( "Lower-left" );
+ label.show();
+ table.attach(label, {1, 2, 0, 1}, {GTK_FILL, GTK_FILL});
+
+ label = ui::Label( "Upper-right" );
+ label.show();
+ table.attach(label, {3, 4, 0, 1},, {GTK_FILL, GTK_FILL});
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "hmin", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Hll );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Hll );
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {3, 4, 1, 2});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "hmax", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Hur );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Hur );
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 2, 3});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "vmin", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Vll );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Vll );
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {3, 4, 2, 3});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "vmax", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Vur );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Vur );
- frame = gtk_frame_new( "Divisions" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( hbox2 ), frame, TRUE, TRUE, 0 );
+ frame = ui::Frame( "Divisions" );
+ frame.show();
+ hbox2.pack_start( frame, TRUE, TRUE, 0 );
- table = gtk_table_new( 2, 2, FALSE );
- gtk_widget_show( table );
+ table = ui::Table( 2, 2, FALSE );
+ table.show();
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- label = gtk_label_new( "X:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ label = ui::Label( "X:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, GTK_EXPAND | GTK_FILL});
g_object_set_data( G_OBJECT( dlg ), "nh_text", label );
- label = gtk_label_new( "Y:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ label = ui::Label( "Y:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, GTK_EXPAND | GTK_FILL});
g_object_set_data( G_OBJECT( dlg ), "nv_text", label );
- adj = gtk_adjustment_new( 8, 1, MAX_ROWS, 1, 10, 0 );
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_nhnv_spin ), &NH );
- spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 );
- gtk_widget_show( spin );
- gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( spin, 60, -2 );
+ adj = ui::Adjustment( 8, 1, MAX_ROWS, 1, 10, 0 );
+ adj.connect( "value_changed", G_CALLBACK( extents_nhnv_spin ), &NH );
+ spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ table.attach(spin, {1, 2, 0, 1});
+ spin.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "nh", spin );
- adj = gtk_adjustment_new( 8, 1, MAX_ROWS, 1, 10, 0 );
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_nhnv_spin ), &NV );
- spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 );
- gtk_widget_show( spin );
- gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( spin, 60, -2 );
+ adj = ui::Adjustment( 8, 1, MAX_ROWS, 1, 10, 0 );
+ adj.connect( "value_changed", G_CALLBACK( extents_nhnv_spin ), &NV );
+ spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ table.attach(spin, {1, 2, 1, 2});
+ spin.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "nv", spin );
- check = gtk_check_button_new_with_label( "Use Bezier patches" );
- gtk_widget_show( check );
- gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 );
+ check = ui::CheckButton( "Use Bezier patches" );
+ check.show();
+ vbox.pack_start( check, FALSE, TRUE, 0 );
g_object_set_data( G_OBJECT( dlg ), "use_patches", check );
- g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( extents_use_patches ), NULL );
+ check.connect( "toggled", G_CALLBACK( extents_use_patches ), NULL );
// ^Fishman - Snap to grid, replaced scroll bar with a texbox.
- label = gtk_label_new( "Snap to grid:" );
- gtk_widget_show( label );
- gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 );
+ label = ui::Label( "Snap to grid:" );
+ label.show();
+ vbox.pack_start( label, FALSE, TRUE, 0 );
gtk_object_set_data( GTK_OBJECT( dlg ), "snap_text", label );
- adj = gtk_adjustment_new( 8, 0, 256, 1, 10, 0 );
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_snaptogrid_spin ), &SP );
- spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 );
- gtk_widget_show( spin );
- gtk_box_pack_start( GTK_BOX( vbox ), spin, FALSE, TRUE, 0 );
- gtk_widget_set_usize( spin, 60, -2 );
+ adj = ui::Adjustment( 8, 0, 256, 1, 10, 0 );
+ adj.connect( "value_changed", G_CALLBACK( extents_snaptogrid_spin ), &SP );
+ spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ vbox.pack_start( spin, FALSE, TRUE, 0 );
+ spin.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "sp", spin );
// ^Fishman - End of Snap to grid code.
- hbox2 = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox2 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 10 );
+ hbox2 = ui::HBox( FALSE, 5 );
+ hbox2.show();
+ vbox.pack_start( hbox2, FALSE, TRUE, 10 );
- label = gtk_label_new( "Decimate:" );
- gtk_widget_show( label );
- gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 );
+ label = ui::Label( "Decimate:" );
+ label.show();
+ hbox2.pack_start( label, FALSE, TRUE, 0 );
- adj = gtk_adjustment_new( 0, 0, 110, 1, 10, 0 );
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( extents_decimate ), NULL );
+ adj = ui::Adjustment( 0, 0, 110, 1, 10, 0 );
+ adj.connect( "value_changed", G_CALLBACK( extents_decimate ), NULL );
g_object_set_data( G_OBJECT( dlg ), "decimate_adj", adj );
- scale = gtk_hscale_new( GTK_ADJUSTMENT( adj ) );
- gtk_widget_show( scale );
- gtk_box_pack_start( GTK_BOX( hbox2 ), scale, TRUE, TRUE, 0 );
+ scale = ui::HScale( adj );
+ scale.show();
+ hbox2.pack_start( scale, TRUE, TRUE, 0 );
gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_RIGHT );
gtk_scale_set_digits( GTK_SCALE( scale ), 0 );
g_object_set_data( G_OBJECT( dlg ), "decimate", scale );
- frame = gtk_frame_new( "Corner values" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
+ frame = ui::Frame( "Corner values" );
+ frame.show();
+ vbox.pack_start( frame, FALSE, TRUE, 0 );
- table = gtk_table_new( 3, 4, FALSE );
- gtk_widget_show( table );
+ table = ui::Table( 3, 4, FALSE );
+ table.show();
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- label = gtk_label_new( "Upper-left:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
-
- label = gtk_label_new( "Lower-left:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
-
- label = gtk_label_new( "Upper-right:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
-
- label = gtk_label_new( "Lower-right:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ label = ui::Label( "Upper-left:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, GTK_FILL});
+
+ label = ui::Label( "Lower-left:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, GTK_FILL});
+
+ label = ui::Label( "Upper-right:" );
+ label.show();
+ table.attach(label, {2, 3, 0, 1}, {GTK_FILL, GTK_FILL});
+
+ label = ui::Label( "Lower-right:" );
+ label.show();
+ table.attach(label, {2, 3, 1, 2}, {GTK_FILL, GTK_FILL});
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "z01", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z01 );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z01 );
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "z00", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z00 );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z00 );
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {3, 4, 0, 1});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "z11", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z11 );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z11 );
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {3, 4, 1, 2});
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "z10", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z10 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &Z10 );
- check = gtk_check_button_new_with_label( "Linear borders" );
- gtk_widget_show( check );
- gtk_table_attach( GTK_TABLE( table ), check, 0, 4, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ check = ui::CheckButton( "Linear borders" );
+ check.show();
+ table.attach(check, {0, 4, 2, 3});
g_object_set_data( G_OBJECT( dlg ), "linearborder", check );
- g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( extents_linearborder ), NULL );
+ check.connect( "toggled", G_CALLBACK( extents_linearborder ), NULL );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_widget_show( vbox );
+ vbox = ui::VBox( FALSE, 10 );
+ vbox.show();
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- label = gtk_label_new( "Bitmap" );
- gtk_widget_show( label );
+ label = ui::Label( "Bitmap" );
+ label.show();
gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label );
- label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 );
+ label = ui::Label( "" );
+ label.show();
+ vbox.pack_start( label, FALSE, TRUE, 0 );
g_object_set_data( G_OBJECT( dlg ), "bmp_note", label );
- table = gtk_table_new( 2, 2, FALSE );
- gtk_widget_show( table );
+ table = ui::Table( 2, 2, FALSE );
+ table.show();
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- label = gtk_label_new( "Filename:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ vbox.pack_start( table, FALSE, TRUE, 0 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ label = ui::Label( "Filename:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, GTK_FILL});
g_object_set_data( G_OBJECT( dlg ), "bmp_text1", label );
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
g_object_set_data( G_OBJECT( dlg ), "bmp_file", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( bitmap_file_entryfocusout ), NULL );
-
- hbox2 = gtk_hbox_new( TRUE, 5 );
- gtk_widget_show( hbox2 );
- gtk_table_attach( GTK_TABLE( table ), hbox2, 1, 2, 1, 2,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
-
- button = gtk_button_new_with_label( "Browse..." );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( bitmap_file_entryfocusout ), NULL );
+
+ hbox2 = ui::HBox( TRUE, 5 );
+ hbox2.show();
+ table.attach(hbox2, {1, 2, 1, 2}, {0, GTK_EXPAND | GTK_FILL});
+
+ button = ui::Button( "Browse..." );
+ button.show();
+ hbox2.pack_start( button, FALSE, FALSE, 0 );
+ button.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "bmp_file_browse", button );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( bitmap_browse ), NULL );
+ button.connect( "clicked", G_CALLBACK( bitmap_browse ), NULL );
- button = gtk_button_new_with_label( "Reload" );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button = ui::Button( "Reload" );
+ button.show();
+ hbox2.pack_start( button, FALSE, FALSE, 0 );
+ button.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "bmp_reload", button );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( bitmap_reload ), NULL );
+ button.connect( "clicked", G_CALLBACK( bitmap_reload ), NULL );
- table = gtk_table_new( 2, 2, TRUE );
- gtk_widget_show( table );
+ table = ui::Table( 2, 2, TRUE );
+ table.show();
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- label = gtk_label_new( "Map color 0 to:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ vbox.pack_start( table, FALSE, TRUE, 0 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ label = ui::Label( "Map color 0 to:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL | GTK_EXPAND, GTK_FILL});
g_object_set_data( G_OBJECT( dlg ), "bmp_text2", label );
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT );
- label = gtk_label_new( "Map color 255 to:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ label = ui::Label( "Map color 255 to:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL | GTK_EXPAND, GTK_FILL});
g_object_set_data( G_OBJECT( dlg ), "bmp_text3", label );
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_RIGHT );
- hbox2 = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox2 );
- gtk_table_attach( GTK_TABLE( table ), hbox2, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ hbox2 = ui::HBox( FALSE, 5 );
+ hbox2.show();
+ table.attach(hbox2, {1, 2, 0, 1});
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_box_pack_start( GTK_BOX( hbox2 ), entry, FALSE, FALSE, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry = ui::Entry();
+ entry.show();
+ hbox2.pack_start( entry, FALSE, FALSE, 0 );
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "bmp_black", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &gbmp.black_value );
-
- hbox2 = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox2 );
- gtk_table_attach( GTK_TABLE( table ), hbox2, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_box_pack_start( GTK_BOX( hbox2 ), entry, FALSE, FALSE, 0 );
- gtk_widget_set_usize( entry, 50, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &gbmp.black_value );
+
+ hbox2 = ui::HBox( FALSE, 5 );
+ hbox2.show();
+ table.attach(hbox2, {1, 2, 1, 2});
+
+ entry = ui::Entry();
+ entry.show();
+ hbox2.pack_start( entry, FALSE, FALSE, 0 );
+ entry.dimensions( 50, -1 );
g_object_set_data( G_OBJECT( dlg ), "bmp_white", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &gbmp.white_value );
+ entry.connect( "focus_out_event", G_CALLBACK( doublevariable_entryfocusout ), &gbmp.white_value );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_widget_show( vbox );
+ vbox = ui::VBox( FALSE, 10 );
+ vbox.show();
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- label = gtk_label_new( "Fix Points" );
- gtk_widget_show( label );
+ label = ui::Label( "Fix Points" );
+ label.show();
gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label );
- label = gtk_label_new( "Click on a vertex in the lower half of the preview window,\n"
+ label = ui::Label( "Click on a vertex in the lower half of the preview window,\n"
"then use the arrow keys or text box to assign a value.\n"
"Use Ctrl+Click to select multiple vertices/toggle a\n"
"selection. Use Shift+Click to select a range of vertices.\n\n"
"Click \"Free\" to unlock a vertex. Vertices within \"Range\n"
"affected\" will be influenced by this vertex." );
- gtk_widget_show( label );
- gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 );
+ label.show();
+ vbox.pack_start( label, FALSE, TRUE, 0 );
- table = gtk_table_new( 3, 3, FALSE );
- gtk_widget_show( table );
+ table = ui::Table( 3, 3, FALSE );
+ table.show();
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
- gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- label = gtk_label_new( "Value:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ vbox.pack_start( table, FALSE, TRUE, 0 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ label = ui::Label( "Value:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, GTK_FILL});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
g_object_set_data( G_OBJECT( dlg ), "fix_value_text", label );
- label = gtk_label_new( "Range affected:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ label = ui::Label( "Range affected:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, GTK_FILL});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
g_object_set_data( G_OBJECT( dlg ), "fix_range_text", label );
- label = gtk_label_new( "Rate of change:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ label = ui::Label( "Rate of change:" );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {GTK_FILL, GTK_FILL});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
g_object_set_data( G_OBJECT( dlg ), "fix_rate_text", label );
- adj = gtk_adjustment_new( 0, -65536, 65536, 1, 16, 0 );
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( fix_value_changed ), NULL );
- spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 );
- gtk_widget_show( spin );
- gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( GTK_EXPAND ), 0, 0 );
- gtk_widget_set_usize( spin, 60, -2 );
+ adj = ui::Adjustment( 0, -65536, 65536, 1, 16, 0 );
+ adj.connect( "value_changed", G_CALLBACK( fix_value_changed ), NULL );
+ spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ table.attach(spin, {1, 2, 0, 1}, {GTK_EXPAND, GTK_EXPAND});
+ spin.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "fix_value", spin );
- g_signal_connect( G_OBJECT( spin ), "focus_out_event", G_CALLBACK( fix_value_entryfocusout ), NULL );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 60, -2 );
+ spin.connect( "focus_out_event", G_CALLBACK( fix_value_entryfocusout ), NULL );
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND, GTK_FILL});
+ entry.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "fix_range", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( fix_range_entryfocusout ), NULL );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 60, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( fix_range_entryfocusout ), NULL );
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 2, 3}, {GTK_EXPAND, GTK_FILL});
+ entry.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "fix_rate", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( fix_rate_entryfocusout ), NULL );
-
- button = gtk_button_new_with_label( "Free" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( fix_rate_entryfocusout ), NULL );
+
+ button = ui::Button( "Free" );
+ button.show();
+ table.attach(button, {2, 3, 0, 1}, {GTK_EXPAND, GTK_FILL});
+ button.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "fix_free", button );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( fix_free ), NULL );
-
- button = gtk_button_new_with_label( "Free All" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button.connect( "clicked", G_CALLBACK( fix_free ), NULL );
+
+ button = ui::Button( "Free All" );
+ button.show();
+ table.attach(button, {2, 3, 1, 2}, {GTK_EXPAND, GTK_FILL});
+ button.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "fix_freeall", button );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( fix_freeall ), NULL );
+ button.connect( "clicked", G_CALLBACK( fix_freeall ), NULL );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_widget_show( vbox );
+ vbox = ui::VBox( FALSE, 10 );
+ vbox.show();
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- label = gtk_label_new( "Texture" );
- gtk_widget_show( label );
+ label = ui::Label( "Texture" );
+ label.show();
gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), vbox, label );
// ^Fishman - Modified to add more labels and textboxes.
- table = gtk_table_new( 5, 2, FALSE );
- gtk_widget_show( table );
- gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- label = gtk_label_new( "Surface:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ table = ui::Table( 5, 2, FALSE );
+ table.show();
+ vbox.pack_start( table, FALSE, TRUE, 0 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ label = ui::Label( "Surface:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, GTK_FILL});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
- label = gtk_label_new( "Other:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ label = ui::Label( "Other:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, GTK_FILL});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
- label = gtk_label_new( "Steep:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ label = ui::Label( "Steep:" );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {GTK_FILL, GTK_FILL});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 60, -2 );
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
+ entry.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "texture1", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( texture_entryfocusout ), GINT_TO_POINTER( 0 ) );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 60, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( texture_entryfocusout ), GINT_TO_POINTER( 0 ) );
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
+ entry.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "texture2", entry );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( texture_entryfocusout ), GINT_TO_POINTER( 1 ) );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 60, -2 );
+ entry.connect( "focus_out_event", G_CALLBACK( texture_entryfocusout ), GINT_TO_POINTER( 1 ) );
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
+ entry.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "texture3", entry );
- hbox2 = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox2 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 );
+ hbox2 = ui::HBox( FALSE, 5 );
+ hbox2.show();
+ vbox.pack_start( hbox2, FALSE, TRUE, 0 );
- label = gtk_label_new( "\"Steep\" angle:" );
- gtk_widget_show( label );
- gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 );
+ label = ui::Label( "\"Steep\" angle:" );
+ label.show();
+ hbox2.pack_start( label, FALSE, TRUE, 0 );
- adj = gtk_adjustment_new( 60, 0, 90, 1, 10, 0 );
- spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 );
- gtk_widget_show( spin );
- gtk_box_pack_start( GTK_BOX( hbox2 ), spin, FALSE, TRUE, 0 );
+ adj = ui::Adjustment( 60, 0, 90, 1, 10, 0 );
+ spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ hbox2.pack_start( spin, FALSE, TRUE, 0 );
g_object_set_data( G_OBJECT( dlg ), "tex_slant", spin );
- table = gtk_table_new( 2, 4, TRUE );
- gtk_widget_show( table );
- gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- label = gtk_label_new( "Offset <h,v>" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
-
- label = gtk_label_new( "Scale <h,v>" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 4, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
-
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 60, -2 );
+ table = ui::Table( 2, 4, TRUE );
+ table.show();
+ vbox.pack_start( table, FALSE, TRUE, 0 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ label = ui::Label( "Offset <h,v>" );
+ label.show();
+ table.attach(label, {0, 2, 0, 1}, {GTK_FILL, GTK_FILL});
+
+ label = ui::Label( "Scale <h,v>" );
+ label.show();
+ table.attach(label, {2, 4, 0, 1}, {GTK_FILL, GTK_FILL});
+
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {0, 1, 1, 2}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
+ entry.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "texoffsetx", entry );
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 60, -2 );
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
+ entry.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "texoffsety", entry );
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 60, -2 );
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {2, 3, 1, 2}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
+ entry.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "texscalex", entry );
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
- gtk_widget_set_usize( entry, 60, -2 );
+ entry = ui::Entry();
+ entry.show();
+ table.attach(entry, {3, 4, 1, 2}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
+ entry.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "texscaley", entry );
- check = gtk_check_button_new_with_label( "Use detail brushes" );
- gtk_widget_show( check );
- gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 );
+ check = ui::CheckButton( "Use detail brushes" );
+ check.show();
+ vbox.pack_start( check, FALSE, TRUE, 0 );
g_object_set_data( G_OBJECT( dlg ), "detail", check );
- g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( texture_detail ), NULL );
+ check.connect( "toggled", G_CALLBACK( texture_detail ), NULL );
- check = gtk_check_button_new_with_label( "Detail hint brushes" );
- gtk_widget_show( check );
- gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 );
+ check = ui::CheckButton( "Detail hint brushes" );
+ check.show();
+ vbox.pack_start( check, FALSE, TRUE, 0 );
g_object_set_data( G_OBJECT( dlg ), "hint", check );
- g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( texture_hint ), NULL );
+ check.connect( "toggled", G_CALLBACK( texture_hint ), NULL );
// ^Fishman - Add terrain key to func_group.
- check = gtk_check_button_new_with_label( "Add terrain key" );
- gtk_widget_show( check );
- gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 );
+ check = ui::CheckButton( "Add terrain key" );
+ check.show();
+ vbox.pack_start( check, FALSE, TRUE, 0 );
g_object_set_data( G_OBJECT( dlg ), "terrain_ent", check );
- g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( texture_terrainent ), NULL );
+ check.connect( "toggled", G_CALLBACK( texture_terrainent ), NULL );
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, TRUE, 0 );
+ vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
+ hbox.pack_start( vbox, FALSE, TRUE, 0 );
- button = gtk_button_new_with_label( "OK" );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button = ui::Button( "OK" );
+ button.show();
+ vbox.pack_start( button, FALSE, TRUE, 0 );
+ button.dimensions( 60, -1 );
g_object_set_data( G_OBJECT( dlg ), "go", button );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_go ), NULL );
+ button.connect( "clicked", G_CALLBACK( main_go ), NULL );
- label = gtk_label_new( "Settings:" );
- gtk_widget_show( label );
- gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, TRUE, 0 );
+ label = ui::Label( "Settings:" );
+ label.show();
+ vbox.pack_start( label, FALSE, TRUE, 0 );
- button = gtk_button_new_with_label( "Open..." );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 );
+ button = ui::Button( "Open..." );
+ button.show();
+ vbox.pack_start( button, FALSE, TRUE, 0 );
g_object_set_data( G_OBJECT( dlg ), "open", button );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_open ), NULL );
+ button.connect( "clicked", G_CALLBACK( main_open ), NULL );
- button = gtk_button_new_with_label( "Save as..." );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 );
+ button = ui::Button( "Save as..." );
+ button.show();
+ vbox.pack_start( button, FALSE, TRUE, 0 );
g_object_set_data( G_OBJECT( dlg ), "save", button );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_save ), NULL );
+ button.connect( "clicked", G_CALLBACK( main_save ), NULL );
- button = gtk_button_new_with_label( "Defaults" );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 );
+ button = ui::Button( "Defaults" );
+ button.show();
+ vbox.pack_start( button, FALSE, TRUE, 0 );
g_object_set_data( G_OBJECT( dlg ), "defaults", button );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_defaults ), NULL );
+ button.connect( "clicked", G_CALLBACK( main_defaults ), NULL );
- button = gtk_button_new_with_label( "About..." );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, TRUE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( main_about ), NULL );
+ button = ui::Button( "About..." );
+ button.show();
+ vbox.pack_start( button, FALSE, TRUE, 0 );
+ button.connect( "clicked", G_CALLBACK( main_about ), NULL );
- check = gtk_check_button_new_with_label( "Preview" );
- gtk_widget_show( check );
- gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 );
- g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( main_preview ), NULL );
+ check = ui::CheckButton( "Preview" );
+ check.show();
+ vbox.pack_start( check, FALSE, TRUE, 0 );
+ check.connect( "toggled", G_CALLBACK( main_preview ), NULL );
g_object_set_data( G_OBJECT( dlg ), "main_preview", check );
// ^Fishman - Antializing for the preview window.
- check = gtk_check_button_new_with_label( "Antialised lines" );
- gtk_widget_show( check );
- gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, TRUE, 0 );
+ check = ui::CheckButton( "Antialised lines" );
+ check.show();
+ vbox.pack_start( check, FALSE, TRUE, 0 );
g_object_set_data( G_OBJECT( dlg ), "main_antialiasing", check );
- g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( main_antialiasing ), NULL );
+ check.connect( "toggled", G_CALLBACK( main_antialiasing ), NULL );
for ( i = 0; i < 5; i++ )
SetDlgValues( i );
int AddTerrainKey; // ^Fishman - Add terrain key to func_group.
int SP; // ^Fishman - Snap to grid.
-GtkWidget *g_pWnd; // ghwnd;
+ui::Window g_pWnd{ui::null}; // ghwnd;
GtkWidget *g_pRadiantWnd; // ghwnd_main;
/*HWND ghwndAngles;
*/GtkWidget *g_pWndPreview;
}
void UpdatePreview( bool DataChange ){
- if ( g_pWndPreview && GTK_WIDGET_VISIBLE( g_pWndPreview ) ) {
+ if ( g_pWndPreview && gtk_widget_get_visible( g_pWndPreview ) ) {
if ( DataChange ) {
GenerateXYZ();
}
#ifndef _GENSURF_H_
#define _GENSURF_H_
+#include "globaldefs.h"
#include <string.h>
#include "qertypes.h"
#include <stdio.h>
#include "igl.h"
#include "ientity.h"
-#include <gtk/gtk.h>
-
#include "iui_gtk.h"
#include "gendlgs.h"
#define PLUGIN
#define Q3RADIANT
-//#if defined(__linux__) || defined(__APPLE__)
+//#if GDEF_OS_LINUX || GDEF_OS_MACOS
#if 1
#include <algorithm>
#else
extern HCURSOR ghCursorDefault;
extern HCURSOR ghCursorVertex;
extern HINSTANCE ghInst;*/
-extern GtkWidget *g_pRadiantWnd;
-extern GtkWidget *g_pWnd;
+extern ui::Window g_pRadiantWnd;
+extern ui::Window g_pWnd;
/*extern HWND ghwndAngles;
extern HWND ghwndFix;
*/extern GtkWidget *g_pWndPreview;
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <uilib/uilib.h>
+
#include "gensurf.h"
// Global plugin FuncTable
#include "iplugin.h"
const char* QERPlug_Init( void* hApp, void* pMainWidget ){
- g_pRadiantWnd = (GtkWidget*)pMainWidget;
+ g_pRadiantWnd = ui::Window::from(pMainWidget);
return "GenSurf for Q3Radiant";
}
UseFaceBounds();
}
- gtk_widget_show( g_pWnd );
+ g_pWnd.show();
}
}
if ( g_pWndPreview == NULL ) {
CreateViewWindow();
}
- gtk_widget_show( g_pWndPreview );
+ g_pWndPreview.show();
UpdatePreview( true );
}
}
void CreateViewWindow(){
- GtkWidget *dlg, *vbox, *hbox, *label, *spin, *frame;
- GtkObject *adj;
+ GtkWidget *label, *spin;
#ifndef ISOMETRIC
elevation = PI / 6.;
azimuth = PI / 6.;
#endif
- g_pWndPreview = dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_window_set_title( GTK_WINDOW( dlg ), "GtkGenSurf Preview" );
- gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", GTK_SIGNAL_FUNC( preview_close ), NULL );
- gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pWnd ) );
- gtk_window_set_default_size( GTK_WINDOW( dlg ), 300, 400 );
+ auto dlg = g_pWndPreview = ui::Window( ui::window_type::TOP );
+ gtk_window_set_title( dlg, "GtkGenSurf Preview" );
+ dlg.connect( "delete_event", G_CALLBACK( preview_close ), NULL );
+ dlg.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
+ gtk_window_set_transient_for( dlg, g_pWnd );
+ gtk_window_set_default_size( dlg, 300, 400 );
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_container_add( GTK_CONTAINER( dlg ), vbox );
+ auto vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
+ dlg.add(vbox);
#ifndef ISOMETRIC
- hbox = gtk_hbox_new( TRUE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, TRUE, 0 );
+ auto hbox = ui::HBox( TRUE, 5 );
+ hbox.show();
+ vbox.pack_start( hbox, FALSE, TRUE, 0 );
gtk_container_set_border_width( GTK_CONTAINER( hbox ), 3 );
- label = gtk_label_new( "Elevation" );
- gtk_widget_show( label );
+ label = ui::Label( "Elevation" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
- gtk_box_pack_start( GTK_BOX( hbox ), label, FALSE, TRUE, 0 );
-
- adj = gtk_adjustment_new( 30, -90, 90, 1, 10, 0 );
- gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( preview_spin ), &elevation );
- spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 );
- gtk_widget_show( spin );
- gtk_box_pack_start( GTK_BOX( hbox ), spin, FALSE, TRUE, 0 );
- g_signal_connect( G_OBJECT( spin ), "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &elevation );
-
- adj = gtk_adjustment_new( 30, 0, 359, 1, 10, 0 );
- gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( preview_spin ), &azimuth );
- spin = gtk_spin_button_new( GTK_ADJUSTMENT( adj ), 1, 0 );
- gtk_widget_show( spin );
+ hbox.pack_start( label, FALSE, TRUE, 0 );
+
+ auto adj = ui::Adjustment( 30, -90, 90, 1, 10, 0 );
+ adj.connect( "value_changed", G_CALLBACK( preview_spin ), &elevation );
+ spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ hbox.pack_start( spin, FALSE, TRUE, 0 );
+ spin.connect( "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &elevation );
+
+ adj = ui::Adjustment( 30, 0, 359, 1, 10, 0 );
+ adj.connect( "value_changed", G_CALLBACK( preview_spin ), &azimuth );
+ spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( spin ), TRUE );
- gtk_box_pack_end( GTK_BOX( hbox ), spin, FALSE, TRUE, 0 );
+ hbox.pack_end(spin, FALSE, TRUE, 0);
- label = gtk_label_new( "Azimuth" );
- gtk_widget_show( label );
+ label = ui::Label( "Azimuth" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
- gtk_box_pack_end( GTK_BOX( hbox ), label, FALSE, TRUE, 0 );
- g_signal_connect( G_OBJECT( spin ), "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &azimuth );
+ hbox.pack_end(label, FALSE, TRUE, 0);
+ spin.connect( "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &azimuth );
#endif
- frame = gtk_frame_new( NULL );
- gtk_widget_show( frame );
+ auto frame = ui::Frame(ui::null);
+ frame.show();
gtk_frame_set_shadow_type( GTK_FRAME( frame ), GTK_SHADOW_IN );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 );
+ vbox.pack_start( frame, TRUE, TRUE, 0 );
g_pPreviewWidget = g_UIGtkTable.m_pfn_glwidget_new( FALSE, NULL );
gtk_widget_set_events( g_pPreviewWidget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK );
- gtk_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "expose_event", GTK_SIGNAL_FUNC( expose ), NULL );
- gtk_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "motion_notify_event", GTK_SIGNAL_FUNC( motion ), NULL );
- gtk_signal_connect( GTK_OBJECT( g_pPreviewWidget ), "button_press_event",
- GTK_SIGNAL_FUNC( button_press ), NULL );
+ g_pPreviewWidget.connect( "expose_event", G_CALLBACK( expose ), NULL );
+ g_pPreviewWidget.connect( "motion_notify_event", G_CALLBACK( motion ), NULL );
+ g_pPreviewWidget.connect( "button_press_event",
+ G_CALLBACK( button_press ), NULL );
- gtk_widget_show( g_pPreviewWidget );
- gtk_container_add( GTK_CONTAINER( frame ), g_pPreviewWidget );
+ g_pPreviewWidget.show();
+ frame.add(ui::Widget(g_pPreviewWidget));
if ( Preview ) {
- gtk_widget_show( g_pWndPreview );
+ g_pWndPreview.show();
}
UpdatePreview( true );
// =============================================================================
// Ripped from TexTool.cpp
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)gtk_object_get_data( GTK_OBJECT( parent ), "loop" );
ret = (int*)gtk_object_get_data( GTK_OBJECT( parent ), "ret" );
}
int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){
- GtkWidget *window, *w, *vbox, *hbox;
+ GtkWidget *w, *hbox;
int mode = ( uType & MB_TYPEMASK ), ret, loop = 1;
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event",
- GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy",
- GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), lpCaption );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ auto window = ui::Window( ui::window_type::TOP );
+ window.connect( "delete_event",
+ G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy",
+ G_CALLBACK( gtk_widget_destroy ), NULL );
+ gtk_window_set_title( window, lpCaption );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
gtk_object_set_data( GTK_OBJECT( window ), "loop", &loop );
gtk_object_set_data( GTK_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
- w = gtk_label_new( lpText );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
+ w = ui::Label( lpText );
+ vbox.pack_start( w, FALSE, FALSE, 2 );
gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
- gtk_widget_show( w );
+ w.show();
w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 2 );
+ w.show();
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
if ( mode == MB_OK ) {
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
ret = IDOK;
}
else if ( mode == MB_OKCANCEL ) {
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
+ w.show();
ret = IDCANCEL;
}
else if ( mode == MB_YESNOCANCEL ) {
- w = gtk_button_new_with_label( "Yes" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Yes" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
-
- w = gtk_button_new_with_label( "No" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
- gtk_widget_show( w );
-
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
- gtk_widget_show( w );
+ w.show();
+
+ w = ui::Button( "No" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
+ w.show();
+
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
+ w.show();
ret = IDCANCEL;
}
else /* if (mode == MB_YESNO) */
{
- w = gtk_button_new_with_label( "Yes" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Yes" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "No" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
- gtk_widget_show( w );
+ w = ui::Button( "No" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
+ w.show();
ret = IDNO;
}
- gtk_widget_show( window );
+ window.show();
gtk_grab_add( window );
while ( loop )
gtk_main_iteration();
gtk_grab_remove( window );
- gtk_widget_destroy( window );
+ window.destroy();
return ret;
}
#define USE_ENTITYTABLE_DEFINE
#include "ientity.h"
-#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
#include "iplugin.h"
-#include <glib.h>
#include "synapse.h"
class CSynapseClientHydraToolz : public CSynapseClient
#include "AboutDialog.h"
#include <gtk/gtk.h>
#include <gtkutil/pointer.h>
+#include <uilib/uilib.h>
#include "version.h"
#include "gtkutil/pointer.h"
#include "prtview.h"
#include "ConfigDialog.h"
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
*ret = gpointer_to_int( data );
}
-static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
- int *loop;
-
- gtk_widget_hide( widget );
- loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" );
+static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
+ widget.hide();
+ int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
*loop = 0;
-
return TRUE;
}
void DoAboutDlg(){
- GtkWidget *dlg, *hbox, *vbox, *button, *label;
int loop = 1, ret = IDCANCEL;
- dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto dlg = ui::Window(ui::window_type::TOP);
gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) );
gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT );
gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE );
- gtk_window_set_title( GTK_WINDOW( dlg ), "About Portal Viewer" );
- gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
- GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( dlg ), "destroy",
- GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- g_object_set_data( G_OBJECT( dlg ), "loop", &loop );
- g_object_set_data( G_OBJECT( dlg ), "ret", &ret );
-
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_widget_show( hbox );
- gtk_container_add( GTK_CONTAINER( dlg ), hbox );
- gtk_container_set_border_width( GTK_CONTAINER( hbox ), 10 );
-
- label = gtk_label_new( "Version 1.000\n\n"
- "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"
- "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"
- "Built against NetRadiant " RADIANT_VERSION "\n"
- __DATE__
- );
- gtk_widget_show( label );
- gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 0 );
- gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
-
- vbox = gtk_vbox_new( FALSE, 0 );
- gtk_widget_show( vbox );
- gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, FALSE, 0 );
-
- button = gtk_button_new_with_label( "OK" );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( button ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
- gtk_widget_set_usize( button, 60, -2 );
-
- gtk_grab_add( dlg );
- gtk_widget_show( dlg );
-
- while ( loop )
+ gtk_window_set_title(dlg, "About Portal Viewer");
+ dlg.connect("delete_event", G_CALLBACK(dialog_delete_callback), NULL);
+ dlg.connect("destroy", G_CALLBACK(gtk_widget_destroy), NULL);
+ g_object_set_data(G_OBJECT(dlg), "loop", &loop);
+ g_object_set_data(G_OBJECT(dlg), "ret", &ret);
+
+ auto hbox = ui::HBox(FALSE, 10);
+ hbox.show();
+ dlg.add(hbox);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
+
+ char const *label_text = "Version 1.000\n\n"
+ "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"
+ "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"
+ "Built against NetRadiant " RADIANT_VERSION "\n"
+ __DATE__;
+ auto label = ui::Label(label_text);
+ label.show();
+ hbox.pack_start( label, TRUE, TRUE, 0);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+
+ auto vbox = ui::VBox(FALSE, 0);
+ vbox.show();
+ hbox.pack_start( vbox, FALSE, FALSE, 0);
+
+ auto button = ui::Button("OK");
+ button.show();
+ vbox.pack_start( button, FALSE, FALSE, 0);
+ button.connect("clicked", G_CALLBACK(dialog_button_callback), GINT_TO_POINTER(IDOK));
+ button.dimensions(60, -1);
+
+ gtk_grab_add(dlg);
+ dlg.show();
+
+ while (loop)
gtk_main_iteration();
- gtk_grab_remove( dlg );
- gtk_widget_destroy( dlg );
+ gtk_grab_remove(dlg);
+ dlg.destroy();
}
--- /dev/null
+radiant_plugin(prtview
+ AboutDialog.cpp AboutDialog.h
+ ConfigDialog.cpp ConfigDialog.h
+ LoadPortalFileDialog.cpp LoadPortalFileDialog.h
+ portals.cpp portals.h
+ prtview.cpp prtview.h
+ )
+
+target_include_directories(prtview PRIVATE uilib)
+target_link_libraries(prtview PRIVATE uilib)
+
+target_include_directories(prtview PRIVATE profile)
+target_link_libraries(prtview PRIVATE profile)
#include "ConfigDialog.h"
#include <stdio.h>
#include <gtk/gtk.h>
+#include <uilib/uilib.h>
#include "gtkutil/pointer.h"
#include "iscenegraph.h"
#include "prtview.h"
#include "portals.h"
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
*ret = gpointer_to_int( data );
}
-static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
- int *loop;
-
- gtk_widget_hide( widget );
- loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" );
+static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
+ widget.hide();
+ int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
*loop = 0;
-
return TRUE;
}
// Color selection dialog
static int DoColor( PackedColour *c ){
- GtkWidget* dlg;
- double clr[4];
+ GdkColor clr;
int loop = 1, ret = IDCANCEL;
- clr[0] = ( (double)GetRValue( *c ) ) / 255.0;
- clr[1] = ( (double)GetGValue( *c ) ) / 255.0;
- clr[2] = ( (double)GetBValue( *c ) ) / 255.0;
+ clr.red = (guint16) (GetRValue(*c) * (65535 / 255));
+ clr.blue = (guint16) (GetGValue(*c) * (65535 / 255));
+ clr.green = (guint16) (GetBValue(*c) * (65535 / 255));
+
+ auto dlg = ui::Widget::from(gtk_color_selection_dialog_new( "Choose Color" ));
- dlg = gtk_color_selection_dialog_new( "Choose Color" );
gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) );
gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT );
gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE );
- gtk_color_selection_set_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr );
- gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
- GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( dlg ), "destroy",
- GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- gtk_signal_connect( GTK_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->ok_button ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
- gtk_signal_connect( GTK_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->cancel_button ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
+ gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dlg)) ), &clr );
+ dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
+ dlg.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
+
+ GtkWidget *ok_button, *cancel_button;
+ g_object_get(dlg, "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr);
+
+ ui::Widget::from(ok_button).connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
+ ui::Widget::from(cancel_button).connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
g_object_set_data( G_OBJECT( dlg ), "loop", &loop );
g_object_set_data( G_OBJECT( dlg ), "ret", &ret );
- gtk_widget_show( dlg );
+ dlg.show();
gtk_grab_add( dlg );
while ( loop )
gtk_main_iteration();
- gtk_color_selection_get_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr );
+ gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(dlg)) ), &clr );
gtk_grab_remove( dlg );
- gtk_widget_destroy( dlg );
+ dlg.destroy();
if ( ret == IDOK ) {
- *c = RGB( clr[0] * 255, clr[1] * 255, clr[2] * 255 );
+ *c = RGB( clr.red / (65535 / 255), clr.green / (65535 / 255), clr.blue / (65535 / 255));
}
return ret;
}
-static void Set2DText( GtkWidget* label ){
+static void Set2DText(ui::Widget label ){
char s[40];
sprintf( s, "Line Width = %6.3f", portals.width_2d * 0.5f );
gtk_label_set_text( GTK_LABEL( label ), s );
}
-static void Set3DText( GtkWidget* label ){
+static void Set3DText(ui::Widget label ){
char s[40];
sprintf( s, "Line Width = %6.3f", portals.width_3d * 0.5f );
gtk_label_set_text( GTK_LABEL( label ), s );
}
-static void Set3DTransText( GtkWidget* label ){
+static void Set3DTransText(ui::Widget label ){
char s[40];
sprintf( s, "Polygon transparency = %d%%", (int)portals.trans_3d );
gtk_label_set_text( GTK_LABEL( label ), s );
}
-static void SetClipText( GtkWidget* label ){
+static void SetClipText(ui::Widget label ){
char s[40];
sprintf( s, "Cubic clip range = %d", (int)portals.clip_range * 64 );
gtk_label_set_text( GTK_LABEL( label ), s );
}
-static void OnScroll2d( GtkAdjustment *adj, gpointer data ){
- portals.width_2d = static_cast<float>( adj->value );
- Set2DText( GTK_WIDGET( data ) );
+static void OnScroll2d(ui::Adjustment adj, gpointer data ){
+ portals.width_2d = static_cast<float>( gtk_adjustment_get_value(adj) );
+ Set2DText( ui::Widget::from(data) );
Portals_shadersChanged();
SceneChangeNotify();
}
-static void OnScroll3d( GtkAdjustment *adj, gpointer data ){
- portals.width_3d = static_cast<float>( adj->value );
- Set3DText( GTK_WIDGET( data ) );
+static void OnScroll3d(ui::Adjustment adj, gpointer data ){
+ portals.width_3d = static_cast<float>( gtk_adjustment_get_value(adj) );
+ Set3DText( ui::Widget::from( data ) );
SceneChangeNotify();
}
-static void OnScrollTrans( GtkAdjustment *adj, gpointer data ){
- portals.trans_3d = static_cast<float>( adj->value );
- Set3DTransText( GTK_WIDGET( data ) );
+static void OnScrollTrans(ui::Adjustment adj, gpointer data ){
+ portals.trans_3d = static_cast<float>( gtk_adjustment_get_value(adj) );
+ Set3DTransText( ui::Widget::from( data ) );
SceneChangeNotify();
}
-static void OnScrollClip( GtkAdjustment *adj, gpointer data ){
- portals.clip_range = static_cast<float>( adj->value );
- SetClipText( GTK_WIDGET( data ) );
+static void OnScrollClip(ui::Adjustment adj, gpointer data ){
+ portals.clip_range = static_cast<float>( gtk_adjustment_get_value(adj) );
+ SetClipText( ui::Widget::from( data ) );
SceneChangeNotify();
}
-static void OnAntiAlias2d( GtkWidget *widget, gpointer data ){
+static void OnAntiAlias2d(ui::Widget widget, gpointer data ){
portals.aa_2d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
Portals_shadersChanged();
SceneChangeNotify();
}
-static void OnConfig2d( GtkWidget *widget, gpointer data ){
+static void OnConfig2d(ui::Widget widget, gpointer data ){
portals.show_2d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
SceneChangeNotify();
}
-static void OnColor2d( GtkWidget *widget, gpointer data ){
+static void OnColor2d(ui::Widget widget, gpointer data ){
if ( DoColor( &portals.color_2d ) == IDOK ) {
Portals_shadersChanged();
}
}
-static void OnConfig3d( GtkWidget *widget, gpointer data ){
+static void OnConfig3d(ui::Widget widget, gpointer data ){
portals.show_3d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
SceneChangeNotify();
}
-static void OnAntiAlias3d( GtkWidget *widget, gpointer data ){
+static void OnAntiAlias3d(ui::Widget widget, gpointer data ){
portals.aa_3d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
Portals_shadersChanged();
SceneChangeNotify();
}
-static void OnColor3d( GtkWidget *widget, gpointer data ){
+static void OnColor3d(ui::Widget widget, gpointer data ){
if ( DoColor( &portals.color_3d ) == IDOK ) {
Portals_shadersChanged();
}
}
-static void OnColorFog( GtkWidget *widget, gpointer data ){
+static void OnColorFog(ui::Widget widget, gpointer data ){
if ( DoColor( &portals.color_fog ) == IDOK ) {
Portals_shadersChanged();
}
}
-static void OnFog( GtkWidget *widget, gpointer data ){
+static void OnFog(ui::Widget widget, gpointer data ){
portals.fog = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
Portals_shadersChanged();
SceneChangeNotify();
}
-static void OnSelchangeZbuffer( GtkWidget *widget, gpointer data ){
+static void OnSelchangeZbuffer(ui::Widget widget, gpointer data ){
portals.zbuffer = gpointer_to_int( data );
Portals_shadersChanged();
SceneChangeNotify();
}
-static void OnPoly( GtkWidget *widget, gpointer data ){
+static void OnPoly(ui::Widget widget, gpointer data ){
portals.polygons = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) );
SceneChangeNotify();
}
-static void OnLines( GtkWidget *widget, gpointer data ){
+static void OnLines(ui::Widget widget, gpointer data ){
portals.lines = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) );
SceneChangeNotify();
}
-static void OnClip( GtkWidget *widget, gpointer data ){
+static void OnClip(ui::Widget widget, gpointer data ){
portals.clip = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( widget ) ) ? true : false;
SceneChangeNotify();
}
void DoConfigDialog(){
- GtkWidget *dlg, *hbox, *vbox, *vbox2, *button, *table, *frame;
- GtkWidget *lw3slider, *lw3label, *lw2slider, *lw2label, *zlist, *menu, *item;
- GtkWidget *aa2check, *aa3check, *depthcheck, *linescheck, *polyscheck;
- GtkWidget *transslider, *translabel, *clipslider, *cliplabel;
- GtkWidget *show2check, *show3check, *portalcheck;
int loop = 1, ret = IDCANCEL;
- GtkObject *adj;
- dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto dlg = ui::Window( ui::window_type::TOP );
+
gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) );
gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT );
gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE );
- gtk_window_set_title( GTK_WINDOW( dlg ), "Portal Viewer Configuration" );
- gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
- GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( dlg ), "destroy",
- GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+
+ gtk_window_set_title( dlg, "Portal Viewer Configuration" );
+ dlg.connect( "delete_event",
+ G_CALLBACK( dialog_delete_callback ), NULL );
+ dlg.connect( "destroy",
+ G_CALLBACK( gtk_widget_destroy ), NULL );
g_object_set_data( G_OBJECT( dlg ), "loop", &loop );
g_object_set_data( G_OBJECT( dlg ), "ret", &ret );
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_container_add( GTK_CONTAINER( dlg ), vbox );
+ auto vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
+ dlg.add(vbox);
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- frame = gtk_frame_new( "3D View" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 );
+ auto frame = ui::Frame( "3D View" );
+ frame.show();
+ vbox.pack_start( frame, TRUE, TRUE, 0 );
- vbox2 = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox2 );
- gtk_container_add( GTK_CONTAINER( frame ), vbox2 );
+ auto vbox2 = ui::VBox( FALSE, 5 );
+ vbox2.show();
+ frame.add(vbox2);
gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 );
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, TRUE, 0 );
+ auto hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox2.pack_start( hbox, TRUE, TRUE, 0 );
- adj = gtk_adjustment_new( portals.width_3d, 2, 40, 1, 1, 0 );
- lw3slider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) );
- gtk_widget_show( lw3slider );
- gtk_box_pack_start( GTK_BOX( hbox ), lw3slider, TRUE, TRUE, 0 );
+ auto adj = ui::Adjustment( portals.width_3d, 2, 40, 1, 1, 0 );
+ auto lw3slider = ui::HScale( adj );
+ lw3slider.show();
+ hbox.pack_start( lw3slider, TRUE, TRUE, 0 );
gtk_scale_set_draw_value( GTK_SCALE( lw3slider ), FALSE );
- lw3label = gtk_label_new( "" );
- gtk_widget_show( lw3label );
- gtk_box_pack_start( GTK_BOX( hbox ), lw3label, FALSE, TRUE, 0 );
- gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScroll3d ), lw3label );
-
- table = gtk_table_new( 2, 4, FALSE );
- gtk_widget_show( table );
- gtk_box_pack_start( GTK_BOX( vbox2 ), table, TRUE, TRUE, 0 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- button = gtk_button_new_with_label( "Color" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnColor3d ), NULL );
-
- button = gtk_button_new_with_label( "Depth Color" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnColorFog ), NULL );
-
- aa3check = gtk_check_button_new_with_label( "Anti-Alias (May not work on some video cards)" );
- gtk_widget_show( aa3check );
- gtk_table_attach( GTK_TABLE( table ), aa3check, 1, 4, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_signal_connect( GTK_OBJECT( aa3check ), "toggled", GTK_SIGNAL_FUNC( OnAntiAlias3d ), NULL );
-
- depthcheck = gtk_check_button_new_with_label( "Depth Cue" );
- gtk_widget_show( depthcheck );
- gtk_table_attach( GTK_TABLE( table ), depthcheck, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_signal_connect( GTK_OBJECT( depthcheck ), "toggled", GTK_SIGNAL_FUNC( OnFog ), NULL );
-
- linescheck = gtk_check_button_new_with_label( "Lines" );
- gtk_widget_show( linescheck );
- gtk_table_attach( GTK_TABLE( table ), linescheck, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_signal_connect( GTK_OBJECT( linescheck ), "toggled", GTK_SIGNAL_FUNC( OnLines ), NULL );
-
- polyscheck = gtk_check_button_new_with_label( "Polygons" );
- gtk_widget_show( polyscheck );
- gtk_table_attach( GTK_TABLE( table ), polyscheck, 3, 4, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_signal_connect( GTK_OBJECT( polyscheck ), "toggled", GTK_SIGNAL_FUNC( OnPoly ), NULL );
-
- zlist = gtk_option_menu_new();
- gtk_widget_show( zlist );
- gtk_box_pack_start( GTK_BOX( vbox2 ), zlist, TRUE, FALSE, 0 );
-
- menu = gtk_menu_new();
- gtk_widget_show( menu );
- gtk_option_menu_set_menu( GTK_OPTION_MENU( zlist ), menu );
-
- item = gtk_menu_item_new_with_label( "Z-Buffer Test and Write (recommended for solid or no polygons)" );
- gtk_widget_show( item );
- gtk_signal_connect( GTK_OBJECT( item ), "activate",
- GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 0 ) );
- gtk_menu_append( GTK_MENU( menu ), item );
-
- item = gtk_menu_item_new_with_label( "Z-Buffer Test Only (recommended for transparent polygons)" );
- gtk_widget_show( item );
- gtk_signal_connect( GTK_OBJECT( item ), "activate",
- GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 1 ) );
- gtk_menu_append( GTK_MENU( menu ), item );
-
- item = gtk_menu_item_new_with_label( "Z-Buffer Off" );
- gtk_widget_show( item );
- gtk_signal_connect( GTK_OBJECT( item ), "activate",
- GTK_SIGNAL_FUNC( OnSelchangeZbuffer ), GINT_TO_POINTER( 2 ) );
- gtk_menu_append( GTK_MENU( menu ), item );
-
- table = gtk_table_new( 2, 2, FALSE );
- gtk_widget_show( table );
- gtk_box_pack_start( GTK_BOX( vbox2 ), table, TRUE, TRUE, 0 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- adj = gtk_adjustment_new( portals.trans_3d, 0, 100, 1, 1, 0 );
- transslider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) );
- gtk_widget_show( transslider );
- gtk_table_attach( GTK_TABLE( table ), transslider, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto lw3label = ui::Label( "" );
+ lw3label.show();
+ hbox.pack_start( lw3label, FALSE, TRUE, 0 );
+ adj.connect( "value_changed", G_CALLBACK( OnScroll3d ), lw3label );
+
+ auto table = ui::Table( 2, 4, FALSE );
+ table.show();
+ vbox2.pack_start( table, TRUE, TRUE, 0 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ auto button = ui::Button( "Color" );
+ button.show();
+ table.attach(button, {0, 1, 0, 1}, {GTK_FILL, 0});
+ button.connect( "clicked", G_CALLBACK( OnColor3d ), NULL );
+
+ button = ui::Button( "Depth Color" );
+ button.show();
+ table.attach(button, {0, 1, 1, 2}, {GTK_FILL, 0});
+ button.connect( "clicked", G_CALLBACK( OnColorFog ), NULL );
+
+ auto aa3check = ui::CheckButton( "Anti-Alias (May not work on some video cards)" );
+ aa3check.show();
+ table.attach(aa3check, {1, 4, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ aa3check.connect( "toggled", G_CALLBACK( OnAntiAlias3d ), NULL );
+
+ auto depthcheck = ui::CheckButton( "Depth Cue" );
+ depthcheck.show();
+ table.attach(depthcheck, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ depthcheck.connect( "toggled", G_CALLBACK( OnFog ), NULL );
+
+ auto linescheck = ui::CheckButton( "Lines" );
+ linescheck.show();
+ table.attach(linescheck, {2, 3, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ linescheck.connect( "toggled", G_CALLBACK( OnLines ), NULL );
+
+ auto polyscheck = ui::CheckButton( "Polygons" );
+ polyscheck.show();
+ table.attach(polyscheck, {3, 4, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ polyscheck.connect( "toggled", G_CALLBACK( OnPoly ), NULL );
+
+ auto zlist = ui::ComboBoxText(ui::New);
+ zlist.show();
+ vbox2.pack_start( zlist, TRUE, FALSE, 0 );
+
+ gtk_combo_box_text_append_text(zlist, "Z-Buffer Test and Write (recommended for solid or no polygons)");
+ gtk_combo_box_text_append_text(zlist, "Z-Buffer Test Only (recommended for transparent polygons)");
+ gtk_combo_box_text_append_text(zlist, "Z-Buffer Off");
+
+ zlist.connect("changed", G_CALLBACK(+[](ui::ComboBox self, void *) {
+ OnSelchangeZbuffer(self, GINT_TO_POINTER(gtk_combo_box_get_active(self)));
+ }), nullptr);
+
+ table = ui::Table( 2, 2, FALSE );
+ table.show();
+ vbox2.pack_start( table, TRUE, TRUE, 0 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ adj = ui::Adjustment( portals.trans_3d, 0, 100, 1, 1, 0 );
+ auto transslider = ui::HScale( adj );
+ transslider.show();
+ table.attach(transslider, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
gtk_scale_set_draw_value( GTK_SCALE( transslider ), FALSE );
- translabel = gtk_label_new( "" );
- gtk_widget_show( translabel );
- gtk_table_attach( GTK_TABLE( table ), translabel, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto translabel = ui::Label( "" );
+ translabel.show();
+ table.attach(translabel, {1, 2, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( translabel ), 0.0, 0.0 );
- gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScrollTrans ), translabel );
-
- adj = gtk_adjustment_new( portals.clip_range, 1, 128, 1, 1, 0 );
- clipslider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) );
- gtk_widget_show( clipslider );
- gtk_table_attach( GTK_TABLE( table ), clipslider, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ adj.connect( "value_changed", G_CALLBACK( OnScrollTrans ), translabel );
+
+ adj = ui::Adjustment( portals.clip_range, 1, 128, 1, 1, 0 );
+ auto clipslider = ui::HScale( adj );
+ clipslider.show();
+ table.attach(clipslider, {0, 1, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
gtk_scale_set_draw_value( GTK_SCALE( clipslider ), FALSE );
- cliplabel = gtk_label_new( "" );
- gtk_widget_show( cliplabel );
- gtk_table_attach( GTK_TABLE( table ), cliplabel, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto cliplabel = ui::Label( "" );
+ cliplabel.show();
+ table.attach(cliplabel, {1, 2, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( cliplabel ), 0.0, 0.0 );
- gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScrollClip ), cliplabel );
+ adj.connect( "value_changed", G_CALLBACK( OnScrollClip ), cliplabel );
- hbox = gtk_hbox_new( TRUE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 );
+ hbox = ui::HBox( TRUE, 5 );
+ hbox.show();
+ vbox2.pack_start( hbox, TRUE, FALSE, 0 );
- show3check = gtk_check_button_new_with_label( "Show" );
- gtk_widget_show( show3check );
- gtk_box_pack_start( GTK_BOX( hbox ), show3check, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( show3check ), "toggled", GTK_SIGNAL_FUNC( OnConfig3d ), NULL );
+ auto show3check = ui::CheckButton( "Show" );
+ show3check.show();
+ hbox.pack_start( show3check, TRUE, TRUE, 0 );
+ show3check.connect( "toggled", G_CALLBACK( OnConfig3d ), NULL );
- portalcheck = gtk_check_button_new_with_label( "Portal cubic clipper" );
- gtk_widget_show( portalcheck );
- gtk_box_pack_start( GTK_BOX( hbox ), portalcheck, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( portalcheck ), "toggled", GTK_SIGNAL_FUNC( OnClip ), NULL );
+ auto portalcheck = ui::CheckButton( "Portal cubic clipper" );
+ portalcheck.show();
+ hbox.pack_start( portalcheck, TRUE, TRUE, 0 );
+ portalcheck.connect( "toggled", G_CALLBACK( OnClip ), NULL );
- frame = gtk_frame_new( "2D View" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 );
+ frame = ui::Frame( "2D View" );
+ frame.show();
+ vbox.pack_start( frame, TRUE, TRUE, 0 );
- vbox2 = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox2 );
- gtk_container_add( GTK_CONTAINER( frame ), vbox2 );
+ vbox2 = ui::VBox( FALSE, 5 );
+ vbox2.show();
+ frame.add(vbox2);
gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 );
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 );
+ hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox2.pack_start( hbox, TRUE, FALSE, 0 );
- adj = gtk_adjustment_new( portals.width_2d, 2, 40, 1, 1, 0 );
- lw2slider = gtk_hscale_new( GTK_ADJUSTMENT( adj ) );
- gtk_widget_show( lw2slider );
- gtk_box_pack_start( GTK_BOX( hbox ), lw2slider, TRUE, TRUE, 0 );
+ adj = ui::Adjustment( portals.width_2d, 2, 40, 1, 1, 0 );
+ auto lw2slider = ui::HScale( adj );
+ lw2slider.show();
+ hbox.pack_start( lw2slider, TRUE, TRUE, 0 );
gtk_scale_set_draw_value( GTK_SCALE( lw2slider ), FALSE );
- lw2label = gtk_label_new( "" );
- gtk_widget_show( lw2label );
- gtk_box_pack_start( GTK_BOX( hbox ), lw2label, FALSE, TRUE, 0 );
- gtk_signal_connect( adj, "value_changed", GTK_SIGNAL_FUNC( OnScroll2d ), lw2label );
-
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 );
-
- button = gtk_button_new_with_label( "Color" );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( hbox ), button, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnColor2d ), NULL );
- gtk_widget_set_usize( button, 60, -2 );
-
- aa2check = gtk_check_button_new_with_label( "Anti-Alias (May not work on some video cards)" );
- gtk_widget_show( aa2check );
- gtk_box_pack_start( GTK_BOX( hbox ), aa2check, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( aa2check ), "toggled", GTK_SIGNAL_FUNC( OnAntiAlias2d ), NULL );
-
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox2 ), hbox, TRUE, FALSE, 0 );
-
- show2check = gtk_check_button_new_with_label( "Show" );
- gtk_widget_show( show2check );
- gtk_box_pack_start( GTK_BOX( hbox ), show2check, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( show2check ), "toggled", GTK_SIGNAL_FUNC( OnConfig2d ), NULL );
-
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
-
- button = gtk_button_new_with_label( "OK" );
- gtk_widget_show( button );
- gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( button ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
- gtk_widget_set_usize( button, 60, -2 );
+ auto lw2label = ui::Label( "" );
+ lw2label.show();
+ hbox.pack_start( lw2label, FALSE, TRUE, 0 );
+ adj.connect( "value_changed", G_CALLBACK( OnScroll2d ), lw2label );
+
+ hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox2.pack_start( hbox, TRUE, FALSE, 0 );
+
+ button = ui::Button( "Color" );
+ button.show();
+ hbox.pack_start( button, FALSE, FALSE, 0 );
+ button.connect( "clicked", G_CALLBACK( OnColor2d ), NULL );
+ button.dimensions(60, -1);
+
+ auto aa2check = ui::CheckButton( "Anti-Alias (May not work on some video cards)" );
+ aa2check.show();
+ hbox.pack_start( aa2check, TRUE, TRUE, 0 );
+ aa2check.connect( "toggled", G_CALLBACK( OnAntiAlias2d ), NULL );
+
+ hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox2.pack_start( hbox, TRUE, FALSE, 0 );
+
+ auto show2check = ui::CheckButton( "Show" );
+ show2check.show();
+ hbox.pack_start( show2check, FALSE, FALSE, 0 );
+ show2check.connect( "toggled", G_CALLBACK( OnConfig2d ), NULL );
+
+ hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+
+ button = ui::Button( "OK" );
+ button.show();
+ hbox.pack_end(button, FALSE, FALSE, 0);
+ button.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
+ button.dimensions(60, -1);
// initialize dialog
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( show2check ), portals.show_2d );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( polyscheck ), portals.polygons );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( linescheck ), portals.lines );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( aa3check ), portals.aa_3d );
- gtk_option_menu_set_history( GTK_OPTION_MENU( zlist ), portals.zbuffer );
+ gtk_combo_box_set_active(zlist, portals.zbuffer);
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( portalcheck ), portals.clip );
Set3DText( lw3label );
SetClipText( cliplabel );
gtk_grab_add( dlg );
- gtk_widget_show( dlg );
+ dlg.show();
while ( loop )
gtk_main_iteration();
gtk_grab_remove( dlg );
- gtk_widget_destroy( dlg );
+ dlg.destroy();
}
#include "prtview.h"
#include "portals.h"
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
*ret = gpointer_to_int( data );
}
-static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
- int *loop;
-
- gtk_widget_hide( widget );
- loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" );
+static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
+ widget.hide();
+ int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
*loop = 0;
-
return TRUE;
}
-static void file_sel_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
- int *loop;
- char **filename;
-
- parent = gtk_widget_get_toplevel( widget );
- loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
- filename = (char**)g_object_get_data( G_OBJECT( parent ), "filename" );
-
- *loop = 0;
- if ( gpointer_to_int( data ) == IDOK ) {
- *filename = g_strdup( gtk_file_selection_get_filename( GTK_FILE_SELECTION( parent ) ) );
- }
-}
-
-static void change_clicked( GtkWidget *widget, gpointer data ){
- GtkWidget* file_sel;
+static void change_clicked(ui::Widget widget, gpointer data ){
char* filename = NULL;
- int loop = 1;
- file_sel = gtk_file_selection_new( "Locate portal (.prt) file" );
+ auto file_sel = ui::Widget::from(gtk_file_chooser_dialog_new ( "Locate portal (.prt) file", nullptr, GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ nullptr));
+
gtk_window_set_transient_for( GTK_WINDOW( file_sel ), GTK_WINDOW( g_pRadiantWnd ) );
gtk_window_set_position( GTK_WINDOW( file_sel ),GTK_WIN_POS_CENTER_ON_PARENT );
gtk_window_set_modal( GTK_WINDOW( file_sel ), TRUE );
- gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->ok_button ), "clicked",
- GTK_SIGNAL_FUNC( file_sel_callback ), GINT_TO_POINTER( IDOK ) );
- gtk_signal_connect( GTK_OBJECT( GTK_FILE_SELECTION( file_sel )->cancel_button ), "clicked",
- GTK_SIGNAL_FUNC( file_sel_callback ), GINT_TO_POINTER( IDCANCEL ) );
- gtk_signal_connect( GTK_OBJECT( file_sel ), "delete_event",
- GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_file_selection_hide_fileop_buttons( GTK_FILE_SELECTION( file_sel ) );
-
- g_object_set_data( G_OBJECT( file_sel ), "loop", &loop );
- g_object_set_data( G_OBJECT( file_sel ), "filename", &filename );
- gtk_file_selection_set_filename( GTK_FILE_SELECTION( file_sel ), portals.fn );
- gtk_grab_add( file_sel );
- gtk_widget_show( file_sel );
-
- while ( loop )
- gtk_main_iteration();
+ gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(file_sel), portals.fn );
- gtk_grab_remove( file_sel );
- gtk_widget_destroy( file_sel );
+ if (gtk_dialog_run (GTK_DIALOG (file_sel)) == GTK_RESPONSE_ACCEPT)
+ {
+ filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_sel));
+ }
+ ui::Widget(file_sel).destroy();
if ( filename != NULL ) {
strcpy( portals.fn, filename );
}
int DoLoadPortalFileDialog(){
- GtkWidget *dlg, *vbox, *hbox, *button, *entry, *check2d, *check3d;
int loop = 1, ret = IDCANCEL;
- dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ auto dlg = ui::Window( ui::window_type::TOP );
+
gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) );
gtk_window_set_position( GTK_WINDOW( dlg ),GTK_WIN_POS_CENTER_ON_PARENT );
gtk_window_set_modal( GTK_WINDOW( dlg ), TRUE );
- gtk_window_set_title( GTK_WINDOW( dlg ), "Load .prt" );
- gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
- GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( dlg ), "destroy",
- GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
+
+ gtk_window_set_title( dlg, "Load .prt" );
+ dlg.connect( "delete_event",
+ G_CALLBACK( dialog_delete_callback ), NULL );
+ dlg.connect( "destroy",
+ G_CALLBACK( gtk_widget_destroy ), NULL );
g_object_set_data( G_OBJECT( dlg ), "loop", &loop );
g_object_set_data( G_OBJECT( dlg ), "ret", &ret );
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_container_add( GTK_CONTAINER( dlg ), vbox );
+ auto vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
+ dlg.add(vbox);
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_entry_set_editable( GTK_ENTRY( entry ), FALSE );
- gtk_box_pack_start( GTK_BOX( vbox ), entry, FALSE, FALSE, 0 );
-
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
-
- check3d = gtk_check_button_new_with_label( "Show 3D" );
- gtk_widget_show( check3d );
- gtk_box_pack_start( GTK_BOX( hbox ), check3d, FALSE, FALSE, 0 );
-
- check2d = gtk_check_button_new_with_label( "Show 2D" );
- gtk_widget_show( check2d );
- gtk_box_pack_start( GTK_BOX( hbox ), check2d, FALSE, FALSE, 0 );
-
- button = gtk_button_new_with_label( "Change" );
- gtk_widget_show( button );
- gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( change_clicked ), entry );
- gtk_widget_set_usize( button, 60, -2 );
-
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
-
- button = gtk_button_new_with_label( "Cancel" );
- gtk_widget_show( button );
- gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( button ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
- gtk_widget_set_usize( button, 60, -2 );
-
- button = gtk_button_new_with_label( "OK" );
- gtk_widget_show( button );
- gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 );
- gtk_signal_connect( GTK_OBJECT( button ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
- gtk_widget_set_usize( button, 60, -2 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ gtk_editable_set_editable( GTK_EDITABLE( entry ), FALSE );
+ vbox.pack_start( entry, FALSE, FALSE, 0 );
+
+ auto hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+
+ auto check3d = ui::CheckButton( "Show 3D" );
+ check3d.show();
+ hbox.pack_start( check3d, FALSE, FALSE, 0 );
+
+ auto check2d = ui::CheckButton( "Show 2D" );
+ check2d.show();
+ hbox.pack_start( check2d, FALSE, FALSE, 0 );
+
+ auto button = ui::Button( "Change" );
+ button.show();
+ hbox.pack_end(button, FALSE, FALSE, 0);
+ button.connect( "clicked", G_CALLBACK( change_clicked ), entry );
+ button.dimensions(60, -1);
+
+ hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
+
+ button = ui::Button( "Cancel" );
+ button.show();
+ hbox.pack_end(button, FALSE, FALSE, 0);
+ button.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
+ button.dimensions(60, -1);
+
+ button = ui::Button( "OK" );
+ button.show();
+ hbox.pack_end(button, FALSE, FALSE, 0);
+ button.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
+ button.dimensions(60, -1);
strcpy( portals.fn, GlobalRadiant().getMapName() );
char* fn = strrchr( portals.fn, '.' );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( check3d ), portals.show_3d );
gtk_grab_add( dlg );
- gtk_widget_show( dlg );
+ dlg.show();
while ( loop )
gtk_main_iteration();
}
gtk_grab_remove( dlg );
- gtk_widget_destroy( dlg );
+ dlg.destroy();
return ret;
}
*/
#include "portals.h"
+#include "globaldefs.h"
#include <string.h>
#include <stdlib.h>
-#ifndef __APPLE__
+#if !GDEF_OS_MACOS
#include <search.h>
#endif
#include <stdio.h>
#include "prtview.h"
-#define LINE_BUF 1000
+const int LINE_BUF = 1000;
CPortals portals;
CPortalsRender render;
}
if ( !portal[n].Build( buf ) ) {
- if ( first && sscanf( buf, "%d %d", &test_vals_1, &test_vals_2 ) == 1 ) { // skip additional counts of later data, not needed
+ if ( first && sscanf( buf, "%d %d", (int *) &test_vals_1, (int *) &test_vals_2 ) == 1 ) { // skip additional counts of later data, not needed
// We can count on hint flags being in the file
hint_flags = true;
continue;
}
void CPortalsDrawSolidOutline::render( RenderStateFlags state ) const {
- for ( int n = 0; n < portals.portal_count; n++ )
+ for ( unsigned int n = 0; n < portals.portal_count; n++ )
{
if ( portals.lines == 2 && !portals.portal[n].hint ) {
continue;
if ( clip.min[0] < portals.portal[n].min[0] ) {
continue;
}
- else if ( clip.min[1] < portals.portal[n].min[1] ) {
+ if ( clip.min[1] < portals.portal[n].min[1] ) {
continue;
}
- else if ( clip.min[2] < portals.portal[n].min[2] ) {
+ if ( clip.min[2] < portals.portal[n].min[2] ) {
continue;
}
- else if ( clip.max[0] > portals.portal[n].max[0] ) {
+ if ( clip.max[0] > portals.portal[n].max[0] ) {
continue;
}
- else if ( clip.max[1] > portals.portal[n].max[1] ) {
+ if ( clip.max[1] > portals.portal[n].max[1] ) {
continue;
}
- else if ( clip.max[2] > portals.portal[n].max[2] ) {
+ if ( clip.max[2] > portals.portal[n].max[2] ) {
continue;
}
}
glBegin( GL_LINE_LOOP );
- for ( int p = 0; p < portals.portal[n].point_count; p++ )
+ for ( unsigned int p = 0; p < portals.portal[n].point_count; p++ )
glVertex3fv( portals.portal[n].inner_point[p].p );
glEnd();
};
#ifdef PATH_MAX
-#define PRTVIEW_PATH_MAX PATH_MAX
+const int PRTVIEW_PATH_MAX = PATH_MAX;
#else
-#define PRTVIEW_PATH_MAX 260
+const int PRTVIEW_PATH_MAX = 260;
#endif
typedef guint32 PackedColour;
#define RGB( r, g, b ) ( (guint32)( ( (guint8) ( r ) | ( (guint16) ( g ) << 8 ) ) | ( ( (guint32) (guint8) ( b ) ) << 16 ) ) )
#include <stdio.h>
#include <stdlib.h>
+#include <uilib/uilib.h>
+
#include "profile/profile.h"
#include "qerplugin.h"
/////////////////////////////////////////////////////////////////////////////
// CPrtViewApp construction
-#define RENDER_2D "Render2D"
-#define WIDTH_2D "Width2D"
-#define AA_2D "AntiAlias2D"
-#define COLOR_2D "Color2D"
-
-#define RENDER_3D "Render3D"
-#define WIDTH_3D "Width3D"
-#define AA_3D "AntiAlias3D"
-#define COLOR_3D "Color3D"
-#define COLOR_FOG "ColorFog"
-#define FOG "Fog"
-#define ZBUFFER "ZBuffer"
-#define POLYGON "Polygons"
-#define LINE "Lines"
-#define TRANS_3D "Transparency"
-#define CLIP_RANGE "ClipRange"
-#define CLIP "Clip"
+const char *RENDER_2D = "Render2D";
+const char *WIDTH_2D = "Width2D";
+const char *AA_2D = "AntiAlias2D";
+const char *COLOR_2D = "Color2D";
+
+const char *RENDER_3D = "Render3D";
+const char *WIDTH_3D = "Width3D";
+const char *AA_3D = "AntiAlias3D";
+const char *COLOR_3D = "Color3D";
+const char *COLOR_FOG = "ColorFog";
+const char *FOG = "Fog";
+const char *ZBUFFER = "ZBuffer";
+const char *POLYGON = "Polygons";
+const char *LINE = "Lines";
+const char *TRANS_3D = "Transparency";
+const char *CLIP_RANGE = "ClipRange";
+const char *CLIP = "Clip";
void PrtView_construct(){
}
-#define CONFIG_SECTION "Configuration"
+const char *CONFIG_SECTION = "Configuration";
-int INIGetInt( char *key, int def ){
+int INIGetInt( const char *key, int def ){
char value[1024];
if ( read_var( INIfn.c_str(), CONFIG_SECTION, key, value ) ) {
}
}
-void INISetInt( char *key, int val, char *comment /* = NULL */ ){
+void INISetInt( const char *key, int val, const char *comment /* = NULL */ ){
char s[1000];
if ( comment ) {
Q3R_CMD_LOAD;
-GtkWidget *g_pRadiantWnd = NULL;
+ui::Widget g_pRadiantWnd{ui::null};
const char* QERPlug_Init( void *hApp, void* pMainWidget ){
- g_pRadiantWnd = (GtkWidget*)pMainWidget;
+ g_pRadiantWnd = ui::Window::from(pMainWidget);
return "Portal Viewer for Q3Radiant";
}
#if !defined( INCLUDED_PRTVIEW_H )
#define INCLUDED_PRTVIEW_H
+#include <uilib/uilib.h>
+
#define MSG_PREFIX "Portal Viewer plugin: "
void InitInstance();
void SaveConfig();
-int INIGetInt( char *key, int def );
-void INISetInt( char *key, int val, char *comment = 0 );
-
-typedef struct _GtkWidget GtkWidget;
-extern GtkWidget *g_pRadiantWnd;
+int INIGetInt( const char *key, int def );
+void INISetInt( const char *key, int val, const char *comment = 0 );
-#define IDOK 1
-#define IDCANCEL 2
+extern ui::Widget g_pRadiantWnd;
+const int IDOK = 1;
+const int IDCANCEL = 2;
#endif
--- /dev/null
+radiant_plugin(shaderplug
+ shaderplug.cpp shaderplug.h
+ )
+
+target_include_directories(shaderplug PRIVATE uilib)
+target_link_libraries(shaderplug PRIVATE uilib)
+
+target_include_directories(shaderplug PRIVATE xmllib)
+target_link_libraries(shaderplug PRIVATE xmllib)
namespace Shaderplug
{
-GtkWindow* g_window;
+ui::Window g_window{ui::null};
std::vector<const char*> archives;
std::set<std::string> shaders;
void CreateTagFile();
const char* init( void* hApp, void* pMainWidget ){
- g_window = GTK_WINDOW( pMainWidget );
+ g_window = ui::Window::from(pMainWidget);
return "";
}
const char* getName(){
}
void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){
if ( string_equal( command, "About" ) ) {
- GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), "Shaderplug (1.0)\n\n"
+ GlobalRadiant().m_pfnMessageBox( g_window, "Shaderplug (1.0)\n\n"
"by Shaderman (shaderman@gmx.net)",
"About",
eMB_OK,
archives.push_back( filename );
}
-typedef FreeCaller1<const char*, loadArchiveFile> LoadArchiveFileCaller;
-
void LoadTextureFile( const char* filename ){
std::string s_filename = filename;
}
}
-typedef FreeCaller1<const char*, LoadTextureFile> LoadTextureFileCaller;
-
-void GetTextures( char* extension ){
- GlobalFileSystem().forEachFile( "textures/", extension, LoadTextureFileCaller(), 0 );
+void GetTextures( const char* extension ){
+ GlobalFileSystem().forEachFile("textures/", extension, makeCallbackF(LoadTextureFile), 0);
}
void LoadShaderList( const char* filename ){
}
}
-typedef FreeCaller1<const char*, LoadShaderList> LoadShaderListCaller;
-
void GetAllShaders(){
- GlobalShaderSystem().foreachShaderName( LoadShaderListCaller() );
+ GlobalShaderSystem().foreachShaderName(makeCallbackF(LoadShaderList));
}
void GetArchiveList(){
- GlobalFileSystem().forEachArchive( LoadArchiveFileCaller() );
+ GlobalFileSystem().forEachArchive(makeCallbackF(loadArchiveFile));
globalOutputStream() << "Shaderplug: " << (const Unsigned)Shaderplug::archives.size() << " archives found.\n";
}
strcat( message, "\nPlease restart Radiant now.\n" );
if ( file_exists( tagFile ) ) {
- EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ),
+ EMessageBoxReturn result = GlobalRadiant().m_pfnMessageBox( g_window ,
"WARNING! A tag file already exists! Overwrite it?", "Overwrite tag file?",
eMB_NOYES,
eMB_ICONWARNING );
if ( result == eIDYES ) {
TagBuilder.SaveXmlDoc( tagFile );
- GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), message, "INFO", eMB_OK, eMB_ICONASTERISK );
+ GlobalRadiant().m_pfnMessageBox( g_window, message, "INFO", eMB_OK, eMB_ICONASTERISK );
}
}
else {
TagBuilder.SaveXmlDoc( tagFile );
- GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ), message, "INFO", eMB_OK, eMB_ICONASTERISK );
+ GlobalRadiant().m_pfnMessageBox( g_window, message, "INFO", eMB_OK, eMB_ICONASTERISK );
}
}
else {
- GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_window ),
+ GlobalRadiant().m_pfnMessageBox( g_window,
"No shaders or textures found. No XML tag file created!\n"
"",
"ERROR",
--- /dev/null
+radiant_plugin(sunplug
+ sunplug.cpp sunplug.h
+ )
+
+target_include_directories(sunplug PRIVATE uilib)
+target_link_libraries(sunplug PRIVATE uilib)
*/
#include "sunplug.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
void about_plugin_window();
void MapCoordinator();
-#ifndef _WIN32
+#if !GDEF_OS_WINDOWS
// linux itoa implementation
char* itoa( int value, char* result, int base ){
// check that the base if valid
#endif
typedef struct _mapcoord_setting_packet {
- GtkSpinButton *spinner1, *spinner2, *spinner3, *spinner4;
+ ui::SpinButton spinner1{ui::null}, spinner2{ui::null}, spinner3{ui::null}, spinner4{ui::null};
Entity* worldspawn;
} mapcoord_setting_packet;
// ** GTK callback functions **
// **************************
-static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ){
+static gboolean delete_event(ui::Widget widget, GdkEvent *event, gpointer data ){
/* If you return FALSE in the "delete_event" signal handler,
* GTK will emit the "destroy" signal. Returning TRUE means
* you don't want the window to be destroyed.
}
// destroy widget if destroy signal is passed to widget
-static void destroy( GtkWidget *widget, gpointer data ){
- gtk_widget_destroy( widget );
+static void destroy( ui::Widget widget, gpointer data ){
+ widget.destroy();
}
// function for close button to destroy the toplevel widget
-static void close_window( GtkWidget *widget, gpointer data ){
- gtk_widget_destroy( gtk_widget_get_toplevel( widget ) );
+static void close_window( ui::Widget widget, gpointer data ){
+ widget.window().destroy();
}
// callback function to assign the optimal mapcoords to the spinboxes
-static void input_optimal( GtkWidget *widget, gpointer data ){
+static void input_optimal(ui::Widget widget, gpointer data ){
gtk_spin_button_set_value( msp.spinner1, minX );
gtk_spin_button_set_value( msp.spinner2, maxY );
gtk_spin_button_set_value( msp.spinner3, maxX );
}
// Spinner return value function
-gint grab_int_value( GtkSpinButton *a_spinner, gpointer user_data ) {
+gint grab_int_value(ui::SpinButton a_spinner, gpointer user_data ) {
return gtk_spin_button_get_value_as_int( a_spinner );
}
// write the values of the Spinner-Boxes to the worldspawn
-static void set_coordinates( GtkWidget *widget, gpointer data ){
+static void set_coordinates( ui::Widget widget, gpointer data ){
//Str str_min, str_max;
char buffer[10], str_min[20], str_max[20];
// *************************
namespace SunPlug
{
-GtkWindow* main_window;
+ui::Window main_window{ui::null};
char MenuList[100] = "";
const char* init( void* hApp, void* pMainWidget ){
- main_window = GTK_WINDOW( pMainWidget );
+ main_window = ui::Window::from(pMainWidget);
return "Initializing SunPlug for GTKRadiant";
}
const char* getName(){
// About dialog
void about_plugin_window(){
- GtkWidget *window, *vbox, *label, *button;
-
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); // create a window
- gtk_window_set_transient_for( GTK_WINDOW( window ), SunPlug::main_window ); // make the window to stay in front of the main window
- g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event
- g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
- gtk_window_set_title( GTK_WINDOW( window ), "About SunPlug" ); // set the title of the window for the window
- gtk_window_set_resizable( GTK_WINDOW( window ), FALSE ); // don't let the user resize the window
- gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); // force the user not to do something with the other windows
+ auto window = ui::Window( ui::window_type::TOP ); // create a window
+ gtk_window_set_transient_for( window, SunPlug::main_window ); // make the window to stay in front of the main window
+ window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event
+ window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
+ gtk_window_set_title( window, "About SunPlug" ); // set the title of the window for the window
+ gtk_window_set_resizable( window, FALSE ); // don't let the user resize the window
+ gtk_window_set_modal( window, TRUE ); // force the user not to do something with the other windows
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window
- vbox = gtk_vbox_new( FALSE, 10 ); // create a box to arrange new objects vertically
- gtk_container_add( GTK_CONTAINER( window ), vbox ); // add the box to the window
+ auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically
+ window.add(vbox);
- label = gtk_label_new( "SunPlug v1.0 for NetRadiant 1.5\nby Topsun" ); // create a label
+ auto label = ui::Label( "SunPlug v1.0 for NetRadiant 1.5\nby Topsun" ); // create a label
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // text align left
- gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, FALSE, 2 ); // insert the label in the box
+ vbox.pack_start( label, FALSE, FALSE, 2 ); // insert the label in the box
- button = gtk_button_new_with_label( "OK" ); // create a button with text
- g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( gtk_widget_destroy ), window ); // connect the click event to close the window
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 ); // insert the button in the box
+ auto button = ui::Button( "OK" ); // create a button with text
+ g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( gtk_widget_destroy ), (void *) window ); // connect the click event to close the window
+ vbox.pack_start( button, FALSE, FALSE, 2 ); // insert the button in the box
- gtk_window_set_position( GTK_WINDOW( window ), GTK_WIN_POS_CENTER ); // center the window on screen
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER ); // center the window on screen
gtk_widget_show_all( window ); // show the window and all subelements
}
// MapCoordinator dialog window
void MapCoordinator(){
- GtkWidget *window, *vbox, *table, *label, *spinnerMinX, *spinnerMinY, *spinnerMaxX, *spinnerMaxY, *button;
- GtkAdjustment *spinner_adj_MinX, *spinner_adj_MinY, *spinner_adj_MaxX, *spinner_adj_MaxY;
Entity *theWorldspawn = NULL;
const char *buffer;
char line[20];
// in any case we need a window to show the user what to do
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); // create the window
- gtk_window_set_transient_for( GTK_WINDOW( window ), SunPlug::main_window ); // make the window to stay in front of the main window
- g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window
- g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
- gtk_window_set_title( GTK_WINDOW( window ), "ET-MapCoordinator" ); // set the title of the window for the window
- gtk_window_set_resizable( GTK_WINDOW( window ), FALSE ); // don't let the user resize the window
- gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); // force the user not to do something with the other windows
+ auto window = ui::Window( ui::window_type::TOP ); // create the window
+ gtk_window_set_transient_for( window, SunPlug::main_window ); // make the window to stay in front of the main window
+ window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window
+ window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
+ gtk_window_set_title( window, "ET-MapCoordinator" ); // set the title of the window for the window
+ gtk_window_set_resizable( window, FALSE ); // don't let the user resize the window
+ gtk_window_set_modal( window, TRUE ); // force the user not to do something with the other windows
gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window
- vbox = gtk_vbox_new( FALSE, 10 ); // create a box to arrange new objects vertically
- gtk_container_add( GTK_CONTAINER( window ), vbox ); // add the box to the window
+ auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically
+ window.add(vbox);
scene::Path path = makeReference( GlobalSceneGraph().root() ); // get the path to the root element of the graph
scene::Instance* instance = GlobalSceneGraph().find( path ); // find the instance to the given path
globalOutputStream() << "SunPlug: adviced mapcoordsmins=" << minX << " " << maxY << "\n"; // console info about mapcoordsmins
globalOutputStream() << "SunPlug: adviced mapcoordsmaxs=" << maxX << " " << minY << "\n"; // console info about mapcoordsmaxs
- spinner_adj_MinX = (GtkAdjustment *)gtk_adjustment_new( map_minX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum x value
- spinner_adj_MinY = (GtkAdjustment *)gtk_adjustment_new( map_minY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum y value
- spinner_adj_MaxX = (GtkAdjustment *)gtk_adjustment_new( map_maxX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum x value
- spinner_adj_MaxY = (GtkAdjustment *)gtk_adjustment_new( map_maxY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum y value
+ auto spinner_adj_MinX = ui::Adjustment( map_minX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum x value
+ auto spinner_adj_MinY = ui::Adjustment( map_minY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of minimum y value
+ auto spinner_adj_MaxX = ui::Adjustment( map_maxX, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum x value
+ auto spinner_adj_MaxY = ui::Adjustment( map_maxY, -65536.0, 65536.0, 1.0, 5.0, 0 ); // create adjustment for value and range of maximum y value
- button = gtk_button_new_with_label( "Get optimal mapcoords" ); // create button with text
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( input_optimal ), NULL ); // connect button with callback function
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 ); // insert button into vbox
+ auto button = ui::Button( "Get optimal mapcoords" ); // create button with text
+ button.connect( "clicked", G_CALLBACK( input_optimal ), NULL ); // connect button with callback function
+ vbox.pack_start( button, FALSE, FALSE, 2 ); // insert button into vbox
- gtk_box_pack_start( GTK_BOX( vbox ), gtk_hseparator_new(), FALSE, FALSE, 2 ); // insert separator into vbox
+ vbox.pack_start( ui::Widget::from(gtk_hseparator_new()), FALSE, FALSE, 2 ); // insert separator into vbox
- table = gtk_table_new( 4, 3, TRUE ); // create table
- gtk_table_set_row_spacings( GTK_TABLE( table ), 8 ); // set row spacings
- gtk_table_set_col_spacings( GTK_TABLE( table ), 8 ); // set column spacings
- gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, FALSE, 2 ); // insert table into vbox
+ auto table = ui::Table( 4, 3, TRUE ); // create table
+ gtk_table_set_row_spacings(table, 8); // set row spacings
+ gtk_table_set_col_spacings(table, 8); // set column spacings
+ vbox.pack_start( table, FALSE, FALSE, 2 ); // insert table into vbox
- label = gtk_label_new( "x" ); // create label
+ auto label = ui::Label( "x" ); // create label
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side
- gtk_table_attach_defaults( GTK_TABLE( table ), label, 1, 2, 0, 1 ); // insert label into table
+ table.attach(label, {1, 2, 0, 1}); // insert label into table
- label = gtk_label_new( "y" ); // create label
+ label = ui::Label( "y" ); // create label
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side
- gtk_table_attach_defaults( GTK_TABLE( table ), label, 2, 3, 0, 1 ); // insert label into table
+ table.attach(label, {2, 3, 0, 1}); // insert label into table
- label = gtk_label_new( "mapcoordsmins" ); // create label
+ label = ui::Label( "mapcoordsmins" ); // create label
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side
- gtk_table_attach_defaults( GTK_TABLE( table ), label, 0, 1, 1, 2 ); // insert label into table
+ table.attach(label, {0, 1, 1, 2}); // insert label into table
- spinnerMinX = gtk_spin_button_new( spinner_adj_MinX, 1.0, 0 ); // create textbox wiht value spin, value and value range
- gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMinX, 1, 2, 1, 2 ); // insert spinbox into table
+ auto spinnerMinX = ui::SpinButton(spinner_adj_MinX, 1.0, 0); // create textbox wiht value spin, value and value range
+ table.attach(spinnerMinX, {1, 2, 1, 2}); // insert spinbox into table
- spinnerMinY = gtk_spin_button_new( spinner_adj_MinY, 1.0, 0 ); // create textbox wiht value spin, value and value range
- gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMinY, 2, 3, 1, 2 ); // insert spinbox into table
+ auto spinnerMinY = ui::SpinButton(spinner_adj_MinY, 1.0, 0); // create textbox wiht value spin, value and value range
+ table.attach(spinnerMinY, {2, 3, 1, 2}); // insert spinbox into table
- label = gtk_label_new( "mapcoordsmaxs" ); // create label
+ label = ui::Label( "mapcoordsmaxs" ); // create label
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // align text to the left side
- gtk_table_attach_defaults( GTK_TABLE( table ), label, 0, 1, 2, 3 ); // insert label into table
+ table.attach(label, {0, 1, 2, 3}); // insert label into table
- spinnerMaxX = gtk_spin_button_new( spinner_adj_MaxX, 1.0, 0 ); // create textbox wiht value spin, value and value range
- gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMaxX, 1, 2, 2, 3 ); // insert spinbox into table
+ auto spinnerMaxX = ui::SpinButton(spinner_adj_MaxX, 1.0, 0); // create textbox wiht value spin, value and value range
+ table.attach(spinnerMaxX, {1, 2, 2, 3}); // insert spinbox into table
- spinnerMaxY = gtk_spin_button_new( spinner_adj_MaxY, 1.0, 0 ); // create textbox wiht value spin, value and value range
- gtk_table_attach_defaults( GTK_TABLE( table ), spinnerMaxY, 2, 3, 2, 3 ); // insert spinbox into table
+ auto spinnerMaxY = ui::SpinButton(spinner_adj_MaxY, 1.0, 0); // create textbox wiht value spin, value and value range
+ table.attach(spinnerMaxY, {2, 3, 2, 3}); // insert spinbox into table
// put the references to the spinboxes and the worldspawn into the global exchange
- msp.spinner1 = GTK_SPIN_BUTTON( spinnerMinX );
- msp.spinner2 = GTK_SPIN_BUTTON( spinnerMinY );
- msp.spinner3 = GTK_SPIN_BUTTON( spinnerMaxX );
- msp.spinner4 = GTK_SPIN_BUTTON( spinnerMaxY );
+ msp.spinner1 = spinnerMinX;
+ msp.spinner2 = spinnerMinY;
+ msp.spinner3 = spinnerMaxX;
+ msp.spinner4 = spinnerMaxY;
msp.worldspawn = theWorldspawn;
- button = gtk_button_new_with_label( "Set" ); // create button with text
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( set_coordinates ), NULL ); // connect button with callback function
- gtk_table_attach_defaults( GTK_TABLE( table ), button, 1, 2, 3, 4 ); // insert button into table
+ button = ui::Button( "Set" ); // create button with text
+ button.connect( "clicked", G_CALLBACK( set_coordinates ), NULL ); // connect button with callback function
+ table.attach(button, {1, 2, 3, 4}); // insert button into table
- button = gtk_button_new_with_label( "Cancel" ); // create button with text
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( close_window ), NULL ); // connect button with callback function
- gtk_table_attach_defaults( GTK_TABLE( table ), button, 2, 3, 3, 4 ); // insert button into table
+ button = ui::Button( "Cancel" ); // create button with text
+ button.connect( "clicked", G_CALLBACK( close_window ), NULL ); // connect button with callback function
+ table.attach(button, {2, 3, 3, 4}); // insert button into table
}
else {
globalOutputStream() << "SunPlug: no worldspawn found!\n"; // output error to console
- label = gtk_label_new( "ERROR: No worldspawn was found in the map!\nIn order to use this tool the map must have at least one brush in the worldspawn. " ); // create a label
+ auto label = ui::Label( "ERROR: No worldspawn was found in the map!\nIn order to use this tool the map must have at least one brush in the worldspawn. " ); // create a label
gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // text align left
- gtk_box_pack_start( GTK_BOX( vbox ), label, FALSE, FALSE, 2 ); // insert the label in the box
+ vbox.pack_start( label, FALSE, FALSE, 2 ); // insert the label in the box
- button = gtk_button_new_with_label( "OK" ); // create a button with text
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( close_window ), NULL ); // connect the click event to close the window
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 2 ); // insert the button in the box
+ auto button = ui::Button( "OK" ); // create a button with text
+ button.connect( "clicked", G_CALLBACK( close_window ), NULL ); // connect the click event to close the window
+ vbox.pack_start( button, FALSE, FALSE, 2 ); // insert the button in the box
}
- gtk_window_set_position( GTK_WINDOW( window ), GTK_WIN_POS_CENTER ); // center the window
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER ); // center the window
gtk_widget_show_all( window ); // show the window and all subelements
}
--- /dev/null
+radiant_plugin(ufoaiplug
+ ufoai.cpp ufoai.h
+ ufoai_filters.cpp ufoai_filters.h
+ ufoai_gtk.cpp ufoai_gtk.h
+ ufoai_level.cpp ufoai_level.h
+ )
+
+target_include_directories(ufoaiplug PRIVATE uilib)
+target_link_libraries(ufoaiplug PRIVATE uilib)
namespace UFOAI
{
-GtkWindow* g_mainwnd;
+ ui::Window g_mainwnd{ui::null};
const char* init( void* hApp, void* pMainWidget ){
- g_mainwnd = GTK_WINDOW( pMainWidget );
+ g_mainwnd = ui::Window::from(pMainWidget);
return "Initializing GTKRadiant UFOAI plugin";
}
const char* getName(){
return "";
}
void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){
- char *message = NULL;
+ char const *message = NULL;
if ( string_equal( command, "About" ) ) {
- GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ),
- "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__ "\nRadiant version: " RADIANT_VERSION "\nPlugin version: " PLUGIN_VERSION "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n", "About",
+ char const *version_string = "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__
+ "\nRadiant version: " RADIANT_VERSION
+ "\nPlugin version: " PLUGIN_VERSION
+ "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n";
+ GlobalRadiant().m_pfnMessageBox( g_mainwnd,
+ version_string, "About",
eMB_OK, eMB_ICONDEFAULT );
}
else if ( string_equal( command, "Level 1" ) ) {
}
if ( message != NULL ) {
- GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ),
+ GlobalRadiant().m_pfnMessageBox( g_mainwnd,
message, "Note",
eMB_OK, eMB_ICONDEFAULT );
}
*/
#include "ufoai_filters.h"
+#include "globaldefs.h"
#include "ibrush.h"
#include "ientity.h"
}
void visit( Face& face ) const {
-#if _DEBUG
+#if GDEF_DEBUG
if ( m_surfaceFlagsVis < 0 ) {
m_surfaceFlagsVis = face.getShader().m_flags.m_surfaceFlags;
}
GlobalSceneGraph().traverse( EntityFindByName( "misc_model", entities, level, true ) );
GlobalSceneGraph().traverse( EntityFindByName( "misc_particle", entities, level, true ) );
-#ifdef _DEBUG
+#if GDEF_DEBUG
if ( brushes.empty() ) {
globalOutputStream() << "UFO:AI: No brushes.\n";
}
brushlist_t brushes;
GlobalSceneGraph().traverse( BrushGetLevel( brushes, SURF_NODRAW, false, false, nodraw_active ) );
-#ifdef _DEBUG
+#if GDEF_DEBUG
if ( brushes.empty() ) {
globalOutputStream() << "UFO:AI: No brushes.\n";
}
brushlist_t brushes;
GlobalSceneGraph().traverse( BrushGetLevel( brushes, CONTENTS_ACTORCLIP, true, false, actorclip_active ) );
-#ifdef _DEBUG
+#if GDEF_DEBUG
if ( brushes.empty() ) {
globalOutputStream() << "UFO:AI: No brushes.\n";
}
brushlist_t brushes;
GlobalSceneGraph().traverse( BrushGetLevel( brushes, CONTENTS_WEAPONCLIP, true, false, weaponclip_active ) );
-#ifdef _DEBUG
+#if GDEF_DEBUG
if ( brushes.empty() ) {
globalOutputStream() << "UFO:AI: No brushes.\n";
}
void filter_weaponclip( void );
void filter_nodraw( void );
-#define SURF_NODRAW 0x80
-
-#define CONTENTS_LEVEL8 0x8000
-#define CONTENTS_LEVEL7 0x4000
-#define CONTENTS_LEVEL6 0x2000
-#define CONTENTS_LEVEL5 0x1000
-#define CONTENTS_LEVEL4 0x0800
-#define CONTENTS_LEVEL3 0x0400
-#define CONTENTS_LEVEL2 0x0200
-#define CONTENTS_LEVEL1 0x0100
-#define CONTENTS_ACTORCLIP 0x10000
-#define CONTENTS_WEAPONCLIP 0x2000000
-#define CONTENTS_STEPON 0x40000000
+const int SURF_NODRAW = 0x80;
+
+const int CONTENTS_LEVEL8 = 0x8000;
+const int CONTENTS_LEVEL7 = 0x4000;
+const int CONTENTS_LEVEL6 = 0x2000;
+const int CONTENTS_LEVEL5 = 0x1000;
+const int CONTENTS_LEVEL4 = 0x0800;
+const int CONTENTS_LEVEL3 = 0x0400;
+const int CONTENTS_LEVEL2 = 0x0200;
+const int CONTENTS_LEVEL1 = 0x0100;
+const int CONTENTS_ACTORCLIP = 0x10000;
+const int CONTENTS_WEAPONCLIP = 0x2000000;
+const int CONTENTS_STEPON = 0x40000000;
#endif
#include "iscenegraph.h"
#include <gtk/gtk.h>
-
-/**
- * GTK callback functions
- */
-
-class UFOAIGtk
-{
-GtkWindow* m_gtk_window;
-public:
-UFOAIGtk( void* gtk_window ) : m_gtk_window( ( GtkWindow* )gtk_window ){
-}
-};
+#include <uilib/uilib.h>
/**
* @brief If you return FALSE in the "delete_event" signal handler,
* This is useful for popping up 'are you sure you want to quit?'
* type dialogs.
*/
-static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ){
+static gboolean delete_event(ui::Widget widget, GdkEvent *event, gpointer data ){
return FALSE;
}
/**
* @brief destroy widget if destroy signal is passed to widget
*/
-static void destroy( GtkWidget *widget, gpointer data ){
- gtk_widget_destroy( widget );
+static void destroy( ui::Widget widget, gpointer data ){
+ widget.destroy();
}
/**
* @brief function for close button to destroy the toplevel widget
*/
-static void close_window( GtkWidget *widget, gpointer data ){
- gtk_widget_destroy( gtk_widget_get_toplevel( widget ) );
+static void close_window( ui::Widget widget, gpointer data ){
+ widget.window().destroy();
}
/* =============================== */
-#define NUM_TOOLBARBUTTONS 12
+const int NUM_TOOLBARBUTTONS = 12;
/**
* @brief
#define INCLUDED_UFOAI_GTK_H
#include "itoolbar.h"
-#include <gtk/gtk.h>
const IToolbarButton* GetToolbarButton( std::size_t index );
const IToolbarButton* GetToolbarNoButton( std::size_t index );
/**
* @brief Some default values to worldspawn like maxlevel and so on
*/
-void assign_default_values_to_worldspawn( bool override, char **returnMsg ){
+void assign_default_values_to_worldspawn( bool override, const char **returnMsg ){
static char message[1024];
Entity* worldspawn;
int teams = 0;
* @brief Will check e.g. the map entities for valid values
* @todo: check for maxlevel
*/
-void check_map_values( char **returnMsg ){
+void check_map_values( const char **returnMsg ){
static char message[1024];
int count = 0;
int teams = 0;
#if !defined( INCLUDED_UFOAI_LEVEL_H )
#define INCLUDED_UFOAI_LEVEL_H
-void assign_default_values_to_worldspawn( bool override, char **returnMsg );
-void check_map_values( char **returnMsg );
-void get_team_count( const char *classname, int *count, int *team );
+void assign_default_values_to_worldspawn(bool override, char const **returnMsg);
+void check_map_values(char const **returnMsg);
+void get_team_count(const char *classname, int *count, int *team);
#endif
</style>
</head>
<body>
-<p class="p1"><a href="https://gitlab.com/xonotic/xonotic/wikis/Mapping/Mapping">Xonotic Mapping Wiki</A></p>
+<p class="p1"><a href="https://gitlab.com/xonotic/xonotic/wikis/Mapping">Xonotic Mapping Wiki</A></p>
</body>
</html>
+++ /dev/null
-#!/bin/sh
-
-# Usage:
-# sh download-gamepack.sh
-# LICENSEFILTER=GPL 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
- " ")
- ;;
- *" $license "*)
- ;;
- *)
- $ECHO "Pack $pack rejected because its license is not in LICENSEFILTER."
- return
- ;;
- 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 NexuizPack GPL gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
-pack OpenArenaPack unknown zip1 http://ingar.satgnu.net/files/gtkradiant/gamepacks/OpenArenaPack.zip
-pack OsirionPack GPL zip1 http://ingar.satgnu.net/files/gtkradiant/gamepacks/OsirionPack.zip
-pack Q3Pack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/Q3Pack/trunk/ -r29
-pack Quake2Pack proprietary zip1 http://ingar.satgnu.net/files/gtkradiant/gamepacks/Quake2Pack.zip
-pack Quake2WorldPack GPL svn svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
-pack QuakePack GPL zip1 http://ingar.satgnu.net/files/gtkradiant/gamepacks/Quake1Pack.zip
-pack TremulousPack proprietary zip1 http://ingar.satgnu.net/files/gtkradiant/gamepacks/TremulousPack.zip
-pack UFOAIPack proprietary svn svn://svn.icculus.org/gtkradiant-gamepacks/UFOAIPack/branches/1.5/
-#pack WarsowPack GPL svn https://svn.bountysource.com/wswpack/trunk/netradiant/games/WarsowPack/
-pack WarsowPack GPL zip1 http://ingar.satgnu.net/files/gtkradiant/gamepacks/WarsowPack.zip
-pack XonoticPack GPL git http://git.xonotic.org/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 ()
+{
+ if [ -f 'extra-urls.txt' ]
+ then
+ while IFS=' ' read -r extra_file extra_url
+ do
+ (
+ ${WGET} -O "${extra_file}" "${extra_url}"
+ ) </dev/null
+ done < '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 "${pack}" ]
+ then
+ (
+ cd "${pack}"
+ downloadExtraUrls
+ )
+ 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
+add_library(includes
+ aboutmsg.h
+ cullable.h
+ dpkdeps.h
+ editable.h
+ iarchive.h
+ ibrush.h
+ icamera.h
+ idatastream.h
+ ieclass.h
+ ientity.h
+ ifilesystem.h
+ ifiletypes.h
+ ifilter.h
+ igl.h
+ iglrender.h
+ igtkgl.h
+ iimage.h
+ imap.h
+ imodel.h
+ ipatch.h
+ iplugin.h
+ ireference.h
+ irender.h
+ iscenegraph.h
+ iscriplib.h
+ iselection.h
+ ishaders.h
+ itexdef.h
+ itextstream.h
+ itextures.h
+ itoolbar.h
+ iundo.h
+ mapfile.h
+ modelskin.h
+ moduleobserver.h
+ modulesystem.h
+ nameable.h
+ namespace.h
+ preferencesystem.cpp preferencesystem.h
+ qerplugin.h
+ renderable.h
+ selectable.h
+ stream_version.h
+ version.h
+ warnings.h
+ windowobserver.h
+ )
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "cullable.h"
--- /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 GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined( INCLUDED_DEFAULTS_H )
+#define INCLUDED_DEFAULTS_H
+
+#define DEFAULT_EDITORVFS_DIRNAME "base/"
+#define DEFAULT_TEXTURE_DIRNAME "textures/"
+#define DEFAULT_NOTEX_DIRNAME DEFAULT_TEXTURE_DIRNAME "radiant/"
+#define DEFAULT_NOTEX_BASENAME "notex"
+#define DEFAULT_SHADERNOTEX_BASENAME "shadernotex"
+#define DEFAULT_NOTEX_NAME DEFAULT_NOTEX_DIRNAME DEFAULT_NOTEX_BASENAME
+#define DEFAULT_SHADERNOTEX_NAME DEFAULT_NOTEX_DIRNAME DEFAULT_SHADERNOTEX_BASENAME
+
+#endif // INCLUDED_DEFAULTS_H
--- /dev/null
+#ifndef __DPKDEPS_H__
+#define __DPKDEPS_H__
+
+#include <locale>
+#include "string/string.h"
+
+// Comparaison function for version numbers
+// Implementation is based on dpkg's version comparison code (verrevcmp() and order())
+// http://anonscm.debian.org/gitweb/?p=dpkg/dpkg.git;a=blob;f=lib/dpkg/version.c;hb=74946af470550a3295e00cf57eca1747215b9311
+inline int char_weight(char c){
+ if (std::isdigit(c))
+ return 0;
+ else if (std::isalpha(c))
+ return c;
+ else if (c == '~')
+ return -1;
+ else if (c)
+ return c + 256;
+ else
+ return 0;
+}
+
+inline int DpkPakVersionCmp(const char* a, const char* b){
+ while (*a || *b) {
+ int firstDiff = 0;
+
+ while ((*a && !std::isdigit(*a)) || (*b && !std::isdigit(*b))) {
+ int ac = char_weight(*a);
+ int bc = char_weight(*b);
+
+ if (ac != bc)
+ return ac - bc;
+
+ a++;
+ b++;
+ }
+
+ while (*a == '0')
+ a++;
+ while (*b == '0')
+ b++;
+
+ while (std::isdigit(*a) && std::isdigit(*b)) {
+ if (firstDiff == 0)
+ firstDiff = *a - *b;
+ a++;
+ b++;
+ }
+
+ if (std::isdigit(*a))
+ return 1;
+ if (std::isdigit(*b))
+ return -1;
+ if (firstDiff)
+ return firstDiff;
+ }
+
+ return false;
+}
+
+// release strings after using
+inline bool DpkReadDepsLine( const char *line, char **pakname, char **pakversion ){
+ const char* c = line;
+ const char* p_name;
+ const char* p_name_end;
+ const char* p_version;
+ const char* p_version_end;
+
+ *pakname = 0;
+ *pakversion = 0;
+
+ while ( std::isspace( *c ) && *c != '\0' ) ++c;
+ p_name = c;
+ while ( !std::isspace( *c ) && *c != '\0' ) ++c;
+ p_name_end = c;
+ while ( std::isspace( *c ) && *c != '\0' ) ++c;
+ p_version = c;
+ while ( !std::isspace( *c ) && *c != '\0' ) ++c;
+ p_version_end = c;
+
+ if ( p_name_end - p_name > 0 ){
+ *pakname = string_clone_range( StringRange( p_name, p_name_end ) );
+ } else return false;
+
+ if ( p_version_end - p_version > 0 ) {
+ *pakversion = string_clone_range( StringRange( p_version, p_version_end ) );
+ }
+ return true;
+}
+
+#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "editable.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "iarchive.h"
class ArchiveFile
{
public:
+virtual ~ArchiveFile() = default;
/// \brief Destroys the file object.
virtual void release() = 0;
/// \brief Returns the size of the file data in bytes.
class ArchiveTextFile
{
public:
+virtual ~ArchiveTextFile() = default;
/// \brief Destroys the file object.
virtual void release() = 0;
/// \brief Returns the stream associated with this file.
class Archive
{
public:
+virtual ~Archive() = default;
class Visitor
{
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ibrush.h"
int value;
};
-typedef Callback1<const _QERFaceData&> BrushFaceDataCallback;
+typedef Callback<void(const _QERFaceData&)> BrushFaceDataCallback;
class BrushCreator
{
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "icamera.h"
#define INCLUDED_ICAMERA_H
#include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
class Matrix4;
{
public:
STRING_CONSTANT( Name, "CameraModel" );
-virtual void setCameraView( CameraView* view, const Callback& disconnect ) = 0;
+virtual void setCameraView( CameraView* view, const Callback<void()>& disconnect ) = 0;
};
template<typename Element> class BasicVector3;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "idatastream.h"
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ieclass.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ientity.h"
class EntityClass;
-typedef Callback1<const char*> KeyObserver;
+typedef Callback<void(const char*)> KeyObserver;
class EntityKeyValue
{
public:
+virtual ~EntityKeyValue() = default;
virtual const char* c_str() const = 0;
virtual void assign( const char* other ) = 0;
virtual void attach( const KeyObserver& observer ) = 0;
virtual void connectEntities( const scene::Path& e1, const scene::Path& e2, int index ) = 0;
virtual void setLightRadii( bool lightRadii ) = 0;
-virtual bool getLightRadii() = 0;
+virtual bool getLightRadii() const = 0;
virtual void setShowNames( bool showNames ) = 0;
virtual bool getShowNames() = 0;
virtual void setShowAngles( bool showAngles ) = 0;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ifilesystem.h"
#include <cstddef>
#include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
-typedef Callback1<const char*> ArchiveNameCallback;
-typedef Callback1<const char*> FileNameCallback;
+typedef Callback<void(const char*)> ArchiveNameCallback;
+typedef Callback<void(const char*)> FileNameCallback;
class ArchiveFile;
class ArchiveTextFile;
/// \brief Initialises the filesystem.
/// Called after all root search paths have been added.
virtual void initialise() = 0;
+/// \brief Clear the filesystem if supported
+virtual void clear() = 0;
+/// \brief Reload the filesystem if supported
+virtual void refresh() = 0;
/// \brief Shuts down the filesystem.
virtual void shutdown() = 0;
/// \deprecated Use \c openFile.
inline int vfsLoadFile( const char* filename, void** buffer, int index = 0 ){
return static_cast<int>( GlobalFileSystem().loadFile( filename, buffer ) );
-};
+}
/// \deprecated Deprecated.
inline void vfsFreeFile( void* p ){
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ifiletypes.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ifilter.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "igl.h"
#if !defined( INCLUDED_IGL_H )
#define INCLUDED_IGL_H
+#include "globaldefs.h"
#include <cstddef>
#include <string.h>
#include "generic/constant.h"
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
#define QGL_DLLEXPORT __stdcall
#else
#define QGL_DLLEXPORT
return GlobalOpenGLModule::getTable();
}
-#if defined( _DEBUG )
+#if GDEF_DEBUG
#define GlobalOpenGL_debugAssertNoErrors() GlobalOpenGL().assertNoErrors( __FILE__, __LINE__ )
#else
#define GlobalOpenGL_debugAssertNoErrors()
+++ /dev/null
-
-#include "iglrender.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "igtkgl.h"
#if !defined( INCLUDED_IGTKGL_H )
#define INCLUDED_IGTKGL_H
+#include <uilib/uilib.h>
#include "generic/constant.h"
-typedef struct _GtkWidget GtkWidget;
-typedef int gint;
-typedef gint gboolean;
+template<class T>
+using func = T *;
-struct _QERGtkGLTable
-{
- INTEGER_CONSTANT( Version, 1 );
- STRING_CONSTANT( Name, "gtkgl" );
+struct _QERGtkGLTable {
+ STRING_CONSTANT(Name, "gtkgl");
+ INTEGER_CONSTANT(Version, 1);
- GtkWidget* ( *glwidget_new )(gboolean zbufffer);
- void ( *glwidget_swap_buffers )( GtkWidget* widget );
- gboolean ( *glwidget_make_current )( GtkWidget* widget );
- void ( *glwidget_destroy_context )( GtkWidget* widget );
- void ( *glwidget_create_context )( GtkWidget* widget );
+ func<ui::GLArea(bool zbufffer)> glwidget_new;
+ func<void(ui::GLArea self)> glwidget_swap_buffers;
+ func<bool(ui::GLArea self)> glwidget_make_current;
+ func<void(ui::GLArea self)> glwidget_destroy_context;
+ func<void(ui::GLArea self)> glwidget_create_context;
};
#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "iimage.h"
class Image
{
public:
+virtual ~Image() = default;
virtual void release() = 0;
virtual byte* getRGBAPixels() const = 0;
virtual unsigned int getWidth() const = 0;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "imap.h"
class MapFormat
{
public:
+virtual ~MapFormat() = default;
INTEGER_CONSTANT( Version, 2 );
STRING_CONSTANT( Name, "map" );
mutable bool wrongFormat;
/// \brief Read a map graph into \p root from \p outputStream, using \p entityTable to create entities.
virtual void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const = 0;
/// \brief Write the map graph obtained by applying \p traverse to \p root into \p outputStream.
-virtual void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const = 0;
+virtual void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const = 0;
};
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "imodel.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ipatch.h"
#if !defined( INCLUDED_IPATCH_H )
#define INCLUDED_IPATCH_H
+#include "globaldefs.h"
+#include "debugging/debugging.h"
#include "generic/constant.h"
#include "generic/vector.h"
}
value_type& operator[]( std::size_t index ){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
#endif
return m_data[index];
}
const value_type& operator[]( std::size_t index ) const {
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
#endif
return m_data[index];
}
value_type& operator[]( std::size_t index ){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
#endif
return m_data[index];
}
const value_type& operator[]( std::size_t index ) const {
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
#endif
return m_data[index];
}
value_type& operator()( std::size_t x, std::size_t y ){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" );
#endif
return m_data[x * m_y + y];
}
const value_type& operator()( std::size_t x, std::size_t y ) const {
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" );
#endif
return m_data[x * m_y + y];
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "iplugin.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ireference.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "irender.h"
#define INCLUDED_IRENDER_H
#include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
// Rendering states to sort by.
};
class Renderable;
-typedef Callback1<const Renderable&> RenderableCallback;
+typedef Callback<void(const Renderable&)> RenderableCallback;
-typedef Callback1<const RendererLight&> RendererLightCallback;
+typedef Callback<void(const RendererLight&)> RendererLightCallback;
class LightList
{
class OpenGLRenderable
{
public:
+virtual ~OpenGLRenderable() = default;
virtual void render( RenderStateFlags state ) const = 0;
};
class Shader
{
public:
+virtual ~Shader() = default;
virtual void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview, const LightList* lights = 0 ) = 0;
virtual void incrementUsed() = 0;
virtual void decrementUsed() = 0;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "iscenegraph.h"
class Graph
{
public:
+virtual ~Graph() = default;
INTEGER_CONSTANT( Version, 1 );
STRING_CONSTANT( Name, "scenegraph" );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "iscriplib.h"
class Tokeniser
{
public:
+virtual ~Tokeniser() = default;
virtual void release() = 0;
virtual void nextLine() = 0;
virtual const char* getToken() = 0;
class TokenWriter
{
public:
+virtual ~TokenWriter() = default;
virtual void release() = 0;
virtual void nextLine() = 0;
virtual void writeToken( const char* token ) = 0;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "iselection.h"
#include <cstddef>
#include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
#include "signal/signalfwd.h"
class Renderer;
namespace scene
{
class Instance;
-};
+}
class InstanceSelectionObserver
{
class Matrix4;
typedef Vector4 Quaternion;
-typedef Callback1<const Selectable&> SelectionChangeCallback;
+typedef Callback<void(const Selectable&)> SelectionChangeCallback;
typedef SignalHandler1<const Selectable&> SelectionChangeHandler;
class SelectionSystem
{
public:
+virtual ~SelectionSystem() = default;
INTEGER_CONSTANT( Version, 1 );
STRING_CONSTANT( Name, "selection" );
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ishaders.h"
#define INCLUDED_ISHADERS_H
#include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
enum
{
virtual float alphaTest() const = 0;
};
-typedef Callback1<const ShaderLayer&> ShaderLayerCallback;
-
+typedef Callback<void(const ShaderLayer&)> ShaderLayerCallback;
class IShader
{
};
typedef struct _GSList GSList;
-typedef Callback1<const char*> ShaderNameCallback;
+typedef Callback<void(const char*)> ShaderNameCallback;
class ModuleObserver;
virtual IShader* dereferenceActiveShadersIterator() = 0;
virtual void incrementActiveShadersIterator() = 0;
-virtual void setActiveShadersChangedNotify( const Callback& notify ) = 0;
+virtual void setActiveShadersChangedNotify( const Callback<void()>& notify ) = 0;
virtual void attach( ModuleObserver& observer ) = 0;
virtual void detach( ModuleObserver& observer ) = 0;
return GlobalShadersModule::getTable();
}
-
#define QERApp_Shader_ForName GlobalShaderSystem().getShaderForName
#define QERApp_ActiveShaders_IteratorBegin GlobalShaderSystem().beginActiveShadersIterator
#define QERApp_ActiveShaders_IteratorAtEnd GlobalShaderSystem().endActiveShadersIterator
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "itexdef.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "itextstream.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "itextures.h"
class TexturesCache
{
public:
+virtual ~TexturesCache() = default;
INTEGER_CONSTANT( Version, 1 );
STRING_CONSTANT( Name, "textures" );
virtual LoadImageCallback defaultLoader() const = 0;
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "itoolbar.h"
eSpace,
eButton,
eToggleButton,
- eRadioButton,
};
virtual const char* getImage() const = 0;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "iundo.h"
#include <cstddef>
#include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
class UndoMemento
{
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "mapfile.h"
#include <limits>
#include "iscenegraph.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
const std::size_t MAPFILE_MAX_CHANGES = std::numeric_limits<std::size_t>::max();
virtual void save() = 0;
virtual bool saved() const = 0;
virtual void changed() = 0;
-virtual void setChangedCallback( const Callback& changed ) = 0;
+virtual void setChangedCallback( const Callback<void()>& changed ) = 0;
virtual std::size_t changes() const = 0;
};
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "modelskin.h"
#define INCLUDED_MODELSKIN_H
#include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
class SkinRemap
{
}
};
-typedef Callback1<SkinRemap> SkinRemapCallback;
+typedef Callback<void(SkinRemap)> SkinRemapCallback;
class ModuleObserver;
class ModelSkin
{
public:
+virtual ~ModelSkin() = default;
STRING_CONSTANT( Name, "ModelSkin" );
/// \brief Attach an \p observer whose realise() and unrealise() methods will be called when the skin is loaded or unloaded.
virtual void attach( ModuleObserver& observer ) = 0;
class ModelSkinCache
{
public:
+virtual ~ModelSkinCache() = default;
INTEGER_CONSTANT( Version, 1 );
STRING_CONSTANT( Name, "modelskin" );
/// \brief Increments the reference count of and returns a reference to the skin uniquely identified by 'name'.
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "moduleobserver.h"
class ModuleObserver
{
public:
+virtual ~ModuleObserver() = default;
virtual void unrealise() = 0;
virtual void realise() = 0;
};
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "modulesystem.h"
#if !defined( INCLUDED_MODULESYSTEM_H )
#define INCLUDED_MODULESYSTEM_H
+#include "globaldefs.h"
#include "generic/static.h"
#include "debugging/debugging.h"
-#if defined( WIN32 )
-#ifdef MINGW32
-#define RADIANT_DLLEXPORT __declspec( dllexport )
-#define RADIANT_DLLIMPORT __declspec( dllimport )
+#if GDEF_OS_WINDOWS
+#define RADIANT_DLLEXPORT __declspec(dllexport)
+#define RADIANT_DLLIMPORT __declspec(dllimport)
#else
-#define RADIANT_DLLEXPORT __stdcall
-#define RADIANT_DLLIMPORT __stdcall
-#endif
-#else
-#define RADIANT_DLLEXPORT
+#define RADIANT_DLLEXPORT __attribute__((visibility("default")))
#define RADIANT_DLLIMPORT
#endif
}
}
Type* getTable(){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( m_table != 0, "ModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" );
#endif
return m_table;
}
Type* getTable(){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( m_table != 0, "SingletonModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" );
#endif
return m_table;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "nameable.h"
#define INCLUDED_NAMEABLE_H
#include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
-typedef Callback1<const char*> NameCallback;
+typedef Callback<void(const char*)> NameCallback;
class Nameable
{
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "namespace.h"
#define INCLUDED_NAMESPACE_H
#include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
-typedef Callback1<const char*> NameCallback;
-typedef Callback1<const NameCallback&> NameCallbackCallback;
+typedef Callback<void(const char*)> NameCallback;
+typedef Callback<void(const NameCallback&)> NameCallbackCallback;
class Namespace
{
m_string = value;
m_observer.onChanged();
}
-typedef MemberCaller1<StringPreference, const char*, &StringPreference::importString> ImportStringCaller;
-void exportString( StringImportCallback& importer ){
+typedef MemberCaller<StringPreference, void(const char*), &StringPreference::importString> ImportStringCaller;
+void exportString( Callback<void(const char *)>& importer ){
importer( m_string.c_str() );
}
-typedef MemberCaller1<StringPreference, StringImportCallback&, &StringPreference::exportString> ExportStringCaller;
+typedef MemberCaller<StringPreference, void(Callback<void(const char *)>&), &StringPreference::exportString> ExportStringCaller;
};
-inline void int_export( int i, StringImportCallback& importer ){
+inline void int_export( int i, Callback<void(const char *)>& importer ){
char buffer[16];
sprintf( buffer, "%d", i );
importer( buffer );
m_int = int_import( value );
m_observer.onChanged();
}
-typedef MemberCaller1<IntPreference, const char*, &IntPreference::importString> ImportStringCaller;
-void exportString( StringImportCallback& importer ){
+typedef MemberCaller<IntPreference, void(const char*), &IntPreference::importString> ImportStringCaller;
+void exportString( Callback<void(const char *)>& importer ){
int_export( m_int, importer );
}
-typedef MemberCaller1<IntPreference, StringImportCallback&, &IntPreference::exportString> ExportStringCaller;
+typedef MemberCaller<IntPreference, void(Callback<void(const char *)>&), &IntPreference::exportString> ExportStringCaller;
};
class IntPreferenceImporter
#define INCLUDED_PREFERENCESYSTEM_H
#include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
+#include "property.h"
-typedef Callback1<const char*> StringImportCallback;
-typedef Callback1<const StringImportCallback&> StringExportCallback;
-
-class PreferenceSystem
-{
+class PreferenceSystem {
public:
-INTEGER_CONSTANT( Version, 1 );
-STRING_CONSTANT( Name, "preferences" );
+ INTEGER_CONSTANT(Version, 1);
+ STRING_CONSTANT(Name, "preferences");
-virtual void registerPreference( const char* name, const StringImportCallback& importer, const StringExportCallback& exporter ) = 0;
+ virtual void registerPreference(const char *name, const Property<const char *> &cb) = 0;
};
+template<class Self>
+Property<const char *> make_property_string(Self &it) {
+ return make_property<PropertyAdaptor<Self, const char *>>(it);
+}
+
+template<class I, class Self>
+Property<const char *> make_property_string(Self &it) {
+ return make_property_chain<PropertyImpl<detail::propertyimpl_other<I>, const char *>, I>(it);
+}
+
+template<class I>
+Property<const char *> make_property_string() {
+ return make_property_chain<PropertyImpl<detail::propertyimpl_other_free<I>, const char *>, I>();
+}
+
#include "modulesystem.h"
template<typename Type>
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "qerplugin.h"
#ifndef __QERPLUGIN_H__
#define __QERPLUGIN_H__
+#include "uilib/uilib.h"
#include "generic/constant.h"
// NOTE: parent can be 0 in all functions but it's best to set them
// this API does not depend on gtk+ or glib
-typedef struct _GtkWidget GtkWidget;
enum EMessageBoxType
{
// simple Message Box, see above for the 'type' flags
-typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( GtkWidget *parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ );
+typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( ui::Window parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ );
// file and directory selection functions return null if the user hits cancel
// - 'title' is the dialog title (can be null)
// - 'path' is used to set the initial directory (can be null)
// - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples
-typedef const char* ( *PFN_QERAPP_FILEDIALOG )( GtkWidget *parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ );
+typedef const char* ( *PFN_QERAPP_FILEDIALOG )( ui::Window parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ );
// returns a gchar* string that must be g_free'd by the user
-typedef char* ( *PFN_QERAPP_DIRDIALOG )( GtkWidget *parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ );
+typedef char* ( *PFN_QERAPP_DIRDIALOG )( ui::Window parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ );
// return true if the user closed the dialog with 'Ok'
// 'color' is used to set the initial value and store the selected value
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
-typedef bool ( *PFN_QERAPP_COLORDIALOG )( GtkWidget *parent, Vector3& color,
+typedef bool ( *PFN_QERAPP_COLORDIALOG )( ui::Window parent, Vector3& color,
const char* title /* = "Choose Color"*/ );
// load a .bmp file and create a GtkImage widget from it
// NOTE: 'filename' is relative to <radiant_path>/plugins/bitmaps/
-typedef struct _GtkImage GtkImage;
-typedef GtkImage* ( *PFN_QERAPP_NEWIMAGE )( const char* filename );
+typedef ui::Image ( *PFN_QERAPP_NEWIMAGE )( const char* filename );
// ========================================
const char* ( *getSettingsPath )( );
const char* ( *getMapsPath )( );
+ const char* ( *getGameFile )( );
const char* ( *getGameName )( );
const char* ( *getGameMode )( );
const char* ( *getGameDescriptionKeyValue )(const char* key);
const char* ( *getRequiredGameDescriptionKeyValue )(const char* key);
- void ( *attachGameToolsPathObserver )( ModuleObserver& observer );
- void ( *detachGameToolsPathObserver )( ModuleObserver& observer );
- void ( *attachEnginePathObserver )( ModuleObserver& observer );
- void ( *detachEnginePathObserver )( ModuleObserver& observer );
- void ( *attachGameNameObserver )( ModuleObserver& observer );
- void ( *detachGameNameObserver )( ModuleObserver& observer );
- void ( *attachGameModeObserver )( ModuleObserver& observer );
- void ( *detachGameModeObserver )( ModuleObserver& observer );
-
SignalHandlerId ( *XYWindowDestroyed_connect )( const SignalHandler& handler );
void ( *XYWindowDestroyed_disconnect )( SignalHandlerId id );
MouseEventHandlerId ( *XYWindowMouseDown_connect )( const MouseEventHandler& handler );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "renderable.h"
virtual void PushState() = 0;
virtual void PopState() = 0;
virtual void SetState( Shader* state, EStyle mode ) = 0;
-virtual const EStyle getStyle() const = 0;
+virtual EStyle getStyle() const = 0;
virtual void Highlight( EHighlightMode mode, bool bEnable = true ) = 0;
virtual void setLights( const LightList& lights ){
}
class Renderable
{
public:
+virtual ~Renderable() = default;
STRING_CONSTANT( Name, "Renderable" );
virtual void renderSolid( Renderer& renderer, const VolumeTest& volume ) const = 0;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "selectable.h"
#include "generic/vector.h"
#include "scenelib.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
class SelectionIntersection
{
class Plane3;
-typedef Callback1<const Plane3&> PlaneCallback;
+typedef Callback<void(const Plane3&)> PlaneCallback;
class SelectedPlanes
{
#ifndef RADIANT_MINOR_VERSION
#error no RADIANT_MINOR_VERSION defined
#endif
+#ifndef RADIANT_PATCH_VERSION
+#error no RADIANT_PATCH_VERSION defined
+#endif
#if !defined ( INCLUDED_WARNINGS_H )
#define INCLUDED_WARNINGS_H
-#if _MSC_VER > 1000 && defined( WIN32 )
+#include "globaldefs.h"
+
+#if GDEF_COMPILER_MSVC && _MSC_VER > 1000
#pragma warning(disable:4355) // 'this' : used in base member initializer list
#pragma warning(disable:4503) // '[symbol]' : decorated name length exceeded, name was truncated
#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "windowobserver.h"
class WindowObserver
{
public:
+virtual ~WindowObserver() = default;
virtual void release() = 0;
virtual void onSizeChanged( int width, int height ) = 0;
virtual void onMouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers ) = 0;
+++ /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
-
-if [ -d "$pack/tools" ]; then
- pack="$pack/tools"
-fi
-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}
-
-dest=$1
-
-case "$DOWNLOAD_GAMEPACKS" in
- yes)
- LICENSEFILTER=GPL BATCH=1 $SH download-gamepacks.sh
- ;;
- all)
- BATCH=1 $SH download-gamepacks.sh
- ;;
- *)
- ;;
-esac
-
-set -e
-for GAME in games/*; do
- if [ "$GAME" = "games/*" ]; then
- $ECHO "Game packs not found, please run"
- $ECHO " ./download-gamepacks.sh"
- $ECHO "and then try again!"
- else
- $SH install-gamepack.sh "$GAME" "$dest"
- fi
-done
--- /dev/null
+add_subdirectory(cmdlib)
+add_subdirectory(container)
+if (BUILD_CRUNCH)
+ add_subdirectory(crnrgba)
+endif ()
+add_subdirectory(ddslib)
+add_subdirectory(debugging)
+add_subdirectory(etclib)
+add_subdirectory(filematch)
+add_subdirectory(generic)
+if (BUILD_RADIANT)
+ add_subdirectory(gtkutil)
+endif ()
+add_subdirectory(l_net)
+add_subdirectory(math)
+add_subdirectory(mathlib)
+add_subdirectory(memory)
+add_subdirectory(modulesystem)
+add_subdirectory(os)
+add_subdirectory(picomodel)
+add_subdirectory(profile)
+add_subdirectory(script)
+add_subdirectory(signal)
+add_subdirectory(splines)
+add_subdirectory(stream)
+add_subdirectory(string)
+add_subdirectory(uilib)
+add_subdirectory(xml)
+
+add_library(libs
+ _.cpp
+ archivelib.h
+ bytebool.h
+ bytestreamutils.h
+ character.h
+ convert.h
+ dragplanes.h
+ eclasslib.h
+ entitylib.h
+ entityxml.h
+ fs_filesystem.h
+ fs_path.h
+ globaldefs.h
+ imagelib.h
+ property.h
+ instancelib.h
+ maplib.h
+ moduleobservers.h
+ pivot.h
+ render.h
+ scenelib.h
+ selectionlib.h
+ shaderlib.h
+ str.h
+ stringio.h
+ texturelib.h
+ transformlib.h
+ traverselib.h
+ typesystem.h
+ undolib.h
+ uniquenames.h
+ versionlib.h
+ )
+
+find_package(GLIB REQUIRED)
+target_include_directories(libs PRIVATE ${GLIB_INCLUDE_DIRS})
+target_link_libraries(libs PRIVATE ${GLIB_LIBRARIES})
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "archivelib.h"
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "bytebool.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "bytestreamutils.h"
#if !defined( INCLUDED_BYTESTREAMUTILS_H )
#define INCLUDED_BYTESTREAMUTILS_H
-#if defined( __GNUC__ )
+#include "globaldefs.h"
+
+#if GDEF_COMPILER_GNU
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
template<typename InputStreamType, typename Type>
inline void istream_read_little_endian( InputStreamType& istream, Type& value ){
- istream.read( reinterpret_cast<typename InputStreamType::byte_type*>( &value ), sizeof( Type ) );
-#if defined( __BIG_ENDIAN__ )
- std::reverse( reinterpret_cast<typename InputStreamType::byte_type*>( &value ), reinterpret_cast<typename InputStreamType::byte_type*>( &value ) + sizeof( Type ) );
-#endif
+ istream.read(reinterpret_cast<typename InputStreamType::byte_type *>( &value ), sizeof(Type));
+ if (GDEF_ARCH_ENDIAN_BIG) {
+ std::reverse(reinterpret_cast<typename InputStreamType::byte_type *>( &value ),
+ reinterpret_cast<typename InputStreamType::byte_type *>( &value ) + sizeof(Type));
+ }
}
template<typename InputStreamType, typename Type>
inline void istream_read_big_endian( InputStreamType& istream, Type& value ){
- istream.read( reinterpret_cast<typename InputStreamType::byte_type*>( &value ), sizeof( Type ) );
-#if !defined( __BIG_ENDIAN__ )
- std::reverse( reinterpret_cast<typename InputStreamType::byte_type*>( &value ), reinterpret_cast<typename InputStreamType::byte_type*>( &value ) + sizeof( Type ) );
-#endif
+ istream.read(reinterpret_cast<typename InputStreamType::byte_type *>( &value ), sizeof(Type));
+ if (!GDEF_ARCH_ENDIAN_BIG) {
+ std::reverse(reinterpret_cast<typename InputStreamType::byte_type *>( &value ),
+ reinterpret_cast<typename InputStreamType::byte_type *>( &value ) + sizeof(Type));
+ }
}
template<typename InputStreamType>
return value;
}
+template<typename InputStreamType>
+inline int16_t istream_read_int16_be( InputStreamType& istream ){
+ int16_t value;
+ istream_read_big_endian( istream, value );
+ return value;
+}
+
template<typename InputStreamType>
inline uint16_t istream_read_uint16_le( InputStreamType& istream ){
uint16_t value;
return value;
}
+template<typename InputStreamType>
+inline uint16_t istream_read_uint16_be( InputStreamType& istream ){
+ uint16_t value;
+ istream_read_big_endian( istream, value );
+ return value;
+}
+
template<typename InputStreamType>
inline int32_t istream_read_int32_le( InputStreamType& istream ){
int32_t value;
return value;
}
+template<typename InputStreamType>
+inline int32_t istream_read_int32_be( InputStreamType& istream ){
+ int32_t value;
+ istream_read_big_endian( istream, value );
+ return value;
+}
+
template<typename InputStreamType>
inline uint32_t istream_read_uint32_le( InputStreamType& istream ){
uint32_t value;
return value;
}
+template<typename InputStreamType>
+inline uint32_t istream_read_uint32_be( InputStreamType& istream ){
+ uint32_t value;
+ istream_read_big_endian( istream, value );
+ return value;
+}
+
template<typename InputStreamType>
inline float istream_read_float32_le( InputStreamType& istream ){
float value;
return value;
}
+template<typename InputStreamType>
+inline float istream_read_float32_be( InputStreamType& istream ){
+ float value;
+ istream_read_big_endian( istream, value );
+ return value;
+}
+
template<typename InputStreamType>
inline typename InputStreamType::byte_type istream_read_byte( InputStreamType& istream ){
typename InputStreamType::byte_type b;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "character.h"
#ifndef __CMDLIB__
#define __CMDLIB__
+#include "globaldefs.h"
#include <time.h>
// Q_mkdir
// returns true if succeeded in creating directory
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <direct.h>
inline bool Q_mkdir( const char* name ){
return _mkdir( name ) != -1;
+++ /dev/null
-*.dsp -m 'COPY' -k 'b'
-*.dsw -m 'COPY' -k 'b'
-*.scc -m 'COPY' -k 'b'
--- /dev/null
+add_library(cmdlib
+ cmdlib.cpp ../cmdlib.h
+ )
//
#include "cmdlib.h"
+#include "globaldefs.h"
#include <string.h>
#include <stdio.h>
#include "container/array.h"
-#if defined ( POSIX )
+#if GDEF_OS_POSIX
#include <unistd.h>
#include <sys/types.h>
char fullcmd[2048];
char *pCmd;
pid_t pid;
-#ifdef _DEBUG
+#if GDEF_DEBUG
printf( "Q_Exec damnit\n" );
#endif
switch ( ( pid = fork() ) )
pCmd = fullcmd;
while ( *pCmd == ' ' )
pCmd++;
-#ifdef _DEBUG
+#if GDEF_DEBUG
printf( "Running system...\n" );
printf( "Command: %s\n", pCmd );
#endif
system( pCmd );
-#ifdef _DEBUG
+#if GDEF_DEBUG
printf( "system() returned\n" );
#endif
_exit( 0 );
return true;
}
-#elif defined( WIN32 )
+#elif GDEF_OS_WINDOWS
#include <windows.h>
--- /dev/null
+add_library(container
+ array.cpp array.h
+ cache.h
+ container.h
+ hashfunc.h
+ hashtable.cpp hashtable.h
+ stack.h
+ )
#if !defined( INCLUDED_CONTAINER_ARRAY_H )
#define INCLUDED_CONTAINER_ARRAY_H
+#include "globaldefs.h"
#include <cstddef>
#include <algorithm>
}
value_type& operator[]( std::size_t index ){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
#endif
return m_data[index];
}
const value_type& operator[]( std::size_t index ) const {
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
#endif
return m_data[index];
self.swap( other );
}
}
-
#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "cache.h"
template<typename Key, typename Cached, typename Hasher, typename KeyEqual = std::equal_to<Key>, typename CreationPolicy = DefaultCreationPolicy<Cached, Key> >
class HashedCache : public CreationPolicy
{
-typedef SharedValue<Cached> Element;
-typedef HashTable<Key, Element, Hasher, KeyEqual> map_type;
+ typedef SharedValue<Cached> Element;
+ typedef HashTable<Key, Element, Hasher, KeyEqual> map_type;
-map_type m_map;
+ map_type m_map;
public:
-explicit HashedCache( const CreationPolicy& creation = CreationPolicy() )
- : CreationPolicy( creation ), m_map( 256 ){
-}
-~HashedCache(){
- ASSERT_MESSAGE( empty(), "HashedCache::~HashedCache: not empty" );
-}
+ explicit HashedCache( const CreationPolicy& creation = CreationPolicy() )
+ : CreationPolicy( creation ), m_map( 256 ){
+ }
+ ~HashedCache(){
+ ASSERT_MESSAGE( empty(), "HashedCache::~HashedCache: not empty" );
+ }
-typedef typename map_type::iterator iterator;
-typedef typename map_type::value_type value_type;
+ typedef typename map_type::iterator iterator;
+ typedef typename map_type::value_type value_type;
-iterator begin(){
- return m_map.begin();
-}
-iterator end(){
- return m_map.end();
-}
+ iterator begin(){
+ return m_map.begin();
+ }
+ iterator end(){
+ return m_map.end();
+ }
-bool empty() const {
- return m_map.empty();
-}
+ bool empty() const {
+ return m_map.empty();
+ }
-iterator find( const Key& key ){
- return m_map.find( key );
-}
+ iterator find( const Key& key ){
+ return m_map.find( key );
+ }
-void capture( iterator i ){
+ void capture( iterator i ){
( *i ).value.increment();
-}
-void release( iterator i ){
+ }
+ void release( iterator i ){
if ( ( *i ).value.decrement() == 0 ) {
CreationPolicy::destroy( ( *i ).value.get() );
- m_map.erase( i );
+ m_map.erase( i );
+ }
}
-}
#if 1
-Element& capture( const Key& key ){
+ Element& capture( const Key& key ){
#if 0
Element& elem = m_map[key];
- if ( elem.increment() == 1 ) {
- elem.set( CreationPolicy::construct( key ) );
- }
+ if ( elem.increment() == 1 ) {
+ elem.set( CreationPolicy::construct( key ) );
+ }
return elem;
#else
iterator i = m_map.insert( key, Element() );
if ( ( *i ).value.increment() == 1 ) {
( *i ).value.set( CreationPolicy::construct( ( *i ).key ) );
- }
+ }
return ( *i ).value;
#endif
-}
+ }
#else
value_type& capture( const Key& key ){
- iterator i = m_map.find( key );
- if ( i == m_map.end() ) {
- i = m_map.insert( key, Element() );
+ iterator i = m_map.find( key );
+ if ( i == m_map.end() ) {
+ i = m_map.insert( key, Element() );
( *i ).value.set( CreationPolicy::construct( ( *i ).key ) );
- }
+ }
( *i ).value.increment();
- return ( *i );
+ return ( *i );
}
#endif
-void release( const Key& key ){
- iterator i = m_map.find( key );
- ASSERT_MESSAGE( i != m_map.end(), "releasing a non-existent object\n" );
- release( i );
-}
+ void release( const Key& key ){
+ iterator i = m_map.find( key );
+ ASSERT_MESSAGE( i != m_map.end(), "releasing a non-existent object\n" );
+ release( i );
+ }
-void clear(){
- m_map.clear();
-}
+ void clear(){
+ m_map.clear();
+ }
};
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "container.h"
#if !defined( INCLUDED_CONTAINER_CONTAINER_H )
#define INCLUDED_CONTAINER_CONTAINER_H
+#include <algorithm>
#include <list>
#include <set>
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "hashfunc.h"
c += length;
switch ( len ) /* all the case statements fall through */
{
- case 11: c += ( ( ub4 ) UB1Traits::as_ub1( k[10] ) << 24 );
- case 10: c += ( ( ub4 ) UB1Traits::as_ub1( k[9] ) << 16 );
- case 9: c += ( ( ub4 ) UB1Traits::as_ub1( k[8] ) << 8 );
+ case 11: c += ( ( ub4 ) UB1Traits::as_ub1( k[10] ) << 24 ); __attribute((fallthrough));
+ case 10: c += ( ( ub4 ) UB1Traits::as_ub1( k[9] ) << 16 ); __attribute((fallthrough));
+ case 9: c += ( ( ub4 ) UB1Traits::as_ub1( k[8] ) << 8 ); __attribute((fallthrough));
/* the first byte of c is reserved for the length */
- case 8: b += ( ( ub4 ) UB1Traits::as_ub1( k[7] ) << 24 );
- case 7: b += ( ( ub4 ) UB1Traits::as_ub1( k[6] ) << 16 );
- case 6: b += ( ( ub4 ) UB1Traits::as_ub1( k[5] ) << 8 );
- case 5: b += UB1Traits::as_ub1( k[4] );
- case 4: a += ( ( ub4 ) UB1Traits::as_ub1( k[3] ) << 24 );
- case 3: a += ( ( ub4 ) UB1Traits::as_ub1( k[2] ) << 16 );
- case 2: a += ( ( ub4 ) UB1Traits::as_ub1( k[1] ) << 8 );
+ case 8: b += ( ( ub4 ) UB1Traits::as_ub1( k[7] ) << 24 ); __attribute((fallthrough));
+ case 7: b += ( ( ub4 ) UB1Traits::as_ub1( k[6] ) << 16 ); __attribute((fallthrough));
+ case 6: b += ( ( ub4 ) UB1Traits::as_ub1( k[5] ) << 8 ); __attribute((fallthrough));
+ case 5: b += UB1Traits::as_ub1( k[4] ); __attribute((fallthrough));
+ case 4: a += ( ( ub4 ) UB1Traits::as_ub1( k[3] ) << 24 ); __attribute((fallthrough));
+ case 3: a += ( ( ub4 ) UB1Traits::as_ub1( k[2] ) << 16 ); __attribute((fallthrough));
+ case 2: a += ( ( ub4 ) UB1Traits::as_ub1( k[1] ) << 8 ); __attribute((fallthrough));
case 1: a += UB1Traits::as_ub1( k[0] );
/* case 0: nothing left to add */
}
*/
#include "hashtable.h"
+#include "globaldefs.h"
-#if defined( _DEBUG ) || defined( DOXYGEN )
+#if GDEF_DEBUG || defined( DOXYGEN )
#include "hashfunc.h"
#include <cstddef>
#include <algorithm>
#include <functional>
+#include <memory>
#include "debugging/debugging.h"
-
namespace HashTableDetail
{
inline std::size_t next_power_of_two( std::size_t size ){
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "stack.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "convert.h"
--- /dev/null
+add_library(crnrgba
+ crn_rgba.h
+ crn_rgba.cpp
+ ../crunch/inc/crn_decomp.h
+ ../crunch/inc/crnlib.h
+ )
+
+set_target_properties(crnrgba PROPERTIES LINKER_LANGUAGE CXX)
+target_link_libraries(crnrgba PRIVATE ddslib)
+target_compile_options(crnrgba PRIVATE -fexceptions)
--- /dev/null
+/*
+ Copyright (C) 2018, Unvanquished Developers
+ All Rights Reserved.
+
+ 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 "crn_rgba.h"
+
+#include <string.h>
+
+#include <memory>
+
+
+#include "ddslib.h"
+#include "../crunch/inc/crn_decomp.h"
+
+int LittleLong(int l) {
+#if GDEF_ARCH_ENDIAN_BIG
+ std::reverse(reinterpret_cast<unsigned char *>( &l ), reinterpret_cast<unsigned char *>( &l ) + sizeof(int));
+#endif
+ return l;
+}
+
+// Sets `x` and `y` to the width and height of the input crn image. Returns false if there is an
+// error reading the image.
+extern "C" int GetCRNImageSize(const void *buffer, int length, int *x, int *y) {
+ crnd::crn_texture_info ti;
+ if(!crnd::crnd_get_texture_info(buffer, length, &ti) ||
+ // Ensure we are not trying to load a cubemap (which has 6 faces...)
+ (ti.m_faces != 1) ) {
+ return false;
+ }
+ if (x) *x = ti.m_width;
+ if (y) *y = ti.m_height;
+ return true;
+}
+
+// Converts a .crn file to RGBA. Stores the pixels in outBuf. Use GetCRNImageSize to get the image
+// size to determine how big outBuf should be. The function will return false if the image does not
+// fit inside outBuf.
+extern "C" int ConvertCRNtoRGBA(const void *buffer, int length, int outBufLen, void* outBuf) {
+ crnd::crn_texture_info ti;
+ if(!crnd::crnd_get_texture_info(buffer, length, &ti) ||
+ // Ensure we are not trying to load a cubemap (which has 6 faces...)
+ (ti.m_faces != 1) ) {
+ return false;
+ }
+
+ // Sanity check mipmaps.
+ if (ti.m_levels <= 0) {
+ return false;
+ }
+
+ // The largest layer is always layer 0, so load that one.
+ crnd::crn_level_info li;
+ if (!crnd::crnd_get_level_info( buffer, length, 0, &li)) {
+ return false;
+ }
+
+ // Ensure we can fit the final image in outBuf.
+ if (outBufLen < ti.m_width * ti.m_height) {
+ return false;
+ }
+
+ crnd::crnd_unpack_context ctx = crnd::crnd_unpack_begin(buffer, length);
+ if (!ctx) {
+ return false;
+ }
+
+ // Since the texture is compressed and the crunch library doesn't provide the code to convert the code
+ // to RGBAImage, we'll need to convert it to DDS first and use the DDS decompression routines to get
+ // the raw pixels (theoretically, we could refactor the DDS functions to be generalized, but for now,
+ // this seems much more maintainable...). This code is cribbed from the example code in
+ // the crunch repo: https://github.com/DaemonEngine/crunch/blob/master/example2/example2.cpp
+ // Compute the face's width, height, number of DXT blocks per row/col, etc.
+ // This is not a proper DDS conversion; it's only enough to get the ddslib decompressor to be happy.
+ const crn_uint32 blocks_x = std::max(1U, (ti.m_width + 3) >> 2);
+ const crn_uint32 blocks_y = std::max(1U, (ti.m_height + 3) >> 2);
+ const crn_uint32 row_pitch = blocks_x * crnd::crnd_get_bytes_per_dxt_block(ti.m_format);
+ const crn_uint32 total_face_size = row_pitch * blocks_y;
+ const crn_uint32 ddsSize = sizeof(ddsBuffer_t) + total_face_size;
+ std::unique_ptr<char> ddsBuffer(new char[ddsSize]);
+ memset(ddsBuffer.get(), 0, ddsSize);
+
+
+ ddsBuffer_t* dds = reinterpret_cast<ddsBuffer_t*>(ddsBuffer.get());
+
+ memcpy(&dds->magic, "DDS ", sizeof(dds->magic));
+ dds->size = LittleLong(124); // Size of the DDS header.
+ dds->height = LittleLong(ti.m_height);
+ dds->width = LittleLong(ti.m_width);
+ dds->mipMapCount = LittleLong(1);
+
+ dds->pixelFormat.size = LittleLong(sizeof(ddsPixelFormat_t));
+
+ crn_format fundamental_fmt = crnd::crnd_get_fundamental_dxt_format(ti.m_format);
+ dds->pixelFormat.fourCC = LittleLong(crnd::crnd_crn_format_to_fourcc(fundamental_fmt));
+ if (fundamental_fmt != ti.m_format) {
+ // It's a funky swizzled DXTn format - write its FOURCC to RGBBitCount.
+ dds->pixelFormat.rgbBitCount = LittleLong(crnd::crnd_crn_format_to_fourcc(ti.m_format));
+ }
+ char* imageArray[1];
+ imageArray[0] = reinterpret_cast<char*>(&dds->data);
+ if (!crnd::crnd_unpack_level(ctx, reinterpret_cast<void**>(&imageArray), total_face_size, row_pitch, 0)) {
+ return false;
+ }
+
+ if (DDSDecompress(dds, reinterpret_cast<unsigned char*>(outBuf)) == -1) {
+ return false;
+ }
+ return true;
+}
--- /dev/null
+/*
+ Copyright (C) 2018, Unvanquished Developers
+ All Rights Reserved.
+
+ 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
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+// Sets `x` and `y` to the width and height of the input crn image. Returns false if there is an
+// error reading the image.
+int GetCRNImageSize(const void *buffer, int length, int *x, int *y);
+
+// Converts a .crn file to RGBA. Stores the pixels in outBuf. Use GetCRNImageSize to get the image
+// size to determine how big outBuf should be. The function will return false if the image does not
+// fit inside outBuf.
+int ConvertCRNtoRGBA(const void *buffer, int length, int outBufLen, void* outBuf);
+#ifdef __cplusplus
+} // extern "C"
+#endif // __cplusplus
--- /dev/null
+Subproject commit 85bab3d798a54abe32a22d5275e625ec06df6917
--- /dev/null
+add_library(ddslib
+ ddslib.c ../ddslib.h
+ )
----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define DDSLIB_C
-
-
-
/* dependencies */
#include "ddslib.h"
-
-
+#include "globaldefs.h"
/* endian tomfoolery */
typedef union
}
floatSwapUnion;
-
-#ifndef __BIG_ENDIAN__
- #ifdef _SGI_SOURCE
- #define __BIG_ENDIAN__
- #endif
-#endif
-
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
int DDSBigLong( int src ) { return src; }
short DDSBigShort( short src ) { return src; }
--- /dev/null
+add_library(debugging
+ debugging.cpp debugging.h
+ )
/// \file
/// \brief Debugging macros for fatal error/assert messages.
+#include "globaldefs.h"
#include "stream/textstream.h"
#include "warnings.h"
#include "generic/static.h"
-#if defined( _MSC_VER ) && ( defined( _M_IX86 ) || defined( _M_AMD64 ) )
+#if GDEF_COMPILER_MSVC && ( defined( _M_IX86 ) || defined( _M_AMD64 ) )
#define DEBUGGER_BREAKPOINT() __asm { int 3 }
-#elif ( defined ( __i386__ ) || defined ( __x86_64__ ) ) && defined ( __GNUC__ ) && __GNUC__ >= 2
+#elif GDEF_COMPILER_GNU && __GNUC__ >= 2 && ( defined ( __i386__ ) || defined ( __x86_64__ ) )
#define DEBUGGER_BREAKPOINT() __asm__ __volatile__ ( "int $03" )
#else
#include <signal.h>
#define DEBUGGER_BREAKPOINT() raise( SIGTRAP );
#endif
-#define STR( x ) # x
+#define STR( x ) #x
#define STR2( x ) STR( x )
#define FILE_LINE __FILE__ ":" STR2( __LINE__ )
-#if defined( _DEBUG ) || 1
#define DEBUG_ASSERTS
-#endif
class DebugMessageHandler
{
return globalErrorStream();
}
virtual bool handleMessage(){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
return false; // send debug-break
#else
return true;
globalDebugMessageHandler().getOutputStream() << FILE_LINE "\nruntime error: " << message << "\n"; \
if ( !globalDebugMessageHandler().handleMessage() ) { DEBUGGER_BREAKPOINT(); }} while ( 0 )
-#define ASSERT_NOTNULL( ptr ) ASSERT_MESSAGE( ptr != 0, "pointer \"" # ptr "\" is null" )
+#define ASSERT_NOTNULL( ptr ) ASSERT_MESSAGE( ptr != 0, "pointer \"" #ptr "\" is null" )
+#define ASSERT_TRUE( flag ) ASSERT_MESSAGE( !!(flag) == true, "condition \"" #flag "\" is false" )
#else
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "dragplanes.h"
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "eclasslib.h"
class ListAttributeType
{
-typedef std::pair<CopiedString, CopiedString> ListItem;
-typedef std::vector<ListItem> ListItems;
+using ListItem = std::pair<CopiedString, CopiedString>;
+using ListItems = std::vector<ListItem>;
ListItems m_items;
public:
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "entitylib.h"
notify();
}
-typedef MemberCaller1<KeyValue, const CopiedString&, &KeyValue::importState> UndoImportCaller;
+typedef MemberCaller<KeyValue, void(const CopiedString&), &KeyValue::importState> UndoImportCaller;
};
/// \brief An unsorted list of key/value pairs.
m_entityKeyValueChanged();
}
- typedef MemberCaller1<EntityKeyValues, const KeyValues&, &EntityKeyValues::importState> UndoImportCaller;
+ typedef MemberCaller<EntityKeyValues, void(const KeyValues&), &EntityKeyValues::importState> UndoImportCaller;
void attach( Observer& observer ){
ASSERT_MESSAGE( !m_observerMutex, "observer cannot be attached during iteration" );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "entityxml.h"
--- /dev/null
+// Copyright 2009 Google Inc.
+//
+// Based on the code from Android ETC1Util.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "etclib.h"
+
+static void ETC_DecodeETC1SubBlock( byte *out, qboolean outRGBA, int r, int g, int b, int tableIndex, unsigned int low, qboolean second, qboolean flipped ){
+ int baseX = 0, baseY = 0;
+ const int modifierTable[] = {
+ 2, 8, -2, -8,
+ 5, 17, -5, -17,
+ 9, 29, -9, -29,
+ 13, 42, -13, -42,
+ 18, 60, -18, -60,
+ 24, 80, -24, -80,
+ 33, 106, -33, -106,
+ 47, 183, -47, -183
+ };
+ const int *table = modifierTable + tableIndex * 4;
+ int i;
+
+ if ( second ) {
+ if ( flipped ) {
+ baseY = 2;
+ }
+ else {
+ baseX = 2;
+ }
+ }
+
+ for ( i = 0; i < 8; i++ )
+ {
+ int x, y, k, delta;
+ int qr, qg, qb;
+ byte *q;
+
+ if ( flipped ) {
+ x = baseX + ( i >> 1 );
+ y = baseY + ( i & 1 );
+ }
+ else {
+ x = baseX + ( i >> 2 );
+ y = baseY + ( i & 3 );
+ }
+ k = y + ( x * 4 );
+ delta = table[( ( low >> k ) & 1 ) | ( ( low >> ( k + 15 ) ) & 2 )];
+
+ qr = r + delta;
+ qg = g + delta;
+ qb = b + delta;
+ if ( outRGBA ) {
+ q = out + 4 * ( x + 4 * y );
+ }
+ else {
+ q = out + 3 * ( x + 4 * y );
+ }
+ *( q++ ) = ( ( qr > 0 ) ? ( ( qr < 255 ) ? qr : 255 ) : 0 );
+ *( q++ ) = ( ( qg > 0 ) ? ( ( qg < 255 ) ? qg : 255 ) : 0 );
+ *( q++ ) = ( ( qb > 0 ) ? ( ( qb < 255 ) ? qb : 255 ) : 0 );
+ if ( outRGBA ) {
+ *( q++ ) = 255;
+ }
+ }
+}
+
+void ETC_DecodeETC1Block( const byte* in, byte* out, qboolean outRGBA ){
+ unsigned int high = ( in[0] << 24 ) | ( in[1] << 16 ) | ( in[2] << 8 ) | in[3];
+ unsigned int low = ( in[4] << 24 ) | ( in[5] << 16 ) | ( in[6] << 8 ) | in[7];
+ int r1, r2, g1, g2, b1, b2;
+ qboolean flipped = ( ( high & 1 ) != 0 );
+
+ if ( high & 2 ) {
+ int rBase, gBase, bBase;
+ const int lookup[] = { 0, 1, 2, 3, -4, -3, -2, -1 };
+
+ rBase = ( high >> 27 ) & 31;
+ r1 = ( rBase << 3 ) | ( rBase >> 2 );
+ rBase = ( rBase + ( lookup[( high >> 24 ) & 7] ) ) & 31;
+ r2 = ( rBase << 3 ) | ( rBase >> 2 );
+
+ gBase = ( high >> 19 ) & 31;
+ g1 = ( gBase << 3 ) | ( gBase >> 2 );
+ gBase = ( gBase + ( lookup[( high >> 16 ) & 7] ) ) & 31;
+ g2 = ( gBase << 3 ) | ( gBase >> 2 );
+
+ bBase = ( high >> 11 ) & 31;
+ b1 = ( bBase << 3 ) | ( bBase >> 2 );
+ bBase = ( bBase + ( lookup[( high >> 8 ) & 7] ) ) & 31;
+ b2 = ( bBase << 3 ) | ( bBase >> 2 );
+ }
+ else {
+ r1 = ( ( high >> 24 ) & 0xf0 ) | ( ( high >> 28 ) & 0xf );
+ r2 = ( ( high >> 20 ) & 0xf0 ) | ( ( high >> 24 ) & 0xf );
+ g1 = ( ( high >> 16 ) & 0xf0 ) | ( ( high >> 20 ) & 0xf );
+ g2 = ( ( high >> 12 ) & 0xf0 ) | ( ( high >> 16 ) & 0xf );
+ b1 = ( ( high >> 8 ) & 0xf0 ) | ( ( high >> 12 ) & 0xf );
+ b2 = ( ( high >> 4 ) & 0xf0 ) | ( ( high >> 8 ) & 0xf );
+ }
+
+ ETC_DecodeETC1SubBlock( out, outRGBA, r1, g1, b1, ( high >> 5 ) & 7, low, qfalse, flipped );
+ ETC_DecodeETC1SubBlock( out, outRGBA, r2, g2, b2, ( high >> 2 ) & 7, low, qtrue, flipped );
+}
--- /dev/null
+// Copyright 2009 Google Inc.
+//
+// Based on the code from Android ETC1Util.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef INCLUDED_ETCLIB_H
+#define INCLUDED_ETCLIB_H
+
+#include "bytebool.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+void ETC_DecodeETC1Block( const byte* in, byte* out, qboolean outRGBA );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+add_library(etclib
+ ../etclib.c ../etclib.h
+ )
--- /dev/null
+add_library(filematch
+ ../filematch.c ../filematch.h
+ )
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "fs_filesystem.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "fs_path.h"
--- /dev/null
+add_library(generic
+ arrayrange.h
+ bitfield.h
+ callback.cpp callback.h
+ constant.cpp constant.h
+ enumeration.h
+ functional.h
+ object.cpp object.h
+ reference.h
+ referencecounted.h
+ static.cpp static.h
+ vector.h
+ )
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "arrayrange.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "bitfield.h"
*/
#include "callback.h"
+#include "globaldefs.h"
-#if defined( _DEBUG ) || defined( DOXYGEN )
+#if GDEF_DEBUG || defined( DOXYGEN )
namespace ExampleMemberCaller
{
value = 3;
}
// a typedef to make things more readable
-typedef MemberCaller<Integer, &Integer::setValue> SetValueCaller;
+typedef MemberCaller<Integer, void(), &Integer::setValue> SetValueCaller;
};
void example(){
Integer foo = { 0 };
{
- Callback bar = ConstMemberCaller<Integer, &Integer::printValue>( foo );
+ Callback<void()> bar = ConstMemberCaller<Integer, void(), &Integer::printValue>( foo );
// invoke the callback
bar(); // foo.printValue()
{
// use the typedef to improve readability
- Callback bar = Integer::SetValueCaller( foo );
+ Callback<void()> bar = Integer::SetValueCaller( foo );
// invoke the callback
bar(); // foo.setValue()
}
// a typedef to make things more readable
-typedef ReferenceCaller<int, Int_setValue> IntSetValueCaller;
+typedef ReferenceCaller<int, void(), Int_setValue> IntSetValueCaller;
void example(){
int foo = 0;
{
- Callback bar = ConstReferenceCaller<int, Int_printValue>( foo );
+ Callback<void()> bar = ConstReferenceCaller<int, void(), Int_printValue>( foo );
// invoke the callback
bar(); // Int_printValue(foo)
{
// use the typedef to improve readability
- Callback bar = IntSetValueCaller( foo );
+ Callback<void()> bar = IntSetValueCaller( foo );
// invoke the callback
bar(); // Int_setValue(foo)
public:
void test0(){
}
-typedef Member<Test, void, &Test::test0> Test0;
-typedef MemberCaller<Test, &Test::test0> Test0Caller;
+typedef Member<Test, void(), &Test::test0> Test0;
+typedef MemberCaller<Test, void(), &Test::test0> Test0Caller;
void test0const() const {
}
-typedef ConstMember<Test, void, &Test::test0const> Test0Const;
-typedef ConstMemberCaller<Test, &Test::test0const> Test0ConstCaller;
+typedef ConstMember<Test, void(), &Test::test0const> Test0Const;
+typedef ConstMemberCaller<Test, void(), &Test::test0const> Test0ConstCaller;
void test1( A1 ){
}
-typedef Member1<Test, A1, void, &Test::test1> Test1;
-typedef MemberCaller1<Test, A1, &Test::test1> Test1Caller;
+typedef Member<Test, void(A1), &Test::test1> Test1;
+typedef MemberCaller<Test, void(A1), &Test::test1> Test1Caller;
void test1const( A1 ) const {
}
-typedef ConstMember1<Test, A1, void, &Test::test1const> Test1Const;
-typedef ConstMemberCaller1<Test, A1, &Test::test1const> Test1ConstCaller;
+typedef ConstMember<Test, void(A1), &Test::test1const> Test1Const;
+typedef ConstMemberCaller<Test, void(A1), &Test::test1const> Test1ConstCaller;
void test2( A1, A2 ){
}
-typedef Member2<Test, A1, A2, void, &Test::test2> Test2;
+typedef Member<Test, void(A1, A2), &Test::test2> Test2;
void test2const( A1, A2 ) const {
}
-typedef ConstMember2<Test, A1, A2, void, &Test::test2const> Test2Const;
+typedef ConstMember<Test, void(A1, A2), &Test::test2const> Test2Const;
void test3( A1, A2, A3 ){
}
-typedef Member3<Test, A1, A2, A3, void, &Test::test3> Test3;
+typedef Member<Test, void(A1, A2, A3), &Test::test3> Test3;
void test3const( A1, A2, A3 ) const {
}
-typedef ConstMember3<Test, A1, A2, A3, void, &Test::test3const> Test3Const;
+typedef ConstMember<Test, void(A1, A2, A3), &Test::test3const> Test3Const;
};
void test0free(){
}
-typedef FreeCaller<&test0free> Test0FreeCaller;
void test1free( A1 ){
}
-typedef FreeCaller1<A1, &test1free> Test1FreeCaller;
void test2free( A1, A2 ){
}
-typedef Function2<A1, A2, void, &test2free> Test2Free;
+typedef Function<void(A1, A2), &test2free> Test2Free;
void test3free( A1, A2, A3 ){
}
-typedef Function3<A1, A2, A3, void, &test3free> Test3Free;
+typedef Function<void(A1, A2, A3), &test3free> Test3Free;
void test0( Test& test ){
}
-typedef ReferenceCaller<Test, &test0> Test0Caller;
+typedef ReferenceCaller<Test, void(), &test0> Test0Caller;
void test0const( const Test& test ){
}
-typedef ConstReferenceCaller<Test, &test0const> Test0ConstCaller;
+typedef ConstReferenceCaller<Test, void(), &test0const> Test0ConstCaller;
void test0p( Test* test ){
}
-typedef PointerCaller<Test, &test0p> Test0PCaller;
+typedef PointerCaller<Test, void(), &test0p> Test0PCaller;
void test0constp( const Test* test ){
}
-typedef ConstPointerCaller<Test, &test0constp> Test0ConstPCaller;
+typedef ConstPointerCaller<Test, void(), &test0constp> Test0ConstPCaller;
void test1( Test& test, A1 ){
}
-typedef ReferenceCaller1<Test, A1, &test1> Test1Caller;
+typedef ReferenceCaller<Test, void(A1), &test1> Test1Caller;
void test1const( const Test& test, A1 ){
}
-typedef ConstReferenceCaller1<Test, A1, &test1const> Test1ConstCaller;
+typedef ConstReferenceCaller<Test, void(A1), &test1const> Test1ConstCaller;
void test1p( Test* test, A1 ){
}
-typedef PointerCaller1<Test, A1, &test1p> Test1PCaller;
+typedef PointerCaller<Test, void(A1), &test1p> Test1PCaller;
void test1constp( const Test* test, A1 ){
}
-typedef ConstPointerCaller1<Test, A1, &test1constp> Test1ConstPCaller;
+typedef ConstPointerCaller<Test, void(A1), &test1constp> Test1ConstPCaller;
void test2( Test& test, A1, A2 ){
}
-typedef Function3<Test&, A1, A2, void, &test2> Test2;
+typedef Function<void(Test&, A1, A2), &test2> Test2;
void test3( Test& test, A1, A2, A3 ){
}
-typedef Function4<Test&, A1, A2, A3, void, &test3> Test3;
+typedef Function<void(Test&, A1, A2, A3), &test3> Test3;
void instantiate(){
Test test;
const Test& testconst = test;
{
- Callback a = Test0FreeCaller();
- Callback b = Test::Test0Caller( test );
- b = makeCallback0( Test::Test0(), test );
- Callback c = Test::Test0ConstCaller( testconst );
- c = makeCallback0( Test::Test0Const(), test );
- Callback d = Test0Caller( test );
- Callback e = Test0ConstCaller( testconst );
- Callback f = Test0PCaller( &test );
- Callback g = Test0ConstPCaller( &testconst );
+ Callback<void()> a = makeCallbackF(&test0free);
+ Callback<void()> b = Test::Test0Caller( test );
+ b = makeCallback( Test::Test0(), test );
+ Callback<void()> c = Test::Test0ConstCaller( testconst );
+ c = makeCallback( Test::Test0Const(), test );
+ Test0Caller{ test };
+ Test0ConstCaller{ testconst };
+ Test0PCaller{ &test };
+ Test0ConstPCaller{ &testconst };
a();
bool u = a != b;
}
{
- typedef Callback1<A1> TestCallback1;
- TestCallback1 a = Test1FreeCaller();
+ typedef Callback<void(A1)> TestCallback1;
+ TestCallback1 a = makeCallbackF(&test1free);
TestCallback1 b = Test::Test1Caller( test );
- b = makeCallback1( Test::Test1(), test );
+ b = makeCallback( Test::Test1(), test );
TestCallback1 c = Test::Test1ConstCaller( testconst );
- c = makeCallback1( Test::Test1Const(), test );
- TestCallback1 d = Test1Caller( test );
- TestCallback1 e = Test1ConstCaller( testconst );
- TestCallback1 f = Test1PCaller( &test );
- TestCallback1 g = Test1ConstPCaller( &testconst );
+ c = makeCallback( Test::Test1Const(), test );
+ Test1Caller{ test };
+ Test1ConstCaller{ testconst };
+ Test1PCaller{ &test };
+ Test1ConstPCaller{ &testconst };
a( A1() );
bool u = a != b;
}
{
- typedef Callback2<A1, A2> TestCallback2;
- TestCallback2 a = makeStatelessCallback2( Test2Free() );
- TestCallback2 b = makeCallback2( Test2(), test );
- TestCallback2 c = makeCallback2( Test::Test2(), test );
- TestCallback2 d = makeCallback2( Test::Test2Const(), test );
+ typedef Callback<void(A1, A2)> TestCallback2;
+ TestCallback2 a = makeStatelessCallback( Test2Free() );
+ TestCallback2 b = makeCallback( Test2(), test );
+ makeCallback( Test::Test2(), test );
+ makeCallback( Test::Test2Const(), test );
a( A1(), A2() );
bool u = a != b;
}
{
- typedef Callback3<A1, A2, A3> TestCallback3;
- TestCallback3 a = makeStatelessCallback3( Test3Free() );
- TestCallback3 b = makeCallback3( Test3(), test );
- TestCallback3 c = makeCallback3( Test::Test3(), test );
- TestCallback3 d = makeCallback3( Test::Test3Const(), test );
+ typedef Callback<void(A1, A2, A3)> TestCallback3;
+ TestCallback3 a = makeStatelessCallback( Test3Free() );
+ TestCallback3 b = makeCallback( Test3(), test );
+ makeCallback( Test::Test3(), test );
+ makeCallback( Test::Test3Const(), test );
a( A1(), A2(), A3() );
bool u = a != b;
}
#include <cstddef>
#include "functional.h"
-#include "callbackfwd.h"
-template<typename Type>
-inline void* convertToOpaque( Type* t ){
- return t;
-}
-template<typename Type>
-inline void* convertToOpaque( const Type* t ){
- return const_cast<Type*>( t );
-}
-template<typename Type>
-inline void* convertToOpaque( Type& t ){
- return &t;
-}
-template<typename Type>
-inline void* convertToOpaque( const Type& t ){
- return const_cast<Type*>( &t );
-}
+namespace detail {
+
+ template<typename Thunk_>
+ class CallbackBase {
+ void *m_environment;
+ Thunk_ m_thunk;
+ public:
+ typedef Thunk_ Thunk;
+
+ CallbackBase(void *environment, Thunk function) : m_environment(environment), m_thunk(function) {
+ }
+
+ void *getEnvironment() const {
+ return m_environment;
+ }
+
+ Thunk getThunk() const {
+ return m_thunk;
+ }
+ };
+
+ template<typename Thunk>
+ inline bool operator==(const CallbackBase<Thunk> &self, const CallbackBase<Thunk> &other) {
+ return self.getEnvironment() == other.getEnvironment() && self.getThunk() == other.getThunk();
+ }
+
+ template<typename Thunk>
+ inline bool operator!=(const CallbackBase<Thunk> &self, const CallbackBase<Thunk> &other) {
+ return !(self == other);
+ }
+
+ template<typename Thunk>
+ inline bool operator<(const CallbackBase<Thunk> &self, const CallbackBase<Thunk> &other) {
+ return self.getEnvironment() < other.getEnvironment() ||
+ (!(other.getEnvironment() < self.getEnvironment()) && self.getThunk() < other.getThunk());
+ }
+
+}
+
+namespace detail {
+
+ template<class Type>
+ struct ConvertFromOpaque {
+ };
+
+ // reference
+
+ template<class T>
+ inline const void *convertToOpaque(const T &t) {
+ return &t;
+ }
+
+ template<class T>
+ struct ConvertFromOpaque<const T &> {
+ static T const &apply(void *p) {
+ return *static_cast<const T *>(p);
+ }
+ };
+
+ template<class T>
+ inline void *convertToOpaque(T &t) {
+ return &t;
+ }
+
+ template<class T>
+ struct ConvertFromOpaque<T &> {
+ static T &apply(void *p) {
+ return *static_cast<T *>( p );
+ }
+ };
+
+ // pointer
+
+ template<class T>
+ inline const void *convertToOpaque(const T *t) {
+ return t;
+ }
+
+ template<class T>
+ struct ConvertFromOpaque<const T *> {
+ static const T *apply(void *p) {
+ return static_cast<const T *>(p);
+ }
+ };
+
+ template<class T>
+ inline void *convertToOpaque(T *t) {
+ return t;
+ }
+
+ template<class T>
+ struct ConvertFromOpaque<T *> {
+ static T *apply(void *p) {
+ return static_cast<T *>(p);
+ }
+ };
+
+ // function pointer
+
+ template<class R, class... Ts>
+ inline const void *convertToOpaque(R(*const &t)(Ts...)) {
+ return &t;
+ }
+
+ template<class R, class... Ts>
+ struct ConvertFromOpaque<R(*const &)(Ts...)> {
+ using Type = R(*)(Ts...);
+
+ static Type const &apply(void *p) {
+ return *static_cast<Type *>(p);
+ }
+ };
+
+ template<class R, class... Ts>
+ inline void *convertToOpaque(R(*&t)(Ts...)) {
+ return &t;
+ }
+
+ template<class R, class... Ts>
+ struct ConvertFromOpaque<R(*&)(Ts...)> {
+ using Type = R(*)(Ts...);
+
+ static Type &apply(void *p) {
+ return *static_cast<Type *>(p);
+ }
+ };
+
+ template<class Caller, class F>
+ class BindFirstOpaqueN;
+ template<class Caller, class R, class FirstBound, class... Ts>
+ class BindFirstOpaqueN<Caller, R(FirstBound, Ts...)> {
+ FirstBound firstBound;
+ public:
+ explicit BindFirstOpaqueN(FirstBound firstBound) : firstBound(firstBound) {
+ }
-template<typename Type>
-class ConvertFromOpaque
-{
-};
+ R operator()(Ts... args) const {
+ return Caller::call(firstBound, args...);
+ }
+
+ FirstBound getBound() const {
+ return firstBound;
+ }
+
+ static R thunk(void *environment, Ts... args) {
+ return thunk_(detail::ConvertFromOpaque<FirstBound>::apply(environment), args...);
+ }
+
+ static R thunk_(FirstBound environment, Ts... args) {
+ return Caller::call(environment, args...);
+ }
+
+ void *getEnvironment() const {
+ return const_cast<void *>(detail::convertToOpaque(firstBound));
+ }
+ };
+
+}
+
+template<class Caller>
+using BindFirstOpaque = detail::BindFirstOpaqueN<Caller, get_func<Caller>>;
-template<typename Type>
-class ConvertFromOpaque<Type&>
-{
-public:
-static Type& apply( void* p ){
- return *static_cast<Type*>( p );
-}
-};
+/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer.
+///
+/// Use with the callback constructors MemberCaller0, ConstMemberCaller0, ReferenceCaller0, ConstReferenceCaller0, PointerCaller0, ConstPointerCaller0 and FreeCaller0.
+template<class F>
+class Callback;
-template<typename Type>
-class ConvertFromOpaque<const Type&>
-{
-public:
-static const Type& apply( void* p ){
- return *static_cast<Type*>( p );
-}
-};
+template<class R, class... Ts>
+class Callback<R(Ts...)> : public detail::CallbackBase<R(*)(void *, Ts...)> {
+ using Base = detail::CallbackBase<R (*)(void *, Ts...)>;
+ static R nullThunk(void *, Ts...) {
+ }
-template<typename Type>
-class ConvertFromOpaque<Type*>
-{
public:
-static Type* apply( void* p ){
- return static_cast<Type*>( p );
-}
-};
+ using func = R(Ts...);
-template<typename Type>
-class ConvertFromOpaque<const Type*>
-{
-public:
-static const Type* apply( void* p ){
- return static_cast<Type*>( p );
-}
-};
+ Callback() : Base(0, nullThunk) {
+ }
-template<typename Caller>
-class BindFirstOpaque
-{
-typedef typename Caller::first_argument_type FirstBound;
-FirstBound firstBound;
-public:
-typedef typename Caller::result_type result_type;
-explicit BindFirstOpaque( FirstBound firstBound ) : firstBound( firstBound ){
-}
-result_type operator()() const {
- return Caller::call( firstBound );
-}
-FirstBound getBound() const {
- return firstBound;
-}
-static result_type thunk( void* environment ){
- return Caller::call( ConvertFromOpaque<FirstBound>::apply( environment ) );
-}
-void* getEnvironment() const {
- return convertToOpaque( firstBound );
-}
-};
+ template<typename Caller>
+ Callback(const BindFirstOpaque<Caller> &caller) : Base(caller.getEnvironment(), BindFirstOpaque<Caller>::thunk) {
+ }
-template<typename Caller>
-class BindFirstOpaque1
-{
-typedef typename Caller::first_argument_type FirstBound;
-FirstBound firstBound;
-public:
-typedef typename Caller::second_argument_type first_argument_type;
-typedef typename Caller::result_type result_type;
-explicit BindFirstOpaque1( FirstBound firstBound ) : firstBound( firstBound ){
-}
-result_type operator()( first_argument_type a1 ) const {
- return Caller::call( firstBound, a1 );
-}
-FirstBound getBound() const {
- return firstBound;
-}
-static result_type thunk( void* environment, first_argument_type a1 ){
- return Caller::call( ConvertFromOpaque<FirstBound>::apply( environment ), a1 );
-}
-void* getEnvironment() const {
- return convertToOpaque( firstBound );
-}
-};
+ Callback(void *environment, typename Base::Thunk function) : Base(environment, function) {
+ }
-template<typename Caller>
-class BindFirstOpaque2
-{
-typedef typename Caller::first_argument_type FirstBound;
-FirstBound firstBound;
-public:
-typedef typename Caller::second_argument_type first_argument_type;
-typedef typename Caller::third_argument_type second_argument_type;
-typedef typename Caller::result_type result_type;
-explicit BindFirstOpaque2( FirstBound firstBound ) : firstBound( firstBound ){
-}
-result_type operator()( first_argument_type a1, second_argument_type a2 ) const {
- return Caller::call( firstBound, a1, a2 );
-}
-FirstBound getBound() const {
- return firstBound;
-}
-static result_type thunk( void* environment, first_argument_type a1, second_argument_type a2 ){
- return Caller::call( ConvertFromOpaque<FirstBound>::apply( environment ), a1, a2 );
-}
-void* getEnvironment() const {
- return convertToOpaque( firstBound );
-}
+ R operator()(Ts... args) const {
+ return Base::getThunk()(Base::getEnvironment(), args...);
+ }
};
-template<typename Caller>
-class BindFirstOpaque3
-{
-typedef typename Caller::first_argument_type FirstBound;
-FirstBound firstBound;
-public:
-typedef typename Caller::second_argument_type first_argument_type;
-typedef typename Caller::third_argument_type second_argument_type;
-typedef typename Caller::fourth_argument_type third_argument_type;
-typedef typename Caller::result_type result_type;
-explicit BindFirstOpaque3( FirstBound firstBound ) : firstBound( firstBound ){
-}
-result_type operator()( first_argument_type a1, second_argument_type a2, third_argument_type a3 ) const {
- return Caller::call( firstBound, a1, a2, a3 );
-}
-FirstBound getBound() const {
- return firstBound;
-}
-static result_type thunk( void* environment, first_argument_type a1, second_argument_type a2, third_argument_type a3 ){
- return Caller::call( ConvertFromOpaque<FirstBound>::apply( environment ), a1, a2, a3 );
-}
-void* getEnvironment() const {
- return convertToOpaque( firstBound );
-}
-};
-
-template<typename Thunk_>
-class CallbackBase
-{
-void* m_environment;
-Thunk_ m_thunk;
-public:
-typedef Thunk_ Thunk;
-CallbackBase( void* environment, Thunk function ) : m_environment( environment ), m_thunk( function ){
-}
-void* getEnvironment() const {
- return m_environment;
-}
-Thunk getThunk() const {
- return m_thunk;
-}
-};
-
-template<typename Thunk>
-inline bool operator==( const CallbackBase<Thunk>& self, const CallbackBase<Thunk>& other ){
- return self.getEnvironment() == other.getEnvironment() && self.getThunk() == other.getThunk();
-}
-template<typename Thunk>
-inline bool operator!=( const CallbackBase<Thunk>& self, const CallbackBase<Thunk>& other ){
- return !( self == other );
-}
-template<typename Thunk>
-inline bool operator<( const CallbackBase<Thunk>& self, const CallbackBase<Thunk>& other ){
- return self.getEnvironment() < other.getEnvironment() ||
- ( !( other.getEnvironment() < self.getEnvironment() ) && self.getThunk() < other.getThunk() );
-}
-
+namespace detail {
+ template<class F>
+ struct Arglist;
-/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer.
-///
-/// Use with the callback constructors MemberCaller, ConstMemberCaller, ReferenceCaller, ConstReferenceCaller, PointerCaller, ConstPointerCaller and FreeCaller.
-template<typename Result>
-class Callback0 : public CallbackBase<Result ( * )( void* )>
-{
-typedef CallbackBase<Result ( * )( void* )> Base;
-static Result nullThunk( void* ){
-}
+ template<class R, class Head, class... Ts>
+ struct Arglist<R(Head, Ts...)> {
+ using type = R(Head, Ts...);
-public:
-typedef Result result_type;
-
-Callback0() : Base( 0, nullThunk ){
-}
-template<typename Caller>
-Callback0( const BindFirstOpaque<Caller>& caller ) : Base( caller.getEnvironment(), BindFirstOpaque<Caller>::thunk ){
-}
-Callback0( void* environment, typename Base::Thunk function ) : Base( environment, function ){
-}
-result_type operator()() const {
- return Base::getThunk() ( Base::getEnvironment() );
-}
-};
+ template <class Unshift>
+ using unshift = Arglist<R(Unshift, Head, Ts...)>;
-template<typename Caller>
-inline Callback0<typename Caller::result_type> makeCallback0( const Caller& caller, typename Caller::first_argument_type callee ){
- return Callback0<typename Caller::result_type>( BindFirstOpaque<Caller>( callee ) );
-}
-template<typename Caller>
-inline Callback0<typename Caller::result_type> makeStatelessCallback0( const Caller& caller ){
- return makeCallback0( Caller0To1<Caller>(), 0 );
-}
-
-typedef Callback0<void> Callback;
-
-
-
-/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer and one other argument.
-///
-/// Use with the callback constructors MemberCaller1, ConstMemberCaller1, ReferenceCaller1, ConstReferenceCaller1, PointerCaller1, ConstPointerCaller1 and FreeCaller1.
-template<typename FirstArgument, typename Result>
-class Callback1 : public CallbackBase<Result ( * )( void*, FirstArgument )>
-{
-typedef CallbackBase<Result ( * )( void*, FirstArgument )> Base;
-static Result nullThunk( void*, FirstArgument ){
-}
-
-public:
-typedef FirstArgument first_argument_type;
-typedef Result result_type;
-
-Callback1() : Base( 0, nullThunk ){
-}
-template<typename Caller>
-Callback1( const BindFirstOpaque1<Caller>& caller ) : Base( caller.getEnvironment(), BindFirstOpaque1<Caller>::thunk ){
-}
-Callback1( void* environment, typename Base::Thunk function ) : Base( environment, function ){
-}
-result_type operator()( FirstArgument firstArgument ) const {
- return Base::getThunk() ( Base::getEnvironment(), firstArgument );
-}
-};
-
-template<typename Caller>
-inline Callback1<typename Caller::second_argument_type, typename Caller::result_type> makeCallback1( const Caller& caller, typename Caller::first_argument_type callee ){
- return Callback1<typename Caller::second_argument_type, typename Caller::result_type>( BindFirstOpaque1<Caller>( callee ) );
-}
-template<typename Caller>
-inline Callback1<typename Caller::second_argument_type, typename Caller::result_type> makeStatelessCallback1( const Caller& caller ){
- return makeCallback1( Caller1To2<Caller>(), 0 );
-}
+ using shift = Arglist<R(Ts...)>;
+ };
+ template<class R, class... Ts>
+ struct Arglist<R(Ts...)> {
+ using type = R(Ts...);
-/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer and two other arguments.
-///
-template<typename FirstArgument, typename SecondArgument, typename Result>
-class Callback2 : public CallbackBase<Result ( * )( void*, FirstArgument, SecondArgument )>
-{
-typedef CallbackBase<Result ( * )( void*, FirstArgument, SecondArgument )> Base;
-static Result nullThunk( void*, FirstArgument, SecondArgument ){
-}
+ template <class Unshift>
+ using unshift = Arglist<R(Unshift, Ts...)>;
+ };
-public:
-typedef FirstArgument first_argument_type;
-typedef SecondArgument second_argument_type;
-typedef Result result_type;
+ template<class F>
+ using ArgShift = typename detail::Arglist<F>::shift::type;
-Callback2() : Base( 0, nullThunk ){
-}
-template<typename Caller>
-Callback2( const BindFirstOpaque2<Caller>& caller ) : Base( caller.getEnvironment(), BindFirstOpaque2<Caller>::thunk ){
-}
-Callback2( void* environment, typename Base::Thunk function ) : Base( environment, function ){
+ template<class F, class T>
+ using ArgUnshift = typename detail::Arglist<F>::template unshift<T>::type;
}
-result_type operator()( FirstArgument firstArgument, SecondArgument secondArgument ) const {
- return Base::getThunk() ( Base::getEnvironment(), firstArgument, secondArgument );
-}
-};
template<typename Caller>
-inline Callback2<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type,
- typename Caller::result_type
- > makeCallback2( const Caller& caller, typename Caller::first_argument_type callee ){
- return Callback2<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type,
- typename Caller::result_type
- >( BindFirstOpaque2<Caller>( callee ) );
-}
-template<typename Caller>
-inline Callback2<
- typename Caller::first_argument_type,
- typename Caller::second_argument_type,
- typename Caller::result_type
- > makeStatelessCallback2( const Caller& caller ){
- return makeCallback2( Caller2To3<Caller>(), 0 );
+inline Callback<detail::ArgShift<get_func<Caller>>> makeCallback(const Caller &caller, get_argument<Caller, 0> callee) {
+ return BindFirstOpaque<Caller>(callee);
}
+template<class Caller, class F>
+class CallerShiftFirst;
-/// \brief Combines a void pointer with a pointer to a function which operates on a void pointer and three other arguments.
-///
-template<typename FirstArgument, typename SecondArgument, typename ThirdArgument, typename Result>
-class Callback3 : public CallbackBase<Result ( * )( void*, FirstArgument, SecondArgument, ThirdArgument )>
-{
-typedef CallbackBase<Result ( * )( void*, FirstArgument, SecondArgument, ThirdArgument )> Base;
-static Result nullThunk( void*, FirstArgument, SecondArgument, ThirdArgument ){
-}
-
+template<class Caller, class R, class FirstArgument, class... Ts>
+class CallerShiftFirst<Caller, R(FirstArgument, Ts...)> {
public:
-typedef FirstArgument first_argument_type;
-typedef SecondArgument second_argument_type;
-typedef ThirdArgument third_argument_type;
-typedef Result result_type;
+ using func = R(FirstArgument, Ts...);
-Callback3() : Base( 0, nullThunk ){
-}
-template<typename Caller>
-Callback3( const BindFirstOpaque3<Caller>& caller ) : Base( caller.getEnvironment(), BindFirstOpaque3<Caller>::thunk ){
-}
-Callback3( void* environment, typename Base::Thunk function ) : Base( environment, function ){
-}
-result_type operator()( FirstArgument firstArgument, SecondArgument secondArgument, ThirdArgument thirdArgument ) const {
- return Base::getThunk() ( Base::getEnvironment(), firstArgument, secondArgument, thirdArgument );
-}
+ static R call(FirstArgument, Ts... args) {
+ return Caller::call(args...);
+ }
};
template<typename Caller>
-inline Callback3<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type,
- typename Caller::fourth_argument_type,
- typename Caller::result_type
- > makeCallback3( const Caller& caller, typename Caller::first_argument_type callee ){
- return Callback3<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type,
- typename Caller::fourth_argument_type,
- typename Caller::result_type
- >( BindFirstOpaque3<Caller>( callee ) );
+inline Callback<get_func<Caller>> makeStatelessCallback(const Caller &caller) {
+ return makeCallback(CallerShiftFirst<Caller, detail::ArgUnshift<get_func<Caller>, void *>>(), nullptr);
}
-template<typename Caller>
-inline Callback3<
- typename Caller::first_argument_type,
- typename Caller::second_argument_type,
- typename Caller::third_argument_type,
- typename Caller::result_type
- > makeStatelessCallback3( const Caller& caller ){
- return makeCallback3( Caller3To4<Caller>(), 0 );
-}
-
/// \brief Forms a Callback from a non-const Environment reference and a non-const Environment member-function.
-///
-/// \dontinclude generic/callback.cpp
-/// \skipline MemberCaller example
-/// \until end example
-template<typename Environment, void( Environment::*member ) ( )>
-class MemberCaller : public BindFirstOpaque< Member<Environment, void, member> >
-{
-public:
-MemberCaller( Environment& environment ) : BindFirstOpaque< Member<Environment, void, member> >( environment ){
-}
-};
+template<class Environment, class F, MemberFunction<Environment, F> member>
+using MemberCaller = BindFirstOpaque<Member<Environment, F, member>>;
-/// \brief Forms a Callback from a const Environment reference and a const Environment member-function.
+/// \brief Constructs a Callback1 from a non-const \p functor
///
-/// \dontinclude generic/callback.cpp
-/// \skipline MemberCaller example
-/// \until end example
-template<typename Environment, void( Environment::*member ) ( ) const>
-class ConstMemberCaller : public BindFirstOpaque< ConstMember<Environment, void, member> >
-{
-public:
-ConstMemberCaller( const Environment& environment ) : BindFirstOpaque< ConstMember<Environment, void, member> >( environment ){
+/// \param Functor Must define \c first_argument_type and \c operator()(first_argument_type).
+template<typename Functor>
+inline Callback<get_func<Functor>> makeCallback(Functor &functor) {
+ return MemberCaller<Functor, get_func<Functor>, &Functor::operator()>(functor);
}
-};
-/// \brief Forms a Callback from a non-const Environment reference and a const Environment member-function which takes one argument.
-template<typename Environment, typename FirstArgument, void( Environment::*member ) (FirstArgument)>
-class MemberCaller1 : public BindFirstOpaque1< Member1<Environment, FirstArgument, void, member> >
-{
-public:
-MemberCaller1( Environment& environment ) : BindFirstOpaque1< Member1<Environment, FirstArgument, void, member> >( environment ){
-}
-};
+/// \brief Forms a Callback from a const Environment reference and a const Environment member-function.
+template<class Environment, class F, ConstMemberFunction<Environment, F> member>
+using ConstMemberCaller = BindFirstOpaque<ConstMember<Environment, F, member>>;
-/// \brief Forms a Callback from a const Environment reference and a const Environment member-function which takes one argument.
-template<typename Environment, typename FirstArgument, void( Environment::*member ) (FirstArgument) const>
-class ConstMemberCaller1 : public BindFirstOpaque1< ConstMember1<Environment, FirstArgument, void, member> >
-{
-public:
-ConstMemberCaller1( const Environment& environment ) : BindFirstOpaque1< ConstMember1<Environment, FirstArgument, void, member> >( environment ){
+/// \brief Constructs a Callback1 from a const \p functor
+///
+/// \param Functor Must define \c first_argument_type and const \c operator()(first_argument_type).
+template<typename Functor>
+inline Callback<get_func<Functor>> makeCallback(const Functor &functor) {
+ return ConstMemberCaller<Functor, get_func<Functor>, &Functor::operator()>(functor);
}
-};
/// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference.
-///
-/// \dontinclude generic/callback.cpp
-/// \skipline ReferenceCaller example
-/// \until end example
-template<typename Environment, void( *func ) (Environment&)>
-class ReferenceCaller : public BindFirstOpaque< Function1<Environment&, void, func> >
-{
-public:
-ReferenceCaller( Environment& environment ) : BindFirstOpaque< Function1<Environment&, void, func> >( environment ){
-}
-};
+template<class Environment, class F, detail::ArgUnshift<F, Environment &> *func>
+using ReferenceCaller = BindFirstOpaque<Function<detail::ArgUnshift<F, Environment &>, func>>;
/// \brief Forms a Callback from a const Environment reference and a free function which operates on a const Environment reference.
-///
-/// \dontinclude generic/callback.cpp
-/// \skipline ReferenceCaller example
-/// \until end example
-template<typename Environment, void( *func ) (const Environment&)>
-class ConstReferenceCaller : public BindFirstOpaque< Function1<const Environment&, void, func> >
-{
-public:
-ConstReferenceCaller( const Environment& environment ) : BindFirstOpaque< Function1<const Environment&, void, func> >( environment ){
-}
-};
-
-/// \brief Forms a Callback from a non-const Environment reference and a free function which operates on a non-const Environment reference and one other argument.
-template<typename Environment, typename FirstArgument, void( *func ) ( Environment&, FirstArgument )>
-class ReferenceCaller1 : public BindFirstOpaque1< Function2<Environment&, FirstArgument, void, func> >
-{
-public:
-ReferenceCaller1( Environment& environment ) : BindFirstOpaque1< Function2<Environment&, FirstArgument, void, func> >( environment ){
-}
-};
-
-/// \brief Forms a Callback from a const Environment reference and a free function which operates on a const Environment reference and one other argument.
-template<typename Environment, typename FirstArgument, void( *func ) ( const Environment&, FirstArgument )>
-class ConstReferenceCaller1 : public BindFirstOpaque1< Function2<const Environment&, FirstArgument, void, func> >
-{
-public:
-ConstReferenceCaller1( const Environment& environment ) : BindFirstOpaque1< Function2<const Environment&, FirstArgument, void, func> >( environment ){
-}
-};
+template<class Environment, class F, detail::ArgUnshift<F, const Environment &> *func>
+using ConstReferenceCaller = BindFirstOpaque<Function<detail::ArgUnshift<F, const Environment &>, func>>;
/// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer.
-template<typename Environment, void( *func ) (Environment*)>
-class PointerCaller : public BindFirstOpaque< Function1<Environment*, void, func> >
-{
-public:
-PointerCaller( Environment* environment ) : BindFirstOpaque< Function1<Environment*, void, func> >( environment ){
-}
-};
+template<class Environment, class F, detail::ArgUnshift<F, Environment *> *func>
+using PointerCaller = BindFirstOpaque<Function<detail::ArgUnshift<F, Environment *>, func>>;
/// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer.
-template<typename Environment, void( *func ) (const Environment*)>
-class ConstPointerCaller : public BindFirstOpaque< Function1<const Environment*, void, func> >
-{
-public:
-ConstPointerCaller( const Environment* environment ) : BindFirstOpaque< Function1<const Environment*, void, func> >( environment ){
-}
-};
+template<class Environment, class F, detail::ArgUnshift<F, const Environment *> *func>
+using ConstPointerCaller = BindFirstOpaque<Function<detail::ArgUnshift<F, const Environment *>, func>>;
-/// \brief Forms a Callback from a non-const Environment pointer and a free function which operates on a non-const Environment pointer and one other argument.
-template<typename Environment, typename FirstArgument, void( *func ) ( Environment*, FirstArgument )>
-class PointerCaller1 : public BindFirstOpaque1< Function2<Environment*, FirstArgument, void, func> >
-{
-public:
-PointerCaller1( Environment* environment ) : BindFirstOpaque1< Function2<Environment*, FirstArgument, void, func> >( environment ){
-}
-};
+namespace detail {
+ template<class Caller, class F>
+ class FreeCaller : public BindFirstOpaque<CallerShiftFirst<Caller, detail::ArgUnshift<F, void *>>> {
+ public:
+ FreeCaller() : BindFirstOpaque<CallerShiftFirst<Caller, detail::ArgUnshift<F, void *>>>(nullptr) {
+ }
+ };
-/// \brief Forms a Callback from a const Environment pointer and a free function which operates on a const Environment pointer and one other argument.
-template<typename Environment, typename FirstArgument, void( *func ) ( const Environment*, FirstArgument )>
-class ConstPointerCaller1 : public BindFirstOpaque1< Function2<const Environment*, FirstArgument, void, func> >
-{
-public:
-ConstPointerCaller1( const Environment* environment ) : BindFirstOpaque1< Function2<const Environment*, FirstArgument, void, func> >( environment ){
-}
-};
+ template<class F>
+ struct FreeCallerWrapper;
-/// \brief Forms a Callback from a free function which takes no arguments.
-template<void( *func ) ( )>
-class FreeCaller : public BindFirstOpaque< Caller0To1< Function0<void, func> > >
-{
-public:
-FreeCaller() : BindFirstOpaque< Caller0To1< Function0<void, func> > >( 0 ){
-}
-};
+ template<class R, class... Ts>
+ struct FreeCallerWrapper<R(Ts...)> {
+ using func = R(void *, Ts...);
-/// \brief Forms a Callback from a free function which takes a single argument.
-template<typename FirstArgument, void( *func ) (FirstArgument)>
-class FreeCaller1 : public BindFirstOpaque1< Caller1To2< Function1<FirstArgument, void, func> > >
-{
-public:
-FreeCaller1() : BindFirstOpaque1< Caller1To2< Function1<FirstArgument, void, func> > >( 0 ){
+ static R call(void *f, Ts... args) {
+ // ideally, we'd get the implementation of the function type directly. Instead, it's passed in
+ return reinterpret_cast<R(*)(Ts...)>(f)(args...);
+ }
+ };
}
-};
+/// \brief Forms a Callback from a free function
+template<class F, F *func>
+using FreeCaller = detail::FreeCaller<Function<F, func>, F>;
-/// \brief Constructs a Callback from a non-const \p functor with zero arguments.
-///
-/// \param Functor Must define \c operator()().
-template<typename Functor>
-inline Callback makeCallback( Functor& functor ){
- return Callback( MemberCaller<Functor, &Functor::operator()>( functor ) );
-}
-
-/// \brief Constructs a Callback from a const \p functor with zero arguments.
-///
-/// \param Functor Must define const \c operator()().
-template<typename Functor>
-inline Callback makeCallback( const Functor& functor ){
- return Callback( ConstMemberCaller<Functor, &Functor::operator()>( functor ) );
+template<class R, class... Ts>
+inline Callback<R(Ts...)> makeCallbackF(R(*func)(Ts...)) {
+ void *pVoid = reinterpret_cast<void *>(func);
+ return BindFirstOpaque<detail::FreeCallerWrapper<R(Ts...)>>(pVoid);
}
-/// \brief Constructs a Callback1 from a non-const \p functor with one argument.
-///
-/// \param Functor Must define \c first_argument_type and \c operator()(first_argument_type).
-template<typename Functor>
-inline Callback1<typename Functor::first_argument_type> makeCallback1( Functor& functor ){
- typedef typename Functor::first_argument_type FirstArgument;
- return Callback1<FirstArgument>( MemberCaller1<Functor, FirstArgument, &Functor::operator()>( functor ) );
-}
-
-/// \brief Constructs a Callback1 from a const \p functor with one argument.
-///
-/// \param Functor Must define \c first_argument_type and const \c operator()(first_argument_type).
-template<typename Functor>
-inline Callback1<typename Functor::first_argument_type> makeCallback1( const Functor& functor ){
- typedef typename Functor::first_argument_type FirstArgument;
- return Callback1<FirstArgument>( ConstMemberCaller1<Functor, FirstArgument, &Functor::operator()>( functor ) );
-}
-
-
-typedef Callback1<bool> BoolImportCallback;
-typedef Callback1<const BoolImportCallback&> BoolExportCallback;
-
-typedef Callback1<int> IntImportCallback;
-typedef Callback1<const IntImportCallback&> IntExportCallback;
-
-typedef Callback1<float> FloatImportCallback;
-typedef Callback1<const FloatImportCallback&> FloatExportCallback;
-
-typedef Callback1<const char*> StringImportCallback;
-typedef Callback1<const StringImportCallback&> StringExportCallback;
-
-typedef Callback1<std::size_t> SizeImportCallback;
-typedef Callback1<const SizeImportCallback&> SizeExportCallback;
-
-
#endif
+++ /dev/null
-
-#include "callbackfwd.h"
+++ /dev/null
-
-#if !defined( INCLUDED_CALLBACKFWD_H )
-#define INCLUDED_CALLBACKFWD_H
-
-template<typename Return>
-class Callback0;
-typedef Callback0<void> Callback;
-
-template<typename FirstArgument, typename Result = void>
-class Callback1;
-
-template<typename FirstArgument, typename SecondArgument, typename Result = void>
-class Callback2;
-
-template<typename FirstArgument, typename SecondArgument, typename ThirdArgument, typename Result = void>
-class Callback3;
-
-#endif
*/
#include "constant.h"
+#include "globaldefs.h"
-#if defined( _DEBUG ) || defined( DOXYGEN )
+#if GDEF_DEBUG || defined( DOXYGEN )
namespace ExampleConstant
{
return ostream_write( ostream, typename Type::Value( c ) );
}
-#define TYPE_CONSTANT( name, value, type ) struct name ## _CONSTANT_ { typedef type Value; static Value evaluate() { return value; } }; typedef ConstantWrapper<name ## _CONSTANT_> name
+#define TYPE_CONSTANT( name, value, type ) struct name##_CONSTANT_ { typedef type Value; static Value evaluate() { return value; } }; typedef ConstantWrapper<name##_CONSTANT_> name
#define STRING_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, const char* )
#define INTEGER_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, int )
+#define UINT_CONSTANT( name, value ) TYPE_CONSTANT ( name, value, unsigned int )
STRING_CONSTANT( EmptyString, "" );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "enumeration.h"
+++ /dev/null
-
-#include "functional.h"
-
#if !defined( INCLUDED_FUNCTIONAL_H )
#define INCLUDED_FUNCTIONAL_H
-template<typename Object, typename R, R( Object::*member ) ( )>
-class Member
-{
-public:
-typedef Object& first_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type object ){
- return ( object.*member )();
-}
-};
-
-template<typename Object, typename R, R( Object::*member ) ( ) const>
-class ConstMember
-{
-public:
-typedef const Object& first_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type object ){
- return ( object.*member )();
-}
-};
-
-template<typename Object, typename A1, typename R, R( Object::*member ) (A1)>
-class Member1
-{
-public:
-typedef Object& first_argument_type;
-typedef A1 second_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type object, second_argument_type a1 ){
- return ( object.*member )( a1 );
-}
-};
-
-template<typename Object, typename A1, typename R, R( Object::*member ) (A1) const>
-class ConstMember1
-{
-public:
-typedef const Object& first_argument_type;
-typedef A1 second_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type object, second_argument_type a1 ){
- return ( object.*member )( a1 );
-}
-};
-
-template<typename Object, typename A2, typename A3, typename R, R( Object::*member ) ( A2, A3 )>
-class Member2
-{
-public:
-typedef Object& first_argument_type;
-typedef A2 second_argument_type;
-typedef A3 third_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type object, second_argument_type a2, third_argument_type a3 ){
- return ( object.*member )( a2, a3 );
-}
-};
-
-template<typename Object, typename A2, typename A3, typename R, R( Object::*member ) ( A2, A3 ) const>
-class ConstMember2
-{
-public:
-typedef const Object& first_argument_type;
-typedef A2 second_argument_type;
-typedef A3 third_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type object, second_argument_type a2, third_argument_type a3 ){
- return ( object.*member )( a2, a3 );
-}
-};
-
-template<typename Object, typename A2, typename A3, typename A4, typename R, R( Object::*member ) ( A2, A3, A4 )>
-class Member3
-{
-public:
-typedef Object& first_argument_type;
-typedef A2 second_argument_type;
-typedef A3 third_argument_type;
-typedef A4 fourth_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type object, second_argument_type a2, third_argument_type a3, fourth_argument_type a4 ){
- return ( object.*member )( a2, a3, a4 );
-}
-};
-
-template<typename Object, typename A2, typename A3, typename A4, typename R, R( Object::*member ) ( A2, A3, A4 ) const>
-class ConstMember3
-{
-public:
-typedef const Object& first_argument_type;
-typedef A2 second_argument_type;
-typedef A3 third_argument_type;
-typedef A4 fourth_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type object, second_argument_type a2, third_argument_type a3, fourth_argument_type a4 ){
- return ( object.*member )( a2, a3, a4 );
-}
-};
-
-template<typename R, R( *func ) ( )>
-class Function0
-{
-public:
-typedef R result_type;
-static result_type call(){
- return (func)( );
-}
-};
-
-template<typename A1, typename R, R( *func ) (A1)>
-class Function1
-{
-public:
-typedef A1 first_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type a1 ){
- return (func)( a1 );
-}
-};
-
-template<typename A1, typename A2, typename R, R( *func ) ( A1, A2 )>
-class Function2
-{
-public:
-typedef A1 first_argument_type;
-typedef A2 second_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type a1, second_argument_type a2 ){
- return (func)( a1, a2 );
-}
-};
-
-template<typename A1, typename A2, typename A3, typename R, R( *func ) ( A1, A2, A3 )>
-class Function3
-{
-public:
-typedef A1 first_argument_type;
-typedef A2 second_argument_type;
-typedef A3 third_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type a1, second_argument_type a2, third_argument_type a3 ){
- return (func)( a1, a2, a3 );
-}
-};
-
-template<typename A1, typename A2, typename A3, typename A4, typename R, R( *func ) ( A1, A2, A3, A4 )>
-class Function4
-{
-public:
-typedef A1 first_argument_type;
-typedef A2 second_argument_type;
-typedef A3 third_argument_type;
-typedef A4 fourth_argument_type;
-typedef R result_type;
-static result_type call( first_argument_type a1, second_argument_type a2, third_argument_type a3, fourth_argument_type a4 ){
- return (func)( a1, a2, a3, a4 );
-}
-};
-
-template<typename Caller, typename FirstArgument = void*>
-class Caller0To1
-{
-public:
-typedef FirstArgument first_argument_type;
-typedef typename Caller::result_type result_type;
-static result_type call( first_argument_type ){
- return Caller::call();
-}
-};
-
-template<typename Caller, typename FirstArgument = void*>
-class Caller1To2
-{
-public:
-typedef FirstArgument first_argument_type;
-typedef typename Caller::first_argument_type second_argument_type;
-typedef typename Caller::result_type result_type;
-static result_type call( first_argument_type, second_argument_type a2 ){
- return Caller::call( a2 );
-}
-};
-
-template<typename Caller, typename FirstArgument = void*>
-class Caller2To3
-{
-public:
-typedef FirstArgument first_argument_type;
-typedef typename Caller::first_argument_type second_argument_type;
-typedef typename Caller::second_argument_type third_argument_type;
-typedef typename Caller::result_type result_type;
-static result_type call( first_argument_type, second_argument_type a2, third_argument_type a3 ){
- return Caller::call( a2, a3 );
-}
-};
-
-template<typename Caller, typename FirstArgument = void*>
-class Caller3To4
-{
-public:
-typedef FirstArgument first_argument_type;
-typedef typename Caller::first_argument_type second_argument_type;
-typedef typename Caller::second_argument_type third_argument_type;
-typedef typename Caller::third_argument_type fourth_argument_type;
-typedef typename Caller::result_type result_type;
-static result_type call( first_argument_type, second_argument_type a2, third_argument_type a3, fourth_argument_type a4 ){
- return Caller::call( a2, a3, a4 );
-}
-};
-
-template<typename Functor>
-class FunctorInvoke
-{
-public:
-typedef typename Functor::result_type result_type;
-inline result_type operator()( Functor functor ){
- return functor();
-}
-};
-
-template<typename Functor>
-class Functor1Invoke
-{
-typename Functor::first_argument_type a1;
-public:
-typedef typename Functor::first_argument_type first_argument_type;
-typedef typename Functor::result_type result_type;
-Functor1Invoke( first_argument_type a1 ) : a1( a1 ){
+#include <functional>
+#include <tuple>
+
+namespace detail {
+
+ template<int N>
+ struct rank : rank<N - 1> {
+ };
+
+ template<>
+ struct rank<0> {
+ };
+
+ struct get_func {
+
+ template<class T>
+ struct wrapper {
+ using type = T;
+ };
+
+ template<class F>
+ using func_member = wrapper<typename F::func>;
+
+ template<class F>
+ static wrapper<func_member<F>> test(rank<2>) { return {}; }
+
+ template<class F>
+ struct func_lambda {
+ using type = typename func_lambda<decltype(&F::operator())>::type;
+ };
+
+ template<class R, class... Ts>
+ struct func_lambda<R(*)(Ts...)> {
+ using type = R(Ts...);
+ };
+
+ template<class Object, class R, class... Ts>
+ struct func_lambda<R(Object::*)(Ts...) const> {
+ using type = R(Ts...);
+ };
+
+ template<class Object, class R, class... Ts>
+ struct func_lambda<R(Object::*)(Ts...)> {
+ using type = R(Ts...);
+ };
+
+ template<class F, class = func_lambda<F>>
+ static wrapper<func_lambda<F>> test(rank<1>) { return {}; }
+ };
+
+ template<class F>
+ struct Fn;
+
+ template<class R, class... Ts>
+ struct Fn<R(Ts...)> {
+ using result_type = R;
+
+ template<int N>
+ using get = typename std::tuple_element<N, std::tuple<Ts...>>::type;
+ };
}
-inline result_type operator()( Functor functor ){
- return functor( a1 );
+
+template<class Caller>
+using get_func = typename decltype(detail::get_func::test<Caller>(detail::rank<2>{}))::type::type;
+
+template<class Caller>
+using get_result_type = typename detail::Fn<get_func<Caller>>::result_type;
+
+template<class Caller, int N>
+using get_argument = typename detail::Fn<get_func<Caller>>::template get<N>;
+
+namespace detail {
+
+ template<class F>
+ class FunctionN;
+
+ template<class R, class... Ts>
+ class FunctionN<R(Ts...)> {
+ public:
+ template<R(*f)(Ts...)>
+ class instance {
+ public:
+ using func = R(Ts...);
+
+ static R call(Ts... args) {
+ return (f)(args...);
+ }
+ };
+ };
+
}
-};
-
-template<typename Functor>
-class Functor2Invoke
-{
-typename Functor::first_argument_type a1;
-typename Functor::second_argument_type a2;
-public:
-typedef typename Functor::first_argument_type first_argument_type;
-typedef typename Functor::second_argument_type second_argument_type;
-typedef typename Functor::result_type result_type;
-Functor2Invoke( first_argument_type a1, second_argument_type a2 )
- : a1( a1 ), a2( a2 ){
+
+template<class F, F *func>
+using Function = typename detail::FunctionN<F>::template instance<func>;
+
+namespace detail {
+ template<class Object, class F>
+ struct MemberFunction;
+
+ template<class Object, class R, class... Ts>
+ struct MemberFunction<Object, R(Ts...)> {
+ using type = R(Object::*)(Ts...);
+ using type_const = R(Object::*)(Ts...) const;
+ };
}
-inline result_type operator()( Functor functor ){
- return functor( a1, a2 );
+
+namespace detail {
+ template<class Object, class F>
+ class MemberN;
+
+ template<class Object, class R, class... Ts>
+ class MemberN<Object, R(Ts...)> {
+ public:
+ template<R(Object::*f)(Ts...)>
+ class instance {
+ public:
+ using func = R(Object &, Ts...);
+
+ static R call(Object &object, Ts... args) {
+ return (object.*f)(args...);
+ }
+ };
+ };
}
-};
-
-template<typename Functor>
-class Functor3Invoke
-{
-typename Functor::first_argument_type a1;
-typename Functor::second_argument_type a2;
-typename Functor::third_argument_type a3;
-public:
-typedef typename Functor::first_argument_type first_argument_type;
-typedef typename Functor::second_argument_type second_argument_type;
-typedef typename Functor::third_argument_type third_argument_type;
-typedef typename Functor::result_type result_type;
-Functor3Invoke( first_argument_type a1, second_argument_type a2, third_argument_type a3 )
- : a1( a1 ), a2( a2 ), a3( a3 ){
+
+template<class Object, class F>
+using MemberFunction = typename detail::MemberFunction<Object, F>::type;
+
+template<class Object, class F, MemberFunction<Object, F> func>
+using Member = typename detail::MemberN<Object, F>::template instance<func>;
+
+namespace detail {
+ template<class Object, class F>
+ class ConstMemberN;
+
+ template<class Object, class R, class... Ts>
+ class ConstMemberN<Object, R(Ts...)> {
+ public:
+ template<R(Object::*f)(Ts...) const>
+ class instance {
+ public:
+ using func = R(const Object &, Ts...);
+
+ static R call(const Object &object, Ts... args) {
+ return (object.*f)(args...);
+ }
+ };
+ };
}
-inline result_type operator()( Functor functor ){
- return functor( a1, a2, a3 );
+
+template<class Object, class F>
+using ConstMemberFunction = typename detail::MemberFunction<Object, F>::type_const;
+
+template<class Object, class F, ConstMemberFunction<Object, F> func>
+using ConstMember = typename detail::ConstMemberN<Object, F>::template instance<func>;
+
+// misc
+
+namespace detail {
+ template<int ...>
+ struct seq {
+ };
+
+ template<int N, int... S>
+ struct gens : gens<N - 1, N - 1, S...> {
+ };
+
+ template<int... S>
+ struct gens<0, S...> {
+ using type = seq<S...>;
+ };
+
+ template<int N>
+ using seq_new = typename gens<N>::type;
+
+ template<class Functor, class F>
+ class FunctorNInvoke;
+
+ template<class Functor, class R, class... Ts>
+ class FunctorNInvoke<Functor, R(Ts...)> {
+ std::tuple<Ts...> args;
+
+ template<class T>
+ struct caller;
+
+ template<int ...I>
+ struct caller<seq<I...>> {
+ static inline R call(FunctorNInvoke<Functor, R(Ts...)> *self, Functor functor) {
+ (void) self;
+ return functor(std::get<I>(self->args)...);
+ }
+ };
+
+ public:
+ FunctorNInvoke(Ts... args) : args(args...) {
+ }
+
+ inline R operator()(Functor functor) {
+ return caller<seq_new<sizeof...(Ts)>>::call(this, functor);
+ }
+ };
}
-};
-
-template<typename Other, typename True, typename False, typename Type>
-class TypeEqual
-{
-public:
-typedef False type;
-};
-template<typename Other, typename True, typename False>
-class TypeEqual<Other, True, False, Other>
-{
-public:
-typedef True type;
-};
+template<class Functor>
+using FunctorInvoke = detail::FunctorNInvoke<Functor, get_func<Functor>>;
#endif
#if !defined( INCLUDED_GENERIC_OBJECT_H )
#define INCLUDED_GENERIC_OBJECT_H
+#include "globaldefs.h"
+
/// \file
/// \brief Convenience functions (syntactic sugar) to wrap explicit constructor (aka in-place 'new') and destructor calls.
///
/// Use makeReference() to wrap non-const-reference constructor parameters.
-#if _MSC_VER > 1000 && defined( WIN32 )
+#if GDEF_COMPILER_MSVC && _MSC_VER > 1000
#pragma warning(disable:4345) // behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "reference.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "referencecounted.h"
*/
#include "static.h"
+#include "globaldefs.h"
-#if defined( _DEBUG ) || defined( DOXYGEN )
+#if GDEF_DEBUG || defined( DOXYGEN )
namespace ExampleStatic
{
+++ /dev/null
-
-#include "vector.h"
--- /dev/null
+#ifndef INCLUDED_LIBS_GLOBALDEFS
+#define INCLUDED_LIBS_GLOBALDEFS
+
+// ARCH_ENDIAN
+
+#if defined(__BIG_ENDIAN__) || defined(_SGI_SOURCE)
+#define GDEF_ARCH_ENDIAN_BIG 1
+#else
+#define GDEF_ARCH_ENDIAN_BIG 0
+#endif
+
+// ARCH_BITS
+
+#if defined(__i386__) || defined(_M_IX86)
+#define GDEF_ARCH_BITS_32 1
+#else
+#define GDEF_ARCH_BITS_32 0
+#endif
+
+#if defined(__LP64__) || defined(_M_X64) || defined(_M_AMD64) || defined(_WIN64)
+#define GDEF_ARCH_BITS_64 1
+#else
+#define GDEF_ARCH_BITS_64 0
+#endif
+
+// OS
+
+#if defined(POSIX)
+#define GDEF_OS_POSIX 1
+#else
+#define GDEF_OS_POSIX 0
+#endif
+
+#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
+#define GDEF_OS_WINDOWS 1
+#else
+#define GDEF_OS_WINDOWS 0
+#endif
+
+#if defined(__APPLE__)
+#define GDEF_OS_MACOS 1
+#else
+#define GDEF_OS_MACOS 0
+#endif
+
+#if defined(__linux__)
+#define GDEF_OS_LINUX 1
+#else
+#define GDEF_OS_LINUX 0
+#endif
+
+
+#define GDEF_OS_BSD 0
+
+#if defined(__FreeBSD__)
+#undef GDEF_OS_BSD
+#define GDEF_OS_BSD 1
+#define GDEF_OS_BSD_FREE 1
+#else
+#define GDEF_OS_BSD_FREE 0
+#endif
+
+#if defined(__NetBSD__)
+#undef GDEF_OS_BSD
+#define GDEF_OS_BSD 1
+#define GDEF_OS_BSD_NET 1
+#else
+#define GDEF_OS_BSD_NET 0
+#endif
+
+#if defined(__OpenBSD__)
+#undef GDEF_OS_BSD
+#define GDEF_OS_BSD 1
+#define GDEF_OS_BSD_OPEN 1
+#else
+#define GDEF_OS_BSD_OPEN 0
+#endif
+
+#if defined(__DragonFly__)
+#undef GDEF_OS_BSD
+#define GDEF_OS_BSD 1
+#define GDEF_OS_BSD_DRAGONFLY 1
+#else
+#define GDEF_OS_BSD_DRAGONFLY 0
+#endif
+
+// COMPILER
+
+#if defined(_MSC_VER)
+#define GDEF_COMPILER_MSVC 1
+#else
+#define GDEF_COMPILER_MSVC 0
+#endif
+
+#if defined(__GNUC__)
+#define GDEF_COMPILER_GNU 1
+#else
+#define GDEF_COMPILER_GNU 0
+#endif
+
+// ATTRIBUTE
+
+#if GDEF_COMPILER_GNU
+#define GDEF_ATTRIBUTE_NORETURN __attribute__((noreturn))
+#else
+#define GDEF_ATTRIBUTE_NORETURN
+#endif
+
+#ifdef GDEF_COMPILER_MSVC
+#define GDEF_ATTRIBUTE_INLINE __inline
+#else
+#define GDEF_ATTRIBUTE_INLINE inline
+#endif
+
+// MISC
+
+#define GDEF_DEBUG 0
+#if defined(_DEBUG)
+#if _DEBUG
+#undef GDEF_DEBUG
+#define GDEF_DEBUG 1
+#endif
+#endif
+
+#endif
--- /dev/null
+add_library(gtkutil
+ accelerator.cpp accelerator.h
+ button.cpp button.h
+ clipboard.cpp clipboard.h
+ closure.h
+ container.h
+ cursor.cpp cursor.h
+ dialog.cpp dialog.h
+ entry.cpp entry.h
+ filechooser.cpp filechooser.h
+ frame.cpp frame.h
+ glfont.cpp glfont.h
+ glwidget.cpp glwidget.h
+ idledraw.h
+ image.cpp image.h
+ menu.cpp menu.h
+ messagebox.cpp messagebox.h
+ nonmodal.cpp nonmodal.h
+ paned.cpp paned.h
+ pointer.h
+ toolbar.cpp toolbar.h
+ widget.cpp widget.h
+ window.cpp window.h
+ xorrectangle.cpp xorrectangle.h
+ )
+
+target_include_directories(gtkutil PRIVATE uilib)
+target_link_libraries(gtkutil PRIVATE uilib)
+
+target_include_directories(gtkutil PRIVATE ${GTK${GTK_TARGET}_INCLUDE_DIRS})
+target_link_libraries(gtkutil PRIVATE ${GTK${GTK_TARGET}_LIBRARIES})
+
+if (GTK_TARGET EQUAL 2)
+ find_package(GtkGLExt REQUIRED)
+ target_include_directories(gtkutil PRIVATE ${GtkGLExt_INCLUDE_DIRS})
+ target_link_libraries(gtkutil PRIVATE ${GtkGLExt_LIBRARIES})
+endif ()
#include <map>
#include <set>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkaccelgroup.h>
+#include <gtk/gtk.h>
#include "generic/callback.h"
#include "generic/bitfield.h"
return 0;
}
k = gdk_keyval_from_name( name );
- if ( k == GDK_VoidSymbol ) {
+ if ( k == GDK_KEY_VoidSymbol ) {
return 0;
}
return k;
ostream << gtk_accelerator_get_label( accelerator.key, accelerator.modifiers );
}
-typedef std::map<Accelerator, Callback> AcceleratorMap;
+typedef std::map<Accelerator, Callback<void()>> AcceleratorMap;
typedef std::set<Accelerator> AcceleratorSet;
-bool accelerator_map_insert( AcceleratorMap& acceleratorMap, Accelerator accelerator, const Callback& callback ){
+bool accelerator_map_insert( AcceleratorMap& acceleratorMap, Accelerator accelerator, const Callback<void()>& callback ){
if ( accelerator.key != 0 ) {
return acceleratorMap.insert( AcceleratorMap::value_type( accelerator, callback ) ).second;
}
Accelerator accelerator_for_event_key( guint keyval, guint state ){
keyval = gdk_keyval_to_upper( keyval );
- if ( keyval == GDK_ISO_Left_Tab ) {
- keyval = GDK_Tab;
+ if ( keyval == GDK_KEY_ISO_Left_Tab ) {
+ keyval = GDK_KEY_Tab;
}
return Accelerator( keyval, (GdkModifierType)( state & gtk_accelerator_get_default_mod_mask() ) );
}
return false;
}
-static gboolean accelerator_key_event( GtkWindow* window, GdkEventKey* event, AcceleratorMap* acceleratorMap ){
+static gboolean accelerator_key_event( ui::Window window, GdkEventKey* event, AcceleratorMap* acceleratorMap ){
return AcceleratorMap_activate( *acceleratorMap, accelerator_for_event_key( event->keyval, event->state ) );
}
return 0;
}
-bool window_has_accel( GtkWindow* toplevel ){
+bool window_has_accel( ui::Window toplevel ){
return g_slist_length( gtk_accel_groups_from_object( G_OBJECT( toplevel ) ) ) != 0;
}
}
-GClosure* accel_group_add_accelerator( GtkAccelGroup* group, Accelerator accelerator, const Callback& callback );
-void accel_group_remove_accelerator( GtkAccelGroup* group, Accelerator accelerator );
+GClosure* accel_group_add_accelerator(ui::AccelGroup group, Accelerator accelerator, const Callback<void()>& callback );
+void accel_group_remove_accelerator(ui::AccelGroup group, Accelerator accelerator );
AcceleratorMap g_queuedAcceleratorsAdd;
AcceleratorSet g_queuedAcceleratorsRemove;
-void globalQueuedAccelerators_add( Accelerator accelerator, const Callback& callback ){
+void globalQueuedAccelerators_add( Accelerator accelerator, const Callback<void()>& callback ){
if ( !g_queuedAcceleratorsAdd.insert( AcceleratorMap::value_type( accelerator, callback ) ).second ) {
globalErrorStream() << "globalQueuedAccelerators_add: accelerator already queued: " << accelerator << "\n";
}
g_queuedAcceleratorsAdd.clear();
}
-void accel_group_test( GtkWindow* toplevel, GtkAccelGroup* accel ){
- guint n_entries;
- gtk_accel_group_query( accel, '4', (GdkModifierType)0, &n_entries );
- globalOutputStream() << "grid4: " << n_entries << "\n";
- globalOutputStream() << "toplevel accelgroups: " << g_slist_length( gtk_accel_groups_from_object( G_OBJECT( toplevel ) ) ) << "\n";
-}
-
-typedef std::set<GtkWindow*> WindowSet;
+typedef std::set<ui::Window> WindowSet;
WindowSet g_accel_windows;
bool Buttons_press( ButtonMask& buttons, guint button, guint state ){
g_accel_enabled = false;
for ( WindowSet::iterator i = g_accel_windows.begin(); i != g_accel_windows.end(); ++i )
{
- GtkWindow* toplevel = *i;
+ ui::Window toplevel = *i;
ASSERT_MESSAGE( window_has_accel( toplevel ), "ERROR" );
- ASSERT_MESSAGE( GTK_WIDGET_TOPLEVEL( toplevel ), "disabling accel for non-toplevel window" );
+ ASSERT_MESSAGE( gtk_widget_is_toplevel( toplevel ), "disabling accel for non-toplevel window" );
gtk_window_remove_accel_group( toplevel, global_accel );
#if 0
globalOutputStream() << reinterpret_cast<unsigned int>( toplevel ) << ": disabled global accelerators\n";
-#endif
-#if 0
- accel_group_test( toplevel, global_accel );
#endif
}
}
g_accel_enabled = true;
for ( WindowSet::iterator i = g_accel_windows.begin(); i != g_accel_windows.end(); ++i )
{
- GtkWindow* toplevel = *i;
+ ui::Window toplevel = *i;
ASSERT_MESSAGE( !window_has_accel( toplevel ), "ERROR" );
- ASSERT_MESSAGE( GTK_WIDGET_TOPLEVEL( toplevel ), "enabling accel for non-toplevel window" );
- gtk_window_add_accel_group( toplevel, global_accel );
+ ASSERT_MESSAGE( gtk_widget_is_toplevel( toplevel ), "enabling accel for non-toplevel window" );
+ toplevel.add_accel_group( global_accel );
#if 0
globalOutputStream() << reinterpret_cast<unsigned int>( toplevel ) << ": enabled global accelerators\n";
-#endif
-#if 0
- accel_group_test( toplevel, global_accel );
#endif
}
globalQueuedAccelerators_commit();
}
};
-gboolean PressedButtons_button_press( GtkWidget* widget, GdkEventButton* event, PressedButtons* pressed ){
+gboolean PressedButtons_button_press(ui::Widget widget, GdkEventButton* event, PressedButtons* pressed ){
if ( event->type == GDK_BUTTON_PRESS ) {
return Buttons_press( pressed->buttons, event->button, event->state );
}
return FALSE;
}
-gboolean PressedButtons_button_release( GtkWidget* widget, GdkEventButton* event, PressedButtons* pressed ){
+gboolean PressedButtons_button_release(ui::Widget widget, GdkEventButton* event, PressedButtons* pressed ){
if ( event->type == GDK_BUTTON_RELEASE ) {
return Buttons_release( pressed->buttons, event->button, event->state );
}
return FALSE;
}
-gboolean PressedButtons_focus_out( GtkWidget* widget, GdkEventFocus* event, PressedButtons* pressed ){
+gboolean PressedButtons_focus_out(ui::Widget widget, GdkEventFocus* event, PressedButtons* pressed ){
Buttons_releaseAll( pressed->buttons );
return FALSE;
}
-void PressedButtons_connect( PressedButtons& pressedButtons, GtkWidget* widget ){
- g_signal_connect( G_OBJECT( widget ), "button_press_event", G_CALLBACK( PressedButtons_button_press ), &pressedButtons );
- g_signal_connect( G_OBJECT( widget ), "button_release_event", G_CALLBACK( PressedButtons_button_release ), &pressedButtons );
- g_signal_connect( G_OBJECT( widget ), "focus_out_event", G_CALLBACK( PressedButtons_focus_out ), &pressedButtons );
+void PressedButtons_connect( PressedButtons& pressedButtons, ui::Widget widget ){
+ widget.connect( "button_press_event", G_CALLBACK( PressedButtons_button_press ), &pressedButtons );
+ widget.connect( "button_release_event", G_CALLBACK( PressedButtons_button_release ), &pressedButtons );
+ widget.connect( "focus_out_event", G_CALLBACK( PressedButtons_focus_out ), &pressedButtons );
}
PressedButtons g_pressedButtons;
#include <set>
+#include <uilib/uilib.h>
struct PressedKeys
{
keys.clear();
}
-gboolean PressedKeys_key_press( GtkWidget* widget, GdkEventKey* event, PressedKeys* pressedKeys ){
+gboolean PressedKeys_key_press(ui::Widget widget, GdkEventKey* event, PressedKeys* pressedKeys ){
//globalOutputStream() << "pressed: " << event->keyval << "\n";
//return event->state == 0 && Keys_press( pressedKeys->keys, event->keyval );
//NumLock perspective window fix
return ( event->state & ALLOWED_MODIFIERS ) == 0 && Keys_press( pressedKeys->keys, event->keyval );
}
-gboolean PressedKeys_key_release( GtkWidget* widget, GdkEventKey* event, PressedKeys* pressedKeys ){
+gboolean PressedKeys_key_release(ui::Widget widget, GdkEventKey* event, PressedKeys* pressedKeys ){
//globalOutputStream() << "released: " << event->keyval << "\n";
return Keys_release( pressedKeys->keys, event->keyval );
}
-gboolean PressedKeys_focus_in( GtkWidget* widget, GdkEventFocus* event, PressedKeys* pressedKeys ){
+gboolean PressedKeys_focus_in(ui::Widget widget, GdkEventFocus* event, PressedKeys* pressedKeys ){
++pressedKeys->refcount;
return FALSE;
}
-gboolean PressedKeys_focus_out( GtkWidget* widget, GdkEventFocus* event, PressedKeys* pressedKeys ){
+gboolean PressedKeys_focus_out(ui::Widget widget, GdkEventFocus* event, PressedKeys* pressedKeys ){
if ( --pressedKeys->refcount == 0 ) {
Keys_releaseAll( pressedKeys->keys, 0 );
}
Keys_releaseAll( g_pressedKeys.keys, 0 );
}
-void GlobalPressedKeys_connect( GtkWindow* window ){
- unsigned int key_press_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( PressedKeys_key_press ), &g_pressedKeys );
- unsigned int key_release_handler = g_signal_connect( G_OBJECT( window ), "key_release_event", G_CALLBACK( PressedKeys_key_release ), &g_pressedKeys );
+void GlobalPressedKeys_connect( ui::Window window ){
+ unsigned int key_press_handler = window.connect( "key_press_event", G_CALLBACK( PressedKeys_key_press ), &g_pressedKeys );
+ unsigned int key_release_handler = window.connect( "key_release_event", G_CALLBACK( PressedKeys_key_release ), &g_pressedKeys );
g_object_set_data( G_OBJECT( window ), "key_press_handler", gint_to_pointer( key_press_handler ) );
g_object_set_data( G_OBJECT( window ), "key_release_handler", gint_to_pointer( key_release_handler ) );
- unsigned int focus_in_handler = g_signal_connect( G_OBJECT( window ), "focus_in_event", G_CALLBACK( PressedKeys_focus_in ), &g_pressedKeys );
- unsigned int focus_out_handler = g_signal_connect( G_OBJECT( window ), "focus_out_event", G_CALLBACK( PressedKeys_focus_out ), &g_pressedKeys );
+ unsigned int focus_in_handler = window.connect( "focus_in_event", G_CALLBACK( PressedKeys_focus_in ), &g_pressedKeys );
+ unsigned int focus_out_handler = window.connect( "focus_out_event", G_CALLBACK( PressedKeys_focus_out ), &g_pressedKeys );
g_object_set_data( G_OBJECT( window ), "focus_in_handler", gint_to_pointer( focus_in_handler ) );
g_object_set_data( G_OBJECT( window ), "focus_out_handler", gint_to_pointer( focus_out_handler ) );
}
-void GlobalPressedKeys_disconnect( GtkWindow* window ){
+void GlobalPressedKeys_disconnect( ui::Window window ){
g_signal_handler_disconnect( G_OBJECT( window ), gpointer_to_int( g_object_get_data( G_OBJECT( window ), "key_press_handler" ) ) );
g_signal_handler_disconnect( G_OBJECT( window ), gpointer_to_int( g_object_get_data( G_OBJECT( window ), "key_release_handler" ) ) );
g_signal_handler_disconnect( G_OBJECT( window ), gpointer_to_int( g_object_get_data( G_OBJECT( window ), "focus_in_handler" ) ) );
-void special_accelerators_add( Accelerator accelerator, const Callback& callback ){
+void special_accelerators_add( Accelerator accelerator, const Callback<void()>& callback ){
//globalOutputStream() << "special_accelerators_add: " << makeQuoted(accelerator) << "\n";
if ( !accelerator_map_insert( g_special_accelerators, accelerator, callback ) ) {
globalErrorStream() << "special_accelerators_add: already exists: " << makeQuoted( accelerator ) << "\n";
}
}
-void keydown_accelerators_add( Accelerator accelerator, const Callback& callback ){
+void keydown_accelerators_add( Accelerator accelerator, const Callback<void()>& callback ){
//globalOutputStream() << "keydown_accelerators_add: " << makeQuoted(accelerator) << "\n";
if ( !accelerator_map_insert( g_keydown_accelerators, accelerator, callback ) ) {
globalErrorStream() << "keydown_accelerators_add: already exists: " << makeQuoted( accelerator ) << "\n";
}
}
-void keyup_accelerators_add( Accelerator accelerator, const Callback& callback ){
+void keyup_accelerators_add( Accelerator accelerator, const Callback<void()>& callback ){
//globalOutputStream() << "keyup_accelerators_add: " << makeQuoted(accelerator) << "\n";
if ( !accelerator_map_insert( g_keyup_accelerators, accelerator, callback ) ) {
globalErrorStream() << "keyup_accelerators_add: already exists: " << makeQuoted( accelerator ) << "\n";
}
-gboolean accel_closure_callback( GtkAccelGroup* group, GtkWidget* widget, guint key, GdkModifierType modifiers, gpointer data ){
- ( *reinterpret_cast<Callback*>( data ) )( );
+gboolean accel_closure_callback(ui::AccelGroup group, ui::Widget widget, guint key, GdkModifierType modifiers, gpointer data ){
+ ( *reinterpret_cast<Callback<void()>*>( data ) )( );
return TRUE;
}
-GClosure* accel_group_add_accelerator( GtkAccelGroup* group, Accelerator accelerator, const Callback& callback ){
+GClosure* accel_group_add_accelerator(ui::AccelGroup group, Accelerator accelerator, const Callback<void()>& callback ){
if ( accelerator.key != 0 && gtk_accelerator_valid( accelerator.key, accelerator.modifiers ) ) {
//globalOutputStream() << "global_accel_connect: " << makeQuoted(accelerator) << "\n";
GClosure* closure = create_cclosure( G_CALLBACK( accel_closure_callback ), callback );
}
}
-void accel_group_remove_accelerator( GtkAccelGroup* group, Accelerator accelerator ){
+void accel_group_remove_accelerator(ui::AccelGroup group, Accelerator accelerator ){
if ( accelerator.key != 0 && gtk_accelerator_valid( accelerator.key, accelerator.modifiers ) ) {
//globalOutputStream() << "global_accel_disconnect: " << makeQuoted(accelerator) << "\n";
gtk_accel_group_disconnect_key( group, accelerator.key, accelerator.modifiers );
}
}
-GtkAccelGroup* global_accel = 0;
-
-void global_accel_init(){
- global_accel = gtk_accel_group_new();
-}
-
-void global_accel_destroy(){
- g_object_unref( global_accel );
-}
+ui::AccelGroup global_accel{ui::New};
-GClosure* global_accel_group_add_accelerator( Accelerator accelerator, const Callback& callback ){
+GClosure* global_accel_group_add_accelerator( Accelerator accelerator, const Callback<void()>& callback ){
if ( !global_accel_enabled() ) {
// workaround: cannot add to GtkAccelGroup while it is disabled
//globalOutputStream() << "queued for add: " << accelerator << "\n";
}
/// \brief Propagates key events to the focus-widget, overriding global accelerators.
-static gboolean override_global_accelerators( GtkWindow* window, GdkEventKey* event, gpointer data ){
+static gboolean override_global_accelerators( ui::Window window, GdkEventKey* event, gpointer data ){
gboolean b = gtk_window_propagate_key_event( window, event );
return b;
}
-void global_accel_connect_window( GtkWindow* window ){
+void global_accel_connect_window( ui::Window window ){
#if 1
- unsigned int override_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( override_global_accelerators ), 0 );
+ unsigned int override_handler = window.connect( "key_press_event", G_CALLBACK( override_global_accelerators ), 0 );
g_object_set_data( G_OBJECT( window ), "override_handler", gint_to_pointer( override_handler ) );
- unsigned int special_key_press_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( accelerator_key_event ), &g_special_accelerators );
+ unsigned int special_key_press_handler = window.connect( "key_press_event", G_CALLBACK( accelerator_key_event ), &g_special_accelerators );
g_object_set_data( G_OBJECT( window ), "special_key_press_handler", gint_to_pointer( special_key_press_handler ) );
GlobalPressedKeys_connect( window );
#else
- unsigned int key_press_handler = g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( accelerator_key_event ), &g_keydown_accelerators );
- unsigned int key_release_handler = g_signal_connect( G_OBJECT( window ), "key_release_event", G_CALLBACK( accelerator_key_event ), &g_keyup_accelerators );
+ unsigned int key_press_handler = window.connect( "key_press_event", G_CALLBACK( accelerator_key_event ), &g_keydown_accelerators );
+ unsigned int key_release_handler = window.connect( "key_release_event", G_CALLBACK( accelerator_key_event ), &g_keyup_accelerators );
g_object_set_data( G_OBJECT( window ), "key_press_handler", gint_to_pointer( key_press_handler ) );
g_object_set_data( G_OBJECT( window ), "key_release_handler", gint_to_pointer( key_release_handler ) );
#endif
g_accel_windows.insert( window );
- gtk_window_add_accel_group( window, global_accel );
+ window.add_accel_group( global_accel );
}
-void global_accel_disconnect_window( GtkWindow* window ){
+void global_accel_disconnect_window( ui::Window window ){
#if 1
GlobalPressedKeys_disconnect( window );
return 0;
}
-void global_accel_group_connect( const Accelerator& accelerator, const Callback& callback ){
+void global_accel_group_connect( const Accelerator& accelerator, const Callback<void()>& callback ){
if ( accelerator.key != 0 ) {
global_accel_group_add_accelerator( accelerator, callback );
}
}
-void global_accel_group_disconnect( const Accelerator& accelerator, const Callback& callback ){
+void global_accel_group_disconnect( const Accelerator& accelerator, const Callback<void()>& callback ){
if ( accelerator.key != 0 ) {
global_accel_group_remove_accelerator( accelerator );
}
#if !defined( INCLUDED_GTKUTIL_ACCELERATOR_H )
#define INCLUDED_GTKUTIL_ACCELERATOR_H
-#include <gdk/gdktypes.h>
-#include <gdk/gdkkeysyms.h>
-#include <gdk/gdkkeys.h>
+#include <uilib/uilib.h>
+#include <gdk/gdk.h>
#include "generic/callback.h"
+#include "property.h"
// ignore numlock
#define ALLOWED_MODIFIERS ( ~( GDK_MOD2_MASK | GDK_LOCK_MASK | GDK_MOD3_MASK | GDK_MOD4_MASK | GDK_MOD5_MASK ) )
return ostream;
}
-void keydown_accelerators_add( Accelerator accelerator, const Callback& callback );
+void keydown_accelerators_add( Accelerator accelerator, const Callback<void()>& callback );
void keydown_accelerators_remove( Accelerator accelerator );
-void keyup_accelerators_add( Accelerator accelerator, const Callback& callback );
+void keyup_accelerators_add( Accelerator accelerator, const Callback<void()>& callback );
void keyup_accelerators_remove( Accelerator accelerator );
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-void global_accel_connect_window( GtkWindow* window );
-void global_accel_disconnect_window( GtkWindow* window );
+void global_accel_connect_window( ui::Window window );
+void global_accel_disconnect_window( ui::Window window );
void GlobalPressedKeys_releaseAll();
-typedef struct _GtkAccelGroup GtkAccelGroup;
-extern GtkAccelGroup* global_accel;
-void global_accel_init();
-void global_accel_destroy();
+extern ui::AccelGroup global_accel;
GClosure* global_accel_group_find( Accelerator accelerator );
-void global_accel_group_connect( const Accelerator& accelerator, const Callback& callback );
-void global_accel_group_disconnect( const Accelerator& accelerator, const Callback& callback );
+void global_accel_group_connect( const Accelerator& accelerator, const Callback<void()>& callback );
+void global_accel_group_disconnect( const Accelerator& accelerator, const Callback<void()>& callback );
class Command
{
public:
-Callback m_callback;
+Callback<void()> m_callback;
const Accelerator& m_accelerator;
-Command( const Callback& callback, const Accelerator& accelerator ) : m_callback( callback ), m_accelerator( accelerator ){
+Command( const Callback<void()>& callback, const Accelerator& accelerator ) : m_callback( callback ), m_accelerator( accelerator ){
}
};
{
public:
Command m_command;
-BoolExportCallback m_exportCallback;
-Toggle( const Callback& callback, const Accelerator& accelerator, const BoolExportCallback& exportCallback ) : m_command( callback, accelerator ), m_exportCallback( exportCallback ){
+Callback<void(const Callback<void(bool)> &)> m_exportCallback;
+Toggle( const Callback<void()>& callback, const Accelerator& accelerator, const Callback<void(const Callback<void(bool)> &)>& exportCallback ) : m_command( callback, accelerator ), m_exportCallback( exportCallback ){
}
};
{
public:
const Accelerator& m_accelerator;
-Callback m_keyDown;
-Callback m_keyUp;
-KeyEvent( const Accelerator& accelerator, const Callback& keyDown, const Callback& keyUp ) : m_accelerator( accelerator ), m_keyDown( keyDown ), m_keyUp( keyUp ){
+Callback<void()> m_keyDown;
+Callback<void()> m_keyUp;
+KeyEvent( const Accelerator& accelerator, const Callback<void()>& keyDown, const Callback<void()>& keyUp ) : m_accelerator( accelerator ), m_keyDown( keyDown ), m_keyUp( keyUp ){
}
};
struct PressedButtons;
-typedef struct _GtkWidget GtkWidget;
-void PressedButtons_connect( PressedButtons& pressedButtons, GtkWidget* widget );
+void PressedButtons_connect( PressedButtons& pressedButtons, ui::Widget widget );
extern PressedButtons g_pressedButtons;
#include "button.h"
-#include <gtk/gtkradiobutton.h>
+#include <gtk/gtk.h>
#include "stream/textstream.h"
#include "stream/stringstream.h"
#include "image.h"
#include "pointer.h"
-void clicked_closure_callback( GtkWidget* widget, gpointer data ){
- ( *reinterpret_cast<Callback*>( data ) )( );
+void clicked_closure_callback( ui::Widget widget, gpointer data ){
+ ( *reinterpret_cast<Callback<void()>*>( data ) )( );
}
-void button_connect_callback( GtkButton* button, const Callback& callback ){
+void button_connect_callback( ui::Button button, const Callback<void()>& callback ){
#if 1
g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
#else
#endif
}
-guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& callback ){
+void button_connect_callback( ui::ToolButton button, const Callback<void()>& callback ){
+#if 1
+ g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
+#else
+ g_signal_connect_closure( G_OBJECT( button ), "clicked", create_cclosure( G_CALLBACK( clicked_closure_callback ), callback ), FALSE );
+#endif
+}
+
+guint toggle_button_connect_callback( ui::ToggleButton button, const Callback<void()>& callback ){
#if 1
guint handler = g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
#else
return handler;
}
-void button_set_icon( GtkButton* button, const char* icon ){
- GtkImage* image = new_local_image( icon );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_container_add( GTK_CONTAINER( button ), GTK_WIDGET( image ) );
+guint toggle_button_connect_callback( ui::ToggleToolButton button, const Callback<void()>& callback ){
+#if 1
+ guint handler = g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
+#else
+ guint handler = g_signal_connect_closure( G_OBJECT( button ), "toggled", create_cclosure( G_CALLBACK( clicked_closure_callback ), callback ), TRUE );
+#endif
+ g_object_set_data( G_OBJECT( button ), "handler", gint_to_pointer( handler ) );
+ return handler;
+}
+
+void button_set_icon( ui::Button button, const char* icon ){
+ ui::Image image = ui::Image(new_local_image( icon ));
+ image.show();
+ button.add(image);
}
-void toggle_button_set_active_no_signal( GtkToggleButton* button, gboolean active ){
+void toggle_button_set_active_no_signal( ui::ToggleButton button, gboolean active ){
//globalOutputStream() << "set active: " << active << "\n";
guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( button ), "handler" ) );
//guint signal_id = g_signal_lookup("toggled", G_OBJECT_TYPE (button));
g_signal_handler_unblock( G_OBJECT( button ), handler_id );
}
+void toggle_button_set_active_no_signal( ui::ToggleToolButton button, gboolean active ){
+ guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( button ), "handler" ) );
+ g_signal_handler_block( G_OBJECT( button ), handler_id );
+ gtk_toggle_tool_button_set_active( button, active );
+ g_signal_handler_unblock( G_OBJECT( button ), handler_id );
+}
+
-void radio_button_print_state( GtkRadioButton* button ){
+void radio_button_print_state( ui::RadioButton button ){
globalOutputStream() << "toggle button: ";
- for ( GSList* radio = gtk_radio_button_group( button ); radio != 0; radio = g_slist_next( radio ) )
+ for ( GSList* radio = gtk_radio_button_get_group( button ); radio != 0; radio = g_slist_next( radio ) )
{
globalOutputStream() << gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radio->data ) );
}
globalOutputStream() << "\n";
}
-GtkToggleButton* radio_button_get_nth( GtkRadioButton* radio, int index ){
- GSList *group = gtk_radio_button_group( radio );
- return GTK_TOGGLE_BUTTON( g_slist_nth_data( group, g_slist_length( group ) - index - 1 ) );
+ui::ToggleButton radio_button_get_nth( ui::RadioButton radio, int index ){
+ GSList *group = gtk_radio_button_get_group( radio );
+ return ui::ToggleButton::from( g_slist_nth_data( group, g_slist_length( group ) - index - 1 ) );
}
-void radio_button_set_active( GtkRadioButton* radio, int index ){
+void radio_button_set_active( ui::RadioButton radio, int index ){
//radio_button_print_state(radio);
gtk_toggle_button_set_active( radio_button_get_nth( radio, index ), TRUE );
//radio_button_print_state(radio);
}
-void radio_button_set_active_no_signal( GtkRadioButton* radio, int index ){
+void radio_button_set_active_no_signal( ui::RadioButton radio, int index ){
{
for ( GSList* l = gtk_radio_button_get_group( radio ); l != 0; l = g_slist_next( l ) )
{
}
}
-int radio_button_get_active( GtkRadioButton* radio ){
+int radio_button_get_active( ui::RadioButton radio ){
//radio_button_print_state(radio);
- GSList *group = gtk_radio_button_group( radio );
+ GSList *group = gtk_radio_button_get_group( radio );
int index = g_slist_length( group ) - 1;
for (; group != 0; group = g_slist_next( group ) )
{
#if !defined( INCLUDED_GTKUTIL_BUTTON_H )
#define INCLUDED_GTKUTIL_BUTTON_H
-#include "generic/callbackfwd.h"
+#include <uilib/uilib.h>
+#include "generic/callback.h"
-typedef struct _GtkButton GtkButton;
-typedef struct _GtkToggleButton GtkToggleButton;
-typedef struct _GtkRadioButton GtkRadioButton;
typedef int gint;
typedef gint gboolean;
typedef unsigned int guint;
-void button_connect_callback( GtkButton* button, const Callback& callback );
-guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& callback );
+void button_connect_callback( ui::Button button, const Callback<void()>& callback );
+void button_connect_callback( ui::ToolButton button, const Callback<void()>& callback );
+guint toggle_button_connect_callback( ui::ToggleButton button, const Callback<void()>& callback );
+guint toggle_button_connect_callback( ui::ToggleToolButton button, const Callback<void()>& callback );
-void button_set_icon( GtkButton* button, const char* icon );
-void toggle_button_set_active_no_signal( GtkToggleButton* item, gboolean active );
+void button_set_icon( ui::Button button, const char* icon );
+void toggle_button_set_active_no_signal( ui::ToggleButton item, gboolean active );
+void toggle_button_set_active_no_signal( ui::ToggleToolButton item, gboolean active );
-void radio_button_set_active( GtkRadioButton* radio, int index );
-void radio_button_set_active_no_signal( GtkRadioButton* radio, int index );
-int radio_button_get_active( GtkRadioButton* radio );
+void radio_button_set_active( ui::RadioButton radio, int index );
+void radio_button_set_active_no_signal( ui::RadioButton radio, int index );
+int radio_button_get_active( ui::RadioButton radio );
#endif
#include "clipboard.h"
+#include "globaldefs.h"
#include "stream/memstream.h"
#include "stream/textstream.h"
/// \file
/// \brief Platform-independent GTK clipboard support.
/// \todo Using GDK_SELECTION_CLIPBOARD fails on win32, so we use the win32 API directly for now.
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
const char* c_clipboard_format = "RadiantClippings";
#else
-#include <gtk/gtkclipboard.h>
+#include <gtk/gtk.h>
enum
{
RADIANT_CLIPPINGS = 23,
};
+static char RADIANT_CLIPPINGS_STR[] = "RADIANT_CLIPPINGS";
+
static const GtkTargetEntry clipboard_targets[] = {
- { "RADIANT_CLIPPINGS", 0, RADIANT_CLIPPINGS, },
+ {RADIANT_CLIPPINGS_STR, 0, RADIANT_CLIPPINGS, },
};
static void clipboard_get( GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, gpointer data ){
}
static void clipboard_received( GtkClipboard *clipboard, GtkSelectionData *data, gpointer user_data ){
- if ( data->length < 0 ) {
+ if ( gtk_selection_data_get_length(data) < 0 ) {
globalErrorStream() << "Error retrieving selection\n";
}
- else if ( strcmp( gdk_atom_name( data->type ), clipboard_targets[0].target ) == 0 ) {
- BufferInputStream istream( reinterpret_cast<const char*>( data->data ), data->length );
+ else if ( strcmp( gdk_atom_name( gtk_selection_data_get_data_type(data) ), clipboard_targets[0].target ) == 0 ) {
+ BufferInputStream istream( reinterpret_cast<const char*>( gtk_selection_data_get_data(data) ), gtk_selection_data_get_length(data) );
( *reinterpret_cast<ClipboardPasteFunc*>( user_data ) )( istream );
}
}
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "closure.h"
#include "generic/callback.h"
inline void closure_destroy( gpointer data, GClosure* closure ){
- delete reinterpret_cast<Callback*>( data );
+ delete reinterpret_cast<Callback<void()>*>( data );
}
-inline GClosure* create_cclosure( GCallback func, const Callback& callback ){
- return g_cclosure_new( func, new Callback( callback ), closure_destroy );
+inline GClosure* create_cclosure( GCallback func, const Callback<void()>& callback ){
+ return g_cclosure_new( func, new Callback<void()>( callback ), closure_destroy );
}
inline GValue GValue_default(){
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "container.h"
#if !defined( INCLUDED_GTKUTIL_CONTAINER_H )
#define INCLUDED_GTKUTIL_CONTAINER_H
-#include <gtk/gtkcontainer.h>
-
-inline GtkWidget* container_add_widget( GtkContainer* container, GtkWidget* widget ){
- gtk_container_add( container, widget );
- return widget;
-}
-
-inline void container_remove( GtkWidget* item, gpointer data ){
- gtk_container_remove( GTK_CONTAINER( data ), item );
-}
-
-inline void container_remove_all( GtkContainer* container ){
- gtk_container_foreach( container, container_remove, container );
+inline void container_remove_all(ui::Container container)
+{
+ container.foreach([=](ui::Widget it) mutable {
+ container.remove(it);
+ });
}
#endif
#include "stream/textstream.h"
#include <string.h>
-#include <gdk/gdkcursor.h>
-#include <gdk/gdkpixmap.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
#if 0
GdkCursor* create_blank_cursor(){
- GdkPixmap *pixmap;
- GdkBitmap *mask;
- char buffer [( 32 * 32 ) / 8];
- memset( buffer, 0, ( 32 * 32 ) / 8 );
- GdkColor white = {0, 0xffff, 0xffff, 0xffff};
- GdkColor black = {0, 0x0000, 0x0000, 0x0000};
- pixmap = gdk_bitmap_create_from_data( 0, buffer, 32, 32 );
- mask = gdk_bitmap_create_from_data( 0, buffer, 32, 32 );
- GdkCursor *cursor = gdk_cursor_new_from_pixmap( pixmap, mask, &white, &black, 1, 1 );
- gdk_drawable_unref( pixmap );
- gdk_drawable_unref( mask );
-
- return cursor;
+ return gdk_cursor_new(GDK_BLANK_CURSOR);
}
-void blank_cursor( GtkWidget* widget ){
+void blank_cursor( ui::Widget widget ){
GdkCursor* cursor = create_blank_cursor();
- gdk_window_set_cursor( widget->window, cursor );
+ gdk_window_set_cursor( gtk_widget_get_window(widget), cursor );
gdk_cursor_unref( cursor );
}
-void default_cursor( GtkWidget* widget ){
- gdk_window_set_cursor( widget->window, 0 );
+void default_cursor( ui::Widget widget ){
+ gdk_window_set_cursor( gtk_widget_get_window(widget), 0 );
}
#endif
-void Sys_GetCursorPos( GtkWindow* window, int *x, int *y ){
+void Sys_GetCursorPos( ui::Window window, int *x, int *y ){
gdk_display_get_pointer( gdk_display_get_default(), 0, x, y, 0 );
}
-void Sys_SetCursorPos( GtkWindow* window, int x, int y ){
+void Sys_SetCursorPos( ui::Window window, int x, int y ){
GdkScreen *screen;
gdk_display_get_pointer( gdk_display_get_default(), &screen, 0, 0, 0 );
gdk_display_warp_pointer( gdk_display_get_default(), screen, x, y );
}
+
+gboolean DeferredMotion::gtk_motion(ui::Widget widget, GdkEventMotion *event, DeferredMotion *self)
+{
+ self->motion( event->x, event->y, event->state );
+ return FALSE;
+}
+
+gboolean FreezePointer::motion_delta(ui::Window widget, GdkEventMotion *event, FreezePointer *self)
+{
+ int current_x, current_y;
+ Sys_GetCursorPos( widget, ¤t_x, ¤t_y );
+ int dx = current_x - self->last_x;
+ int dy = current_y - self->last_y;
+ int ddx = current_x - self->center_x;
+ int ddy = current_y - self->center_y;
+ self->last_x = current_x;
+ self->last_y = current_y;
+ if ( dx != 0 || dy != 0 ) {
+ //globalOutputStream() << "motion x: " << dx << ", y: " << dy << "\n";
+ if (ddx < -32 || ddx > 32 || ddy < -32 || ddy > 32) {
+ Sys_SetCursorPos( widget, self->center_x, self->center_y );
+ self->last_x = self->center_x;
+ self->last_y = self->center_y;
+ }
+ self->m_function( dx, dy, event->state, self->m_data );
+ }
+ return FALSE;
+}
+
+void FreezePointer::freeze_pointer(ui::Window window, ui::Widget widget, FreezePointer::MotionDeltaFunction function, void *data)
+{
+ ASSERT_MESSAGE( m_function == 0, "can't freeze pointer" );
+
+ const GdkEventMask mask = static_cast<GdkEventMask>( GDK_POINTER_MOTION_MASK
+ | GDK_POINTER_MOTION_HINT_MASK
+ | GDK_BUTTON_MOTION_MASK
+ | GDK_BUTTON1_MOTION_MASK
+ | GDK_BUTTON2_MOTION_MASK
+ | GDK_BUTTON3_MOTION_MASK
+ | GDK_BUTTON_PRESS_MASK
+ | GDK_BUTTON_RELEASE_MASK
+ | GDK_VISIBILITY_NOTIFY_MASK );
+
+ //GdkCursor* cursor = create_blank_cursor();
+ GdkCursor* cursor = gdk_cursor_new( GDK_BLANK_CURSOR );
+ //GdkGrabStatus status =
+ /* fixes cursor runaways during srsly quick drags in camera
+ drags with pressed buttons have no problem at all w/o this */
+ gdk_pointer_grab( gtk_widget_get_window(window), TRUE, mask, 0, cursor, GDK_CURRENT_TIME );
+ //gdk_window_set_cursor ( GTK_WIDGET( window )->window, cursor );
+ /* is needed to fix activating neighbour widgets, that happens, if using upper one */
+ gtk_grab_add( widget );
+ m_weedjet = widget;
+
+ gdk_cursor_unref( cursor );
+
+ Sys_GetCursorPos( window, &recorded_x, &recorded_y );
+
+ /* using center for tracking for max safety */
+ gdk_window_get_origin( GTK_WIDGET( widget )->window, ¢er_x, ¢er_y );
+ auto allocation = widget.dimensions();
+ center_y += allocation.height / 2;
+ center_x += allocation.width / 2;
+
+ Sys_SetCursorPos( window, center_x, center_y );
+
+ last_x = center_x;
+ last_y = center_y;
+
+ m_function = function;
+ m_data = data;
+
+ handle_motion = window.connect( "motion_notify_event", G_CALLBACK( motion_delta ), this );
+}
+
+void FreezePointer::unfreeze_pointer(ui::Window window, bool centerize )
+{
+ g_signal_handler_disconnect( G_OBJECT( window ), handle_motion );
+
+ m_function = 0;
+ m_data = 0;
+
+ if ( centerize ){
+ Sys_SetCursorPos( window, center_x, center_y );
+ }
+ else{
+ Sys_SetCursorPos( window, recorded_x, recorded_y );
+ }
+
+// gdk_window_set_cursor( GTK_WIDGET( window )->window, 0 );
+ gdk_pointer_ungrab( GDK_CURRENT_TIME );
+
+ if ( m_weedjet )
+ {
+ gtk_grab_remove( m_weedjet );
+ }
+}
#if !defined( INCLUDED_GTKUTIL_CURSOR_H )
#define INCLUDED_GTKUTIL_CURSOR_H
-#include <glib.h>
-#include <gdk/gdkevents.h>
-#include <gtk/gtkwidget.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkmain.h>
+#include <uilib/uilib.h>
#include "debugging/debugging.h"
typedef struct _GdkCursor GdkCursor;
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
+typedef struct _GdkEventMotion GdkEventMotion;
#if 0
GdkCursor* create_blank_cursor();
-void blank_cursor( GtkWidget* widget );
-void default_cursor( GtkWidget* widget );
+void blank_cursor( ui::Widget widget );
+void default_cursor( ui::Widget widget );
#endif
-void Sys_GetCursorPos( GtkWindow* window, int *x, int *y );
-void Sys_SetCursorPos( GtkWindow* window, int x, int y );
+void Sys_GetCursorPos( ui::Window window, int *x, int *y );
+void Sys_SetCursorPos( ui::Window window, int x, int y );
m_handler = g_idle_add( (GSourceFunc)deferred, this );
}
}
-static gboolean gtk_motion( GtkWidget *widget, GdkEventMotion *event, DeferredMotion* self ){
- self->motion( event->x, event->y, event->state );
- return FALSE;
-}
+static gboolean gtk_motion( ui::Widget widget, GdkEventMotion *event, DeferredMotion* self );
};
class DeferredMotionDelta
{
unsigned int handle_motion;
int recorded_x, recorded_y, last_x, last_y, center_x, center_y;
-GtkWidget* m_weedjet;
+ui::Widget m_weedjet{ui::null};
typedef void ( *MotionDeltaFunction )( int x, int y, unsigned int state, void* data );
MotionDeltaFunction m_function;
void* m_data;
public:
FreezePointer() : handle_motion( 0 ), m_function( 0 ), m_data( 0 ){
}
-static gboolean motion_delta( GtkWidget *widget, GdkEventMotion *event, FreezePointer* self ){
- int current_x, current_y;
- Sys_GetCursorPos( GTK_WINDOW( widget ), ¤t_x, ¤t_y );
- int dx = current_x - self->last_x;
- int dy = current_y - self->last_y;
- int ddx = current_x - self->center_x;
- int ddy = current_y - self->center_y;
- self->last_x = current_x;
- self->last_y = current_y;
- if ( dx != 0 || dy != 0 ) {
- //globalOutputStream() << "motion x: " << dx << ", y: " << dy << "\n";
- if (ddx < -32 || ddx > 32 || ddy < -32 || ddy > 32) {
- Sys_SetCursorPos( GTK_WINDOW( widget ), self->center_x, self->center_y );
- self->last_x = self->center_x;
- self->last_y = self->center_y;
- }
- self->m_function( dx, dy, event->state, self->m_data );
- }
- return FALSE;
-}
-
-void freeze_pointer( GtkWindow* window, GtkWidget* widget, MotionDeltaFunction function, void* data ){
- ASSERT_MESSAGE( m_function == 0, "can't freeze pointer" );
-
- const GdkEventMask mask = static_cast<GdkEventMask>( GDK_POINTER_MOTION_MASK
- | GDK_POINTER_MOTION_HINT_MASK
- | GDK_BUTTON_MOTION_MASK
- | GDK_BUTTON1_MOTION_MASK
- | GDK_BUTTON2_MOTION_MASK
- | GDK_BUTTON3_MOTION_MASK
- | GDK_BUTTON_PRESS_MASK
- | GDK_BUTTON_RELEASE_MASK
- | GDK_VISIBILITY_NOTIFY_MASK );
-
- GdkCursor* cursor = gdk_cursor_new( GDK_BLANK_CURSOR );
- //GdkCursor* cursor = create_blank_cursor();
- //GdkGrabStatus status =
- /* fixes cursor runaways during srsly quick drags in camera
- drags with pressed buttons have no problem at all w/o this */
- gdk_pointer_grab( GTK_WIDGET( window )->window, TRUE, mask, 0, cursor, GDK_CURRENT_TIME );
- //gdk_window_set_cursor ( GTK_WIDGET( window )->window, cursor );
- /* is needed to fix activating neighbour widgets, that happens, if using upper one */
- gtk_grab_add( widget );
- m_weedjet = widget;
-
- gdk_cursor_unref( cursor );
-
- Sys_GetCursorPos( window, &recorded_x, &recorded_y );
-
- /* using center for tracking for max safety */
- gdk_window_get_origin( widget->window, ¢er_x, ¢er_y );
- center_y += widget->allocation.height / 2;
- center_x += widget->allocation.width / 2;
-
- Sys_SetCursorPos( window, center_x, center_y );
-
- last_x = center_x;
- last_y = center_y;
-
- m_function = function;
- m_data = data;
-
- handle_motion = g_signal_connect( G_OBJECT( window ), "motion_notify_event", G_CALLBACK( motion_delta ), this );
-}
-
-void unfreeze_pointer( GtkWindow* window, bool centerize ){
- g_signal_handler_disconnect( G_OBJECT( window ), handle_motion );
+static gboolean motion_delta( ui::Window widget, GdkEventMotion *event, FreezePointer* self );
- m_function = 0;
- m_data = 0;
+void freeze_pointer( ui::Window window, ui::Widget widget, MotionDeltaFunction function, void* data );
- if( centerize ){
- Sys_SetCursorPos( window, center_x, center_y );
- }
- else{
- Sys_SetCursorPos( window, recorded_x, recorded_y );
- }
-// gdk_window_set_cursor( GTK_WIDGET( window )->window, 0 );
- gdk_pointer_ungrab( GDK_CURRENT_TIME );
- if( m_weedjet )
- gtk_grab_remove( m_weedjet );
-}
+void unfreeze_pointer( ui::Window window, bool centerize );
};
#endif
#include "dialog.h"
-#include <gtk/gtkmain.h>
-#include <gtk/gtkalignment.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkradiobutton.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtklabel.h>
+#include <gtk/gtk.h>
#include "button.h"
#include "window.h"
-GtkVBox* create_dialog_vbox( int spacing, int border ){
- GtkVBox* vbox = GTK_VBOX( gtk_vbox_new( FALSE, spacing ) );
- gtk_widget_show( GTK_WIDGET( vbox ) );
+ui::VBox create_dialog_vbox( int spacing, int border ){
+ auto vbox = ui::VBox( FALSE, spacing );
+ vbox.show();
gtk_container_set_border_width( GTK_CONTAINER( vbox ), border );
return vbox;
}
-GtkHBox* create_dialog_hbox( int spacing, int border ){
- GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( FALSE, spacing ) );
- gtk_widget_show( GTK_WIDGET( hbox ) );
+ui::HBox create_dialog_hbox( int spacing, int border ){
+ auto hbox = ui::HBox( FALSE, spacing );
+ hbox.show();
gtk_container_set_border_width( GTK_CONTAINER( hbox ), border );
return hbox;
}
-GtkFrame* create_dialog_frame( const char* label, GtkShadowType shadow ){
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( label ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
- gtk_frame_set_shadow_type( frame, shadow );
+ui::Frame create_dialog_frame( const char* label, ui::Shadow shadow ){
+ auto frame = ui::Frame( label );
+ frame.show();
+ gtk_frame_set_shadow_type( frame, (GtkShadowType) shadow );
return frame;
}
-GtkTable* create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border ){
- GtkTable* table = GTK_TABLE( gtk_table_new( rows, columns, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
+ui::Table create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border ){
+ auto table = ui::Table( rows, columns, FALSE );
+ table.show();
gtk_table_set_row_spacings( table, row_spacing );
gtk_table_set_col_spacings( table, col_spacing );
gtk_container_set_border_width( GTK_CONTAINER( table ), border );
return table;
}
-GtkButton* create_dialog_button( const char* label, GCallback func, gpointer data ){
- GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( label ) );
- gtk_widget_set_size_request( GTK_WIDGET( button ), 64, -1 );
- gtk_widget_show( GTK_WIDGET( button ) );
- g_signal_connect( G_OBJECT( button ), "clicked", func, data );
+ui::Button create_dialog_button( const char* label, GCallback func, gpointer data ){
+ auto button = ui::Button( label );
+ button.dimensions(64, -1);
+ button.show();
+ button.connect( "clicked", func, data );
return button;
}
-GtkWindow* create_dialog_window( GtkWindow* parent, const char* title, GCallback func, gpointer data, int default_w, int default_h ){
- GtkWindow* window = create_floating_window( title, parent );
+ui::Window create_dialog_window( ui::Window parent, const char* title, GCallback func, gpointer data, int default_w, int default_h ){
+ ui::Window window = create_floating_window( title, parent );
gtk_window_set_default_size( window, default_w, default_h );
gtk_window_set_position( window, GTK_WIN_POS_CENTER_ON_PARENT );
- g_signal_connect( G_OBJECT( window ), "delete_event", func, data );
+ window.connect( "delete_event", func, data );
return window;
}
-gboolean modal_dialog_button_clicked( GtkWidget *widget, ModalDialogButton* button ){
+gboolean modal_dialog_button_clicked( ui::Widget widget, ModalDialogButton* button ){
button->m_dialog.loop = false;
button->m_dialog.ret = button->m_value;
return TRUE;
}
-gboolean modal_dialog_delete( GtkWidget *widget, GdkEvent* event, ModalDialog* dialog ){
+gboolean modal_dialog_delete( ui::Widget widget, GdkEvent* event, ModalDialog* dialog ){
dialog->loop = 0;
dialog->ret = eIDCANCEL;
return TRUE;
}
-EMessageBoxReturn modal_dialog_show( GtkWindow* window, ModalDialog& dialog ){
- gtk_grab_add( GTK_WIDGET( window ) );
- gtk_widget_show( GTK_WIDGET( window ) );
+EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog ){
+ gtk_grab_add( window );
+ window.show();
dialog.loop = true;
while ( dialog.loop )
gtk_main_iteration();
}
- gtk_widget_hide( GTK_WIDGET( window ) );
- gtk_grab_remove( GTK_WIDGET( window ) );
+ window.hide();
+ gtk_grab_remove( window );
return dialog.ret;
}
-GtkButton* create_modal_dialog_button( const char* label, ModalDialogButton& button ){
+ui::Button create_modal_dialog_button( const char* label, ModalDialogButton& button ){
return create_dialog_button( label, G_CALLBACK( modal_dialog_button_clicked ), &button );
}
-GtkWindow* create_modal_dialog_window( GtkWindow* parent, const char* title, ModalDialog& dialog, int default_w, int default_h ){
+ui::Window create_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int default_w, int default_h ){
return create_dialog_window( parent, title, G_CALLBACK( modal_dialog_delete ), &dialog, default_w, default_h );
}
-GtkWindow* create_fixedsize_modal_dialog_window( GtkWindow* parent, const char* title, ModalDialog& dialog, int width, int height ){
- GtkWindow* window = create_modal_dialog_window( parent, title, dialog, width, height );
+ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int width, int height ){
+ auto window = create_modal_dialog_window( parent, title, dialog, width, height );
gtk_window_set_resizable( window, FALSE );
gtk_window_set_modal( window, TRUE );
window_remove_minmax( window );
- //gtk_widget_set_size_request(GTK_WIDGET(window), width, height);
+ //window.dimensions(width, height);
//gtk_window_set_default_size(window, width, height);
//gtk_window_resize(window, width, height);
//GdkGeometry geometry = { width, height, -1, -1, width, height, -1, -1, -1, -1, GDK_GRAVITY_STATIC, };
- //gtk_window_set_geometry_hints(window, GTK_WIDGET(window), &geometry, (GdkWindowHints)(GDK_HINT_POS|GDK_HINT_MIN_SIZE|GDK_HINT_BASE_SIZE));
+ //gtk_window_set_geometry_hints(window, window, &geometry, (GdkWindowHints)(GDK_HINT_POS|GDK_HINT_MIN_SIZE|GDK_HINT_BASE_SIZE));
return window;
}
-gboolean dialog_button_ok( GtkWidget *widget, ModalDialog* data ){
+gboolean dialog_button_ok( ui::Widget widget, ModalDialog* data ){
data->loop = false;
data->ret = eIDOK;
return TRUE;
}
-gboolean dialog_button_cancel( GtkWidget *widget, ModalDialog* data ){
+gboolean dialog_button_cancel( ui::Widget widget, ModalDialog* data ){
data->loop = false;
data->ret = eIDCANCEL;
return TRUE;
}
-gboolean dialog_button_yes( GtkWidget *widget, ModalDialog* data ){
+gboolean dialog_button_yes( ui::Widget widget, ModalDialog* data ){
data->loop = false;
data->ret = eIDYES;
return TRUE;
}
-gboolean dialog_button_no( GtkWidget *widget, ModalDialog* data ){
+gboolean dialog_button_no( ui::Widget widget, ModalDialog* data ){
data->loop = false;
data->ret = eIDNO;
return TRUE;
}
-gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDialog* data ){
- gtk_widget_hide( widget );
+gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDialog* data ){
+ widget.hide();
data->loop = false;
return TRUE;
}
-GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents ){
- GtkWindow* window = create_fixedsize_modal_dialog_window( 0, title, dialog );
+ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, ui::Widget contents ){
+ ui::Window window = create_fixedsize_modal_dialog_window(ui::Window{ui::null}, title, dialog );
- GtkVBox* vbox1 = create_dialog_vbox( 8, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox1 ) );
+ auto vbox1 = create_dialog_vbox( 8, 4 );
+ window.add(vbox1);
- gtk_container_add( GTK_CONTAINER( vbox1 ), contents );
+ vbox1.add(contents);
- GtkAlignment* alignment = GTK_ALIGNMENT( gtk_alignment_new( 0.5, 0.0, 0.0, 0.0 ) );
- gtk_widget_show( GTK_WIDGET( alignment ) );
- gtk_box_pack_start( GTK_BOX( vbox1 ), GTK_WIDGET( alignment ), FALSE, FALSE, 0 );
+ ui::Alignment alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 );
+ alignment.show();
+ vbox1.pack_start( alignment, FALSE, FALSE, 0 );
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
- gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( button ) );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
+ alignment.add(button);
return window;
}
RadioHBox RadioHBox_new( StringArrayRange names ){
- GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( TRUE, 4 ) );
- gtk_widget_show( GTK_WIDGET( hbox ) );
+ auto hbox = ui::HBox( TRUE, 4 );
+ hbox.show();
GSList* group = 0;
- GtkRadioButton* radio = 0;
+ auto radio = ui::RadioButton(ui::null);
for ( StringArrayRange::Iterator i = names.first; i != names.last; ++i )
{
- radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( group, *i ) );
- gtk_widget_show( GTK_WIDGET( radio ) );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( radio ), FALSE, FALSE, 0 );
+ radio = ui::RadioButton::from( gtk_radio_button_new_with_label( group, *i ) );
+ radio.show();
+ hbox.pack_start( radio, FALSE, FALSE, 0 );
group = gtk_radio_button_get_group( radio );
}
PathEntry PathEntry_new(){
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( NULL ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
+ auto frame = ui::Frame();
+ frame.show();
gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN );
// path entry
- GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( FALSE, 0 ) );
- gtk_widget_show( GTK_WIDGET( hbox ) );
+ auto hbox = ui::HBox( FALSE, 0 );
+ hbox.show();
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
+ auto entry = ui::Entry(ui::New);
gtk_entry_set_has_frame( entry, FALSE );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ entry.show();
+ hbox.pack_start( entry, TRUE, TRUE, 0 );
// browse button
- GtkButton* button = GTK_BUTTON( gtk_button_new() );
+ auto button = ui::Button(ui::New);
button_set_icon( button, "ellipsis.png" );
- gtk_widget_show( GTK_WIDGET( button ) );
- gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ button.show();
+ hbox.pack_end(button, FALSE, FALSE, 0);
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( hbox ) );
+ frame.add(hbox);
return PathEntry( frame, entry, button );
}
void PathEntry_setPath( PathEntry& self, const char* path ){
gtk_entry_set_text( self.m_entry, path );
}
-typedef ReferenceCaller1<PathEntry, const char*, PathEntry_setPath> PathEntrySetPathCaller;
+typedef ReferenceCaller<PathEntry, void(const char*), PathEntry_setPath> PathEntrySetPathCaller;
-void BrowsedPathEntry_clicked( GtkWidget* widget, BrowsedPathEntry* self ){
+void BrowsedPathEntry_clicked( ui::Widget widget, BrowsedPathEntry* self ){
self->m_browse( PathEntrySetPathCaller( self->m_entry ) );
}
BrowsedPathEntry::BrowsedPathEntry( const BrowseCallback& browse ) :
m_entry( PathEntry_new() ),
m_browse( browse ){
- g_signal_connect( G_OBJECT( m_entry.m_button ), "clicked", G_CALLBACK( BrowsedPathEntry_clicked ), this );
+ m_entry.m_button.connect( "clicked", G_CALLBACK( BrowsedPathEntry_clicked ), this );
}
-GtkLabel* DialogLabel_new( const char* name ){
- GtkLabel* label = GTK_LABEL( gtk_label_new( name ) );
- gtk_widget_show( GTK_WIDGET( label ) );
+ui::Label DialogLabel_new( const char* name ){
+ auto label = ui::Label( name );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
gtk_label_set_justify( label, GTK_JUSTIFY_LEFT );
return label;
}
-GtkTable* DialogRow_new( const char* name, GtkWidget* widget ){
- GtkTable* table = GTK_TABLE( gtk_table_new( 1, 3, TRUE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
+ui::Table DialogRow_new( const char* name, ui::Widget widget ){
+ auto table = ui::Table( 1, 3, TRUE );
+ table.show();
gtk_table_set_col_spacings( table, 4 );
gtk_table_set_row_spacings( table, 0 );
- gtk_table_attach( table, GTK_WIDGET( DialogLabel_new( name ) ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(DialogLabel_new(name), {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
- gtk_table_attach( table, widget, 1, 3, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(widget, {1, 3, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
return table;
}
-void DialogVBox_packRow( GtkVBox* vbox, GtkWidget* row ){
- gtk_box_pack_start( GTK_BOX( vbox ), row, FALSE, FALSE, 0 );
+void DialogVBox_packRow( ui::Box vbox, ui::Widget row ){
+ vbox.pack_start( row, FALSE, FALSE, 0 );
}
#include "generic/callback.h"
#include "generic/arrayrange.h"
#include "qerplugin.h"
-#include <gtk/gtkenums.h>
typedef int gint;
typedef gint gboolean;
typedef struct _GdkEventAny GdkEventAny;
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkHBox GtkHBox;
-typedef struct _GtkVBox GtkVBox;
-typedef struct _GtkRadioButton GtkRadioButton;
-typedef struct _GtkFrame GtkFrame;
-typedef struct _GtkEntry GtkEntry;
-typedef struct _GtkButton GtkButton;
-typedef struct _GtkLabel GtkLabel;
-typedef struct _GtkTable GtkTable;
struct ModalDialog
typedef void ( *GCallback )( void );
typedef void* gpointer;
-typedef struct _GtkWindow GtkWindow;
-typedef struct _GtkTable GtkTable;
-typedef struct _GtkButton GtkButton;
-typedef struct _GtkVBox GtkVBox;
-typedef struct _GtkHBox GtkHBox;
-typedef struct _GtkFrame GtkFrame;
-GtkWindow* create_fixedsize_modal_window( GtkWindow* parent, const char* title, int width, int height );
+ui::Window create_fixedsize_modal_window( ui::Window parent, const char* title, int width, int height );
-GtkWindow* create_dialog_window( GtkWindow* parent, const char* title, GCallback func, gpointer data, int default_w = -1, int default_h = -1 );
-GtkTable* create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border = 0 );
-GtkButton* create_dialog_button( const char* label, GCallback func, gpointer data );
-GtkVBox* create_dialog_vbox( int spacing, int border = 0 );
-GtkHBox* create_dialog_hbox( int spacing, int border = 0 );
-GtkFrame* create_dialog_frame( const char* label, GtkShadowType shadow = GTK_SHADOW_ETCHED_IN );
+ui::Window create_dialog_window( ui::Window parent, const char* title, GCallback func, gpointer data, int default_w = -1, int default_h = -1 );
+ui::Table create_dialog_table( unsigned int rows, unsigned int columns, unsigned int row_spacing, unsigned int col_spacing, int border = 0 );
+ui::Button create_dialog_button( const char* label, GCallback func, gpointer data );
+ui::VBox create_dialog_vbox( int spacing, int border = 0 );
+ui::HBox create_dialog_hbox( int spacing, int border = 0 );
+ui::Frame create_dialog_frame( const char* label, ui::Shadow shadow = ui::Shadow::ETCHED_IN );
-GtkButton* create_modal_dialog_button( const char* label, ModalDialogButton& button );
-GtkWindow* create_modal_dialog_window( GtkWindow* parent, const char* title, ModalDialog& dialog, int default_w = -1, int default_h = -1 );
-GtkWindow* create_fixedsize_modal_dialog_window( GtkWindow* parent, const char* title, ModalDialog& dialog, int width = -1, int height = -1 );
-EMessageBoxReturn modal_dialog_show( GtkWindow* window, ModalDialog& dialog );
+ui::Button create_modal_dialog_button( const char* label, ModalDialogButton& button );
+ui::Window create_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int default_w = -1, int default_h = -1 );
+ui::Window create_fixedsize_modal_dialog_window( ui::Window parent, const char* title, ModalDialog& dialog, int width = -1, int height = -1 );
+EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog );
-gboolean dialog_button_ok( GtkWidget *widget, ModalDialog* data );
-gboolean dialog_button_cancel( GtkWidget *widget, ModalDialog* data );
-gboolean dialog_button_yes( GtkWidget *widget, ModalDialog* data );
-gboolean dialog_button_no( GtkWidget *widget, ModalDialog* data );
-gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDialog* data );
+gboolean dialog_button_ok( ui::Widget widget, ModalDialog* data );
+gboolean dialog_button_cancel( ui::Widget widget, ModalDialog* data );
+gboolean dialog_button_yes( ui::Widget widget, ModalDialog* data );
+gboolean dialog_button_no( ui::Widget widget, ModalDialog* data );
+gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDialog* data );
-GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents );
+ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, ui::Widget contents );
class RadioHBox
{
public:
-GtkHBox* m_hbox;
-GtkRadioButton* m_radio;
-RadioHBox( GtkHBox* hbox, GtkRadioButton* radio ) :
+ui::HBox m_hbox;
+ui::RadioButton m_radio;
+RadioHBox( ui::HBox hbox, ui::RadioButton radio ) :
m_hbox( hbox ),
m_radio( radio ){
}
class PathEntry
{
public:
-GtkFrame* m_frame;
-GtkEntry* m_entry;
-GtkButton* m_button;
-PathEntry( GtkFrame* frame, GtkEntry* entry, GtkButton* button ) :
+ui::Frame m_frame;
+ui::Entry m_entry;
+ui::Button m_button;
+PathEntry( ui::Frame frame, ui::Entry entry, ui::Button button ) :
m_frame( frame ),
m_entry( entry ),
m_button( button ){
class BrowsedPathEntry
{
public:
-typedef Callback1<const char*> SetPathCallback;
-typedef Callback1<const SetPathCallback&> BrowseCallback;
+typedef Callback<void(const char*)> SetPathCallback;
+typedef Callback<void(const SetPathCallback&)> BrowseCallback;
PathEntry m_entry;
BrowseCallback m_browse;
BrowsedPathEntry( const BrowseCallback& browse );
};
-GtkLabel* DialogLabel_new( const char* name );
-GtkTable* DialogRow_new( const char* name, GtkWidget* widget );
-typedef struct _GtkVBox GtkVBox;
-void DialogVBox_packRow( GtkVBox* vbox, GtkWidget* row );
+ui::Label DialogLabel_new( const char* name );
+ui::Table DialogRow_new( const char* name, ui::Widget widget );
+void DialogVBox_packRow( ui::Box vbox, ui::Widget row );
#endif
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
+#include "entry.h"
- This file is part of GtkRadiant.
+#include <gtk/gtk.h>
- GtkRadiant 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.
+void entry_set_string(ui::Entry entry, const char *string)
+{
+ gtk_entry_set_text(entry, string);
+}
- GtkRadiant 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.
+void entry_set_int(ui::Entry entry, int i)
+{
+ char buf[32];
+ sprintf(buf, "%d", i);
+ entry_set_string(entry, buf);
+}
- You should have received a copy of the GNU General Public License
- along with GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
+void entry_set_float(ui::Entry entry, float f)
+{
+ char buf[32];
+ sprintf(buf, "%g", f);
+ entry_set_string(entry, buf);
+}
-#include "entry.h"
+const char *entry_get_string(ui::Entry entry)
+{
+ return gtk_entry_get_text(entry);
+}
+
+int entry_get_int(ui::Entry entry)
+{
+ return atoi(entry_get_string(entry));
+}
+
+double entry_get_float(ui::Entry entry)
+{
+ return atof(entry_get_string(entry));
+}
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_GTKUTIL_ENTRY_H )
#define INCLUDED_GTKUTIL_ENTRY_H
-#include <stdio.h>
-#include <stdlib.h>
-#include <gtk/gtkentry.h>
-
-inline void entry_set_string( GtkEntry* entry, const char* string ){
- gtk_entry_set_text( entry, string );
-}
-
-inline void entry_set_int( GtkEntry* entry, int i ){
- char buf[32];
- sprintf( buf, "%d", i );
- entry_set_string( entry, buf );
-}
-
-inline void entry_set_float( GtkEntry* entry, float f ){
- char buf[32];
- sprintf( buf, "%g", f );
- entry_set_string( entry, buf );
-}
-
-inline const char* entry_get_string( GtkEntry* entry ){
- return gtk_entry_get_text( entry );
-}
-
-inline int entry_get_int( GtkEntry* entry ){
- return atoi( entry_get_string( entry ) );
-}
-
-inline double entry_get_float( GtkEntry* entry ){
- return atof( entry_get_string( entry ) );
-}
+void entry_set_string(ui::Entry entry, const char *string);
+
+void entry_set_int(ui::Entry entry, int i);
+
+void entry_set_float(ui::Entry entry, float f);
+
+const char *entry_get_string(ui::Entry entry);
+
+int entry_get_int(ui::Entry entry);
+
+double entry_get_float(ui::Entry entry);
#endif
#include <list>
#include <vector>
-#include <gtk/gtkwidget.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkfilechooser.h>
-#include <gtk/gtkfilechooserdialog.h>
-#include <gtk/gtkstock.h>
+#include <gtk/gtk.h>
+#include <uilib/uilib.h>
#include "string/string.h"
#include "stream/stringstream.h"
static char g_file_dialog_file[1024];
-const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){
+const char* file_dialog_show( ui::Window parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){
filetype_t type;
if ( pattern == 0 ) {
title = open ? "Open File" : "Save File";
}
- GtkWidget* dialog;
+ ui::Dialog dialog{ui::null};
if ( open ) {
- dialog = gtk_file_chooser_dialog_new( title,
- GTK_WINDOW( parent ),
+ dialog = ui::Dialog::from(gtk_file_chooser_dialog_new( title,
+ parent,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL );
+ NULL ));
}
else
{
- dialog = gtk_file_chooser_dialog_new( title,
- GTK_WINDOW( parent ),
+ dialog = ui::Dialog::from(gtk_file_chooser_dialog_new( title,
+ parent,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL );
+ NULL ));
gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER( dialog ), "unnamed" );
}
- gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
- gtk_window_set_position( GTK_WINDOW( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_modal( dialog, TRUE );
+ gtk_window_set_position( dialog, GTK_WIN_POS_CENTER_ON_PARENT );
// we expect an actual path below, if the path is 0 we might crash
if ( path != 0 && !string_empty( path ) ) {
g_file_dialog_file[0] = '\0';
}
- gtk_widget_destroy( dialog );
+ ui::Widget(dialog).destroy();
// don't return an empty filename
if ( g_file_dialog_file[0] == '\0' ) {
return g_file_dialog_file;
}
-char* dir_dialog( GtkWidget* parent, const char* title, const char* path ){
- GtkWidget* dialog = gtk_file_chooser_dialog_new( title,
- GTK_WINDOW( parent ),
+char* dir_dialog( ui::Window parent, const char* title, const char* path ){
+ auto dialog = ui::Dialog::from(gtk_file_chooser_dialog_new( title,
+ parent,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL );
+ NULL ));
- gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
- gtk_window_set_position( GTK_WINDOW( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
+ gtk_window_set_modal( dialog, TRUE );
+ gtk_window_set_position( dialog, GTK_WIN_POS_CENTER_ON_PARENT );
if ( !string_empty( path ) ) {
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( dialog ), path );
filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( dialog ) );
}
- gtk_widget_destroy( dialog );
+ dialog.destroy();
return filename;
}
-const char* file_dialog( GtkWidget* parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){
+const char* file_dialog( ui::Window parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){
for (;; )
{
const char* file = file_dialog_show( parent, open, title, path, pattern, want_load, want_import, want_save );
if ( open
- || file == 0
+ || !file
|| !file_exists( file )
- || gtk_MessageBox( parent, "The file specified already exists.\nDo you want to replace it?", title, eMB_NOYES, eMB_ICONQUESTION ) == eIDYES ) {
+ || ui::alert(parent, "The file specified already exists.\nDo you want to replace it?", title, ui::alert_type::NOYES, ui::alert_icon::Question ) == ui::alert_response::YES ) {
return file;
}
}
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_GTKUTIL_FILECHOOSER_H )
#define INCLUDED_GTKUTIL_FILECHOOSER_H
/// \file
/// GTK+ file-chooser dialogs.
-typedef struct _GtkWidget GtkWidget;
-const char* file_dialog( GtkWidget *parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false );
+const char* file_dialog( ui::Window parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false );
/// \brief Prompts the user to browse for a directory.
/// The prompt window will be transient to \p parent.
/// The directory will initially default to \p path, which must be an absolute path.
/// The returned string is allocated with \c g_malloc and must be freed with \c g_free.
-char* dir_dialog( GtkWidget *parent, const char* title = "Choose Directory", const char* path = "" );
+char* dir_dialog( ui::Window parent, const char* title = "Choose Directory", const char* path = "" );
#endif
#include "frame.h"
-#include <gtk/gtkframe.h>
+#include <gtk/gtk.h>
+#include <uilib/uilib.h>
-GtkFrame* create_framed_widget( GtkWidget* widget ){
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( 0 ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
+ui::Frame create_framed_widget( ui::Widget widget ){
+ auto frame = ui::Frame();
+ frame.show();
gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN );
- gtk_container_add( GTK_CONTAINER( frame ), widget );
- gtk_widget_show( GTK_WIDGET( widget ) );
+ frame.add(widget);
+ widget.show();
return frame;
}
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_GTKUTIL_FRAME_H )
#define INCLUDED_GTKUTIL_FRAME_H
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkFrame GtkFrame;
-GtkFrame* create_framed_widget( GtkWidget* widget );
+ui::Frame create_framed_widget( ui::Widget widget );
#endif
*/
#include "glfont.h"
+#include "globaldefs.h"
#include "igl.h"
// generic string printing with call lists
}
};
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
#include <windows.h>
#endif
#include "debugging/debugging.h"
// new font code ripped from ZeroRadiant
#include <pango/pangoft2.h>
+#include <pango/pango-features.h>
#include <pango/pango-utils.h>
class GLFontInternal : public GLFont
#include "glwidget.h"
-#include "debugging/debugging.h"
-
#include "igl.h"
-#include <gtk/gtkdrawingarea.h>
-#include <gtk/gtkglwidget.h>
+void (*GLWidget_sharedContextCreated)() = 0;
-#include "pointer.h"
+void (*GLWidget_sharedContextDestroyed)() = 0;
+
+unsigned int g_context_count = 0;
-void ( *GLWidget_sharedContextCreated )() = 0;
-void ( *GLWidget_sharedContextDestroyed )() = 0;
+ui::GLArea g_shared{ui::null};
+void _glwidget_context_created(ui::GLArea self, void *data)
+{
+ if (++g_context_count == 1) {
+ g_shared = self;
+ g_object_ref(g_shared._handle);
+
+ glwidget_make_current(g_shared);
+ GlobalOpenGL().contextValid = true;
+
+ GLWidget_sharedContextCreated();
+ }
+}
+
+void _glwidget_context_destroyed(ui::GLArea self, void *data)
+{
+ if (--g_context_count == 0) {
+ GlobalOpenGL().contextValid = false;
+
+ GLWidget_sharedContextDestroyed();
+
+ g_shared.unref();
+ g_shared = ui::GLArea(ui::null);
+ }
+}
+
+void glwidget_destroy_context(ui::GLArea self)
+{
+}
-typedef int* attribs_t;
-struct config_t
+void glwidget_create_context(ui::GLArea self)
{
- const char* name;
- attribs_t attribs;
+}
+
+#if GTK_TARGET == 3
+
+#include <gtk/gtk.h>
+
+GdkGLContext *glwidget_context_created(ui::GLArea self)
+{
+ _glwidget_context_created(self, nullptr);
+ return gtk_gl_area_get_context(self);
+}
+
+ui::GLArea glwidget_new(bool zbuffer)
+{
+ auto self = ui::GLArea(GTK_GL_AREA(gtk_gl_area_new()));
+ gtk_gl_area_set_has_depth_buffer(self, zbuffer);
+ gtk_gl_area_set_auto_render(self, false);
+
+ self.connect("realize", G_CALLBACK(glwidget_context_created), nullptr);
+ return self;
+}
+
+bool glwidget_make_current(ui::GLArea self)
+{
+// if (!g_context_count) {
+// glwidget_context_created(self);
+// }
+ gtk_gl_area_make_current(self);
+ auto valid = GlobalOpenGL().contextValid;
+ return true;
+}
+
+void glwidget_swap_buffers(ui::GLArea self)
+{
+ gtk_gl_area_queue_render(self);
+}
+
+#endif
+
+#if GTK_TARGET == 2
+
+#include <gtk/gtk.h>
+#include <gtk/gtkglwidget.h>
+
+#include "pointer.h"
+
+struct config_t {
+ const char *name;
+ int *attribs;
};
-typedef const config_t* configs_iterator;
+typedef const config_t *configs_iterator;
int config_rgba32[] = {
- GDK_GL_RGBA,
- GDK_GL_DOUBLEBUFFER,
- GDK_GL_BUFFER_SIZE, 24,
- GDK_GL_ATTRIB_LIST_NONE,
+ GDK_GL_RGBA,
+ GDK_GL_DOUBLEBUFFER,
+ GDK_GL_BUFFER_SIZE, 24,
+ GDK_GL_ATTRIB_LIST_NONE,
};
int config_rgba[] = {
- GDK_GL_RGBA,
- GDK_GL_DOUBLEBUFFER,
- GDK_GL_BUFFER_SIZE, 16,
- GDK_GL_ATTRIB_LIST_NONE,
+ GDK_GL_RGBA,
+ GDK_GL_DOUBLEBUFFER,
+ GDK_GL_BUFFER_SIZE, 16,
+ GDK_GL_ATTRIB_LIST_NONE,
};
const config_t configs[] = {
- {
- "colour-buffer = 32bpp, depth-buffer = none",
- config_rgba32,
- },
- {
- "colour-buffer = 16bpp, depth-buffer = none",
- config_rgba,
- }
+ {
+ "colour-buffer = 32bpp, depth-buffer = none",
+ config_rgba32,
+ },
+ {
+ "colour-buffer = 16bpp, depth-buffer = none",
+ config_rgba,
+ }
};
-GdkGLConfig* glconfig_new(){
- GdkGLConfig* glconfig = 0;
-
- for ( configs_iterator i = configs, end = configs + 2; i != end; ++i )
- {
- glconfig = gdk_gl_config_new( ( *i ).attribs );
- if ( glconfig != 0 ) {
- globalOutputStream() << "OpenGL window configuration: " << ( *i ).name << "\n";
- return glconfig;
- }
- }
-
- globalOutputStream() << "OpenGL window configuration: colour-buffer = auto, depth-buffer = none\n";
- return gdk_gl_config_new_by_mode( (GdkGLConfigMode)( GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE ) );
+GdkGLConfig *glconfig_new()
+{
+ for (configs_iterator i = configs, end = configs + 2; i != end; ++i) {
+ if (auto glconfig = gdk_gl_config_new(i->attribs)) {
+ globalOutputStream() << "OpenGL window configuration: " << i->name << "\n";
+ return glconfig;
+ }
+ }
+ globalOutputStream() << "OpenGL window configuration: colour-buffer = auto, depth-buffer = none\n";
+ return gdk_gl_config_new_by_mode((GdkGLConfigMode) (GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE));
}
int config_rgba32_depth32[] = {
- GDK_GL_RGBA,
- GDK_GL_DOUBLEBUFFER,
- GDK_GL_BUFFER_SIZE, 24,
- GDK_GL_DEPTH_SIZE, 32,
- GDK_GL_ATTRIB_LIST_NONE,
+ GDK_GL_RGBA,
+ GDK_GL_DOUBLEBUFFER,
+ GDK_GL_BUFFER_SIZE,
+ 24,
+ GDK_GL_DEPTH_SIZE,
+ 32,
+ GDK_GL_ATTRIB_LIST_NONE,
};
int config_rgba32_depth24[] = {
- GDK_GL_RGBA,
- GDK_GL_DOUBLEBUFFER,
- GDK_GL_BUFFER_SIZE, 24,
- GDK_GL_DEPTH_SIZE, 24,
- GDK_GL_ATTRIB_LIST_NONE,
+ GDK_GL_RGBA,
+ GDK_GL_DOUBLEBUFFER,
+ GDK_GL_BUFFER_SIZE, 24,
+ GDK_GL_DEPTH_SIZE, 24,
+ GDK_GL_ATTRIB_LIST_NONE,
};
int config_rgba32_depth16[] = {
- GDK_GL_RGBA,
- GDK_GL_DOUBLEBUFFER,
- GDK_GL_BUFFER_SIZE, 24,
- GDK_GL_DEPTH_SIZE, 16,
- GDK_GL_ATTRIB_LIST_NONE,
+ GDK_GL_RGBA,
+ GDK_GL_DOUBLEBUFFER,
+ GDK_GL_BUFFER_SIZE, 24,
+ GDK_GL_DEPTH_SIZE, 16,
+ GDK_GL_ATTRIB_LIST_NONE,
};
int config_rgba32_depth[] = {
- GDK_GL_RGBA,
- GDK_GL_DOUBLEBUFFER,
- GDK_GL_BUFFER_SIZE, 24,
- GDK_GL_DEPTH_SIZE, 1,
- GDK_GL_ATTRIB_LIST_NONE,
+ GDK_GL_RGBA,
+ GDK_GL_DOUBLEBUFFER,
+ GDK_GL_BUFFER_SIZE, 24,
+ GDK_GL_DEPTH_SIZE, 1,
+ GDK_GL_ATTRIB_LIST_NONE,
};
int config_rgba_depth16[] = {
- GDK_GL_RGBA,
- GDK_GL_DOUBLEBUFFER,
- GDK_GL_BUFFER_SIZE, 16,
- GDK_GL_DEPTH_SIZE, 16,
- GDK_GL_ATTRIB_LIST_NONE,
+ GDK_GL_RGBA,
+ GDK_GL_DOUBLEBUFFER,
+ GDK_GL_BUFFER_SIZE, 16,
+ GDK_GL_DEPTH_SIZE, 16,
+ GDK_GL_ATTRIB_LIST_NONE,
};
int config_rgba_depth[] = {
- GDK_GL_RGBA,
- GDK_GL_DOUBLEBUFFER,
- GDK_GL_BUFFER_SIZE, 16,
- GDK_GL_DEPTH_SIZE, 1,
- GDK_GL_ATTRIB_LIST_NONE,
+ GDK_GL_RGBA,
+ GDK_GL_DOUBLEBUFFER,
+ GDK_GL_BUFFER_SIZE, 16,
+ GDK_GL_DEPTH_SIZE, 1,
+ GDK_GL_ATTRIB_LIST_NONE,
};
const config_t configs_with_depth[] =
+ {
+ {
+ "colour-buffer = 32bpp, depth-buffer = 32bpp",
+ config_rgba32_depth32,
+ },
+ {
+ "colour-buffer = 32bpp, depth-buffer = 24bpp",
+ config_rgba32_depth24,
+ },
+ {
+ "colour-buffer = 32bpp, depth-buffer = 16bpp",
+ config_rgba32_depth16,
+ },
+ {
+ "colour-buffer = 32bpp, depth-buffer = auto",
+ config_rgba32_depth,
+ },
+ {
+ "colour-buffer = 16bpp, depth-buffer = 16bpp",
+ config_rgba_depth16,
+ },
+ {
+ "colour-buffer = auto, depth-buffer = auto",
+ config_rgba_depth,
+ },
+ };
+
+GdkGLConfig *glconfig_new_with_depth()
{
- {
- "colour-buffer = 32bpp, depth-buffer = 32bpp",
- config_rgba32_depth32,
- },
- {
- "colour-buffer = 32bpp, depth-buffer = 24bpp",
- config_rgba32_depth24,
- },
- {
- "colour-buffer = 32bpp, depth-buffer = 16bpp",
- config_rgba32_depth16,
- },
- {
- "colour-buffer = 32bpp, depth-buffer = auto",
- config_rgba32_depth,
- },
- {
- "colour-buffer = 16bpp, depth-buffer = 16bpp",
- config_rgba_depth16,
- },
- {
- "colour-buffer = auto, depth-buffer = auto",
- config_rgba_depth,
- },
-};
-
-GdkGLConfig* glconfig_new_with_depth(){
- GdkGLConfig* glconfig = 0;
-
- for ( configs_iterator i = configs_with_depth, end = configs_with_depth + 6; i != end; ++i )
- {
- glconfig = gdk_gl_config_new( ( *i ).attribs );
- if ( glconfig != 0 ) {
- globalOutputStream() << "OpenGL window configuration: " << ( *i ).name << "\n";
- return glconfig;
- }
- }
-
- globalOutputStream() << "OpenGL window configuration: colour-buffer = auto, depth-buffer = auto (fallback)\n";
- return gdk_gl_config_new_by_mode( (GdkGLConfigMode)( GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_DEPTH ) );
+ for (configs_iterator i = configs_with_depth, end = configs_with_depth + 6; i != end; ++i) {
+ if (auto glconfig = gdk_gl_config_new(i->attribs)) {
+ globalOutputStream() << "OpenGL window configuration: " << i->name << "\n";
+ return glconfig;
+ }
+ }
+ globalOutputStream() << "OpenGL window configuration: colour-buffer = auto, depth-buffer = auto (fallback)\n";
+ return gdk_gl_config_new_by_mode((GdkGLConfigMode) (GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_DEPTH));
}
-unsigned int g_context_count = 0;
-
-namespace
+int glwidget_context_created(ui::GLArea self, void *data)
{
-GtkWidget* g_shared = 0;
+ _glwidget_context_created(self, data);
+ return false;
}
-gint glwidget_context_created( GtkWidget* widget, gpointer data ){
- if ( ++g_context_count == 1 ) {
- g_shared = widget;
- gtk_widget_ref( g_shared );
-
- glwidget_make_current( g_shared );
- GlobalOpenGL().contextValid = true;
-
- GLWidget_sharedContextCreated();
- }
- return FALSE;
-}
-
-gint glwidget_context_destroyed( GtkWidget* widget, gpointer data ){
- if ( --g_context_count == 0 ) {
- GlobalOpenGL().contextValid = false;
-
- GLWidget_sharedContextDestroyed();
-
- gtk_widget_unref( g_shared );
- g_shared = 0;
- }
- return FALSE;
+int glwidget_context_destroyed(ui::GLArea self, void *data)
+{
+ _glwidget_context_destroyed(self, data);
+ return false;
}
-gboolean glwidget_enable_gl( GtkWidget* widget, GtkWidget* widget2, gpointer data ){
- if ( widget2 == 0 && !gtk_widget_is_gl_capable( widget ) ) {
- GdkGLConfig* glconfig = ( g_object_get_data( G_OBJECT( widget ), "zbuffer" ) ) ? glconfig_new_with_depth() : glconfig_new();
- ASSERT_MESSAGE( glconfig != 0, "failed to create OpenGL config" );
-
- gtk_widget_set_gl_capability( widget, glconfig, g_shared != 0 ? gtk_widget_get_gl_context( g_shared ) : 0, TRUE, GDK_GL_RGBA_TYPE );
-
- gtk_widget_realize( widget );
- if ( g_shared == 0 ) {
- g_shared = widget;
- }
-
- // free glconfig?
- }
- return FALSE;
+bool glwidget_enable_gl(ui::GLArea self, ui::Widget root, gpointer data)
+{
+ if (!root && !gtk_widget_is_gl_capable(self)) {
+ const auto zbuffer = g_object_get_data(G_OBJECT(self), "zbuffer");
+ GdkGLConfig *glconfig = zbuffer ? glconfig_new_with_depth() : glconfig_new();
+ ASSERT_MESSAGE(glconfig, "failed to create OpenGL config");
+
+ const auto share_list = g_shared ? gtk_widget_get_gl_context(g_shared) : nullptr;
+ gtk_widget_set_gl_capability(self, glconfig, share_list, true, GDK_GL_RGBA_TYPE);
+
+ gtk_widget_realize(self);
+ if (!g_shared) {
+ g_shared = self;
+ }
+ // free glconfig?
+ }
+ return false;
}
-GtkWidget* glwidget_new( gboolean zbuffer ){
- GtkWidget* widget = gtk_drawing_area_new();
-
- g_object_set_data( G_OBJECT( widget ), "zbuffer", gint_to_pointer( zbuffer ) );
+ui::GLArea glwidget_new(bool zbuffer)
+{
+ auto self = ui::GLArea::from(gtk_drawing_area_new());
- g_signal_connect( G_OBJECT( widget ), "hierarchy-changed", G_CALLBACK( glwidget_enable_gl ), 0 );
+ g_object_set_data(G_OBJECT(self), "zbuffer", gint_to_pointer(zbuffer));
- g_signal_connect( G_OBJECT( widget ), "realize", G_CALLBACK( glwidget_context_created ), 0 );
- g_signal_connect( G_OBJECT( widget ), "unrealize", G_CALLBACK( glwidget_context_destroyed ), 0 );
+ self.connect("hierarchy-changed", G_CALLBACK(glwidget_enable_gl), 0);
- return widget;
-}
+ self.connect("realize", G_CALLBACK(glwidget_context_created), 0);
+ self.connect("unrealize", G_CALLBACK(glwidget_context_destroyed), 0);
-void glwidget_destroy_context( GtkWidget *widget ){
+ return self;
}
-void glwidget_create_context( GtkWidget *widget ){
+void glwidget_swap_buffers(ui::GLArea self)
+{
+ GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(self);
+ gdk_gl_drawable_swap_buffers(gldrawable);
}
-void glwidget_swap_buffers( GtkWidget *widget ){
- GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable( widget );
- gdk_gl_drawable_swap_buffers( gldrawable );
+bool glwidget_make_current(ui::GLArea self)
+{
+ GdkGLContext *glcontext = gtk_widget_get_gl_context(self);
+ GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(self);
+ return gdk_gl_drawable_gl_begin(gldrawable, glcontext);
}
-gboolean glwidget_make_current( GtkWidget *widget ){
- GdkGLContext *glcontext = gtk_widget_get_gl_context( widget );
- GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable( widget );
- return gdk_gl_drawable_gl_begin( gldrawable, glcontext );
-}
+#endif
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_GTKUTIL_GLWIDGET_H )
#define INCLUDED_GTKUTIL_GLWIDGET_H
-typedef struct _GtkWidget GtkWidget;
-typedef int gint;
-typedef gint gboolean;
-
-GtkWidget* glwidget_new( gboolean zbuffer );
-void glwidget_swap_buffers( GtkWidget* widget );
-gboolean glwidget_make_current( GtkWidget* widget );
-void glwidget_destroy_context( GtkWidget* widget );
-void glwidget_create_context( GtkWidget* widget );
-
-extern void ( *GLWidget_sharedContextCreated )();
-extern void ( *GLWidget_sharedContextDestroyed )();
+extern void (*GLWidget_sharedContextCreated)();
+extern void (*GLWidget_sharedContextDestroyed)();
+ui::GLArea glwidget_new(bool zbuffer);
+void glwidget_create_context(ui::GLArea self);
+void glwidget_destroy_context(ui::GLArea self);
+bool glwidget_make_current(ui::GLArea self);
+void glwidget_swap_buffers(ui::GLArea self);
#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "idledraw.h"
class IdleDraw
{
-Callback m_draw;
+Callback<void()> m_draw;
unsigned int m_handler;
static gboolean draw( gpointer data ){
reinterpret_cast<IdleDraw*>( data )->m_draw();
return FALSE;
}
public:
-IdleDraw( const Callback& draw ) : m_draw( draw ), m_handler( 0 ){
+IdleDraw( const Callback<void()>& draw ) : m_draw( draw ), m_handler( 0 ){
}
~IdleDraw(){
if ( m_handler != 0 ) {
m_handler = g_idle_add( &draw, this );
}
}
-typedef MemberCaller<IdleDraw, &IdleDraw::queueDraw> QueueDrawCaller;
+typedef MemberCaller<IdleDraw, void(), &IdleDraw::queueDraw> QueueDrawCaller;
void flush(){
if ( m_handler != 0 ) {
#include "image.h"
-#include <gtk/gtkimage.h>
-#include <gtk/gtkstock.h>
+#include <gtk/gtk.h>
#include "string/string.h"
#include "stream/stringstream.h"
else
{
//GdkPixbuf* rgba = gdk_pixbuf_add_alpha( rgb, TRUE, 255, 0, 255 ); //pink to alpha
- GdkPixbuf* rgba = gdk_pixbuf_add_alpha( rgb, FALSE, 255, 0, 255 ); //alpha
+ GdkPixbuf* rgba = gdk_pixbuf_add_alpha( rgb, FALSE, 255, 0, 255 );
g_object_unref( rgb );
return rgba;
}
}
-GtkImage* image_new_from_file_with_mask( const char* filename ){
+ui::Image image_new_from_file_with_mask( const char* filename ){
GdkPixbuf* rgba = pixbuf_new_from_file_with_mask( filename );
if ( rgba == 0 ) {
- return 0;
+ return ui::Image(ui::null);
}
else
{
- GtkImage* image = GTK_IMAGE( gtk_image_new_from_pixbuf( rgba ) );
+ auto image = ui::Image::from( gtk_image_new_from_pixbuf( rgba ) );
g_object_unref( rgba );
return image;
}
}
-GtkImage* image_new_missing(){
- return GTK_IMAGE( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) );
+ui::Image image_new_missing(){
+ return ui::Image::from( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) );
}
-GtkImage* new_image( const char* filename ){
- {
- GtkImage* image = image_new_from_file_with_mask( filename );
- if ( image != 0 ) {
- return image;
- }
+ui::Image new_image( const char* filename ){
+ if ( auto image = image_new_from_file_with_mask( filename ) ) {
+ return image;
}
-
return image_new_missing();
}
-GtkImage* new_local_image( const char* filename ){
+ui::Image new_local_image( const char* filename ){
StringOutputStream fullPath( 256 );
fullPath << g_bitmapsPath.c_str() << filename;
return new_image( fullPath.c_str() );
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_GTKUTIL_IMAGE_H )
#define INCLUDED_GTKUTIL_IMAGE_H
void BitmapsPath_set( const char* path );
-typedef struct _GtkImage GtkImage;
typedef struct _GdkPixbuf GdkPixbuf;
GdkPixbuf* pixbuf_new_from_file_with_mask( const char* filename );
-GtkImage* image_new_from_file_with_mask( const char* filename );
-GtkImage* image_new_missing();
-GtkImage* new_image( const char* filename ); // filename is full path to image file
-GtkImage* new_local_image( const char* filename ); // filename is relative to local bitmaps path
+ui::Image image_new_from_file_with_mask( const char* filename );
+ui::Image image_new_missing();
+ui::Image new_image( const char* filename ); // filename is full path to image file
+ui::Image new_local_image( const char* filename ); // filename is relative to local bitmaps path
#endif
#include "menu.h"
#include <ctype.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenubar.h>
-#include <gtk/gtkradiomenuitem.h>
-#include <gtk/gtktearoffmenuitem.h>
-#include <gtk/gtkaccellabel.h>
+#include <gtk/gtk.h>
+#include <uilib/uilib.h>
+#include <debugging/debugging.h>
#include "generic/callback.h"
#include "container.h"
#include "pointer.h"
-void menu_add_item( GtkMenu* menu, GtkMenuItem* item ){
- gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( item ) );
+void menu_add_item( ui::Menu menu, ui::MenuItem item ){
+ menu.add(item);
}
-GtkMenuItem* menu_separator( GtkMenu* menu ){
- GtkMenuItem* menu_item = GTK_MENU_ITEM( gtk_menu_item_new() );
- container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( menu_item ) );
- gtk_widget_set_sensitive( GTK_WIDGET( menu_item ), FALSE );
- gtk_widget_show( GTK_WIDGET( menu_item ) );
+ui::MenuItem menu_separator( ui::Menu menu ){
+ auto menu_item = ui::MenuItem::from( gtk_menu_item_new() );
+ menu.add(menu_item);
+ gtk_widget_set_sensitive( menu_item , FALSE );
+ menu_item.show();
return menu_item;
}
-GtkTearoffMenuItem* menu_tearoff( GtkMenu* menu ){
- GtkTearoffMenuItem* menu_item = GTK_TEAROFF_MENU_ITEM( gtk_tearoff_menu_item_new() );
- container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( menu_item ) );
-// gtk_widget_set_sensitive(GTK_WIDGET(menu_item), FALSE); -- controls whether menu is detachable
- gtk_widget_show( GTK_WIDGET( menu_item ) );
+ui::TearoffMenuItem menu_tearoff( ui::Menu menu ){
+ auto menu_item = ui::TearoffMenuItem::from( gtk_tearoff_menu_item_new() );
+ menu.add(menu_item);
+// gtk_widget_set_sensitive(menu_item, FALSE); -- controls whether menu is detachable
+ menu_item.show();
return menu_item;
}
-GtkMenuItem* new_sub_menu_item_with_mnemonic( const char* mnemonic ){
- GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_mnemonic( mnemonic ) );
- gtk_widget_show( GTK_WIDGET( item ) );
+ui::MenuItem new_sub_menu_item_with_mnemonic( const char* mnemonic ){
+ auto item = ui::MenuItem( mnemonic, true );
+ item.show();
- GtkWidget* sub_menu = gtk_menu_new();
+ auto sub_menu = ui::Menu(ui::New);
gtk_menu_item_set_submenu( item, sub_menu );
return item;
}
-GtkMenu* create_sub_menu_with_mnemonic( GtkMenuShell* parent, const char* mnemonic ){
- GtkMenuItem* item = new_sub_menu_item_with_mnemonic( mnemonic );
- container_add_widget( GTK_CONTAINER( parent ), GTK_WIDGET( item ) );
- return GTK_MENU( gtk_menu_item_get_submenu( item ) );
+ui::Menu create_sub_menu_with_mnemonic( ui::MenuShell parent, const char* mnemonic ){
+ auto item = new_sub_menu_item_with_mnemonic( mnemonic );
+ parent.add(item);
+ return ui::Menu::from( gtk_menu_item_get_submenu( item ) );
}
-GtkMenu* create_sub_menu_with_mnemonic( GtkMenuBar* bar, const char* mnemonic ){
- return create_sub_menu_with_mnemonic( GTK_MENU_SHELL( bar ), mnemonic );
+ui::Menu create_sub_menu_with_mnemonic( ui::MenuBar bar, const char* mnemonic ){
+ return create_sub_menu_with_mnemonic( ui::MenuShell::from( bar._handle ), mnemonic );
}
-GtkMenu* create_sub_menu_with_mnemonic( GtkMenu* parent, const char* mnemonic ){
- return create_sub_menu_with_mnemonic( GTK_MENU_SHELL( parent ), mnemonic );
+ui::Menu create_sub_menu_with_mnemonic( ui::Menu parent, const char* mnemonic ){
+ return create_sub_menu_with_mnemonic( ui::MenuShell::from( parent._handle ), mnemonic );
}
-void activate_closure_callback( GtkWidget* widget, gpointer data ){
- ( *reinterpret_cast<Callback*>( data ) )( );
+void activate_closure_callback( ui::Widget widget, gpointer data ){
+ ( *reinterpret_cast<Callback<void()>*>( data ) )( );
}
-guint menu_item_connect_callback( GtkMenuItem* item, const Callback& callback ){
+guint menu_item_connect_callback( ui::MenuItem item, const Callback<void()>& callback ){
#if 1
return g_signal_connect_swapped( G_OBJECT( item ), "activate", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
#else
#endif
}
-guint check_menu_item_connect_callback( GtkCheckMenuItem* item, const Callback& callback ){
+guint check_menu_item_connect_callback( ui::CheckMenuItem item, const Callback<void()>& callback ){
#if 1
guint handler = g_signal_connect_swapped( G_OBJECT( item ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
#else
return handler;
}
-GtkMenuItem* new_menu_item_with_mnemonic( const char *mnemonic, const Callback& callback ){
- GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_mnemonic( mnemonic ) );
- gtk_widget_show( GTK_WIDGET( item ) );
+ui::MenuItem new_menu_item_with_mnemonic( const char *mnemonic, const Callback<void()>& callback ){
+ auto item = ui::MenuItem( mnemonic, true );
+ item.show();
menu_item_connect_callback( item, callback );
return item;
}
-GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char *mnemonic, const Callback& callback ){
- GtkMenuItem* item = new_menu_item_with_mnemonic( mnemonic, callback );
- container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) );
+ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const Callback<void()>& callback ){
+ auto item = new_menu_item_with_mnemonic( mnemonic, callback );
+ menu.add(item);
return item;
}
-GtkCheckMenuItem* new_check_menu_item_with_mnemonic( const char* mnemonic, const Callback& callback ){
- GtkCheckMenuItem* item = GTK_CHECK_MENU_ITEM( gtk_check_menu_item_new_with_mnemonic( mnemonic ) );
- gtk_widget_show( GTK_WIDGET( item ) );
+ui::CheckMenuItem new_check_menu_item_with_mnemonic( const char* mnemonic, const Callback<void()>& callback ){
+ auto item = ui::CheckMenuItem::from( gtk_check_menu_item_new_with_mnemonic( mnemonic ) );
+ item.show();
check_menu_item_connect_callback( item, callback );
return item;
}
-GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Callback& callback ){
- GtkCheckMenuItem* item = new_check_menu_item_with_mnemonic( mnemonic, callback );
- container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) );
+ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Callback<void()>& callback ){
+ auto item = new_check_menu_item_with_mnemonic( mnemonic, callback );
+ menu.add(item);
return item;
}
-GtkRadioMenuItem* new_radio_menu_item_with_mnemonic( GSList** group, const char* mnemonic, const Callback& callback ){
- GtkRadioMenuItem* item = GTK_RADIO_MENU_ITEM( gtk_radio_menu_item_new_with_mnemonic( *group, mnemonic ) );
+ui::RadioMenuItem new_radio_menu_item_with_mnemonic( GSList** group, const char* mnemonic, const Callback<void()>& callback ){
+ auto item = ui::RadioMenuItem::from( gtk_radio_menu_item_new_with_mnemonic( *group, mnemonic ) );
if ( *group == 0 ) {
- gtk_check_menu_item_set_state( GTK_CHECK_MENU_ITEM( item ), TRUE );
+ gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( item ), TRUE );
}
- *group = gtk_radio_menu_item_group( item );
- gtk_widget_show( GTK_WIDGET( item ) );
- check_menu_item_connect_callback( GTK_CHECK_MENU_ITEM( item ), callback );
+ *group = gtk_radio_menu_item_get_group( item );
+ item.show();
+ check_menu_item_connect_callback( item, callback );
return item;
}
-GtkRadioMenuItem* create_radio_menu_item_with_mnemonic( GtkMenu* menu, GSList** group, const char* mnemonic, const Callback& callback ){
- GtkRadioMenuItem* item = new_radio_menu_item_with_mnemonic( group, mnemonic, callback );
- container_add_widget( GTK_CONTAINER( menu ), GTK_WIDGET( item ) );
+ui::RadioMenuItem create_radio_menu_item_with_mnemonic( ui::Menu menu, GSList** group, const char* mnemonic, const Callback<void()>& callback ){
+ auto item = new_radio_menu_item_with_mnemonic( group, mnemonic, callback );
+ menu.add(item);
return item;
}
-void check_menu_item_set_active_no_signal( GtkCheckMenuItem* item, gboolean active ){
+void check_menu_item_set_active_no_signal( ui::CheckMenuItem item, gboolean active ){
guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( item ), "handler" ) );
g_signal_handler_block( G_OBJECT( item ), handler_id );
gtk_check_menu_item_set_active( item, active );
-void radio_menu_item_set_active_no_signal( GtkRadioMenuItem* item, gboolean active ){
+void radio_menu_item_set_active_no_signal( ui::RadioMenuItem item, gboolean active ){
{
for ( GSList* l = gtk_radio_menu_item_get_group( item ); l != 0; l = g_slist_next( l ) )
{
}
-void menu_item_set_accelerator( GtkMenuItem* item, GClosure* closure ){
+void menu_item_set_accelerator( ui::MenuItem item, GClosure* closure ){
GtkAccelLabel* accel_label = GTK_ACCEL_LABEL( gtk_bin_get_child( GTK_BIN( item ) ) );
gtk_accel_label_set_accel_closure( accel_label, closure );
}
}
}
-void menu_item_set_accelerator( GtkMenuItem* item, Accelerator accelerator ){
- GtkAccelLabel* accel_label = GTK_ACCEL_LABEL( gtk_bin_get_child( GTK_BIN( item ) ) );
-
- g_free( accel_label->accel_string );
- accel_label->accel_string = 0;
-
- GString* gstring = g_string_new( accel_label->accel_string );
- g_string_append( gstring, " " );
-
- accelerator_name( accelerator, gstring );
-
- g_free( accel_label->accel_string );
- accel_label->accel_string = gstring->str;
- g_string_free( gstring, FALSE );
-
- if ( !accel_label->accel_string ) {
- accel_label->accel_string = g_strdup( "" );
- }
-
- gtk_widget_queue_resize( GTK_WIDGET( accel_label ) );
-}
-
-void menu_item_add_accelerator( GtkMenuItem* item, Accelerator accelerator ){
- if ( accelerator.key != 0 ) {
+void menu_item_add_accelerator( ui::MenuItem item, Accelerator accelerator ){
+ if ( accelerator.key != 0 && gtk_accelerator_valid( accelerator.key, accelerator.modifiers )) {
GClosure* closure = global_accel_group_find( accelerator );
- if ( closure != 0 ) {
- menu_item_set_accelerator( item, closure );
- }
- else
- {
- menu_item_set_accelerator( item, accelerator );
- }
+ ASSERT_NOTNULL(closure);
+ menu_item_set_accelerator( item, closure );
}
}
-GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Command& command ){
- GtkMenuItem* item = create_menu_item_with_mnemonic( menu, mnemonic, command.m_callback );
+ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Command& command ){
+ auto item = create_menu_item_with_mnemonic( menu, mnemonic, command.m_callback );
menu_item_add_accelerator( item, command.m_accelerator );
return item;
}
-void check_menu_item_set_active_callback( GtkCheckMenuItem& item, bool enabled ){
- check_menu_item_set_active_no_signal( &item, enabled );
+void check_menu_item_set_active_callback(void *it, bool enabled ){
+ auto item = ui::CheckMenuItem::from(it);
+ check_menu_item_set_active_no_signal( item, enabled );
}
-typedef ReferenceCaller1<GtkCheckMenuItem, bool, check_menu_item_set_active_callback> CheckMenuItemSetActiveCaller;
-GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Toggle& toggle ){
- GtkCheckMenuItem* item = create_check_menu_item_with_mnemonic( menu, mnemonic, toggle.m_command.m_callback );
- menu_item_add_accelerator( GTK_MENU_ITEM( item ), toggle.m_command.m_accelerator );
- toggle.m_exportCallback( CheckMenuItemSetActiveCaller( *item ) );
+ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Toggle& toggle ){
+ auto item = create_check_menu_item_with_mnemonic( menu, mnemonic, toggle.m_command.m_callback );
+ menu_item_add_accelerator( item, toggle.m_command.m_accelerator );
+ toggle.m_exportCallback( PointerCaller<void, void(bool), check_menu_item_set_active_callback>( item._handle ) );
return item;
}
#if !defined( INCLUDED_GTKUTIL_MENU_H )
#define INCLUDED_GTKUTIL_MENU_H
-#include "generic/callbackfwd.h"
+#include <uilib/uilib.h>
+#include "generic/callback.h"
typedef int gint;
typedef gint gboolean;
typedef struct _GSList GSList;
-typedef struct _GtkMenu GtkMenu;
-typedef struct _GtkMenuBar GtkMenuBar;
-typedef struct _GtkMenuItem GtkMenuItem;
-typedef struct _GtkCheckMenuItem GtkCheckMenuItem;
-typedef struct _GtkRadioMenuItem GtkRadioMenuItem;
-typedef struct _GtkTearoffMenuItem GtkTearoffMenuItem;
-
-void menu_add_item( GtkMenu* menu, GtkMenuItem* item );
-GtkMenuItem* menu_separator( GtkMenu* menu );
-GtkTearoffMenuItem* menu_tearoff( GtkMenu* menu );
-GtkMenuItem* new_sub_menu_item_with_mnemonic( const char* mnemonic );
-GtkMenu* create_sub_menu_with_mnemonic( GtkMenuBar* bar, const char* mnemonic );
-GtkMenu* create_sub_menu_with_mnemonic( GtkMenu* parent, const char* mnemonic );
-GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Callback& callback );
-GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Callback& callback );
-GtkRadioMenuItem* create_radio_menu_item_with_mnemonic( GtkMenu* menu, GSList** group, const char* mnemonic, const Callback& callback );
+
+void menu_add_item( ui::Menu menu, ui::MenuItem item );
+ui::MenuItem menu_separator( ui::Menu menu );
+ui::TearoffMenuItem menu_tearoff( ui::Menu menu );
+ui::MenuItem new_sub_menu_item_with_mnemonic( const char* mnemonic );
+ui::Menu create_sub_menu_with_mnemonic( ui::MenuBar bar, const char* mnemonic );
+ui::Menu create_sub_menu_with_mnemonic( ui::Menu parent, const char* mnemonic );
+ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Callback<void()>& callback );
+ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Callback<void()>& callback );
+ui::RadioMenuItem create_radio_menu_item_with_mnemonic( ui::Menu menu, GSList** group, const char* mnemonic, const Callback<void()>& callback );
class Command;
-GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Command& command );
+ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Command& command );
class Toggle;
-GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const Toggle& toggle );
+ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const Toggle& toggle );
-typedef struct _GtkCheckMenuItem GtkCheckMenuItem;
-void check_menu_item_set_active_no_signal( GtkCheckMenuItem* item, gboolean active );
-typedef struct _GtkRadioMenuItem GtkRadioMenuItem;
-void radio_menu_item_set_active_no_signal( GtkRadioMenuItem* item, gboolean active );
+void check_menu_item_set_active_no_signal( ui::CheckMenuItem item, gboolean active );
+void radio_menu_item_set_active_no_signal( ui::RadioMenuItem item, gboolean active );
#endif
#include "messagebox.h"
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkalignment.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtkstock.h>
+#include <gtk/gtk.h>
#include "dialog.h"
#include "widget.h"
-GtkWidget* create_padding( int width, int height ){
- GtkWidget* widget = gtk_alignment_new( 0.0, 0.0, 0.0, 0.0 );
- gtk_widget_show( widget );
- gtk_widget_set_size_request( widget, width, height );
+ui::Widget create_padding( int width, int height ){
+ ui::Alignment widget = ui::Alignment( 0.0, 0.0, 0.0, 0.0 );
+ widget.show();
+ widget.dimensions(width, height);
return widget;
}
}
}
-EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){
+EMessageBoxReturn gtk_MessageBox( ui::Window parentWindow, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){
ModalDialog dialog;
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
ModalDialogButton yes_button( dialog, eIDYES );
ModalDialogButton no_button( dialog, eIDNO );
- GtkWindow* parentWindow = parent != 0 ? GTK_WINDOW( parent ) : 0;
+ ui::Window window = create_fixedsize_modal_dialog_window( parentWindow, title, dialog, 400, 100 );
- GtkWindow* window = create_fixedsize_modal_dialog_window( parentWindow, title, dialog, 400, 100 );
-
- if ( parentWindow != 0 ) {
- //g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(floating_window_delete_present), parent);
+ if ( parentWindow ) {
+ //window.connect( "delete_event", G_CALLBACK(floating_window_delete_present), parent);
gtk_window_deiconify( parentWindow );
}
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel );
- GtkVBox* vbox = create_dialog_vbox( 8, 8 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) );
+ auto vbox = create_dialog_vbox( 8, 8 );
+ window.add(vbox);
- GtkHBox* hboxDummy = create_dialog_hbox( 0, 0 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hboxDummy ), FALSE, FALSE, 0 );
+ auto hboxDummy = create_dialog_hbox( 0, 0 );
+ vbox.pack_start( hboxDummy, FALSE, FALSE, 0 );
- gtk_box_pack_start( GTK_BOX( hboxDummy ), create_padding( 0, 50 ), FALSE, FALSE, 0 ); // HACK to force minimum height
+ hboxDummy.pack_start( create_padding( 0, 50 ), FALSE, FALSE, 0 ); // HACK to force minimum height
- GtkHBox* iconBox = create_dialog_hbox( 16, 0 );
- gtk_box_pack_start( GTK_BOX( hboxDummy ), GTK_WIDGET( iconBox ), FALSE, FALSE, 0 );
+ auto iconBox = create_dialog_hbox( 16, 0 );
+ hboxDummy.pack_start( iconBox, FALSE, FALSE, 0 );
- GtkImage* image = GTK_IMAGE( gtk_image_new_from_stock( messagebox_stock_icon( icon ), GTK_ICON_SIZE_DIALOG ) );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_box_pack_start( GTK_BOX( iconBox ), GTK_WIDGET( image ), FALSE, FALSE, 0 );
+ auto image = ui::Image::from( gtk_image_new_from_stock( messagebox_stock_icon( icon ), GTK_ICON_SIZE_DIALOG ) );
+ image.show();
+ iconBox.pack_start( image, FALSE, FALSE, 0 );
- GtkLabel* label = GTK_LABEL( gtk_label_new( text ) );
- gtk_widget_show( GTK_WIDGET( label ) );
+ auto label = ui::Label( text );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
gtk_label_set_justify( label, GTK_JUSTIFY_LEFT );
gtk_label_set_line_wrap( label, TRUE );
- gtk_box_pack_start( GTK_BOX( iconBox ), GTK_WIDGET( label ), TRUE, TRUE, 0 );
+ iconBox.pack_start( label, TRUE, TRUE, 0 );
- GtkVBox* vboxDummy = create_dialog_vbox( 0, 0 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( vboxDummy ), FALSE, FALSE, 0 );
+ auto vboxDummy = create_dialog_vbox( 0, 0 );
+ vbox.pack_start( vboxDummy, FALSE, FALSE, 0 );
- GtkAlignment* alignment = GTK_ALIGNMENT( gtk_alignment_new( 0.5, 0.0, 0.0, 0.0 ) );
- gtk_widget_show( GTK_WIDGET( alignment ) );
- gtk_box_pack_start( GTK_BOX( vboxDummy ), GTK_WIDGET( alignment ), FALSE, FALSE, 0 );
+ auto alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 );
+ alignment.show();
+ vboxDummy.pack_start( alignment, FALSE, FALSE, 0 );
- GtkHBox* hbox = create_dialog_hbox( 8, 0 );
- gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 8, 0 );
+ alignment.add(hbox);
- gtk_box_pack_start( GTK_BOX( vboxDummy ), create_padding( 400, 0 ), FALSE, FALSE, 0 ); // HACK to force minimum width
+ vboxDummy.pack_start( create_padding( 400, 0 ), FALSE, FALSE, 0 ); // HACK to force minimum width
if ( type == eMB_OK ) {
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_show( GTK_WIDGET( button ) );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ hbox.pack_start( button, TRUE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ widget_make_default( button );
+ button.show();
dialog.ret = eIDOK;
}
else if ( type == eMB_OKCANCEL ) {
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_show( GTK_WIDGET( button ) );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ hbox.pack_start( button, TRUE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ widget_make_default( button );
+ button.show();
}
{
- GtkButton* button = create_modal_dialog_button( "OK", cancel_button );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
- gtk_widget_show( GTK_WIDGET( button ) );
+ auto button = create_modal_dialog_button( "OK", cancel_button );
+ hbox.pack_start( button, TRUE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ button.show();
}
dialog.ret = eIDCANCEL;
}
else if ( type == eMB_YESNOCANCEL ) {
{
- GtkButton* button = create_modal_dialog_button( "Yes", yes_button );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_show( GTK_WIDGET( button ) );
+ auto button = create_modal_dialog_button( "Yes", yes_button );
+ hbox.pack_start( button, TRUE, FALSE, 0 );
+ widget_make_default( button );
+ button.show();
}
{
- GtkButton* button = create_modal_dialog_button( "No", no_button );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- gtk_widget_show( GTK_WIDGET( button ) );
+ auto button = create_modal_dialog_button( "No", no_button );
+ hbox.pack_start( button, TRUE, FALSE, 0 );
+ button.show();
}
{
- GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- gtk_widget_show( GTK_WIDGET( button ) );
+ auto button = create_modal_dialog_button( "Cancel", cancel_button );
+ hbox.pack_start( button, TRUE, FALSE, 0 );
+ button.show();
}
dialog.ret = eIDCANCEL;
}
else if ( type == eMB_NOYES ) {
{
- GtkButton* button = create_modal_dialog_button( "No", no_button );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_show( GTK_WIDGET( button ) );
+ auto button = create_modal_dialog_button( "No", no_button );
+ hbox.pack_start( button, TRUE, FALSE, 0 );
+ widget_make_default( button );
+ button.show();
}
{
- GtkButton* button = create_modal_dialog_button( "Yes", yes_button );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- gtk_widget_show( GTK_WIDGET( button ) );
+ auto button = create_modal_dialog_button( "Yes", yes_button );
+ hbox.pack_start( button, TRUE, FALSE, 0 );
+ button.show();
}
dialog.ret = eIDNO;
else /* if (type == eMB_YESNO) */
{
{
- GtkButton* button = create_modal_dialog_button( "Yes", yes_button );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_show( GTK_WIDGET( button ) );
+ auto button = create_modal_dialog_button( "Yes", yes_button );
+ hbox.pack_start( button, TRUE, FALSE, 0 );
+ widget_make_default( button );
+ button.show();
}
{
- GtkButton* button = create_modal_dialog_button( "No", no_button );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- gtk_widget_show( GTK_WIDGET( button ) );
+ auto button = create_modal_dialog_button( "No", no_button );
+ hbox.pack_start( button, TRUE, FALSE, 0 );
+ button.show();
}
dialog.ret = eIDNO;
}
modal_dialog_show( window, dialog );
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
return dialog.ret;
}
#include "qerplugin.h"
-typedef struct _GtkWidget GtkWidget;
/// \brief Shows a modal message-box.
-EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT );
+EMessageBoxReturn gtk_MessageBox( ui::Window parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT );
#endif
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
+#include "nonmodal.h"
- This file is part of GtkRadiant.
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
- GtkRadiant 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.
+gboolean escape_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data)
+{
+ if (event->keyval == GDK_KEY_Escape) {
+ gtk_window_set_focus(widget.window(), NULL);
+ return TRUE;
+ }
+ return FALSE;
+}
- GtkRadiant 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.
+void widget_connect_escape_clear_focus_widget(ui::Widget widget)
+{
+ widget.connect("key_press_event", G_CALLBACK(escape_clear_focus_widget), 0);
+}
- You should have received a copy of the GNU General Public License
- along with GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
+gboolean NonModalEntry::focus_in(ui::Entry entry, GdkEventFocus *event, NonModalEntry *self)
+{
+ self->m_editing = false;
+ return FALSE;
+}
-#include "nonmodal.h"
+gboolean NonModalEntry::focus_out(ui::Entry entry, GdkEventFocus *event, NonModalEntry *self)
+{
+ if (self->m_editing && gtk_widget_get_visible(entry)) {
+ self->m_apply();
+ }
+ self->m_editing = false;
+ return FALSE;
+}
+
+gboolean NonModalEntry::changed(ui::Entry entry, NonModalEntry *self)
+{
+ self->m_editing = true;
+ return FALSE;
+}
+
+gboolean NonModalEntry::enter(ui::Entry entry, GdkEventKey *event, NonModalEntry *self)
+{
+ if (event->keyval == GDK_KEY_Return) {
+ self->m_apply();
+ self->m_editing = false;
+ gtk_window_set_focus(entry.window(), NULL);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gboolean NonModalEntry::escape(ui::Entry entry, GdkEventKey *event, NonModalEntry *self)
+{
+ if (event->keyval == GDK_KEY_Escape) {
+ self->m_cancel();
+ self->m_editing = false;
+ gtk_window_set_focus(entry.window(), NULL);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void NonModalEntry::connect(ui::Entry entry)
+{
+ entry.connect("focus_in_event", G_CALLBACK(focus_in), this);
+ entry.connect("focus_out_event", G_CALLBACK(focus_out), this);
+ entry.connect("key_press_event", G_CALLBACK(enter), this);
+ entry.connect("key_press_event", G_CALLBACK(escape), this);
+ entry.connect("changed", G_CALLBACK(changed), this);
+}
+
+gboolean NonModalSpinner::changed(ui::SpinButton spin, NonModalSpinner *self)
+{
+ self->m_apply();
+ return FALSE;
+}
+
+gboolean NonModalSpinner::enter(ui::SpinButton spin, GdkEventKey *event, NonModalSpinner *self)
+{
+ if (event->keyval == GDK_KEY_Return) {
+ gtk_window_set_focus(spin.window(), NULL);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gboolean NonModalSpinner::escape(ui::SpinButton spin, GdkEventKey *event, NonModalSpinner *self)
+{
+ if (event->keyval == GDK_KEY_Escape) {
+ self->m_cancel();
+ gtk_window_set_focus(spin.window(), NULL);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void NonModalSpinner::connect(ui::SpinButton spin)
+{
+ auto adj = ui::Adjustment::from(gtk_spin_button_get_adjustment(spin));
+ guint handler = adj.connect("value_changed", G_CALLBACK(changed), this);
+ g_object_set_data(G_OBJECT(spin), "handler", gint_to_pointer(handler));
+ spin.connect("key_press_event", G_CALLBACK(enter), this);
+ spin.connect("key_press_event", G_CALLBACK(escape), this);
+}
+
+void NonModalRadio::connect(ui::RadioButton radio)
+{
+ GSList *group = gtk_radio_button_get_group(radio);
+ for (; group != 0; group = g_slist_next(group)) {
+ toggle_button_connect_callback(ui::ToggleButton::from(group->data), m_changed);
+ }
+}
#if !defined( INCLUDED_GTKUTIL_NONMODAL_H )
#define INCLUDED_GTKUTIL_NONMODAL_H
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkspinbutton.h>
-#include <gtk/gtkradiobutton.h>
-#include <gdk/gdkkeysyms.h>
-
+#include <gdk/gdk.h>
#include "generic/callback.h"
#include "pointer.h"
#include "button.h"
-typedef struct _GtkEntry GtkEntry;
-
-
-inline gboolean escape_clear_focus_widget( GtkWidget* widget, GdkEventKey* event, gpointer data ){
- if ( event->keyval == GDK_Escape ) {
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), NULL );
- return TRUE;
- }
- return FALSE;
-}
-
-inline void widget_connect_escape_clear_focus_widget( GtkWidget* widget ){
- g_signal_connect( G_OBJECT( widget ), "key_press_event", G_CALLBACK( escape_clear_focus_widget ), 0 );
-}
-
-
-class NonModalEntry
-{
-bool m_editing;
-Callback m_apply;
-Callback m_cancel;
-
-static gboolean focus_in( GtkEntry* entry, GdkEventFocus *event, NonModalEntry* self ){
- self->m_editing = false;
- return FALSE;
-}
-
-static gboolean focus_out( GtkEntry* entry, GdkEventFocus *event, NonModalEntry* self ){
- if ( self->m_editing && GTK_WIDGET_VISIBLE( entry ) ) {
- self->m_apply();
- }
- self->m_editing = false;
- return FALSE;
-}
-
-static gboolean changed( GtkEntry* entry, NonModalEntry* self ){
- self->m_editing = true;
- return FALSE;
-}
-
-static gboolean enter( GtkEntry* entry, GdkEventKey* event, NonModalEntry* self ){
- if ( event->keyval == GDK_Return ) {
- self->m_apply();
- self->m_editing = false;
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( entry ) ) ), NULL );
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean escape( GtkEntry* entry, GdkEventKey* event, NonModalEntry* self ){
- if ( event->keyval == GDK_Escape ) {
- self->m_cancel();
- self->m_editing = false;
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( entry ) ) ), NULL );
- return TRUE;
- }
- return FALSE;
-}
+gboolean escape_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data);
+
+void widget_connect_escape_clear_focus_widget(ui::Widget widget);
+
+class NonModalEntry {
+ bool m_editing;
+ Callback<void()> m_apply;
+ Callback<void()> m_cancel;
+
+ static gboolean focus_in(ui::Entry entry, GdkEventFocus *event, NonModalEntry *self);
+
+ static gboolean focus_out(ui::Entry entry, GdkEventFocus *event, NonModalEntry *self);
+
+ static gboolean changed(ui::Entry entry, NonModalEntry *self);
+
+ static gboolean enter(ui::Entry entry, GdkEventKey *event, NonModalEntry *self);
+
+ static gboolean escape(ui::Entry entry, GdkEventKey *event, NonModalEntry *self);
public:
-NonModalEntry( const Callback& apply, const Callback& cancel ) : m_editing( false ), m_apply( apply ), m_cancel( cancel ){
-}
-void connect( GtkEntry* entry ){
- g_signal_connect( G_OBJECT( entry ), "focus_in_event", G_CALLBACK( focus_in ), this );
- g_signal_connect( G_OBJECT( entry ), "focus_out_event", G_CALLBACK( focus_out ), this );
- g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( enter ), this );
- g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( escape ), this );
- g_signal_connect( G_OBJECT( entry ), "changed", G_CALLBACK( changed ), this );
-}
+ NonModalEntry(const Callback<void()> &apply, const Callback<void()> &cancel) : m_editing(false), m_apply(apply), m_cancel(cancel)
+ {
+ }
+
+ void connect(ui::Entry entry);
};
-class NonModalSpinner
-{
-Callback m_apply;
-Callback m_cancel;
-
-static gboolean changed( GtkSpinButton* spin, NonModalSpinner* self ){
- self->m_apply();
- return FALSE;
-}
-
-static gboolean enter( GtkSpinButton* spin, GdkEventKey* event, NonModalSpinner* self ){
- if ( event->keyval == GDK_Return ) {
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( spin ) ) ), NULL );
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean escape( GtkSpinButton* spin, GdkEventKey* event, NonModalSpinner* self ){
- if ( event->keyval == GDK_Escape ) {
- self->m_cancel();
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( spin ) ) ), NULL );
- return TRUE;
- }
- return FALSE;
-}
+class NonModalSpinner {
+ Callback<void()> m_apply;
+ Callback<void()> m_cancel;
+
+ static gboolean changed(ui::SpinButton spin, NonModalSpinner *self);
+
+ static gboolean enter(ui::SpinButton spin, GdkEventKey *event, NonModalSpinner *self);
+
+ static gboolean escape(ui::SpinButton spin, GdkEventKey *event, NonModalSpinner *self);
public:
-NonModalSpinner( const Callback& apply, const Callback& cancel ) : m_apply( apply ), m_cancel( cancel ){
-}
-void connect( GtkSpinButton* spin ){
- guint handler = g_signal_connect( G_OBJECT( gtk_spin_button_get_adjustment( spin ) ), "value_changed", G_CALLBACK( changed ), this );
- g_object_set_data( G_OBJECT( spin ), "handler", gint_to_pointer( handler ) );
- g_signal_connect( G_OBJECT( spin ), "key_press_event", G_CALLBACK( enter ), this );
- g_signal_connect( G_OBJECT( spin ), "key_press_event", G_CALLBACK( escape ), this );
-}
+ NonModalSpinner(const Callback<void()> &apply, const Callback<void()> &cancel) : m_apply(apply), m_cancel(cancel)
+ {
+ }
+
+ void connect(ui::SpinButton spin);
};
-class NonModalRadio
-{
-Callback m_changed;
+class NonModalRadio {
+ Callback<void()> m_changed;
public:
-NonModalRadio( const Callback& changed ) : m_changed( changed ){
-}
-void connect( GtkRadioButton* radio ){
- GSList* group = gtk_radio_button_group( radio );
- for (; group != 0; group = g_slist_next( group ) )
- {
- toggle_button_connect_callback( GTK_TOGGLE_BUTTON( group->data ), m_changed );
- }
-}
+ NonModalRadio(const Callback<void()> &changed) : m_changed(changed)
+ {
+ }
+
+ void connect(ui::RadioButton radio);
};
#include "paned.h"
-#include <gtk/gtkhpaned.h>
-#include <gtk/gtkvpaned.h>
+#include <gtk/gtk.h>
#include "frame.h"
int size;
};
-gboolean hpaned_allocate( GtkWidget* widget, GtkAllocation* allocation, PanedState* paned ){
+gboolean hpaned_allocate(ui::Widget widget, GtkAllocation* allocation, PanedState* paned ){
if ( paned->size != allocation->width ) {
paned->size = allocation->width;
gtk_paned_set_position( GTK_PANED( widget ), static_cast<int>( paned->size * paned->position ) );
return FALSE;
}
-gboolean vpaned_allocate( GtkWidget* widget, GtkAllocation* allocation, PanedState* paned ){
+gboolean vpaned_allocate(ui::Widget widget, GtkAllocation* allocation, PanedState* paned ){
if ( paned->size != allocation->height ) {
paned->size = allocation->height;
gtk_paned_set_position( GTK_PANED( widget ), static_cast<int>( paned->size * paned->position ) );
return FALSE;
}
-gboolean paned_position( GtkWidget* widget, gpointer dummy, PanedState* paned ){
+gboolean paned_position(ui::Widget widget, gpointer dummy, PanedState* paned ){
if ( paned->size != -1 ) {
paned->position = gtk_paned_get_position( GTK_PANED( widget ) ) / static_cast<float>( paned->size );
}
PanedState g_vpaned1 = { 0.5f, -1, };
PanedState g_vpaned2 = { 0.5f, -1, };
-GtkWidget* create_split_views( GtkWidget* topleft, GtkWidget* botleft, GtkWidget* topright, GtkWidget* botright, GtkWidget*& vsplit1, GtkWidget*& vsplit2 ){
- GtkHPaned* hsplit = GTK_HPANED( gtk_hpaned_new() );
- gtk_widget_show( GTK_WIDGET( hsplit ) );
+ui::Widget create_split_views( ui::Widget topleft, ui::Widget topright, ui::Widget botleft, ui::Widget botright, ui::Widget& vsplit1, ui::Widget& vsplit2 ){
+ auto hsplit = ui::HPaned(ui::New);
+ hsplit.show();
- g_signal_connect( G_OBJECT( hsplit ), "size_allocate", G_CALLBACK( hpaned_allocate ), &g_hpaned );
- g_signal_connect( G_OBJECT( hsplit ), "notify::position", G_CALLBACK( paned_position ), &g_hpaned );
+ hsplit.connect( "size_allocate", G_CALLBACK( hpaned_allocate ), &g_hpaned );
+ hsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_hpaned );
{
- GtkVPaned* vsplit = GTK_VPANED( gtk_vpaned_new() );
- vsplit1 = GTK_WIDGET( vsplit );
+ auto vsplit = ui::VPaned(ui::New);
+ vsplit1 = vsplit;
gtk_paned_add1( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) );
gtk_widget_show( GTK_WIDGET( vsplit ) );
- g_signal_connect( G_OBJECT( vsplit ), "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned1 );
- g_signal_connect( G_OBJECT( vsplit ), "notify::position", G_CALLBACK( paned_position ), &g_vpaned1 );
+ vsplit.connect( "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned1 );
+ vsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_vpaned1 );
gtk_paned_add1( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( topleft ) ) );
gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( botleft ) ) );
}
{
- GtkVPaned* vsplit = GTK_VPANED( gtk_vpaned_new() );
- vsplit2 = GTK_WIDGET( vsplit );
+ auto vsplit = ui::VPaned(ui::New);
+ vsplit2 = vsplit;
gtk_paned_add2( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) );
gtk_widget_show( GTK_WIDGET( vsplit ) );
- g_signal_connect( G_OBJECT( vsplit ), "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned2 );
- g_signal_connect( G_OBJECT( vsplit ), "notify::position", G_CALLBACK( paned_position ), &g_vpaned2 );
+ vsplit.connect( "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned2 );
+ vsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_vpaned2 );
gtk_paned_add1( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( topright ) ) );
gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( botright ) ) );
}
- return GTK_WIDGET( hsplit );
+ return hsplit;
}
#if !defined( INCLUDED_GTKUTIL_PANED_H )
#define INCLUDED_GTKUTIL_PANED_H
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkHPaned GtkHPaned;
-GtkWidget* create_split_views( GtkWidget* topleft, GtkWidget* botleft, GtkWidget* topright, GtkWidget* botright, GtkWidget*& vsplit1, GtkWidget*& vsplit2 );
+#include <uilib/uilib.h>
+
+ui::Widget create_split_views( ui::Widget topleft, ui::Widget botleft, ui::Widget topright, ui::Widget botright, ui::Widget& vsplit1, ui::Widget& vsplit2 );
#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "pointer.h"
#include "toolbar.h"
-#include <gtk/gtktoolbar.h>
-#include <gtk/gtktogglebutton.h>
+#include <uilib/uilib.h>
+#include <gtk/gtk.h>
#include "generic/callback.h"
#include "accelerator.h"
#include "button.h"
-#include "closure.h"
-#include "pointer.h"
+#include "image.h"
-void toolbar_append( GtkToolbar* toolbar, GtkButton* button, const char* description ){
- gtk_widget_show( GTK_WIDGET( button ) );
- gtk_button_set_relief( button, GTK_RELIEF_NONE );
- GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_FOCUS );
- GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_DEFAULT );
- gtk_toolbar_append_element( toolbar, GTK_TOOLBAR_CHILD_WIDGET, GTK_WIDGET( button ), "", description, "", 0, 0, 0 );
+void toolbar_append( ui::Toolbar toolbar, ui::ToolItem button, const char* description ){
+ gtk_widget_show_all(button);
+ gtk_widget_set_tooltip_text(button, description);
+ toolbar.add(button);
}
-GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){
- GtkButton* button = GTK_BUTTON( gtk_button_new() );
- button_set_icon( button, icon );
- button_connect_callback( button, callback );
- toolbar_append( toolbar, button, description );
+ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon ){
+ auto button = ui::ToolButton::from(gtk_tool_button_new(new_local_image(icon), nullptr));
+ toolbar_append(toolbar, button, description);
return button;
}
-GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback ){
- GtkToggleButton* button = GTK_TOGGLE_BUTTON( gtk_toggle_button_new() );
- button_set_icon( GTK_BUTTON( button ), icon );
- toggle_button_connect_callback( button, callback );
- toolbar_append( toolbar, GTK_BUTTON( button ), description );
+ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback<void()>& callback ){
+ auto button = ui::ToolButton::from(gtk_tool_button_new(new_local_image(icon), nullptr));
+ button_connect_callback(button, callback);
+ toolbar_append(toolbar, button, description);
return button;
}
-GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command ){
+ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback<void()>& callback ){
+ auto button = ui::ToggleToolButton::from(gtk_toggle_tool_button_new());
+ toggle_button_connect_callback(button, callback);
+ gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), new_local_image(icon));
+ gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), description);
+ toolbar_append(toolbar, button, description);
+ return button;
+}
+
+ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Command& command ){
return toolbar_append_button( toolbar, description, icon, command.m_callback );
}
-void toggle_button_set_active_callback( GtkToggleButton& button, bool active ){
- toggle_button_set_active_no_signal( &button, active );
+void toggle_button_set_active_callback(void *it, bool active ){
+ auto button = ui::ToggleToolButton::from(it);
+ toggle_button_set_active_no_signal( button, active );
}
-typedef ReferenceCaller1<GtkToggleButton, bool, toggle_button_set_active_callback> ToggleButtonSetActiveCaller;
-GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle ){
- GtkToggleButton* button = toolbar_append_toggle_button( toolbar, description, icon, toggle.m_command.m_callback );
- toggle.m_exportCallback( ToggleButtonSetActiveCaller( *button ) );
+ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Toggle& toggle ){
+ auto button = toolbar_append_toggle_button( toolbar, description, icon, toggle.m_command.m_callback );
+ toggle.m_exportCallback( PointerCaller<void, void(bool), toggle_button_set_active_callback>( button._handle ) );
return button;
}
#if !defined( INCLUDED_GTKUTIL_TOOLBAR_H )
#define INCLUDED_GTKUTIL_TOOLBAR_H
-#include "generic/callbackfwd.h"
+#include <uilib/uilib.h>
+#include "generic/callback.h"
-typedef struct _GtkButton GtkButton;
-typedef struct _GtkToggleButton GtkToggleButton;
-typedef struct _GtkToolbar GtkToolbar;
class Command;
class Toggle;
-GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback );
-GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const Command& command );
-GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Callback& callback );
-GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const Toggle& toggle );
+ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon );
+ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback<void()>& callback );
+ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Command& command );
+ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback<void()>& callback );
+ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const Toggle& toggle );
#endif
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
+#include "widget.h"
+#include <gtk/gtk.h>
- This file is part of GtkRadiant.
+void widget_queue_draw(ui::Widget &widget)
+{
+ gtk_widget_queue_draw(widget);
+}
- GtkRadiant 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.
+void widget_make_default(ui::Widget widget)
+{
+ gtk_widget_set_can_default(widget, true);
+ gtk_widget_grab_default(widget);
+}
- GtkRadiant 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.
+gboolean ToggleShown::notify_visible(ui::Widget widget, gpointer dummy, ToggleShown *self)
+{
+ self->update();
+ return FALSE;
+}
- You should have received a copy of the GNU General Public License
- along with GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
+gboolean ToggleShown::destroy(ui::Widget widget, ToggleShown *self)
+{
+ self->m_shownDeferred = gtk_widget_get_visible(self->m_widget) != FALSE;
+ self->m_widget = ui::Widget(ui::null);
+ return FALSE;
+}
-#include "widget.h"
+void ToggleShown::update()
+{
+ m_item.update();
+}
+
+bool ToggleShown::active() const
+{
+ if (!m_widget) {
+ return m_shownDeferred;
+ } else {
+ return gtk_widget_get_visible(m_widget) != FALSE;
+ }
+}
+
+void ToggleShown::exportActive(const Callback<void(bool)> &importCallback)
+{
+ importCallback(active());
+}
+
+void ToggleShown::set(bool shown)
+{
+ if (!m_widget) {
+ m_shownDeferred = shown;
+ } else {
+ m_widget.visible(shown);
+ }
+}
+
+void ToggleShown::toggle()
+{
+ m_widget.visible(!m_widget.visible());
+}
+
+void ToggleShown::connect(ui::Widget widget)
+{
+ m_widget = widget;
+ m_widget.visible(m_shownDeferred);
+ m_widget.connect("notify::visible", G_CALLBACK(notify_visible), this);
+ m_widget.connect("destroy", G_CALLBACK(destroy), this);
+ update();
+}
+
+gboolean WidgetFocusPrinter::focus_in(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self)
+{
+ globalOutputStream() << self->m_name << " takes focus\n";
+ return FALSE;
+}
+
+gboolean WidgetFocusPrinter::focus_out(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self)
+{
+ globalOutputStream() << self->m_name << " loses focus\n";
+ return FALSE;
+}
+
+void WidgetFocusPrinter::connect(ui::Widget widget)
+{
+ widget.connect("focus_in_event", G_CALLBACK(focus_in), this);
+ widget.connect("focus_out_event", G_CALLBACK(focus_out), this);
+}
#define INCLUDED_GTKUTIL_WIDGET_H
#include <list>
-#include <gtk/gtkwidget.h>
+#include <uilib/uilib.h>
+#include <gdk/gdk.h>
#include "generic/callback.h"
#include "warnings.h"
#include "debugging/debugging.h"
+#include "property.h"
+#define GARUX_GTK_WORKAROUND
+#ifndef GARUX_GTK_WORKAROUND
inline bool widget_is_visible( GtkWidget* widget ){
return GTK_WIDGET_VISIBLE( widget ) != FALSE;
}
gtk_widget_hide( widget );
}
}
+#endif
+
+class ToggleItem {
+ Callback<void(const Callback<void(bool)> &)> m_exportCallback;
+ typedef std::list<Callback<void(bool)>> ImportCallbacks;
+ ImportCallbacks m_importCallbacks;
+public:
+ ToggleItem(const Callback<void(const Callback<void(bool)> &)> &exportCallback) : m_exportCallback(exportCallback)
+ {
+ }
+
+ void update()
+ {
+ for (ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i) {
+ m_exportCallback(*i);
+ }
+ }
+
+ void addCallback(const Callback<void(bool)> &callback)
+ {
+ m_importCallbacks.push_back(callback);
+ m_exportCallback(callback);
+ }
+
+ typedef MemberCaller<ToggleItem, void(const Callback<void(bool)> &), &ToggleItem::addCallback> AddCallbackCaller;
+};
+class ToggleShown {
+ bool m_shownDeferred;
-inline void widget_toggle_visible( GtkWidget* widget ){
- widget_set_visible( widget, !widget_is_visible( widget ) );
-}
+ ToggleShown(const ToggleShown &other); // NOT COPYABLE
+ ToggleShown &operator=(const ToggleShown &other); // NOT ASSIGNABLE
+
+ static gboolean notify_visible(ui::Widget widget, gpointer dummy, ToggleShown *self);
+
+ static gboolean destroy(ui::Widget widget, ToggleShown *self);
-class ToggleItem
-{
-BoolExportCallback m_exportCallback;
-typedef std::list<BoolImportCallback> ImportCallbacks;
-ImportCallbacks m_importCallbacks;
public:
-ToggleItem( const BoolExportCallback& exportCallback ) : m_exportCallback( exportCallback ){
-}
+ ui::Widget m_widget;
+ ToggleItem m_item;
-void update(){
- for ( ImportCallbacks::iterator i = m_importCallbacks.begin(); i != m_importCallbacks.end(); ++i )
- {
- m_exportCallback( *i );
- }
-}
+ ToggleShown(bool shown)
+ : m_shownDeferred(shown), m_widget(ui::null), m_item(ActiveCaller(*this))
+ {
+ }
-void addCallback( const BoolImportCallback& callback ){
- m_importCallbacks.push_back( callback );
- m_exportCallback( callback );
-}
-typedef MemberCaller1<ToggleItem, const BoolImportCallback&, &ToggleItem::addCallback> AddCallbackCaller;
-};
+ void update();
-class ToggleShown
-{
-bool m_shownDeferred;
+ bool active() const;
-ToggleShown( const ToggleShown& other ); // NOT COPYABLE
-ToggleShown& operator=( const ToggleShown& other ); // NOT ASSIGNABLE
+ void exportActive(const Callback<void(bool)> &importCallback);
-static gboolean notify_visible( GtkWidget* widget, gpointer dummy, ToggleShown* self ){
- self->update();
- return FALSE;
-}
-static gboolean destroy( GtkWidget* widget, ToggleShown* self ){
- self->m_shownDeferred = GTK_WIDGET_VISIBLE( self->m_widget ) != FALSE;
- self->m_widget = 0;
- return FALSE;
-}
-public:
-GtkWidget* m_widget;
-ToggleItem m_item;
+ typedef MemberCaller<ToggleShown, void(const Callback<void(bool)> &), &ToggleShown::exportActive> ActiveCaller;
-ToggleShown( bool shown )
- : m_shownDeferred( shown ), m_widget( 0 ), m_item( ActiveCaller( *this ) ){
-}
-void update(){
- m_item.update();
-}
-bool active() const {
- if ( m_widget == 0 ) {
- return m_shownDeferred;
- }
- else
- {
- return GTK_WIDGET_VISIBLE( m_widget ) != FALSE;
- }
-}
-void exportActive( const BoolImportCallback& importCallback ){
- importCallback( active() );
-}
-typedef MemberCaller1<ToggleShown, const BoolImportCallback&, &ToggleShown::exportActive> ActiveCaller;
-void set( bool shown ){
- if ( m_widget == 0 ) {
- m_shownDeferred = shown;
- }
- else
- {
- widget_set_visible( m_widget, shown );
- }
-}
-void toggle(){
- widget_toggle_visible( m_widget );
-}
-typedef MemberCaller<ToggleShown, &ToggleShown::toggle> ToggleCaller;
-void connect( GtkWidget* widget ){
- m_widget = widget;
- widget_set_visible( m_widget, m_shownDeferred );
- g_signal_connect( G_OBJECT( m_widget ), "notify::visible", G_CALLBACK( notify_visible ), this );
- g_signal_connect( G_OBJECT( m_widget ), "destroy", G_CALLBACK( destroy ), this );
- update();
-}
+ void set(bool shown);
+
+ void toggle();
+
+ typedef MemberCaller<ToggleShown, void(), &ToggleShown::toggle> ToggleCaller;
+
+ void connect(ui::Widget widget);
};
-inline void widget_queue_draw( GtkWidget& widget ){
- gtk_widget_queue_draw( &widget );
-}
-typedef ReferenceCaller<GtkWidget, widget_queue_draw> WidgetQueueDrawCaller;
+void widget_queue_draw(ui::Widget &widget);
+typedef ReferenceCaller<ui::Widget, void(), widget_queue_draw> WidgetQueueDrawCaller;
-inline void widget_make_default( GtkWidget* widget ){
- GTK_WIDGET_SET_FLAGS( widget, GTK_CAN_DEFAULT );
- gtk_widget_grab_default( widget );
-}
-class WidgetFocusPrinter
-{
-const char* m_name;
+void widget_make_default(ui::Widget widget);
+
+class WidgetFocusPrinter {
+ const char *m_name;
+
+ static gboolean focus_in(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self);
+
+ static gboolean focus_out(ui::Widget widget, GdkEventFocus *event, WidgetFocusPrinter *self);
-static gboolean focus_in( GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self ){
- globalOutputStream() << self->m_name << " takes focus\n";
- return FALSE;
-}
-static gboolean focus_out( GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self ){
- globalOutputStream() << self->m_name << " loses focus\n";
- return FALSE;
-}
public:
-WidgetFocusPrinter( const char* name ) : m_name( name ){
-}
-void connect( GtkWidget* widget ){
- g_signal_connect( G_OBJECT( widget ), "focus_in_event", G_CALLBACK( focus_in ), this );
- g_signal_connect( G_OBJECT( widget ), "focus_out_event", G_CALLBACK( focus_out ), this );
-}
+ WidgetFocusPrinter(const char *name) : m_name(name)
+ {
+ }
+
+ void connect(ui::Widget widget);
};
#endif
#include "window.h"
-#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtk.h>
#include "pointer.h"
#include "accelerator.h"
-inline void CHECK_RESTORE( GtkWidget* w ){
+inline void CHECK_RESTORE( ui::Widget w ){
if ( gpointer_to_int( g_object_get_data( G_OBJECT( w ), "was_mapped" ) ) != 0 ) {
- gtk_widget_show( w );
+ w.show();
+#define GARUX_GTK_WORKAROUND
+#ifndef GARUX_GTK_WORKAROUND
/* workaround for gtk 2.24 issue: not displayed glwidget after min/restore */
GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( w ), "glwidget" ) );
if ( glwidget ){
gtk_widget_hide( glwidget );
gtk_widget_show( glwidget );
}
+#endif
}
}
-inline void CHECK_MINIMIZE( GtkWidget* w ){
- g_object_set_data( G_OBJECT( w ), "was_mapped", gint_to_pointer( GTK_WIDGET_VISIBLE( w ) ) );
- //gtk_widget_hide( w ); //fix for gtk 2.24 + the whole scheme isn't needed with gtk 2.16, 2.24; they do it all alone
+inline void CHECK_MINIMIZE( ui::Widget w ){
+ g_object_set_data( G_OBJECT( w ), "was_mapped", gint_to_pointer( gtk_widget_get_visible( w ) ) );
+ w.hide();
}
-static gboolean main_window_iconified( GtkWidget* widget, GdkEventWindowState* event, gpointer data ){
+static gboolean main_window_iconified( ui::Widget widget, GdkEventWindowState* event, gpointer data ){
if ( ( event->changed_mask & ( GDK_WINDOW_STATE_ICONIFIED | GDK_WINDOW_STATE_WITHDRAWN ) ) != 0 ) {
if ( ( event->new_window_state & ( GDK_WINDOW_STATE_ICONIFIED | GDK_WINDOW_STATE_WITHDRAWN ) ) != 0 ) {
- CHECK_MINIMIZE( GTK_WIDGET( data ) );
+ CHECK_MINIMIZE( ui::Widget::from( data ) );
}
else
{
- CHECK_RESTORE( GTK_WIDGET( data ) );
+ CHECK_RESTORE( ui::Widget::from( data ) );
}
}
return FALSE;
}
-unsigned int connect_floating( GtkWindow* main_window, GtkWindow* floating ){
- return g_signal_connect( G_OBJECT( main_window ), "window_state_event", G_CALLBACK( main_window_iconified ), floating );
+unsigned int connect_floating( ui::Window main_window, ui::Window floating ){
+ return main_window.connect( "window_state_event", G_CALLBACK( main_window_iconified ), floating );
}
-gboolean destroy_disconnect_floating( GtkWindow* widget, gpointer data ){
+gboolean destroy_disconnect_floating( ui::Window widget, gpointer data ){
g_signal_handler_disconnect( G_OBJECT( data ), gpointer_to_int( g_object_get_data( G_OBJECT( widget ), "floating_handler" ) ) );
return FALSE;
}
-gboolean floating_window_delete_present( GtkWindow* floating, GdkEventFocus *event, GtkWindow* main_window ){
+gboolean floating_window_delete_present( ui::Window floating, GdkEventFocus *event, ui::Window main_window ){
if ( gtk_window_is_active( floating ) || gtk_window_is_active( main_window ) ) {
gtk_window_present( main_window );
}
return FALSE;
}
-guint connect_floating_window_delete_present( GtkWindow* floating, GtkWindow* main_window ){
- return g_signal_connect( G_OBJECT( floating ), "delete_event", G_CALLBACK( floating_window_delete_present ), main_window );
+guint connect_floating_window_delete_present( ui::Window floating, ui::Window main_window ){
+ return floating.connect( "delete_event", G_CALLBACK( floating_window_delete_present ), main_window );
}
-gboolean floating_window_destroy_present( GtkWindow* floating, GtkWindow* main_window ){
+gboolean floating_window_destroy_present( ui::Window floating, ui::Window main_window ){
if ( gtk_window_is_active( floating ) || gtk_window_is_active( main_window ) ) {
gtk_window_present( main_window );
}
return FALSE;
}
-guint connect_floating_window_destroy_present( GtkWindow* floating, GtkWindow* main_window ){
- return g_signal_connect( G_OBJECT( floating ), "destroy", G_CALLBACK( floating_window_destroy_present ), main_window );
+guint connect_floating_window_destroy_present( ui::Window floating, ui::Window main_window ){
+ return floating.connect( "destroy", G_CALLBACK( floating_window_destroy_present ), main_window );
}
-GtkWindow* create_floating_window( const char* title, GtkWindow* parent ){
- GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) );
+ui::Window create_floating_window( const char* title, ui::Window parent ){
+ ui::Window window = ui::Window( ui::window_type::TOP );
gtk_window_set_title( window, title );
- if ( parent != 0 ) {
+ if ( parent ) {
gtk_window_set_transient_for( window, parent );
connect_floating_window_destroy_present( window, parent );
g_object_set_data( G_OBJECT( window ), "floating_handler", gint_to_pointer( connect_floating( parent, window ) ) );
- g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy_disconnect_floating ), parent );
+ window.connect( "destroy", G_CALLBACK( destroy_disconnect_floating ), parent );
/*
//gtk_window_set_type_hint (window,GDK_WINDOW_TYPE_HINT_UTILITY);
//gtk_window_set_type_hint (window,GDK_WINDOW_TYPE_HINT_DIALOG);
return window;
}
-void destroy_floating_window( GtkWindow* window ){
- gtk_widget_destroy( GTK_WIDGET( window ) );
+void destroy_floating_window( ui::Window window ){
+ window.destroy();
}
-gint window_realize_remove_sysmenu( GtkWidget* widget, gpointer data ){
- gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU ) );
+gint window_realize_remove_sysmenu( ui::Widget widget, gpointer data ){
+ gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU ) );
return FALSE;
}
-gboolean persistent_floating_window_delete( GtkWindow* floating, GdkEvent *event, GtkWindow* main_window ){
- gtk_widget_hide( GTK_WIDGET( floating ) );
+gboolean persistent_floating_window_delete( ui::Window floating, GdkEvent *event, ui::Window main_window ){
+ floating.hide();
return TRUE;
}
-GtkWindow* create_persistent_floating_window( const char* title, GtkWindow* main_window ){
- GtkWindow* window = GTK_WINDOW( create_floating_window( title, main_window ) );
+ui::Window create_persistent_floating_window( const char* title, ui::Window main_window ){
+ auto window = create_floating_window( title, main_window );
- gtk_widget_set_events( GTK_WIDGET( window ), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK );
+ gtk_widget_set_events( window , GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK );
connect_floating_window_delete_present( window, main_window );
- g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( persistent_floating_window_delete ), 0 );
+ window.connect( "delete_event", G_CALLBACK( persistent_floating_window_delete ), 0 );
#if 0
if ( g_multimon_globals.m_bStartOnPrimMon && g_multimon_globals.m_bNoSysMenuPopups ) {
- g_signal_connect( G_OBJECT( window ), "realize", G_CALLBACK( window_realize_remove_sysmenu ), 0 );
+ window.connect( "realize", G_CALLBACK( window_realize_remove_sysmenu ), 0 );
}
#endif
return window;
}
-gint window_realize_remove_minmax( GtkWidget* widget, gpointer data ){
- gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) );
+gint window_realize_remove_minmax( ui::Widget widget, gpointer data ){
+ gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) );
return FALSE;
}
-void window_remove_minmax( GtkWindow* window ){
- g_signal_connect( G_OBJECT( window ), "realize", G_CALLBACK( window_realize_remove_minmax ), 0 );
+void window_remove_minmax( ui::Window window ){
+ window.connect( "realize", G_CALLBACK( window_realize_remove_minmax ), 0 );
}
-GtkScrolledWindow* create_scrolled_window( GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, int border ){
- GtkScrolledWindow* scr = GTK_SCROLLED_WINDOW( gtk_scrolled_window_new( 0, 0 ) );
- gtk_widget_show( GTK_WIDGET( scr ) );
- gtk_scrolled_window_set_policy( scr, hscrollbar_policy, vscrollbar_policy );
+ui::ScrolledWindow create_scrolled_window( ui::Policy hscrollbar_policy, ui::Policy vscrollbar_policy, int border ){
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
+ gtk_scrolled_window_set_policy( scr, (GtkPolicyType) hscrollbar_policy, (GtkPolicyType) vscrollbar_policy );
gtk_scrolled_window_set_shadow_type( scr, GTK_SHADOW_IN );
gtk_container_set_border_width( GTK_CONTAINER( scr ), border );
return scr;
}
+
+gboolean window_focus_in_clear_focus_widget(ui::Window widget, GdkEventKey *event, gpointer data)
+{
+ gtk_window_set_focus( widget, NULL );
+ return FALSE;
+}
+
+guint window_connect_focus_in_clear_focus_widget(ui::Window window)
+{
+ return window.connect( "focus_in_event", G_CALLBACK( window_focus_in_clear_focus_widget ), NULL );
+}
+
+void window_get_position(ui::Window window, WindowPosition &position)
+{
+ ASSERT_MESSAGE( window , "error saving window position" );
+
+ gtk_window_get_position( window, &position.x, &position.y );
+ gtk_window_get_size( window, &position.w, &position.h );
+}
+
+void window_set_position(ui::Window window, const WindowPosition &position)
+{
+ gtk_window_set_gravity( window, GDK_GRAVITY_STATIC );
+
+ GdkScreen* screen = gdk_screen_get_default();
+ if ( position.x < 0
+ || position.y < 0
+ || position.x > gdk_screen_get_width( screen )
+ || position.y > gdk_screen_get_height( screen ) ) {
+ gtk_window_set_position( window, GTK_WIN_POS_CENTER_ON_PARENT );
+ }
+ else
+ {
+ gtk_window_move( window, position.x, position.y );
+ }
+
+ gtk_window_set_default_size( window, position.w, position.h );
+}
+
+void WindowPosition_String::Import(WindowPosition &position, const char *value)
+{
+ if ( sscanf( value, "%d %d %d %d", &position.x, &position.y, &position.w, &position.h ) != 4 ) {
+ position = WindowPosition( c_default_window_pos ); // ensure sane default value for window position
+ }
+}
+
+void WindowPosition_String::Export(const WindowPosition &self, const Callback<void(const char *)> &returnz)
+{
+ char buffer[64];
+ sprintf( buffer, "%d %d %d %d", self.x, self.y, self.w, self.h );
+ returnz( buffer );
+}
+
+void WindowPositionTracker_String::Import(WindowPositionTracker &self, const char *value)
+{
+ WindowPosition position;
+ WindowPosition_String::Import( position, value );
+ self.setPosition( position );
+}
+
+void WindowPositionTracker_String::Export(const WindowPositionTracker &self, const Callback<void(const char *)> &returnz)
+{
+ WindowPosition_String::Export( self.getPosition(), returnz );
+}
+
+gboolean WindowPositionTracker::configure(ui::Widget widget, GdkEventConfigure *event, WindowPositionTracker *self)
+{
+ self->m_position = WindowPosition( event->x, event->y, event->width, event->height );
+ return FALSE;
+}
+
+void WindowPositionTracker::sync(ui::Window window)
+{
+ window_set_position( window, m_position );
+}
+
+void WindowPositionTracker::connect(ui::Window window)
+{
+ sync( window );
+ window.connect( "configure_event", G_CALLBACK( configure ), this );
+}
+
+const WindowPosition &WindowPositionTracker::getPosition() const
+{
+ return m_position;
+}
+
+void WindowPositionTracker::setPosition(const WindowPosition &position)
+{
+ m_position = position;
+}
#if !defined( INCLUDED_GTKUTIL_WINDOW_H )
#define INCLUDED_GTKUTIL_WINDOW_H
-#include <gtk/gtkwindow.h>
+#include <uilib/uilib.h>
#include "debugging/debugging.h"
#include "generic/callback.h"
#include "widget.h"
-inline gboolean window_focus_in_clear_focus_widget( GtkWidget* widget, GdkEventKey* event, gpointer data ){
- gtk_window_set_focus( GTK_WINDOW( widget ), NULL );
- return FALSE;
-}
+gboolean window_focus_in_clear_focus_widget(ui::Window widget, GdkEventKey *event, gpointer data);
-inline guint window_connect_focus_in_clear_focus_widget( GtkWindow* window ){
- return g_signal_connect( G_OBJECT( window ), "focus_in_event", G_CALLBACK( window_focus_in_clear_focus_widget ), NULL );
-}
+guint window_connect_focus_in_clear_focus_widget(ui::Window window);
+unsigned int connect_floating(ui::Window main_window, ui::Window floating);
-unsigned int connect_floating( GtkWindow* main_window, GtkWindow* floating );
-GtkWindow* create_floating_window( const char* title, GtkWindow* parent );
-void destroy_floating_window( GtkWindow* window );
+ui::Window create_floating_window(const char *title, ui::Window parent);
-GtkWindow* create_persistent_floating_window( const char* title, GtkWindow* main_window );
-gboolean persistent_floating_window_delete( GtkWindow* floating, GdkEvent *event, GtkWindow* main_window );
+void destroy_floating_window(ui::Window window);
-void window_remove_minmax( GtkWindow* window );
+ui::Window create_persistent_floating_window(const char *title, ui::Window main_window);
-typedef struct _GtkScrolledWindow GtkScrolledWindow;
-GtkScrolledWindow* create_scrolled_window( GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, int border = 0 );
+gboolean persistent_floating_window_delete(ui::Window floating, GdkEvent *event, ui::Window main_window);
+void window_remove_minmax(ui::Window window);
-struct WindowPosition
-{
- int x, y, w, h;
+ui::ScrolledWindow create_scrolled_window(ui::Policy hscrollbar_policy, ui::Policy vscrollbar_policy, int border = 0);
- WindowPosition(){
- }
- WindowPosition( int _x, int _y, int _w, int _h )
- : x( _x ), y( _y ), w( _w ), h( _h ){
- }
-};
-const WindowPosition c_default_window_pos( 50, 25, 400, 300 );
+struct WindowPosition {
+ int x, y, w, h;
-inline void window_get_position( GtkWindow* window, WindowPosition& position ){
- ASSERT_MESSAGE( window != 0, "error saving window position" );
+ WindowPosition()
+ {
+ }
- gtk_window_get_position( window, &position.x, &position.y );
- gtk_window_get_size( window, &position.w, &position.h );
-}
+ WindowPosition(int _x, int _y, int _w, int _h)
+ : x(_x), y(_y), w(_w), h(_h)
+ {
+ }
+};
-inline void window_set_position( GtkWindow* window, const WindowPosition& position ){
- gtk_window_set_gravity( window, GDK_GRAVITY_STATIC );
+const WindowPosition c_default_window_pos(50, 25, 400, 300);
- GdkScreen* screen = gdk_screen_get_default();
- if ( position.x < 0
- || position.y < 0
- || position.x > gdk_screen_get_width( screen )
- || position.y > gdk_screen_get_height( screen ) ) {
- gtk_window_set_position( window, GTK_WIN_POS_CENTER_ON_PARENT );
- }
- else
- {
- gtk_window_move( window, position.x, position.y );
- }
+void window_get_position(ui::Window window, WindowPosition &position);
- gtk_window_set_default_size( window, position.w, position.h );
-}
+void window_set_position(ui::Window window, const WindowPosition &position);
-inline void WindowPosition_Parse( WindowPosition& position, const char* value ){
- if ( sscanf( value, "%d %d %d %d", &position.x, &position.y, &position.w, &position.h ) != 4 ) {
- position = WindowPosition( c_default_window_pos ); // ensure sane default value for window position
- }
-}
-typedef ReferenceCaller1<WindowPosition, const char*, WindowPosition_Parse> WindowPositionImportStringCaller;
+struct WindowPosition_String {
-inline void WindowPosition_Write( const WindowPosition& position, const StringImportCallback& importCallback ){
- char buffer[64];
- sprintf( buffer, "%d %d %d %d", position.x, position.y, position.w, position.h );
- importCallback( buffer );
-}
-typedef ConstReferenceCaller1<WindowPosition, const StringImportCallback&, WindowPosition_Write> WindowPositionExportStringCaller;
+ static void Export(const WindowPosition &self, const Callback<void(const char *)> &returnz);
+ static void Import(WindowPosition &self, const char *value);
+};
-class WindowPositionTracker
-{
-WindowPosition m_position;
+class WindowPositionTracker {
+ WindowPosition m_position;
-static gboolean configure( GtkWidget* widget, GdkEventConfigure *event, WindowPositionTracker* self ){
- self->m_position = WindowPosition( event->x, event->y, event->width, event->height );
- return FALSE;
-}
+ static gboolean configure(ui::Widget widget, GdkEventConfigure *event, WindowPositionTracker *self);
public:
-WindowPositionTracker()
- : m_position( c_default_window_pos ){
-}
+ WindowPositionTracker()
+ : m_position(c_default_window_pos)
+ {
+ }
-void sync( GtkWindow* window ){
- window_set_position( window, m_position );
-}
+ void sync(ui::Window window);
-void connect( GtkWindow* window ){
- sync( window );
- g_signal_connect( G_OBJECT( window ), "configure_event", G_CALLBACK( configure ), this );
-}
+ void connect(ui::Window window);
-const WindowPosition& getPosition() const {
- return m_position;
-}
+ const WindowPosition &getPosition() const;
//hack
-void setPosition( const WindowPosition& position ){
- m_position = position;
-}
+ void setPosition(const WindowPosition &position);
};
-inline void WindowPositionTracker_importString( WindowPositionTracker& self, const char* value ){
- WindowPosition position;
- WindowPosition_Parse( position, value );
- self.setPosition( position );
-}
-typedef ReferenceCaller1<WindowPositionTracker, const char*, WindowPositionTracker_importString> WindowPositionTrackerImportStringCaller;
-
-inline void WindowPositionTracker_exportString( const WindowPositionTracker& self, const StringImportCallback& importer ){
- WindowPosition_Write( self.getPosition(), importer );
-}
-typedef ConstReferenceCaller1<WindowPositionTracker, const StringImportCallback&, WindowPositionTracker_exportString> WindowPositionTrackerExportStringCaller;
-
+struct WindowPositionTracker_String {
+ static void Export(const WindowPositionTracker &self, const Callback<void(const char *)> &returnz);
+ static void Import(WindowPositionTracker &self, const char *value);
+};
#endif
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
+#include "xorrectangle.h"
- This file is part of GtkRadiant.
+#include <gtk/gtk.h>
- GtkRadiant 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.
+#include "gtkutil/glwidget.h"
+#include "igl.h"
- GtkRadiant 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.
+#include <gtk/gtkglwidget.h>
- You should have received a copy of the GNU General Public License
- along with GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
+//#include "stream/stringstream.h"
-#include "xorrectangle.h"
+bool XORRectangle::initialised() const
+{
+ return !!cr;
+}
+
+void XORRectangle::lazy_init()
+{
+ if (!initialised()) {
+ cr = gdk_cairo_create(gtk_widget_get_window(m_widget));
+ }
+}
+
+void XORRectangle::draw() const
+{
+ const int x = float_to_integer(m_rectangle.x);
+ const int y = float_to_integer(m_rectangle.y);
+ const int w = float_to_integer(m_rectangle.w);
+ const int h = float_to_integer(m_rectangle.h);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(m_widget, &allocation);
+ cairo_rectangle(cr, x, -(h) - (y - allocation.height), w, h);
+ cairo_set_source_rgb(cr, 1, 1, 1);
+ cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE);
+ cairo_stroke(cr);
+}
+
+XORRectangle::XORRectangle(ui::GLArea widget) : m_widget(widget), cr(0)
+{
+}
+
+XORRectangle::~XORRectangle()
+{
+ if (initialised()) {
+ cairo_destroy(cr);
+ }
+}
+
+void XORRectangle::set(rectangle_t rectangle)
+{
+ if (gtk_widget_get_realized(m_widget)) {
+ if( m_rectangle.w != rectangle.w || m_rectangle.h != rectangle.h ){
+ //if( !(m_rectangle.w == 0 && m_rectangle.h == 0 && rectangle.w == 0 && rectangle.h == 0) ){
+ //globalOutputStream() << "m_x" << m_rectangle.x << " m_y" << m_rectangle.y << " m_w" << m_rectangle.w << " m_h" << m_rectangle.h << "\n";
+ //globalOutputStream() << "__x" << rectangle.x << " __y" << rectangle.y << " __w" << rectangle.w << " __h" << rectangle.h << "\n";
+ if ( glwidget_make_current( m_widget ) != FALSE ) {
+ GlobalOpenGL_debugAssertNoErrors();
+
+ gint width, height;
+ gdk_gl_drawable_get_size( gtk_widget_get_gl_drawable( m_widget ), &width, &height );
+
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho( 0, width, 0, height, -100, 100 );
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+ glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
+ glDisable( GL_DEPTH_TEST );
+
+ glDrawBuffer( GL_FRONT );
+
+ glEnable( GL_BLEND );
+ glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
+
+ glLineWidth( 2 );
+ glColor3f( 1, 1, 1 );
+ glDisable( GL_TEXTURE_2D );
+ glBegin( GL_LINE_LOOP );
+ glVertex2f( m_rectangle.x, m_rectangle.y + m_rectangle.h );
+ glVertex2f( m_rectangle.x + m_rectangle.w, m_rectangle.y + m_rectangle.h );
+ glVertex2f( m_rectangle.x + m_rectangle.w, m_rectangle.y );
+ glVertex2f( m_rectangle.x, m_rectangle.y );
+ glEnd();
+
+ glBegin( GL_LINE_LOOP );
+ glVertex2f( rectangle.x, rectangle.y + rectangle.h );
+ glVertex2f( rectangle.x + rectangle.w, rectangle.y + rectangle.h );
+ glVertex2f( rectangle.x + rectangle.w, rectangle.y );
+ glVertex2f( rectangle.x, rectangle.y );
+ glEnd();
+
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ glDrawBuffer( GL_BACK );
+ GlobalOpenGL_debugAssertNoErrors();
+ //glwidget_swap_buffers( m_widget );
+ glwidget_make_current( m_widget );
+ }
+ }
+ m_rectangle = rectangle;
+ }
+}
#if !defined ( INCLUDED_XORRECTANGLE_H )
#define INCLUDED_XORRECTANGLE_H
-#include <gtk/gtkwidget.h>
+#include <cairo.h>
+#include <uilib/uilib.h>
#include "math/vector.h"
-
-#include "gtkutil/glwidget.h"
-#include "igl.h"
-
-#include <gtk/gtkglwidget.h>
-
-//#include "stream/stringstream.h"
-
-
class rectangle_t
{
public:
class XORRectangle
{
+
rectangle_t m_rectangle;
-GtkWidget* m_widget;
+
+ui::GLArea m_widget;
+cairo_t *cr;
+
+bool initialised() const;
+void lazy_init();
+void draw() const;
public:
-XORRectangle( GtkWidget* widget ) : m_widget( widget ){
-}
-~XORRectangle(){
-}
-void set( rectangle_t rectangle ){
- if ( GTK_WIDGET_REALIZED( m_widget ) ) {
- if( m_rectangle.w != rectangle.w || m_rectangle.h != rectangle.h ){
- //if( !(m_rectangle.w == 0 && m_rectangle.h == 0 && rectangle.w == 0 && rectangle.h == 0) ){
- //globalOutputStream() << "m_x" << m_rectangle.x << " m_y" << m_rectangle.y << " m_w" << m_rectangle.w << " m_h" << m_rectangle.h << "\n";
- //globalOutputStream() << "__x" << rectangle.x << " __y" << rectangle.y << " __w" << rectangle.w << " __h" << rectangle.h << "\n";
- if ( glwidget_make_current( m_widget ) != FALSE ) {
- GlobalOpenGL_debugAssertNoErrors();
-
- gint width, height;
- gdk_gl_drawable_get_size( gtk_widget_get_gl_drawable( m_widget ), &width, &height );
-
- glViewport( 0, 0, width, height );
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- glOrtho( 0, width, 0, height, -100, 100 );
-
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
-
- glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
- glDisable( GL_DEPTH_TEST );
-
- glDrawBuffer( GL_FRONT );
-
- glEnable( GL_BLEND );
- glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
-
- glLineWidth( 2 );
- glColor3f( 1, 1, 1 );
- glDisable( GL_TEXTURE_2D );
- glBegin( GL_LINE_LOOP );
- glVertex2f( m_rectangle.x, m_rectangle.y + m_rectangle.h );
- glVertex2f( m_rectangle.x + m_rectangle.w, m_rectangle.y + m_rectangle.h );
- glVertex2f( m_rectangle.x + m_rectangle.w, m_rectangle.y );
- glVertex2f( m_rectangle.x, m_rectangle.y );
- glEnd();
-
- glBegin( GL_LINE_LOOP );
- glVertex2f( rectangle.x, rectangle.y + rectangle.h );
- glVertex2f( rectangle.x + rectangle.w, rectangle.y + rectangle.h );
- glVertex2f( rectangle.x + rectangle.w, rectangle.y );
- glVertex2f( rectangle.x, rectangle.y );
- glEnd();
-
- glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
- glDrawBuffer( GL_BACK );
- GlobalOpenGL_debugAssertNoErrors();
- //glwidget_swap_buffers( m_widget );
- glwidget_make_current( m_widget );
- }
- }
- m_rectangle = rectangle;
- }
-}
+XORRectangle( ui::GLArea widget );
+~XORRectangle();
+void set( rectangle_t rectangle );
};
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "imagelib.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "instancelib.h"
( *i ).second->transformChanged();
}
}
-typedef MemberCaller<InstanceSet, &InstanceSet::transformChanged> TransformChangedCaller;
+typedef MemberCaller<InstanceSet, void(), &InstanceSet::transformChanged> TransformChangedCaller;
void boundsChanged(){
for ( InstanceMap::iterator i = m_instances.begin(); i != m_instances.end(); ++i )
{
( *i ).second->boundsChanged();
}
}
-typedef MemberCaller<InstanceSet, &InstanceSet::boundsChanged> BoundsChangedCaller;
+typedef MemberCaller<InstanceSet, void(), &InstanceSet::boundsChanged> BoundsChangedCaller;
};
template<typename Functor>
}
}
-template<typename Type>
-class InstanceEvaluateTransform
-{
-public:
-inline void operator()( scene::Instance& instance ) const {
- InstanceTypeCast<Type>::cast( instance )->evaluateTransform();
-}
-};
-
template<typename Type>
class InstanceSetEvaluateTransform
{
public:
static void apply( InstanceSet& instances ){
- InstanceSet_forEach( instances, InstanceEvaluateTransform<Type>() );
+ InstanceSet_forEach(instances, [&](scene::Instance &instance) {
+ InstanceTypeCast<Type>::cast(instance)->evaluateTransform();
+ });
}
-typedef ReferenceCaller<InstanceSet, &InstanceSetEvaluateTransform<Type>::apply> Caller;
+typedef ReferenceCaller<InstanceSet, void(), &InstanceSetEvaluateTransform<Type>::apply> Caller;
};
#endif
--- /dev/null
+set(L_NETLIST
+ l_net.c l_net.h
+ )
+if (WIN32)
+ list(APPEND L_NETLIST l_net_wins.c l_net_wins.h)
+else ()
+ list(APPEND L_NETLIST l_net_berkley.c)
+endif ()
+
+add_library(l_net ${L_NETLIST})
+
+if (WIN32)
+ target_link_libraries(l_net PRIVATE ws2_32)
+endif ()
// Notes:
//====================================================================
+#include "globaldefs.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "l_net.h"
#include "l_net_wins.h"
-#define GetMemory malloc
-#define FreeMemory free
-
-#define qtrue 1
-#define qfalse 0
-
-#ifdef _DEBUG
+#if GDEF_DEBUG
void WinPrint( const char *str, ... ){
va_list argptr;
char text[4096];
vsprintf( text, str, argptr );
va_end( argptr );
- printf( text );
+ printf( "%s", text );
}
#else
void WinPrint( const char *str, ... ){
// Changes Globals: -
//===========================================================================
int Net_AddressCompare( address_t *addr1, address_t *addr2 ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
return _stricmp( addr1->ip, addr2->ip );
#else
return strcasecmp( addr1->ip, addr2->ip );
return msg->size - 4;
} //end if
//the message has not been completely read yet
-#ifdef _DEBUG
+#if GDEF_DEBUG
printf( "++timo TODO: debug the Net_Receive on big size messages\n" );
#endif
return 0;
socket_t *Net_AllocSocket( void ){
socket_t *sock;
- sock = (socket_t *) GetMemory( sizeof( socket_t ) );
+ sock = (socket_t *) malloc( sizeof( socket_t ) );
memset( sock, 0, sizeof( socket_t ) );
return sock;
} //end of the function Net_AllocSocket
// Changes Globals: -
//===========================================================================
void Net_FreeSocket( socket_t *sock ){
- FreeMemory( sock );
+ free( sock );
} //end of the function Net_FreeSocket
//===========================================================================
//
extern "C" {
#endif
-#ifndef __BYTEBOOL__
-#define __BYTEBOOL__
-typedef enum { qfalse, qtrue } qboolean;
-typedef unsigned char byte;
-#endif
+#include "bytebool.h"
typedef struct address_s
{
#include <unistd.h>
#include <stdarg.h>
#include <stdio.h>
-#define SOCKET_ERROR -1
-#define INVALID_SOCKET -1
+const int SOCKET_ERROR = -1;
+const int INVALID_SOCKET = -1;
#define WinError WinPrint
-#define qtrue 1
-#define qfalse 0
-
#define ioctlsocket ioctl
#define closesocket close
static char my_tcpip_address[NET_NAMELEN];
-#define DEFAULTnet_hostport 26000
+const int DEFAULTnet_hostport = 26000;
-#define MAXHOSTNAMELEN 256
+const int MAXHOSTNAMELEN = 256;
static int net_acceptsocket = -1; // socket for fielding new connections
static int net_controlsocket;
#define WinError WinPrint
-#define qtrue 1
-#define qfalse 0
-
typedef struct tag_error_struct
{
int errnum;
LPSTR errstr;
} ERROR_STRUCT;
-#define NET_NAMELEN 64
+#define NET_NAMELEN 64
char my_tcpip_address[NET_NAMELEN];
-#define DEFAULTnet_hostport 26000
+const int DEFAULTnet_hostport = 26000;
-#define MAXHOSTNAMELEN 256
+const int MAXHOSTNAMELEN = 256;
static int net_acceptsocket = -1; // socket for fielding new connections
static int net_controlsocket;
// Notes:
//===========================================================================
+#include "bytebool.h"
+
int WINS_Init( void );
void WINS_Shutdown( void );
char *WINS_MyAddress( void );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "maplib.h"
std::size_t m_saved;
typedef void ( UndoFileChangeTracker::*Pending )();
Pending m_pending;
-Callback m_changed;
+Callback<void()> m_changed;
public:
UndoFileChangeTracker() : m_size( 0 ), m_saved( MAPFILE_MAX_CHANGES ), m_pending( 0 ){
return m_saved == m_size;
}
-void setChangedCallback( const Callback& changed ){
+void setChangedCallback( const Callback<void()>& changed ){
m_changed = changed;
m_changed();
}
--- /dev/null
+add_library(math
+ _.cpp
+ aabb.h
+ curve.h
+ frustum.h
+ line.h
+ matrix.h
+ pi.h
+ plane.h
+ quaternion.h
+ vector.h
+ )
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "aabb.h"
}
}
-class AABBExtendByPoint
-{
-AABB& m_aabb;
-public:
-AABBExtendByPoint( AABB& aabb ) : m_aabb( aabb ){
-}
-void operator()( const Vector3& point ) const {
- aabb_extend_by_point_safe( m_aabb, point );
-}
-};
-
inline void aabb_extend_by_aabb( AABB& aabb, const AABB& other ){
AABBExtend< IntegralConstant<0> >::apply( aabb, other );
AABBExtend< IntegralConstant<1> >::apply( aabb, other );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "curve.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "frustum.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "line.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "matrix.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "pi.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "plane.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "quaternion.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "vector.h"
/// \brief Vector data types and related operations.
#include "generic/vector.h"
+#include "globaldefs.h"
-#if defined ( _MSC_VER )
+#if GDEF_COMPILER_MSVC
inline int lrint( double flt ){
int i;
return static_cast<__int64>( f + 0.5 );
}
-#elif defined( __FreeBSD__ )
+#elif GDEF_OS_BSD
inline long lrint( double f ){
return static_cast<long>( f + 0.5 );
return static_cast<long long>( f + 0.5 );
}
-#elif defined( __GNUC__ )
+#elif GDEF_COMPILER_GNU
// lrint is part of ISO C99
#define _ISOC9X_SOURCE 1
--- /dev/null
+add_library(mathlib
+ bbox.c
+ line.c
+ m4x4.c
+ mathlib.c ../mathlib.h
+ ray.c
+ )
from "Graphics Gems", Academic Press, 1990
*/
-#define NUMDIM 3
-#define RIGHT 0
-#define LEFT 1
-#define MIDDLE 2
+const int NUMDIM = 3;
+const int RIGHT = 0;
+const int LEFT = 1;
+const int MIDDLE = 2;
int aabb_intersect_ray( const aabb_t *aabb, const ray_t *ray, vec3_t intersection ){
int inside = 1;
}
#endif
-#define N 3
-
int matrix_solve_ge( vec_t* matrix, vec_t* aug, vec3_t x ){
+ const int N = 3;
int indx[N];
int c,r;
int i;
}
// NOTE: added these from Ritual's Q3Radiant
-#define INVALID_BOUNDS 99999
+const int INVALID_BOUNDS = 99999;
void ClearBounds( vec3_t mins, vec3_t maxs ){
mins[0] = mins[1] = mins[2] = +INVALID_BOUNDS;
maxs[0] = maxs[1] = maxs[2] = -INVALID_BOUNDS;
// Tomas Moller and Ben Trumbore. Fast, minimum storage ray-triangle intersection. Journal of graphics tools, 2(1):21-28, 1997
-#define EPSILON 0.000001
+const double EPSILON = 0.000001;
vec_t ray_intersect_triangle( const ray_t *ray, qboolean bCullBack, const vec3_t vert0, const vec3_t vert1, const vec3_t vert2 ){
float edge1[3], edge2[3], tvec[3], pvec[3], qvec[3];
*/
#ifndef md5_INCLUDED
-# define md5_INCLUDED
+#define md5_INCLUDED
/*
* This package supports both compile-time and run-time determination of CPU
*/
#include "md5lib.h" /* ydnar */
+#include "globaldefs.h"
#include <string.h>
-/* ydnar: gtkradiant endian picking */
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
#define ARCH_IS_BIG_ENDIAN 1
#else
#define ARCH_IS_BIG_ENDIAN 0
/* ydnar: end */
#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
-#ifdef ARCH_IS_BIG_ENDIAN
-# define BYTE_ORDER ( ARCH_IS_BIG_ENDIAN ? 1 : -1 )
-#else
-# define BYTE_ORDER 0
-#endif
+#define BYTE_ORDER ( ARCH_IS_BIG_ENDIAN ? 1 : -1 )
#define T_MASK ( ( md5_word_t ) ~0 )
#define T1 /* 0xd76aa478 */ ( T_MASK ^ 0x28955b87 )
const md5_byte_t *xp = data;
int i;
-# if BYTE_ORDER == 0
+#if BYTE_ORDER == 0
X = xbuf; /* (dynamic only) */
-# else
-# define xbuf X /* (static only) */
-# endif
+#else
+#define xbuf X /* (static only) */
+#endif
for ( i = 0; i < 16; ++i, xp += 4 )
xbuf[i] = xp[0] + ( xp[1] << 8 ) + ( xp[2] << 16 ) + ( xp[3] << 24 );
}
--- /dev/null
+add_library(memory
+ allocator.cpp allocator.h
+ )
typedef NamedAllocator<Other> other;
};
-explicit NamedAllocator( const char* name ) : m_name( name ){
+explicit NamedAllocator( const char* name ) : DefaultAllocator<Type>(), m_name( name ){
}
-NamedAllocator( const NamedAllocator<Type>& other ) : m_name( other.m_name ){
+NamedAllocator( const NamedAllocator<Type>& other ) : DefaultAllocator<Type>(), m_name( other.m_name ){
}
-template<typename Other> NamedAllocator( const NamedAllocator<Other>& other ) : m_name( other.m_name ){
+template<typename Other> NamedAllocator( const NamedAllocator<Other>& other ) : DefaultAllocator<Type>(), m_name( other.m_name ){
}
~NamedAllocator(){
}
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "moduleobservers.h"
--- /dev/null
+add_library(modulesystem
+ moduleregistry.h
+ modulesmap.h
+ singletonmodule.cpp singletonmodule.h
+ )
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "moduleregistry.h"
class ModuleRegisterable
{
public:
-virtual void selfRegister() = 0;
+ virtual void selfRegister() = 0;
};
class ModuleRegistryList
{
-typedef std::list<ModuleRegisterable*> RegisterableModules;
-RegisterableModules m_modules;
+ typedef std::list<ModuleRegisterable*> RegisterableModules;
+ RegisterableModules m_modules;
public:
-void addModule( ModuleRegisterable& module ){
- m_modules.push_back( &module );
-}
-void registerModules() const {
- for ( RegisterableModules::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i )
- {
- ( *i )->selfRegister();
+ void addModule( ModuleRegisterable& module ){
+ m_modules.push_back( &module );
+ }
+ void registerModules() const {
+ for ( RegisterableModules::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i )
+ {
+ ( *i )->selfRegister();
+ }
}
-}
};
typedef SmartStatic<ModuleRegistryList> StaticModuleRegistryList;
class StaticRegisterModule : public StaticModuleRegistryList
{
public:
-StaticRegisterModule( ModuleRegisterable& module ){
- StaticModuleRegistryList::instance().addModule( module );
-}
+ StaticRegisterModule( ModuleRegisterable& module ){
+ StaticModuleRegistryList::instance().addModule( module );
+ }
};
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "modulesmap.h"
ModulesMap<Type> m_modules;
public:
ModulesRef( const char* names ){
+ std::string type_name { typename Type::Name() };
if ( !globalModuleServer().getError() ) {
if ( string_equal( names, "*" ) ) {
InsertModules<Type> visitor( m_modules );
}
Module* module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
if ( module == 0 ) {
- globalModuleServer().setError( true );
- globalErrorStream() << "ModulesRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
+ // do not fail on missing image or model plugin, they can be optional
+ if ( type_name.compare("image") == 0 || type_name.compare("model") == 0 ) {
+ globalOutputStream() << "ModulesRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
+ }
+ else {
+ globalModuleServer().setError( true );
+ globalErrorStream() << "ModulesRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
+ }
break;
}
else
void selfRegister(){
globalModuleServer().registerModule( typename Type::Name(), typename Type::Version(), APIConstructor::getName(), *this );
-}
+ }
Dependencies& getDependencies(){
return *m_dependencies;
--- /dev/null
+add_library(os
+ _.cpp
+ dir.h
+ file.h
+ path.h
+ )
+
+find_package(GLIB REQUIRED)
+target_include_directories(os PRIVATE ${GLIB_INCLUDE_DIRS})
+target_link_libraries(os PRIVATE ${GLIB_LIBRARIES})
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "dir.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "file.h"
#if !defined( INCLUDED_OS_FILE_H )
#define INCLUDED_OS_FILE_H
+#include "globaldefs.h"
+
/// \file
/// \brief OS file-system querying and manipulation.
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
#define S_ISDIR( mode ) ( mode & _S_IFDIR )
#include <io.h> // _access()
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "path.h"
#if !defined ( INCLUDED_OS_PATH_H )
#define INCLUDED_OS_PATH_H
+#include "globaldefs.h"
+
/// \file
/// \brief OS file-system path comparison, decomposition and manipulation.
///
#include "string/string.h"
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
#define OS_CASE_INSENSITIVE
#endif
/// \brief Returns true if \p path is a fully qualified file-system path.
/// O(1)
inline bool path_is_absolute( const char* path ){
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
return path[0] == '/'
|| ( path[0] != '\0' && path[1] == ':' ); // local drive
-#elif defined( POSIX )
+#elif GDEF_OS_POSIX
return path[0] == '/';
#endif
}
--- /dev/null
+add_library(picomodel
+ lwo/clip.c
+ lwo/envelope.c
+ lwo/list.c
+ lwo/lwio.c
+ lwo/lwo2.c lwo/lwo2.h
+ lwo/lwob.c
+ lwo/pntspols.c
+ lwo/surface.c
+ lwo/vecmath.c
+ lwo/vmap.c
+
+ picointernal.c picointernal.h
+ picomodel.c ../picomodel.h
+ picomodules.c
+ pm_3ds.c
+ pm_ase.c
+ pm_fm.c pm_fm.h
+ pm_lwo.c
+ pm_md2.c
+ pm_md3.c
+ pm_mdc.c
+ pm_ms3d.c
+ pm_obj.c
+ pm_terrain.c
+ )
void lwFreeClip( lwClip *clip ){
if ( clip ) {
- lwListFree( clip->ifilter, (void *) lwFreePlugin );
- lwListFree( clip->pfilter, (void *) lwFreePlugin );
+ lwListFree(clip->ifilter, (void (*)(void *)) lwFreePlugin);
+ lwListFree(clip->pfilter, (void (*)(void *)) lwFreePlugin);
switch ( clip->type ) {
case ID_STIL:
_pico_free( env->name );
}
lwListFree( env->key, _pico_free );
- lwListFree( env->cfilter, (void *) lwFreePlugin );
+ lwListFree(env->cfilter, (void (*)(void *)) lwFreePlugin);
_pico_free( env );
}
}
}
key->time = getF4( fp );
key->value = getF4( fp );
- lwListInsert( (void **) &env->key, key, (void *) compare_keys );
+ lwListInsert((void **) &env->key, key, (int (*)(void *, void *)) compare_keys);
env->nkeys++;
break;
#include "../picointernal.h"
#include "lwo2.h"
+#include <limits.h>
+#include "globaldefs.h"
/*
read requests until flen is reset.
====================================================================== */
-#define INT_MIN ( -2147483647 - 1 ) /* minimum (signed) int value */
-#define FLEN_ERROR INT_MIN
+const int FLEN_ERROR = INT_MIN;
static int flen;
int get_flen( void ) { return flen; }
-#ifndef __BIG_ENDIAN__
+#if !GDEF_ARCH_ENDIAN_BIG
/*
=====================================================================
revbytes()
#include "../picointernal.h"
#include "lwo2.h"
+#include "globaldefs.h"
/* disable warnings */
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning( disable:4018 ) /* signed/unsigned mismatch */
#endif
}
lwFreePoints( &layer->point );
lwFreePolygons( &layer->polygon );
- lwListFree( layer->vmap, (void *) lwFreeVMap );
+ lwListFree(layer->vmap, (void (*)(void *)) lwFreeVMap);
_pico_free( layer );
}
}
void lwFreeObject( lwObject *object ){
if ( object ) {
- lwListFree( object->layer, (void *) lwFreeLayer );
- lwListFree( object->env, (void *) lwFreeEnvelope );
- lwListFree( object->clip, (void *) lwFreeClip );
- lwListFree( object->surf, (void *) lwFreeSurface );
+ lwListFree(object->layer, (void (*)(void *)) lwFreeLayer);
+ lwListFree(object->env, (void (*)(void *)) lwFreeEnvelope);
+ lwListFree(object->clip, (void (*)(void *)) lwFreeClip);
+ lwListFree(object->surf, (void (*)(void *)) lwFreeSurface);
lwFreeTags( &object->taglist );
_pico_free( object );
}
#ifndef LWO2_H
#define LWO2_H
+#include "globaldefs.h"
+
/* chunk and subchunk IDs */
#define LWID_( a,b,c,d ) ( ( ( a ) << 24 ) | ( ( b ) << 16 ) | ( ( c ) << 8 ) | ( d ) )
float sgetF4( unsigned char **bp );
char *sgetS0( unsigned char **bp );
-#ifndef __BIG_ENDIAN__
+#if !GDEF_ARCH_ENDIAN_BIG
void revbytes( void *bp, int elsize, int elcount );
#else
#define revbytes( b, s, c )
#include "../picointernal.h"
#include "lwo2.h"
+#include "globaldefs.h"
/* disable warnings */
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning( disable:4018 ) /* signed/unsigned mismatch */
#endif
clip->saturation.val = 1.0f;
clip->gamma.val = 1.0f;
- if ( ( p = strstr( s, "(sequence)" ) ) ) {
+ if ( ( p = strstr( s, "(sequence)" ) ) != NULL ) {
p[ -1 ] = 0;
clip->type = ID_ISEQ;
clip->source.seq.prefix = s;
break;
case ID_TFLG:
- if ( !tex ) {
+ if( tex == NULL ) {
goto Fail;
}
+
flags = getU2( fp );
i = -1;
+
+ //only one of the three axis bits should be set
if ( flags & 1 ) {
i = 0;
}
_pico_free( surf->srcname );
}
- lwListFree( surf->shader, (void *) lwFreePlugin );
-
- lwListFree( surf->color.tex, (void *) lwFreeTexture );
- lwListFree( surf->luminosity.tex, (void *) lwFreeTexture );
- lwListFree( surf->diffuse.tex, (void *) lwFreeTexture );
- lwListFree( surf->specularity.tex, (void *) lwFreeTexture );
- lwListFree( surf->glossiness.tex, (void *) lwFreeTexture );
- lwListFree( surf->reflection.val.tex, (void *) lwFreeTexture );
- lwListFree( surf->transparency.val.tex, (void *) lwFreeTexture );
- lwListFree( surf->eta.tex, (void *) lwFreeTexture );
- lwListFree( surf->translucency.tex, (void *) lwFreeTexture );
- lwListFree( surf->bump.tex, (void *) lwFreeTexture );
+ lwListFree(surf->shader, (void (*)(void *)) lwFreePlugin);
+
+ void (*freeTexture)(void *) = (void (*)(void *)) lwFreeTexture;
+ lwListFree(surf->color.tex, freeTexture);
+ lwListFree(surf->luminosity.tex, freeTexture);
+ lwListFree(surf->diffuse.tex, freeTexture);
+ lwListFree(surf->specularity.tex, freeTexture);
+ lwListFree(surf->glossiness.tex, freeTexture);
+ lwListFree(surf->reflection.val.tex, freeTexture);
+ lwListFree(surf->transparency.val.tex, freeTexture);
+ lwListFree(surf->eta.tex, freeTexture);
+ lwListFree(surf->translucency.tex, freeTexture);
+ lwListFree(surf->bump.tex, freeTexture);
_pico_free( surf );
}
default: return 0;
}
- lwListInsert( (void **) list, tex, ( void *) compare_textures );
+ lwListInsert((void **) list, tex, (int (*)(void *, void *)) compare_textures);
return 1;
}
if ( !shdr ) {
goto Fail;
}
- lwListInsert( (void **) &surf->shader, shdr, (void *) compare_shaders );
+ lwListInsert((void **) &surf->shader, shdr, (int (*)(void *, void *)) compare_shaders);
++surf->nshaders;
set_flen( 4 + get_flen() );
break;
----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define PICOINTERNAL_C
-
-
-
/* todo:
* - fix p->curLine for parser routines. increased twice
*/
/* dependencies */
#include <string.h>
#include "picointernal.h"
+#include "globaldefs.h"
dest[ 3 ] = src[ 3 ];
}
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
int _pico_big_long( int src ) { return src; }
short _pico_big_short( short src ) { return src; }
}
/* setup */
p->buffer = (const char *) buffer;
- p->cursor = (const char *) buffer;
+ p->cursor = p->buffer;
p->bufSize = bufSize;
p->max = p->buffer + bufSize;
p->curLine = 1; /* sea: new */
#ifndef PICOINTERNAL_H
#define PICOINTERNAL_H
+#include "globaldefs.h"
+
#ifdef __cplusplus
extern "C"
{
/* os dependent replacements */
-#if WIN32 || _WIN32
+#if GDEF_OS_WINDOWS
#define _pico_stricmp stricmp
#define _pico_strnicmp strnicmp
#else
/* types */
typedef struct picoParser_s
{
- const char *buffer;
+ const char *buffer;
int bufSize;
- char *token;
+ char *token;
int tokenSize;
int tokenMax;
- const char *cursor;
- const char *max;
+ const char *cursor;
+ const char *max;
int curLine;
}
picoParser_t;
typedef struct picoMemStream_s
{
- const picoByte_t *buffer;
+ const picoByte_t *buffer;
int bufSize;
- const picoByte_t *curPos;
+ const picoByte_t *curPos;
int flag;
}
picoMemStream_t;
----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define PICOMODEL_C
-
-
-
/* dependencies */
#include "picointernal.h"
/* hashtable code for faster vertex lookups */
//#define HASHTABLE_SIZE 32768 // 2048 /* power of 2, use & */
-#define HASHTABLE_SIZE 7919 // 32749 // 2039 /* prime, use % */
+const int HASHTABLE_SIZE = 7919; // 32749 // 2039 /* prime, use % */
int PicoGetHashTableSize( void ){
return HASHTABLE_SIZE;
----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define PICOMODULES_C
-
-
-
/* dependencies */
#include "picointernal.h"
----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define PM_3DS_C
-
/* dependencies */
#include "picointernal.h"
{ CHUNK_OBJECT_UV, "CHUNK_OBJECT_UV" },
{ 0, NULL }
};
-static char *DebugGetChunkName( int id ){
+static char *DebugGetChunkName( int id ) {
int i,max; /* imax? ;) */
max = sizeof( debugChunkNames ) / sizeof( debugChunkNames[0] );
/* read in surface name */
if ( !GetASCIIZ( pers,surfaceName,sizeof( surfaceName ) ) ) {
return 0; /* this is bad */
-
}
//PicoGetSurfaceName
/* ignore NULL name surfaces */
----------------------------------------------------------------------------- */
-
-/* marker */
-#define PM_ASE_C
-
/* uncomment when debugging this module */
//#define DEBUG_PM_ASE
//#define DEBUG_PM_ASE_EX
Nurail: Used pm_md3.c (Randy Reddig) as a template.
*/
-/* marker */
-#define PM_FM_C
-
/* dependencies */
#include "pm_fm.h"
----------------------------------------------------------------------------- */
-/* marker */
-#define PM_LWO_C
-
/* dependencies */
#include "picointernal.h"
#include "lwo/lwo2.h"
Nurail: Used pm_md3.c (Randy Reddig) as a template.
*/
-
-/* marker */
-#define PM_MD2_C
-
/* dependencies */
#include "picointernal.h"
-
+#include "bytebool.h"
/* md2 model format */
-#define MD2_MAGIC "IDP2"
-#define MD2_VERSION 8
-
-#define MD2_NUMVERTEXNORMALS 162
-#define MD2_MAX_SKINNAME 64
-#define MD2_MAX_TRIANGLES 4096
-#define MD2_MAX_VERTS 2048
-#define MD2_MAX_FRAMES 512
-#define MD2_MAX_MD2SKINS 32
-#define MD2_MAX_SKINNAME 64
-
-#ifndef byte
- #define byte unsigned char
-#endif
+const char *MD2_MAGIC = "IDP2";
+const int MD2_VERSION = 8;
+
+#define MD2_NUMVERTEXNORMALS 162
+
+const int MD2_MAX_TRIANGLES = 4096;
+const int MD2_MAX_VERTS = 2048;
+const int MD2_MAX_FRAMES = 512;
+const int MD2_MAX_MD2SKINS = 32;
+const int MD2_MAX_SKINNAME = 64;
typedef struct index_LUT_s
{
----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define PM_MD3_C
-
-
-
/* dependencies */
#include "picointernal.h"
/* md3 model format */
-#define MD3_MAGIC "IDP3"
-#define MD3_VERSION 15
+const char *MD3_MAGIC = "IDP3";
+const int MD3_VERSION = 15;
/* md3 vertex scale */
-#define MD3_SCALE ( 1.0f / 64.0f )
+const float MD3_SCALE = ( 1.0f / 64.0f );
/* md3 model frame information */
typedef struct md3Frame_s
----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define PM_MDC_C
-
-
-
/* dependencies */
#include "picointernal.h"
/* mdc model format */
-#define MDC_MAGIC "IDPC"
-#define MDC_VERSION 2
+const char *MDC_MAGIC = "IDPC";
+const int MDC_VERSION = 2;
/* mdc vertex scale */
-#define MDC_SCALE ( 1.0f / 64.0f )
-#define MDC_MAX_OFS 127.0f
-#define MDC_DIST_SCALE 0.05f
+const float MDC_SCALE = ( 1.0f / 64.0f );
+const float MDC_MAX_OFS = 127.0f;
+const float MDC_DIST_SCALE = 0.05f;
/* mdc decoding normal table */
double mdcNormals[ 256 ][ 3 ] =
----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define PM_MS3D_C
-
/* dependencies */
#include "picointernal.h"
+#include "globaldefs.h"
/* disable warnings */
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning( disable:4100 ) /* unref param */
#endif
static picoColor_t white = { 255,255,255,255 };
/* ms3d limits */
-#define MS3D_MAX_VERTS 8192
-#define MS3D_MAX_TRIS 16384
-#define MS3D_MAX_GROUPS 128
-#define MS3D_MAX_MATERIALS 128
-#define MS3D_MAX_JOINTS 128
-#define MS3D_MAX_KEYFRAMES 216
+const int MS3D_MAX_VERTS = 8192;
+const int MS3D_MAX_TRIS = 16384;
+const int MS3D_MAX_GROUPS = 128;
+const int MS3D_MAX_MATERIALS = 128;
+const int MS3D_MAX_JOINTS = 128;
+const int MS3D_MAX_KEYFRAMES = 216;
/* ms3d flags */
-#define MS3D_SELECTED 1
-#define MS3D_HIDDEN 2
-#define MS3D_SELECTED2 4
-#define MS3D_DIRTY 8
+const int MS3D_SELECTED = 1;
+const int MS3D_HIDDEN = 2;
+const int MS3D_SELECTED2 = 4;
+const int MS3D_DIRTY = 8;
/* this freaky loader needs byte alignment */
#pragma pack(push, 1)
----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define PM_OBJ_C
-
/* dependencies */
#include "picointernal.h"
+#include "globaldefs.h"
/* disable warnings */
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning( disable:4100 ) /* unref param */
#endif
* allocates - and reallocates as soon as required -
* my vertex data array in even steps.
*/
-#define SIZE_OBJ_STEP 4096
+const int SIZE_OBJ_STEP = 4096;
static TObjVertexData *SizeObjVertexData(
TObjVertexData *vertexData, int reqEntries,
/* 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 */
newSurface = PicoNewSurface( model ); \
if ( newSurface == NULL ) { \
_obj_error_return( "Error allocating surface" ); } \
- /* reset face index for surface */ \
+ /* reset face index and vertex index for surface */ \
curFace = 0; \
+ curVertex = 0; \
/* if we can, assign the previous shader to this surface */ \
if ( curSurface ) { \
PicoSetSurfaceShader( newSurface, curSurface->shader ); } \
/* helper */
#define _obj_error_return( m ) \
{ \
- _pico_printf( PICO_ERROR,"%s in OBJ, line %d.",m,p->curLine ); \
+ _pico_printf( PICO_ERROR, "%s in OBJ %s, line %d.", m, model->fileName, p->curLine ); \
_pico_free_parser( p ); \
FreeObjVertexData( vertexData ); \
PicoFreeModel( model ); \
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 );
----------------------------------------------------------------------------- */
-
-
-/* marker */
-#define PM_TERRAIN_C
-
-
-
/* dependencies */
#include "picointernal.h"
fixme: replace/clean this function
*/
-void _terrain_load_tga_buffer( unsigned char *buffer, unsigned char **pic, int *width, int *height ){
+void _terrain_load_tga_buffer( unsigned char *buffer, unsigned char **pic, int *width, int *height ) {
int row, column;
int columns, rows, numPixels;
unsigned char *pixbuf;
validates a picoterrain file
*/
-static int _terrain_canload( PM_PARAMS_CANLOAD ){
+static int _terrain_canload( PM_PARAMS_CANLOAD ) {
picoParser_t *p;
loads a picoterrain file
*/
-static picoModel_t *_terrain_load( PM_PARAMS_LOAD ){
+static picoModel_t *_terrain_load( PM_PARAMS_LOAD ) {
int i, j, v, pw[ 5 ], r;
picoParser_t *p;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "pivot.h"
--- /dev/null
+add_library(profile
+ file.cpp file.h
+ profile.cpp profile.h
+ )
lNewPos = m_nFileSize + lOff;
}
else{
- return ( position_type ) - 1;
+ return -1;
}
m_nPosition = lNewPos;
fclose( f );
}
- return true;
+ return ret;
}
int profile_load_int( const char *filename, const char *section, const char *key, int default_value ){
--- /dev/null
+#ifndef INCLUDED_IMPORTEXPORT_H
+#define INCLUDED_IMPORTEXPORT_H
+
+#include "generic/callback.h"
+#include "string/string.h"
+
+template<class T>
+struct Property {
+ // todo: just return T, don't use continuation passing style
+ Callback<void(const Callback<void(T)> &returnz)> get;
+ Callback<void(T value)> set;
+};
+
+// implementation
+
+template<class Self, class T = Self>
+struct PropertyImpl {
+ static void Export(const Self &self, const Callback<void(T)> &returnz) {
+ returnz(self);
+ }
+
+ static void Import(Self &self, T value) {
+ self = value;
+ }
+};
+
+namespace detail {
+
+ template<class I>
+ using propertyimpl_self = typename std::remove_reference<get_argument<decltype(&I::Import), 0>>::type;
+
+ template<class I>
+ using propertyimpl_other = get_argument<decltype(&I::Import), 1>;
+
+ template<class I>
+ using propertyimpl_other_free = get_argument<decltype(&I::Import), 0>;
+
+}
+
+// adaptor
+
+template<
+ class Self,
+ class T = Self,
+ class I = PropertyImpl<Self, T>
+>
+struct PropertyAdaptor {
+ using Type = Self;
+ using Other = T;
+
+ using Get = ConstReferenceCaller<Self, void(const Callback<void(T)> &), I::Export>;
+ using Set = ReferenceCaller<Self, void(T), I::Import>;
+};
+
+template<
+ class T,
+ class I
+>
+struct PropertyAdaptorFree {
+ using Other = T;
+
+ using Get = FreeCaller<void(const Callback<void(T)> &), I::Export>;
+ using Set = FreeCaller<void(T), I::Import>;
+};
+
+// explicit full
+
+template<class A>
+Property<typename A::Other> make_property(typename A::Type &self) {
+ return {typename A::Get(self), typename A::Set(self)};
+}
+
+template<class A>
+Property<typename A::Other> make_property() {
+ return {typename A::Get(), typename A::Set()};
+}
+
+// explicit impl
+
+template<class I, class Self = detail::propertyimpl_self<I>, class T = detail::propertyimpl_other<I>>
+using property_impl = PropertyAdaptor<Self, T, I>;
+
+template<class I, class Self, class T = detail::propertyimpl_other<I>>
+Property<T> make_property(Self &self) {
+ return make_property<property_impl<I>>(self);
+}
+
+template<class I, class T = detail::propertyimpl_other_free<I>>
+using property_impl_free = PropertyAdaptorFree<T, I>;
+
+template<class I, class T = detail::propertyimpl_other_free<I>>
+Property<T> make_property() {
+ return make_property<property_impl_free<I>>();
+}
+
+// implicit
+
+template<class Self, class T = Self>
+Property<T> make_property(Self &self) {
+ return make_property<PropertyAdaptor<Self, T>>(self);
+}
+
+// chain
+
+template<class I_Outer, class I_Inner>
+Property<detail::propertyimpl_other<I_Outer>> make_property_chain(detail::propertyimpl_self<I_Inner> &it) {
+ using DST = detail::propertyimpl_other<I_Outer>;
+ using SRC = detail::propertyimpl_self<I_Outer>;
+ using X = detail::propertyimpl_self<I_Inner>;
+
+ using A = property_impl<I_Inner>;
+ struct I {
+ static void ExportThunk(const Callback<void(DST)> &self, SRC value) {
+ PropertyImpl<SRC, DST>::Export(value, self);
+ }
+
+ static void Export(const X &self, const Callback<void(DST)> &returnz) {
+ A::Get::thunk_(self, ConstReferenceCaller<Callback<void(DST)>, void(SRC), ExportThunk>(returnz));
+ }
+
+ static void Import(X &self, DST value) {
+ SRC out;
+ PropertyImpl<SRC, DST>::Import(out, value);
+ A::Set::thunk_(self, out);
+ }
+ };
+ return make_property<PropertyAdaptor<X, DST, I>>(it);
+}
+
+template<class I_Outer, class I_Inner>
+Property<detail::propertyimpl_other<I_Outer>> make_property_chain() {
+ using DST = detail::propertyimpl_other<I_Outer>;
+ using SRC = detail::propertyimpl_self<I_Outer>;
+
+ using A = property_impl_free<I_Inner>;
+ struct I {
+ static void ExportThunk(const Callback<void(DST)> &self, SRC value) {
+ PropertyImpl<SRC, DST>::Export(value, self);
+ }
+
+ static void Export(const Callback<void(DST)> &returnz) {
+ A::Get::thunk_(nullptr, ConstReferenceCaller<Callback<void(DST)>, void(SRC), ExportThunk>(returnz));
+ }
+
+ static void Import(DST value) {
+ SRC out;
+ PropertyImpl<SRC, DST>::Import(out, value);
+ A::Set::thunk_(nullptr, out);
+ }
+ };
+ return make_property<PropertyAdaptorFree<DST, I>>();
+}
+
+// specializations
+
+template<>
+struct PropertyImpl<CopiedString, const char *> {
+ static void Export(const CopiedString &self, const Callback<void(const char *)> &returnz) {
+ returnz(self.c_str());
+ }
+
+ static void Import(CopiedString &self, const char *value) {
+ self = value;
+ }
+};
+
+#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "render.h"
RenderIndex m_prev1;
RenderIndex m_prev2;
-const RenderIndex find_or_insert( const Vertex& vertex ){
+RenderIndex find_or_insert( const Vertex& vertex ){
RenderIndex index = 0;
while ( 1 )
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "scenelib.h"
#if !defined ( INCLUDED_SCENELIB_H )
#define INCLUDED_SCENELIB_H
+#include "globaldefs.h"
#include "iscenegraph.h"
#include "iselection.h"
void initialise(){
m_typeId = GlobalSceneGraph().getNodeTypeId( Name() );
}
-typedef MemberCaller<NodeType<Type>, &NodeType<Type>::initialise> InitialiseCaller;
+typedef MemberCaller<NodeType<Type>, void(), &NodeType<Type>::initialise> InitialiseCaller;
TypeId getTypeId(){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( m_typeId != NODETYPEID_NONE, "node-type " << makeQuoted( Name() ) << " used before being initialised" );
#endif
return m_typeId;
void initialise(){
m_typeId = GlobalSceneGraph().getInstanceTypeId( Name() );
}
-typedef MemberCaller<InstanceType<Type>, &InstanceType<Type>::initialise> InitialiseCaller;
+typedef MemberCaller<InstanceType<Type>, void(), &InstanceType<Type>::initialise> InitialiseCaller;
TypeId getTypeId(){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
ASSERT_MESSAGE( m_typeId != INSTANCETYPEID_NONE, "instance-type " << makeQuoted( Name() ) << " used before being initialised" );
#endif
return m_typeId;
mutable bool m_childSelectedChanged;
mutable bool m_parentSelected;
mutable bool m_parentSelectedChanged;
-Callback m_childSelectedChangedCallback;
-Callback m_transformChangedCallback;
+Callback<void()> m_childSelectedChangedCallback;
+Callback<void()> m_transformChangedCallback;
void evaluateTransform() const {
GlobalSceneGraph().traverse_subgraph( TransformChangedWalker(), m_path );
boundsChanged();
}
-void setTransformChangedCallback( const Callback& callback ){
+void setTransformChangedCallback( const Callback<void()>& callback ){
m_transformChangedCallback = callback;
}
return m_childSelected;
}
-void setChildSelectedChangedCallback( const Callback& callback ){
+void setChildSelectedChangedCallback( const Callback<void()>& callback ){
m_childSelectedChangedCallback = callback;
}
void selectedChanged(){
class SimpleCounter : public Counter
{
-Callback m_countChanged;
+Callback<void()> m_countChanged;
std::size_t m_count;
public:
-void setCountChangedCallback( const Callback& countChanged ){
+void setCountChangedCallback( const Callback<void()>& countChanged ){
m_countChanged = countChanged;
}
void increment(){
--- /dev/null
+add_library(script
+ _.cpp
+ scripttokeniser.h
+ scripttokenwriter.h
+ )
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "scripttokeniser.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "scripttokenwriter.h"
{
public:
SimpleTokenWriter( TextOutputStream& ostream )
- : m_ostream( ostream ), m_separator( '\n' ){
+ // HACK: \0 separator is used to tell we are at beginning of file
+ : m_ostream( ostream ), m_separator( '\0' ){
}
~SimpleTokenWriter(){
writeSeparator();
private:
void writeSeparator(){
- m_ostream << m_separator;
+ // HACK: do not write separator at beginning of file
+ if (m_separator != '\0') {
+ m_ostream << m_separator;
+ }
m_separator = ' ';
}
TextOutputStream& m_ostream;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "selectionlib.h"
Instance::selectedChanged();
}
-typedef MemberCaller1<SelectableInstance, const Selectable&, &SelectableInstance::selectedChanged> SelectedChangedCaller;
+typedef MemberCaller<SelectableInstance, void(const Selectable&), &SelectableInstance::selectedChanged> SelectedChangedCaller;
};
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "shaderlib.h"
#if !defined ( INCLUDED_SHADERLIB_H )
#define INCLUDED_SHADERLIB_H
+#include "defaults.h"
#include "string/string.h"
#include "character.h"
#include "ishaders.h"
}
inline const char* texdef_name_default(){
- return GlobalTexturePrefix_get();
+ const char* notex = DEFAULT_NOTEX_NAME;
+ return notex;
}
-
#endif
--- /dev/null
+add_library(signal
+ isignal.h
+ signal.cpp signal.h
+ signalfwd.h
+ )
+++ /dev/null
-
-#include "isignal.h"
const SignalHandlerResult SIGNAL_CONTINUE_EMISSION = SignalHandlerResult( false );
const SignalHandlerResult SIGNAL_STOP_EMISSION = SignalHandlerResult( true );
-template<typename Caller>
-class SignalHandlerCaller1
-{
+template<class Caller, class F>
+class SignalHandlerCallerN;
+
+template<class Caller, class R, class... Ts>
+class SignalHandlerCallerN<Caller, R(Ts...)> {
public:
-typedef typename Caller::first_argument_type first_argument_type;
-typedef SignalHandlerResult result_type;
-static result_type call( first_argument_type a1 ){
- Caller::call( a1 );
- return SIGNAL_CONTINUE_EMISSION;
-}
+ using func = SignalHandlerResult(Ts...);
+
+ static SignalHandlerResult call(Ts... args) {
+ Caller::call(args...);
+ return SIGNAL_CONTINUE_EMISSION;
+ }
};
+template<class Caller>
+using SignalHandlerCaller = SignalHandlerCallerN<Caller, get_func<Caller>>;
+
+template<class Caller>
+using SignalHandlerCaller1 = SignalHandlerCaller<Caller>;
+
+template<class Caller>
+using SignalHandlerCaller2 = SignalHandlerCaller<Caller>;
+
template<typename Caller>
-class SignalHandlerCaller2
-{
-public:
-typedef typename Caller::first_argument_type first_argument_type;
-typedef typename Caller::second_argument_type second_argument_type;
-typedef SignalHandlerResult result_type;
-static result_type call( first_argument_type a1, second_argument_type a2 ){
- Caller::call( a1, a2 );
- return SIGNAL_CONTINUE_EMISSION;
-}
-};
+using SignalHandlerCaller3 = SignalHandlerCaller<Caller>;
template<typename Caller>
-class SignalHandlerCaller3
-{
+using SignalHandlerCaller4 = SignalHandlerCaller<Caller>;
+
+template<typename Other, typename True, typename False, typename Type>
+class TypeEqual {
public:
-typedef typename Caller::first_argument_type first_argument_type;
-typedef typename Caller::second_argument_type second_argument_type;
-typedef typename Caller::third_argument_type third_argument_type;
-typedef SignalHandlerResult result_type;
-static result_type call( first_argument_type a1, second_argument_type a2, third_argument_type a3 ){
- Caller::call( a1, a2, a3 );
- return SIGNAL_CONTINUE_EMISSION;
-}
+ using type = False;
};
-template<typename Caller>
-class SignalHandlerCaller4
-{
+template<typename Other, typename True, typename False>
+class TypeEqual<Other, True, False, Other> {
public:
-typedef typename Caller::first_argument_type first_argument_type;
-typedef typename Caller::second_argument_type second_argument_type;
-typedef typename Caller::third_argument_type third_argument_type;
-typedef typename Caller::fourth_argument_type fourth_argument_type;
-typedef SignalHandlerResult result_type;
-static result_type call( first_argument_type a1, second_argument_type a2, third_argument_type a3, fourth_argument_type a4 ){
- Caller::call( a1, a2, a3, a4 );
- return SIGNAL_CONTINUE_EMISSION;
-}
+ using type = True;
};
-class SignalHandler : public Callback0<SignalHandlerResult>
-{
+template<class CB, template<class T> class Wrapper>
+class SignalHandlerN : public CB {
public:
-template<typename Caller>
-SignalHandler( const BindFirstOpaque<Caller>& caller )
- : Callback0<SignalHandlerResult>( BindFirstOpaque<typename TypeEqual<
- SignalHandlerResult,
- Caller,
- SignalHandlerCaller1<Caller>,
- typename Caller::result_type
- >::type>( caller.getBound() ) ){
-}
+ template<typename Caller>
+ SignalHandlerN(const BindFirstOpaque<Caller> &caller)
+ : CB(BindFirstOpaque<typename TypeEqual<
+ SignalHandlerResult,
+ Caller,
+ Wrapper<Caller>,
+ get_result_type<Caller>
+ >::type>(caller.getBound())) {
+ }
+};
+
+class SignalHandler : public SignalHandlerN<Callback<SignalHandlerResult()>, SignalHandlerCaller1> {
+ using SignalHandlerN<Callback<SignalHandlerResult()>, SignalHandlerCaller1>::SignalHandlerN;
};
template<typename Caller>
return SignalHandler( caller );
}
template<typename Caller>
-inline SignalHandler makeSignalHandler( const Caller& caller, typename Caller::first_argument_type callee ){
+inline SignalHandler makeSignalHandler(const Caller &caller, get_argument<Caller, 0> callee) {
return SignalHandler( BindFirstOpaque<Caller>( callee ) );
}
-
template<typename FirstArgument>
-class SignalHandler1 : public Callback1<FirstArgument, SignalHandlerResult>
-{
-public:
-template<typename Caller>
-SignalHandler1( const BindFirstOpaque1<Caller>& caller )
- : Callback1<FirstArgument, SignalHandlerResult>( BindFirstOpaque1<typename TypeEqual<
- SignalHandlerResult,
- Caller,
- SignalHandlerCaller2<Caller>,
- typename Caller::result_type
- >::type>( caller.getBound() ) ){
-}
+class SignalHandler1 : public SignalHandlerN<Callback<SignalHandlerResult(FirstArgument)>, SignalHandlerCaller2> {
+ using SignalHandlerN<Callback<SignalHandlerResult(FirstArgument)>, SignalHandlerCaller2>::SignalHandlerN;
};
template<typename Caller>
-inline SignalHandler1<typename Caller::second_argument_type> makeSignalHandler1( const BindFirstOpaque1<Caller>& caller ){
- return SignalHandler1<typename Caller::second_argument_type>( caller );
+inline SignalHandler1<get_argument<Caller, 1>> makeSignalHandler1(const BindFirstOpaque<Caller> &caller) {
+ return SignalHandler1<get_argument<Caller, 1>>(caller);
}
template<typename Caller>
-inline SignalHandler1<typename Caller::second_argument_type> makeSignalHandler1( const Caller& caller, typename Caller::first_argument_type callee ){
- return SignalHandler1<typename Caller::second_argument_type>( BindFirstOpaque1<Caller>( callee ) );
+inline SignalHandler1<get_argument<Caller, 1>>
+makeSignalHandler1(const Caller &caller, get_argument<Caller, 0> callee) {
+ return SignalHandler1<get_argument<Caller, 1>>(BindFirstOpaque<Caller>(callee));
}
-
template<typename FirstArgument, typename SecondArgument>
-class SignalHandler2 : public Callback2<FirstArgument, SecondArgument, SignalHandlerResult>
-{
-public:
-template<typename Caller>
-SignalHandler2( const BindFirstOpaque2<Caller>& caller )
- : Callback2<FirstArgument, SecondArgument, SignalHandlerResult>( BindFirstOpaque2<typename TypeEqual<
- SignalHandlerResult,
- Caller,
- SignalHandlerCaller3<Caller>,
- typename Caller::result_type
- >::type>( caller.getBound() ) ){
-}
+class SignalHandler2
+ : public SignalHandlerN<Callback<SignalHandlerResult(FirstArgument, SecondArgument)>, SignalHandlerCaller3> {
+ using SignalHandlerN<Callback<SignalHandlerResult(FirstArgument, SecondArgument)>, SignalHandlerCaller3>::SignalHandlerN;
};
template<typename Caller>
inline SignalHandler2<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type
- > makeSignalHandler2( const BindFirstOpaque2<Caller>& caller ){
+ get_argument<Caller, 1>,
+ get_argument<Caller, 2>
+> makeSignalHandler2(const BindFirstOpaque<Caller> &caller) {
return SignalHandler2<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type
+ get_argument<Caller, 1>,
+ get_argument<Caller, 2>
>( caller );
}
template<typename Caller>
inline SignalHandler2<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type
- > makeSignalHandler2( const Caller& caller, typename Caller::first_argument_type callee ){
+ get_argument<Caller, 1>,
+ get_argument<Caller, 2>
+> makeSignalHandler2(const Caller &caller, get_argument<Caller, 0> callee) {
return SignalHandler2<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type
- >( BindFirstOpaque2<Caller>( callee ) );
+ get_argument<Caller, 1>,
+ get_argument<Caller, 2>
+ >(BindFirstOpaque<Caller>(callee));
}
-
template<typename FirstArgument, typename SecondArgument, typename ThirdArgument>
-class SignalHandler3 : public Callback3<FirstArgument, SecondArgument, ThirdArgument, SignalHandlerResult>
-{
-public:
-template<typename Caller>
-SignalHandler3( const BindFirstOpaque3<Caller>& caller )
- : Callback3<FirstArgument, SecondArgument, ThirdArgument, SignalHandlerResult>( BindFirstOpaque3<typename TypeEqual<
- SignalHandlerResult,
- Caller,
- SignalHandlerCaller4<Caller>,
- typename Caller::result_type
- >::type>( caller.getBound() ) ){
-}
+class SignalHandler3
+ : public SignalHandlerN<Callback<SignalHandlerResult(FirstArgument, SecondArgument, ThirdArgument)>, SignalHandlerCaller4> {
+ using SignalHandlerN<Callback<SignalHandlerResult(FirstArgument, SecondArgument, ThirdArgument)>, SignalHandlerCaller4>::SignalHandlerN;
};
template<typename Caller>
inline SignalHandler3<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type,
- typename Caller::fourth_argument_type
- > makeSignalHandler3( const BindFirstOpaque3<Caller>& caller ){
+ get_argument<Caller, 1>,
+ get_argument<Caller, 2>,
+ get_argument<Caller, 3>
+> makeSignalHandler3(const BindFirstOpaque<Caller> &caller) {
return SignalHandler3<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type,
- typename Caller::fourth_argument_type
+ get_argument<Caller, 1>,
+ get_argument<Caller, 2>,
+ get_argument<Caller, 3>
>( caller );
}
template<typename Caller>
inline SignalHandler3<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type,
- typename Caller::fourth_argument_type
- > makeSignalHandler3( const Caller& caller, typename Caller::first_argument_type callee ){
+ get_argument<Caller, 1>,
+ get_argument<Caller, 2>,
+ get_argument<Caller, 3>
+> makeSignalHandler3(const Caller &caller, get_argument<Caller, 0> callee) {
return SignalHandler3<
- typename Caller::second_argument_type,
- typename Caller::third_argument_type,
- typename Caller::fourth_argument_type
- >( BindFirstOpaque3<Caller>( callee ) );
+ get_argument<Caller, 1>,
+ get_argument<Caller, 2>,
+ get_argument<Caller, 3>
+ >(BindFirstOpaque<Caller>(callee));
}
#endif
SignalHandlerResult handler0( Test& ){
return SIGNAL_CONTINUE_EMISSION;
}
-typedef Function1<Test&, SignalHandlerResult, handler0> TestHandler0;
+typedef Function<SignalHandlerResult(Test&), handler0> TestHandler0;
int function0( Test& ){
return 7;
}
-typedef Function1<Test&, int, function0> TestFunction0;
+typedef Function<int(Test&), function0> TestFunction0;
SignalHandlerResult handler1( Test&, A1 ){
return SIGNAL_CONTINUE_EMISSION;
}
-typedef Function2<Test&, A1, SignalHandlerResult, handler1> TestHandler1;
+typedef Function<SignalHandlerResult(Test&, A1), handler1> TestHandler1;
void function1( Test&, A1 ){
}
-typedef ReferenceCaller1<Test, A1, function1> TestFunction1;
+typedef ReferenceCaller<Test, void(A1), function1> TestFunction1;
SignalHandlerResult handler2( Test&, A1, A2 ){
return SIGNAL_CONTINUE_EMISSION;
}
-typedef Function3<Test&, A1, A2, SignalHandlerResult, handler2> TestHandler2;
+typedef Function<SignalHandlerResult(Test&, A1, A2), handler2> TestHandler2;
void function2( Test&, A1, A2 ){
}
-typedef Function3<Test&, A1, A2, void, function2> TestFunction2;
+typedef Function<void(Test&, A1, A2), function2> TestFunction2;
SignalHandlerResult handler3( Test&, A1, A2, A3 ){
return SIGNAL_CONTINUE_EMISSION;
}
-typedef Function4<Test&, A1, A2, A3, SignalHandlerResult, handler3> TestHandler3;
+typedef Function<SignalHandlerResult(Test&, A1, A2, A3), handler3> TestHandler3;
void function3( Test&, A1, A2, A3 ){
}
-typedef Function4<Test&, A1, A2, A3, void, function3> TestFunction3;
+typedef Function<void(Test&, A1, A2, A3), function3> TestFunction3;
void testSignals(){
Test test;
typedef SignalBase< SignalHandler1<FirstArgument> > Base;
public:
void operator()( FirstArgument a1 ) const {
- invokeSignalHandlers( Base::begin(), Base::end(), Functor1Invoke<typename Base::handler_type>( a1 ) );
+ invokeSignalHandlers( Base::begin(), Base::end(), FunctorInvoke<typename Base::handler_type>( a1 ) );
}
};
typedef SignalBase< SignalHandler2<FirstArgument, SecondArgument> > Base;
public:
void operator()( FirstArgument a1, SecondArgument a2 ) const {
- invokeSignalHandlers( Base::begin(), Base::end(), Functor2Invoke<typename Base::handler_type>( a1, a2 ) );
+ invokeSignalHandlers( Base::begin(), Base::end(), FunctorInvoke<typename Base::handler_type>( a1, a2 ) );
}
};
typedef SignalBase< SignalHandler3<FirstArgument, SecondArgument, ThirdArgument> > Base;
public:
void operator()( FirstArgument a1, SecondArgument a2, ThirdArgument a3 ) const {
- invokeSignalHandlers( Base::begin(), Base::end(), Functor3Invoke<typename Base::handler_type>( a1, a2, a3 ) );
+ invokeSignalHandlers( Base::begin(), Base::end(), FunctorInvoke<typename Base::handler_type>( a1, a2, a3 ) );
}
};
+++ /dev/null
-
-#include "signalfwd.h"
--- /dev/null
+add_library(splines
+ math_angles.cpp math_angles.h
+ math_matrix.cpp math_matrix.h
+ math_quaternion.cpp math_quaternion.h
+ math_vector.cpp math_vector.h
+ q_parse.cpp
+ q_shared.cpp q_shared.h
+ splines.cpp splines.h
+ util_list.h
+ util_str.cpp util_str.h
+ )
#include <string.h>
#include "math_vector.h"
-#ifndef ID_INLINE
-#ifdef _WIN32
-#define ID_INLINE __inline
-#else
-#define ID_INLINE inline
-#endif
-#endif
-
class quat_t;
class angles_t;
ID_INLINE mat3_t::mat3_t() {
}
-ID_INLINE mat3_t::mat3_t( float src[ 3 ][ 3 ] ) {
- memcpy( mat, src, sizeof( src ) );
+ID_INLINE mat3_t::mat3_t(float src[3][3]) {
+ memcpy(mat, src, sizeof(float) * 3 * 3);
}
ID_INLINE mat3_t::mat3_t( idVec3 const &x, idVec3 const &y, idVec3 const &z ) {
}
inline int operator!=( quat_t a, quat_t b ) {
- return ( ( a.x != b.x ) || ( a.y != b.y ) || ( a.z != b.z ) && ( a.w != b.w ) );
+ return ( ( a.x != b.x ) || ( a.y != b.y ) || (( a.z != b.z ) && ( a.w != b.w )) );
}
inline float quat_t::Length( void ) {
#ifndef __MATH_VECTOR_H__
#define __MATH_VECTOR_H__
-#ifdef WIN32
+#include "globaldefs.h"
+
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4244)
#endif
float Q_fabs( float f );
#ifndef ID_INLINE
-#ifdef _WIN32
-#define ID_INLINE __inline
-#else
-#define ID_INLINE inline
-#endif
+#define ID_INLINE GDEF_ATTRIBUTE_INLINE
#endif
// if this is defined, vec3 will take four elements, which may allow
}
B = x;
-#ifdef __GNUC__
+#if GDEF_COMPILER_GNU
asm ( "frsqrte %0,%1" : "=f" ( y0 ) : "f" ( B ) );
#else
y0 = __frsqrte( B );
char parseFile[MAX_QPATH];
} parseInfo_t;
-#define MAX_PARSE_INFO 16
+const int MAX_PARSE_INFO = 16;
static parseInfo_t parseInfo[MAX_PARSE_INFO];
static int parseInfoNum;
static parseInfo_t *pi = &parseInfo[0];
Safe strncpy that ensures a trailing zero
=============
*/
-void Q_strncpyz( char *dest, const char *src, int destsize ) {
+void Q_strncpyz( char *dest, const char *src, std::size_t destsize ) {
if ( !src ) {
Com_Error( ERR_FATAL, "Q_strncpyz: NULL src" );
}
// never goes past bounds or leaves without a terminating 0
-void Q_strcat( char *dest, int size, const char *src ) {
- int l1;
-
- l1 = strlen( dest );
+void Q_strcat( char *dest, std::size_t size, const char *src ) {
+ auto l1 = strlen( dest );
if ( l1 >= size ) {
Com_Error( ERR_FATAL, "Q_strcat: already overflowed" );
}
}
-void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... ) {
- int len;
+void QDECL Com_sprintf( char *dest, std::size_t size, const char *fmt, ... ) {
va_list argptr;
char bigbuffer[32000]; // big, but small enough to fit in PPC stack
va_start( argptr,fmt );
- len = vsprintf( bigbuffer,fmt,argptr );
+ int ret = vsprintf( bigbuffer,fmt,argptr );
va_end( argptr );
+ if ( ret < 0 ) {
+ Com_Error(ERR_FATAL, "Com_sprintf: vsprintf failed");
+ }
+ auto len = static_cast<size_t>(ret);
if ( len >= sizeof( bigbuffer ) ) {
Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" );
}
FIXME: make this buffer size safe someday
============
*/
-char * QDECL va( char *format, ... ) {
+char *QDECL va( const char *format, ... ) {
va_list argptr;
static char string[2][32000]; // in case va is called by nested functions
static int index = 0;
FIXME: overflow check?
===============
*/
-char *Info_ValueForKey( const char *s, const char *key ) {
+const char *Info_ValueForKey( const char *s, const char *key ) {
char pkey[MAX_INFO_KEY];
static char value[2][MAX_INFO_VALUE]; // use two buffers so compares
// work without stomping on each other
#ifndef __Q_SHARED_H
#define __Q_SHARED_H
+#include "globaldefs.h"
+
// q_shared.h -- included first by ALL program modules.
// these are the definitions that have no dependance on
// central system services, and can be used by any part
#define ALIGN_ON
#define ALIGN_OFF
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4018) // signed/unsigned mismatch
#pragma warning(disable : 4032)
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
-#ifdef WIN32 // mac doesn't have malloc.h
+#include <cstddef>
+
+#if GDEF_OS_WINDOWS // mac doesn't have malloc.h
#include <malloc.h> // for _alloca()
#endif
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
//#pragma intrinsic( memset, memcpy )
// this is the define for determining if we have an asm version of a C function
-#if ( defined _M_IX86 || defined __i386__ ) && !defined __sun__ && !defined __LCC__
+#if GDEF_ARCH_BITS_32 && !defined __sun__ && !defined __LCC__
#define id386 1
#else
#define id386 0
//======================= WIN32 DEFINES =================================
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#define MAC_STATIC
// buildstring will be incorporated into the version string
#ifdef NDEBUG
-#ifdef _M_IX86
+#if GDEF_ARCH_BITS_32
#define CPUSTRING "win-x86"
#elif defined _M_ALPHA
#define CPUSTRING "win-AXP"
#endif
#else
-#ifdef _M_IX86
+#if GDEF_ARCH_BITS_32
#define CPUSTRING "win-x86-debug"
#elif defined _M_ALPHA
#define CPUSTRING "win-AXP-debug"
//======================= MAC OS X SERVER DEFINES =====================
-#if defined( __MACH__ ) && defined( __APPLE__ )
+#if GDEF_OS_MACOS && defined( __MACH__ )
#define MAC_STATIC
#ifdef __ppc__
#define CPUSTRING "MacOSXS-ppc"
-#elif defined __i386__
+#elif GDEF_ARCH_BITS_32
#define CPUSTRING "MacOSXS-i386"
#else
#define CPUSTRING "MacOSXS-other"
#undef ALIGN_ON
#undef ALIGN_OFF
-#define ALIGN_ON # pragma align( 16 )
-#define ALIGN_OFF # pragma align()
+#define ALIGN_ON #pragma align( 16 )
+#define ALIGN_OFF #pragma align()
#ifdef __cplusplus
extern "C" {
// the mac compiler can't handle >32k of locals, so we
// just waste space and make big arrays static...
-#ifdef __linux__
+#if GDEF_OS_LINUX
#define MAC_STATIC
-#ifdef __i386__
+#if GDEF_ARCH_BITS_32
#define CPUSTRING "linux-i386"
#elif defined __axp__
#define CPUSTRING "linux-alpha"
#define MAX_QINT 0x7fffffff
#define MIN_QINT ( -MAX_QINT - 1 )
-#ifndef max
+#if !defined(__cplusplus) && !defined(max)
#define max( x, y ) ( ( ( x ) > ( y ) ) ? ( x ) : ( y ) )
#define min( x, y ) ( ( ( x ) < ( y ) ) ? ( x ) : ( y ) )
#endif
extern "C" {
#endif
-void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... );
+void QDECL Com_sprintf( char *dest, std::size_t size, const char *fmt, ... );
// mode parm for FS_FOpenFile
char *Q_strrchr( const char* string, int c );
// buffer size safe library replacements
-void Q_strncpyz( char *dest, const char *src, int destsize );
-void Q_strcat( char *dest, int size, const char *src );
+void Q_strncpyz( char *dest, const char *src, std::size_t destsize );
+void Q_strcat( char *dest, std::size_t size, const char *src );
// strlen that discounts Quake color sequences
int Q_PrintStrlen( const char *string );
float LittleFloat( float l );
void Swap_Init( void );
-char * QDECL va( char *format, ... );
+char *QDECL va( const char *format, ... );
#ifdef __cplusplus
}
//
// key / value info strings
//
-char *Info_ValueForKey( const char *s, const char *key );
+const char *Info_ValueForKey( const char *s, const char *key );
void Info_RemoveKey( char *s, const char *key );
void Info_SetValueForKey( char *s, const char *key, const char *value );
qboolean Info_Validate( const char *s );
// Certainly better ways to do this, but this lets
// me get underway quickly with ents that need spline
// targets.
-#define MAX_CAMERAS 64
+const int MAX_CAMERAS = 64;
idCameraDef camera[MAX_CAMERAS];
}
-#define NUM_CCELERATION_SEGS 10
-#define CELL_AMT 5
+const int NUM_CCELERATION_SEGS = 10;
+const int CELL_AMT = 5;
void idCameraDef::buildCamera() {
int i;
for ( i = 0; i < events.Num(); i++ ) {
events[i]->setTriggered( false );
switch ( events[i]->getType() ) {
+ default: break;
case idCameraEvent::EVENT_TARGET: {
targets.Append( i );
break;
Com_UngetToken();
idStr key = Com_ParseOnLine( text );
- const char *token = Com_Parse( text );
+ Com_Parse( text );
if ( Q_stricmp( key.c_str(), "pos" ) == 0 ) {
Com_UngetToken();
Com_Parse1DMatrix( text, 3, pos );
Com_UngetToken();
idCameraPosition::parseToken( key.c_str(), text );
}
- token = Com_Parse( text );
+ Com_Parse( text );
} while ( 1 );
Com_UngetToken();
idStr key = Com_ParseOnLine( text );
- const char *token = Com_Parse( text );
+ Com_Parse( text );
if ( Q_stricmp( key.c_str(), "startPos" ) == 0 ) {
Com_UngetToken();
Com_Parse1DMatrix( text, 3, startPos );
Com_UngetToken();
idCameraPosition::parseToken( key.c_str(), text );
}
- token = Com_Parse( text );
+ Com_Parse( text );
} while ( 1 );
Com_UngetToken();
idStr key = Com_ParseOnLine( text );
- const char *token = Com_Parse( text );
+ Com_Parse( text );
if ( Q_stricmp( key.c_str(), "target" ) == 0 ) {
target.parse( text );
}
Com_UngetToken();
idCameraPosition::parseToken( key.c_str(), text );
}
- token = Com_Parse( text );
+ Com_Parse( text );
} while ( 1 );
#include <stdio.h>
#include <stdarg.h>
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data
#pragma warning(disable : 4710) // function 'blah' not inlined
#endif
strncpy( dst, buffer, size - 1 );
}
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4189) // local variable is initialized but not referenced
#endif
void
){
char ch; // ch == ?
+ (void) ch;
idStr *t; // t == ?
idStr a; // a.len == 0, a.data == "\0"
idStr b; // b.len == 0, b.data == "\0"
idStr c( "test" ); // c.len == 4, c.data == "test\0"
idStr d( c ); // d.len == 4, d.data == "test\0"
- idStr e( reinterpret_cast<const char *>( NULL ) );
+ idStr e( static_cast<const char *>( NULL ) );
// e.len == 0, e.data == "\0" ASSERT!
int i; // i == ?
+ (void) i;
i = a.length(); // i == 0
i = c.length(); // i == 4
a = NULL; // a.len == 0, a.data == "\0" ASSERT!
a = c + d; // a.len == 8, a.data == "testtest\0"
a = c + "wow"; // a.len == 7, a.data == "testwow\0"
- a = c + reinterpret_cast<const char *>( NULL );
+ a = c + static_cast<const char *>( NULL );
// a.len == 4, a.data == "test\0" ASSERT!
a = "this" + d; // a.len == 8, a.data == "thistest\0"
- a = reinterpret_cast<const char *>( NULL ) + d;
+ a = static_cast<const char *>( NULL ) + d;
// a.len == 4, a.data == "test\0" ASSERT!
a += c; // a.len == 8, a.data == "testtest\0"
a += "wow"; // a.len == 11, a.data == "testtestwow\0"
- a += reinterpret_cast<const char *>( NULL );
+ a += static_cast<const char *>( NULL );
// a.len == 11, a.data == "testtestwow\0" ASSERT!
a = "test"; // a.len == 4, a.data == "test\0"
a[1] = '1'; // a.data = "t1st", b.data = "test"
}
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(default : 4189) // local variable is initialized but not referenced
#pragma warning(disable : 4514) // unreferenced inline function has been removed
#endif
#include <string.h>
#include <stdio.h>
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4710) // function 'blah' not inlined
#endif
+++ /dev/null
-/*
- Copyright (c) 2001, Loki software, inc.
- 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 name of Loki software nor the names of its 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 REGENTS 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.
- */
-
-#include "str.h"
#ifndef __STR__
#define __STR__
+#include "globaldefs.h"
+
//
// class Str
// loose replacement for CString from MFC
#include <cstdio>
-#ifdef _MSC_VER
+#if GDEF_COMPILER_MSVC
#define strcasecmp strcmpi
#if _MSC_VER < 1400
#define vsnprintf std::vsnprintf
return strcpy( new char[strlen( pStr ) + 1], pStr );
}
-#if !defined( WIN32 )
+#if !GDEF_OS_WINDOWS
#define strcmpi strcasecmp
#define stricmp strcasecmp
#define strnicmp strncasecmp
}
else
{
- g_pStrWork = "";
g_pStrWork = new char[1];
g_pStrWork[0] = '\0';
}
}
else
{
- g_pStrWork = "";
g_pStrWork = new char[1];
g_pStrWork[0] = '\0';
}
bool operator >( const char* pStr ) const { return ( m_bIgnoreCase ) ? stricmp( m_pStr, pStr ) > 0 : strcmp( m_pStr, pStr ) > 0; }
char& operator []( std::size_t nIndex ) { return m_pStr[nIndex]; }
const char& operator []( std::size_t nIndex ) const { return m_pStr[nIndex]; }
-const char GetAt( std::size_t nIndex ) { return m_pStr[nIndex]; }
+char GetAt( std::size_t nIndex ) { return m_pStr[nIndex]; }
};
--- /dev/null
+add_library(stream
+ _.cpp
+ filestream.h
+ memstream.h
+ stringstream.h
+ textfilestream.h
+ textstream.h
+ )
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "filestream.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "memstream.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "stringstream.h"
StringOutputStream(){
}
-StringOutputStream( std::size_t capacity ) : m_string( capacity ){
+explicit StringOutputStream( std::size_t capacity ) : m_string( capacity ){
}
std::size_t write( const char* buffer, std::size_t length ){
m_string.push_range( buffer, buffer + length );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "textfilestream.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "textstream.h"
#if !defined( INCLUDED_STREAM_TEXTSTREAM_H )
#define INCLUDED_STREAM_TEXTSTREAM_H
+#include "globaldefs.h"
+
/// \file
/// \brief Text-output-formatting.
#include "itextstream.h"
+#include "string/string.h"
#include <cctype>
#include <cstddef>
#include <stdio.h>
#include <string.h>
#include <algorithm>
+#include <string>
#include "generic/arrayrange.h"
return ptr;
}
- #if defined ( _WIN64 ) || defined ( __LP64__ )
+ #if GDEF_ARCH_BITS_64
inline char* write_size_t_nonzero_decimal_backward( char* ptr, size_t decimal ){
for (; decimal != 0; decimal /= 10 )
{
return ptr;
}
- #if defined ( _WIN64 ) || defined ( __LP64__ )
+ #if GDEF_ARCH_BITS_64
inline char* write_size_t_nonzero_decimal_backward( char* ptr, size_t decimal, bool show_positive ){
ptr = write_size_t_nonzero_decimal_backward( ptr, decimal );
if ( show_positive ) {
return ptr;
}
- #if defined ( _WIN64 ) || defined ( __LP64__ )
+ #if GDEF_ARCH_BITS_64
inline char* write_size_t_decimal_backward( char* ptr, size_t decimal, bool show_positive ){
if ( decimal == 0 ) {
*--ptr = '0';
}
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#define snprintf _snprintf
#endif
return ostream;
}
-#if defined ( _WIN64 ) || defined ( __LP64__ )
+#if GDEF_ARCH_BITS_64
/// \brief Writes a size_t \p i to \p ostream in decimal form.
template<typename TextOutputStreamType>
}
};
+
+/// \brief A wrapper for a TextInputStream used for reading one text line at a time.
+template<typename TextInputStreamType, int SIZE = 1024>
+class TextLinesInputStream
+{
+TextInputStreamType& m_inputStream;
+char m_buffer[SIZE + 1];
+char* m_cur;
+char* m_end;
+
+int fillBuffer(){
+ m_end = m_buffer + m_inputStream.read( m_buffer, SIZE );
+ m_cur = m_buffer;
+ m_buffer[SIZE] = '\0';
+ *m_end = '\0';
+ return m_end - m_cur;
+}
+public:
+
+TextLinesInputStream( TextInputStreamType& inputStream ) : m_inputStream( inputStream ), m_cur( m_buffer ), m_end( m_buffer ){
+ m_buffer[0] = '\0';
+}
+
+CopiedString readLine(){
+ std::string s;
+ char* m_fin;
+
+ while ( (m_fin = strchr( m_cur, '\n' )) == 0 )
+ {
+ s.append( m_cur, m_end - m_cur );
+ if ( fillBuffer() <= 0 ) break;
+ }
+ if ( m_fin != 0 ) {
+ s.append( m_cur, m_fin - m_cur + 1 );
+ m_cur = m_fin + 1;
+ }
+
+ return CopiedString( s.c_str() );
+}
+};
+
+
/// \brief A wrapper for a TextOutputStream, optimised for writing a few characters at a time.
template<typename TextOutputStreamType, int SIZE = 1024>
class BufferedTextOutputStream : public TextOutputStream
--- /dev/null
+add_library(string
+ pooledstring.cpp pooledstring.h
+ string.h
+ stringfwd.h
+ )
#include "pooledstring.h"
+#include "globaldefs.h"
#include "generic/static.h"
-#if defined( _DEBUG )
+#if GDEF_DEBUG
namespace ExamplePooledString
{
} always;
}
-#endif
\ No newline at end of file
+#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "string.h"
-
-void TestString(){
- CopiedString bleh( "bleh" );
- SmartString blah( "blah" );
-}
\ No newline at end of file
#if !defined( INCLUDED_STRING_STRING_H )
#define INCLUDED_STRING_STRING_H
+#include "globaldefs.h"
+
/// \file
/// C-style null-terminated-character-array string library.
/// Returns 0 if \p string is lexicographically equal to \p other after converting both to lower-case.
/// O(n)
inline int string_compare_nocase( const char* string, const char* other ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
return _stricmp( string, other );
#else
return strcasecmp( string, other );
/// Treats all ascii characters as lower-case during comparisons.
/// O(n)
inline int string_compare_nocase_n( const char* string, const char* other, std::size_t n ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
return _strnicmp( string, other, n );
#else
return strncasecmp( string, other, n );
return string_new( length, allocator );
}
+/// \brief Allocates a new buffer large enough to hold two concatenated strings and fills it with strings.
+inline char* string_new_concat( const char* a, const char* b ){
+ char* str = string_new( string_length( a ) + string_length( b ) );
+ strcpy( str, a );
+ strcat( str, b );
+ return str;
+}
+
/// \brief Deallocates the \p buffer large enough to hold \p length characters.
inline void string_release( char* string, std::size_t length ){
DefaultAllocator<char> allocator;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "stringfwd.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "stringio.h"
#include "iscriplib.h"
#include "string/string.h"
#include "generic/callback.h"
+#include "property.h"
inline float string_read_float( const char* string ){
return static_cast<float>( atof( string ) );
}
-#define RETURN_FALSE_IF_FAIL( expression ) if ( !expression ) {return false; }else
+#define RETURN_FALSE_IF_FAIL(expression) do { if (!(expression)) return false; } while (0)
inline void Tokeniser_unexpectedError( Tokeniser& tokeniser, const char* token, const char* expected ){
globalErrorStream() << Unsigned( tokeniser.getLine() ) << ":" << Unsigned( tokeniser.getColumn() ) << ": parse error at '" << ( token != 0 ? token : "#EOF" ) << "': expected '" << expected << "'\n";
//fallback for 1.#IND 1.#INF 1.#QNAN cases, happening sometimes after rotating & often scaling with tex lock in BP mode
else if ( token != 0 && strstr( token, ".#" ) ) {
globalErrorStream() << "Warning: " << Unsigned( tokeniser.getLine() ) << ":" << Unsigned( tokeniser.getColumn() ) << ": expected parse problem at '" << token << "': wanted '#number'\nProcessing anyway\n";
+ #define GARUX_DISABLE_QNAN_FALLBACK
+ #ifndef GARUX_DISABLE_QNAN_FALLBACK
// *strstr( token, ".#" ) = '\0';
+ #endif
return true;
}
Tokeniser_unexpectedError( tokeniser, token, "#number" );
}
-
-
-inline void CopiedString_importString( CopiedString& self, const char* string ){
- self = string;
-}
-typedef ReferenceCaller1<CopiedString, const char*, CopiedString_importString> CopiedStringImportStringCaller;
-inline void CopiedString_exportString( const CopiedString& self, const StringImportCallback& importer ){
- importer( self.c_str() );
-}
-typedef ConstReferenceCaller1<CopiedString, const StringImportCallback&, CopiedString_exportString> CopiedStringExportStringCaller;
-
-inline void Bool_importString( bool& self, const char* string ){
- self = string_equal( string, "true" );
-}
-typedef ReferenceCaller1<bool, const char*, Bool_importString> BoolImportStringCaller;
-inline void Bool_exportString( const bool& self, const StringImportCallback& importer ){
- importer( self ? "true" : "false" );
-}
-typedef ConstReferenceCaller1<bool, const StringImportCallback&, Bool_exportString> BoolExportStringCaller;
-
-inline void Int_importString( int& self, const char* string ){
- if ( !string_parse_int( string, self ) ) {
- self = 0;
- }
-}
-typedef ReferenceCaller1<int, const char*, Int_importString> IntImportStringCaller;
-inline void Int_exportString( const int& self, const StringImportCallback& importer ){
- char buffer[16];
- sprintf( buffer, "%d", self );
- importer( buffer );
-}
-typedef ConstReferenceCaller1<int, const StringImportCallback&, Int_exportString> IntExportStringCaller;
-
-inline void Size_importString( std::size_t& self, const char* string ){
- int i;
- if ( string_parse_int( string, i ) && i >= 0 ) {
- self = i;
- }
- else
- {
- self = 0;
+template<>
+struct PropertyImpl<bool, const char *> {
+ static void Export(const bool &self, const Callback<void(const char *)> &returnz) {
+ returnz(self ? "true" : "false");
}
-}
-typedef ReferenceCaller1<std::size_t, const char*, Size_importString> SizeImportStringCaller;
-inline void Size_exportString( const std::size_t& self, const StringImportCallback& importer ){
- char buffer[16];
- sprintf( buffer, "%u", Unsigned( self ) );
- importer( buffer );
-}
-typedef ConstReferenceCaller1<std::size_t, const StringImportCallback&, Size_exportString> SizeExportStringCaller;
-inline void Float_importString( float& self, const char* string ){
- if ( !string_parse_float( string, self ) ) {
- self = 0;
- }
-}
-typedef ReferenceCaller1<float, const char*, Float_importString> FloatImportStringCaller;
-inline void Float_exportString( const float& self, const StringImportCallback& importer ){
- char buffer[16];
- sprintf( buffer, "%g", self );
- importer( buffer );
-}
-typedef ConstReferenceCaller1<float, const StringImportCallback&, Float_exportString> FloatExportStringCaller;
+ static void Import(bool &self, const char *value) {
+ self = string_equal(value, "true");
+ }
+};
-inline void Vector3_importString( Vector3& self, const char* string ){
- if ( !string_parse_vector3( string, self ) ) {
- self = Vector3( 0, 0, 0 );
+template<>
+struct PropertyImpl<int, const char *> {
+ static void Export(const int &self, const Callback<void(const char *)> &returnz) {
+ char buffer[16];
+ sprintf(buffer, "%d", self);
+ returnz(buffer);
}
-}
-typedef ReferenceCaller1<Vector3, const char*, Vector3_importString> Vector3ImportStringCaller;
-inline void Vector3_exportString( const Vector3& self, const StringImportCallback& importer ){
- char buffer[64];
- sprintf( buffer, "%g %g %g", self[0], self[1], self[2] );
- importer( buffer );
-}
-typedef ConstReferenceCaller1<Vector3, const StringImportCallback&, Vector3_exportString> Vector3ExportStringCaller;
-
-
-template<typename FirstArgument, typename Caller, typename FirstConversion>
-class ImportConvert1
-{
-public:
-static void thunk( void* environment, FirstArgument firstArgument ){
- Caller::thunk( environment, FirstConversion( firstArgument ) );
-}
+ static void Import(int &self, const char *value) {
+ if (!string_parse_int(value, self)) {
+ self = 0;
+ }
+ }
};
+template<>
+struct PropertyImpl<std::size_t, const char *> {
+ static void Export(const std::size_t &self, const Callback<void(const char *)> &returnz) {
+ char buffer[16];
+ sprintf(buffer, "%u", Unsigned(self));
+ returnz(buffer);
+ }
-class BoolFromString
-{
-bool m_value;
-public:
-BoolFromString( const char* string ){
- Bool_importString( m_value, string );
-}
-operator bool() const
-{
- return m_value;
-}
+ static void Import(std::size_t &self, const char *value) {
+ int i;
+ if (string_parse_int(value, i) && i >= 0) {
+ self = i;
+ } else {
+ self = 0;
+ }
+ }
};
-inline void Bool_toString( const StringImportCallback& self, bool value ){
- Bool_exportString( value, self );
-}
-typedef ConstReferenceCaller1<StringImportCallback, bool, Bool_toString> BoolToString;
-
-
-template<typename Caller>
-inline StringImportCallback makeBoolStringImportCallback( const Caller& caller ){
- return StringImportCallback( caller.getEnvironment(), ImportConvert1<StringImportCallback::first_argument_type, Caller, BoolFromString>::thunk );
-}
-
-template<typename Caller>
-inline StringExportCallback makeBoolStringExportCallback( const Caller& caller ){
- return StringExportCallback( caller.getEnvironment(), ImportConvert1<StringExportCallback::first_argument_type, Caller, BoolToString>::thunk );
-}
-
+template<>
+struct PropertyImpl<float, const char *> {
+ static void Export(const float &self, const Callback<void(const char *)> &returnz) {
+ char buffer[16];
+ sprintf(buffer, "%g", self);
+ returnz(buffer);
+ }
-class IntFromString
-{
-int m_value;
-public:
-IntFromString( const char* string ){
- Int_importString( m_value, string );
-}
-operator int() const
-{
- return m_value;
-}
+ static void Import(float &self, const char *value) {
+ if (!string_parse_float(value, self)) {
+ self = 0;
+ }
+ }
};
-inline void Int_toString( const StringImportCallback& self, int value ){
- Int_exportString( value, self );
-}
-typedef ConstReferenceCaller1<StringImportCallback, int, Int_toString> IntToString;
-
-
-template<typename Caller>
-inline StringImportCallback makeIntStringImportCallback( const Caller& caller ){
- return StringImportCallback( caller.getEnvironment(), ImportConvert1<StringImportCallback::first_argument_type, Caller, IntFromString>::thunk );
-}
-
-template<typename Caller>
-inline StringExportCallback makeIntStringExportCallback( const Caller& caller ){
- return StringExportCallback( caller.getEnvironment(), ImportConvert1<StringExportCallback::first_argument_type, Caller, IntToString>::thunk );
-}
-
-
+template<>
+struct PropertyImpl<Vector3, const char *> {
+ static void Export(const Vector3 &self, const Callback<void(const char *)> &returnz) {
+ char buffer[64];
+ sprintf(buffer, "%g %g %g", self[0], self[1], self[2]);
+ returnz(buffer);
+ }
-class SizeFromString
-{
-std::size_t m_value;
-public:
-SizeFromString( const char* string ){
- Size_importString( m_value, string );
-}
-operator std::size_t() const
-{
- return m_value;
-}
+ static void Import(Vector3 &self, const char *value) {
+ if (!string_parse_vector3(value, self)) {
+ self = Vector3(0, 0, 0);
+ }
+ }
};
-inline void Size_toString( const StringImportCallback& self, std::size_t value ){
- Size_exportString( value, self );
-}
-typedef ConstReferenceCaller1<StringImportCallback, std::size_t, Size_toString> SizeToString;
-
-
-template<typename Caller>
-inline StringImportCallback makeSizeStringImportCallback( const Caller& caller ){
- return StringImportCallback( caller.getEnvironment(), ImportConvert1<StringImportCallback::first_argument_type, Caller, SizeFromString>::thunk );
-}
-
-template<typename Caller>
-inline StringExportCallback makeSizeStringExportCallback( const Caller& caller ){
- return StringExportCallback( caller.getEnvironment(), ImportConvert1<StringExportCallback::first_argument_type, Caller, SizeToString>::thunk );
-}
-
#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "texturelib.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "transformlib.h"
Translation m_translation;
Rotation m_rotation;
Scale m_scale;
-Callback m_changed;
-Callback m_apply;
+Callback<void()> m_changed;
+Callback<void()> m_apply;
TransformModifierType m_type;
public:
-TransformModifier( const Callback& changed, const Callback& apply ) :
+TransformModifier( const Callback<void()>& changed, const Callback<void()>& apply ) :
m_translation( c_translation_identity ),
m_rotation( c_quaternion_identity ),
m_scale( c_scale_identity ),
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "traverselib.h"
}
/// \brief \copydoc scene::Traversable::insert()
void insert( scene::Node& node ){
- ASSERT_MESSAGE( &node != 0, "TraversableNodeSet::insert: sanity check failed" );
m_undo.save();
ASSERT_MESSAGE( m_children.find( NodeSmartReference( node ) ) == m_children.end(), "TraversableNodeSet::insert - element already exists" );
}
/// \brief \copydoc scene::Traversable::erase()
void erase( scene::Node& node ){
- ASSERT_MESSAGE( &node != 0, "TraversableNodeSet::erase: sanity check failed" );
m_undo.save();
ASSERT_MESSAGE( m_children.find( NodeSmartReference( node ) ) != m_children.end(), "TraversableNodeSet::erase - failed to find element" );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "typesystem.h"
class InitialiserList
{
-typedef std::list<Callback> Initialisers;
+typedef std::list<Callback<void()>> Initialisers;
Initialisers m_initialisers;
mutable bool m_initialised;
public:
InitialiserList() : m_initialised( false ){
}
-void addInitialiser( const Callback& callback ){
+void addInitialiser( const Callback<void()>& callback ){
m_initialisers.push_back( callback );
}
void initialise() const {
--- /dev/null
+add_library(uilib
+ uilib.cpp
+ )
+
+find_package(GLIB REQUIRED)
+target_include_directories(uilib PUBLIC ${GLIB_INCLUDE_DIRS})
+target_link_libraries(uilib PUBLIC ${GLIB_LIBRARIES})
+
+find_package(Pango REQUIRED)
+target_include_directories(uilib PUBLIC ${Pango_INCLUDE_DIRS} ${PangoFT2_INCLUDE_DIRS})
+target_link_libraries(uilib PUBLIC ${Pango_LIBRARIES} ${PangoFT2_LIBRARIES})
+
+find_package(GTK${GTK_TARGET} REQUIRED)
+target_include_directories(uilib PUBLIC ${GTK${GTK_TARGET}_INCLUDE_DIRS})
+target_link_libraries(uilib PUBLIC ${GTK${GTK_TARGET}_LIBRARIES})
+
+target_include_directories(uilib PUBLIC gtkutil)
+target_link_libraries(uilib PUBLIC gtkutil)
--- /dev/null
+#include "uilib.h"
+
+#include <tuple>
+
+#include <gtk/gtk.h>
+
+#include "gtkutil/dialog.h"
+#include "gtkutil/filechooser.h"
+#include "gtkutil/messagebox.h"
+#include "gtkutil/window.h"
+
+namespace ui {
+
+ bool init(int *argc, char **argv[], char const *parameter_string, char const **error)
+ {
+ gtk_disable_setlocale();
+ static GOptionEntry entries[] = {{}};
+ char const *translation_domain = NULL;
+ GError *gerror = NULL;
+ bool ret = gtk_init_with_args(argc, argv, parameter_string, entries, translation_domain, &gerror) != 0;
+ if (!ret) {
+ *error = gerror->message;
+ }
+ return ret;
+ }
+
+ void main()
+ {
+ gtk_main();
+ }
+
+ void process()
+ {
+ while (gtk_events_pending()) {
+ gtk_main_iteration();
+ }
+ }
+
+#define IMPL(T, F) template<> _IMPL(T, F)
+#define _IMPL(T, F) struct verify<T *> { using self = T; static self test(self it) { return self::from(F(it)); } }
+
+ template<class T>
+ struct verify;
+
+ template<class T> _IMPL(T,);
+
+ template<class T>
+ using pointer_remove_const = std::add_pointer<
+ typename std::remove_const<
+ typename std::remove_pointer<T>::type
+ >::type
+ >;
+
+#define this (verify<self>::test(*static_cast<self>(const_cast<pointer_remove_const<decltype(this)>::type>(this))))
+
+ IMPL(Editable, GTK_EDITABLE);
+
+ void IEditable::editable(bool value)
+ {
+ gtk_editable_set_editable(this, value);
+ }
+
+ IMPL(TreeModel, GTK_TREE_MODEL);
+
+ IMPL(Widget, GTK_WIDGET);
+
+ Widget::Widget(ui::New_t) : Widget(nullptr)
+ {}
+
+ Window IWidget::window()
+ {
+ return Window::from(gtk_widget_get_toplevel(this));
+ }
+
+ const char *
+ IWidget::file_dialog(bool open, const char *title, const char *path, const char *pattern, bool want_load,
+ bool want_import, bool want_save)
+ {
+ return ::file_dialog(this.window(), open, title, path, pattern, want_load, want_import, want_save);
+ }
+
+ bool IWidget::visible()
+ {
+ return gtk_widget_get_visible(this) != 0;
+ }
+
+ void IWidget::visible(bool shown)
+ {
+ if (shown) {
+ this.show();
+ } else {
+ this.hide();
+ }
+ }
+
+ void IWidget::show()
+ {
+ gtk_widget_show(this);
+ }
+
+ void IWidget::hide()
+ {
+ gtk_widget_hide(this);
+ }
+
+ Dimensions IWidget::dimensions()
+ {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(this, &allocation);
+ return Dimensions{allocation.width, allocation.height};
+ }
+
+ void IWidget::dimensions(int width, int height)
+ {
+ gtk_widget_set_size_request(this, width, height);
+ }
+
+ void IWidget::destroy()
+ {
+ gtk_widget_destroy(this);
+ }
+
+ IMPL(Container, GTK_CONTAINER);
+
+ void IContainer::add(Widget widget)
+ {
+ gtk_container_add(this, widget);
+ }
+
+ void IContainer::remove(Widget widget)
+ {
+ gtk_container_remove(this, widget);
+ }
+
+ IMPL(Bin, GTK_BIN);
+
+ IMPL(Window, GTK_WINDOW);
+
+ Window::Window(window_type type) : Window(GTK_WINDOW(gtk_window_new(
+ type == window_type::TOP ? GTK_WINDOW_TOPLEVEL :
+ type == window_type::POPUP ? GTK_WINDOW_POPUP :
+ GTK_WINDOW_TOPLEVEL
+ )))
+ {}
+
+ Window IWindow::create_dialog_window(const char *title, void func(), void *data, int default_w, int default_h)
+ {
+ return Window(::create_dialog_window(this, title, func, data, default_w, default_h));
+ }
+
+ Window IWindow::create_modal_dialog_window(const char *title, ModalDialog &dialog, int default_w, int default_h)
+ {
+ return Window(::create_modal_dialog_window(this, title, dialog, default_w, default_h));
+ }
+
+ Window IWindow::create_floating_window(const char *title)
+ {
+ return Window(::create_floating_window(title, this));
+ }
+
+ std::uint64_t IWindow::on_key_press(bool (*f)(Widget widget, _GdkEventKey *event, void *extra), void *extra)
+ {
+ using f_t = decltype(f);
+ struct user_data {
+ f_t f;
+ void *extra;
+ } *pass = new user_data{f, extra};
+ auto dtor = [](user_data *data, GClosure *) {
+ delete data;
+ };
+ auto func = [](_GtkWidget *widget, GdkEventKey *event, user_data *args) -> bool {
+ return args->f(Widget::from(widget), event, args->extra);
+ };
+ auto clos = g_cclosure_new(G_CALLBACK(+func), pass, reinterpret_cast<GClosureNotify>(+dtor));
+ return g_signal_connect_closure(G_OBJECT(this), "key-press-event", clos, false);
+ }
+
+ void IWindow::add_accel_group(AccelGroup group)
+ {
+ gtk_window_add_accel_group(this, group);
+ }
+
+ IMPL(Alignment, GTK_ALIGNMENT);
+
+ Alignment::Alignment(float xalign, float yalign, float xscale, float yscale)
+ : Alignment(GTK_ALIGNMENT(gtk_alignment_new(xalign, yalign, xscale, yscale)))
+ {}
+
+ IMPL(Frame, GTK_FRAME);
+
+ Frame::Frame(const char *label) : Frame(GTK_FRAME(gtk_frame_new(label)))
+ {}
+
+ IMPL(Button, GTK_BUTTON);
+
+ Button::Button(ui::New_t) : Button(GTK_BUTTON(gtk_button_new()))
+ {}
+
+ Button::Button(const char *label) : Button(GTK_BUTTON(gtk_button_new_with_label(label)))
+ {}
+
+ IMPL(ToggleButton, GTK_TOGGLE_BUTTON);
+
+ bool IToggleButton::active() const
+ {
+ return gtk_toggle_button_get_active(this) != 0;
+ }
+
+ void IToggleButton::active(bool value)
+ {
+ gtk_toggle_button_set_active(this, value);
+ }
+
+ IMPL(CheckButton, GTK_CHECK_BUTTON);
+
+ CheckButton::CheckButton(ui::New_t) : CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new()))
+ {}
+
+ CheckButton::CheckButton(const char *label) : CheckButton(GTK_CHECK_BUTTON(gtk_check_button_new_with_label(label)))
+ {}
+
+ IMPL(MenuItem, GTK_MENU_ITEM);
+
+ MenuItem::MenuItem(ui::New_t) : MenuItem(GTK_MENU_ITEM(gtk_menu_item_new()))
+ {}
+
+ MenuItem::MenuItem(const char *label, bool mnemonic) : MenuItem(
+ GTK_MENU_ITEM((mnemonic ? gtk_menu_item_new_with_mnemonic : gtk_menu_item_new_with_label)(label)))
+ {}
+
+ IMPL(TearoffMenuItem, GTK_TEAROFF_MENU_ITEM);
+
+ TearoffMenuItem::TearoffMenuItem(ui::New_t) : TearoffMenuItem(GTK_TEAROFF_MENU_ITEM(gtk_tearoff_menu_item_new()))
+ {}
+
+ IMPL(ComboBoxText, GTK_COMBO_BOX_TEXT);
+
+ ComboBoxText::ComboBoxText(ui::New_t) : ComboBoxText(GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new()))
+ {}
+
+ IMPL(ScrolledWindow, GTK_SCROLLED_WINDOW);
+
+ ScrolledWindow::ScrolledWindow(ui::New_t) : ScrolledWindow(GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(nullptr, nullptr)))
+ {}
+
+ void IScrolledWindow::overflow(Policy x, Policy y)
+ {
+ gtk_scrolled_window_set_policy(this, static_cast<GtkPolicyType>(x), static_cast<GtkPolicyType>(y));
+ }
+
+ IMPL(Box, GTK_BOX);
+
+ void IBox::pack_start(ui::Widget child, bool expand, bool fill, unsigned int padding)
+ {
+ gtk_box_pack_start(this, child, expand, fill, padding);
+ }
+
+ void IBox::pack_end(ui::Widget child, bool expand, bool fill, unsigned int padding)
+ {
+ gtk_box_pack_end(this, child, expand, fill, padding);
+ }
+
+ IMPL(VBox, GTK_VBOX);
+
+ VBox::VBox(bool homogenous, int spacing) : VBox(GTK_VBOX(gtk_vbox_new(homogenous, spacing)))
+ {}
+
+ IMPL(HBox, GTK_HBOX);
+
+ HBox::HBox(bool homogenous, int spacing) : HBox(GTK_HBOX(gtk_hbox_new(homogenous, spacing)))
+ {}
+
+ IMPL(HPaned, GTK_HPANED);
+
+ HPaned::HPaned(ui::New_t) : HPaned(GTK_HPANED(gtk_hpaned_new()))
+ {}
+
+ IMPL(VPaned, GTK_VPANED);
+
+ VPaned::VPaned(ui::New_t) : VPaned(GTK_VPANED(gtk_vpaned_new()))
+ {}
+
+ IMPL(Menu, GTK_MENU);
+
+ Menu::Menu(ui::New_t) : Menu(GTK_MENU(gtk_menu_new()))
+ {}
+
+ IMPL(Table, GTK_TABLE);
+
+ Table::Table(std::size_t rows, std::size_t columns, bool homogenous) : Table(
+ GTK_TABLE(gtk_table_new(rows, columns, homogenous))
+ )
+ {}
+
+ void ITable::attach(Widget child, TableAttach attach, TableAttachOptions options, TablePadding padding) {
+ gtk_table_attach(this, child,
+ attach.left, attach.right, attach.top, attach.bottom,
+ static_cast<GtkAttachOptions>(options.x), static_cast<GtkAttachOptions>(options.y),
+ padding.x, padding.y
+ );
+ }
+
+ IMPL(TextView, GTK_TEXT_VIEW);
+
+ TextView::TextView(ui::New_t) : TextView(GTK_TEXT_VIEW(gtk_text_view_new()))
+ {}
+
+ void ITextView::text(char const *str)
+ {
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(this);
+ gtk_text_buffer_set_text(buffer, str, -1);
+ }
+
+ TreeView::TreeView(ui::New_t) : TreeView(GTK_TREE_VIEW(gtk_tree_view_new()))
+ {}
+
+ TreeView::TreeView(TreeModel model) : TreeView(GTK_TREE_VIEW(gtk_tree_view_new_with_model(model)))
+ {}
+
+ IMPL(Label, GTK_LABEL);
+
+ Label::Label(const char *label) : Label(GTK_LABEL(gtk_label_new(label)))
+ {}
+
+ void ILabel::text(char const *str)
+ {
+ gtk_label_set_text(this, str);
+ }
+
+ IMPL(Image, GTK_IMAGE);
+
+ Image::Image(ui::New_t) : Image(GTK_IMAGE(gtk_image_new()))
+ {}
+
+ IMPL(Entry, GTK_ENTRY);
+
+ Entry::Entry(ui::New_t) : Entry(GTK_ENTRY(gtk_entry_new()))
+ {}
+
+ Entry::Entry(std::size_t max_length) : Entry(ui::New)
+ {
+ gtk_entry_set_max_length(this, static_cast<gint>(max_length));
+ }
+
+ char const *IEntry::text()
+ {
+ return gtk_entry_get_text(this);
+ }
+
+ void IEntry::text(char const *str)
+ {
+ return gtk_entry_set_text(this, str);
+ }
+
+ IMPL(SpinButton, GTK_SPIN_BUTTON);
+
+ SpinButton::SpinButton(Adjustment adjustment, double climb_rate, std::size_t digits) : SpinButton(
+ GTK_SPIN_BUTTON(gtk_spin_button_new(adjustment, climb_rate, digits)))
+ {}
+
+ IMPL(HScale, GTK_HSCALE);
+
+ HScale::HScale(Adjustment adjustment) : HScale(GTK_HSCALE(gtk_hscale_new(adjustment)))
+ {}
+
+ HScale::HScale(double min, double max, double step) : HScale(GTK_HSCALE(gtk_hscale_new_with_range(min, max, step)))
+ {}
+
+ IMPL(Adjustment, GTK_ADJUSTMENT);
+
+ Adjustment::Adjustment(double value,
+ double lower, double upper,
+ double step_increment, double page_increment,
+ double page_size)
+ : Adjustment(
+ GTK_ADJUSTMENT(gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size)))
+ {}
+
+ IMPL(CellRendererText, GTK_CELL_RENDERER_TEXT);
+
+ CellRendererText::CellRendererText(ui::New_t) : CellRendererText(GTK_CELL_RENDERER_TEXT(gtk_cell_renderer_text_new()))
+ {}
+
+ IMPL(TreeViewColumn, GTK_TREE_VIEW_COLUMN);
+
+ TreeViewColumn::TreeViewColumn(const char *title, CellRenderer renderer,
+ std::initializer_list<TreeViewColumnAttribute> attributes)
+ : TreeViewColumn(gtk_tree_view_column_new_with_attributes(title, renderer, nullptr))
+ {
+ for (auto &it : attributes) {
+ gtk_tree_view_column_add_attribute(this, renderer, it.attribute, it.column);
+ }
+ }
+
+ IMPL(AccelGroup, GTK_ACCEL_GROUP);
+
+ AccelGroup::AccelGroup(ui::New_t) : AccelGroup(GTK_ACCEL_GROUP(gtk_accel_group_new()))
+ {}
+
+ IMPL(ListStore, GTK_LIST_STORE);
+
+ void IListStore::clear()
+ {
+ gtk_list_store_clear(this);
+ }
+
+ void IListStore::append()
+ {
+ gtk_list_store_append(this, nullptr);
+ }
+
+ IMPL(TreeStore, GTK_TREE_STORE);
+
+ // IMPL(TreePath, GTK_TREE_PATH);
+
+ TreePath::TreePath(ui::New_t) : TreePath(gtk_tree_path_new())
+ {}
+
+ TreePath::TreePath(const char *path) : TreePath(gtk_tree_path_new_from_string(path))
+ {}
+
+ // Custom
+
+#if GTK_TARGET == 3
+
+ IMPL(GLArea, (void *));
+
+#elif GTK_TARGET == 2
+
+ IMPL(GLArea, GTK_DRAWING_AREA);
+
+#endif
+
+ guint IGLArea::on_render(GCallback pFunction, void *data)
+ {
+#if GTK_TARGET == 3
+ return this.connect("render", pFunction, data);
+#endif
+#if GTK_TARGET == 2
+ return this.connect("expose_event", pFunction, data);
+#endif
+ }
+
+ // global
+
+ Window root{ui::null};
+
+ alert_response alert(Window parent, std::string text, std::string title, alert_type type, alert_icon icon)
+ {
+ auto ret = gtk_MessageBox(parent, text.c_str(),
+ title.c_str(),
+ type == alert_type::OK ? eMB_OK :
+ type == alert_type::OKCANCEL ? eMB_OKCANCEL :
+ type == alert_type::YESNO ? eMB_YESNO :
+ type == alert_type::YESNOCANCEL ? eMB_YESNOCANCEL :
+ type == alert_type::NOYES ? eMB_NOYES :
+ eMB_OK,
+ icon == alert_icon::Default ? eMB_ICONDEFAULT :
+ icon == alert_icon::Error ? eMB_ICONERROR :
+ icon == alert_icon::Warning ? eMB_ICONWARNING :
+ icon == alert_icon::Question ? eMB_ICONQUESTION :
+ icon == alert_icon::Asterisk ? eMB_ICONASTERISK :
+ eMB_ICONDEFAULT
+ );
+ return
+ ret == eIDOK ? alert_response::OK :
+ ret == eIDCANCEL ? alert_response::CANCEL :
+ ret == eIDYES ? alert_response::YES :
+ ret == eIDNO ? alert_response::NO :
+ alert_response::OK;
+ }
+
+}
--- /dev/null
+#ifndef INCLUDED_UILIB_H
+#define INCLUDED_UILIB_H
+
+#include <string>
+#include <glib-object.h>
+
+struct _GdkEventKey;
+struct _GtkAccelGroup;
+struct _GtkAdjustment;
+struct _GtkAlignment;
+struct _GtkBin;
+struct _GtkBox;
+struct _GtkButton;
+struct _GtkCellEditable;
+struct _GtkCellRenderer;
+struct _GtkCellRendererText;
+struct _GtkCheckButton;
+struct _GtkCheckMenuItem;
+struct _GtkComboBox;
+struct _GtkComboBoxText;
+struct _GtkContainer;
+struct _GtkDialog;
+struct _GtkEditable;
+struct _GtkEntry;
+struct _GtkEntryCompletion;
+struct _GtkFrame;
+struct _GtkHBox;
+struct _GtkHPaned;
+struct _GtkHScale;
+struct _GtkImage;
+struct _GtkItem;
+struct _GtkLabel;
+struct _GtkListStore;
+struct _GtkTreeIter;
+struct _GtkMenu;
+struct _GtkMenuBar;
+struct _GtkMenuItem;
+struct _GtkMenuShell;
+struct _GtkMisc;
+struct _GtkObject;
+struct _GtkPaned;
+struct _GtkRadioButton;
+struct _GtkRadioMenuItem;
+struct _GtkRadioToolButton;
+struct _GtkRange;
+struct _GtkScale;
+struct _GtkScrolledWindow;
+struct _GtkSpinButton;
+struct _GtkTable;
+struct _GtkTearoffMenuItem;
+struct _GtkTextView;
+struct _GtkToggleButton;
+struct _GtkToggleToolButton;
+struct _GtkToolbar;
+struct _GtkToolButton;
+struct _GtkToolItem;
+struct _GtkTreeModel;
+struct _GtkTreePath;
+struct _GtkTreeSelection;
+struct _GtkTreeStore;
+struct _GtkTreeView;
+struct _GtkTreeViewColumn;
+struct _GtkVBox;
+struct _GtkVPaned;
+struct _GtkWidget;
+struct _GtkWindow;
+struct _GTypeInstance;
+
+#if GTK_TARGET == 3
+struct _GtkGLArea;
+#endif
+
+#if GTK_TARGET == 2
+using _GtkGLArea = struct _GtkDrawingArea;
+#endif
+
+struct ModalDialog;
+
+namespace ui {
+
+ bool init(int *argc, char **argv[], char const *parameter_string, char const **error);
+
+ void main();
+
+ void process();
+
+ enum class window_type {
+ TOP,
+ POPUP
+ };
+
+ enum class Shadow {
+ NONE,
+ IN,
+ OUT,
+ ETCHED_IN,
+ ETCHED_OUT
+ };
+
+ enum class Policy {
+ ALWAYS,
+ AUTOMATIC,
+ NEVER
+ };
+
+ namespace details {
+
+ enum class Convert {
+ Implicit, Explicit
+ };
+
+ template<class Self, class T, Convert mode>
+ struct Convertible;
+
+ template<class Self, class T>
+ struct Convertible<Self, T, Convert::Implicit> {
+ operator T() const
+ { return reinterpret_cast<T>(static_cast<Self const *>(this)->_handle); }
+ };
+
+ template<class Self, class T>
+ struct Convertible<Self, T, Convert::Explicit> {
+ explicit operator T() const
+ { return reinterpret_cast<T>(static_cast<Self const *>(this)->_handle); }
+ };
+
+ template<class Self, class... T>
+ struct All : T ... {
+ All()
+ {};
+ };
+
+ template<class Self, class Interfaces>
+ struct Mixin;
+ template<class Self>
+ struct Mixin<Self, void()> {
+ using type = All<Self>;
+ };
+ template<class Self, class... Interfaces>
+ struct Mixin<Self, void(Interfaces...)> {
+ using type = All<Self, Interfaces...>;
+ };
+ }
+
+ const struct Null {} null = {};
+ const struct New_t {} New = {};
+
+ class Object :
+ public details::Convertible<Object, _GtkObject *, details::Convert::Explicit>,
+ public details::Convertible<Object, _GTypeInstance *, details::Convert::Explicit> {
+ public:
+ using self = Object *;
+ using native = _GtkObject *;
+ native _handle;
+
+ explicit Object(native h) : _handle(h)
+ {}
+
+ explicit operator bool() const
+ { return _handle != nullptr; }
+
+ explicit operator void *() const
+ { return _handle; }
+
+ void unref()
+ { g_object_unref(_handle); }
+
+ void ref()
+ { g_object_ref(_handle); }
+
+ template<class Lambda>
+ gulong connect(char const *detailed_signal, Lambda &&c_handler, void *data);
+
+ template<class Lambda>
+ gulong connect(char const *detailed_signal, Lambda &&c_handler, Object data);
+ };
+ static_assert(sizeof(Object) == sizeof(Object::native), "object slicing");
+
+#define WRAP(name, super, T, interfaces, ctors, methods) \
+ class name; \
+ class I##name : public details::Convertible<name, T *, details::Convert::Implicit> { \
+ public: \
+ using self = name *; \
+ methods \
+ }; \
+ class name : public super, public I##name, public details::Mixin<name, void interfaces>::type { \
+ public: \
+ using self = name *; \
+ using native = T *; \
+ protected: \
+ explicit name(native h) noexcept : super(reinterpret_cast<super::native>(h)) {} \
+ public: \
+ explicit name(Null n) noexcept : name((native) nullptr) {} \
+ explicit name(New_t); \
+ static name from(native h) { return name(h); } \
+ static name from(void *ptr) { return name((native) ptr); } \
+ ctors \
+ }; \
+ inline bool operator<(name self, name other) { return self._handle < other._handle; } \
+ static_assert(sizeof(name) == sizeof(super), "object slicing")
+
+ // https://developer.gnome.org/gtk2/stable/ch01.html
+
+ // GInterface
+
+ WRAP(CellEditable, Object, _GtkCellEditable, (),
+ ,
+ );
+
+ WRAP(Editable, Object, _GtkEditable, (),
+ ,
+ void editable(bool value);
+ );
+
+ WRAP(TreeModel, Object, _GtkTreeModel, (),
+ ,
+ );
+
+ // GObject
+
+ struct Dimensions {
+ int width;
+ int height;
+ };
+
+ class Window;
+ WRAP(Widget, Object, _GtkWidget, (),
+ ,
+ Window window();
+ const char *file_dialog(
+ bool open,
+ const char *title,
+ const char *path = nullptr,
+ const char *pattern = nullptr,
+ bool want_load = false,
+ bool want_import = false,
+ bool want_save = false
+ );
+ bool visible();
+ void visible(bool shown);
+ void show();
+ void hide();
+ Dimensions dimensions();
+ void dimensions(int width, int height);
+ void destroy();
+ );
+
+ WRAP(Container, Widget, _GtkContainer, (),
+ ,
+ void add(Widget widget);
+
+ void remove(Widget widget);
+
+ template<class Lambda>
+ void foreach(Lambda &&lambda);
+ );
+
+ WRAP(Bin, Container, _GtkBin, (),
+ ,
+ );
+
+ class AccelGroup;
+ WRAP(Window, Bin, _GtkWindow, (),
+ explicit Window(window_type type);
+ ,
+ Window create_dialog_window(
+ const char *title,
+ void func(),
+ void *data,
+ int default_w = -1,
+ int default_h = -1
+ );
+
+ Window create_modal_dialog_window(
+ const char *title,
+ ModalDialog &dialog,
+ int default_w = -1,
+ int default_h = -1
+ );
+
+ Window create_floating_window(const char *title);
+
+ std::uint64_t on_key_press(
+ bool (*f)(Widget widget, _GdkEventKey *event, void *extra),
+ void *extra = nullptr
+ );
+
+ void add_accel_group(AccelGroup group);
+ );
+
+ WRAP(Dialog, Window, _GtkDialog, (),
+ ,
+ );
+
+ WRAP(Alignment, Bin, _GtkAlignment, (),
+ Alignment(float xalign, float yalign, float xscale, float yscale);
+ ,
+ );
+
+ WRAP(Frame, Bin, _GtkFrame, (),
+ explicit Frame(const char *label = nullptr);
+ ,
+ );
+
+ WRAP(Button, Bin, _GtkButton, (),
+ explicit Button(const char *label);
+ ,
+ );
+
+ WRAP(ToggleButton, Button, _GtkToggleButton, (),
+ ,
+ bool active() const;
+ void active(bool value);
+ );
+
+ WRAP(CheckButton, ToggleButton, _GtkCheckButton, (),
+ explicit CheckButton(const char *label);
+ ,
+ );
+
+ WRAP(RadioButton, CheckButton, _GtkRadioButton, (),
+ ,
+ );
+
+ WRAP(Item, Bin, _GtkItem, (),
+ ,
+ );
+
+ WRAP(MenuItem, Item, _GtkMenuItem, (),
+ explicit MenuItem(const char *label, bool mnemonic = false);
+ ,
+ );
+
+ WRAP(CheckMenuItem, MenuItem, _GtkCheckMenuItem, (),
+ ,
+ );
+
+ WRAP(RadioMenuItem, CheckMenuItem, _GtkRadioMenuItem, (),
+ ,
+ );
+
+ WRAP(TearoffMenuItem, MenuItem, _GtkTearoffMenuItem, (),
+ ,
+ );
+
+ WRAP(ComboBox, Bin, _GtkComboBox, (),
+ ,
+ );
+
+ WRAP(ComboBoxText, ComboBox, _GtkComboBoxText, (),
+ ,
+ );
+
+ WRAP(ToolItem, Bin, _GtkToolItem, (),
+ ,
+ );
+
+ WRAP(ToolButton, ToolItem, _GtkToolButton, (),
+ ,
+ );
+
+ WRAP(ToggleToolButton, ToolButton, _GtkToggleToolButton, (),
+ ,
+ );
+
+ WRAP(RadioToolButton, ToggleToolButton, _GtkRadioToolButton, (),
+ ,
+ );
+
+ WRAP(ScrolledWindow, Bin, _GtkScrolledWindow, (),
+ ,
+ void overflow(Policy x, Policy y);
+ );
+
+ WRAP(Box, Container, _GtkBox, (),
+ ,
+ void pack_start(ui::Widget child, bool expand, bool fill, unsigned int padding);
+ void pack_end(ui::Widget child, bool expand, bool fill, unsigned int padding);
+ );
+
+ WRAP(VBox, Box, _GtkVBox, (),
+ VBox(bool homogenous, int spacing);
+ ,
+ );
+
+ WRAP(HBox, Box, _GtkHBox, (),
+ HBox(bool homogenous, int spacing);
+ ,
+ );
+
+ WRAP(Paned, Container, _GtkPaned, (),
+ ,
+ );
+
+ WRAP(HPaned, Paned, _GtkHPaned, (),
+ ,
+ );
+
+ WRAP(VPaned, Paned, _GtkVPaned, (),
+ ,
+ );
+
+ WRAP(MenuShell, Container, _GtkMenuShell, (),
+ ,
+ );
+
+ WRAP(MenuBar, MenuShell, _GtkMenuBar, (),
+ ,
+ );
+
+ WRAP(Menu, MenuShell, _GtkMenu, (),
+ ,
+ );
+
+ struct TableAttach {
+ unsigned int left, right, top, bottom;
+ };
+
+ struct TableAttachOptions {
+ // todo: type safety
+ unsigned int x, y;
+ };
+
+ struct TablePadding {
+ unsigned int x, y;
+ };
+
+ WRAP(Table, Container, _GtkTable, (),
+ Table(std::size_t rows, std::size_t columns, bool homogenous);
+ ,
+ // 5 = expand | fill
+ void attach(Widget child, TableAttach attach, TableAttachOptions options = {5, 5}, TablePadding padding = {0, 0});
+ );
+
+ WRAP(TextView, Container, _GtkTextView, (),
+ ,
+ void text(char const *str);
+ );
+
+ WRAP(Toolbar, Container, _GtkToolbar, (),
+ ,
+ );
+
+ class TreeModel;
+ WRAP(TreeView, Widget, _GtkTreeView, (),
+ TreeView(TreeModel model);
+ ,
+ );
+
+ WRAP(Misc, Widget, _GtkMisc, (),
+ ,
+ );
+
+ WRAP(Label, Widget, _GtkLabel, (),
+ explicit Label(const char *label);
+ ,
+ void text(char const *str);
+ );
+
+ WRAP(Image, Widget, _GtkImage, (),
+ ,
+ );
+
+ WRAP(Entry, Widget, _GtkEntry, (IEditable, ICellEditable),
+ explicit Entry(std::size_t max_length);
+ ,
+ char const *text();
+ void text(char const *str);
+ );
+
+ class Adjustment;
+ WRAP(SpinButton, Entry, _GtkSpinButton, (),
+ SpinButton(Adjustment adjustment, double climb_rate, std::size_t digits);
+ ,
+ );
+
+ WRAP(Range, Widget, _GtkRange, (),
+ ,
+ );
+
+ WRAP(Scale, Range, _GtkScale, (),
+ ,
+ );
+
+ WRAP(HScale, Scale, _GtkHScale, (),
+ explicit HScale(Adjustment adjustment);
+ HScale(double min, double max, double step);
+ ,
+ );
+
+ WRAP(Adjustment, Object, _GtkAdjustment, (),
+ Adjustment(double value,
+ double lower, double upper,
+ double step_increment, double page_increment,
+ double page_size);
+ ,
+ );
+
+ WRAP(CellRenderer, Object, _GtkCellRenderer, (),
+ ,
+ );
+
+ WRAP(CellRendererText, CellRenderer, _GtkCellRendererText, (),
+ ,
+ );
+
+ struct TreeViewColumnAttribute {
+ const char *attribute;
+ int column;
+ };
+ WRAP(TreeViewColumn, Object, _GtkTreeViewColumn, (),
+ TreeViewColumn(const char *title, CellRenderer renderer, std::initializer_list<TreeViewColumnAttribute> attributes);
+ ,
+ );
+
+ WRAP(AccelGroup, Object, _GtkAccelGroup, (),
+ ,
+ );
+
+ WRAP(EntryCompletion, Object, _GtkEntryCompletion, (),
+ ,
+ );
+
+ WRAP(ListStore, Object, _GtkListStore, (ITreeModel),
+ ,
+ void clear();
+
+ template<class... T>
+ void append(T... args);
+
+ void append();
+ );
+
+ WRAP(TreeStore, Object, _GtkTreeStore, (ITreeModel),
+ ,
+ );
+
+ WRAP(TreeSelection, Object, _GtkTreeSelection, (),
+ ,
+ );
+
+ // GBoxed
+
+ WRAP(TreePath, Object, _GtkTreePath, (),
+ explicit TreePath(const char *path);
+ ,
+ );
+
+ // Custom
+
+ WRAP(GLArea, Widget, _GtkGLArea, (),
+ ,
+ guint on_render(GCallback pFunction, void *data);
+ );
+
+#undef WRAP
+
+ // global
+
+ enum class alert_response {
+ OK,
+ CANCEL,
+ YES,
+ NO,
+ };
+
+ enum class alert_type {
+ OK,
+ OKCANCEL,
+ YESNO,
+ YESNOCANCEL,
+ NOYES,
+ };
+
+ enum class alert_icon {
+ Default,
+ Error,
+ Warning,
+ Question,
+ Asterisk,
+ };
+
+ extern class Window root;
+
+ alert_response alert(
+ Window parent,
+ std::string text,
+ std::string title = "NetRadiant",
+ alert_type type = alert_type::OK,
+ alert_icon icon = alert_icon::Default
+ );
+
+ // callbacks
+
+ namespace {
+ using GtkCallback = void (*)(_GtkWidget *, void *);
+ extern "C" {
+ void gtk_container_foreach(_GtkContainer *, GtkCallback, void *);
+ }
+ }
+
+#define this (*static_cast<self>(this))
+
+ template<class Lambda>
+ gulong Object::connect(char const *detailed_signal, Lambda &&c_handler, void *data)
+ {
+ return g_signal_connect(G_OBJECT(this), detailed_signal, c_handler, data);
+ }
+
+ template<class Lambda>
+ gulong Object::connect(char const *detailed_signal, Lambda &&c_handler, Object data)
+ {
+ return g_signal_connect(G_OBJECT(this), detailed_signal, c_handler, (_GtkObject *) data);
+ }
+
+ template<class Lambda>
+ void IContainer::foreach(Lambda &&lambda)
+ {
+ GtkCallback cb = [](_GtkWidget *widget, void *data) -> void {
+ using Function = typename std::decay<Lambda>::type;
+ Function *f = static_cast<Function *>(data);
+ (*f)(Widget::from(widget));
+ };
+ gtk_container_foreach(this, cb, &lambda);
+ }
+
+ namespace {
+ extern "C" {
+ void gtk_list_store_insert_with_values(_GtkListStore *, _GtkTreeIter *, gint position, ...);
+ }
+ }
+
+ template<class... T>
+ void IListStore::append(T... args) {
+ static_assert(sizeof...(args) % 2 == 0, "received an odd number of arguments");
+ gtk_list_store_insert_with_values(this, NULL, -1, args..., -1);
+ }
+
+#undef this
+
+}
+
+#endif
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "undolib.h"
template<typename Copyable>
class ObservedUndoableObject : public Undoable
{
-typedef Callback1<const Copyable&> ImportCallback;
+typedef Callback<void(const Copyable&)> ImportCallback;
Copyable& m_object;
ImportCallback m_importCallback;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "uniquenames.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "versionlib.h"
--- /dev/null
+add_library(xmllib
+ ixml.h
+ xmlelement.h
+ xmlparser.h
+ xmltextags.cpp xmltextags.h
+ xmlwriter.h
+ )
+
+find_package(GLIB REQUIRED)
+target_include_directories(xmllib PUBLIC ${GLIB_INCLUDE_DIRS})
+target_link_libraries(xmllib PUBLIC ${GLIB_LIBRARIES})
+
+find_package(LibXml2 REQUIRED)
+target_include_directories(xmllib PUBLIC ${LIBXML2_INCLUDE_DIR})
+target_link_libraries(xmllib PUBLIC ${LIBXML2_LIBRARIES})
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ixml.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "xmlelement.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "xmlparser.h"
xmlFreeParserCtxt( ctxt );
}
+ (void) wellFormed;
//return wellFormed;
}
private:
returns a vector containing the tags
*/
- char* expression;
+ char const *expression;
if ( shader == NULL ) { // get all tags from all shaders
expression = "/root/*/*/tag";
returns a set containing the shaders (with path)
*/
- char* expression = "/root/*/*[not(child::tag)]";
+ char const *expression = "/root/*/*[not(child::tag)]";
xmlXPathObjectPtr xpathPtr = XpathEval( expression );
xmlNodeSetPtr nodePtr;
returns a set containing all used tags
*/
- char* expression = "/root/*/*/tag";
+ char const *expression = "/root/*/*/tag";
xmlXPathObjectPtr xpathPtr = XpathEval( expression );
xmlNodeSetPtr nodePtr;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "xmlwriter.h"
--- /dev/null
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/modules")
+
+add_custom_target(modules)
+macro(radiant_plugin name)
+ message(STATUS "Found Module ${name}")
+ add_library(${name} MODULE ${ARGN})
+ add_dependencies(modules ${name})
+ copy_dlls(${name})
+ install(
+ TARGETS ${name}
+ LIBRARY DESTINATION modules
+ )
+endmacro()
+
+add_subdirectory(archivepak)
+add_subdirectory(archivewad)
+add_subdirectory(archivezip)
+add_subdirectory(entity)
+add_subdirectory(image)
+
+if(BUILD_CRUNCH)
+ add_subdirectory(imagecrn)
+endif()
+
+add_subdirectory(imagehl)
+add_subdirectory(imagepng)
+add_subdirectory(imageq2)
+add_subdirectory(imagewebp)
+add_subdirectory(iqmmodel)
+add_subdirectory(mapq3)
+add_subdirectory(mapxml)
+add_subdirectory(md3model)
+add_subdirectory(model)
+add_subdirectory(shaders)
+add_subdirectory(vfspk3)
--- /dev/null
+radiant_plugin(archivepak
+ archive.cpp archive.h
+ pak.h
+ plugin.cpp
+ )
#include "archivelib.h"
-#include "plugin.h"
-
#include <map>
#include "string/string.h"
#include "fs_filesystem.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "pak.h"
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
#include "iarchive.h"
#include "debugging/debugging.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; 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
--- /dev/null
+radiant_plugin(archivewad
+ archive.cpp archive.h
+ plugin.cpp
+ wad.h
+ )
#include "archivelib.h"
-#include "plugin.h"
-
#include <map>
#include "string/string.h"
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
#include "iarchive.h"
#include "debugging/debugging.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; 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
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "wad.h"
--- /dev/null
+radiant_plugin(archivezip
+ archive.cpp archive.h
+ pkzip.h
+ plugin.cpp
+ zlibstream.h
+ )
+
+find_package(ZLIB REQUIRED)
+target_include_directories(archivezip PRIVATE ${ZLIB_INCLUDE_DIRS})
+target_link_libraries(archivezip PRIVATE ${ZLIB_LIBRARIES})
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "pkzip.h"
file_header.z_namlen = istream_read_uint16_le( istream );
file_header.z_extras = istream_read_uint16_le( istream );
istream.seek( file_header.z_namlen + file_header.z_extras, SeekableInputStream::cur );
-};
+}
/* B. data descriptor
* the data descriptor exists only if bit 3 of z_flags is set. It is byte aligned
file_trailer.z_crc32 = istream_read_uint32_le( istream );
file_trailer.z_csize = istream_read_uint32_le( istream );
file_trailer.z_usize = istream_read_uint32_le( istream );
-};
+}
/* C. central directory structure:
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
#include "iarchive.h"
#include "debugging/debugging.h"
ArchivePK4Module g_ArchivePK4Module;
+class ArchiveDPKAPI
+{
+_QERArchiveTable m_archivedpk;
+public:
+typedef _QERArchiveTable Type;
+STRING_CONSTANT( Name, "dpk" );
+
+ArchiveDPKAPI(){
+ m_archivedpk.m_pfnOpenArchive = &OpenArchive;
+}
+_QERArchiveTable* getTable(){
+ return &m_archivedpk;
+}
+};
+
+typedef SingletonModule<ArchiveDPKAPI> ArchiveDPKModule;
+
+ArchiveDPKModule g_ArchiveDPKModule;
+
+
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
initialiseModule( server );
g_ArchiveZipModule.selfRegister();
g_ArchivePK4Module.selfRegister();
+ g_ArchiveDPKModule.selfRegister();
}
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; 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
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "zlibstream.h"
--- /dev/null
+radiant_plugin(entity
+ angle.h
+ angles.h
+ colour.h
+ curve.h
+ doom3group.cpp doom3group.h
+ eclassmodel.cpp eclassmodel.h
+ entity.cpp entity.h
+ filters.cpp filters.h
+ generic.cpp generic.h
+ group.cpp group.h
+ keyobservers.h
+ light.cpp light.h
+ miscmodel.cpp miscmodel.h
+ model.h
+ modelskinkey.h
+ namedentity.h
+ namekeys.h
+ origin.h
+ plugin.cpp
+ rotation.h
+ scale.h
+ skincache.cpp skincache.h
+ targetable.cpp targetable.h
+ )
+
+target_include_directories(entity
+ PRIVATE $<TARGET_PROPERTY:uilib,INTERFACE_INCLUDE_DIRECTORIES>
+)
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "angle.h"
class AngleKey
{
-Callback m_angleChanged;
+Callback<void()> m_angleChanged;
public:
float m_angle;
-AngleKey( const Callback& angleChanged )
+AngleKey( const Callback<void()>& angleChanged )
: m_angleChanged( angleChanged ), m_angle( ANGLEKEY_IDENTITY ){
}
read_angle( m_angle, value );
m_angleChanged();
}
-typedef MemberCaller1<AngleKey, const char*, &AngleKey::angleChanged> AngleChangedCaller;
+typedef MemberCaller<AngleKey, void(const char*), &AngleKey::angleChanged> AngleChangedCaller;
void write( Entity* entity ) const {
write_angle( m_angle, entity );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "angles.h"
class AnglesKey
{
-Callback m_anglesChanged;
+Callback<void()> m_anglesChanged;
public:
Vector3 m_angles;
-AnglesKey( const Callback& anglesChanged )
+AnglesKey( const Callback<void()>& anglesChanged )
: m_anglesChanged( anglesChanged ), m_angles( ANGLESKEY_IDENTITY ){
}
read_angle( m_angles, value );
m_anglesChanged();
}
-typedef MemberCaller1<AnglesKey, const char*, &AnglesKey::angleChanged> AngleChangedCaller;
+typedef MemberCaller<AnglesKey, void(const char*), &AnglesKey::angleChanged> AngleChangedCaller;
void anglesChanged( const char* value ){
read_angles( m_angles, value );
m_anglesChanged();
}
-typedef MemberCaller1<AnglesKey, const char*, &AnglesKey::anglesChanged> AnglesChangedCaller;
+typedef MemberCaller<AnglesKey, void(const char*), &AnglesKey::anglesChanged> AnglesChangedCaller;
void write( Entity* entity ) const {
write_angles( m_angles, entity );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "colour.h"
class Colour
{
-Callback m_colourChanged;
+Callback<void()> m_colourChanged;
Shader* m_state;
void capture_state(){
public:
Vector3 m_colour;
-Colour( const Callback& colourChanged )
+Colour( const Callback<void()>& colourChanged )
: m_colourChanged( colourChanged ){
default_colour( m_colour );
capture_state();
m_colourChanged();
}
-typedef MemberCaller1<Colour, const char*, &Colour::colourChanged> ColourChangedCaller;
+typedef MemberCaller<Colour, void(const char*), &Colour::colourChanged> ColourChangedCaller;
void write( Entity* entity ) const {
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "curve.h"
}
}
-class ControlPointTransform
-{
-const Matrix4& m_matrix;
-public:
-ControlPointTransform( const Matrix4& matrix ) : m_matrix( matrix ){
-}
-void operator()( Vector3& point ) const {
- matrix4_transform_point( m_matrix, point );
-}
-};
-
-class ControlPointSnap
-{
-float m_snap;
-public:
-ControlPointSnap( float snap ) : m_snap( snap ){
-}
-void operator()( Vector3& point ) const {
- vector3_snap( point, m_snap );
-}
-};
-
-class ControlPointAdd
-{
-RenderablePointVector& m_points;
-public:
-ControlPointAdd( RenderablePointVector& points ) : m_points( points ){
-}
-void operator()( const Vector3& point ) const {
- m_points.push_back( PointVertex( vertex3f_for_vector3( point ), colour_vertex ) );
-}
-};
-
-class ControlPointAddSelected
-{
-RenderablePointVector& m_points;
-public:
-ControlPointAddSelected( RenderablePointVector& points ) : m_points( points ){
-}
-void operator()( const Vector3& point ) const {
- m_points.push_back( PointVertex( vertex3f_for_vector3( point ), colour_selected ) );
-}
-};
-
class CurveEditType
{
public:
}
void transform( const Matrix4& matrix ){
- forEachSelected( ControlPointTransform( matrix ) );
+ forEachSelected([&](Vector3 &point) {
+ matrix4_transform_point(matrix, point);
+ });
}
void snapto( float snap ){
- forEachSelected( ControlPointSnap( snap ) );
+ forEachSelected([&](Vector3 &point) {
+ vector3_snap(point, snap);
+ });
}
void updateSelected() const {
m_selectedRender.clear();
- forEachSelected( ControlPointAddSelected( m_selectedRender ) );
+ forEachSelected([&](const Vector3 &point) {
+ m_selectedRender.push_back(PointVertex(vertex3f_for_vector3(point), colour_selected));
+ });
}
void renderComponents( Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld ) const {
m_controlsRender.clear();
m_controlsRender.reserve( m_controlPoints.size() );
- forEach( ControlPointAdd( m_controlsRender ) );
+ forEach([&](const Vector3 &point) {
+ m_controlsRender.push_back(PointVertex(vertex3f_for_vector3(point), colour_vertex));
+ });
m_selectedRender.reserve( m_controlPoints.size() );
}
-typedef MemberCaller<CurveEdit, &CurveEdit::curveChanged> CurveChangedCaller;
+typedef MemberCaller<CurveEdit, void(), &CurveEdit::curveChanged> CurveChangedCaller;
};
class NURBSCurve
{
Signal0 m_curveChanged;
-Callback m_boundsChanged;
+Callback<void()> m_boundsChanged;
public:
ControlPoints m_controlPoints;
ControlPoints m_controlPointsTransformed;
RenderableCurve m_renderCurve;
AABB m_bounds;
-NURBSCurve( const Callback& boundsChanged ) : m_boundsChanged( boundsChanged ){
+NURBSCurve( const Callback<void()>& boundsChanged ) : m_boundsChanged( boundsChanged ){
}
SignalHandlerId connect( const SignalHandler& curveChanged ){
m_controlPointsTransformed = m_controlPoints;
curveChanged();
}
-typedef MemberCaller1<NURBSCurve, const char*, &NURBSCurve::curveChanged> CurveChangedCaller;
+typedef MemberCaller<NURBSCurve, void(const char*), &NURBSCurve::curveChanged> CurveChangedCaller;
};
class CatmullRomSpline
{
Signal0 m_curveChanged;
-Callback m_boundsChanged;
+Callback<void()> m_boundsChanged;
public:
ControlPoints m_controlPoints;
ControlPoints m_controlPointsTransformed;
RenderableCurve m_renderCurve;
AABB m_bounds;
-CatmullRomSpline( const Callback& boundsChanged ) : m_boundsChanged( boundsChanged ){
+CatmullRomSpline( const Callback<void()>& boundsChanged ) : m_boundsChanged( boundsChanged ){
}
SignalHandlerId connect( const SignalHandler& curveChanged ){
m_controlPointsTransformed = m_controlPoints;
curveChanged();
}
-typedef MemberCaller1<CatmullRomSpline, const char*, &CatmullRomSpline::curveChanged> CurveChangedCaller;
+typedef MemberCaller<CatmullRomSpline, void(const char*), &CatmullRomSpline::curveChanged> CurveChangedCaller;
};
const char* const curve_Nurbs = "curve_Nurbs";
private:
mutable AABB m_curveBounds;
-Callback m_transformChanged;
-Callback m_evaluateTransform;
+Callback<void()> m_transformChanged;
+Callback<void()> m_evaluateTransform;
CopiedString m_name;
CopiedString m_modelKey;
m_name = value;
updateIsModel();
}
-typedef MemberCaller1<Doom3Group, const char*, &Doom3Group::nameChanged> NameChangedCaller;
+typedef MemberCaller<Doom3Group, void(const char*), &Doom3Group::nameChanged> NameChangedCaller;
void modelChanged( const char* value ){
m_modelKey = value;
m_model.modelChanged( "" );
}
}
-typedef MemberCaller1<Doom3Group, const char*, &Doom3Group::modelChanged> ModelChangedCaller;
+typedef MemberCaller<Doom3Group, void(const char*), &Doom3Group::modelChanged> ModelChangedCaller;
void updateTransform(){
m_transform.localToParent() = g_matrix4_identity;
m_funcStaticOrigin.originChanged();
}
}
-typedef MemberCaller<Doom3Group, &Doom3Group::updateTransform> UpdateTransformCaller;
+typedef MemberCaller<Doom3Group, void(), &Doom3Group::updateTransform> UpdateTransformCaller;
void originChanged(){
m_origin = m_originKey.m_origin;
updateTransform();
}
-typedef MemberCaller<Doom3Group, &Doom3Group::originChanged> OriginChangedCaller;
+typedef MemberCaller<Doom3Group, void(), &Doom3Group::originChanged> OriginChangedCaller;
void rotationChanged(){
rotation_assign( m_rotation, m_rotationKey.m_rotation );
updateTransform();
}
-typedef MemberCaller<Doom3Group, &Doom3Group::rotationChanged> RotationChangedCaller;
+typedef MemberCaller<Doom3Group, void(), &Doom3Group::rotationChanged> RotationChangedCaller;
void skinChanged(){
if ( isModel() ) {
}
}
}
-typedef MemberCaller<Doom3Group, &Doom3Group::skinChanged> SkinChangedCaller;
+typedef MemberCaller<Doom3Group, void(), &Doom3Group::skinChanged> SkinChangedCaller;
public:
-Doom3Group( EntityClass* eclass, scene::Node& node, const Callback& transformChanged, const Callback& boundsChanged, const Callback& evaluateTransform ) :
+Doom3Group( EntityClass* eclass, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& boundsChanged, const Callback<void()>& evaluateTransform ) :
m_entity( eclass ),
m_originKey( OriginChangedCaller( *this ) ),
m_origin( ORIGINKEY_IDENTITY ),
m_traversable( 0 ){
construct();
}
-Doom3Group( const Doom3Group& other, scene::Node& node, const Callback& transformChanged, const Callback& boundsChanged, const Callback& evaluateTransform ) :
+Doom3Group( const Doom3Group& other, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& boundsChanged, const Callback<void()>& evaluateTransform ) :
m_entity( other.m_entity ),
m_originKey( OriginChangedCaller( *this ) ),
m_origin( ORIGINKEY_IDENTITY ),
m_curveNURBS.curveChanged();
m_curveCatmullRom.curveChanged();
}
-typedef MemberCaller<Doom3Group, &Doom3Group::transformChanged> TransformChangedCaller;
-};
-
-class ControlPointAddBounds
-{
-AABB& m_bounds;
-public:
-ControlPointAddBounds( AABB& bounds ) : m_bounds( bounds ){
-}
-void operator()( const Vector3& point ) const {
- aabb_extend_by_point_safe( m_bounds, point );
-}
+typedef MemberCaller<Doom3Group, void(), &Doom3Group::transformChanged> TransformChangedCaller;
};
class Doom3GroupInstance :
const AABB& getSelectedComponentsBounds() const {
m_aabb_component = AABB();
- m_curveNURBS.forEachSelected( ControlPointAddBounds( m_aabb_component ) );
- m_curveCatmullRom.forEachSelected( ControlPointAddBounds( m_aabb_component ) );
+ m_curveNURBS.forEachSelected([&](const Vector3 &point) {
+ aabb_extend_by_point_safe(m_aabb_component, point);
+ });
+ m_curveCatmullRom.forEachSelected([&](const Vector3 &point) {
+ aabb_extend_by_point_safe(m_aabb_component, point);
+ });
return m_aabb_component;
}
evaluateTransform();
m_contained.freezeTransform();
}
-typedef MemberCaller<Doom3GroupInstance, &Doom3GroupInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<Doom3GroupInstance, void(), &Doom3GroupInstance::applyTransform> ApplyTransformCaller;
void selectionChangedComponent( const Selectable& selectable ){
GlobalSelectionSystem().getObserver ( SelectionSystem::eComponent )( selectable );
GlobalSelectionSystem().onComponentSelection( *this, selectable );
}
-typedef MemberCaller1<Doom3GroupInstance, const Selectable&, &Doom3GroupInstance::selectionChangedComponent> SelectionChangedComponentCaller;
+typedef MemberCaller<Doom3GroupInstance, void(const Selectable&), &Doom3GroupInstance::selectionChangedComponent> SelectionChangedComponentCaller;
};
class Doom3GroupNode :
RenderableNamedEntity m_renderName;
ModelSkinKey m_skin;
-Callback m_transformChanged;
-Callback m_evaluateTransform;
+Callback<void()> m_transformChanged;
+Callback<void()> m_evaluateTransform;
void construct(){
default_rotation( m_rotation );
m_transformChanged();
}
-typedef MemberCaller<EclassModel, &EclassModel::updateTransform> UpdateTransformCaller;
+typedef MemberCaller<EclassModel, void(), &EclassModel::updateTransform> UpdateTransformCaller;
void originChanged(){
m_origin = m_originKey.m_origin;
updateTransform();
}
-typedef MemberCaller<EclassModel, &EclassModel::originChanged> OriginChangedCaller;
+typedef MemberCaller<EclassModel, void(), &EclassModel::originChanged> OriginChangedCaller;
void angleChanged(){
m_angle = m_angleKey.m_angle;
updateTransform();
}
-typedef MemberCaller<EclassModel, &EclassModel::angleChanged> AngleChangedCaller;
+typedef MemberCaller<EclassModel, void(), &EclassModel::angleChanged> AngleChangedCaller;
void rotationChanged(){
rotation_assign( m_rotation, m_rotationKey.m_rotation );
updateTransform();
}
-typedef MemberCaller<EclassModel, &EclassModel::rotationChanged> RotationChangedCaller;
+typedef MemberCaller<EclassModel, void(), &EclassModel::rotationChanged> RotationChangedCaller;
void skinChanged(){
scene::Node* node = m_model.getNode();
Node_modelSkinChanged( *node );
}
}
-typedef MemberCaller<EclassModel, &EclassModel::skinChanged> SkinChangedCaller;
+typedef MemberCaller<EclassModel, void(), &EclassModel::skinChanged> SkinChangedCaller;
public:
-EclassModel( EntityClass* eclass, scene::Node& node, const Callback& transformChanged, const Callback& evaluateTransform ) :
+EclassModel( EntityClass* eclass, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& evaluateTransform ) :
m_entity( eclass ),
m_originKey( OriginChangedCaller( *this ) ),
m_origin( ORIGINKEY_IDENTITY ),
m_evaluateTransform( evaluateTransform ){
construct();
}
-EclassModel( const EclassModel& other, scene::Node& node, const Callback& transformChanged, const Callback& evaluateTransform ) :
+EclassModel( const EclassModel& other, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& evaluateTransform ) :
m_entity( other.m_entity ),
m_originKey( OriginChangedCaller( *this ) ),
m_origin( ORIGINKEY_IDENTITY ),
m_evaluateTransform();
updateTransform();
}
-typedef MemberCaller<EclassModel, &EclassModel::transformChanged> TransformChangedCaller;
+typedef MemberCaller<EclassModel, void(), &EclassModel::transformChanged> TransformChangedCaller;
};
class EclassModelInstance : public TargetableInstance, public TransformModifier, public Renderable
evaluateTransform();
m_contained.freezeTransform();
}
-typedef MemberCaller<EclassModelInstance, &EclassModelInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<EclassModelInstance, void(), &EclassModelInstance::applyTransform> ApplyTransformCaller;
};
class EclassModelNode :
namespace scene
{
class Node;
-};
+}
class EntityClass;
scene::Node& New_EclassModel( EntityClass* eclass );
void Entity_setName( Entity& entity, const char* name ){
entity.setKeyValue( "name", name );
}
-typedef ReferenceCaller1<Entity, const char*, Entity_setName> EntitySetNameCaller;
+typedef ReferenceCaller<Entity, void(const char*), Entity_setName> EntitySetNameCaller;
inline Namespaced* Node_getNamespaced( scene::Node& node ){
return NodeTypeCast<Namespaced>::cast( node );
m_e1->setKeyValue( keyname(), name );
m_e2->setKeyValue( "targetname", name );
}
-typedef MemberCaller1<ConnectEntities, const char*, &ConnectEntities::connect> ConnectCaller;
+typedef MemberCaller<ConnectEntities, void(const char*), &ConnectEntities::connect> ConnectCaller;
};
inline Entity* ScenePath_getEntity( const scene::Path& path ){
void setLightRadii( bool lightRadii ){
g_lightRadii = lightRadii;
}
-bool getLightRadii(){
+bool getLightRadii() const {
return g_lightRadii;
}
void setShowNames( bool showNames ){
Static<KeyIsName>::instance().m_nameKey = "targetname";
}
- GlobalPreferenceSystem().registerPreference( "SI_ShowNames", BoolImportStringCaller( g_showNames ), BoolExportStringCaller( g_showNames ) );
- GlobalPreferenceSystem().registerPreference( "SI_ShowAngles", BoolImportStringCaller( g_showAngles ), BoolExportStringCaller( g_showAngles ) );
- GlobalPreferenceSystem().registerPreference( "NewLightStyle", BoolImportStringCaller( g_newLightDraw ), BoolExportStringCaller( g_newLightDraw ) );
- GlobalPreferenceSystem().registerPreference( "LightRadiuses", BoolImportStringCaller( g_lightRadii ), BoolExportStringCaller( g_lightRadii ) );
+ GlobalPreferenceSystem().registerPreference( "SI_ShowNames", make_property_string( g_showNames ) );
+ GlobalPreferenceSystem().registerPreference( "SI_ShowAngles", make_property_string( g_showAngles ) );
+ GlobalPreferenceSystem().registerPreference( "NewLightStyle", make_property_string( g_newLightDraw ) );
+ GlobalPreferenceSystem().registerPreference( "LightRadiuses", make_property_string( g_lightRadii ) );
Entity_InitFilters();
LightType lightType = LIGHTTYPE_DEFAULT;
void classnameChanged( const char* value ){
updateFiltered();
}
-typedef MemberCaller1<ClassnameFilter, const char*, &ClassnameFilter::classnameChanged> ClassnameChangedCaller;
+typedef MemberCaller<ClassnameFilter, void(const char*), &ClassnameFilter::classnameChanged> ClassnameChangedCaller;
};
#endif
RenderableWireframeAABB m_aabb_wire;
RenderableNamedEntity m_renderName;
-Callback m_transformChanged;
-Callback m_evaluateTransform;
+Callback<void()> m_transformChanged;
+Callback<void()> m_evaluateTransform;
void construct(){
read_aabb( m_aabb_local, m_entity.getEntityClass() );
matrix4_translate_by_vec3( m_transform.localToParent(), m_origin );
m_transformChanged();
}
-typedef MemberCaller<GenericEntity, &GenericEntity::updateTransform> UpdateTransformCaller;
+typedef MemberCaller<GenericEntity, void(), &GenericEntity::updateTransform> UpdateTransformCaller;
void originChanged(){
m_origin = m_originKey.m_origin;
updateTransform();
}
-typedef MemberCaller<GenericEntity, &GenericEntity::originChanged> OriginChangedCaller;
+typedef MemberCaller<GenericEntity, void(), &GenericEntity::originChanged> OriginChangedCaller;
void anglesChanged(){
m_angles = m_anglesKey.m_angles;
updateTransform();
}
-typedef MemberCaller<GenericEntity, &GenericEntity::anglesChanged> AnglesChangedCaller;
+typedef MemberCaller<GenericEntity, void(), &GenericEntity::anglesChanged> AnglesChangedCaller;
public:
-GenericEntity( EntityClass* eclass, scene::Node& node, const Callback& transformChanged, const Callback& evaluateTransform ) :
+GenericEntity( EntityClass* eclass, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& evaluateTransform ) :
m_entity( eclass ),
m_originKey( OriginChangedCaller( *this ) ),
m_origin( ORIGINKEY_IDENTITY ),
m_evaluateTransform( evaluateTransform ){
construct();
}
-GenericEntity( const GenericEntity& other, scene::Node& node, const Callback& transformChanged, const Callback& evaluateTransform ) :
+GenericEntity( const GenericEntity& other, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& evaluateTransform ) :
m_entity( other.m_entity ),
m_originKey( OriginChangedCaller( *this ) ),
m_origin( ORIGINKEY_IDENTITY ),
m_evaluateTransform();
updateTransform();
}
-typedef MemberCaller<GenericEntity, &GenericEntity::transformChanged> TransformChangedCaller;
+typedef MemberCaller<GenericEntity, void(), &GenericEntity::transformChanged> TransformChangedCaller;
};
class GenericEntityInstance :
evaluateTransform();
m_contained.freezeTransform();
}
-typedef MemberCaller<GenericEntityInstance, &GenericEntityInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<GenericEntityInstance, void(), &GenericEntityInstance::applyTransform> ApplyTransformCaller;
};
class GenericEntityNode :
mutable Vector3 m_name_origin;
RenderableNamedEntity m_renderName;
-Callback m_transformChanged;
-Callback m_evaluateTransform;
+Callback<void()> m_transformChanged;
+Callback<void()> m_evaluateTransform;
void construct(){
m_keyObservers.insert( "classname", ClassnameFilter::ClassnameChangedCaller( m_filter ) );
}
public:
-Group( EntityClass* eclass, scene::Node& node, const Callback& transformChanged, const Callback& evaluateTransform ) :
+Group( EntityClass* eclass, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& evaluateTransform ) :
m_entity( eclass ),
m_filter( m_entity, node ),
m_named( m_entity ),
m_evaluateTransform( evaluateTransform ){
construct();
}
-Group( const Group& other, scene::Node& node, const Callback& transformChanged, const Callback& evaluateTransform ) :
+Group( const Group& other, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& evaluateTransform ) :
m_entity( other.m_entity ),
m_filter( m_entity, node ),
m_named( m_entity ),
matrix4_translate_by_vec3( m_transform.localToParent(), m_origin );
m_transformChanged();
}
-typedef MemberCaller<Group, &Group::updateTransform> UpdateTransformCaller;
+typedef MemberCaller<Group, void(), &Group::updateTransform> UpdateTransformCaller;
void originChanged(){
m_origin = m_originKey.m_origin;
updateTransform();
}
-typedef MemberCaller<Group, &Group::originChanged> OriginChangedCaller;
+typedef MemberCaller<Group, void(), &Group::originChanged> OriginChangedCaller;
void translate( const Vector3& translation ){
m_origin = origin_translated( m_origin, translation );
m_evaluateTransform();
updateTransform();
}
-typedef MemberCaller<Group, &Group::transformChanged> TransformChangedCaller;
+typedef MemberCaller<Group, void(), &Group::transformChanged> TransformChangedCaller;
};
#if 0
evaluateTransform();
m_contained.freezeTransform();
}
-typedef MemberCaller<GroupInstance, &GroupInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<GroupInstance, void(), &GroupInstance::applyTransform> ApplyTransformCaller;
};
class GroupNode :
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "keyobservers.h"
m_primaryIntensity = string_read_float( value );
calculateRadii();
}
-typedef MemberCaller1<LightRadii, const char*, &LightRadii::primaryIntensityChanged> PrimaryIntensityChangedCaller;
+typedef MemberCaller<LightRadii, void(const char*), &LightRadii::primaryIntensityChanged> PrimaryIntensityChangedCaller;
void secondaryIntensityChanged( const char* value ){
m_secondaryIntensity = string_read_float( value );
calculateRadii();
}
-typedef MemberCaller1<LightRadii, const char*, &LightRadii::secondaryIntensityChanged> SecondaryIntensityChangedCaller;
+typedef MemberCaller<LightRadii, void(const char*), &LightRadii::secondaryIntensityChanged> SecondaryIntensityChangedCaller;
void scaleChanged( const char* value ){
m_scale = string_read_float( value );
if ( m_scale <= 0.0f ) {
}
calculateRadii();
}
-typedef MemberCaller1<LightRadii, const char*, &LightRadii::scaleChanged> ScaleChangedCaller;
+typedef MemberCaller<LightRadii, void(const char*), &LightRadii::scaleChanged> ScaleChangedCaller;
void fadeChanged( const char* value ){
m_fade = string_read_float( value );
if ( m_fade <= 0.0f ) {
}
calculateRadii();
}
-typedef MemberCaller1<LightRadii, const char*, &LightRadii::fadeChanged> FadeChangedCaller;
+typedef MemberCaller<LightRadii, void(const char*), &LightRadii::fadeChanged> FadeChangedCaller;
void flagsChanged( const char* value ){
m_flags = string_read_int( value );
calculateRadii();
}
-typedef MemberCaller1<LightRadii, const char*, &LightRadii::flagsChanged> FlagsChangedCaller;
+typedef MemberCaller<LightRadii, void(const char*), &LightRadii::flagsChanged> FlagsChangedCaller;
};
class Doom3LightRadius
Vector3 m_radius;
Vector3 m_radiusTransformed;
Vector3 m_center;
-Callback m_changed;
+Callback<void()> m_changed;
bool m_useCenterKey;
Doom3LightRadius( const char* defaultRadius ) : m_defaultRadius( 300, 300, 300 ), m_center( 0, 0, 0 ), m_useCenterKey( false ){
m_changed();
SceneChangeNotify();
}
-typedef MemberCaller1<Doom3LightRadius, const char*, &Doom3LightRadius::lightRadiusChanged> LightRadiusChangedCaller;
+typedef MemberCaller<Doom3LightRadius, void(const char*), &Doom3LightRadius::lightRadiusChanged> LightRadiusChangedCaller;
void lightCenterChanged( const char* value ){
m_useCenterKey = string_parse_vector3( value, m_center );
}
SceneChangeNotify();
}
-typedef MemberCaller1<Doom3LightRadius, const char*, &Doom3LightRadius::lightCenterChanged> LightCenterChangedCaller;
+typedef MemberCaller<Doom3LightRadius, void(const char*), &Doom3LightRadius::lightCenterChanged> LightCenterChangedCaller;
};
class RenderLightRadiiWire : public OpenGLRenderable
points[5] = vector4_projected( matrix4_transformed_vector4( unproject, Vector4( points[5], 1 ) ) );
points[6] = vector4_projected( matrix4_transformed_vector4( unproject, Vector4( points[6], 1 ) ) );
points[7] = vector4_projected( matrix4_transformed_vector4( unproject, Vector4( points[7], 1 ) ) );
- Vector4 test1 = matrix4_transformed_vector4( unproject, Vector4( 0.5f, 0.5f, 0.5f, 1 ) );
- Vector3 test2 = vector4_projected( test1 );
+// Vector4 test1 = matrix4_transformed_vector4( unproject, Vector4( 0.5f, 0.5f, 0.5f, 1 ) );
+// Vector3 test2 = vector4_projected( test1 );
aabb_draw_wire( points );
}
};
}
SceneChangeNotify();
}
-typedef MemberCaller1<LightShader, const char*, &LightShader::valueChanged> ValueChangedCaller;
+typedef MemberCaller<LightShader, void(const char*), &LightShader::valueChanged> ValueChangedCaller;
Shader* get() const {
return m_shader.get();
LightShader m_shader;
-Callback m_transformChanged;
-Callback m_boundsChanged;
-Callback m_evaluateTransform;
+Callback<void()> m_transformChanged;
+Callback<void()> m_boundsChanged;
+Callback<void()> m_evaluateTransform;
void construct(){
default_rotation( m_rotation );
m_aabb_light.origin = m_useLightOrigin ? m_lightOrigin : m_originKey.m_origin;
updateOrigin();
}
-typedef MemberCaller<Light, &Light::originChanged> OriginChangedCaller;
+typedef MemberCaller<Light, void(), &Light::originChanged> OriginChangedCaller;
void lightOriginChanged( const char* value ){
m_useLightOrigin = !string_empty( value );
}
originChanged();
}
-typedef MemberCaller1<Light, const char*, &Light::lightOriginChanged> LightOriginChangedCaller;
+typedef MemberCaller<Light, void(const char*), &Light::lightOriginChanged> LightOriginChangedCaller;
void lightTargetChanged( const char* value ){
m_useLightTarget = !string_empty( value );
}
projectionChanged();
}
-typedef MemberCaller1<Light, const char*, &Light::lightTargetChanged> LightTargetChangedCaller;
+typedef MemberCaller<Light, void(const char*), &Light::lightTargetChanged> LightTargetChangedCaller;
void lightUpChanged( const char* value ){
m_useLightUp = !string_empty( value );
if ( m_useLightUp ) {
}
projectionChanged();
}
-typedef MemberCaller1<Light, const char*, &Light::lightUpChanged> LightUpChangedCaller;
+typedef MemberCaller<Light, void(const char*), &Light::lightUpChanged> LightUpChangedCaller;
void lightRightChanged( const char* value ){
m_useLightRight = !string_empty( value );
if ( m_useLightRight ) {
}
projectionChanged();
}
-typedef MemberCaller1<Light, const char*, &Light::lightRightChanged> LightRightChangedCaller;
+typedef MemberCaller<Light, void(const char*), &Light::lightRightChanged> LightRightChangedCaller;
void lightStartChanged( const char* value ){
m_useLightStart = !string_empty( value );
if ( m_useLightStart ) {
}
projectionChanged();
}
-typedef MemberCaller1<Light, const char*, &Light::lightStartChanged> LightStartChangedCaller;
+typedef MemberCaller<Light, void(const char*), &Light::lightStartChanged> LightStartChangedCaller;
void lightEndChanged( const char* value ){
m_useLightEnd = !string_empty( value );
if ( m_useLightEnd ) {
}
projectionChanged();
}
-typedef MemberCaller1<Light, const char*, &Light::lightEndChanged> LightEndChangedCaller;
+typedef MemberCaller<Light, void(const char*), &Light::lightEndChanged> LightEndChangedCaller;
void writeLightOrigin(){
write_origin( m_lightOrigin, &m_entity, "light_origin" );
rotation_assign( m_rotation, m_useLightRotation ? m_lightRotation : m_rotationKey.m_rotation );
GlobalSelectionSystem().pivotChanged();
}
-typedef MemberCaller<Light, &Light::rotationChanged> RotationChangedCaller;
+typedef MemberCaller<Light, void(), &Light::rotationChanged> RotationChangedCaller;
void lightRotationChanged( const char* value ){
m_useLightRotation = !string_empty( value );
}
rotationChanged();
}
-typedef MemberCaller1<Light, const char*, &Light::lightRotationChanged> LightRotationChangedCaller;
+typedef MemberCaller<Light, void(const char*), &Light::lightRotationChanged> LightRotationChangedCaller;
public:
-Light( EntityClass* eclass, scene::Node& node, const Callback& transformChanged, const Callback& boundsChanged, const Callback& evaluateTransform ) :
+Light( EntityClass* eclass, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& boundsChanged, const Callback<void()>& evaluateTransform ) :
m_entity( eclass ),
m_originKey( OriginChangedCaller( *this ) ),
m_rotationKey( RotationChangedCaller( *this ) ),
- m_colour( Callback() ),
+ m_colour( Callback<void()>() ),
m_filter( m_entity, node ),
m_named( m_entity ),
m_nameKeys( m_entity ),
m_evaluateTransform( evaluateTransform ){
construct();
}
-Light( const Light& other, scene::Node& node, const Callback& transformChanged, const Callback& boundsChanged, const Callback& evaluateTransform ) :
+Light( const Light& other, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& boundsChanged, const Callback<void()>& evaluateTransform ) :
m_entity( other.m_entity ),
m_originKey( OriginChangedCaller( *this ) ),
m_rotationKey( RotationChangedCaller( *this ) ),
- m_colour( Callback() ),
+ m_colour( Callback<void()>() ),
m_filter( m_entity, node ),
m_named( m_entity ),
m_nameKeys( m_entity ),
m_evaluateTransform();
updateOrigin();
}
-typedef MemberCaller<Light, &Light::transformChanged> TransformChangedCaller;
+typedef MemberCaller<Light, void(), &Light::transformChanged> TransformChangedCaller;
mutable Matrix4 m_localPivot;
const Matrix4& getLocalPivot() const {
return m_localPivot;
}
-void setLightChangedCallback( const Callback& callback ){
+void setLightChangedCallback( const Callback<void()>& callback ){
m_doom3Radius.m_changed = callback;
}
StaticRenderableConnectionLines::instance().detach( *this );
if ( g_lightType == LIGHTTYPE_DOOM3 ) {
- m_contained.setLightChangedCallback( Callback() );
+ m_contained.setLightChangedCallback( Callback<void()>() );
GlobalShaderCache().detach( *this );
}
GlobalSelectionSystem().getObserver ( SelectionSystem::eComponent )( selectable );
GlobalSelectionSystem().onComponentSelection( *this, selectable );
}
-typedef MemberCaller1<LightInstance, const Selectable&, &LightInstance::selectedChangedComponent> SelectedChangedComponentCaller;
+typedef MemberCaller<LightInstance, void(const Selectable&), &LightInstance::selectedChangedComponent> SelectedChangedComponentCaller;
void evaluateTransform(){
if ( getType() == TRANSFORM_PRIMITIVE ) {
evaluateTransform();
m_contained.freezeTransform();
}
-typedef MemberCaller<LightInstance, &LightInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<LightInstance, void(), &LightInstance::applyTransform> ApplyTransformCaller;
void lightChanged(){
GlobalShaderCache().changed( *this );
}
-typedef MemberCaller<LightInstance, &LightInstance::lightChanged> LightChangedCaller;
+typedef MemberCaller<LightInstance, void(), &LightInstance::lightChanged> LightChangedCaller;
Shader* getShader() const {
return m_contained.getShader();
namespace scene
{
class Node;
-};
+}
class EntityClass;
scene::Node& New_Light( EntityClass* eclass );
RenderablePivot m_renderOrigin;
RenderableNamedEntity m_renderName;
-Callback m_transformChanged;
-Callback m_evaluateTransform;
+Callback<void()> m_transformChanged;
+Callback<void()> m_evaluateTransform;
void construct(){
m_keyObservers.insert( "classname", ClassnameFilter::ClassnameChangedCaller( m_filter ) );
m_origin = m_originKey.m_origin;
updateTransform();
}
-typedef MemberCaller<MiscModel, &MiscModel::originChanged> OriginChangedCaller;
+typedef MemberCaller<MiscModel, void(), &MiscModel::originChanged> OriginChangedCaller;
void anglesChanged(){
m_angles = m_anglesKey.m_angles;
updateTransform();
}
-typedef MemberCaller<MiscModel, &MiscModel::anglesChanged> AnglesChangedCaller;
+typedef MemberCaller<MiscModel, void(), &MiscModel::anglesChanged> AnglesChangedCaller;
void scaleChanged(){
m_scale = m_scaleKey.m_scale;
updateTransform();
}
-typedef MemberCaller<MiscModel, &MiscModel::scaleChanged> ScaleChangedCaller;
+typedef MemberCaller<MiscModel, void(), &MiscModel::scaleChanged> ScaleChangedCaller;
public:
-MiscModel( EntityClass* eclass, scene::Node& node, const Callback& transformChanged, const Callback& evaluateTransform ) :
+MiscModel( EntityClass* eclass, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& evaluateTransform ) :
m_entity( eclass ),
m_originKey( OriginChangedCaller( *this ) ),
m_origin( ORIGINKEY_IDENTITY ),
m_evaluateTransform( evaluateTransform ){
construct();
}
-MiscModel( const MiscModel& other, scene::Node& node, const Callback& transformChanged, const Callback& evaluateTransform ) :
+MiscModel( const MiscModel& other, scene::Node& node, const Callback<void()>& transformChanged, const Callback<void()>& evaluateTransform ) :
m_entity( other.m_entity ),
m_originKey( OriginChangedCaller( *this ) ),
m_origin( ORIGINKEY_IDENTITY ),
m_evaluateTransform();
updateTransform();
}
-typedef MemberCaller<MiscModel, &MiscModel::transformChanged> TransformChangedCaller;
+typedef MemberCaller<MiscModel, void(), &MiscModel::transformChanged> TransformChangedCaller;
};
class MiscModelInstance : public TargetableInstance, public TransformModifier, public Renderable
evaluateTransform();
m_contained.freezeTransform();
}
-typedef MemberCaller<MiscModelInstance, &MiscModelInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<MiscModelInstance, void(), &MiscModelInstance::applyTransform> ApplyTransformCaller;
};
class MiscModelNode :
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "model.h"
ResourceReference m_resource;
scene::Traversable& m_traverse;
scene::Node* m_node;
-Callback m_modelChanged;
+Callback<void()> m_modelChanged;
public:
-EModel( scene::Traversable& traversable, const Callback& modelChanged )
+EModel( scene::Traversable& traversable, const Callback<void()>& modelChanged )
: m_resource( "" ), m_traverse( traversable ), m_node( 0 ), m_modelChanged( modelChanged ){
m_resource.attach( *this );
}
m_resource.attach( *this );
m_modelChanged();
}
-typedef MemberCaller1<EModel, const char*, &EModel::modelChanged> ModelChangedCaller;
+typedef MemberCaller<EModel, void(const char*), &EModel::modelChanged> ModelChangedCaller;
const char* getName() const {
return m_resource.getName();
EModel m_model;
public:
SingletonModel()
- : m_model( m_traverse, Callback() ){
+ : m_model( m_traverse, Callback<void()>() ){
}
void attach( scene::Traversable::Observer* observer ){
void modelChanged( const char* value ){
m_model.modelChanged( value );
}
-typedef MemberCaller1<SingletonModel, const char*, &SingletonModel::modelChanged> ModelChangedCaller;
+typedef MemberCaller<SingletonModel, void(const char*), &SingletonModel::modelChanged> ModelChangedCaller;
scene::Node* getNode() const {
return m_model.getNode();
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "modelskinkey.h"
{
CopiedString m_name;
ModelSkin* m_skin;
-Callback m_skinChangedCallback;
+Callback<void()> m_skinChangedCallback;
ModelSkinKey( const ModelSkinKey& );
ModelSkinKey operator=( const ModelSkinKey& );
}
public:
-ModelSkinKey( const Callback& skinChangedCallback ) : m_skinChangedCallback( skinChangedCallback ){
+ModelSkinKey( const Callback<void()>& skinChangedCallback ) : m_skinChangedCallback( skinChangedCallback ){
construct();
}
~ModelSkinKey(){
parseTextureName( m_name, value );
construct();
}
-typedef MemberCaller1<ModelSkinKey, const char*, &ModelSkinKey::skinChanged> SkinChangedCaller;
+typedef MemberCaller<ModelSkinKey, void(const char*), &ModelSkinKey::skinChanged> SkinChangedCaller;
void realise(){
m_skinChangedCallback();
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "namedentity.h"
}
m_name = value;
}
-typedef MemberCaller1<NamedEntity, const char*, &NamedEntity::identifierChanged> IdentifierChangedCaller;
+typedef MemberCaller<NamedEntity, void(const char*), &NamedEntity::identifierChanged> IdentifierChangedCaller;
};
class RenderableNamedEntity : public OpenGLRenderable
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "namekeys.h"
};
-typedef MemberCaller1<EntityKeyValue, const char*, &EntityKeyValue::assign> KeyValueAssignCaller;
-typedef MemberCaller1<EntityKeyValue, const KeyObserver&, &EntityKeyValue::attach> KeyValueAttachCaller;
-typedef MemberCaller1<EntityKeyValue, const KeyObserver&, &EntityKeyValue::detach> KeyValueDetachCaller;
+typedef MemberCaller<EntityKeyValue, void(const char*), &EntityKeyValue::assign> KeyValueAssignCaller;
+typedef MemberCaller<EntityKeyValue, void(const KeyObserver&), &EntityKeyValue::attach> KeyValueAttachCaller;
+typedef MemberCaller<EntityKeyValue, void(const KeyObserver&), &EntityKeyValue::detach> KeyValueDetachCaller;
class NameKeys : public Entity::Observer, public Namespaced
{
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "origin.h"
class OriginKey
{
-Callback m_originChanged;
+Callback<void()> m_originChanged;
public:
Vector3 m_origin;
-OriginKey( const Callback& originChanged )
+OriginKey( const Callback<void()>& originChanged )
: m_originChanged( originChanged ), m_origin( ORIGINKEY_IDENTITY ){
}
read_origin( m_origin, value );
m_originChanged();
}
-typedef MemberCaller1<OriginKey, const char*, &OriginKey::originChanged> OriginChangedCaller;
+typedef MemberCaller<OriginKey, void(const char*), &OriginKey::originChanged> OriginChangedCaller;
void write( Entity* entity ) const {
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
#include "debugging/debugging.h"
#include "iscenegraph.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; 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
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "rotation.h"
class RotationKey
{
-Callback m_rotationChanged;
+Callback<void()> m_rotationChanged;
public:
Float9 m_rotation;
-RotationKey( const Callback& rotationChanged )
+RotationKey( const Callback<void()>& rotationChanged )
: m_rotationChanged( rotationChanged ){
default_rotation( m_rotation );
}
read_angle( m_rotation, value );
m_rotationChanged();
}
-typedef MemberCaller1<RotationKey, const char*, &RotationKey::angleChanged> AngleChangedCaller;
+typedef MemberCaller<RotationKey, void(const char*), &RotationKey::angleChanged> AngleChangedCaller;
void rotationChanged( const char* value ){
read_rotation( m_rotation, value );
m_rotationChanged();
}
-typedef MemberCaller1<RotationKey, const char*, &RotationKey::rotationChanged> RotationChangedCaller;
+typedef MemberCaller<RotationKey, void(const char*), &RotationKey::rotationChanged> RotationChangedCaller;
void write( Entity* entity ) const {
Vector3 euler = matrix4_get_rotation_euler_xyz_degrees( rotation_toMatrix( m_rotation ) );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "scale.h"
class ScaleKey
{
-Callback m_scaleChanged;
+Callback<void()> m_scaleChanged;
public:
Vector3 m_scale;
-ScaleKey( const Callback& scaleChanged )
+ScaleKey( const Callback<void()>& scaleChanged )
: m_scaleChanged( scaleChanged ), m_scale( SCALEKEY_IDENTITY ){
}
read_scale( m_scale, value );
m_scaleChanged();
}
-typedef MemberCaller1<ScaleKey, const char*, &ScaleKey::uniformScaleChanged> UniformScaleChangedCaller;
+typedef MemberCaller<ScaleKey, void(const char*), &ScaleKey::uniformScaleChanged> UniformScaleChangedCaller;
void scaleChanged( const char* value ){
read_scalevec( m_scale, value );
m_scaleChanged();
}
-typedef MemberCaller1<ScaleKey, const char*, &ScaleKey::scaleChanged> ScaleChangedCaller;
+typedef MemberCaller<ScaleKey, void(const char*), &ScaleKey::scaleChanged> ScaleChangedCaller;
void write( Entity* entity ) const {
write_scale( m_scale, entity );
}
}
-typedef MemberCaller1<GlobalSkins, const char*, &GlobalSkins::parseFile> ParseFileCaller;
+typedef MemberCaller<GlobalSkins, void(const char*), &GlobalSkins::parseFile> ParseFileCaller;
void construct(){
GlobalFileSystem().forEachFile( "skins/", "skin", ParseFileCaller( *this ) );
m_targets = getTargetables( name );
construct();
}
-typedef MemberCaller1<TargetedEntity, const char*, &TargetedEntity::targetnameChanged> TargetnameChangedCaller;
+typedef MemberCaller<TargetedEntity, void(const char*), &TargetedEntity::targetnameChanged> TargetnameChangedCaller;
};
void targetChanged( const char* target ){
m_targets = getTargetables( target );
}
-typedef MemberCaller1<TargetingEntity, const char*, &TargetingEntity::targetChanged> TargetChangedCaller;
+typedef MemberCaller<TargetingEntity, void(const char*), &TargetingEntity::targetChanged> TargetChangedCaller;
typedef targetables_t::iterator iterator;
class TargetKeys : public Entity::Observer
{
TargetingEntities m_targetingEntities;
-Callback m_targetsChanged;
+Callback<void()> m_targetsChanged;
bool readTargetKey( const char* key, std::size_t& index ){
if ( string_equal_n( key, "target", 6 ) ) {
return false;
}
public:
-void setTargetsChanged( const Callback& targetsChanged ){
+void setTargetsChanged( const Callback<void()>& targetsChanged ){
m_targetsChanged = targetsChanged;
}
void targetsChanged(){
m_entity.detach( *this );
}
-void setTargetsChanged( const Callback& targetsChanged ){
+void setTargetsChanged( const Callback<void()>& targetsChanged ){
m_targeting.setTargetsChanged( targetsChanged );
}
void targetsChanged(){
--- /dev/null
+radiant_plugin(image
+ bmp.cpp bmp.h
+ dds.cpp dds.h
+ image.cpp
+ jpeg.cpp jpeg.h
+ ktx.cpp ktx.h
+ pcx.cpp pcx.h
+ tga.cpp tga.h
+ )
+
+find_package(JPEG REQUIRED)
+target_include_directories(image PRIVATE ${JPEG_INCLUDE_DIR})
+target_link_libraries(image PRIVATE ddslib etclib ${JPEG_LIBRARIES})
+target_compile_options(image PRIVATE -fexceptions)
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "image.h"
-
#include "ifilesystem.h"
#include "iimage.h"
#include "bmp.h"
#include "pcx.h"
#include "dds.h"
+#include "ktx.h"
#include "modulesystem/singletonmodule.h"
ImageDDSModule g_ImageDDSModule;
+class ImageKTXAPI
+{
+_QERPlugImageTable m_imagektx;
+public:
+typedef _QERPlugImageTable Type;
+STRING_CONSTANT( Name, "ktx" );
+
+ImageKTXAPI(){
+ m_imagektx.loadImage = LoadKTX;
+}
+_QERPlugImageTable* getTable(){
+ return &m_imagektx;
+}
+};
+
+typedef SingletonModule<ImageKTXAPI, ImageDependencies> ImageKTXModule;
+
+ImageKTXModule g_ImageKTXModule;
+
+
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
initialiseModule( server );
g_ImageBMPModule.selfRegister();
g_ImagePCXModule.selfRegister();
g_ImageDDSModule.selfRegister();
+ g_ImageKTXModule.selfRegister();
}
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#if !defined( INCLUDED_IMAGE_H )
-#define INCLUDED_IMAGE_H
-
-#endif
typedef my_source_mgr * my_src_ptr;
-#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */
+const int INPUT_BUF_SIZE = 4096; /* choose an efficiently fread'able size */
/*
//!\todo fix jpeglib, it leaves alpha channel uninitialised
#if 1
+ (void) iAlp;
*oAlp = 255;
#else
*oAlp = iAlp;
--- /dev/null
+/*
+ Copyright (C) 2015, SiPlus, Chasseur de bots.
+ All Rights Reserved.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "ktx.h"
+
+#include <string.h>
+
+#include "bytestreamutils.h"
+#include "etclib.h"
+#include "ifilesystem.h"
+#include "imagelib.h"
+
+
+const int KTX_TYPE_UNSIGNED_BYTE = 0x1401;
+const int KTX_TYPE_UNSIGNED_SHORT_4_4_4_4 = 0x8033;
+const int KTX_TYPE_UNSIGNED_SHORT_5_5_5_1 = 0x8034;
+const int KTX_TYPE_UNSIGNED_SHORT_5_6_5 = 0x8363;
+
+const int KTX_FORMAT_ALPHA = 0x1906;
+const int KTX_FORMAT_RGB = 0x1907;
+const int KTX_FORMAT_RGBA = 0x1908;
+const int KTX_FORMAT_LUMINANCE = 0x1909;
+const int KTX_FORMAT_LUMINANCE_ALPHA = 0x190A;
+const int KTX_FORMAT_BGR = 0x80E0;
+const int KTX_FORMAT_BGRA = 0x80E1;
+
+const int KTX_FORMAT_ETC1_RGB8 = 0x8D64;
+
+class KTX_Decoder
+{
+public:
+ virtual ~KTX_Decoder() = default;
+ virtual void Decode( PointerInputStream& istream, byte* out ) = 0;
+ virtual unsigned int GetPixelSize() = 0;
+};
+
+class KTX_Decoder_A8 : public KTX_Decoder
+{
+public:
+ virtual void Decode( PointerInputStream& istream, byte* out ){
+ out[0] = out[1] = out[2] = 0;
+ out[3] = istream_read_byte( istream );
+ }
+ virtual unsigned int GetPixelSize(){
+ return 1;
+ }
+};
+
+class KTX_Decoder_RGB8 : public KTX_Decoder
+{
+public:
+ virtual void Decode( PointerInputStream& istream, byte* out ){
+ istream.read( out, 3 );
+ out[3] = 255;
+ }
+ virtual unsigned int GetPixelSize(){
+ return 3;
+ }
+};
+
+class KTX_Decoder_RGBA8 : public KTX_Decoder
+{
+public:
+ virtual void Decode( PointerInputStream& istream, byte* out ){
+ istream.read( out, 4 );
+ }
+ virtual unsigned int GetPixelSize(){
+ return 4;
+ }
+};
+
+class KTX_Decoder_L8 : public KTX_Decoder
+{
+public:
+ virtual void Decode( PointerInputStream& istream, byte* out ){
+ byte l = istream_read_byte( istream );
+ out[0] = out[1] = out[2] = l;
+ out[3] = 255;
+ }
+ virtual unsigned int GetPixelSize(){
+ return 1;
+ }
+};
+
+class KTX_Decoder_LA8 : public KTX_Decoder
+{
+public:
+ virtual void Decode( PointerInputStream& istream, byte* out ){
+ byte la[2];
+ istream.read( la, 2 );
+ out[0] = out[1] = out[2] = la[0];
+ out[3] = la[1];
+ }
+ virtual unsigned int GetPixelSize(){
+ return 2;
+ }
+};
+
+class KTX_Decoder_BGR8 : public KTX_Decoder
+{
+public:
+ virtual void Decode( PointerInputStream& istream, byte* out ){
+ byte bgr[3];
+ istream.read( bgr, 3 );
+ out[0] = bgr[2];
+ out[1] = bgr[1];
+ out[2] = bgr[0];
+ out[3] = 255;
+ }
+ virtual unsigned int GetPixelSize(){
+ return 3;
+ }
+};
+
+class KTX_Decoder_BGRA8 : public KTX_Decoder
+{
+public:
+ virtual void Decode( PointerInputStream& istream, byte* out ){
+ byte bgra[4];
+ istream.read( bgra, 4 );
+ out[0] = bgra[2];
+ out[1] = bgra[1];
+ out[2] = bgra[0];
+ out[3] = bgra[3];
+ }
+ virtual unsigned int GetPixelSize(){
+ return 4;
+ }
+};
+
+class KTX_Decoder_RGBA4 : public KTX_Decoder
+{
+protected:
+ bool m_bigEndian;
+public:
+ KTX_Decoder_RGBA4( bool bigEndian ) : m_bigEndian( bigEndian ){}
+ virtual void Decode( PointerInputStream& istream, byte* out ){
+ uint16_t rgba;
+ if ( m_bigEndian ) {
+ rgba = istream_read_uint16_be( istream );
+ }
+ else {
+ rgba = istream_read_uint16_le( istream );
+ }
+ int r = ( rgba >> 12 ) & 0xf;
+ int g = ( rgba >> 8 ) & 0xf;
+ int b = ( rgba >> 4 ) & 0xf;
+ int a = rgba & 0xf;
+ out[0] = ( r << 4 ) | r;
+ out[1] = ( g << 4 ) | g;
+ out[2] = ( b << 4 ) | b;
+ out[3] = ( a << 4 ) | a;
+ }
+ virtual unsigned int GetPixelSize(){
+ return 2;
+ }
+};
+
+class KTX_Decoder_RGBA5 : public KTX_Decoder
+{
+protected:
+ bool m_bigEndian;
+public:
+ KTX_Decoder_RGBA5( bool bigEndian ) : m_bigEndian( bigEndian ){}
+ virtual void Decode( PointerInputStream& istream, byte* out ){
+ uint16_t rgba;
+ if ( m_bigEndian ) {
+ rgba = istream_read_uint16_be( istream );
+ }
+ else {
+ rgba = istream_read_uint16_le( istream );
+ }
+ int r = ( rgba >> 11 ) & 0x1f;
+ int g = ( rgba >> 6 ) & 0x1f;
+ int b = ( rgba >> 1 ) & 0x1f;
+ out[0] = ( r << 3 ) | ( r >> 2 );
+ out[1] = ( g << 3 ) | ( g >> 2 );
+ out[2] = ( b << 3 ) | ( b >> 2 );
+ out[3] = ( rgba & 1 ) * 255;
+ }
+ virtual unsigned int GetPixelSize(){
+ return 2;
+ }
+};
+
+class KTX_Decoder_RGB5 : public KTX_Decoder
+{
+protected:
+ bool m_bigEndian;
+public:
+ KTX_Decoder_RGB5( bool bigEndian ) : m_bigEndian( bigEndian ){}
+ virtual void Decode( PointerInputStream& istream, byte* out ){
+ uint16_t rgb;
+ if ( m_bigEndian ) {
+ rgb = istream_read_uint16_be( istream );
+ }
+ else {
+ rgb = istream_read_uint16_le( istream );
+ }
+ int r = ( rgb >> 11 ) & 0x1f;
+ int g = ( rgb >> 5 ) & 0x3f;
+ int b = rgb & 0x1f;
+ out[0] = ( r << 3 ) | ( r >> 2 );
+ out[1] = ( g << 2 ) | ( g >> 4 );
+ out[2] = ( b << 3 ) | ( b >> 2 );
+ out[3] = 255;
+ }
+ virtual unsigned int GetPixelSize(){
+ return 2;
+ }
+};
+
+static void KTX_DecodeETC1( PointerInputStream& istream, Image& image ){
+ unsigned int width = image.getWidth(), height = image.getHeight();
+ unsigned int stride = width * 4;
+ byte* pixbuf = image.getRGBAPixels();
+ byte etc[8], rgba[64];
+
+ for ( unsigned int y = 0; y < height; y += 4, pixbuf += stride * 4 )
+ {
+ unsigned int blockrows = height - y;
+ if ( blockrows > 4 ) {
+ blockrows = 4;
+ }
+
+ byte* p = pixbuf;
+ for ( unsigned int x = 0; x < width; x += 4, p += 16 )
+ {
+ istream.read( etc, 8 );
+ ETC_DecodeETC1Block( etc, rgba, qtrue );
+
+ unsigned int blockrowsize = width - x;
+ if ( blockrowsize > 4 ) {
+ blockrowsize = 4;
+ }
+ blockrowsize *= 4;
+ for ( unsigned int blockrow = 0; blockrow < blockrows; blockrow++ )
+ {
+ memcpy( p + blockrow * stride, rgba + blockrow * 16, blockrowsize );
+ }
+ }
+ }
+}
+
+Image* LoadKTXBuff( PointerInputStream& istream ){
+ byte identifier[12];
+ istream.read( identifier, 12 );
+ if ( memcmp( identifier, "\xABKTX 11\xBB\r\n\x1A\n", 12 ) ) {
+ globalErrorStream() << "LoadKTX: Image has the wrong identifier\n";
+ return 0;
+ }
+
+ bool bigEndian = ( istream_read_uint32_le( istream ) == 0x01020304 );
+
+ unsigned int type;
+ if ( bigEndian ) {
+ type = istream_read_uint32_be( istream );
+ }
+ else {
+ type = istream_read_uint32_le( istream );
+ }
+
+ // For compressed textures, the format is in glInternalFormat.
+ // For uncompressed textures, it's in glBaseInternalFormat.
+ istream.seek( ( type ? 3 : 2 ) * sizeof( uint32_t ) );
+ unsigned int format;
+ if ( bigEndian ) {
+ format = istream_read_uint32_be( istream );
+ }
+ else {
+ format = istream_read_uint32_le( istream );
+ }
+ if ( !type ) {
+ istream.seek( sizeof( uint32_t ) );
+ }
+
+ unsigned int width, height;
+ if ( bigEndian ) {
+ width = istream_read_uint32_be( istream );
+ height = istream_read_uint32_be( istream );
+ }
+ else {
+ width = istream_read_uint32_le( istream );
+ height = istream_read_uint32_le( istream );
+ }
+ if ( !width ) {
+ globalErrorStream() << "LoadKTX: Image has zero width\n";
+ return 0;
+ }
+ if ( !height ) {
+ height = 1;
+ }
+
+ // Skip the key/values and load the first 2D image in the texture.
+ // Since KTXorientation is only a hint and has no effect on the texture data and coordinates, it must be ignored.
+ istream.seek( 4 * sizeof( uint32_t ) );
+ unsigned int bytesOfKeyValueData;
+ if ( bigEndian ) {
+ bytesOfKeyValueData = istream_read_uint32_be( istream );
+ }
+ else {
+ bytesOfKeyValueData = istream_read_uint32_le( istream );
+ }
+ istream.seek( bytesOfKeyValueData + sizeof( uint32_t ) );
+
+ RGBAImage* image = new RGBAImage( width, height );
+
+ if ( type ) {
+ KTX_Decoder* decoder = NULL;
+ switch ( type )
+ {
+ case KTX_TYPE_UNSIGNED_BYTE:
+ switch ( format )
+ {
+ case KTX_FORMAT_ALPHA:
+ decoder = new KTX_Decoder_A8();
+ break;
+ case KTX_FORMAT_RGB:
+ decoder = new KTX_Decoder_RGB8();
+ break;
+ case KTX_FORMAT_RGBA:
+ decoder = new KTX_Decoder_RGBA8();
+ break;
+ case KTX_FORMAT_LUMINANCE:
+ decoder = new KTX_Decoder_L8();
+ break;
+ case KTX_FORMAT_LUMINANCE_ALPHA:
+ decoder = new KTX_Decoder_LA8();
+ break;
+ case KTX_FORMAT_BGR:
+ decoder = new KTX_Decoder_BGR8();
+ break;
+ case KTX_FORMAT_BGRA:
+ decoder = new KTX_Decoder_BGRA8();
+ break;
+ }
+ break;
+ case KTX_TYPE_UNSIGNED_SHORT_4_4_4_4:
+ if ( format == KTX_FORMAT_RGBA ) {
+ decoder = new KTX_Decoder_RGBA4( bigEndian );
+ }
+ break;
+ case KTX_TYPE_UNSIGNED_SHORT_5_5_5_1:
+ if ( format == KTX_FORMAT_RGBA ) {
+ decoder = new KTX_Decoder_RGBA5( bigEndian );
+ }
+ break;
+ case KTX_TYPE_UNSIGNED_SHORT_5_6_5:
+ if ( format == KTX_FORMAT_RGB ) {
+ decoder = new KTX_Decoder_RGB5( bigEndian );
+ }
+ break;
+ }
+
+ if ( !decoder ) {
+ globalErrorStream() << "LoadKTX: Image has an unsupported pixel type " << type << " or format " << format << "\n";
+ image->release();
+ return 0;
+ }
+
+ unsigned int inRowLength = width * decoder->GetPixelSize();
+ unsigned int inPadding = ( ( inRowLength + 3 ) & ~3 ) - inRowLength;
+ byte* out = image->getRGBAPixels();
+ for ( unsigned int y = 0; y < height; y++ )
+ {
+ for ( unsigned int x = 0; x < width; x++, out += 4 )
+ {
+ decoder->Decode( istream, out );
+ }
+
+ if ( inPadding ) {
+ istream.seek( inPadding );
+ }
+ }
+
+ delete decoder;
+ }
+ else {
+ switch ( format )
+ {
+ case KTX_FORMAT_ETC1_RGB8:
+ KTX_DecodeETC1( istream, *image );
+ break;
+ default:
+ globalErrorStream() << "LoadKTX: Image has an unsupported compressed format " << format << "\n";
+ image->release();
+ return 0;
+ }
+ }
+
+ return image;
+}
+
+Image* LoadKTX( ArchiveFile& file ){
+ ScopedArchiveBuffer buffer( file );
+ PointerInputStream istream( buffer.buffer );
+ return LoadKTXBuff( istream );
+}
--- /dev/null
+/*
+ Copyright (C) 2015, SiPlus, Chasseur de bots.
+ All Rights Reserved.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined( INCLUDED_KTX_H )
+#define INCLUDED_KTX_H
+
+class Image;
+class ArchiveFile;
+
+Image* LoadKTX( ArchiveFile& file );
+
+#endif
--- /dev/null
+radiant_plugin(imagecrn
+ imagecrn.cpp
+ crn.cpp crn.h
+ )
+
+target_include_directories(imagecrn PRIVATE ${CMAKE_SOURCE_DIR}/libs/crnrgba)
+target_link_libraries(imagecrn PRIVATE crnrgba)
--- /dev/null
+/*
+ Copyright (C) 2018, Unvanquished Developers
+ All Rights Reserved.
+
+ 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 "crn.h"
+
+#include <stdlib.h>
+
+#include "ifilesystem.h"
+#include "iarchive.h"
+#include "idatastream.h"
+
+#include "crn_rgba.h"
+#include "ddslib.h"
+#include "imagelib.h"
+
+Image *LoadCRNBuff(const byte *buffer, int length)
+{
+ int width, height;
+ if (!GetCRNImageSize(buffer, length, &width, &height)) {
+ globalErrorStream() << "ERROR: Error getting crn imag dimensions.\n";
+ return nullptr;
+ }
+ RGBAImage *image = new RGBAImage(width, height);
+ if (!ConvertCRNtoRGBA(buffer, length, width * height, image->getRGBAPixels())) {
+ globalErrorStream() << "ERROR: Error decoding crn image.\n";
+ image->release();
+ return nullptr;
+ }
+ return image;
+}
+
+Image *LoadCRN(ArchiveFile &file)
+{
+ ScopedArchiveBuffer buffer(file);
+ return LoadCRNBuff(buffer.buffer, buffer.length);
+}
--- /dev/null
+/*
+ Copyright (C) 2018, Unvanquished Developers
+ All Rights Reserved.
+
+ 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_CRN_H )
+#define INCLUDED_CRN_H
+
+class Image;
+
+class ArchiveFile;
+
+Image *LoadCRN(ArchiveFile &file);
+
+#endif
+
--- /dev/null
+/*
+ Copyright (C) 2001-2006, William Joseph.
+ All Rights Reserved.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "ifilesystem.h"
+#include "iimage.h"
+
+#include "crn.h"
+
+
+#include "modulesystem/singletonmodule.h"
+
+class ImageDependencies : public GlobalFileSystemModuleRef {
+};
+
+class ImageCRNAPI {
+ _QERPlugImageTable m_imagecrn;
+public:
+ typedef _QERPlugImageTable Type;
+
+ STRING_CONSTANT(Name, "crn");
+
+ ImageCRNAPI()
+ {
+ m_imagecrn.loadImage = LoadCRN;
+ }
+
+ _QERPlugImageTable *getTable()
+ {
+ return &m_imagecrn;
+ }
+};
+
+typedef SingletonModule<ImageCRNAPI, ImageDependencies> ImageCRNModule;
+
+ImageCRNModule g_ImageCRNModule;
+
+
+extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server)
+{
+ initialiseModule(server);
+
+ g_ImageCRNModule.selfRegister();
+}
--- /dev/null
+; imagepng.def : Declares the module parameters for the DLL.
+
+LIBRARY "IMAGECRN"
+
+EXPORTS
+ ; Explicit exports can go here
+ Radiant_RegisterModules @1
--- /dev/null
+radiant_plugin(imagehl
+ hlw.cpp hlw.h
+ imagehl.cpp
+ mip.cpp mip.h
+ sprite.cpp sprite.h
+ )
Image* LoadHLWBuff( byte* buffer ){
byte *buf_p;
unsigned long mipdatasize;
- int columns, rows, numPixels;
+ int columns, rows;
byte *pixbuf;
int row, column;
byte *palette;
columns = lpMip->width;
rows = lpMip->height;
- numPixels = columns * rows;
RGBAImage* image = new RGBAImage( columns, rows );
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "imagehl.h"
-
#include "debugging/debugging.h"
#include "ifilesystem.h"
#include "iimage.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#if !defined( INCLUDED_IMAGEHL_H )
-#define INCLUDED_IMAGEHL_H
-
-#endif
Image* LoadMIPBuff( byte* buffer ){
byte *buf_p;
int palettelength;
- unsigned long mipdatasize;
int columns, rows, numPixels;
byte *pixbuf;
int i;
return 0;
}
- mipdatasize = GET_MIP_DATA_SIZE( columns, rows );
+// unsigned long mipdatasize = GET_MIP_DATA_SIZE( columns, rows );
palettelength = vfsLoadFile( "gfx/palette.lmp", (void **) &loadedpalette );
if ( palettelength == 768 ) {
} dpalette_t;
*/
-#define IDSPRITEHEADER ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' )
+const int IDSPRITEHEADER = ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' );
// little-endian "IDSP"
/*
Image* LoadIDSPBuff( byte *buffer ){
byte *buf_p;
- int columns, rows, numPixels;
+ int columns, rows;
byte *pixbuf;
int row, column;
// palette = buffer+mipdatasize+2;
// buf_p = buffer+lpMip->offsets[0];
- numPixels = columns * rows;
-
RGBAImage* image = new RGBAImage( columns, rows );
#ifdef DEBUG
--- /dev/null
+radiant_plugin(imagepng
+ plugin.cpp
+ )
+
+find_package(PNG REQUIRED)
+target_include_directories(imagepng PRIVATE ${PNG_INCLUDE_DIR})
+target_link_libraries(imagepng PRIVATE ${PNG_LIBRARIES})
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
#include "debugging/debugging.h"
#include "ifilesystem.h"
_QERPlugImageTable m_imagepng;
public:
typedef _QERPlugImageTable Type;
+
STRING_CONSTANT( Name, "png" );
ImagePNGAPI(){
m_imagepng.loadImage = LoadPNG;
}
+
_QERPlugImageTable* getTable(){
return &m_imagepng;
}
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; 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
--- /dev/null
+radiant_plugin(imageq2
+ imageq2.cpp
+ wal.cpp wal.h
+ wal32.cpp wal32.h
+ )
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "imageq2.h"
-
#include "debugging/debugging.h"
#include "ifilesystem.h"
#include "iimage.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#if !defined( INCLUDED_IMAGEQ2_H )
-#define INCLUDED_IMAGEQ2_H
-
-#endif
#include "bytestreamutils.h"
#include "imagelib.h"
-#define QUAKE2_WAL 0
-#define HERETIC2_M8 1
+const int QUAKE2_WAL = 0;
+const int HERETIC2_M8 = 1;
typedef unsigned char byte;
--- /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
--- /dev/null
+radiant_plugin(iqmmodel
+ iqm.cpp iqm.h
+ plugin.cpp plugin.h
+ )
--- /dev/null
+/*
+ Copyright (C) 2001-2006, William Joseph.
+ Copyright (C) 2010-2014 COR Entertainment, LLC.
+ All Rights Reserved.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "iqm.h"
+
+#include "ifilesystem.h"
+#include "imodel.h"
+
+#include "imagelib.h"
+#include "bytestreamutils.h"
+
+#include "../md3model/model.h"
+
+typedef unsigned char byte;
+
+/*
+ ========================================================================
+
+ .IQM triangle model file format
+
+ ========================================================================
+ */
+
+typedef struct {
+ float s;
+ float t;
+} iqmSt_t;
+
+void istream_read_iqmSt( PointerInputStream &inputStream, iqmSt_t &st ){
+ st.s = istream_read_float32_le( inputStream );
+ st.t = istream_read_float32_le( inputStream );
+}
+
+typedef struct {
+ unsigned int indices[3];
+} iqmTriangle_t;
+
+void istream_read_iqmTriangle( PointerInputStream &inputStream, iqmTriangle_t &triangle ){
+ triangle.indices[0] = istream_read_int32_le( inputStream );
+ triangle.indices[1] = istream_read_int32_le( inputStream );
+ triangle.indices[2] = istream_read_int32_le( inputStream );
+}
+
+typedef struct {
+ float v[3];
+} iqmPos_t;
+
+void istream_read_iqmPos( PointerInputStream &inputStream, iqmPos_t &iqmPos ){
+ iqmPos.v[0] = istream_read_float32_le( inputStream );
+ iqmPos.v[1] = istream_read_float32_le( inputStream );
+ iqmPos.v[2] = istream_read_float32_le( inputStream );
+}
+
+const int IQM_POSITION = 0;
+const int IQM_TEXCOORD = 1;
+const int IQM_NORMAL = 2;
+const int IQM_TANGENT = 3;
+const int IQM_BLENDINDEXES = 4;
+const int IQM_BLENDWEIGHTS = 5;
+const int IQM_COLOR = 6;
+const int IQM_CUSTOM = 0x10;
+
+const int IQM_BYTE = 0;
+const int IQM_UBYTE = 1;
+const int IQM_SHORT = 2;
+const int IQM_USHORT = 3;
+const int IQM_INT = 4;
+const int IQM_UINT = 5;
+const int IQM_HALF = 6;
+const int IQM_FLOAT = 7;
+const int IQM_DOUBLE = 8;
+
+// animflags
+const int IQM_LOOP = 1;
+
+typedef struct iqmHeader_s {
+ byte id[16];
+ unsigned int version;
+ unsigned int filesize;
+ unsigned int flags;
+ unsigned int num_text, ofs_text;
+ unsigned int num_meshes, ofs_meshes;
+ unsigned int num_vertexarrays, num_vertexes, ofs_vertexarrays;
+ unsigned int num_triangles, ofs_triangles, ofs_neighbors;
+ unsigned int num_joints, ofs_joints;
+ unsigned int num_poses, ofs_poses;
+ unsigned int num_anims, ofs_anims;
+ unsigned int num_frames, num_framechannels, ofs_frames, ofs_bounds;
+ unsigned int num_comment, ofs_comment;
+ unsigned int num_extensions, ofs_extensions;
+} iqmHeader_t;
+
+void istream_read_iqmHeader( PointerInputStream &inputStream, iqmHeader_t &header ){
+ inputStream.read( header.id, 16 );
+#define READINT( x ) header.x = istream_read_int32_le( inputStream );
+ READINT( version )
+ READINT( filesize )
+ READINT( flags )
+ READINT( num_text )
+ READINT( ofs_text )
+ READINT( num_meshes )
+ READINT( ofs_meshes )
+ READINT( num_vertexarrays )
+ READINT( num_vertexes )
+ READINT( ofs_vertexarrays )
+ READINT( num_triangles )
+ READINT( ofs_triangles )
+ READINT( ofs_neighbors )
+ READINT( num_joints )
+ READINT( ofs_joints )
+ READINT( num_frames )
+ READINT( num_framechannels )
+ READINT( ofs_frames )
+ READINT( ofs_bounds )
+ READINT( num_comment )
+ READINT( ofs_comment )
+ READINT( num_extensions )
+ READINT( ofs_extensions )
+#undef READINT
+}
+
+typedef struct iqmmesh_s {
+ unsigned int name;
+ unsigned int material;
+ unsigned int first_vertex;
+ unsigned int num_vertexes;
+ unsigned int first_triangle;
+ unsigned int num_triangles;
+} iqmmesh_t;
+
+void istream_read_iqmMesh( PointerInputStream &inputStream, iqmmesh_t &iqmmesh ){
+#define READUINT( x ) iqmmesh.x = istream_read_uint32_le( inputStream );
+ READUINT( name )
+ READUINT( material )
+ READUINT( first_vertex )
+ READUINT( num_vertexes )
+ READUINT( first_triangle )
+ READUINT( num_triangles )
+#undef READUINT
+}
+
+typedef struct iqmvertexarray_s {
+ unsigned int type;
+ unsigned int flags;
+ unsigned int format;
+ unsigned int size;
+ unsigned int offset;
+} iqmvertexarray_t;
+
+void istream_read_iqmVertexarray( PointerInputStream &inputStream, iqmvertexarray_t &vertexarray ){
+#define READINT( x ) vertexarray.x = istream_read_int32_le( inputStream );
+ READINT( type )
+ READINT( flags )
+ READINT( format )
+ READINT( size )
+ READINT( offset )
+#undef READINT
+}
+
+ArbitraryMeshVertex IQMVertex_construct( const iqmPos_t *pos, const iqmPos_t *norm, const iqmSt_t *st ){
+ return ArbitraryMeshVertex(
+ Vertex3f( pos->v[0], pos->v[1], pos->v[2] ),
+ Normal3f( norm->v[0], norm->v[1], norm->v[2] ),
+ TexCoord2f( st->s, st->t )
+ );
+}
+
+void IQMSurface_read( Model &model, const byte *buffer, ArchiveFile &file ){
+ iqmHeader_t header;
+ {
+ PointerInputStream inputStream( buffer );
+ istream_read_iqmHeader( inputStream, header );
+ }
+
+ int ofs_position = -1, ofs_st = -1, ofs_normal = -1;
+ PointerInputStream vaStream( buffer + header.ofs_vertexarrays );
+ for ( unsigned int i = 0; i < header.num_vertexarrays; i++ ) {
+ iqmvertexarray_t va;
+ istream_read_iqmVertexarray( vaStream, va );
+
+ switch ( va.type ) {
+ case IQM_POSITION:
+ if ( va.format == IQM_FLOAT && va.size == 3 ) {
+ ofs_position = va.offset;
+ }
+ break;
+ case IQM_TEXCOORD:
+ if ( va.format == IQM_FLOAT && va.size == 2 ) {
+ ofs_st = va.offset;
+ }
+ break;
+ case IQM_NORMAL:
+ if ( va.format == IQM_FLOAT && va.size == 3 ) {
+ ofs_normal = va.offset;
+ }
+ break;
+ }
+ }
+
+ PointerInputStream posStream( buffer + ofs_position );
+ Array<iqmPos_t> iqmPos( header.num_vertexes );
+ for ( Array<iqmPos_t>::iterator i = iqmPos.begin(); i != iqmPos.end(); ++i ) {
+ istream_read_iqmPos( posStream, *i );
+ }
+
+ PointerInputStream normStream( buffer + ofs_normal );
+ Array<iqmPos_t> iqmNorm( header.num_vertexes );
+ for ( Array<iqmPos_t>::iterator i = iqmNorm.begin(); i != iqmNorm.end(); ++i ) {
+ istream_read_iqmPos( normStream, *i );
+ }
+
+ Array<iqmSt_t> iqmSt( header.num_vertexes );
+ PointerInputStream stStream( buffer + ofs_st );
+ for ( Array<iqmSt_t>::iterator i = iqmSt.begin(); i != iqmSt.end(); ++i ) {
+ istream_read_iqmSt( stStream, *i );
+ }
+
+ PointerInputStream iqmMesh( buffer + header.ofs_meshes );
+ for ( unsigned int m = 0; m < header.num_meshes; m++ ) {
+ Surface &surface = model.newSurface();
+
+ iqmmesh_t iqmmesh;
+ istream_read_iqmMesh( iqmMesh, iqmmesh );
+
+ bool material_found = false;
+ // if not malformed data neither missing string
+ if ( iqmmesh.material <= header.num_text && iqmmesh.material > 0 ) {
+ char *material;
+ material = (char*) buffer + header.ofs_text + iqmmesh.material;
+
+ if ( material[0] != '\0' ) {
+ surface.setShader( material );
+ material_found = true;
+ }
+ }
+
+ if ( !material_found ) {
+ // empty string will trigger "textures/shader/notex" on display
+ surface.setShader( "" );
+ }
+
+ UniqueVertexBuffer<ArbitraryMeshVertex> inserter( surface.vertices() );
+ inserter.reserve( iqmmesh.num_vertexes );
+
+ surface.indices().reserve( iqmmesh.num_vertexes );
+
+ unsigned int triangle_offset = header.ofs_triangles + iqmmesh.first_triangle * sizeof( iqmTriangle_t );
+ PointerInputStream triangleStream( buffer + triangle_offset );
+ for ( unsigned int i = 0; i < iqmmesh.num_triangles; ++i ) {
+ iqmTriangle_t triangle;
+ istream_read_iqmTriangle( triangleStream, triangle );
+ for ( int j = 0; j < 3; j++ ) {
+ surface.indices().insert( inserter.insert( IQMVertex_construct(
+ &iqmPos[triangle.indices[j]],
+ &iqmNorm[triangle.indices[j]],
+ &iqmSt[triangle.indices[j]] ) ) );
+ }
+ }
+
+ surface.updateAABB();
+ }
+}
+
+void IQMModel_read( Model &model, const byte *buffer, ArchiveFile &file ){
+ IQMSurface_read( model, buffer, file );
+ model.updateAABB();
+}
+
+scene::Node &IQMModel_new( const byte *buffer, ArchiveFile &file ){
+ ModelNode *modelNode = new ModelNode();
+ IQMModel_read( modelNode->model(), buffer, file );
+ return modelNode->node();
+}
+
+scene::Node &IQMModel_default(){
+ ModelNode *modelNode = new ModelNode();
+ Model_constructNull( modelNode->model() );
+ return modelNode->node();
+}
+
+scene::Node &IQMModel_fromBuffer( unsigned char *buffer, ArchiveFile &file ){
+ if ( memcmp( buffer, "INTERQUAKEMODEL", 16 ) ) {
+ globalErrorStream() << "IQM read error: incorrect ident\n";
+ return IQMModel_default();
+ }
+ else {
+ return IQMModel_new( buffer, file );
+ }
+}
+
+scene::Node &loadIQMModel( ArchiveFile &file ){
+ ScopedArchiveBuffer buffer( file );
+ return IQMModel_fromBuffer( buffer.buffer, file );
+}
--- /dev/null
+/*
+ Copyright (C) 2001-2006, William Joseph.
+ All Rights Reserved.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined( INCLUDED_IQM_H )
+#define INCLUDED_IQM_H
+
+namespace scene { class Node; }
+class ArchiveFile;
+
+scene::Node &loadIQMModel( ArchiveFile &file );
+
+#endif
--- /dev/null
+; modeliqm.def : Declares the module parameters for the DLL.
+
+LIBRARY "MODELIQM"
+
+EXPORTS
+ ; Explicit exports can go here
+ Radiant_RegisterModules @1
--- /dev/null
+/*
+ Copyright (C) 2001-2006, William Joseph.
+ All Rights Reserved.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "plugin.h"
+
+#include "iscenegraph.h"
+#include "irender.h"
+#include "iselection.h"
+#include "iimage.h"
+#include "imodel.h"
+#include "igl.h"
+#include "ifilesystem.h"
+#include "iundo.h"
+#include "ifiletypes.h"
+#include "iscriplib.h"
+
+#include "modulesystem/singletonmodule.h"
+#include "typesystem.h"
+
+#include "iqm.h"
+
+
+class IQMModelLoader : public ModelLoader {
+public:
+scene::Node &loadModel( ArchiveFile &file ){
+ return loadIQMModel( file );
+}
+};
+
+class ModelDependencies :
+ public GlobalFileSystemModuleRef,
+ public GlobalOpenGLModuleRef,
+ public GlobalUndoModuleRef,
+ public GlobalSceneGraphModuleRef,
+ public GlobalShaderCacheModuleRef,
+ public GlobalSelectionModuleRef,
+ public GlobalFiletypesModuleRef {
+};
+
+class ModelIQMAPI : public TypeSystemRef {
+IQMModelLoader m_modeliqm;
+public:
+typedef ModelLoader Type;
+
+STRING_CONSTANT( Name, "iqm" );
+
+ModelIQMAPI(){
+ GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "InterQuake Models", "*.iqm" ) );
+}
+
+ModelLoader *getTable(){
+ return &m_modeliqm;
+}
+};
+
+typedef SingletonModule<ModelIQMAPI, ModelDependencies> ModelIQMModule;
+
+ModelIQMModule g_ModelIQMModule;
+
+extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer &server ){
+ initialiseModule( server );
+
+ g_ModelIQMModule.selfRegister();
+}
--- /dev/null
+/*
+ Copyright (C) 2001-2006, William Joseph.
+ All Rights Reserved.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined( INCLUDED_SAMPLE_H )
+#define INCLUDED_SAMPLE_H
+#endif
--- /dev/null
+radiant_plugin(mapq3
+ parse.cpp parse.h
+ plugin.cpp
+ write.cpp write.h
+ )
+
+target_include_directories(mapq3
+ PRIVATE $<TARGET_PROPERTY:uilib,INTERFACE_INCLUDE_DIRECTORIES>
+)
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
#include "iscriplib.h"
#include "ibrush.h"
#include "ipatch.h"
m_patchDef2Doom3Module( "def2doom3" ),
m_patchDoom3Module( "doom3" ){
}
+
BrushCreator& getBrushDoom3(){
return GlobalBrushModule::getTable();
}
+
PatchCreator& getPatchDoom3(){
return *m_patchDoom3Module.getTable();
}
+
PatchCreator& getPatchDef2Doom3(){
return *m_patchDef2Doom3Module.getTable();
}
MapDoom3Dependencies& m_dependencies;
public:
typedef MapFormat Type;
+
STRING_CONSTANT( Name, "mapdoom3" );
-INTEGER_CONSTANT( MapVersion, 2 );
+
+UINT_CONSTANT( MapVersion, 2 );
MapDoom3API( MapDoom3Dependencies& dependencies ) : m_dependencies( dependencies ){
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "doom3 maps", "*.map" ) );
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "doom3 region", "*.reg" ) );
}
+
MapFormat* getTable(){
return this;
}
Map_Read( root, tokeniser, entityTable, *this );
tokeniser.release();
}
-void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
+
+void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const {
TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter( outputStream );
writer.writeToken( "Version" );
writer.writeInteger( MapVersion() );
writer.nextLine();
- Map_Write( root, traverse, writer, false );
+ Map_Write( root, traverse, writer, false, writeComments );
writer.release();
}
};
MapDoom3Dependencies& m_dependencies;
public:
typedef MapFormat Type;
+
STRING_CONSTANT( Name, "mapquake4" );
-INTEGER_CONSTANT( MapVersion, 3 );
+
+UINT_CONSTANT( MapVersion, 3 );
MapQuake4API( MapDoom3Dependencies& dependencies ) : m_dependencies( dependencies ){
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake4 maps", "*.map" ) );
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake4 region", "*.reg" ) );
}
+
MapFormat* getTable(){
return this;
}
Map_Read( root, tokeniser, entityTable, *this );
tokeniser.release();
}
-void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
+
+void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const {
TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter( outputStream );
writer.writeToken( "Version" );
writer.writeInteger( MapVersion() );
writer.nextLine();
- Map_Write( root, traverse, writer, false );
+ Map_Write( root, traverse, writer, false, writeComments );
writer.release();
}
};
mutable bool detectedFormat;
public:
typedef MapFormat Type;
+
STRING_CONSTANT( Name, "mapq3" );
MapQ3API(){
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake3 region", "*.reg", true, true, true ) );
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake3 compiled maps", "*.bsp", false, true, false ) );
}
+
MapFormat* getTable(){
return this;
}
void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const {
detectedFormat = false;
wrongFormat = false;
- Tokeniser& tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser( inputStream );
+ Tokeniser &tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser( inputStream );
Map_Read( root, tokeniser, entityTable, *this );
tokeniser.release();
}
-void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
+
+void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const {
TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter( outputStream );
- Map_Write( root, traverse, writer, false );
+ Map_Write( root, traverse, writer, false, writeComments );
writer.release();
}
};
{
public:
typedef MapFormat Type;
+
STRING_CONSTANT( Name, "mapq1" );
MapQ1API(){
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake maps", "*.map" ) );
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake region", "*.reg" ) );
}
+
MapFormat* getTable(){
return this;
}
Map_Read( root, tokeniser, entityTable, *this );
tokeniser.release();
}
-void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
+
+void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const {
TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter( outputStream );
- Map_Write( root, traverse, writer, true );
+ Map_Write( root, traverse, writer, true, writeComments );
writer.release();
}
};
{
public:
typedef MapFormat Type;
+
STRING_CONSTANT( Name, "maphl" );
MapHalfLifeAPI(){
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "half-life maps", "*.map" ) );
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "half-life region", "*.reg" ) );
}
+
MapFormat* getTable(){
return this;
}
Tokeniser_unexpectedError( tokeniser, primitive, "#halflife-primitive" );
return g_nullNode;
}
-void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const {
+
+void readGraph( scene::Node &root, TextInputStream &inputStream, EntityCreator &entityTable ) const {
Tokeniser& tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser( inputStream );
Map_Read( root, tokeniser, entityTable, *this );
tokeniser.release();
}
-void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
+
+void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const {
TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter( outputStream );
- Map_Write( root, traverse, writer, true );
+ Map_Write( root, traverse, writer, true, writeComments );
writer.release();
}
};
{
public:
typedef MapFormat Type;
+
STRING_CONSTANT( Name, "mapq2" );
MapQ2API(){
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake2 maps", "*.map" ) );
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "quake2 region", "*.reg" ) );
}
+
MapFormat* getTable(){
return this;
}
Map_Read( root, tokeniser, entityTable, *this );
tokeniser.release();
}
-void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
+
+void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const {
TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter( outputStream );
- Map_Write( root, traverse, writer, true );
+ Map_Write( root, traverse, writer, true, writeComments );
writer.release();
}
};
MapQ2Module g_MapQ2Module;
-
-#define PARSE_ERROR "error parsing VMF"
+const char *PARSE_ERROR = "error parsing VMF";
inline void parseToken( Tokeniser& tokeniser, const char* token ){
ASSERT_MESSAGE( Tokeniser_parseToken( tokeniser, token ), "error parsing vmf: token not found: " << makeQuoted( token ) );
#include "generic/arrayrange.h"
class VMFBlock;
+
typedef ArrayConstRange<VMFBlock> VMFBlockArrayRange;
return m_name;
}
typedef Value* const_iterator;
+
const_iterator begin() const {
return m_children.first;
}
+
const_iterator end() const {
return m_children.last;
}
{
public:
typedef MapFormat Type;
+
STRING_CONSTANT( Name, "mapvmf" );
MapVMFAPI(){
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "vmf maps", "*.vmf" ) );
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "vmf region", "*.reg" ) );
}
+
MapFormat* getTable(){
return this;
}
VMF_Read( root, tokeniser, entityTable );
tokeniser.release();
}
-void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
+
+void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const {
}
};
MapVMFModule g_MapVMFModule;
-
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
initialiseModule( server );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; 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
mutable Stack<bool> m_stack;
TokenWriter& m_writer;
bool m_ignorePatches;
+bool m_writeComments;
public:
-WriteTokensWalker( TokenWriter& writer, bool ignorePatches )
- : m_writer( writer ), m_ignorePatches( ignorePatches ){
+WriteTokensWalker( TokenWriter& writer, bool ignorePatches, bool writeComments )
+ : m_writer( writer ), m_ignorePatches( ignorePatches ), m_writeComments( writeComments ){
}
-bool pre( scene::Node& node ) const {
+
+bool pre( scene::Node &node ) const {
m_stack.push( false );
Entity* entity = Node_getEntity( node );
if ( entity != 0 ) {
- m_writer.writeToken( "//" );
- m_writer.writeToken( "entity" );
- m_writer.writeUnsigned( g_count_entities++ );
- m_writer.nextLine();
+ if ( m_writeComments ) {
+ m_writer.writeToken( "//" );
+ m_writer.writeToken( "entity" );
+ m_writer.writeUnsigned( g_count_entities++ );
+ m_writer.nextLine();
+ }
m_writer.writeToken( "{" );
m_writer.nextLine();
{
MapExporter* exporter = Node_getMapExporter( node );
if ( exporter != 0
- && !( m_ignorePatches && Node_isPatch( node ) ) ) {
- m_writer.writeToken( "//" );
- m_writer.writeToken( "brush" );
- m_writer.writeUnsigned( g_count_brushes++ );
- m_writer.nextLine();
+ && !( m_ignorePatches && Node_isPatch( node ) ) ) {
+ if ( m_writeComments ) {
+ m_writer.writeToken( "//" );
+ m_writer.writeToken( "brush" );
+ m_writer.writeUnsigned( g_count_brushes++ );
+ m_writer.nextLine();
+ }
exporter->exportTokens( m_writer );
}
return true;
}
+
void post( scene::Node& node ) const {
if ( m_stack.top() ) {
m_writer.writeToken( "}" );
}
};
-void Map_Write( scene::Node& root, GraphTraversalFunc traverse, TokenWriter& writer, bool ignorePatches ){
+void Map_Write( scene::Node& root, GraphTraversalFunc traverse, TokenWriter& writer, bool ignorePatches, bool writeComments ){
g_count_entities = 0;
- traverse( root, WriteTokensWalker( writer, ignorePatches ) );
+ traverse( root, WriteTokensWalker( writer, ignorePatches, writeComments ) );
}
#include "imap.h"
-void Map_Write( scene::Node& root, GraphTraversalFunc traverse, TokenWriter& writer, bool ignorePatches );
+void Map_Write( scene::Node& root, GraphTraversalFunc traverse, TokenWriter& writer, bool ignorePatches, bool writeComments );
#endif
--- /dev/null
+radiant_plugin(mapxml
+ plugin.cpp
+ xmlparse.cpp xmlparse.h
+ xmlwrite.cpp xmlwrite.h
+ )
+
+target_include_directories(mapxml PRIVATE xmllib)
+target_link_libraries(mapxml PRIVATE xmllib)
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
#include "ibrush.h"
#include "ipatch.h"
#include "ifiletypes.h"
m_patchDef2Doom3Module( "def2doom3" ),
m_patchDoom3Module( "doom3" ){
}
+
BrushCreator& getBrushDoom3(){
return GlobalBrushModule::getTable();
}
+
PatchCreator& getPatchDoom3(){
return *m_patchDoom3Module.getTable();
}
+
PatchCreator& getPatchDef2Doom3(){
return *m_patchDef2Doom3Module.getTable();
}
{
public:
typedef MapFormat Type;
+
STRING_CONSTANT( Name, "xmldoom3" );
MapXMLAPI(){
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "xml doom3 maps", "*.xmap" ) );
}
+
MapFormat* getTable(){
return this;
}
void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const {
Map_Read( root, inputStream, entityTable );
}
-void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
+
+void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const {
Map_Write( root, traverse, outputStream );
}
};
MapXMLModule g_MapXMLModule;
-
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
GlobalErrorStream::instance().setOutputStream( server.getErrorStream() );
GlobalOutputStream::instance().setOutputStream( server.getOutputStream() );
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; 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
#include "generic/object.h"
-#define PARSE_ERROR "XML PARSE ERROR"
+const char *PARSE_ERROR = "XML PARSE ERROR";
inline XMLImporter* Node_getXMLImporter( scene::Node& node ){
--- /dev/null
+radiant_plugin(md3model
+ ident.h
+ md2.cpp md2.h
+ md3.cpp md3.h
+ md3normals.h
+ md5.cpp md5.h
+ mdc.cpp mdc.h
+ mdl.cpp mdl.h
+ mdlformat.h
+ mdlimage.cpp mdlimage.h
+ mdlnormals.h
+ model.h
+ plugin.cpp
+ )
========================================================================
*/
-#define MD2_NUMVERTEXNORMALS 162
-#define MD2_MAX_SKINNAME 64
+const int MD2_NUMVERTEXNORMALS = 162;
const unsigned char MD2_IDENT[4] = { 'I', 'D', 'P', '2', };
-#define MD2_VERSION 8
+const int MD2_VERSION = 8;
-#define MD2_MAX_TRIANGLES 4096
-#define MD2_MAX_VERTS 2048
-#define MD2_MAX_FRAMES 512
-#define MD2_MAX_MD2SKINS 32
-#define MD2_MAX_SKINNAME 64
+const int MD2_MAX_TRIANGLES = 4096;
+const int MD2_MAX_VERTS = 2048;
+const int MD2_MAX_FRAMES = 512;
+const int MD2_MAX_MD2SKINS = 32;
+const int MD2_MAX_SKINNAME = 64;
typedef struct
{
inputStream.read( &xyz.lightnormalindex, 1 );
}
-#define MD2_XYZNORMAL_V0 0
-#define MD2_XYZNORMAL_V1 1
-#define MD2_XYZNORMAL_V2 2
-#define MD2_XYZNORMAL_LNI 3
-#define MD2_XYZNORMAL_SIZE 4
+const int MD2_XYZNORMAL_V0 = 0;
+const int MD2_XYZNORMAL_V1 = 1;
+const int MD2_XYZNORMAL_V2 = 2;
+const int MD2_XYZNORMAL_LNI = 3;
+const int MD2_XYZNORMAL_SIZE = 4;
typedef struct
{
#include "md3normals.h"
// the maximum size of game reletive pathnames
-#define MAX_QPATH 64
+const int MAX_QPATH = 64;
/*
========================================================================
*/
const unsigned char MD3_IDENT[4] = { 'I', 'D', 'P', '3', };
-#define MD3_VERSION 15
+const int MD3_VERSION = 15;
// limits
-#define MD3_MAX_LODS 4
-#define MD3_MAX_TRIANGLES 8192 // per surface
-#define MD3_MAX_VERTS 4096 // per surface
-#define MD3_MAX_SHADERS 256 // per surface
-#define MD3_MAX_FRAMES 1024 // per model
-#define MD3_MAX_SURFACES 32 // per model
-#define MD3_MAX_TAGS 16 // per frame
+const int MD3_MAX_LODS = 4;
+const int MD3_MAX_TRIANGLES = 8192; // per surface
+const int MD3_MAX_VERTS = 4096; // per surface
+const int MD3_MAX_SHADERS = 256; // per surface
+const int MD3_MAX_FRAMES = 1024; // per model
+const int MD3_MAX_SURFACES = 32; // per model
+const int MD3_MAX_TAGS = 16; // per frame
// vertex scales
-#define MD3_XYZ_SCALE ( 1.f / 64 )
+const float MD3_XYZ_SCALE = ( 1.f / 64 );
typedef float float3[3];
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "md3normals.h"
#include "model.h"
-#define MD5_RETURN_FALSE_IF_FAIL( expression ) if ( !( expression ) ) { globalErrorStream() << "md5 parse failed: " # expression "\n"; return false; } else
+#define MD5_RETURN_FALSE_IF_FAIL(expression) do { if (!(expression)) { globalErrorStream() << "md5 parse failed: " #expression "\n"; return false; } } while (0)
bool MD5_parseToken( Tokeniser& tokeniser, const char* string ){
const char* token = tokeniser.getToken();
const unsigned char MDC_IDENT[4] = { 'I', 'D', 'P', 'C', };
const float MDC_XYZ_SCALE = 0.015625f;
-#define MAX_QPATH 64 // max length of a quake game pathname
+const int MAX_QPATH = 64; // max length of a quake game pathname
typedef float float3[3];
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "mdlformat.h"
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "mdlnormals.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "model.h"
#if !defined( INCLUDED_MODEL_H )
#define INCLUDED_MODEL_H
+#include "globaldefs.h"
#include "cullable.h"
#include "renderable.h"
#include "selectable.h"
glEnd();
#endif
-#if defined( _DEBUG )
+#if GDEF_DEBUG
glBegin( GL_LINES );
for ( VertexBuffer<ArbitraryMeshVertex>::const_iterator i = m_vertices.begin(); i != m_vertices.end(); ++i )
AABB m_aabb_local;
public:
-Callback m_lightsChanged;
+Callback<void()> m_lightsChanged;
~Model(){
for ( surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i )
void lightsChanged(){
m_lightList->lightsChanged();
}
-typedef MemberCaller<ModelInstance, &ModelInstance::lightsChanged> LightsChangedCaller;
+typedef MemberCaller<ModelInstance, void(), &ModelInstance::lightsChanged> LightsChangedCaller;
void constructRemaps(){
ModelSkin* skin = NodeTypeCast<ModelSkin>::cast( path().parent() );
~ModelInstance(){
destroyRemaps();
- Instance::setTransformChangedCallback( Callback() );
+ Instance::setTransformChangedCallback( Callback<void()>() );
- m_model.m_lightsChanged = Callback();
+ m_model.m_lightsChanged = Callback<void()>();
GlobalShaderCache().detach( *this );
}
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
#include "iscenegraph.h"
#include "irender.h"
#include "iselection.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; 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
--- /dev/null
+radiant_plugin(model
+ model.cpp model.h
+ plugin.cpp
+ )
+
+target_include_directories(model PRIVATE picomodel)
+target_link_libraries(model PRIVATE picomodel)
*/
#include "model.h"
+#include "globaldefs.h"
#include "picomodel.h"
glVertexPointer( 3, GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_vertices.data()->vertex );
glDrawElements( GL_TRIANGLES, GLsizei( m_indices.size() ), RenderIndexTypeID, m_indices.data() );
-#if defined( _DEBUG )
+#if GDEF_DEBUG
GLfloat modelview[16];
glGetFloatv( GL_MODELVIEW_MATRIX, modelview ); // I know this is slow as hell, but hey - we're in _DEBUG
Matrix4 modelview_inv(
AABB m_aabb_local;
public:
-Callback m_lightsChanged;
+Callback<void()> m_lightsChanged;
PicoModel(){
constructNull();
void lightsChanged(){
m_lightList->lightsChanged();
}
-typedef MemberCaller<PicoModelInstance, &PicoModelInstance::lightsChanged> LightsChangedCaller;
+typedef MemberCaller<PicoModelInstance, void(), &PicoModelInstance::lightsChanged> LightsChangedCaller;
void constructRemaps(){
ASSERT_MESSAGE( m_skins.size() == m_picomodel.size(), "ERROR" );
~PicoModelInstance(){
destroyRemaps();
- Instance::setTransformChangedCallback( Callback() );
+ Instance::setTransformChangedCallback( Callback<void()>() );
- m_picomodel.m_lightsChanged = Callback();
+ m_picomodel.m_lightsChanged = Callback<void()>();
GlobalShaderCache().detach( *this );
}
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
#include <stdio.h>
#include "picomodel.h"
typedef unsigned char byte;
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; 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
--- /dev/null
+radiant_plugin(sample
+ sample.cpp sample.h
+ )
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#if !defined( INCLUDED_SAMPLE_H )
-#define INCLUDED_SAMPLE_H
-
-#endif
--- /dev/null
+radiant_plugin(shaders
+ plugin.cpp
+ shaders.cpp shaders.h
+ )
+
+find_package(GLIB REQUIRED)
+target_include_directories(shaders PRIVATE ${GLIB_INCLUDE_DIRS})
+target_link_libraries(shaders PRIVATE ${GLIB_LIBRARIES})
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "plugin.h"
-
#include "ishaders.h"
#include "ifilesystem.h"
#include "itextures.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; 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
//
// Shaders Manager Plugin
//
-// Leonardo Zide (leo@lokigames.com)
+// Leonardo Zide ( leo@lokigames.com )
//
+#include "defaults.h"
#include "shaders.h"
+#include "globaldefs.h"
#include <stdio.h>
#include <stdlib.h>
ShaderLanguage g_shaderLanguage = SHADERLANGUAGE_QUAKE3;
bool g_useShaderList = true;
_QERPlugImageTable* g_bitmapModule = 0;
-const char* g_texturePrefix = "textures/";
+const char* g_texturePrefix = DEFAULT_TEXTURE_DIRNAME;
void ActiveShaders_IteratorBegin();
+
bool ActiveShaders_IteratorAtEnd();
+
IShader *ActiveShaders_IteratorCurrent();
+
void ActiveShaders_IteratorIncrement();
-Callback g_ActiveShadersChangedNotify;
+
+Callback<void()> g_ActiveShadersChangedNotify;
void FreeShaders();
+
void LoadShaderFile( const char *filename );
+
qtexture_t *Texture_ForName( const char *filename );
return 0;
}
-
-Image* loadSpecial( void* environment, const char* name ){
- if ( *name == '_' ) { // special image
- StringOutputStream bitmapName( 256 );
- bitmapName << GlobalRadiant().getAppPath() << "bitmaps/" << name + 1 << ".png";
- Image* image = loadBitmap( environment, bitmapName.c_str() );
- if ( image != 0 ) {
- return image;
- }
- }
- return GlobalTexturesCache().loadImage( name );
-}
-
class ShaderPoolContext
{
};
+
typedef Static<StringPool, ShaderPoolContext> ShaderPool;
typedef PooledString<ShaderPool> ShaderString;
typedef ShaderString ShaderVariable;
}
-
typedef std::list<ShaderVariable> ShaderParameters;
typedef std::list<ShaderVariable> ShaderArguments;
void IncRef(){
++m_refcount;
}
+
void DecRef(){
ASSERT_MESSAGE( m_refcount != 0, "shader reference-count going below zero" );
if ( --m_refcount == 0 ) {
const char* getName() const {
return m_Name.c_str();
}
+
void setName( const char* name ){
m_Name = name;
}
// -----------------------------------------
bool parseDoom3( Tokeniser& tokeniser );
+
bool parseQuake3( Tokeniser& tokeniser );
+
bool parseTemplate( Tokeniser& tokeniser );
m_clampToBorder( false ),
m_alphaTest( alphaTest ){
}
+
const TextureExpression& texture() const {
return m_texture;
}
+
const BlendFuncExpression& blendFunc() const {
return m_blendFunc;
}
+
bool clampToBorder() const {
return m_clampToBorder;
}
+
const ShaderValue& alphaTest() const {
return m_alphaTest;
}
};
+
typedef std::vector<MapLayerTemplate> MapLayers;
MapLayers m_layers;
};
ShaderDefinition( ShaderTemplate* shaderTemplate, const ShaderArguments& args, const char* filename )
: shaderTemplate( shaderTemplate ), args( args ), filename( filename ){
}
+
ShaderTemplate* shaderTemplate;
ShaderArguments args;
const char* filename;
const ShaderTemplate& m_template;
const ShaderArguments& m_args;
const char* m_filename;
-// name is shader-name, otherwise texture-name (if not a real shader)
+// name is shader-name, otherwise texture-name ( if not a real shader )
CopiedString m_Name;
qtexture_t* m_pTexture;
realise();
}
+
virtual ~CShader(){
unrealise();
void IncRef(){
++m_refcount;
}
+
void DecRef(){
ASSERT_MESSAGE( m_refcount != 0, "shader reference-count going below zero" );
if ( --m_refcount == 0 ) {
qtexture_t* getTexture() const {
return m_pTexture;
}
+
qtexture_t* getDiffuse() const {
return m_pDiffuse;
}
+
qtexture_t* getBump() const {
return m_pBump;
}
+
qtexture_t* getSpecular() const {
return m_pSpecular;
}
+
// get shader name
const char* getName() const {
return m_Name.c_str();
}
+
bool IsInUse() const {
return m_bInUse;
}
+
void SetInUse( bool bInUse ){
m_bInUse = bInUse;
g_ActiveShadersChangedNotify();
}
+
// get the shader flags
int getFlags() const {
return m_template.m_nFlags;
}
+
// get the transparency value
float getTrans() const {
return m_template.m_fTrans;
}
+
// test if it's a true shader, or a default shader created to wrap around a texture
bool IsDefault() const {
return string_empty( m_filename );
}
+
// get the alphaFunc
void getAlphaFunc( EAlphaFunc *func, float *ref ) { *func = m_template.m_AlphaFunc; *ref = m_template.m_AlphaRef; };
BlendFunc getBlendFunc() const {
return m_blendFunc;
}
+
// get the cull type
ECull getCull(){
return m_template.m_Cull;
};
-// get shader file name (ie the file where this one is defined)
+
+// get shader file name ( ie the file where this one is defined )
const char* getShaderFileName() const {
return m_filename;
}
m_notfound = m_pTexture;
{
- StringOutputStream name( 256 );
- name << GlobalRadiant().getAppPath() << "bitmaps/" << ( IsDefault() ? "notex.png" : "shadernotex.png" );
- m_pTexture = GlobalTexturesCache().capture( LoadImageCallback( 0, loadBitmap ), name.c_str() );
+ m_pTexture = GlobalTexturesCache().capture( IsDefault() ? DEFAULT_NOTEX_NAME : DEFAULT_SHADERNOTEX_NAME );
}
}
m_clampToBorder( false ),
m_alphaTest( alphaTest ){
}
+
qtexture_t* texture() const {
return m_texture;
}
+
BlendFunc blendFunc() const {
return m_blendFunc;
}
+
bool clampToBorder() const {
return m_clampToBorder;
}
+
float alphaTest() const {
return m_alphaTest;
}
static MapLayer evaluateLayer( const ShaderTemplate::MapLayerTemplate& layerTemplate, const ShaderParameters& params, const ShaderArguments& args ){
return MapLayer(
- evaluateTexture( layerTemplate.texture(), params, args ),
- evaluateBlendFunc( layerTemplate.blendFunc(), params, args ),
- layerTemplate.clampToBorder(),
- evaluateFloat( layerTemplate.alphaTest(), params, args )
- );
+ evaluateTexture( layerTemplate.texture(), params, args ),
+ evaluateBlendFunc( layerTemplate.blendFunc(), params, args ),
+ layerTemplate.clampToBorder(),
+ evaluateFloat( layerTemplate.alphaTest(), params, args )
+ );
}
typedef std::vector<MapLayer> MapLayers;
}
bool ShaderTemplate::parseQuake3( Tokeniser& tokeniser ){
- // name of the qtexture_t we'll use to represent this shader (this one has the "textures\" before)
+ // name of the qtexture_t we'll use to represent this shader ( this one has the "textures\" before )
m_textureName = m_Name.c_str();
tokeniser.nextLine();
&& !string_equal( token, "skin" ) ) {
tokeniser.ungetToken();
}
- // first token should be the path + name.. (from base)
+ // first token should be the path + name.. ( from base )
CopiedString name;
if ( !Tokeniser_parseShaderName( tokeniser, name ) ) {
}
if ( result ) {
// do we already have this shader?
if ( !g_shaderDefinitions.insert( ShaderDefinitionMap::value_type( shaderTemplate->getName(), ShaderDefinition( shaderTemplate.get(), ShaderArguments(), filename ) ) ).second ) {
- #ifdef _DEBUG
+#if GDEF_DEBUG
globalOutputStream() << "WARNING: shader " << shaderTemplate->getName() << " is already in memory, definition in " << filename << " ignored.\n";
- #endif
+#endif
}
}
else
}
if ( string_equal( token, "guide" ) ) {
- // first token should be the path + name.. (from base)
+ // first token should be the path + name.. ( from base )
ShaderTemplatePointer shaderTemplate( new ShaderTemplate );
shaderTemplate->parseTemplate( tokeniser );
if ( !g_shaderTemplates.insert( ShaderTemplateMap::value_type( shaderTemplate->getName(), shaderTemplate ) ).second ) {
}
}
-typedef FreeCaller1<const char*, LoadShaderFile> LoadShaderFileCaller;
-
-
void loadGuideFile( const char* filename ){
StringOutputStream fullname( 256 );
fullname << "guides/" << filename;
}
}
-typedef FreeCaller1<const char*, loadGuideFile> LoadGuideFileCaller;
-
-
CShader* Try_Shader_ForName( const char* name ){
{
shaders_t::iterator i = g_ActiveShaders.find( name );
}
-
-
// the list of scripts/*.shader files we need to work with
// those are listed in shaderlist file
GSList *l_shaderfiles = 0;
globalOutputStream() << "\t" << filename << "\n";
}
}
-typedef ReferenceCaller1<bool, const char*, IfFound_dumpUnreferencedShader> IfFoundDumpUnreferencedShaderCaller;
+
+typedef ReferenceCaller<bool, void(const char*), IfFound_dumpUnreferencedShader> IfFoundDumpUnreferencedShaderCaller;
void DumpUnreferencedShaders(){
bool bFound = false;
}
}
-typedef FreeCaller1<const char*, ShaderList_addShaderFile> AddShaderFileCaller;
-
-
/*
==================
BuildShaderList
}
}
-typedef FreeCaller1<const char *, ShaderList_addFromArchive> AddShaderListFromArchiveCaller;
-
#include "stream/filestream.h"
bool shaderlist_findOrInstall( const char* enginePath, const char* toolsPath, const char* shaderPath, const char* gamename ){
void Shaders_Load(){
if ( g_shaderLanguage == SHADERLANGUAGE_QUAKE4 ) {
- GlobalFileSystem().forEachFile( "guides/", "guide", LoadGuideFileCaller(), 0 );
+ GlobalFileSystem().forEachFile("guides/", "guide", makeCallbackF(loadGuideFile), 0);
}
const char* shaderPath = GlobalRadiant().getGameDescriptionKeyValue( "shaderpath" );
shaderlist_findOrInstall( enginePath, toolsPath, path.c_str(), gamename );
}
- GlobalFileSystem().forEachArchive( AddShaderListFromArchiveCaller(), false, true );
+ GlobalFileSystem().forEachArchive(makeCallbackF(ShaderList_addFromArchive), false, true);
DumpUnreferencedShaders();
}
else
{
- GlobalFileSystem().forEachFile( path.c_str(), g_shadersExtension, AddShaderFileCaller(), 0 );
+ GlobalFileSystem().forEachFile(path.c_str(), g_shadersExtension, makeCallbackF(ShaderList_addShaderFile), 0);
}
GSList *lst = l_shaderfiles;
}
}
- //StringPool_analyse(ShaderPool::instance());
+ //StringPool_analyse( ShaderPool::instance() );
}
void Shaders_Free(){
bool Shaders_realised(){
return g_shaders_unrealised == 0;
}
+
void Shaders_Realise(){
if ( --g_shaders_unrealised == 0 ) {
Shaders_Load();
g_observers.realise();
}
}
+
void Shaders_Unrealise(){
if ( ++g_shaders_unrealised == 1 ) {
g_observers.unrealise();
void realise(){
Shaders_Realise();
}
+
void unrealise(){
Shaders_Unrealise();
}
+
void refresh(){
Shaders_Refresh();
}
void beginActiveShadersIterator(){
ActiveShaders_IteratorBegin();
}
+
bool endActiveShadersIterator(){
return ActiveShaders_IteratorAtEnd();
}
+
IShader* dereferenceActiveShadersIterator(){
return ActiveShaders_IteratorCurrent();
}
+
void incrementActiveShadersIterator(){
ActiveShaders_IteratorIncrement();
}
-void setActiveShadersChangedNotify( const Callback& notify ){
+
+void setActiveShadersChangedNotify( const Callback<void()>& notify ){
g_ActiveShadersChangedNotify = notify;
}
void attach( ModuleObserver& observer ){
g_observers.attach( observer );
}
+
void detach( ModuleObserver& observer ){
g_observers.detach( observer );
}
void Shaders_Construct(){
GlobalFileSystem().attach( g_Quake3ShaderSystem );
}
+
void Shaders_Destroy(){
GlobalFileSystem().detach( g_Quake3ShaderSystem );
+++ /dev/null
-*.dsp -m 'COPY' -k 'b'
-*.rc -m 'COPY' -k 'b'
if ( m_bPopup ) {
GtkWidget *menu, *item;
- menu = gtk_menu_new();
+ menu = ui::Menu();
- item = gtk_menu_item_new_with_label( "Validate (RETURN)" );
- gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( Textool_Validate ), NULL );
- gtk_widget_show( item );
+ item = ui::MenuItem( "Validate (RETURN)" );
+ item.connect( "activate", G_CALLBACK( Textool_Validate ), NULL );
+ item.show();
gtk_menu_append( GTK_MENU( menu ), item );
- item = gtk_menu_item_new_with_label( "Zoom in (INSERT)" );
- gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( view_ZoomIn ), this );
- gtk_widget_show( item );
+ item = ui::MenuItem( "Zoom in (INSERT)" );
+ item.connect( "activate", G_CALLBACK( view_ZoomIn ), this );
+ item.show();
gtk_menu_append( GTK_MENU( menu ), item );
- item = gtk_menu_item_new_with_label( "Zoom out (DELETE)" );
- gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( view_ZoomOut ), this );
- gtk_widget_show( item );
+ item = ui::MenuItem( "Zoom out (DELETE)" );
+ item.connect( "activate", G_CALLBACK( view_ZoomOut ), this );
+ item.show();
gtk_menu_append( GTK_MENU( menu ), item );
- item = gtk_menu_item_new_with_label( "Cancel (ESC)" );
- gtk_signal_connect( GTK_OBJECT( item ), "activate", GTK_SIGNAL_FUNC( Textool_Cancel ), NULL );
- gtk_widget_show( item );
+ item = ui::MenuItem( "Cancel (ESC)" );
+ item.connect( "activate", G_CALLBACK( Textool_Cancel ), NULL );
+ item.show();
gtk_menu_append( GTK_MENU( menu ), item );
gtk_menu_popup( GTK_MENU( menu ), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME );
+++ /dev/null
-*.jpg -m 'COPY' -k 'b'
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-// stdafx.cpp : source file that includes just the standard includes
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
// stdafx.h
// precompiled headers
+#include "globaldefs.h"
+
// standard headers
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
-#if !defined( WIN32 )
+#if !GDEF_OS_WINDOWS
// Necessary for proper boolean type declaration
#include "qertypes.h"
#include "StdAfx.h"
static void dialog_button_callback( GtkWidget *widget, gpointer data ){
- GtkWidget *parent;
int *loop, *ret;
- parent = gtk_widget_get_toplevel( widget );
+ auto parent = widget.window();
loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
}
int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){
- GtkWidget *window, *w, *vbox, *hbox;
+ GtkWidget *w, *vbox, *hbox;
int mode = ( uType & MB_TYPEMASK ), ret, loop = 1;
- window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_signal_connect( GTK_OBJECT( window ), "delete_event",
- GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
- gtk_signal_connect( GTK_OBJECT( window ), "destroy",
- GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
- gtk_window_set_title( GTK_WINDOW( window ), lpCaption );
- gtk_container_border_width( GTK_CONTAINER( window ), 10 );
+ auto window = ui::Window( ui::window_type::TOP );
+ window.connect( "delete_event",
+ G_CALLBACK( dialog_delete_callback ), NULL );
+ window.connect( "destroy",
+ G_CALLBACK( gtk_widget_destroy ), NULL );
+ gtk_window_set_title( window, lpCaption );
+ gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
g_object_set_data( G_OBJECT( window ), "loop", &loop );
g_object_set_data( G_OBJECT( window ), "ret", &ret );
gtk_widget_realize( window );
- vbox = gtk_vbox_new( FALSE, 10 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ vbox = ui::VBox( FALSE, 10 );
+ window.add(vbox);
+ vbox.show();
- w = gtk_label_new( lpText );
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
+ w = ui::Label( lpText );
+ vbox.pack_start( w, FALSE, FALSE, 2 );
gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
- gtk_widget_show( w );
+ w.show();
w = gtk_hseparator_new();
- gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
- gtk_widget_show( w );
+ vbox.pack_start( w, FALSE, FALSE, 2 );
+ w.show();
- hbox = gtk_hbox_new( FALSE, 10 );
- gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
- gtk_widget_show( hbox );
+ hbox = ui::HBox( FALSE, 10 );
+ vbox.pack_start( hbox, FALSE, FALSE, 2 );
+ hbox.show();
if ( mode == MB_OK ) {
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
ret = IDOK;
}
else if ( mode == MB_OKCANCEL ) {
- w = gtk_button_new_with_label( "Ok" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Ok" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
- gtk_widget_show( w );
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
+ w.show();
ret = IDCANCEL;
}
else if ( mode == MB_YESNOCANCEL ) {
- w = gtk_button_new_with_label( "Yes" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Yes" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
-
- w = gtk_button_new_with_label( "No" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
- gtk_widget_show( w );
-
- w = gtk_button_new_with_label( "Cancel" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
- gtk_widget_show( w );
+ w.show();
+
+ w = ui::Button( "No" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
+ w.show();
+
+ w = ui::Button( "Cancel" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDCANCEL ) );
+ w.show();
ret = IDCANCEL;
}
else /* if (mode == MB_YESNO) */
{
- w = gtk_button_new_with_label( "Yes" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
- GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
+ w = ui::Button( "Yes" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDYES ) );
+ gtk_widget_set_can_default( w, true );
gtk_widget_grab_default( w );
- gtk_widget_show( w );
+ w.show();
- w = gtk_button_new_with_label( "No" );
- gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
- gtk_signal_connect( GTK_OBJECT( w ), "clicked",
- GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
- gtk_widget_show( w );
+ w = ui::Button( "No" );
+ hbox.pack_start( w, TRUE, TRUE, 0 );
+ w.connect( "clicked",
+ G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( IDNO ) );
+ w.show();
ret = IDNO;
}
- gtk_widget_show( window );
+ window.show();
gtk_grab_add( window );
while ( loop )
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK );
// Connect signal handlers
- gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "expose_event", GTK_SIGNAL_FUNC( expose ), NULL );
- gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "motion_notify_event",
- GTK_SIGNAL_FUNC( motion ), NULL );
- gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "button_press_event",
- GTK_SIGNAL_FUNC( button_press ), NULL );
- gtk_signal_connect( GTK_OBJECT( g_pToolWidget ), "button_release_event",
- GTK_SIGNAL_FUNC( button_release ), NULL );
-
- gtk_signal_connect( GTK_OBJECT( g_pToolWnd ), "delete_event", GTK_SIGNAL_FUNC( close ), NULL );
- gtk_signal_connect( GTK_OBJECT( g_pToolWnd ), "key_press_event",
- GTK_SIGNAL_FUNC( keypress ), NULL );
+ g_pToolWidget.connect( "expose_event", G_CALLBACK( expose ), NULL );
+ g_pToolWidget.connect( "motion_notify_event",
+ G_CALLBACK( motion ), NULL );
+ g_pToolWidget.connect( "button_press_event",
+ G_CALLBACK( button_press ), NULL );
+ g_pToolWidget.connect( "button_release_event",
+ G_CALLBACK( button_release ), NULL );
+
+ g_pToolWnd.connect( "delete_event", G_CALLBACK( close ), NULL );
+ g_pToolWnd.connect( "key_press_event",
+ G_CALLBACK( keypress ), NULL );
return g_pToolWidget;
}
--- /dev/null
+radiant_plugin(vfspk3
+ archive.cpp archive.h
+ vfs.cpp vfs.h
+ vfspk3.cpp
+ )
+
+find_package(GLIB REQUIRED)
+target_include_directories(vfspk3 PRIVATE ${GLIB_INCLUDE_DIRS})
+target_link_libraries(vfspk3 PRIVATE ${GLIB_LIBRARIES})
+
+target_include_directories(vfspk3 PRIVATE filematch)
+target_link_libraries(vfspk3 PRIVATE filematch)
#include "archivelib.h"
#include "fs_path.h"
-#include "vfspk3.h"
-
class DirectoryArchive : public Archive
{
//
#include "vfs.h"
+#include "globaldefs.h"
#include <stdio.h>
#include <stdlib.h>
#include "os/path.h"
#include "moduleobservers.h"
#include "filematch.h"
+#include "dpkdeps.h"
-#define VFS_MAXDIRS 64
+const int VFS_MAXDIRS = 64;
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
#define PATH_MAX 260
#endif
};
#include <list>
+#include <map>
typedef std::list<archive_entry_t> archives_t;
}
}
-
-
const _QERArchiveTable* GetArchiveTable( ArchiveModules& archiveModules, const char* ext ){
StringOutputStream tmp( 16 );
tmp << LowerCase( ext );
return archiveModules.findModule( tmp.c_str() );
}
-static void InitPakFile( ArchiveModules& archiveModules, const char *filename ){
+
+static Archive* InitPakFile( ArchiveModules& archiveModules, const char *filename ){
const _QERArchiveTable* table = GetArchiveTable( archiveModules, path_get_extension( filename ) );
if ( table != 0 ) {
entry.is_pakfile = true;
g_archives.push_back( entry );
globalOutputStream() << " pak file: " << filename << "\n";
+
+ return entry.archive;
}
+
+ return 0;
}
inline void pathlist_prepend_unique( GSList*& pathlist, char* path ){
typedef std::set<CopiedString, PakLess> Archives;
+Archive* AddPk3Dir( const char* fullpath ){
+ if ( g_numDirs == VFS_MAXDIRS ) return 0;
+
+ strncpy( g_strDirs[g_numDirs], fullpath, PATH_MAX );
+ g_strDirs[g_numDirs][PATH_MAX] = '\0';
+ g_numDirs++;
+
+ {
+ archive_entry_t entry;
+ entry.name = fullpath;
+ entry.archive = OpenArchive( fullpath );
+ entry.is_pakfile = false;
+ g_archives.push_back( entry );
+
+ return entry.archive;
+ }
+}
+
+// for Daemon DPK vfs
+
+Archive* AddDpkDir( const char* fullpath ){
+ return AddPk3Dir( fullpath );
+}
+
+struct pakfile_path_t
+{
+ CopiedString fullpath; // full pak dir or pk3dir name
+ bool is_pakfile; // defines is it .pk3dir or .pk3 file
+};
+
+typedef std::pair<CopiedString, pakfile_path_t> PakfilePathsKV;
+typedef std::map<CopiedString, pakfile_path_t> PakfilePaths; // key must have no extension, only name
+
+static PakfilePaths g_pakfile_paths;
+
+void AddDpkPak( const char* name, const char* fullpath, bool is_pakfile ){
+ pakfile_path_t pakfile_path;
+ pakfile_path.fullpath = fullpath;
+ pakfile_path.is_pakfile = is_pakfile;
+ g_pakfile_paths.insert( PakfilePathsKV( name, pakfile_path ) );
+}
+
+// takes name without ext, returns without ext
+static const char* GetLatestDpkPakVersion( const char* name ){
+ const char* maxversion = 0;
+ const char* result = 0;
+ const char* pakname;
+ const char* pakversion;
+ int namelen = string_length( name );
+
+ for ( PakfilePaths::iterator i = g_pakfile_paths.begin(); i != g_pakfile_paths.end(); ++i )
+ {
+ pakname = i->first.c_str();
+ if ( strncmp( pakname, name, namelen ) != 0 || pakname[namelen] != '_' ) continue;
+ pakversion = pakname + (namelen + 1);
+ if ( maxversion == 0 || DpkPakVersionCmp( pakversion, maxversion ) > 0 ){
+ maxversion = pakversion;
+ result = pakname;
+ }
+ }
+ return result;
+}
+
+// release string after using
+static char* GetCurrentMapDpkPakName(){
+ char* mapdir;
+ char* mapname;
+ int mapnamelen;
+ char* result = 0;
+
+ mapname = string_clone( GlobalRadiant().getMapName() );
+ mapnamelen = string_length( mapname );
+
+ mapdir = strrchr( mapname, '/' );
+ if ( mapdir ) {
+ mapdir -= 12;
+ if ( strncmp( mapdir, ".dpkdir/maps/", 13 ) == 0 ) {
+ *mapdir = '\0';
+ mapdir = strrchr( mapname, '/' );
+ if ( mapdir ) mapdir++;
+ else mapdir = mapname;
+ result = string_clone( mapdir );
+ }
+ }
+
+ string_release( mapname, mapnamelen );
+ return result;
+
+}
+
+// prevent loading duplicates or circular references
+static Archives g_loaded_dpk_paks;
+
+// actual pak adding on initialise, deferred from InitDirectory
+// Daemon DPK filesystem doesn't need load all paks it finds
+static void LoadDpkPakWithDeps( const char* pakname ){
+ Archive* arc;
+ ArchiveTextFile* depsFile;
+
+ if (pakname == NULL) {
+ // load DEPS from game pack
+ StringOutputStream baseDirectory( 256 );
+ const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue( "basegame" );
+ baseDirectory << GlobalRadiant().getGameToolsPath() << basegame << '/';
+ arc = AddDpkDir( baseDirectory.c_str() );
+ depsFile = arc->openTextFile( "DEPS" );
+ } else {
+ const char* und = strrchr( pakname, '_' );
+ if ( !und ) {
+ pakname = GetLatestDpkPakVersion( pakname );
+ }
+ if ( !pakname || g_loaded_dpk_paks.find( pakname ) != g_loaded_dpk_paks.end() ) {
+ return;
+ }
+
+ PakfilePaths::iterator i = g_pakfile_paths.find( pakname );
+ if ( i == g_pakfile_paths.end() ) {
+ return;
+ }
+
+ if ( i->second.is_pakfile ){
+ arc = InitPakFile( FileSystemQ3API_getArchiveModules(), i->second.fullpath.c_str() );
+ } else {
+ arc = AddDpkDir( i->second.fullpath.c_str() );
+ }
+ g_loaded_dpk_paks.insert( pakname );
+
+ depsFile = arc->openTextFile( "DEPS" );
+ }
+
+ if ( !depsFile ) {
+ return;
+ }
+
+ {
+ TextLinesInputStream<TextInputStream> istream = depsFile->getInputStream();
+
+ CopiedString line;
+ char *p_name;
+ char *p_version;
+ while ( line = istream.readLine(), string_length( line.c_str() ) ) {
+ if ( !DpkReadDepsLine( line.c_str(), &p_name, &p_version ) ) continue;
+ if ( !p_version ) {
+ const char* p_latest = GetLatestDpkPakVersion( p_name );
+ if ( p_latest ) LoadDpkPakWithDeps( p_latest );
+ } else {
+ int len = string_length( p_name ) + string_length( p_version ) + 1;
+ char* p_pakname = string_new( len );
+ sprintf( p_pakname, "%s_%s", p_name, p_version );
+ LoadDpkPakWithDeps( p_pakname );
+ string_release( p_pakname, len );
+ }
+ string_release( p_name, string_length( p_name ) );
+ if ( p_version ) string_release( p_version, string_length( p_version ) );
+ }
+ }
+
+ depsFile->release();
+}
+
+// end for Daemon DPK vfs
+
// =============================================================================
// Global functions
}
if ( g_bUsePak ) {
+
GDir* dir = g_dir_open( path, 0, 0 );
if ( dir != 0 ) {
globalOutputStream() << "vfs directory: " << path << "\n";
+ Archives archives;
+ Archives archivesOverride;
const char* ignore_prefix = "";
const char* override_prefix = "";
+ bool is_pk3_vfs, is_pk4_vfs, is_dpk_vfs;
- {
+ is_pk3_vfs = GetArchiveTable( archiveModules, "pk3" );
+ is_pk4_vfs = GetArchiveTable( archiveModules, "pk4" );
+ is_dpk_vfs = GetArchiveTable( archiveModules, "dpk" );
+
+ if ( !is_dpk_vfs ) {
// See if we are in "sp" or "mp" mapping mode
const char* gamemode = gamemode_get();
}
}
- Archives archives;
- Archives archivesOverride;
for (;; )
{
const char* name = g_dir_read_name( dir );
}
const char *ext = strrchr( name, '.' );
-
- if ( ext && !string_compare_nocase_upper( ext, ".pk3dir" ) ) {
- if ( g_numDirs == VFS_MAXDIRS ) {
- continue;
+ char tmppath[PATH_MAX];
+
+ if ( is_dpk_vfs ) {
+ if ( !!ext && !string_compare_nocase_upper( ext, ".dpkdir" ) ) {
+ snprintf( tmppath, PATH_MAX, "%s%s/", path, name );
+ tmppath[PATH_MAX] = '\0';
+ FixDOSName( tmppath );
+ AddSlash( tmppath );
+ AddDpkPak( CopiedString( StringRange( name, ext ) ).c_str(), tmppath, false );
}
- snprintf( g_strDirs[g_numDirs], PATH_MAX, "%s%s/", path, name );
- g_strDirs[g_numDirs][PATH_MAX] = '\0';
- FixDOSName( g_strDirs[g_numDirs] );
- AddSlash( g_strDirs[g_numDirs] );
- g_numDirs++;
-
- {
- archive_entry_t entry;
- entry.name = g_strDirs[g_numDirs - 1];
- entry.archive = OpenArchive( g_strDirs[g_numDirs - 1] );
- entry.is_pakfile = false;
- g_archives.push_back( entry );
+ }
+
+ if ( is_pk3_vfs || is_pk4_vfs ) {
+ if ( !!ext && ( !string_compare_nocase_upper( ext, ".pk3dir" )
+ || !string_compare_nocase_upper( ext, ".pk4dir" ) ) ) {
+ snprintf( tmppath, PATH_MAX, "%s%s/", path, name );
+ tmppath[PATH_MAX] = '\0';
+ FixDOSName( tmppath );
+ AddSlash( tmppath );
+ AddPk3Dir( tmppath );
}
}
- if ( ( ext == 0 ) || *( ++ext ) == '\0' || GetArchiveTable( archiveModules, ext ) == 0 ) {
+ // GetArchiveTable() needs "pk3" if ext is ".pk3"
+ if ( ( ext == 0 ) || *( ext + 1 ) == '\0' || GetArchiveTable( archiveModules, ext + 1 ) == 0 ) {
continue;
}
continue;
}
if ( !string_empty( override_prefix ) && strncmp( name, override_prefix, strlen( override_prefix ) ) == 0 ) {
- archivesOverride.insert( name );
+ if ( !string_compare_nocase_upper( ext, ".dpk" ) ) {
+ if ( is_dpk_vfs ) {
+ archives.insert( name );
+ }
+ }
+ else {
+ archivesOverride.insert( name );
+ }
continue;
}
g_dir_close( dir );
// add the entries to the vfs
- for ( Archives::iterator i = archivesOverride.begin(); i != archivesOverride.end(); ++i )
- {
- char filename[PATH_MAX];
- strcpy( filename, path );
- strcat( filename, ( *i ).c_str() );
- InitPakFile( archiveModules, filename );
+ char* fullpath;
+ if ( is_dpk_vfs ) {
+ for ( Archives::iterator i = archives.begin(); i != archives.end(); ++i ) {
+ const char* name = i->c_str();
+ const char* ext = strrchr( name, '.' );
+ if ( !string_compare_nocase_upper( ext, ".dpk" ) ) {
+ CopiedString name_final = CopiedString( StringRange( name, ext ) );
+ fullpath = string_new_concat( path, name );
+ AddDpkPak( name_final.c_str(), fullpath, true );
+ string_release( fullpath, string_length( fullpath ) );
+ }
+ }
}
- for ( Archives::iterator i = archives.begin(); i != archives.end(); ++i )
- {
- char filename[PATH_MAX];
- strcpy( filename, path );
- strcat( filename, ( *i ).c_str() );
- InitPakFile( archiveModules, filename );
+ if ( is_pk3_vfs || is_pk4_vfs ) {
+ for ( Archives::iterator i = archivesOverride.begin(); i != archivesOverride.end(); ++i )
+ {
+ const char* name = i->c_str();
+ const char* ext = strrchr( name, '.' );
+ if ( !string_compare_nocase_upper( ext, ".pk3" )
+ || !string_compare_nocase_upper( ext, ".pk4" ) ) {
+ fullpath = string_new_concat( path, i->c_str() );
+ InitPakFile( archiveModules, fullpath );
+ string_release( fullpath, string_length( fullpath ) );
+ }
+ }
+ for ( Archives::iterator i = archives.begin(); i != archives.end(); ++i )
+ {
+ const char* name = i->c_str();
+ const char* ext = strrchr( name, '.' );
+ if ( !string_compare_nocase_upper( ext, ".pk3" )
+ || !string_compare_nocase_upper( ext, ".pk4" ) ) {
+ fullpath = string_new_concat( path, i->c_str() );
+ InitPakFile( archiveModules, fullpath );
+ string_release( fullpath, string_length( fullpath ) );
+ }
+ }
}
}
else
g_numDirs = 0;
g_numForbiddenDirs = 0;
+
+ g_pakfile_paths.clear();
+ g_loaded_dpk_paks.clear();
}
-#define VFS_SEARCH_PAK 0x1
-#define VFS_SEARCH_DIR 0x2
+const int VFS_SEARCH_PAK = 0x1;
+const int VFS_SEARCH_DIR = 0x2;
int GetFileCount( const char *filename, int flag ){
int count = 0;
for ( archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i )
{
- if ( ( *i ).is_pakfile && ( flag & VFS_SEARCH_PAK ) != 0
- || !( *i ).is_pakfile && ( flag & VFS_SEARCH_DIR ) != 0 ) {
+ if ( (( *i ).is_pakfile && ( flag & VFS_SEARCH_PAK ) != 0)
+ || (!( *i ).is_pakfile && ( flag & VFS_SEARCH_DIR ) != 0) ) {
if ( ( *i ).archive->containsFile( fixed ) ) {
++count;
}
InitDirectory( path, FileSystemQ3API_getArchiveModules() );
}
void initialise(){
+ load();
globalOutputStream() << "filesystem initialised\n";
g_observers.realise();
}
+
+void load(){
+ ArchiveModules& archiveModules = FileSystemQ3API_getArchiveModules();
+ bool is_dpk_vfs = GetArchiveTable( archiveModules, "dpk" );
+
+ if ( is_dpk_vfs ) {
+ const char* pakname;
+ g_loaded_dpk_paks.clear();
+
+ // Load DEPS from game pack
+ LoadDpkPakWithDeps( NULL );
+
+ // prevent VFS double start, for MapName="" and MapName="unnamed.map"
+ if ( string_length( GlobalRadiant().getMapName() ) ){
+ // load map's paks from DEPS
+ char* mappakname = GetCurrentMapDpkPakName();
+ if ( mappakname != NULL ) {
+ LoadDpkPakWithDeps( mappakname );
+ string_release( mappakname, string_length( mappakname ) );
+ }
+ }
+
+ g_pakfile_paths.clear();
+ g_loaded_dpk_paks.clear();
+ }
+}
+
+void clear() {
+ // like shutdown() but does not unrealise (keep map etc.)
+ Shutdown();
+}
+
+void refresh(){
+ // like initialise() but does not realise (keep map etc.)
+ load();
+ globalOutputStream() << "filesystem refreshed\n";
+}
+
void shutdown(){
g_observers.unrealise();
globalOutputStream() << "filesystem shutdown\n";
}
};
+
Quake3FileSystem g_Quake3FileSystem;
-void FileSystem_Init(){
+VirtualFileSystem& GetFileSystem(){
+ return g_Quake3FileSystem;
}
-void FileSystem_Shutdown(){
+void FileSystem_Init(){
}
-VirtualFileSystem& GetFileSystem(){
- return g_Quake3FileSystem;
+void FileSystem_Shutdown(){
}
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "vfspk3.h"
-
#include "qerplugin.h"
#include "iarchive.h"
#include "ifilesystem.h"
+++ /dev/null
-/*
- Copyright (C) 2001-2006, William Joseph.
- All Rights Reserved.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#if !defined( INCLUDED_VFSPK3_H )
-#define INCLUDED_VFSPK3_H
-
-#endif
--- /dev/null
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+
+find_package(OpenGL REQUIRED)
+
+string(SUBSTRING ${CMAKE_SHARED_MODULE_SUFFIX} 1 -1 _clibext)
+add_definitions(-DCMAKE_SHARED_MODULE_SUFFIX="${_clibext}")
+unset(_clibext)
+
+set(RADIANTLIST
+ autosave.cpp autosave.h
+ brush.cpp brush.h
+ brush_primit.cpp brush_primit.h
+ brushmanip.cpp brushmanip.h
+ brushmodule.cpp brushmodule.h
+ brushnode.cpp brushnode.h
+ brushtokens.cpp brushtokens.h
+ brushxml.cpp brushxml.h
+ build.cpp build.h
+ camwindow.cpp camwindow.h
+ clippertool.cpp clippertool.h
+ commands.cpp commands.h
+ console.cpp console.h
+ csg.cpp csg.h
+ dialog.cpp dialog.h
+ eclass.cpp eclass.h
+ eclass_def.cpp eclass_def.h
+ eclass_doom3.cpp eclass_doom3.h
+ eclass_fgd.cpp eclass_fgd.h
+ eclass_xml.cpp eclass_xml.h
+ entity.cpp entity.h
+ entityinspector.cpp entityinspector.h
+ entitylist.cpp entitylist.h
+ environment.cpp environment.h
+ error.cpp error.h
+ feedback.cpp feedback.h
+ filetypes.cpp filetypes.h
+ filterbar.cpp filterbar.h
+ filters.cpp filters.h
+ findtexturedialog.cpp findtexturedialog.h
+ glwidget.cpp glwidget.h
+ grid.cpp grid.h
+ groupdialog.cpp groupdialog.h
+ gtkdlgs.cpp gtkdlgs.h
+ gtkmisc.cpp gtkmisc.h
+ gtktheme.cpp gtktheme.h
+ help.cpp help.h
+ image.cpp image.h
+ main.cpp main.h
+ mainframe.cpp mainframe.h
+ map.cpp map.h
+ mru.cpp mru.h
+ nullmodel.cpp nullmodel.h
+ parse.cpp parse.h
+ patch.cpp patch.h
+ patchdialog.cpp patchdialog.h
+ patchmanip.cpp patchmanip.h
+ patchmodule.cpp patchmodule.h
+ plugin.cpp plugin.h
+ pluginapi.cpp pluginapi.h
+ pluginmanager.cpp pluginmanager.h
+ pluginmenu.cpp pluginmenu.h
+ plugintoolbar.cpp plugintoolbar.h
+ points.cpp points.h
+ preferencedictionary.cpp preferencedictionary.h
+ preferences.cpp preferences.h
+ qe3.cpp qe3.h
+ qgl.cpp qgl.h
+ referencecache.cpp referencecache.h
+ renderer.cpp renderer.h
+ renderstate.cpp renderstate.h
+ resource.h
+ scenegraph.cpp scenegraph.h
+ select.cpp select.h
+ selection.cpp selection.h
+ server.cpp server.h
+ shaders.cpp shaders.h
+ sockets.cpp sockets.h
+ stacktrace.cpp stacktrace.h
+ surfacedialog.cpp surfacedialog.h
+ texmanip.cpp texmanip.h
+ textureentry.cpp textureentry.h
+ textures.cpp textures.h
+ texwindow.cpp texwindow.h
+ timer.cpp timer.h
+ treemodel.cpp treemodel.h
+ undo.cpp undo.h
+ url.cpp url.h
+ view.cpp view.h
+ watchbsp.cpp watchbsp.h
+ winding.cpp winding.h
+ windowobservers.cpp windowobservers.h
+ xmlstuff.cpp xmlstuff.h
+ xywindow.cpp xywindow.h
+)
+if (WIN32)
+ list(APPEND RADIANTLIST multimon.cpp multimon.h)
+endif()
+
+radiant_tool(radiant WIN32 radiant.rc ${RADIANTLIST})
+add_dependencies(radiant modules)
+target_link_libraries(radiant
+ ${CMAKE_DL_LIBS}
+ ${LIBXML2_LIBRARIES}
+ ${OPENGL_gl_LIBRARY}
+ ${GTK${GTK_TARGET}_LIBRARIES}
+ ${GTKGL_LIBRARIES}
+ includes
+ cmdlib
+ container
+ ddslib
+ debugging
+ etclib
+ filematch
+ generic
+ l_net
+ math
+ mathlib
+ memory
+ modulesystem
+ os
+ picomodel
+ profile
+ script
+ signal
+ splines
+ stream
+ string
+ uilib
+ xmllib
+)
+if (X11_LIBRARIES)
+ target_link_libraries(radiant ${X11_LIBRARIES})
+endif ()
+
+copy_dlls(radiant)
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
#include "autosave.h"
+#include "globaldefs.h"
#include "os/file.h"
#include "os/path.h"
#include "preferences.h"
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
#define PATH_MAX 260
#endif
{
StringOutputStream strMsg( 256 );
strMsg << "Snapshot save failed.. unabled to create directory\n" << snapshotsDir.c_str();
- gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), strMsg.c_str() );
+ ui::alert( MainFrame_getWindow(), strMsg.c_str() );
}
}
/*
}
void Autosave_constructPreferences( PreferencesPage& page ){
- GtkWidget* autosave_enabled = page.appendCheckBox( "Autosave", "Enable Autosave", g_AutoSave_Enabled );
- GtkWidget* autosave_frequency = page.appendSpinner( "Autosave Frequency (minutes)", m_AutoSave_Frequency, 1, 1, 60 );
+ ui::CheckButton autosave_enabled = page.appendCheckBox( "Autosave", "Enable Autosave", g_AutoSave_Enabled );
+ ui::SpinButton autosave_frequency = page.appendSpinner( "Autosave Frequency (minutes)", m_AutoSave_Frequency, 1, 1, 60 );
Widget_connectToggleDependency( autosave_frequency, autosave_enabled );
page.appendCheckBox( "", "Save Snapshots", g_SnapShots_Enabled );
}
Autosave_constructPreferences( page );
}
void Autosave_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Autosave_constructPage>() );
+ PreferencesDialog_addSettingsPage(makeCallbackF(Autosave_constructPage));
}
#include "stringio.h"
void Autosave_Construct(){
- GlobalPreferenceSystem().registerPreference( "Autosave", BoolImportStringCaller( g_AutoSave_Enabled ), BoolExportStringCaller( g_AutoSave_Enabled ) );
- GlobalPreferenceSystem().registerPreference( "AutosaveMinutes", IntImportStringCaller( m_AutoSave_Frequency ), IntExportStringCaller( m_AutoSave_Frequency ) );
- GlobalPreferenceSystem().registerPreference( "Snapshots", BoolImportStringCaller( g_SnapShots_Enabled ), BoolExportStringCaller( g_SnapShots_Enabled ) );
+ GlobalPreferenceSystem().registerPreference( "Autosave", make_property_string( g_AutoSave_Enabled ) );
+ GlobalPreferenceSystem().registerPreference( "AutosaveMinutes", make_property_string( m_AutoSave_Frequency ) );
+ GlobalPreferenceSystem().registerPreference( "Snapshots", make_property_string( g_SnapShots_Enabled ) );
Autosave_registerPreferencesPage();
}
}
-
inline bool texdef_sane( const texdef_t& texdef ){
return fabs( texdef.shift[0] ) < ( 1 << 16 )
&& fabs( texdef.shift[1] ) < ( 1 << 16 );
{
public:
virtual void realiseShader() = 0;
-virtual void unrealiseShader() = 0;
-};
-
-class FaceShaderObserverRealise
-{
-public:
-void operator()( FaceShaderObserver& observer ) const {
- observer.realiseShader();
-}
-};
-class FaceShaderObserverUnrealise
-{
-public:
-void operator()( FaceShaderObserver& observer ) const {
- observer.unrealiseShader();
-}
+virtual void unrealiseShader() = 0;
};
typedef ReferencePair<FaceShaderObserver> FaceShaderObserverPair;
public:
ContentsFlagsValue(){
}
+
ContentsFlagsValue( int surfaceFlags, int contentFlags, int value, bool specified ) :
m_surfaceFlags( surfaceFlags ),
m_contentFlags( contentFlags ),
m_value( value ),
m_specified( specified ){
}
+
int m_surfaceFlags;
int m_contentFlags;
int m_value;
m_realised( false ){
captureShader();
}
+
~FaceShader(){
releaseShader();
}
+
// copy-construction not supported
FaceShader( const FaceShader& other );
m_instanced = true;
m_state->incrementUsed();
}
+
void instanceDetach(){
m_state->decrementUsed();
m_instanced = false;
m_state = GlobalShaderCache().capture( m_shader.c_str() );
m_state->attach( *this );
}
+
void releaseShader(){
ASSERT_MESSAGE( m_state != 0, "shader cannot be released" );
m_state->detach( *this );
void realise(){
ASSERT_MESSAGE( !m_realised, "FaceTexdef::realise: already realised" );
m_realised = true;
- m_observers.forEach( FaceShaderObserverRealise() );
+ m_observers.forEach([](FaceShaderObserver &observer) {
+ observer.realiseShader();
+ });
}
+
void unrealise(){
ASSERT_MESSAGE( m_realised, "FaceTexdef::unrealise: already unrealised" );
- m_observers.forEach( FaceShaderObserverUnrealise() );
+ m_observers.forEach([](FaceShaderObserver &observer) {
+ observer.unrealiseShader();
+ });
m_realised = false;
}
m_state->incrementUsed();
}
}
+
ContentsFlagsValue getFlags() const {
ASSERT_MESSAGE( m_realised, "FaceShader::getFlags: flags not valid when unrealised" );
if ( !m_flags.m_specified ) {
}
return m_flags;
}
+
void setFlags( const ContentsFlagsValue& flags ){
ASSERT_MESSAGE( m_realised, "FaceShader::setFlags: flags not valid when unrealised" );
ContentsFlagsValue_assignMasked( m_flags, flags );
}
return 1;
}
+
std::size_t height() const {
if ( m_realised ) {
return m_state->getTexture().height;
}
return 1;
}
+
unsigned int shaderFlags() const {
if ( m_realised ) {
return m_state->getFlags();
};
-
-
class FaceTexdef : public FaceShaderObserver
{
// not copyable
FaceTexdef( const FaceTexdef& other );
+
// not assignable
FaceTexdef& operator=( const FaceTexdef& other );
+
public:
class SavedState
{
m_scaleApplied( false ){
m_shader.attach( *this );
}
+
~FaceTexdef(){
m_shader.detach( *this );
}
m_scaleApplied = true;
m_projection.m_brushprimit_texdef.addScale( m_shader.width(), m_shader.height() );
}
+
void removeScale(){
ASSERT_MESSAGE( m_scaleApplied, "texture scale aready removed" );
m_scaleApplied = false;
addScale();
}
}
+
void unrealiseShader(){
if ( m_projectionInitialised && m_scaleApplied ) {
removeScale();
tmp.removeScale( m_shader.width(), m_shader.height() );
return TextureProjection( m_projection.m_texdef, tmp, m_projection.m_basis_s, m_projection.m_basis_t );
}
+
void setBasis( const Vector3& normal ){
Matrix4 basis;
Normal_GetTransform( normal, basis );
FacePlane() : m_funcStaticOrigin( 0, 0, 0 ){
}
+
FacePlane( const FacePlane& other ) : m_funcStaticOrigin( 0, 0, 0 ){
if ( !isDoom3Plane() ) {
planepts_assign( m_planepts, other.m_planepts );
updateSource();
}
}
+
void transform( const Matrix4& matrix, bool mirror ){
if ( !isDoom3Plane() ) {
updateSource();
}
}
+
void offset( float offset ){
if ( !isDoom3Plane() ) {
Vector3 move( vector3_scaled( m_planeCached.normal(), -offset ) );
void updateTranslated(){
m_planeCached = Plane3_applyTranslation( m_plane, m_funcStaticOrigin );
}
+
void updateSource(){
m_plane = Plane3_applyTranslation( m_planeCached, vector3_negated( m_funcStaticOrigin ) );
}
PlanePoints& planePoints(){
return m_planepts;
}
+
const PlanePoints& planePoints() const {
return m_planepts;
}
+
const Plane3& plane3() const {
return m_planeCached;
}
+
void setDoom3Plane( const Plane3& plane ){
m_plane = plane;
updateTranslated();
}
+
const Plane3& getDoom3Plane() const {
return m_plane;
}
updateSource();
}
}
+
void copy( const Vector3& p0, const Vector3& p1, const Vector3& p2 ){
if ( !isDoom3Plane() ) {
m_planepts[0] = p0;
};
bool face_filtered( Face& face );
+
void add_face_filter( FaceFilter& filter, int mask, bool invert = false );
void Brush_addTextureChangedCallback( const SignalHandler& callback );
+
void Brush_textureChanged();
{
public:
virtual void planeChanged() = 0;
+
virtual void connectivityChanged() = 0;
+
virtual void shaderChanged() = 0;
+
virtual void evaluateTransform() = 0;
};
// assignment not supported
Face& operator=( const Face& other );
+
// copy-construction not supported
Face( const Face& other );
m_texdef.setBasis( m_plane.plane3().normal() );
planeChanged();
}
+
Face(
const Vector3& p0,
const Vector3& p1,
planeChanged();
updateFiltered();
}
+
Face( const Face& other, FaceObserver* observer ) :
m_refcount( 0 ),
m_shader( other.m_shader.getShader(), other.m_shader.m_flags ),
planeChanged();
updateFiltered();
}
+
~Face(){
m_shader.detach( *this );
}
void realiseShader(){
m_observer->shaderChanged();
}
+
void unrealiseShader(){
}
void updateFiltered(){
m_filtered = face_filtered( *this );
}
+
bool isFiltered() const {
return m_filtered;
}
UndoMemento* exportState() const {
return new SavedState( *this );
}
+
void importState( const UndoMemento* data ){
undoSave();
void IncRef(){
++m_refcount;
}
+
void DecRef(){
if ( --m_refcount == 0 ) {
delete this;
planepts_assign( m_move_planeptsTransformed, m_move_planepts );
m_texdefTransformed = m_texdef.m_projection;
}
+
void freezeTransform(){
undoSave();
m_plane = m_planeTransformed;
const char* GetShader() const {
return m_shader.getShader();
}
+
void SetShader( const char* name ){
undoSave();
m_shader.setShader( name );
void revertTexdef(){
m_texdefTransformed = m_texdef.m_projection;
}
+
void texdefChanged(){
revertTexdef();
EmitTextureCoordinates();
void GetTexdef( TextureProjection& projection ) const {
projection = m_texdef.normalised();
}
+
void SetTexdef( const TextureProjection& projection ){
undoSave();
m_texdef.setTexdef( projection );
void GetFlags( ContentsFlagsValue& flags ) const {
flags = m_shader.getFlags();
}
+
void SetFlags( const ContentsFlagsValue& flags ){
undoSave();
m_shader.setFlags( flags );
const Winding& getWinding() const {
return m_winding;
}
+
Winding& getWinding(){
return m_winding;
}
m_observer->evaluateTransform();
return m_planeTransformed.plane3();
}
+
FacePlane& getPlane(){
return m_plane;
}
+
const FacePlane& getPlane() const {
return m_plane;
}
+
FaceTexdef& getTexdef(){
return m_texdef;
}
+
const FaceTexdef& getTexdef() const {
return m_texdef;
}
+
FaceShader& getShader(){
return m_shader;
}
+
const FaceShader& getShader() const {
return m_shader;
}
bool isDetail() const {
return ( m_shader.m_flags.m_contentFlags & BRUSH_DETAIL_MASK ) != 0;
}
+
void setDetail( bool detail ){
undoSave();
if ( detail && !isDetail() ) {
bool contributes() const {
return m_winding.numpoints > 2;
}
+
bool is_bounded() const {
for ( Winding::const_iterator i = m_winding.begin(); i != m_winding.end(); ++i )
{
std::size_t getFace() const {
return m_face;
}
+
std::size_t getVertex() const {
return m_vertex;
}
EdgeRenderIndices()
: first( 0 ), second( 0 ){
}
+
EdgeRenderIndices( const RenderIndex _first, const RenderIndex _second )
: first( _first ), second( _second ){
}
EdgeFaces()
: first( c_brush_maxFaces ), second( c_brush_maxFaces ){
}
+
EdgeFaces( const faceIndex_t _first, const faceIndex_t _second )
: first( _first ), second( _second ){
}
};
class Brush;
+
typedef std::vector<Brush*> brush_vector_t;
class BrushFilter
};
bool brush_filtered( Brush& brush );
+
void add_brush_filter( BrushFilter& filter, int mask, bool invert = false );
SelectableEdge( Faces& faces, FaceVertexId faceVertex )
: m_faces( faces ), m_faceVertex( faceVertex ){
}
+
SelectableEdge& operator=( const SelectableEdge& other ){
m_faceVertex = other.m_faceVertex;
return *this;
SelectableVertex( Faces& faces, FaceVertexId faceVertex )
: m_faces( faces ), m_faceVertex( faceVertex ){
}
+
SelectableVertex& operator=( const SelectableVertex& other ){
m_faceVertex = other.m_faceVertex;
return *this;
{
public:
virtual void reserve( std::size_t size ) = 0;
+
virtual void clear() = 0;
+
virtual void push_back( Face& face ) = 0;
+
virtual void pop_back() = 0;
+
virtual void erase( std::size_t index ) = 0;
+
virtual void connectivityChanged() = 0;
virtual void edge_clear() = 0;
+
virtual void edge_push_back( SelectableEdge& edge ) = 0;
virtual void vertex_clear() = 0;
+
virtual void vertex_push_back( SelectableVertex& vertex ) = 0;
virtual void DEBUG_verify() const = 0;
AABB m_aabb_local;
// ----
-Callback m_evaluateTransform;
-Callback m_boundsChanged;
+Callback<void()> m_evaluateTransform;
+Callback<void()> m_boundsChanged;
mutable bool m_planeChanged; // b-rep evaluation required
mutable bool m_transformChanged; // transform evaluation required
public:
STRING_CONSTANT( Name, "Brush" );
-Callback m_lightsChanged;
+Callback<void()> m_lightsChanged;
// static data
static Shader* m_state_point;
static EBrushType m_type;
static double m_maxWorldCoord;
-Brush( scene::Node& node, const Callback& evaluateTransform, const Callback& boundsChanged ) :
+Brush( scene::Node& node, const Callback<void()>& evaluateTransform, const Callback<void()>& boundsChanged ) :
m_node( &node ),
m_undoable_observer( 0 ),
m_map( 0 ),
m_transformChanged( false ){
planeChanged();
}
-Brush( const Brush& other, scene::Node& node, const Callback& evaluateTransform, const Callback& boundsChanged ) :
+Brush( const Brush& other, scene::Node& node, const Callback<void()>& evaluateTransform, const Callback<void()>& boundsChanged ) :
m_node( &node ),
m_undoable_observer( 0 ),
m_map( 0 ),
m_transformChanged( false ){
copy( other );
}
+
Brush( const Brush& other ) :
TransformNode( other ),
Bounded( other ),
m_transformChanged( false ){
copy( other );
}
+
~Brush(){
ASSERT_MESSAGE( m_observers.empty(), "Brush::~Brush: observers still attached" );
}
m_observers.insert( &observer );
}
+
void detach( BrushObserver& observer ){
m_observers.erase( &observer );
}
( *i )->instanceAttach( map );
}
}
+
void forEachFace_instanceDetach( MapFile* map ) const {
for ( Faces::const_iterator i = m_faces.begin(); i != m_faces.end(); ++i )
{
}
InstanceCounter m_instanceCounter;
+
void instanceAttach( const scene::Path& path ){
if ( ++m_instanceCounter.m_count == 1 ) {
m_map = path_find_mapfile( path.begin(), path.end() );
ASSERT_MESSAGE( path_find_mapfile( path.begin(), path.end() ) == m_map, "node is instanced across more than one file" );
}
}
+
void instanceDetach( const scene::Path& path ){
if ( --m_instanceCounter.m_count == 0 ) {
forEachFace_instanceDetach( m_map );
const char* name() const {
return "brush";
}
+
void attach( const NameCallback& callback ){
}
+
void detach( const NameCallback& callback ){
}
aabbChanged();
m_lightsChanged();
}
+
void shaderChanged(){
updateFiltered();
planeChanged();
m_transformChanged = true;
planeChanged();
}
-typedef MemberCaller<Brush, &Brush::transformChanged> TransformChangedCaller;
+
+typedef MemberCaller<Brush, void(), &Brush::transformChanged> TransformChangedCaller;
void evaluateTransform(){
if ( m_transformChanged ) {
m_evaluateTransform();
}
}
+
const Matrix4& localToParent() const {
return g_matrix4_identity;
}
+
void aabbChanged(){
m_boundsChanged();
}
+
const AABB& localAABB() const {
evaluateBRep();
return m_aabb_local;
( *i )->transform( matrix, mirror );
}
}
+
void snapto( float snap ){
for ( Faces::iterator i = m_faces.begin(); i != m_faces.end(); ++i )
{
( *i )->snapto( snap );
}
}
+
void revertTransform(){
for ( Faces::iterator i = m_faces.begin(); i != m_faces.end(); ++i )
{
( *i )->revertTransform();
}
}
+
void freezeTransform(){
for ( Faces::iterator i = m_faces.begin(); i != m_faces.end(); ++i )
{
public:
BrushUndoMemento( const Faces& faces ) : m_faces( faces ){
}
+
void release(){
delete this;
}
m_state_point = GlobalShaderCache().capture( "$POINT" );
}
+
static void destroyStatic(){
GlobalShaderCache().release( "$POINT" );
}
const_iterator begin() const {
return m_faces.begin();
}
+
const_iterator end() const {
return m_faces.end();
}
Face* back(){
return m_faces.back();
}
+
const Face* back() const {
return m_faces.back();
}
+
void reserve( std::size_t count ){
m_faces.reserve( count );
for ( Observers::iterator i = m_observers.begin(); i != m_observers.end(); ++i )
( *i )->reserve( count );
}
}
+
void push_back( Faces::value_type face ){
m_faces.push_back( face );
if ( m_instanceCounter.m_count != 0 ) {
( *i )->DEBUG_verify();
}
}
+
void pop_back(){
if ( m_instanceCounter.m_count != 0 ) {
m_faces.back()->instanceDetach( m_map );
( *i )->DEBUG_verify();
}
}
+
void erase( std::size_t index ){
if ( m_instanceCounter.m_count != 0 ) {
m_faces[index]->instanceDetach( m_map );
( *i )->DEBUG_verify();
}
}
+
void connectivityChanged(){
for ( Observers::iterator i = m_observers.begin(); i != m_observers.end(); ++i )
{
( *i )->DEBUG_verify();
}
}
+
std::size_t size() const {
return m_faces.size();
}
+
bool empty() const {
return m_faces.empty();
}
( *i )->edge_push_back( m_select_edges.back() );
}
}
+
void edge_clear(){
m_select_edges.clear();
for ( Observers::iterator i = m_observers.begin(); i != m_observers.end(); ++i )
( *i )->edge_clear();
}
}
+
void vertex_push_back( FaceVertexId faceVertex ){
m_select_vertices.push_back( SelectableVertex( m_faces, faceVertex ) );
for ( Observers::iterator i = m_observers.begin(); i != m_observers.end(); ++i )
( *i )->vertex_push_back( m_select_vertices.back() );
}
}
+
void vertex_clear(){
m_select_vertices.clear();
for ( Observers::iterator i = m_observers.begin(); i != m_observers.end(); ++i )
};
-
class FaceInstance;
class FaceInstanceSet
void insert( FaceInstance& faceInstance ){
m_faceInstances.append( faceInstance );
}
+
void erase( FaceInstance& faceInstance ){
m_faceInstances.erase( faceInstance );
}
bool empty() const {
return m_faceInstances.empty();
}
+
FaceInstance& last() const {
return m_faceInstances.back();
}
}
return i;
}
+
inline void VertexSelection_erase( VertexSelection& self, std::size_t value ){
VertexSelection::iterator i = VertexSelection_find( self, value );
if ( i != self.end() ) {
inline bool triangle_reversed( std::size_t x, std::size_t y, std::size_t z ){
return !( ( x < y && y < z ) || ( z < x && x < y ) || ( y < z && z < x ) );
}
+
template<typename Element>
inline Vector3 triangle_cross( const BasicVector3<Element>& x, const BasicVector3<Element> y, const BasicVector3<Element>& z ){
return vector3_cross( y - x, z - x );
}
+
template<typename Element>
inline bool triangles_same_winding( const BasicVector3<Element>& x1, const BasicVector3<Element> y1, const BasicVector3<Element>& z1, const BasicVector3<Element>& x2, const BasicVector3<Element> y2, const BasicVector3<Element>& z2 ){
return vector3_dot( triangle_cross( x1, y1, z1 ), triangle_cross( x2, y2, z2 ) ) > 0;
void addLight( const RendererLight& light ){
m_lights.push_back( &light );
}
+
void clear(){
m_lights.clear();
}
+
void evaluateLights() const {
}
+
void lightsChanged() const {
}
+
void forEachLight( const RendererLightCallback& callback ) const {
for ( Lights::const_iterator i = m_lights.begin(); i != m_lights.end(); ++i )
{
m_selectableEdges( observer ),
m_selectionChanged( observer ){
}
+
FaceInstance( const FaceInstance& other ) :
m_face( other.m_face ),
m_selectable( SelectedChangedCaller( *this ) ),
m_selectableEdges( other.m_selectableEdges ),
m_selectionChanged( other.m_selectionChanged ){
}
+
FaceInstance& operator=( const FaceInstance& other ){
m_face = other.m_face;
return *this;
Face& getFace(){
return *m_face;
}
+
const Face& getFace() const {
return *m_face;
}
}
m_selectionChanged( selectable );
}
-typedef MemberCaller1<FaceInstance, const Selectable&, &FaceInstance::selectedChanged> SelectedChangedCaller;
+
+typedef MemberCaller<FaceInstance, void(const Selectable&), &FaceInstance::selectedChanged> SelectedChangedCaller;
bool selectedVertices() const {
return !m_vertexSelection.empty();
}
+
bool selectedEdges() const {
return !m_edgeSelection.empty();
}
+
bool isSelected() const {
return m_selectable.isSelected();
}
bool selectedComponents() const {
return selectedVertices() || selectedEdges() || isSelected();
}
+
bool selectedComponents( SelectionSystem::EComponentMode mode ) const {
switch ( mode )
{
return false;
}
}
+
void setSelected( SelectionSystem::EComponentMode mode, bool select ){
switch ( mode )
{
}
}
}
+
template<typename Functor>
void SelectedEdges_foreach( Functor functor ) const {
for ( VertexSelection::const_iterator i = m_edgeSelection.begin(); i != m_edgeSelection.end(); ++i )
}
}
}
+
template<typename Functor>
void SelectedFaces_foreach( Functor functor ) const {
if ( isSelected() ) {
}
void iterate_selected( AABB& aabb ) const {
- SelectedComponents_foreach( AABBExtendByPoint( aabb ) );
-}
-
-class RenderablePointVectorPushBack
-{
-RenderablePointVector& m_points;
-public:
-RenderablePointVectorPushBack( RenderablePointVector& points ) : m_points( points ){
-}
-void operator()( const Vector3& point ) const {
- const Colour4b colour_selected( 0, 0, 255, 255 );
- m_points.push_back( pointvertex_for_windingpoint( point, colour_selected ) );
+ SelectedComponents_foreach([&](const Vector3 &point) {
+ aabb_extend_by_point_safe(aabb, point);
+ });
}
-};
void iterate_selected( RenderablePointVector& points ) const {
- SelectedComponents_foreach( RenderablePointVectorPushBack( points ) );
+ SelectedComponents_foreach([&](const Vector3 &point) {
+ const Colour4b colour_selected(0, 0, 255, 255);
+ points.push_back(pointvertex_for_windingpoint(point, colour_selected));
+ });
}
bool intersectVolume( const VolumeTest& volume, const Matrix4& localToWorld ) const {
m_face->testSelect( test, best );
}
}
+
void testSelect( Selector& selector, SelectionTest& test ){
SelectionIntersection best;
testSelect( test, best );
Selector_add( selector, m_selectable, best );
}
}
+
void testSelect_centroid( Selector& selector, SelectionTest& test ){
if ( m_face->contributes() && !m_face->isFiltered() ) {
SelectionIntersection best;
selectedPlaneCallback( getFace().plane3() );
}
+
void selectReversedPlane( Selector& selector, const SelectedPlanes& selectedPlanes ){
if ( selectedPlanes.contains( plane3_flipped( getFace().plane3() ) ) ) {
Selector_add( selector, m_selectable );
m_face->freezeTransform();
}
}
+
void update_move_planepts_vertex( std::size_t index ){
m_face->update_move_planepts_vertex( index, m_face->m_move_planepts );
}
+
void update_move_planepts_vertex2( std::size_t index, std::size_t other ){
const std::size_t numpoints = m_face->getWinding().numpoints;
ASSERT_MESSAGE( index < numpoints, "select_vertex: invalid index" );
m_face->m_move_planepts[2] = m_face->getWinding()[other].vertex;
planepts_quantise( m_face->m_move_planepts, GRID_MIN ); // winding points are very inaccurate
}
+
void update_selection_vertex(){
if ( m_vertexSelection.size() == 0 ) {
m_selectableVertices.setSelected( false );
}
}
}
+
void select_vertex( std::size_t index, bool select ){
if ( select ) {
VertexSelection_insert( m_vertexSelection, getFace().getWinding()[index].adjacent );
m_face->m_move_planepts[2] = m_face->getWinding()[opposite].vertex;
planepts_quantise( m_face->m_move_planepts, GRID_MIN ); // winding points are very inaccurate
}
+
void update_selection_edge(){
if ( m_edgeSelection.size() == 0 ) {
m_selectableEdges.setSelected( false );
}
}
}
+
void select_edge( std::size_t index, bool select ){
if ( select ) {
VertexSelection_insert( m_edgeSelection, getFace().getWinding()[index].adjacent );
static void constructStatic(){
m_state = GlobalShaderCache().capture( "$CLIPPER_OVERLAY" );
}
+
static void destroyStatic(){
GlobalShaderCache().release( "$CLIPPER_OVERLAY" );
}
}
-
typedef std::vector<FaceInstance> FaceInstances;
class EdgeInstance : public Selectable
faceVertex = next_edge( m_edge->m_faces, faceVertex );
m_faceInstances[faceVertex.getFace()].select_edge( faceVertex.getVertex(), select );
}
+
bool selected_edge() const {
FaceVertexId faceVertex = m_edge->m_faceVertex;
if ( !m_faceInstances[faceVertex.getFace()].selected_edge( faceVertex.getVertex() ) ) {
void setSelected( bool select ){
select_edge( select );
}
+
bool isSelected() const {
return selected_edge();
}
}
while ( faceVertex.getFace() != m_vertex->m_faceVertex.getFace() );
}
+
bool selected_vertex() const {
FaceVertexId faceVertex = m_vertex->m_faceVertex;
do
void setSelected( bool select ){
select_vertex( select );
}
+
bool isSelected() const {
return selected_vertex();
}
InstanceIdentityCast<BrushInstance>::install( m_casts );
InstanceContainedCast<BrushInstance, Transformable>::install( m_casts );
}
+
InstanceTypeCastTable& get(){
return m_casts;
}
void lightsChanged(){
m_lightList->lightsChanged();
}
-typedef MemberCaller<BrushInstance, &BrushInstance::lightsChanged> LightsChangedCaller;
+
+typedef MemberCaller<BrushInstance, void(), &BrushInstance::lightsChanged> LightsChangedCaller;
STRING_CONSTANT( Name, "BrushInstance" );
Instance::setTransformChangedCallback( LightsChangedCaller( *this ) );
}
+
~BrushInstance(){
- Instance::setTransformChangedCallback( Callback() );
+ Instance::setTransformChangedCallback( Callback<void()>() );
- m_brush.m_lightsChanged = Callback();
+ m_brush.m_lightsChanged = Callback<void()>();
GlobalShaderCache().detach( *this );
m_counter->decrement();
Bounded& get( NullType<Bounded>){
return m_brush;
}
+
Cullable& get( NullType<Cullable>){
return m_brush;
}
+
Transformable& get( NullType<Transformable>){
return m_transform;
}
Instance::selectedChanged();
}
-typedef MemberCaller1<BrushInstance, const Selectable&, &BrushInstance::selectedChanged> SelectedChangedCaller;
+typedef MemberCaller<BrushInstance, void(const Selectable&), &BrushInstance::selectedChanged> SelectedChangedCaller;
void selectedChangedComponent( const Selectable& selectable ){
GlobalSelectionSystem().getObserver ( SelectionSystem::eComponent )( selectable );
GlobalSelectionSystem().onComponentSelection( *this, selectable );
}
-typedef MemberCaller1<BrushInstance, const Selectable&, &BrushInstance::selectedChangedComponent> SelectedChangedComponentCaller;
+typedef MemberCaller<BrushInstance, void(const Selectable&), &BrushInstance::selectedChangedComponent> SelectedChangedComponentCaller;
const BrushInstanceVisitor& forEachFaceInstance( const BrushInstanceVisitor& visitor ){
for ( FaceInstances::iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i )
static void constructStatic(){
m_state_selpoint = GlobalShaderCache().capture( "$SELPOINT" );
}
+
static void destroyStatic(){
GlobalShaderCache().release( "$SELPOINT" );
}
void clear(){
m_faceInstances.clear();
}
+
void reserve( std::size_t size ){
m_faceInstances.reserve( size );
}
void push_back( Face& face ){
m_faceInstances.push_back( FaceInstance( face, SelectedChangedComponentCaller( *this ) ) );
}
+
void pop_back(){
ASSERT_MESSAGE( !m_faceInstances.empty(), "erasing invalid element" );
m_faceInstances.pop_back();
}
+
void erase( std::size_t index ){
ASSERT_MESSAGE( index < m_faceInstances.size(), "erasing invalid element" );
m_faceInstances.erase( m_faceInstances.begin() + index );
}
+
void connectivityChanged(){
for ( FaceInstances::iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i )
{
void edge_clear(){
m_edgeInstances.clear();
}
+
void edge_push_back( SelectableEdge& edge ){
m_edgeInstances.push_back( EdgeInstance( m_faceInstances, edge ) );
}
void vertex_clear(){
m_vertexInstances.clear();
}
+
void vertex_push_back( SelectableVertex& vertex ){
m_vertexInstances.push_back( VertexInstance( m_faceInstances, vertex ) );
}
bool isSelected() const {
return m_selectable.isSelected();
}
+
void setSelected( bool select ){
m_selectable.setSelected( select );
if ( !select && parent() ){
}
return false;
}
+
void setSelectedComponents( bool select, SelectionSystem::EComponentMode mode ){
for ( FaceInstances::iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i )
{
( *i ).setSelected( mode, select );
}
}
+
void testSelectComponents( Selector& selector, SelectionTest& test, SelectionSystem::EComponentMode mode ){
test.BeginMesh( localToWorld() );
( *i ).selectPlane( selector, Line( test.getNear(), test.getFar() ), selectedPlaneCallback );
}
}
+
void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPlanes ){
for ( FaceInstances::iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i )
{
( *i ).transformComponents( matrix );
}
}
+
const AABB& getSelectedComponentsBounds() const {
m_aabb_component = AABB();
( *i ).snapComponents( snap );
}
}
+
void evaluateTransform(){
Matrix4 matrix( m_transform.calculateTransform() );
//globalOutputStream() << "matrix: " << matrix << "\n";
transformComponents( matrix );
}
}
+
void applyTransform(){
m_brush.revertTransform();
evaluateTransform();
m_brush.freezeTransform();
}
-typedef MemberCaller<BrushInstance, &BrushInstance::applyTransform> ApplyTransformCaller;
+
+typedef MemberCaller<BrushInstance, void(), &BrushInstance::applyTransform> ApplyTransformCaller;
void setClipPlane( const Plane3& plane ){
m_clipPlane.setPlane( m_brush, plane );
bool testLight( const RendererLight& light ) const {
return light.testAABB( worldAABB() );
}
+
void insertLight( const RendererLight& light ){
const Matrix4& localToWorld = Instance::localToWorld();
for ( FaceInstances::const_iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i )
Face_addLight( *i, localToWorld, light );
}
}
+
void clearLights(){
for ( FaceInstances::const_iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i )
{
public:
BrushSelectedVisitor( const Functor& functor ) : m_functor( functor ){
}
+
void visit( scene::Instance& instance ) const {
BrushInstance* brush = Instance_getBrush( instance );
if ( brush != 0 ) {
public:
BrushVisibleSelectedVisitor( const Functor& functor ) : m_functor( functor ){
}
+
void visit( scene::Instance& instance ) const {
BrushInstance* brush = Instance_getBrush( instance );
if ( brush != 0
public:
BrushForEachFace( const BrushInstanceVisitor& visitor ) : m_visitor( visitor ){
}
+
void operator()( BrushInstance& brush ) const {
brush.forEachFaceInstance( m_visitor );
}
FaceInstanceVisitFace( const Functor& functor )
: functor( functor ){
}
+
void visit( FaceInstance& face ) const {
functor( face.getFace() );
}
FaceVisitAll( const Functor& functor )
: functor( functor ){
}
+
void visit( Face& face ) const {
functor( face );
}
FaceInstanceVisitAll( const Functor& functor )
: functor( functor ){
}
+
void visit( FaceInstance& face ) const {
functor( face );
}
public:
InstanceIfVisible( const Functor& functor ) : Functor( functor ){
}
+
void operator()( scene::Instance& instance ){
if ( instance.path().top().get().visible() ) {
Functor::operator()( instance );
public:
BrushVisibleWalker( const Functor& functor ) : m_functor( functor ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
BrushInstance* brush = Instance_getBrush( instance );
*/
#include "brush_primit.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
void BPMatMul( float A[2][3], float B[2][3], float C[2][3] );
// apply a rotation (degrees)
void BPMatRotate( float A[2][3], float theta );
-#ifdef _DEBUG
+#if GDEF_DEBUG
void BPMatDump( float A[2][3] );
#endif
-#ifdef _DEBUG
+#if GDEF_DEBUG
//#define DBG_BP
#endif
Vector3 first = from;
Vector3 second = to;
- if ( vector3_dot( from, plane.normal() ) > 0 == vector3_dot( to, plane.normal() ) > 0 ) {
+ if ( (vector3_dot( from, plane.normal() ) > 0) == (vector3_dot( to, plane.normal() ) > 0) ) {
first = vector3_negated( first );
second = vector3_negated( second );
}
Matrix4 swap = matrix4_swap_axes( first, second );
- Matrix4 tmp = matrix4_reflection_for_plane( plane );
-
swap.tx() = -static_cast<float>( -2 * plane.a * plane.d );
swap.ty() = -static_cast<float>( -2 * plane.b * plane.d );
swap.tz() = -static_cast<float>( -2 * plane.c * plane.d );
#include "preferences.h"
#include <list>
+#include <gdk/gdkkeysyms.h>
void Brush_ConstructCuboid( Brush& brush, const AABB& bounds, const char* shader, const TextureProjection& projection ){
const unsigned char box[3][2] = { { 0, 1 }, { 2, 0 }, { 1, 2 } };
}
-class FaceSetTexdef
-{
-const TextureProjection& m_projection;
-public:
-FaceSetTexdef( const TextureProjection& projection ) : m_projection( projection ){
-}
-void operator()( Face& face ) const {
- face.SetTexdef( m_projection );
-}
-};
-
void Scene_BrushSetTexdef_Selected( scene::Graph& graph, const TextureProjection& projection ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceSetTexdef( projection ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.SetTexdef(projection);
+ });
SceneChangeNotify();
}
void Scene_BrushSetTexdef_Component_Selected( scene::Graph& graph, const TextureProjection& projection ){
- Scene_ForEachSelectedBrushFace( graph, FaceSetTexdef( projection ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.SetTexdef(projection);
+ });
SceneChangeNotify();
}
-class FaceSetFlags
-{
-const ContentsFlagsValue& m_flags;
-public:
-FaceSetFlags( const ContentsFlagsValue& flags ) : m_flags( flags ){
-}
-void operator()( Face& face ) const {
- face.SetFlags( m_flags );
-}
-};
-
void Scene_BrushSetFlags_Selected( scene::Graph& graph, const ContentsFlagsValue& flags ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceSetFlags( flags ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.SetFlags(flags);
+ });
SceneChangeNotify();
}
void Scene_BrushSetFlags_Component_Selected( scene::Graph& graph, const ContentsFlagsValue& flags ){
- Scene_ForEachSelectedBrushFace( graph, FaceSetFlags( flags ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.SetFlags(flags);
+ });
SceneChangeNotify();
}
-class FaceShiftTexdef
-{
-float m_s, m_t;
-public:
-FaceShiftTexdef( float s, float t ) : m_s( s ), m_t( t ){
-}
-void operator()( Face& face ) const {
- face.ShiftTexdef( m_s, m_t );
-}
-};
-
void Scene_BrushShiftTexdef_Selected( scene::Graph& graph, float s, float t ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceShiftTexdef( s, t ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.ShiftTexdef(s, t);
+ });
SceneChangeNotify();
}
void Scene_BrushShiftTexdef_Component_Selected( scene::Graph& graph, float s, float t ){
- Scene_ForEachSelectedBrushFace( graph, FaceShiftTexdef( s, t ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.ShiftTexdef(s, t);
+ });
SceneChangeNotify();
}
-class FaceScaleTexdef
-{
-float m_s, m_t;
-public:
-FaceScaleTexdef( float s, float t ) : m_s( s ), m_t( t ){
-}
-void operator()( Face& face ) const {
- face.ScaleTexdef( m_s, m_t );
-}
-};
-
void Scene_BrushScaleTexdef_Selected( scene::Graph& graph, float s, float t ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceScaleTexdef( s, t ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.ScaleTexdef(s, t);
+ });
SceneChangeNotify();
}
void Scene_BrushScaleTexdef_Component_Selected( scene::Graph& graph, float s, float t ){
- Scene_ForEachSelectedBrushFace( graph, FaceScaleTexdef( s, t ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.ScaleTexdef(s, t);
+ });
SceneChangeNotify();
}
-class FaceRotateTexdef
-{
-float m_angle;
-public:
-FaceRotateTexdef( float angle ) : m_angle( angle ){
-}
-void operator()( Face& face ) const {
- face.RotateTexdef( m_angle );
-}
-};
-
void Scene_BrushRotateTexdef_Selected( scene::Graph& graph, float angle ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceRotateTexdef( angle ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.RotateTexdef(angle);
+ });
SceneChangeNotify();
}
void Scene_BrushRotateTexdef_Component_Selected( scene::Graph& graph, float angle ){
- Scene_ForEachSelectedBrushFace( graph, FaceRotateTexdef( angle ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.RotateTexdef(angle);
+ });
SceneChangeNotify();
}
-class FaceSetShader
-{
-const char* m_name;
-public:
-FaceSetShader( const char* name ) : m_name( name ) {}
-void operator()( Face& face ) const {
- face.SetShader( m_name );
-}
-};
-
void Scene_BrushSetShader_Selected( scene::Graph& graph, const char* name ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceSetShader( name ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.SetShader(name);
+ });
SceneChangeNotify();
}
void Scene_BrushSetShader_Component_Selected( scene::Graph& graph, const char* name ){
- Scene_ForEachSelectedBrushFace( graph, FaceSetShader( name ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.SetShader(name);
+ });
SceneChangeNotify();
}
-class FaceSetDetail
-{
-bool m_detail;
-public:
-FaceSetDetail( bool detail ) : m_detail( detail ){
-}
-void operator()( Face& face ) const {
- face.setDetail( m_detail );
-}
-};
-
void Scene_BrushSetDetail_Selected( scene::Graph& graph, bool detail ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceSetDetail( detail ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.setDetail(detail);
+ });
SceneChangeNotify();
}
return false;
}
-class FaceFindReplaceShader
-{
-const char* m_find;
-const char* m_replace;
-public:
-FaceFindReplaceShader( const char* find, const char* replace ) : m_find( find ), m_replace( replace ){
-}
-void operator()( Face& face ) const {
- Face_FindReplaceShader( face, m_find, m_replace );
-}
-};
-
-class FaceFindShader
-{
-const char* m_find;
-const char* m_replace;
-public:
-FaceFindShader( const char* find ) : m_find( find ){
-}
-void operator()( FaceInstance& faceinst ) const {
- if ( shader_equal( faceinst.getFace().GetShader(), m_find ) ) {
- faceinst.setSelected( SelectionSystem::eFace, true );
- }
-}
-};
-
bool DoingSearch( const char *repl ){
return ( repl == NULL || ( strcmp( "textures/", repl ) == 0 ) );
}
void Scene_BrushFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
if ( DoingSearch( replace ) ) {
- Scene_ForEachBrush_ForEachFaceInstance( graph, FaceFindShader( find ) );
+ Scene_ForEachBrush_ForEachFaceInstance(graph, [&](FaceInstance &faceinst) {
+ if (shader_equal(faceinst.getFace().GetShader(), find)) {
+ faceinst.setSelected(SelectionSystem::eFace, true);
+ }
+ });
}
else
{
- Scene_ForEachBrush_ForEachFace( graph, FaceFindReplaceShader( find, replace ) );
+ Scene_ForEachBrush_ForEachFace(graph, [&](Face &face) { Face_FindReplaceShader(face, find, replace); });
}
}
void Scene_BrushFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
if ( DoingSearch( replace ) ) {
- Scene_ForEachSelectedBrush_ForEachFaceInstance( graph,
- FaceFindShader( find ) );
+ Scene_ForEachSelectedBrush_ForEachFaceInstance(graph, [&](FaceInstance &faceinst) {
+ if (shader_equal(faceinst.getFace().GetShader(), find)) {
+ faceinst.setSelected(SelectionSystem::eFace, true);
+ }
+ });
}
else
{
- Scene_ForEachSelectedBrush_ForEachFace( graph,
- FaceFindReplaceShader( find, replace ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ Face_FindReplaceShader(face, find, replace);
+ });
}
}
}
else
{
- Scene_ForEachSelectedBrushFace( graph, FaceFindReplaceShader( find, replace ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ Face_FindReplaceShader(face, find, replace);
+ });
}
}
-class FaceFitTexture
-{
-float m_s_repeat, m_t_repeat;
-public:
-FaceFitTexture( float s_repeat, float t_repeat ) : m_s_repeat( s_repeat ), m_t_repeat( t_repeat ){
-}
-void operator()( Face& face ) const {
- face.FitTexture( m_s_repeat, m_t_repeat );
-}
-};
-
void Scene_BrushFitTexture_Selected( scene::Graph& graph, float s_repeat, float t_repeat ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceFitTexture( s_repeat, t_repeat ) );
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ face.FitTexture(s_repeat, t_repeat);
+ });
SceneChangeNotify();
}
void Scene_BrushFitTexture_Component_Selected( scene::Graph& graph, float s_repeat, float t_repeat ){
- Scene_ForEachSelectedBrushFace( graph, FaceFitTexture( s_repeat, t_repeat ) );
+ Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
+ face.FitTexture(s_repeat, t_repeat);
+ });
SceneChangeNotify();
}
TextureProjection g_defaultTextureProjection;
+
const TextureProjection& TextureTransform_getDefault(){
TexDef_Construct_Default( g_defaultTextureProjection );
return g_defaultTextureProjection;
BrushSelectByShaderWalker( const char* name )
: m_name( name ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Brush* brush = Node_getBrush( path.top() );
graph.traverse( BrushSelectByShaderWalker( name ) );
}
-class FaceSelectByShader
-{
-const char* m_name;
-public:
-FaceSelectByShader( const char* name )
- : m_name( name ){
-}
-void operator()( FaceInstance& face ) const {
- printf( "checking %s = %s\n", face.getFace().GetShader(), m_name );
- if ( shader_equal( face.getFace().GetShader(), m_name ) ) {
- face.setSelected( SelectionSystem::eFace, true );
- }
-}
-};
-
void Scene_BrushSelectByShader_Component( scene::Graph& graph, const char* name ){
- Scene_ForEachSelectedBrush_ForEachFaceInstance( graph, FaceSelectByShader( name ) );
-}
-
-class FaceGetTexdef
-{
-TextureProjection& m_projection;
-mutable bool m_done;
-public:
-FaceGetTexdef( TextureProjection& projection )
- : m_projection( projection ), m_done( false ){
-}
-void operator()( Face& face ) const {
- if ( !m_done ) {
- m_done = true;
- face.GetTexdef( m_projection );
+ Scene_ForEachSelectedBrush_ForEachFaceInstance(graph, [&](FaceInstance &face) {
+ printf("checking %s = %s\n", face.getFace().GetShader(), name);
+ if (shader_equal(face.getFace().GetShader(), name)) {
+ face.setSelected( SelectionSystem::eFace, true );
}
+ });
}
-};
-
void Scene_BrushGetTexdef_Selected( scene::Graph& graph, TextureProjection& projection ){
- Scene_ForEachSelectedBrush_ForEachFace( graph, FaceGetTexdef( projection ) );
+ bool done = false;
+ Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
+ if (!done) {
+ done = true;
+ face.GetTexdef(projection);
+}
+ });
}
void Scene_BrushGetTexdef_Component_Selected( scene::Graph& graph, TextureProjection& projection ){
}
-class FaceGetFlags
-{
-ContentsFlagsValue& m_flags;
-mutable bool m_done;
-public:
-FaceGetFlags( ContentsFlagsValue& flags )
- : m_flags( flags ), m_done( false ){
-}
-void operator()( Face& face ) const {
- if ( !m_done ) {
- m_done = true;
- face.GetFlags( m_flags );
- }
-}
-};
-
-
void Scene_BrushGetFlags_Selected( scene::Graph& graph, ContentsFlagsValue& flags ){
#if 1
if ( GlobalSelectionSystem().countSelected() != 0 ) {
BrushInstance* brush = Instance_getBrush( GlobalSelectionSystem().ultimateSelected() );
if ( brush != 0 ) {
- Brush_forEachFace( *brush, FaceGetFlags( flags ) );
+ bool done = false;
+ Brush_forEachFace(*brush, [&](Face &face) {
+ if (!done) {
+ done = true;
+ face.GetFlags(flags);
+ }
+ });
}
}
#else
}
-class FaceGetShader
-{
-CopiedString& m_shader;
-mutable bool m_done;
-public:
-FaceGetShader( CopiedString& shader )
- : m_shader( shader ), m_done( false ){
-}
-void operator()( Face& face ) const {
- if ( !m_done ) {
- m_done = true;
- m_shader = face.GetShader();
- }
-}
-};
-
void Scene_BrushGetShader_Selected( scene::Graph& graph, CopiedString& shader ){
#if 1
if ( GlobalSelectionSystem().countSelected() != 0 ) {
BrushInstance* brush = Instance_getBrush( GlobalSelectionSystem().ultimateSelected() );
if ( brush != 0 ) {
- Brush_forEachFace( *brush, FaceGetShader( shader ) );
+ bool done = false;
+ Brush_forEachFace(*brush, [&](Face &face) {
+ if (!done) {
+ done = true;
+ shader = face.GetShader();
+ }
+ });
}
}
#else
public:
filter_face_shader( const char* shader ) : m_shader( shader ){
}
+
bool filter( const Face& face ) const {
return shader_equal( face.GetShader(), m_shader );
}
public:
filter_face_shader_prefix( const char* prefix ) : m_prefix( prefix ){
}
+
bool filter( const Face& face ) const {
return shader_equal_n( face.GetShader(), m_prefix, strlen( m_prefix ) );
}
public:
filter_face_flags( int flags ) : m_flags( flags ){
}
+
bool filter( const Face& face ) const {
return ( face.getShader().shaderFlags() & m_flags ) != 0;
}
public:
filter_face_contents( int contents ) : m_contents( contents ){
}
+
bool filter( const Face& face ) const {
return ( face.getShader().m_flags.m_contentFlags & m_contents ) != 0;
}
-class FaceFilterAny
-{
-FaceFilter* m_filter;
-bool& m_filtered;
-public:
-FaceFilterAny( FaceFilter* filter, bool& filtered ) : m_filter( filter ), m_filtered( filtered ){
- m_filtered = false;
-}
-void operator()( Face& face ) const {
- if ( m_filter->filter( face ) ) {
- m_filtered = true;
- }
-}
-};
-
class filter_brush_any_face : public BrushFilter
{
FaceFilter* m_filter;
public:
filter_brush_any_face( FaceFilter* filter ) : m_filter( filter ){
}
+
bool filter( const Brush& brush ) const {
- bool filtered;
- Brush_forEachFace( brush, FaceFilterAny( m_filter, filtered ) );
+ bool filtered = false;
+ Brush_forEachFace(brush, [&](Face &face) {
+ if (m_filter->filter(face)) {
+ filtered = true;
+ }
+ });
return filtered;
}
};
-class FaceFilterAll
-{
-FaceFilter* m_filter;
-bool& m_filtered;
-public:
-FaceFilterAll( FaceFilter* filter, bool& filtered ) : m_filter( filter ), m_filtered( filtered ){
- m_filtered = true;
-}
-void operator()( Face& face ) const {
- if ( !m_filter->filter( face ) ) {
- m_filtered = false;
- }
-}
-};
-
class filter_brush_all_faces : public BrushFilter
{
FaceFilter* m_filter;
filter_brush_all_faces( FaceFilter* filter ) : m_filter( filter ){
}
bool filter( const Brush& brush ) const {
- bool filtered;
- Brush_forEachFace( brush, FaceFilterAll( m_filter, filtered ) );
+ bool filtered = true;
+ Brush_forEachFace(brush, [&](Face &face) {
+ if (!m_filter->filter(face)) {
+ filtered = false;
+ }
+ });
return filtered;
}
};
BrushMakeSided( std::size_t count )
: m_count( count ){
}
+
void set(){
Scene_BrushConstructPrefab( GlobalSceneGraph(), eBrushPrism, m_count, TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
}
-typedef MemberCaller<BrushMakeSided, &BrushMakeSided::set> SetCaller;
+
+typedef MemberCaller<BrushMakeSided, void(), &BrushMakeSided::set> SetCaller;
};
BrushPrefab( EBrushPrefab type )
: m_type( type ){
}
+
void set(){
DoSides( m_type, axis_for_viewtype( GetViewAxis() ) );
}
-typedef MemberCaller<BrushPrefab, &BrushPrefab::set> SetCaller;
+
+typedef MemberCaller<BrushPrefab, void(), &BrushPrefab::set> SetCaller;
};
BrushPrefab g_brushprism( eBrushPrism );
void FlipClip();
+
void SplitClip();
+
void Clip();
+
void OnClipMode( bool enable );
+
bool ClipMode();
}
-Callback g_texture_lock_status_changed;
-BoolExportCaller g_texdef_movelock_caller( g_brush_texturelock_enabled );
+Callback<void()> g_texture_lock_status_changed;
+ConstReferenceCaller<bool, void(const Callback<void(bool)> &), PropertyImpl<bool>::Export> g_texdef_movelock_caller( g_brush_texturelock_enabled );
ToggleItem g_texdef_movelock_item( g_texdef_movelock_caller );
void Texdef_ToggleMoveLock(){
}
-
-
-
void Brush_registerCommands(){
- GlobalToggles_insert( "TogTexLock", FreeCaller<Texdef_ToggleMoveLock>(), ToggleItem::AddCallbackCaller( g_texdef_movelock_item ), Accelerator( 'T', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalToggles_insert( "TogTexLock", makeCallbackF(Texdef_ToggleMoveLock), ToggleItem::AddCallbackCaller( g_texdef_movelock_item ), Accelerator( 'T', (GdkModifierType)GDK_SHIFT_MASK ) );
GlobalCommands_insert( "BrushPrism", BrushPrefab::SetCaller( g_brushprism ) );
GlobalCommands_insert( "BrushCone", BrushPrefab::SetCaller( g_brushcone ) );
GlobalCommands_insert( "Brush8Sided", BrushMakeSided::SetCaller( g_brushmakesided8 ), Accelerator( '8', (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "Brush9Sided", BrushMakeSided::SetCaller( g_brushmakesided9 ), Accelerator( '9', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "ClipSelected", FreeCaller<ClipSelected>(), Accelerator( GDK_Return ) );
- GlobalCommands_insert( "SplitSelected", FreeCaller<SplitSelected>(), Accelerator( GDK_Return, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "FlipClip", FreeCaller<FlipClipper>(), Accelerator( GDK_Return, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "ClipSelected", makeCallbackF(ClipSelected), Accelerator( GDK_KEY_Return ) );
+ GlobalCommands_insert( "SplitSelected", makeCallbackF(SplitSelected), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "FlipClip", makeCallbackF(FlipClipper), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "MakeDetail", FreeCaller<Select_MakeDetail>(), Accelerator( 'D', (GdkModifierType)GDK_MOD1_MASK ) );
- GlobalCommands_insert( "MakeStructural", FreeCaller<Select_MakeStructural>(), Accelerator( 'S', (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "MakeDetail", makeCallbackF(Select_MakeDetail), Accelerator( 'M', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "MakeStructural", makeCallbackF(Select_MakeStructural), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
}
-void Brush_constructMenu( GtkMenu* menu ){
+void Brush_constructMenu( ui::Menu menu ){
create_menu_item_with_mnemonic( menu, "Prism...", "BrushPrism" );
create_menu_item_with_mnemonic( menu, "Cone...", "BrushCone" );
create_menu_item_with_mnemonic( menu, "Sphere...", "BrushSphere" );
create_menu_item_with_mnemonic( menu, "Rock...", "BrushRock" );
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "CSG" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "CSG" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
create_menu_item_with_mnemonic( menu_in_menu, "CSG _Subtract", "CSGSubtract" );
create_menu_item_with_mnemonic( menu_in_menu, "CSG _Merge", "CSGMerge" );
- create_menu_item_with_mnemonic( menu_in_menu, "Make _Room", "CSGroom" );
+ create_menu_item_with_mnemonic( menu_in_menu, "Make _Room", "CSGRoom" );
create_menu_item_with_mnemonic( menu_in_menu, "CSG _Tool", "CSGTool" );
}
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Clipper" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Clipper" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
#define INCLUDED_BRUSHWRAPPER_H
#include <cstddef>
+#include <uilib/uilib.h>
#include "string/stringfwd.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
enum EBrushPrefab
{
void Scene_BrushFitTexture_Selected( scene::Graph& graph, float s_repeat, float t_repeat );
void Scene_BrushFitTexture_Component_Selected( scene::Graph& graph, float s_repeat, float t_repeat );
-typedef struct _GtkMenu GtkMenu;
-void Brush_constructMenu( GtkMenu* menu );
+void Brush_constructMenu( ui::Menu menu );
-extern Callback g_texture_lock_status_changed;
+extern Callback<void()> g_texture_lock_status_changed;
void BrushFilters_construct();
void Brush_registerCommands();
#include "mainframe.h"
#include "preferences.h"
-LatchedBool g_useAlternativeTextureProjection( false, "Use alternative texture-projection (\"brush primitives\")" );
+LatchedValue<bool> g_useAlternativeTextureProjection( false, "Use alternative texture-projection (\"brush primitives\")" );
bool g_showAlternativeTextureProjectionOption = false;
bool g_brush_always_caulk;
return g_brush_texturelock_enabled;
}
-void Face_importSnapPlanes( bool value ){
- Face::m_quantise = value ? quantiseInteger : quantiseFloating;
-}
-typedef FreeCaller1<bool, Face_importSnapPlanes> FaceImportSnapPlanesCaller;
+struct Face_SnapPlanes {
+ static void Export(const QuantiseFunc &self, const Callback<void(bool)> &returnz) {
+ returnz(self == quantiseInteger);
+ }
-void Face_exportSnapPlanes( const BoolImportCallback& importer ){
- importer( Face::m_quantise == quantiseInteger );
-}
-typedef FreeCaller1<const BoolImportCallback&, Face_exportSnapPlanes> FaceExportSnapPlanesCaller;
+ static void Import(QuantiseFunc &self, bool value) {
+ self = value ? quantiseInteger : quantiseFloating;
+ }
+};
void Brush_constructPreferences( PreferencesPage& page ){
page.appendCheckBox(
"", "Snap planes to integer grid",
- FaceImportSnapPlanesCaller(),
- FaceExportSnapPlanesCaller()
+ make_property<Face_SnapPlanes>(Face::m_quantise)
);
page.appendEntry(
"Default texture scale",
if ( g_showAlternativeTextureProjectionOption ) {
page.appendCheckBox(
"", "Use alternative texture-projection (\"brush primitives\")",
- LatchedBoolImportCaller( g_useAlternativeTextureProjection ),
- BoolExportCaller( g_useAlternativeTextureProjection.m_latched )
+ make_property(g_useAlternativeTextureProjection)
);
}
// d1223m
Brush_constructPreferences( page );
}
void Brush_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Brush_constructPage>() );
+ PreferencesDialog_addSettingsPage( makeCallbackF(Brush_constructPage) );
}
void Brush_unlatchPreferences(){
GlobalPreferenceSystem().registerPreference(
"AlternativeTextureProjection",
- BoolImportStringCaller( g_useAlternativeTextureProjection.m_latched ),
- BoolExportStringCaller( g_useAlternativeTextureProjection.m_latched )
+ make_property_string( g_useAlternativeTextureProjection.m_latched )
);
g_useAlternativeTextureProjection.useLatched();
// d1223m
GlobalPreferenceSystem().registerPreference(
"BrushAlwaysCaulk",
- BoolImportStringCaller( g_brush_always_caulk ),
- BoolExportStringCaller( g_brush_always_caulk ) );
+ make_property_string( g_brush_always_caulk )
+ );
}
Brush_registerCommands();
}
}
- GlobalPreferenceSystem().registerPreference( "TextureLock", BoolImportStringCaller( g_brush_texturelock_enabled ), BoolExportStringCaller( g_brush_texturelock_enabled ) );
- GlobalPreferenceSystem().registerPreference( "BrushSnapPlanes", makeBoolStringImportCallback( FaceImportSnapPlanesCaller() ), makeBoolStringExportCallback( FaceExportSnapPlanesCaller() ) );
- GlobalPreferenceSystem().registerPreference( "TexdefDefaultScale", FloatImportStringCaller( g_texdef_default_scale ), FloatExportStringCaller( g_texdef_default_scale ) );
+ GlobalPreferenceSystem().registerPreference( "TextureLock", make_property_string( g_brush_texturelock_enabled ) );
+ GlobalPreferenceSystem().registerPreference("BrushSnapPlanes", make_property_string<Face_SnapPlanes>(Face::m_quantise));
+ GlobalPreferenceSystem().registerPreference( "TexdefDefaultScale", make_property_string( g_texdef_default_scale ) );
GridStatus_getTextureLockEnabled = getTextureLockEnabled;
- g_texture_lock_status_changed = FreeCaller<GridStatus_onTextureLockEnabledChanged>();
+ g_texture_lock_status_changed = makeCallbackF(GridStatus_onTextureLockEnabledChanged);
}
void Brush_Destroy(){
faceData.value = face.getShader().m_flags.m_value;
callback( faceData );
}
-typedef ConstReferenceCaller1<BrushFaceDataCallback, Face&, BrushFaceData_fromFace> BrushFaceDataFromFaceCaller;
-typedef Callback1<Face&> FaceCallback;
+typedef ConstReferenceCaller<BrushFaceDataCallback, void(Face&), BrushFaceData_fromFace> BrushFaceDataFromFaceCaller;
+typedef Callback<void(Face&)> FaceCallback;
class Quake3BrushCreator : public BrushCreator
{
#include "build.h"
#include "debugging/debugging.h"
+#include <gtk/gtk.h>
#include <map>
#include <list>
#include "stream/stringstream.h"
class Evaluatable
{
public:
+virtual ~Evaluatable() = default;
virtual void evaluate( StringBuffer& output ) = 0;
virtual void exportXML( XMLImporter& importer ) = 0;
};
class XMLElementParser : public TextOutputStream
{
public:
+virtual ~XMLElementParser() = default;
virtual XMLElementParser& pushElement( const XMLElement& element ) = 0;
virtual void popElement( const char* name ) = 0;
};
};
typedef std::pair<CopiedString, Build> BuildPair;
-#define SEPARATOR_STRING "-"
+const char *SEPARATOR_STRING = "-";
static bool is_separator( const BuildPair &p ){
if ( !string_equal( p.first.c_str(), SEPARATOR_STRING ) ) {
return false;
}
-class BuildPairEqual
-{
-const char* m_name;
-public:
-BuildPairEqual( const char* name ) : m_name( name ){
-}
-bool operator()( const BuildPair& self ) const {
- return string_equal( self.first.c_str(), m_name );
-}
-};
-
typedef std::list<BuildPair> Project;
Project::iterator Project_find( Project& project, const char* name ){
- return std::find_if( project.begin(), project.end(), BuildPairEqual( name ) );
+ return std::find_if(project.begin(), project.end(), [&](const BuildPair &self) {
+ return string_equal(self.first.c_str(), name);
+ });
}
Project::iterator Project_find( Project& project, std::size_t index ){
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkbox.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkliststore.h>
-#include <gtk/gtkscrolledwindow.h>
#include "gtkutil/dialog.h"
#include "gtkutil/closure.h"
#include "gtkutil/window.h"
#include "gtkdlgs.h"
-void Build_refreshMenu( GtkMenu* menu );
+void Build_refreshMenu( ui::Menu menu );
-void BSPCommandList_Construct( GtkListStore* store, Project& project ){
- gtk_list_store_clear( store );
+void BSPCommandList_Construct( ui::ListStore store, Project& project ){
+ store.clear();
for ( Project::iterator i = project.begin(); i != project.end(); ++i )
{
- const char* buildName = ( *i ).first.c_str();
-
- GtkTreeIter buildIter;
- gtk_list_store_append( store, &buildIter );
- gtk_list_store_set( store, &buildIter, 0, const_cast<char*>( buildName ), -1 );
+ store.append(0, (*i).first.c_str());
}
- GtkTreeIter lastIter;
- gtk_list_store_append( store, &lastIter );
+ store.append();
}
class ProjectList
{
public:
Project& m_project;
-GtkListStore* m_store;
+ui::ListStore m_store{ui::null};
GtkWidget* m_buildView;
bool m_changed;
ProjectList( Project& project ) : m_project( project ), m_changed( false ){
}
};
-gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, ProjectList* projectList ){
+gboolean project_cell_edited(ui::CellRendererText cell, gchar* path_string, gchar* new_text, ProjectList* projectList ){
Project& project = projectList->m_project;
- GtkTreePath* path = gtk_tree_path_new_from_string( path_string );
+ auto path = ui::TreePath( path_string );
ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" );
GtkTreeIter iter;
- gtk_tree_model_get_iter( GTK_TREE_MODEL( projectList->m_store ), &iter, path );
+ gtk_tree_model_get_iter(projectList->m_store, &iter, path );
Project::iterator i = Project_find( project, gtk_tree_path_get_indices( path )[0] );
if ( i != project.end() ) {
project.push_back( Project::value_type( new_text, Build() ) );
gtk_list_store_set( projectList->m_store, &iter, 0, new_text, -1 );
- GtkTreeIter lastIter;
- gtk_list_store_append( projectList->m_store, &lastIter );
+ projectList->m_store.append();
//make command field activatable
g_signal_emit_by_name( G_OBJECT( gtk_tree_view_get_selection( GTK_TREE_VIEW( projectList->m_buildView ) ) ), "changed" );
}
return FALSE;
}
-gboolean project_key_press( GtkWidget* widget, GdkEventKey* event, ProjectList* projectList ){
+gboolean project_key_press( ui::TreeView widget, GdkEventKey* event, ProjectList* projectList ){
Project& project = projectList->m_project;
- if ( event->keyval == GDK_Delete ) {
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( widget ) );
+ if ( event->keyval == GDK_KEY_Delete ) {
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(widget));
GtkTreeIter iter;
GtkTreeModel* model;
if ( gtk_tree_selection_get_selected( selection, &model, &iter ) ) {
- GtkTreePath* path = gtk_tree_model_get_path( model, &iter );
+ auto path = gtk_tree_model_get_path( model, &iter );
Project::iterator x = Project_find( project, gtk_tree_path_get_indices( path )[0] );
gtk_tree_path_free( path );
Build* g_current_build = 0;
-gboolean project_selection_changed( GtkTreeSelection* selection, GtkListStore* store ){
+gboolean project_selection_changed( ui::TreeSelection selection, ui::ListStore store ){
Project& project = g_build_project;
- gtk_list_store_clear( store );
+ store.clear();
GtkTreeIter iter;
GtkTreeModel* model;
if ( gtk_tree_selection_get_selected( selection, &model, &iter ) ) {
- GtkTreePath* path = gtk_tree_model_get_path( model, &iter );
+ auto path = gtk_tree_model_get_path( model, &iter );
Project::iterator x = Project_find( project, gtk_tree_path_get_indices( path )[0] );
gtk_tree_path_free( path );
for ( Build::iterator i = build.begin(); i != build.end(); ++i )
{
- GtkTreeIter commandIter;
- gtk_list_store_append( store, &commandIter );
- gtk_list_store_set( store, &commandIter, 0, const_cast<char*>( ( *i ).c_str() ), -1 );
+ store.append(0, (*i).c_str());
}
- GtkTreeIter lastIter;
- gtk_list_store_append( store, &lastIter );
+ store.append();
}
else
{
return FALSE;
}
-gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gchar* new_text, GtkListStore* store ){
+gboolean commands_cell_edited(ui::CellRendererText cell, gchar* path_string, gchar* new_text, ui::ListStore store ){
if ( g_current_build == 0 ) {
return FALSE;
}
Build& build = *g_current_build;
- GtkTreePath* path = gtk_tree_path_new_from_string( path_string );
+ auto path = ui::TreePath( path_string );
ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" );
GtkTreeIter iter;
- gtk_tree_model_get_iter( GTK_TREE_MODEL( store ), &iter, path );
+ gtk_tree_model_get_iter(store, &iter, path );
Build::iterator i = Build_find( build, gtk_tree_path_get_indices( path )[0] );
if ( i != build.end() ) {
gtk_list_store_set( store, &iter, 0, new_text, -1 );
- GtkTreeIter lastIter;
- gtk_list_store_append( store, &lastIter );
+ store.append();
}
gtk_tree_path_free( path );
return FALSE;
}
-gboolean commands_key_press( GtkWidget* widget, GdkEventKey* event, GtkListStore* store ){
+gboolean commands_key_press( ui::TreeView widget, GdkEventKey* event, ui::ListStore store ){
if ( g_current_build == 0 ) {
return FALSE;
}
Build& build = *g_current_build;
- if ( event->keyval == GDK_Delete ) {
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( widget ) );
+ if ( event->keyval == GDK_KEY_Delete ) {
+ auto selection = gtk_tree_view_get_selection(widget );
GtkTreeIter iter;
GtkTreeModel* model;
if ( gtk_tree_selection_get_selected( selection, &model, &iter ) ) {
- GtkTreePath* path = gtk_tree_model_get_path( model, &iter );
+ auto path = gtk_tree_model_get_path( model, &iter );
Build::iterator i = Build_find( build, gtk_tree_path_get_indices( path )[0] );
gtk_tree_path_free( path );
}
-GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectList ){
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Build Menu", G_CALLBACK( dialog_delete_callback ), &modal, -1, 400 );
-
- GtkWidget* buildView = 0;
+ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectList ){
+ ui::Window window = MainFrame_getWindow().create_dialog_window("Build Menu", G_CALLBACK(dialog_delete_callback ), &modal, -1, 400 );
{
- GtkTable* table1 = create_dialog_table( 2, 2, 4, 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( table1 ) );
+ auto table1 = create_dialog_table( 2, 2, 4, 4, 4 );
+ window.add(table1);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_table_attach( table1, GTK_WIDGET( vbox ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ table1.attach(vbox, {1, 2, 0, 1}, {GTK_FILL, GTK_FILL});
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &modal );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &modal );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
}
}
+ auto buildViewStore = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
+ auto buildView = ui::TreeView( ui::TreeModel::from( buildViewStore._handle ));
{
- GtkFrame* frame = create_dialog_frame( "Build menu" );
- gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ auto frame = create_dialog_frame( "Build menu" );
+ table1.attach(frame, {0, 1, 0, 1});
{
- GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( scr ) );
+ auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
+ frame.add(scr);
{
- GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING );
+ auto view = buildView;
+ auto store = buildViewStore;
+ gtk_tree_view_set_headers_visible(view, FALSE );
- GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
-
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+ auto renderer = ui::CellRendererText(ui::New);
object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE );
- g_signal_connect( renderer, "edited", G_CALLBACK( project_cell_edited ), &projectList );
+ renderer.connect("edited", G_CALLBACK( project_cell_edited ), &projectList );
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
+ auto selection = gtk_tree_view_get_selection(view );
gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE );
- gtk_widget_show( view );
+ view.show();
- buildView = view;
projectList.m_buildView = buildView;
projectList.m_store = store;
- gtk_container_add( GTK_CONTAINER( scr ), view );
+ scr.add(view);
- g_signal_connect( G_OBJECT( view ), "key_press_event", G_CALLBACK( project_key_press ), &projectList );
+ view.connect( "key_press_event", G_CALLBACK( project_key_press ), &projectList );
- g_object_unref( G_OBJECT( store ) );
+ store.unref();
}
}
}
{
- GtkFrame* frame = create_dialog_frame( "Commandline" );
- gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
+ auto frame = create_dialog_frame( "Commandline" );
+ table1.attach(frame, {0, 1, 1, 2});
{
- GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( scr ) );
+ auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
+ frame.add(scr);
{
- GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING );
+ auto store = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
- GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
+ auto view = ui::TreeView(ui::TreeModel::from( store._handle ));
+ gtk_tree_view_set_headers_visible(view, FALSE );
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+ auto renderer = ui::CellRendererText(ui::New);
object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE );
g_object_set( G_OBJECT( renderer ), "wrap-mode", PANGO_WRAP_WORD, NULL );
//g_object_set( G_OBJECT( renderer ), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, NULL );
object_set_int_property( G_OBJECT( renderer ), "wrap-width", 640 );
- g_signal_connect( renderer, "edited", G_CALLBACK( commands_cell_edited ), store );
+ renderer.connect( "edited", G_CALLBACK( commands_cell_edited ), store );
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
+ auto selection = gtk_tree_view_get_selection(view );
gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE );
- gtk_widget_show( view );
+ view.show();
- gtk_container_add( GTK_CONTAINER( scr ), view );
+ scr.add(view);
- g_object_unref( G_OBJECT( store ) );
+ store.unref();
- g_signal_connect( G_OBJECT( view ), "key_press_event", G_CALLBACK( commands_key_press ), store );
+ view.connect( "key_press_event", G_CALLBACK( commands_key_press ), store );
- g_signal_connect( G_OBJECT( gtk_tree_view_get_selection( GTK_TREE_VIEW( buildView ) ) ), "changed", G_CALLBACK( project_selection_changed ), store );
+ auto sel = ui::TreeSelection::from(gtk_tree_view_get_selection(buildView ));
+ sel.connect( "changed", G_CALLBACK( project_selection_changed ), store );
}
}
}
ProjectList projectList( g_build_project );
- GtkWindow* window = BuildMenuDialog_construct( modal, projectList );
+ ui::Window window = BuildMenuDialog_construct( modal, projectList );
if ( modal_dialog_show( window, modal ) == eIDCANCEL ) {
build_commands_clear();
g_build_changed = true;
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
}
#include "preferences.h"
#include "qe3.h"
-typedef struct _GtkMenuItem GtkMenuItem;
-
class BuildMenuItem
{
const char* m_name;
public:
-GtkMenuItem* m_item;
-BuildMenuItem( const char* name, GtkMenuItem* item )
+ui::MenuItem m_item;
+BuildMenuItem( const char* name, ui::MenuItem item )
: m_name( name ), m_item( item ){
}
void run(){
g_lastExecutedBuild = m_name;
RunBSP( m_name );
}
-typedef MemberCaller<BuildMenuItem, &BuildMenuItem::run> RunCaller;
+typedef MemberCaller<BuildMenuItem, void(), &BuildMenuItem::run> RunCaller;
};
typedef std::list<BuildMenuItem> BuildMenuItems;
BuildMenuItems g_BuildMenuItems;
-GtkMenu* g_bsp_menu;
+ui::Menu g_bsp_menu{ui::null};
-void Build_constructMenu( GtkMenu* menu ){
+void Build_constructMenu( ui::Menu menu ){
for ( Project::iterator i = g_build_project.begin(); i != g_build_project.end(); ++i )
{
- g_BuildMenuItems.push_back( BuildMenuItem( ( *i ).first.c_str(), 0 ) );
+ g_BuildMenuItems.push_back( BuildMenuItem( ( *i ).first.c_str(), ui::MenuItem(ui::null) ) );
if ( is_separator( *i ) ) {
g_BuildMenuItems.back().m_item = menu_separator( menu );
}
}
-void Build_refreshMenu( GtkMenu* menu ){
- for ( BuildMenuItems::iterator i = g_BuildMenuItems.begin(); i != g_BuildMenuItems.end(); ++i )
+void Build_refreshMenu( ui::Menu menu ){
+ for (auto i = g_BuildMenuItems.begin(); i != g_BuildMenuItems.end(); ++i )
{
- gtk_container_remove( GTK_CONTAINER( menu ), GTK_WIDGET( ( *i ).m_item ) );
+ menu.remove(ui::MenuItem(i->m_item));
}
g_BuildMenuItems.clear();
#include "stringio.h"
void BuildMenu_Construct(){
- GlobalPreferenceSystem().registerPreference( "BuildMenu", CopiedStringImportStringCaller( g_buildMenu ), CopiedStringExportStringCaller( g_buildMenu ) );
+ GlobalPreferenceSystem().registerPreference( "BuildMenu", make_property_string( g_buildMenu ) );
LoadBuildMenu();
}
void BuildMenu_Destroy(){
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_BUILD_H )
#define INCLUDED_BUILD_H
void BuildMenu_Construct();
void BuildMenu_Destroy();
-typedef struct _GtkMenu GtkMenu;
-void Build_constructMenu( GtkMenu* menu );
-extern GtkMenu* g_bsp_menu;
+void Build_constructMenu( ui::Menu menu );
+extern ui::Menu g_bsp_menu;
void Build_runRecentExecutedBuild();
#include "camwindow.h"
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
#include "debugging/debugging.h"
#include "iscenegraph.h"
}
View* m_view;
- Callback m_update;
+ Callback<void()> m_update;
static camera_draw_mode draw_mode;
- camera_t( View* view, const Callback& update )
+ camera_t( View* view, const Callback<void()>& update )
: width( 0 ),
height( 0 ),
timing( false ),
}
void Cam_MouseControl( camera_t& camera, int x, int y ){
-// int xl, xh;
-// int yl, yh;
- float xf, yf;
-
- xf = (float)( x - camera.width / 2 ) / ( camera.width / 2 );
- yf = (float)( y - camera.height / 2 ) / ( camera.height / 2 );
-
-// xl = camera.width / 3;
-// xh = xl * 2;
-// yl = camera.height / 3;
-// yh = yl * 2;
+ float xf = (float)( x - camera.width / 2 ) / ( camera.width / 2 );
+ float yf = (float)( y - camera.height / 2 ) / ( camera.height / 2 );
xf *= 1.0f - fabsf( yf );
if ( xf < 0 ) {
}
-typedef ReferenceCaller<camera_t, &Camera_MoveForward_KeyDown> FreeMoveCameraMoveForwardKeyDownCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveForward_KeyUp> FreeMoveCameraMoveForwardKeyUpCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveBack_KeyDown> FreeMoveCameraMoveBackKeyDownCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveBack_KeyUp> FreeMoveCameraMoveBackKeyUpCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveLeft_KeyDown> FreeMoveCameraMoveLeftKeyDownCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveLeft_KeyUp> FreeMoveCameraMoveLeftKeyUpCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveRight_KeyDown> FreeMoveCameraMoveRightKeyDownCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveRight_KeyUp> FreeMoveCameraMoveRightKeyUpCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveUp_KeyDown> FreeMoveCameraMoveUpKeyDownCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveUp_KeyUp> FreeMoveCameraMoveUpKeyUpCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveDown_KeyDown> FreeMoveCameraMoveDownKeyDownCaller;
-typedef ReferenceCaller<camera_t, &Camera_MoveDown_KeyUp> FreeMoveCameraMoveDownKeyUpCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveForward_KeyDown> FreeMoveCameraMoveForwardKeyDownCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveForward_KeyUp> FreeMoveCameraMoveForwardKeyUpCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveBack_KeyDown> FreeMoveCameraMoveBackKeyDownCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveBack_KeyUp> FreeMoveCameraMoveBackKeyUpCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveLeft_KeyDown> FreeMoveCameraMoveLeftKeyDownCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveLeft_KeyUp> FreeMoveCameraMoveLeftKeyUpCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveRight_KeyDown> FreeMoveCameraMoveRightKeyDownCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveRight_KeyUp> FreeMoveCameraMoveRightKeyUpCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveUp_KeyDown> FreeMoveCameraMoveUpKeyDownCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveUp_KeyUp> FreeMoveCameraMoveUpKeyUpCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveDown_KeyDown> FreeMoveCameraMoveDownKeyDownCaller;
+typedef ReferenceCaller<camera_t, void(), &Camera_MoveDown_KeyUp> FreeMoveCameraMoveDownKeyUpCaller;
-#define SPEED_MOVE 32
-#define SPEED_TURN 22.5
-#define MIN_CAM_SPEED 10
-#define MAX_CAM_SPEED 610
-#define CAM_SPEED_STEP 50
+const float SPEED_MOVE = 32;
+const float SPEED_TURN = 22.5;
+const float MIN_CAM_SPEED = 10;
+const float MAX_CAM_SPEED = 610;
+const float CAM_SPEED_STEP = 50;
void Camera_MoveForward_Discrete( camera_t& camera ){
Camera_Move_updateAxes( camera );
{
camera_t& m_camera;
View* m_view;
-Callback m_update;
+Callback<void()> m_update;
public:
-RadiantCameraView( camera_t& camera, View* view, const Callback& update ) : m_camera( camera ), m_view( view ), m_update( update ){
+RadiantCameraView( camera_t& camera, View* view, const Callback<void()>& update ) : m_camera( camera ), m_view( view ), m_update( update ){
}
void update(){
m_view->Construct( m_camera.projection, m_camera.modelview, m_camera.width, m_camera.height );
FreezePointer m_freezePointer;
public:
-GtkWidget* m_gl_widget;
-GtkWindow* m_parent;
+ui::GLArea m_gl_widget;
+ui::Window m_parent{ui::null};
SelectionSystemWindowObserver* m_window_observer;
XORRectangle m_XORRectangle;
void Cam_Draw();
};
-typedef MemberCaller<CamWnd, &CamWnd::queue_draw> CamWndQueueDraw;
+typedef MemberCaller<CamWnd, void(), &CamWnd::queue_draw> CamWndQueueDraw;
Shader* CamWnd::m_state_select1 = 0;
Shader* CamWnd::m_state_select2 = 0;
}
-GtkWidget* CamWnd_getWidget( CamWnd& camwnd ){
+ui::GLArea CamWnd_getWidget( CamWnd& camwnd ){
return camwnd.m_gl_widget;
}
-GtkWindow* CamWnd_getParent( CamWnd& camwnd ){
+ui::Window CamWnd_getParent( CamWnd& camwnd ){
return camwnd.m_parent;
}
ToggleShown g_camera_shown( true );
-void CamWnd_setParent( CamWnd& camwnd, GtkWindow* parent ){
+void CamWnd_setParent( CamWnd& camwnd, ui::Window parent ){
camwnd.m_parent = parent;
- g_camera_shown.connect( GTK_WIDGET( camwnd.m_parent ) );
+ g_camera_shown.connect( camwnd.m_parent );
}
void CamWnd_Update( CamWnd& camwnd ){
// =============================================================================
// CamWnd class
-gboolean enable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){
+gboolean enable_freelook_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){
if ( event->type == GDK_BUTTON_PRESS && event->button == 3 && modifiers_for_state( event->state ) == c_modifierNone ) {
camwnd->EnableFreeMove();
return TRUE;
return FALSE;
}
-gboolean disable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){
+gboolean disable_freelook_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){
if ( event->type == GDK_BUTTON_PRESS && event->button == 3 && modifiers_for_state( event->state ) == c_modifierNone ) {
camwnd->DisableFreeMove();
return TRUE;
}
#if 0
-gboolean mousecontrol_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){
+gboolean mousecontrol_button_press( ui::Widget widget, GdkEventButton* event, CamWnd* camwnd ){
if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) {
Cam_MouseControl( camwnd->getCamera(), event->x, widget->allocation.height - 1 - event->y );
}
#endif
void camwnd_update_xor_rectangle( CamWnd& self, rect_t area ){
- if ( GTK_WIDGET_VISIBLE( self.m_gl_widget ) ) {
+ if ( self.m_gl_widget.visible() ) {
self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.getCamera().width, self.getCamera().height ) );
}
}
-gboolean selection_button_press( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){
+gboolean selection_button_press( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){
if ( event->type == GDK_BUTTON_PRESS ) {
observer->onMouseDown( WindowVector_forDouble( event->x, event->y ), button_for_button( event->button ), modifiers_for_state( event->state ) );
}
return FALSE;
}
-gboolean selection_button_release( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){
+gboolean selection_button_release( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){
if ( event->type == GDK_BUTTON_RELEASE ) {
observer->onMouseUp( WindowVector_forDouble( event->x, event->y ), button_for_button( event->button ), modifiers_for_state( event->state ) );
}
reinterpret_cast<WindowObserver*>( data )->onMouseMotion( WindowVector_forDouble( x, y ), modifiers_for_state( state ) );
}
-inline WindowVector windowvector_for_widget_centre( GtkWidget* widget ){
- return WindowVector( static_cast<float>( widget->allocation.width / 2 ), static_cast<float>( widget->allocation.height / 2 ) );
+inline WindowVector windowvector_for_widget_centre( ui::Widget widget ){
+ auto allocation = widget.dimensions();
+ return WindowVector( static_cast<float>( allocation.width / 2 ), static_cast<float>(allocation.height / 2 ) );
}
-gboolean selection_button_press_freemove( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){
+gboolean selection_button_press_freemove( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){
if ( event->type == GDK_BUTTON_PRESS ) {
observer->onMouseDown( windowvector_for_widget_centre( widget ), button_for_button( event->button ), modifiers_for_state( event->state ) );
}
return FALSE;
}
-gboolean selection_button_release_freemove( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){
+gboolean selection_button_release_freemove( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){
if ( event->type == GDK_BUTTON_RELEASE ) {
observer->onMouseUp( windowvector_for_widget_centre( widget ), button_for_button( event->button ), modifiers_for_state( event->state ) );
}
return FALSE;
}
-gboolean selection_motion_freemove( GtkWidget *widget, GdkEventMotion *event, WindowObserver* observer ){
+gboolean selection_motion_freemove( ui::Widget widget, GdkEventMotion *event, WindowObserver* observer ){
observer->onMouseMotion( windowvector_for_widget_centre( widget ), modifiers_for_state( event->state ) );
return FALSE;
}
-gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* camwnd ){
+gboolean wheelmove_scroll( ui::Widget widget, GdkEventScroll* event, CamWnd* camwnd ){
if ( event->direction == GDK_SCROLL_UP ) {
Camera_Freemove_updateAxes( camwnd->getCamera() );
Camera_setOrigin( *camwnd, vector3_added( Camera_getOrigin( *camwnd ), vector3_scaled( camwnd->getCamera().forward, static_cast<float>( g_camwindow_globals_private.m_nMoveSpeed ) ) ) );
return FALSE;
}
-gboolean camera_size_allocate( GtkWidget* widget, GtkAllocation* allocation, CamWnd* camwnd ){
+gboolean camera_size_allocate( ui::Widget widget, GtkAllocation* allocation, CamWnd* camwnd ){
camwnd->getCamera().width = allocation->width;
camwnd->getCamera().height = allocation->height;
Camera_updateProjection( camwnd->getCamera() );
return FALSE;
}
-gboolean camera_expose( GtkWidget* widget, GdkEventExpose* event, gpointer data ){
+gboolean camera_expose( ui::Widget widget, GdkEventExpose* event, gpointer data ){
reinterpret_cast<CamWnd*>( data )->draw();
return FALSE;
}
void CamWnd_registerCommands( CamWnd& camwnd ){
GlobalKeyEvents_insert( "CameraForward", accelerator_null(),
- ReferenceCaller<camera_t, Camera_MoveForward_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_MoveForward_KeyUp>( camwnd.getCamera() )
+ ReferenceCaller<camera_t, void(), Camera_MoveForward_KeyDown>( camwnd.getCamera() ),
+ ReferenceCaller<camera_t, void(), Camera_MoveForward_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraBack", accelerator_null(),
- ReferenceCaller<camera_t, Camera_MoveBack_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_MoveBack_KeyUp>( camwnd.getCamera() )
+ ReferenceCaller<camera_t, void(), Camera_MoveBack_KeyDown>( camwnd.getCamera() ),
+ ReferenceCaller<camera_t, void(), Camera_MoveBack_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraLeft", accelerator_null(),
- ReferenceCaller<camera_t, Camera_RotateLeft_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_RotateLeft_KeyUp>( camwnd.getCamera() )
+ ReferenceCaller<camera_t, void(), Camera_RotateLeft_KeyDown>( camwnd.getCamera() ),
+ ReferenceCaller<camera_t, void(), Camera_RotateLeft_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraRight", accelerator_null(),
- ReferenceCaller<camera_t, Camera_RotateRight_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_RotateRight_KeyUp>( camwnd.getCamera() )
+ ReferenceCaller<camera_t, void(), Camera_RotateRight_KeyDown>( camwnd.getCamera() ),
+ ReferenceCaller<camera_t, void(), Camera_RotateRight_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraStrafeRight", accelerator_null(),
- ReferenceCaller<camera_t, Camera_MoveRight_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_MoveRight_KeyUp>( camwnd.getCamera() )
+ ReferenceCaller<camera_t, void(), Camera_MoveRight_KeyDown>( camwnd.getCamera() ),
+ ReferenceCaller<camera_t, void(), Camera_MoveRight_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraStrafeLeft", accelerator_null(),
- ReferenceCaller<camera_t, Camera_MoveLeft_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_MoveLeft_KeyUp>( camwnd.getCamera() )
+ ReferenceCaller<camera_t, void(), Camera_MoveLeft_KeyDown>( camwnd.getCamera() ),
+ ReferenceCaller<camera_t, void(), Camera_MoveLeft_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraUp", accelerator_null(),
- ReferenceCaller<camera_t, Camera_MoveUp_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_MoveUp_KeyUp>( camwnd.getCamera() )
+ ReferenceCaller<camera_t, void(), Camera_MoveUp_KeyDown>( camwnd.getCamera() ),
+ ReferenceCaller<camera_t, void(), Camera_MoveUp_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraDown", accelerator_null(),
- ReferenceCaller<camera_t, Camera_MoveDown_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_MoveDown_KeyUp>( camwnd.getCamera() )
+ ReferenceCaller<camera_t, void(), Camera_MoveDown_KeyDown>( camwnd.getCamera() ),
+ ReferenceCaller<camera_t, void(), Camera_MoveDown_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraAngleUp", accelerator_null(),
- ReferenceCaller<camera_t, Camera_PitchUp_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_PitchUp_KeyUp>( camwnd.getCamera() )
+ ReferenceCaller<camera_t, void(), Camera_PitchUp_KeyDown>( camwnd.getCamera() ),
+ ReferenceCaller<camera_t, void(), Camera_PitchUp_KeyUp>( camwnd.getCamera() )
);
GlobalKeyEvents_insert( "CameraAngleDown", accelerator_null(),
- ReferenceCaller<camera_t, Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
- ReferenceCaller<camera_t, Camera_PitchDown_KeyUp>( camwnd.getCamera() )
+ ReferenceCaller<camera_t, void(), Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
+ ReferenceCaller<camera_t, void(), Camera_PitchDown_KeyUp>( camwnd.getCamera() )
);
+
GlobalKeyEvents_insert( "CameraFreeMoveForward", accelerator_null(),
FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ),
FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() )
FreeMoveCameraMoveDownKeyUpCaller( camwnd.getCamera() )
);
- GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, Camera_MoveForward_Discrete>( camwnd.getCamera() ) );
- GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, Camera_MoveBack_Discrete>( camwnd.getCamera() ) );
- GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, Camera_RotateLeft_Discrete>( camwnd.getCamera() ) );
- GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, Camera_RotateRight_Discrete>( camwnd.getCamera() ) );
- GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, Camera_MoveRight_Discrete>( camwnd.getCamera() ) );
- GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, Camera_MoveLeft_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, void(), Camera_MoveForward_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, void(), Camera_MoveBack_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, void(), Camera_RotateLeft_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, void(), Camera_RotateRight_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, void(), Camera_MoveRight_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, void(), Camera_MoveLeft_Discrete>( camwnd.getCamera() ) );
- GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, Camera_MoveUp_Discrete>( camwnd.getCamera() ) );
- GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, Camera_MoveDown_Discrete>( camwnd.getCamera() ) );
- GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, Camera_PitchUp_Discrete>( camwnd.getCamera() ) );
- GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, Camera_PitchDown_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, void(), Camera_MoveUp_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, void(), Camera_MoveDown_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, void(), Camera_PitchUp_Discrete>( camwnd.getCamera() ) );
+ GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, void(), Camera_PitchDown_Discrete>( camwnd.getCamera() ) );
}
void CamWnd_Move_Enable( CamWnd& camwnd ){
command_disconnect_accelerator( "CameraAngleDown" );
}
-void CamWnd_Move_Discrete_Import( CamWnd& camwnd, bool value ){
+struct CamWnd_Move_Discrete {
+ static void Export(const Callback<void(bool)> &returnz) {
+ returnz(g_camwindow_globals_private.m_bCamDiscrete);
+ }
+
+ static void Import(bool value) {
+ if (g_camwnd) {
+ Import_(*g_camwnd, value);
+ } else {
+ g_camwindow_globals_private.m_bCamDiscrete = value;
+ }
+ }
+
+ static void Import_(CamWnd &camwnd, bool value) {
if ( g_camwindow_globals_private.m_bCamDiscrete ) {
CamWnd_Move_Discrete_Disable( camwnd );
- }
- else
- {
+ } else {
CamWnd_Move_Disable( camwnd );
}
if ( g_camwindow_globals_private.m_bCamDiscrete ) {
CamWnd_Move_Discrete_Enable( camwnd );
- }
- else
- {
+ } else {
CamWnd_Move_Enable( camwnd );
}
}
-
-void CamWnd_Move_Discrete_Import( bool value ){
- if ( g_camwnd != 0 ) {
- CamWnd_Move_Discrete_Import( *g_camwnd, value );
- }
- else
- {
- g_camwindow_globals_private.m_bCamDiscrete = value;
- }
-}
-
+};
void CamWnd_Add_Handlers_Move( CamWnd& camwnd ){
- camwnd.m_selection_button_press_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_press_event", G_CALLBACK( selection_button_press ), camwnd.m_window_observer );
- camwnd.m_selection_button_release_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_release_event", G_CALLBACK( selection_button_release ), camwnd.m_window_observer );
- camwnd.m_selection_motion_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &camwnd.m_deferred_motion );
+ camwnd.m_selection_button_press_handler = camwnd.m_gl_widget.connect( "button_press_event", G_CALLBACK( selection_button_press ), camwnd.m_window_observer );
+ camwnd.m_selection_button_release_handler = camwnd.m_gl_widget.connect( "button_release_event", G_CALLBACK( selection_button_release ), camwnd.m_window_observer );
+ camwnd.m_selection_motion_handler = camwnd.m_gl_widget.connect( "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &camwnd.m_deferred_motion );
- camwnd.m_freelook_button_press_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_press_event", G_CALLBACK( enable_freelook_button_press ), &camwnd );
+ camwnd.m_freelook_button_press_handler = camwnd.m_gl_widget.connect( "button_press_event", G_CALLBACK( enable_freelook_button_press ), &camwnd );
if ( g_camwindow_globals_private.m_bCamDiscrete ) {
CamWnd_Move_Discrete_Enable( camwnd );
}
void CamWnd_Add_Handlers_FreeMove( CamWnd& camwnd ){
- camwnd.m_selection_button_press_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_press_event", G_CALLBACK( selection_button_press_freemove ), camwnd.m_window_observer );
- camwnd.m_selection_button_release_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_release_event", G_CALLBACK( selection_button_release_freemove ), camwnd.m_window_observer );
- camwnd.m_selection_motion_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "motion_notify_event", G_CALLBACK( selection_motion_freemove ), camwnd.m_window_observer );
+ camwnd.m_selection_button_press_handler = camwnd.m_gl_widget.connect( "button_press_event", G_CALLBACK( selection_button_press_freemove ), camwnd.m_window_observer );
+ camwnd.m_selection_button_release_handler = camwnd.m_gl_widget.connect( "button_release_event", G_CALLBACK( selection_button_release_freemove ), camwnd.m_window_observer );
+ camwnd.m_selection_motion_handler = camwnd.m_gl_widget.connect( "motion_notify_event", G_CALLBACK( selection_motion_freemove ), camwnd.m_window_observer );
- camwnd.m_freelook_button_press_handler = g_signal_connect( G_OBJECT( camwnd.m_gl_widget ), "button_press_event", G_CALLBACK( disable_freelook_button_press ), &camwnd );
+ camwnd.m_freelook_button_press_handler = camwnd.m_gl_widget.connect( "button_press_event", G_CALLBACK( disable_freelook_button_press ), &camwnd );
KeyEvent_connect( "CameraFreeMoveForward" );
KeyEvent_connect( "CameraFreeMoveBack" );
CamWnd::CamWnd() :
m_view( true ),
m_Camera( &m_view, CamWndQueueDraw( *this ) ),
- m_cameraview( m_Camera, &m_view, ReferenceCaller<CamWnd, CamWnd_Update>( *this ) ),
+ m_cameraview( m_Camera, &m_view, ReferenceCaller<CamWnd, void(), CamWnd_Update>( *this ) ),
m_gl_widget( glwidget_new( TRUE ) ),
m_window_observer( NewWindowObserver() ),
m_XORRectangle( m_gl_widget ),
- m_deferredDraw( WidgetQueueDrawCaller( *m_gl_widget ) ),
+ m_deferredDraw( WidgetQueueDrawCaller( m_gl_widget ) ),
m_deferred_motion( selection_motion, m_window_observer ),
m_selection_button_press_handler( 0 ),
m_selection_button_release_handler( 0 ),
GlobalWindowObservers_add( m_window_observer );
GlobalWindowObservers_connectWidget( m_gl_widget );
- m_window_observer->setRectangleDrawCallback( ReferenceCaller1<CamWnd, rect_t, camwnd_update_xor_rectangle>( *this ) );
+ m_window_observer->setRectangleDrawCallback( ReferenceCaller<CamWnd, void(rect_t), camwnd_update_xor_rectangle>( *this ) );
m_window_observer->setView( m_view );
- gtk_widget_ref( m_gl_widget );
+ g_object_ref( m_gl_widget._handle );
gtk_widget_set_events( m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK );
- GTK_WIDGET_SET_FLAGS( m_gl_widget, GTK_CAN_FOCUS );
+ gtk_widget_set_can_focus( m_gl_widget, true );
- m_sizeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "size_allocate", G_CALLBACK( camera_size_allocate ), this );
- m_exposeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "expose_event", G_CALLBACK( camera_expose ), this );
+ m_sizeHandler = m_gl_widget.connect( "size_allocate", G_CALLBACK( camera_size_allocate ), this );
+ m_exposeHandler = m_gl_widget.on_render( G_CALLBACK( camera_expose ), this );
Map_addValidCallback( g_map, DeferredDrawOnMapValidChangedCaller( m_deferredDraw ) );
CamWnd_Add_Handlers_Move( *this );
- g_signal_connect( G_OBJECT( m_gl_widget ), "scroll_event", G_CALLBACK( wheelmove_scroll ), this );
+ m_gl_widget.connect( "scroll_event", G_CALLBACK( wheelmove_scroll ), this );
- AddSceneChangeCallback( ReferenceCaller<CamWnd, CamWnd_Update>( *this ) );
+ AddSceneChangeCallback( ReferenceCaller<CamWnd, void(), CamWnd_Update>( *this ) );
PressedButtons_connect( g_pressedButtons, m_gl_widget );
}
g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_sizeHandler );
g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_exposeHandler );
- gtk_widget_unref( m_gl_widget );
+ m_gl_widget.unref();
m_window_observer->release();
}
void CamWnd::Cam_PositionDrag(){
int x, y;
- Sys_GetCursorPos( GTK_WINDOW( m_gl_widget ), &x, &y );
+ Sys_GetCursorPos( m_gl_widget, &x, &y );
if ( x != m_PositionDragCursorX || y != m_PositionDragCursorY ) {
x -= m_PositionDragCursorX;
vector3_add( m_Camera.origin, vector3_scaled( m_Camera.vright, x ) );
CamWnd_Update( camwnd );
CameraMovedNotify();
- Sys_SetCursorPos( GTK_WINDOW( m_parent ), m_PositionDragCursorX, m_PositionDragCursorY );
+ Sys_SetCursorPos( m_parent, m_PositionDragCursorX, m_PositionDragCursorY );
}
}
#endif
// NOTE TTimo if there's an OS-level focus out of the application
// then we can release the camera cursor grab
-static gboolean camwindow_freemove_focusout( GtkWidget* widget, GdkEventFocus* event, gpointer data ){
+static gboolean camwindow_freemove_focusout( ui::Widget widget, GdkEventFocus* event, gpointer data ){
reinterpret_cast<CamWnd*>( data )->DisableFreeMove();
return FALSE;
}
CamWnd_Add_Handlers_FreeMove( *this );
gtk_window_set_focus( m_parent, m_gl_widget );
- m_freemove_handle_focusout = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( camwindow_freemove_focusout ), this );
+ m_freemove_handle_focusout = m_gl_widget.connect( "focus_out_event", G_CALLBACK( camwindow_freemove_focusout ), this );
m_freezePointer.freeze_pointer( m_parent, m_gl_widget, Camera_motionDelta, &m_Camera );
CamWnd_Update( *this );
m_state_stack.back().m_state = state;
}
}
-const EStyle getStyle() const {
+EStyle getStyle() const {
return eFullMaterials;
}
void PushState(){
void ShowStatsToggle(){
g_camwindow_globals_private.m_showStats ^= 1;
}
-typedef FreeCaller<ShowStatsToggle> ShowStatsToggleCaller;
-void ShowStatsExport( const BoolImportCallback& importer ){
+void ShowStatsExport( const Callback<void(bool)> &importer ){
importer( g_camwindow_globals_private.m_showStats );
}
-typedef FreeCaller1<const BoolImportCallback&, ShowStatsExport> ShowStatsExportCaller;
-ShowStatsExportCaller g_show_stats_caller;
-BoolExportCallback g_show_stats_callback( g_show_stats_caller );
+FreeCaller<void(const Callback<void(bool)>&), ShowStatsExport> g_show_stats_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_stats_callback( g_show_stats_caller );
ToggleItem g_show_stats( g_show_stats_callback );
*/
-BoolExportCaller g_show_stats_caller( g_camwindow_globals_private.m_showStats );
-ToggleItem g_show_stats( g_show_stats_caller );
+
void ShowStatsToggle(){
g_camwindow_globals_private.m_showStats ^= 1;
- g_show_stats.update();
+// g_show_stats.update();
UpdateAllWindows();
}
+typedef FreeCaller<void(), ShowStatsToggle> ShowStatsToggleCaller;
+void ShowStatsExport( const Callback<void(bool)> & importer ){
+ importer( g_camwindow_globals_private.m_showStats );
+}
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowStatsExport> ShowStatsExportCaller;
+
+ShowStatsExportCaller g_show_stats_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_stats_callback( g_show_stats_caller );
+ToggleItem g_show_stats( g_show_stats_callback );
void CamWnd::Cam_Draw(){
glViewport( 0, 0, m_Camera.width, m_Camera.height );
return g_camwindow_globals_private.m_bCubicClipping;
}
-BoolExportCaller g_getfarclip_caller( g_camwindow_globals_private.m_bCubicClipping );
+ConstReferenceCaller<bool, void(const Callback<void(bool)> &), PropertyImpl<bool>::Export> g_getfarclip_caller( g_camwindow_globals_private.m_bCubicClipping );
ToggleItem g_getfarclip_item( g_getfarclip_caller );
void Camera_SetFarClip( bool value ){
CamWnd_Update( camwnd );
}
+struct Camera_FarClip {
+ static void Export(const Callback<void(bool)> &returnz) {
+ returnz(g_camwindow_globals_private.m_bCubicClipping);
+ }
+
+ static void Import(bool value) {
+ Camera_SetFarClip(value);
+ }
+};
+
void Camera_ToggleFarClip(){
Camera_SetFarClip( !Camera_GetFarClip() );
}
-void CamWnd_constructToolbar( GtkToolbar* toolbar ){
+void CamWnd_constructToolbar( ui::Toolbar toolbar ){
toolbar_append_toggle_button( toolbar, "Cubic clip the camera view (Ctrl + \\)", "view_cubicclipping.png", "ToggleCubicClip" );
}
void CamWnd_LookThroughCamera( CamWnd& camwnd ){
if ( g_camera_model != 0 ) {
CamWnd_Add_Handlers_Move( camwnd );
- g_camera_model->setCameraView( 0, Callback() );
+ g_camera_model->setCameraView( 0, Callback<void()>() );
g_camera_model = 0;
Camera_updateModelview( camwnd.getCamera() );
Camera_updateProjection( camwnd.getCamera() );
if ( cameraModel != 0 ) {
CamWnd_Remove_Handlers_Move( camwnd );
g_camera_model = cameraModel;
- g_camera_model->setCameraView( &camwnd.getCameraView(), ReferenceCaller<CamWnd, CamWnd_LookThroughCamera>( camwnd ) );
+ g_camera_model->setCameraView( &camwnd.getCameraView(), ReferenceCaller<CamWnd, void(), CamWnd_LookThroughCamera>( camwnd ) );
}
}
}
CamWnd_LookThroughCamera( *g_camwnd );
}
+struct RenderMode {
+ static void Export(const Callback<void(int)> &returnz) {
+ switch (CamWnd_GetMode()) {
+ case cd_wire:
+ returnz(0);
+ break;
+ case cd_solid:
+ returnz(1);
+ break;
+ case cd_texture:
+ returnz(2);
+ break;
+ case cd_lighting:
+ returnz(3);
+ break;
+ }
+ }
-void RenderModeImport( int value ){
- switch ( value )
- {
+ static void Import(int value) {
+ switch (value) {
case 0:
CamWnd_SetMode( cd_wire );
break;
CamWnd_SetMode( cd_texture );
}
}
-typedef FreeCaller1<int, RenderModeImport> RenderModeImportCaller;
-
-void RenderModeExport( const IntImportCallback& importer ){
- switch ( CamWnd_GetMode() )
- {
- case cd_wire:
- importer( 0 );
- break;
- case cd_solid:
- importer( 1 );
- break;
- case cd_texture:
- importer( 2 );
- break;
- case cd_lighting:
- importer( 3 );
- break;
- }
-}
-typedef FreeCaller1<const IntImportCallback&, RenderModeExport> RenderModeExportCaller;
+};
void Camera_constructPreferences( PreferencesPage& page ){
page.appendSlider( "Movement Speed", g_camwindow_globals_private.m_nMoveSpeed, TRUE, 0, 0, 100, MIN_CAM_SPEED, MAX_CAM_SPEED, 1, 10 );
page.appendCheckBox( "", "Invert mouse vertical axis", g_camwindow_globals_private.m_bCamInverseMouse );
page.appendCheckBox(
"", "Discrete movement",
- FreeCaller1<bool, CamWnd_Move_Discrete_Import>(),
- BoolExportCaller( g_camwindow_globals_private.m_bCamDiscrete )
+ make_property<CamWnd_Move_Discrete>()
);
page.appendCheckBox(
"", "Enable far-clip plane",
- FreeCaller1<bool, Camera_SetFarClip>(),
- BoolExportCaller( g_camwindow_globals_private.m_bCubicClipping )
+ make_property<Camera_FarClip>()
);
if ( g_pGameDescription->mGameType == "doom3" ) {
page.appendCombo(
"Render Mode",
STRING_ARRAY_RANGE( render_mode ),
- IntImportCallback( RenderModeImportCaller() ),
- IntExportCallback( RenderModeExportCaller() )
+ make_property<RenderMode>()
);
}
else
page.appendCombo(
"Render Mode",
STRING_ARRAY_RANGE( render_mode ),
- IntImportCallback( RenderModeImportCaller() ),
- IntExportCallback( RenderModeExportCaller() )
+ make_property<RenderMode>()
);
}
Camera_constructPreferences( page );
}
void Camera_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Camera_constructPage>() );
+ PreferencesDialog_addSettingsPage( makeCallbackF(Camera_constructPage) );
}
#include "preferencesystem.h"
#include "stringio.h"
#include "dialog.h"
-typedef FreeCaller1<bool, CamWnd_Move_Discrete_Import> CamWndMoveDiscreteImportCaller;
-
void CameraSpeed_increase(){
if ( g_camwindow_globals_private.m_nMoveSpeed <= ( MAX_CAM_SPEED - CAM_SPEED_STEP - 10 ) ) {
g_camwindow_globals_private.m_nMoveSpeed += CAM_SPEED_STEP;
/// \brief Initialisation for things that have the same lifespan as this module.
void CamWnd_Construct(){
- GlobalCommands_insert( "CenterView", FreeCaller<GlobalCamera_ResetAngles>(), Accelerator( GDK_End ) );
- GlobalCommands_insert( "CameraFocusOnSelected", FreeCaller<GlobalCamera_FocusOnSelected>(), Accelerator( GDK_Tab ) );
+ GlobalCommands_insert( "CenterView", makeCallbackF(GlobalCamera_ResetAngles), Accelerator( GDK_KEY_End ) );
+ GlobalCommands_insert( "CameraFocusOnSelected", makeCallbackF( GlobalCamera_FocusOnSelected ), Accelerator( GDK_Tab ) );
- GlobalToggles_insert( "ToggleCubicClip", FreeCaller<Camera_ToggleFarClip>(), ToggleItem::AddCallbackCaller( g_getfarclip_item ), Accelerator( '\\', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "CubicClipZoomIn", FreeCaller<Camera_CubeIn>(), Accelerator( '[', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "CubicClipZoomOut", FreeCaller<Camera_CubeOut>(), Accelerator( ']', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalToggles_insert( "ToggleCubicClip", makeCallbackF(Camera_ToggleFarClip), ToggleItem::AddCallbackCaller( g_getfarclip_item ), Accelerator( '\\', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "CubicClipZoomIn", makeCallbackF(Camera_CubeIn), Accelerator( '[', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "CubicClipZoomOut", makeCallbackF(Camera_CubeOut), Accelerator( ']', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "UpFloor", FreeCaller<Camera_ChangeFloorUp>(), Accelerator( GDK_Prior ) );
- GlobalCommands_insert( "DownFloor", FreeCaller<Camera_ChangeFloorDown>(), Accelerator( GDK_Next ) );
+ GlobalCommands_insert( "UpFloor", makeCallbackF(Camera_ChangeFloorUp), Accelerator( GDK_KEY_Prior ) );
+ GlobalCommands_insert( "DownFloor", makeCallbackF(Camera_ChangeFloorDown), Accelerator( GDK_KEY_Next ) );
GlobalToggles_insert( "ToggleCamera", ToggleShown::ToggleCaller( g_camera_shown ), ToggleItem::AddCallbackCaller( g_camera_shown.m_item ), Accelerator( 'C', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
-// GlobalCommands_insert( "LookThroughSelected", FreeCaller<GlobalCamera_LookThroughSelected>() );
-// GlobalCommands_insert( "LookThroughCamera", FreeCaller<GlobalCamera_LookThroughCamera>() );
+// GlobalCommands_insert( "LookThroughSelected", makeCallbackF(GlobalCamera_LookThroughSelected) );
+// GlobalCommands_insert( "LookThroughCamera", makeCallbackF(GlobalCamera_LookThroughCamera) );
if ( g_pGameDescription->mGameType == "doom3" ) {
- GlobalCommands_insert( "TogglePreview", FreeCaller<CamWnd_TogglePreview>(), Accelerator( GDK_F3 ) );
+ GlobalCommands_insert( "TogglePreview", makeCallbackF(CamWnd_TogglePreview), Accelerator( GDK_KEY_F3 ) );
}
- GlobalCommands_insert( "CameraSpeedInc", FreeCaller<CameraSpeed_increase>(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "CameraSpeedDec", FreeCaller<CameraSpeed_decrease>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "CameraSpeedInc", makeCallbackF(CameraSpeed_increase), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "CameraSpeedDec", makeCallbackF(CameraSpeed_decrease), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalShortcuts_insert( "CameraForward", Accelerator( GDK_Up ) );
- GlobalShortcuts_insert( "CameraBack", Accelerator( GDK_Down ) );
- GlobalShortcuts_insert( "CameraLeft", Accelerator( GDK_Left ) );
- GlobalShortcuts_insert( "CameraRight", Accelerator( GDK_Right ) );
- GlobalShortcuts_insert( "CameraStrafeRight", Accelerator( 'D' ) );
- GlobalShortcuts_insert( "CameraStrafeLeft", Accelerator( 'A' ) );
+ GlobalShortcuts_insert( "CameraForward", Accelerator( GDK_KEY_Up ) );
+ GlobalShortcuts_insert( "CameraBack", Accelerator( GDK_KEY_Down ) );
+ GlobalShortcuts_insert( "CameraLeft", Accelerator( GDK_KEY_Left ) );
+ GlobalShortcuts_insert( "CameraRight", Accelerator( GDK_KEY_Right ) );
+ GlobalShortcuts_insert( "CameraStrafeRight", Accelerator( GDK_KEY_period ) );
+ GlobalShortcuts_insert( "CameraStrafeLeft", Accelerator( GDK_KEY_comma ) );
GlobalShortcuts_insert( "CameraUp", accelerator_null() );
GlobalShortcuts_insert( "CameraDown", accelerator_null() );
GlobalShortcuts_insert( "CameraAngleUp", accelerator_null() );
GlobalShortcuts_insert( "CameraAngleDown", accelerator_null() );
- GlobalShortcuts_insert( "CameraFreeMoveForward", Accelerator( 'W' ) );
- GlobalShortcuts_insert( "CameraFreeMoveBack", Accelerator( 'S' ) );
- GlobalShortcuts_insert( "CameraFreeMoveLeft", Accelerator( 'A' ) );
- GlobalShortcuts_insert( "CameraFreeMoveRight", Accelerator( 'D' ) );
+ GlobalShortcuts_insert( "CameraFreeMoveForward", Accelerator( GDK_Up ) );
+ GlobalShortcuts_insert( "CameraFreeMoveBack", Accelerator( GDK_Down ) );
+ GlobalShortcuts_insert( "CameraFreeMoveLeft", Accelerator( GDK_Left ) );
+ GlobalShortcuts_insert( "CameraFreeMoveRight", Accelerator( GDK_Right ) );
GlobalShortcuts_insert( "CameraFreeMoveForward2", Accelerator( GDK_Up ) );
GlobalShortcuts_insert( "CameraFreeMoveBack2", Accelerator( GDK_Down ) );
GlobalShortcuts_insert( "CameraFreeMoveUp", accelerator_null() );
GlobalShortcuts_insert( "CameraFreeMoveDown", accelerator_null() );
- GlobalToggles_insert( "ShowStats", FreeCaller<ShowStatsToggle>(), ToggleItem::AddCallbackCaller( g_show_stats ) );
-
- GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals_private.m_showStats ), BoolExportStringCaller( g_camwindow_globals_private.m_showStats ) );
- GlobalPreferenceSystem().registerPreference( "MoveSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ) );
- GlobalPreferenceSystem().registerPreference( "CamLinkSpeed", BoolImportStringCaller( g_camwindow_globals_private.m_bCamLinkSpeed ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamLinkSpeed ) );
- GlobalPreferenceSystem().registerPreference( "AngleSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nAngleSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nAngleSpeed ) );
- GlobalPreferenceSystem().registerPreference( "CamInverseMouse", BoolImportStringCaller( g_camwindow_globals_private.m_bCamInverseMouse ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamInverseMouse ) );
- GlobalPreferenceSystem().registerPreference( "CamDiscrete", makeBoolStringImportCallback( CamWndMoveDiscreteImportCaller() ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamDiscrete ) );
- GlobalPreferenceSystem().registerPreference( "CubicClipping", BoolImportStringCaller( g_camwindow_globals_private.m_bCubicClipping ), BoolExportStringCaller( g_camwindow_globals_private.m_bCubicClipping ) );
- GlobalPreferenceSystem().registerPreference( "CubicScale", IntImportStringCaller( g_camwindow_globals.m_nCubicScale ), IntExportStringCaller( g_camwindow_globals.m_nCubicScale ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors4", Vector3ImportStringCaller( g_camwindow_globals.color_cameraback ), Vector3ExportStringCaller( g_camwindow_globals.color_cameraback ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors12", Vector3ImportStringCaller( g_camwindow_globals.color_selbrushes3d ), Vector3ExportStringCaller( g_camwindow_globals.color_selbrushes3d ) );
- GlobalPreferenceSystem().registerPreference( "CameraRenderMode", makeIntStringImportCallback( RenderModeImportCaller() ), makeIntStringExportCallback( RenderModeExportCaller() ) );
- GlobalPreferenceSystem().registerPreference( "StrafeMode", IntImportStringCaller( g_camwindow_globals_private.m_nStrafeMode ), IntExportStringCaller( g_camwindow_globals_private.m_nStrafeMode ) );
+ GlobalToggles_insert( "ShowStats", makeCallbackF(ShowStatsToggle), ToggleItem::AddCallbackCaller( g_show_stats ) );
+
+ GlobalPreferenceSystem().registerPreference( "ShowStats", make_property_string( g_camwindow_globals_private.m_showStats ) );
+ GlobalPreferenceSystem().registerPreference( "MoveSpeed", make_property_string( g_camwindow_globals_private.m_nMoveSpeed ) );
+ GlobalPreferenceSystem().registerPreference( "CamLinkSpeed", make_property_string( g_camwindow_globals_private.m_bCamLinkSpeed ) );
+ GlobalPreferenceSystem().registerPreference( "AngleSpeed", make_property_string( g_camwindow_globals_private.m_nAngleSpeed ) );
+ GlobalPreferenceSystem().registerPreference( "CamInverseMouse", make_property_string( g_camwindow_globals_private.m_bCamInverseMouse ) );
+ GlobalPreferenceSystem().registerPreference( "CamDiscrete", make_property_string<CamWnd_Move_Discrete>());
+ GlobalPreferenceSystem().registerPreference( "CubicClipping", make_property_string( g_camwindow_globals_private.m_bCubicClipping ) );
+ GlobalPreferenceSystem().registerPreference( "CubicScale", make_property_string( g_camwindow_globals.m_nCubicScale ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors4", make_property_string( g_camwindow_globals.color_cameraback ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors12", make_property_string( g_camwindow_globals.color_selbrushes3d ) );
+ GlobalPreferenceSystem().registerPreference( "CameraRenderMode", make_property_string<RenderMode>() );
+ GlobalPreferenceSystem().registerPreference( "StrafeMode", make_property_string( g_camwindow_globals_private.m_nStrafeMode ) );
CamWnd_constructStatic();
#if !defined( INCLUDED_CAMWINDOW_H )
#define INCLUDED_CAMWINDOW_H
+#include <uilib/uilib.h>
#include "math/vector.h"
#include "signal/signalfwd.h"
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-
class CamWnd;
CamWnd* NewCamWnd();
void DeleteCamWnd( CamWnd* camwnd );
void CamWnd_Update( CamWnd& camwnd );
-GtkWidget* CamWnd_getWidget( CamWnd& camwnd );
-void CamWnd_setParent( CamWnd& camwnd, GtkWindow* parent );
+ui::GLArea CamWnd_getWidget( CamWnd& camwnd );
+void CamWnd_setParent( CamWnd& camwnd, ui::Window parent );
void GlobalCamera_setCamWnd( CamWnd& camwnd );
-typedef struct _GtkToolbar GtkToolbar;
-void CamWnd_constructToolbar( GtkToolbar* toolbar );
+void CamWnd_constructToolbar( ui::Toolbar toolbar );
void CamWnd_registerShortcuts();
void GlobalCamera_Benchmark();
#include "commands.h"
+#include "gtk/gtk.h"
#include "debugging/debugging.h"
#include "warnings.h"
#include <map>
#include "string/string.h"
#include "versionlib.h"
-#include "gtkutil/accelerator.h"
#include "gtkutil/messagebox.h"
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkbutton.h>
#include "gtkmisc.h"
typedef std::pair<Accelerator, int> ShortcutValue; // accelerator, isRegistered
Commands g_commands;
-void GlobalCommands_insert( const char* name, const Callback& callback, const Accelerator& accelerator ){
+void GlobalCommands_insert( const char* name, const Callback<void()>& callback, const Accelerator& accelerator ){
bool added = g_commands.insert( Commands::value_type( name, Command( callback, GlobalShortcuts_insert( name, accelerator ) ) ) ).second;
ASSERT_MESSAGE( added, "command already registered: " << makeQuoted( name ) );
}
Toggles g_toggles;
-void GlobalToggles_insert( const char* name, const Callback& callback, const BoolExportCallback& exportCallback, const Accelerator& accelerator ){
+void GlobalToggles_insert( const char* name, const Callback<void()>& callback, const Callback<void(const Callback<void(bool)> &)>& exportCallback, const Accelerator& accelerator ){
bool added = g_toggles.insert( Toggles::value_type( name, Toggle( callback, GlobalShortcuts_insert( name, accelerator ), exportCallback ) ) ).second;
ASSERT_MESSAGE( added, "toggle already registered: " << makeQuoted( name ) );
}
KeyEvents g_keyEvents;
-void GlobalKeyEvents_insert( const char* name, const Accelerator& accelerator, const Callback& keyDown, const Callback& keyUp ){
+void GlobalKeyEvents_insert( const char* name, const Accelerator& accelerator, const Callback<void()>& keyDown, const Callback<void()>& keyUp ){
bool added = g_keyEvents.insert( KeyEvents::value_type( name, KeyEvent( GlobalShortcuts_insert( name, accelerator ), keyDown, keyUp ) ) ).second;
ASSERT_MESSAGE( added, "command already registered: " << makeQuoted( name ) );
}
}
-#include <cctype>
-
-#include <gtk/gtkbox.h>
-#include <gtk/gtkliststore.h>
-#include <gtk/gtktreemodel.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtkcellrenderertext.h>
+#include <uilib/uilib.h>
+#include <gdk/gdkkeysyms.h>
#include "gtkutil/dialog.h"
#include "mainframe.h"
struct command_list_dialog_t : public ModalDialog
{
command_list_dialog_t()
- : m_close_button( *this, eIDCANCEL ), m_list( NULL ), m_command_iter(), m_model( NULL ), m_waiting_for_key( false ){
+ : m_close_button( *this, eIDCANCEL ), m_list( ui::null ), m_command_iter(), m_model( ui::null ), m_waiting_for_key( false ){
}
ModalDialogButton m_close_button;
- GtkTreeView *m_list;
+ ui::TreeView m_list;
GtkTreeIter m_command_iter;
- GtkTreeModel *m_model;
+ ui::TreeModel m_model;
bool m_waiting_for_key;
};
-void accelerator_clear_button_clicked( GtkButton *btn, gpointer dialogptr ){
+void accelerator_clear_button_clicked( ui::Button btn, gpointer dialogptr ){
command_list_dialog_t &dialog = *(command_list_dialog_t *) dialogptr;
if ( dialog.m_waiting_for_key ) {
// just unhighlight, user wanted to cancel
dialog.m_waiting_for_key = false;
- gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
- gtk_widget_set_sensitive( GTK_WIDGET( dialog.m_list ), true );
- dialog.m_model = NULL;
+ gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
+ gtk_widget_set_sensitive( dialog.m_list , true );
+ dialog.m_model = ui::TreeModel(ui::null);
return;
}
- GtkTreeSelection *sel = gtk_tree_view_get_selection( dialog.m_list );
+ auto sel = gtk_tree_view_get_selection( dialog.m_list );
GtkTreeModel *model;
GtkTreeIter iter;
if ( !gtk_tree_selection_get_selected( sel, &model, &iter ) ) {
GValue val;
memset( &val, 0, sizeof( val ) );
- gtk_tree_model_get_value( GTK_TREE_MODEL( model ), &iter, 0, &val );
+ gtk_tree_model_get_value(model, &iter, 0, &val );
const char *commandName = g_value_get_string( &val );;
// clear the ACTUAL accelerator too!
}
thisShortcutIterator->second.first = accelerator_null();
- gtk_list_store_set( GTK_LIST_STORE( model ), &iter, 1, "", -1 );
+ gtk_list_store_set( ui::ListStore::from( model ), &iter, 1, "", -1 );
g_value_unset( &val );
}
-void accelerator_edit_button_clicked( GtkButton *btn, gpointer dialogptr ){
+void accelerator_edit_button_clicked( ui::Button btn, gpointer dialogptr ){
command_list_dialog_t &dialog = *(command_list_dialog_t *) dialogptr;
// 1. find selected row
- GtkTreeSelection *sel = gtk_tree_view_get_selection( dialog.m_list );
+ auto sel = gtk_tree_view_get_selection( dialog.m_list );
GtkTreeModel *model;
GtkTreeIter iter;
if ( !gtk_tree_selection_get_selected( sel, &model, &iter ) ) {
return;
}
dialog.m_command_iter = iter;
- dialog.m_model = model;
+ dialog.m_model = ui::TreeModel::from(model);
// 2. disallow changing the row
- //gtk_widget_set_sensitive(GTK_WIDGET(dialog.m_list), false);
+ //gtk_widget_set_sensitive(dialog.m_list, false);
// 3. highlight the row
- gtk_list_store_set( GTK_LIST_STORE( model ), &iter, 2, true, -1 );
+ gtk_list_store_set( ui::ListStore::from( model ), &iter, 2, true, -1 );
// 4. grab keyboard focus
dialog.m_waiting_for_key = true;
}
-gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gpointer dialogptr ){
+bool accelerator_window_key_press( ui::Window widget, GdkEventKey *event, gpointer dialogptr ){
command_list_dialog_t &dialog = *(command_list_dialog_t *) dialogptr;
if ( !dialog.m_waiting_for_key ) {
#else
switch ( event->keyval )
{
- case GDK_Shift_L:
- case GDK_Shift_R:
- case GDK_Control_L:
- case GDK_Control_R:
- case GDK_Caps_Lock:
- case GDK_Shift_Lock:
- case GDK_Meta_L:
- case GDK_Meta_R:
- case GDK_Alt_L:
- case GDK_Alt_R:
- case GDK_Super_L:
- case GDK_Super_R:
- case GDK_Hyper_L:
- case GDK_Hyper_R:
+ case GDK_KEY_Shift_L:
+ case GDK_KEY_Shift_R:
+ case GDK_KEY_Control_L:
+ case GDK_KEY_Control_R:
+ case GDK_KEY_Caps_Lock:
+ case GDK_KEY_Shift_Lock:
+ case GDK_KEY_Meta_L:
+ case GDK_KEY_Meta_R:
+ case GDK_KEY_Alt_L:
+ case GDK_KEY_Alt_R:
+ case GDK_KEY_Super_L:
+ case GDK_KEY_Super_R:
+ case GDK_KEY_Hyper_L:
+ case GDK_KEY_Hyper_R:
return false;
}
#endif
// 7. find the name of the accelerator
GValue val;
memset( &val, 0, sizeof( val ) );
- gtk_tree_model_get_value( GTK_TREE_MODEL( dialog.m_model ), &dialog.m_command_iter, 0, &val );
+ gtk_tree_model_get_value(dialog.m_model, &dialog.m_command_iter, 0, &val );
const char *commandName = g_value_get_string( &val );;
Shortcuts::iterator thisShortcutIterator = g_shortcuts.find( commandName );
if ( thisShortcutIterator == g_shortcuts.end() ) {
- gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
- gtk_widget_set_sensitive( GTK_WIDGET( dialog.m_list ), true );
+ gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
+ gtk_widget_set_sensitive( dialog.m_list , true );
return true;
}
{
const char *commandName;
const Accelerator &newAccel;
- GtkWidget *widget;
- GtkTreeModel *model;
+ ui::Widget widget;
+ ui::TreeModel model;
public:
bool allow;
- VerifyAcceleratorNotTaken( const char *name, const Accelerator &accelerator, GtkWidget *w, GtkTreeModel *m ) : commandName( name ), newAccel( accelerator ), widget( w ), model( m ), allow( true ){
+ VerifyAcceleratorNotTaken( const char *name, const Accelerator &accelerator, ui::Widget w, ui::TreeModel m ) : commandName( name ), newAccel( accelerator ), widget( w ), model( m ), allow( true ){
}
void visit( const char* name, Accelerator& accelerator ){
if ( !strcmp( name, commandName ) ) {
StringOutputStream msg;
msg << "The command " << name << " is already assigned to the key " << accelerator << ".\n\n"
<< "Do you want to unassign " << name << " first?";
- EMessageBoxReturn r = gtk_MessageBox( widget, msg.c_str(), "Key already used", eMB_YESNOCANCEL );
- if ( r == eIDYES ) {
+ auto r = ui::alert( widget.window(), msg.c_str(), "Key already used", ui::alert_type::YESNOCANCEL );
+ if ( r == ui::alert_response::YES ) {
// clear the ACTUAL accelerator too!
disconnect_accelerator( name );
// delete the modifier
accelerator = accelerator_null();
// empty the cell of the key binds dialog
GtkTreeIter i;
- if ( gtk_tree_model_get_iter_first( GTK_TREE_MODEL( model ), &i ) ) {
+ if ( gtk_tree_model_get_iter_first(model, &i ) ) {
for (;; )
{
GValue val;
memset( &val, 0, sizeof( val ) );
- gtk_tree_model_get_value( GTK_TREE_MODEL( model ), &i, 0, &val );
+ gtk_tree_model_get_value(model, &i, 0, &val );
const char *thisName = g_value_get_string( &val );;
if ( !strcmp( thisName, name ) ) {
- gtk_list_store_set( GTK_LIST_STORE( model ), &i, 1, "", -1 );
+ gtk_list_store_set( ui::ListStore::from( model ), &i, 1, "", -1 );
}
g_value_unset( &val );
- if ( !gtk_tree_model_iter_next( GTK_TREE_MODEL( model ), &i ) ) {
+ if ( !gtk_tree_model_iter_next(model, &i ) ) {
break;
}
}
}
}
- else if ( r == eIDCANCEL ) {
+ else if ( r == ui::alert_response::CANCEL ) {
// aborted
allow = false;
}
} verify_visitor( commandName, newAccel, widget, dialog.m_model );
GlobalShortcuts_foreach( verify_visitor );
- gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
- gtk_widget_set_sensitive( GTK_WIDGET( dialog.m_list ), true );
+ gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 );
+ gtk_widget_set_sensitive( dialog.m_list , true );
if ( verify_visitor.allow ) {
// clear the ACTUAL accelerator first
// write into the cell
StringOutputStream modifiers;
modifiers << newAccel;
- gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 1, modifiers.c_str(), -1 );
+ gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 1, modifiers.c_str(), -1 );
// set the ACTUAL accelerator too!
connect_accelerator( commandName );
g_value_unset( &val );
- dialog.m_model = NULL;
+ dialog.m_model = ui::TreeModel(ui::null);
return true;
}
GtkTreeIter row;
GValue val;
if(!model) {g_error("Unable to get model from cell renderer");}
- gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(model), &row, path_string);
+ gtk_tree_model_get_iter_from_string(model, &row, path_string);
- gtk_tree_model_get_value(GTK_TREE_MODEL(model), &row, 0, &val);
+ gtk_tree_model_get_value(model, &row, 0, &val);
const char *name = g_value_get_string(&val);
Shortcuts::iterator i = g_shortcuts.find(name);
if(i != g_shortcuts.end())
accelerator_parse(i->second.first, new_text);
StringOutputStream modifiers;
modifiers << i->second.first;
- gtk_list_store_set(GTK_LIST_STORE(model), &row, 1, modifiers.c_str(), -1);
+ gtk_list_store_set(ui::ListStore::from(model), &row, 1, modifiers.c_str(), -1);
}
};
*/
void DoCommandListDlg(){
command_list_dialog_t dialog;
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Mapped Commands", dialog, -1, 400 );
- g_signal_connect( G_OBJECT( window ), "key-press-event", (GCallback) accelerator_window_key_press, &dialog );
+ ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Mapped Commands", dialog, -1, 400);
+ window.on_key_press([](ui::Widget widget, GdkEventKey *event, gpointer dialogptr) {
+ return accelerator_window_key_press(ui::Window::from(widget), event, dialogptr);
+ }, &dialog);
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel );
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( scr ), TRUE, TRUE, 0 );
+ auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC );
+ hbox.pack_start( scr, TRUE, TRUE, 0 );
{
- GtkListStore* store = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT );
+ auto store = ui::ListStore::from(gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT ));
- GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) );
- dialog.m_list = GTK_TREE_VIEW( view );
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
+ dialog.m_list = view;
- gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), false ); // annoying
+ gtk_tree_view_set_enable_search(view, false ); // annoying
{
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Command", renderer, "text", 0, "weight-set", 2, "weight", 3, NULL );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "Command", renderer, {{"text", 0}, {"weight-set", 2}, {"weight", 3}} );
+ gtk_tree_view_append_column(view, column );
}
{
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Key", renderer, "text", 1, "weight-set", 2, "weight", 3, NULL );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "Key", renderer, {{"text", 1}, {"weight-set", 2}, {"weight", 3}} );
+ gtk_tree_view_append_column(view, column );
}
- gtk_widget_show( view );
- gtk_container_add( GTK_CONTAINER( scr ), view );
+ view.show();
+ scr.add(view);
{
// Initialize dialog
class BuildCommandList : public CommandVisitor
{
TextFileOutputStream m_commandList;
- GtkListStore* m_store;
+ ui::ListStore m_store;
public:
- BuildCommandList( const char* filename, GtkListStore* store ) : m_commandList( filename ), m_store( store ){
+ BuildCommandList( const char* filename, ui::ListStore store ) : m_commandList( filename ), m_store( store ){
}
void visit( const char* name, Accelerator& accelerator ){
StringOutputStream modifiers;
modifiers << accelerator;
- {
- GtkTreeIter iter;
- gtk_list_store_append( m_store, &iter );
- gtk_list_store_set( m_store, &iter, 0, name, 1, modifiers.c_str(), 2, false, 3, 800, -1 );
- }
+ m_store.append(0, name, 1, modifiers.c_str(), 2, false, 3, 800);
if ( !m_commandList.failed() ) {
int l = strlen( name );
GlobalShortcuts_foreach( visitor );
}
- g_object_unref( G_OBJECT( store ) );
+ store.unref();
}
}
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkButton* editbutton = create_dialog_button( "Edit", (GCallback) accelerator_edit_button_clicked, &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( editbutton ), FALSE, FALSE, 0 );
-
- GtkButton* clearbutton = create_dialog_button( "Clear", (GCallback) accelerator_clear_button_clicked, &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( clearbutton ), FALSE, FALSE, 0 );
-
- GtkWidget *spacer = gtk_image_new();
- gtk_widget_show( spacer );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( spacer ), TRUE, TRUE, 0 );
-
- GtkButton* button = create_modal_dialog_button( "Close", dialog.m_close_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_grab_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto editbutton = create_dialog_button( "Edit", (GCallback) accelerator_edit_button_clicked, &dialog );
+ vbox.pack_start( editbutton, FALSE, FALSE, 0 );
+
+ auto clearbutton = create_dialog_button( "Clear", (GCallback) accelerator_clear_button_clicked, &dialog );
+ vbox.pack_start( clearbutton, FALSE, FALSE, 0 );
+
+ ui::Widget spacer = ui::Image(ui::New);
+ spacer.show();
+ vbox.pack_start( spacer, TRUE, TRUE, 0 );
+
+ auto button = create_modal_dialog_button( "Close", dialog.m_close_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_grab_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
modal_dialog_show( window, dialog );
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
}
#include "profile/profile.h"
virtual void visit( const char* name, Accelerator& accelerator ) = 0;
};
-void GlobalCommands_insert( const char* name, const Callback& callback, const Accelerator& accelerator = accelerator_null() );
+void GlobalCommands_insert( const char* name, const Callback<void()>& callback, const Accelerator& accelerator = accelerator_null() );
const Command& GlobalCommands_find( const char* name );
-void GlobalToggles_insert( const char* name, const Callback& callback, const BoolExportCallback& exportCallback, const Accelerator& accelerator = accelerator_null() );
+void GlobalToggles_insert( const char* name, const Callback<void()>& callback, const Callback<void(const Callback<void(bool)> &)>& exportCallback, const Accelerator& accelerator = accelerator_null() );
const Toggle& GlobalToggles_find( const char* name );
-void GlobalKeyEvents_insert( const char* name, const Accelerator& accelerator, const Callback& keyDown, const Callback& keyUp );
+void GlobalKeyEvents_insert( const char* name, const Accelerator& accelerator, const Callback<void()>& keyDown, const Callback<void()>& keyUp );
const KeyEvent& GlobalKeyEvents_find( const char* name );
#include "console.h"
#include <time.h>
-#include <gtk/gtktextbuffer.h>
-#include <gtk/gtktextview.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkscrolledwindow.h>
+#include <uilib/uilib.h>
+#include <gtk/gtk.h>
#include "gtkutil/accelerator.h"
#include "gtkutil/messagebox.h"
<< "This is NetRadiant '" RADIANT_VERSION "' compiled " __DATE__ "\n" RADIANT_ABOUTMSG "\n";
}
else{
- gtk_MessageBox( 0, "Failed to create log file, check write permissions in Radiant directory.\n",
- "Console logging", eMB_OK, eMB_ICONERROR );
+ ui::alert( ui::root, "Failed to create log file, check write permissions in Radiant directory.\n",
+ "Console logging", ui::alert_type::OK, ui::alert_icon::Error );
}
}
else if ( !enable && g_hLogFile != 0 ) {
}
}
-GtkWidget* g_console = 0;
+ui::TextView g_console{ui::null};
void console_clear(){
- GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( g_console ) );
- gtk_text_buffer_set_text( buffer, "", -1 );
+ g_console.text("");
}
-void console_populate_popup( GtkTextView* textview, GtkMenu* menu, gpointer user_data ){
+void console_populate_popup( ui::TextView textview, ui::Menu menu, gpointer user_data ){
menu_separator( menu );
- GtkWidget* item = gtk_menu_item_new_with_label( "Clear" );
- g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( console_clear ), 0 );
- gtk_widget_show( item );
- container_add_widget( GTK_CONTAINER( menu ), item );
+ ui::Widget item(ui::MenuItem( "Clear" ));
+ item.connect( "activate", G_CALLBACK( console_clear ), 0 );
+ item.show();
+ menu.add(item);
}
-gboolean destroy_set_null( GtkWindow* widget, GtkWidget** p ){
- *p = 0;
+gboolean destroy_set_null( ui::Window widget, ui::Widget* p ){
+ *p = ui::Widget{ui::null};
return FALSE;
}
WidgetFocusPrinter g_consoleWidgetFocusPrinter( "console" );
-GtkWidget* Console_constructWindow( GtkWindow* toplevel ){
- GtkWidget* scr = gtk_scrolled_window_new( 0, 0 );
- gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+ui::Widget Console_constructWindow( ui::Window toplevel ){
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.overflow(ui::Policy::AUTOMATIC, ui::Policy::AUTOMATIC);
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
- gtk_widget_show( scr );
+ scr.show();
{
- GtkWidget* text = gtk_text_view_new();
- gtk_widget_set_size_request( text, 0, -1 ); // allow shrinking
- gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text ), GTK_WRAP_WORD );
- gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), FALSE );
- gtk_container_add( GTK_CONTAINER( scr ), text );
- gtk_widget_show( text );
+ auto text = ui::TextView(ui::New);
+ text.dimensions(0, -1); // allow shrinking
+ gtk_text_view_set_wrap_mode( text, GTK_WRAP_WORD );
+ gtk_text_view_set_editable( text, FALSE );
+ scr.add(text);
+ text.show();
g_console = text;
//globalExtendedASCIICharacterSet().print();
//g_consoleWidgetFocusPrinter.connect(g_console);
- g_signal_connect( G_OBJECT( g_console ), "populate-popup", G_CALLBACK( console_populate_popup ), 0 );
- g_signal_connect( G_OBJECT( g_console ), "destroy", G_CALLBACK( destroy_set_null ), &g_console );
+ g_console.connect( "populate-popup", G_CALLBACK( console_populate_popup ), 0 );
+ g_console.connect( "destroy", G_CALLBACK( destroy_set_null ), &g_console );
}
gtk_container_set_focus_chain( GTK_CONTAINER( scr ), NULL );
GtkTextBufferOutputStream( GtkTextBuffer* textBuffer, GtkTextIter* iter, GtkTextTag* tag ) : textBuffer( textBuffer ), iter( iter ), tag( tag ){
}
std::size_t __attribute__((optimize("O0"))) write( const char* buffer, std::size_t length ){
- gtk_text_buffer_insert_with_tags( textBuffer, iter, buffer, gint( length ), tag, 0 );
+ gtk_text_buffer_insert_with_tags( textBuffer, iter, buffer, gint( length ), tag, NULL );
return length;
}
};
}
if ( level != SYS_NOCON ) {
- if ( g_console != 0 ) {
- GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( g_console ) );
+ if ( g_console ) {
+ auto buffer = gtk_text_view_get_buffer( g_console );
GtkTextIter iter;
gtk_text_buffer_get_end_iter( buffer, &iter );
- static GtkTextMark* end = gtk_text_buffer_create_mark( buffer, "end", &iter, FALSE );
+ static auto end = gtk_text_buffer_create_mark( buffer, "end", &iter, FALSE );
const GdkColor yellow = { 0, 0xb0ff, 0xb0ff, 0x0000 };
const GdkColor red = { 0, 0xffff, 0x0000, 0x0000 };
- static GtkTextTag* error_tag = gtk_text_buffer_create_tag( buffer, "red_foreground", "foreground-gdk", &red, 0 );
- static GtkTextTag* warning_tag = gtk_text_buffer_create_tag( buffer, "yellow_foreground", "foreground-gdk", &yellow, 0 );
- static GtkTextTag* standard_tag = gtk_text_buffer_create_tag( buffer, "black_foreground", 0 );
+ static auto error_tag = gtk_text_buffer_create_tag( buffer, "red_foreground", "foreground-gdk", &red, NULL );
+ static auto warning_tag = gtk_text_buffer_create_tag( buffer, "yellow_foreground", "foreground-gdk", &yellow, NULL );
+ static auto standard_tag = gtk_text_buffer_create_tag( buffer, "black_foreground", NULL );
GtkTextTag* tag;
switch ( level )
{
// update console widget immediatly if we're doing something time-consuming
if ( contains_newline ) {
- gtk_text_view_scroll_mark_onscreen( GTK_TEXT_VIEW( g_console ), end );
+ gtk_text_view_scroll_mark_onscreen( g_console, end );
- if ( !ScreenUpdates_Enabled() && GTK_WIDGET_REALIZED( g_console ) ) {
+ if ( !ScreenUpdates_Enabled() && gtk_widget_get_realized( g_console ) ) {
ScreenUpdates_process();
}
}
#define INCLUDED_CONSOLE_H
#include <cstddef>
+#include <uilib/uilib.h>
#define SYS_VRB 0 ///< verbose support (on/off)
#define SYS_STD 1 ///< standard print level - this is the default
TextOutputStream& getSysPrintOutputStream();
TextOutputStream& getSysPrintErrorStream();
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-GtkWidget* Console_constructWindow( GtkWindow* toplevel );
+ui::Widget Console_constructWindow( ui::Window toplevel );
// will open/close the log file based on the parameter
void Sys_LogFile( bool enable );
#include "brushmanip.h"
#include "brushnode.h"
#include "grid.h"
+
/*
void Face_makeBrush( Face& face, const Brush& brush, brush_vector_t& out, float offset ){
if ( face.contributes() ) {
BrushGatherSelected( brush_vector_t& brushlist )
: m_brushlist( brushlist ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Brush* brush = Node_getBrush( path.top() );
{
const Functor& functor;
public:
-typedef typename RemoveReference<typename Functor::first_argument_type>::type* first_argument_type;
-typedef typename Functor::result_type result_type;
Dereference( const Functor& functor ) : functor( functor ){
}
-result_type operator()( first_argument_type firstArgument ) const {
+get_result_type<Functor> operator()( typename RemoveReference<get_argument<Functor, 0>>::type *firstArgument ) const {
return functor( *firstArgument );
}
};
template<typename Caller>
class BindArguments1
{
-typedef typename Caller::second_argument_type FirstBound;
+typedef get_argument<Caller, 1> FirstBound;
FirstBound firstBound;
public:
-typedef typename Caller::result_type result_type;
-typedef typename Caller::first_argument_type first_argument_type;
BindArguments1( FirstBound firstBound )
: firstBound( firstBound ){
}
-result_type operator()( first_argument_type firstArgument ) const {
+
+get_result_type<Caller> operator()( get_argument<Caller, 0> firstArgument ) const {
return Caller::call( firstArgument, firstBound );
}
};
template<typename Caller>
class BindArguments2
{
-typedef typename Caller::second_argument_type FirstBound;
-typedef typename Caller::third_argument_type SecondBound;
+typedef get_argument<Caller, 1> FirstBound;
+typedef get_argument<Caller, 2> SecondBound;
FirstBound firstBound;
SecondBound secondBound;
public:
-typedef typename Caller::result_type result_type;
-typedef typename Caller::first_argument_type first_argument_type;
BindArguments2( FirstBound firstBound, SecondBound secondBound )
: firstBound( firstBound ), secondBound( secondBound ){
}
-result_type operator()( first_argument_type firstArgument ) const {
+
+get_result_type<Caller> operator()( get_argument<Caller, 0> firstArgument ) const {
return Caller::call( firstArgument, firstBound, secondBound );
}
};
inline bool Face_testPlane( const Face& face, const Plane3& plane, bool flipped ){
return face.contributes() && !Winding_TestPlane( face.getWinding(), plane, flipped );
}
-typedef Function3<const Face&, const Plane3&, bool, bool, Face_testPlane> FaceTestPlane;
+typedef Function<bool ( const Face &, const Plane3 &, bool ), Face_testPlane> FaceTestPlane;
/// \brief Returns true if
SubtractBrushesFromUnselected( const brush_vector_t& brushlist, std::size_t& before, std::size_t& after )
: m_brushlist( brushlist ), m_before( before ), m_after( after ), m_eraseParent( false ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
return true;
}
return false;
}
+
void post( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Brush* brush = Node_getBrush( path.top() );
BrushSplitByPlaneSelected( const Vector3& p0, const Vector3& p1, const Vector3& p2, const char* shader, const TextureProjection& projection, EBrushSplit split )
: m_p0( p0 ), m_p1( p1 ), m_p2( p2 ), m_shader( shader ), m_projection( projection ), m_split( split ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
return true;
}
+
void post( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Brush* brush = Node_getBrush( path.top() );
BrushInstanceSetClipPlane( const Plane3& plane )
: m_plane( plane ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
BrushInstance* brush = Instance_getBrush( instance );
if ( brush != 0
struct CSGToolDialog
{
GtkSpinButton* spin;
- GtkWindow *window;
+ bool allocated{false};
+ ui::Window window{ui::null};
GtkToggleButton *radFaces, *radProj, *radCam, *caulk, *removeInner;
};
}
void CSG_Tool(){
- if ( g_csgtool_dialog.window == NULL ) {
- g_csgtool_dialog.window = create_dialog_window( MainFrame_getWindow(), "CSG Tool", G_CALLBACK( CSGdlg_delete ), &g_csgtool_dialog );
+ // FIXME: there is probably improvements to do less raw GTK stuff, more GTK wrapper
+ if ( !g_csgtool_dialog.allocated ) {
+ g_csgtool_dialog.allocated = true;
+ g_csgtool_dialog.window = MainFrame_getWindow().create_dialog_window( "CSG Tool", G_CALLBACK( CSGdlg_delete ), &g_csgtool_dialog );
gtk_window_set_type_hint( g_csgtool_dialog.window, GDK_WINDOW_TYPE_HINT_UTILITY );
//GtkAccelGroup* accel = gtk_accel_group_new();
global_accel_connect_window( g_csgtool_dialog.window );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
+ auto hbox = create_dialog_hbox( 4, 4 );
gtk_container_add( GTK_CONTAINER( g_csgtool_dialog.window ), GTK_WIDGET( hbox ) );
{
- GtkTable* table = create_dialog_table( 3, 8, 4, 4 );
+ auto table = create_dialog_table( 3, 8, 4, 4 );
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
{
//GtkWidget* label = gtk_label_new( "<->" );
//gtk_widget_show( label );
- GtkWidget* button = gtk_button_new_with_label( "Grid->" );
- gtk_table_attach( table, button, 0, 1, 0, 1,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_show( button );
+ auto button = ui::Button( "Grid->" );
+ table.attach( button, {0, 1, 0, 1}, {0, 0} );
+ button.show();
g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( CSGdlg_grid2spin ), &g_csgtool_dialog );
}
{
}
{
GtkWidget* button = gtk_toggle_button_new();
- button_set_icon( GTK_BUTTON( button ), "f-caulk.png" );
+ auto ubutton = ui::Button::from( button );
+ button_set_icon( ubutton, "f-caulk.png" );
gtk_button_set_relief( GTK_BUTTON( button ), GTK_RELIEF_NONE );
- gtk_table_attach( table, button, 6, 7, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach( ubutton, { 6, 7, 0, 1 }, { GTK_EXPAND, 0 } );
gtk_widget_set_tooltip_text( button, "Caulk some faces" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), TRUE );
- gtk_widget_show( button );
+ ubutton.show();
g_csgtool_dialog.caulk = GTK_TOGGLE_BUTTON( button );
}
{
GtkWidget* button = gtk_toggle_button_new();
- button_set_icon( GTK_BUTTON( button ), "csgtool_removeinner.png" );
+ auto ubutton = ui::Button::from( button );
+ button_set_icon( ubutton, "csgtool_removeinner.png" );
gtk_button_set_relief( GTK_BUTTON( button ), GTK_RELIEF_NONE );
- gtk_table_attach( table, button, 7, 8, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach( ubutton, { 7, 8, 0, 1 }, { GTK_EXPAND, 0 } );
gtk_widget_set_tooltip_text( button, "Remove inner brush" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), TRUE );
- gtk_widget_show( button );
+ ubutton.show();
g_csgtool_dialog.removeInner = GTK_TOGGLE_BUTTON( button );
}
{
}
{
GtkWidget* button = gtk_button_new();
- button_set_icon( GTK_BUTTON( button ), "csgtool_shrink.png" );
- gtk_table_attach( table, button, 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto ubutton = ui::Button::from( button );
+ button_set_icon( ubutton, "csgtool_shrink.png" );
+ table.attach( ubutton, { 0, 1, 2, 3 }, { GTK_EXPAND, 0 } );
gtk_widget_set_tooltip_text( button, "Shrink brush" );
- gtk_widget_show( button );
+ ubutton.show();
g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( CSGdlg_BrushShrink ), &g_csgtool_dialog );
}
{
GtkWidget* button = gtk_button_new();
- button_set_icon( GTK_BUTTON( button ), "csgtool_expand.png" );
- gtk_table_attach( table, button, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto ubutton = ui::Button::from( button );
+ button_set_icon( ubutton, "csgtool_expand.png" );
+ table.attach( ubutton, { 1, 2, 2, 3 }, { GTK_EXPAND, 0 } );
gtk_widget_set_tooltip_text( button, "Expand brush" );
- gtk_widget_show( button );
+ ubutton.show();
g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( CSGdlg_BrushExpand ), &g_csgtool_dialog );
}
{
GtkWidget* button = gtk_button_new();
- button_set_icon( GTK_BUTTON( button ), "csgtool_diagonal.png" );
- gtk_table_attach( table, button, 3, 4, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto ubutton = ui::Button::from( button );
+ button_set_icon( ubutton, "csgtool_diagonal.png" );
+ table.attach( ubutton, { 3, 4, 2, 3 }, { GTK_EXPAND, 0 } );
gtk_widget_set_tooltip_text( button, "Hollow::diagonal joints" );
- gtk_widget_show( button );
+ ubutton.show();
g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( CSGdlg_HollowDiag ), &g_csgtool_dialog );
}
{
GtkWidget* button = gtk_button_new();
- button_set_icon( GTK_BUTTON( button ), "csgtool_wrap.png" );
- gtk_table_attach( table, button, 4, 5, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto ubutton = ui::Button::from( button );
+ button_set_icon( ubutton, "csgtool_wrap.png" );
+ table.attach( ubutton, { 4, 5, 2, 3 }, { GTK_EXPAND, 0 } );
gtk_widget_set_tooltip_text( button, "Hollow::warp" );
- gtk_widget_show( button );
+ ubutton.show();
g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( CSGdlg_HollowWrap ), &g_csgtool_dialog );
}
{
GtkWidget* button = gtk_button_new();
- button_set_icon( GTK_BUTTON( button ), "csgtool_extrude.png" );
- gtk_table_attach( table, button, 5, 6, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto ubutton = ui::Button::from( button );
+ button_set_icon( ubutton, "csgtool_extrude.png" );
+ table.attach( ubutton, { 5, 6, 2, 3 }, { GTK_EXPAND, 0 } );
gtk_widget_set_tooltip_text( button, "Hollow::extrude faces" );
- gtk_widget_show( button );
+ ubutton.show();
g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( CSGdlg_HollowExtrude ), &g_csgtool_dialog );
}
{
GtkWidget* button = gtk_button_new();
- button_set_icon( GTK_BUTTON( button ), "csgtool_pull.png" );
- gtk_table_attach( table, button, 6, 7, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto ubutton = ui::Button::from( button );
+ button_set_icon( ubutton, "csgtool_pull.png" );
+ table.attach( ubutton, { 6, 7, 2, 3 }, { GTK_EXPAND, 0 } );
gtk_widget_set_tooltip_text( button, "Hollow::pull faces" );
- gtk_widget_show( button );
+ ubutton.show();
g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( CSGdlg_HollowPull ), &g_csgtool_dialog );
}
#if !defined( INCLUDED_CSG_H )
#define INCLUDED_CSG_H
+
void CSG_MakeRoom( void );
+
void CSG_Subtract( void );
+
void CSG_Merge( void );
+
void CSG_Tool( void );
namespace scene
}
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
+
class Plane3;
void Scene_BrushSetClipPlane( scene::Graph& graph, const Plane3& plane );
+
enum EBrushSplit
{
eFront,
eBack,
eFrontAndBack,
};
+
void Scene_BrushSplitByPlane( scene::Graph& graph, const Vector3& p0, const Vector3& p1, const Vector3& p2, const char* shader, EBrushSplit split );
#endif
#include "dialog.h"
+#include <gtk/gtk.h>
+
#include "debugging/debugging.h"
#include <stdlib.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtktogglebutton.h>
-#include <gtk/gtkspinbutton.h>
-#include <gtk/gtkradiobutton.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkcombobox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkhscale.h>
-#include <gtk/gtkalignment.h>
-
#include "stream/stringstream.h"
#include "convert.h"
#include "gtkutil/dialog.h"
#include "gtkmisc.h"
-GtkEntry* DialogEntry_new(){
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 );
+ui::Entry DialogEntry_new(){
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ entry.dimensions(64, -1);
return entry;
}
class DialogEntryRow
{
public:
-DialogEntryRow( GtkWidget* row, GtkEntry* entry ) : m_row( row ), m_entry( entry ){
+DialogEntryRow( ui::Widget row, ui::Entry entry ) : m_row( row ), m_entry( entry ){
}
-GtkWidget* m_row;
-GtkEntry* m_entry;
+ui::Widget m_row;
+ui::Entry m_entry;
};
DialogEntryRow DialogEntryRow_new( const char* name ){
- GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 );
- gtk_widget_show( alignment );
+ auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
+ alignment.show();
- GtkEntry* entry = DialogEntry_new();
- gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( entry ) );
+ auto entry = DialogEntry_new();
+ alignment.add(entry);
- return DialogEntryRow( GTK_WIDGET( DialogRow_new( name, alignment ) ), entry );
+ return DialogEntryRow( ui::Widget(DialogRow_new( name, alignment )), entry );
}
-GtkSpinButton* DialogSpinner_new( double value, double lower, double upper, int fraction ){
+ui::SpinButton DialogSpinner_new( double value, double lower, double upper, int fraction ){
double step = 1.0 / double(fraction);
unsigned int digits = 0;
for (; fraction > 1; fraction /= 10 )
{
++digits;
}
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( value, lower, upper, step, 10, 0 ) ), step, digits ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 );
+ auto spin = ui::SpinButton( ui::Adjustment( value, lower, upper, step, 10, 0 ), step, digits );
+ spin.show();
+ spin.dimensions(64, -1);
return spin;
}
class DialogSpinnerRow
{
public:
-DialogSpinnerRow( GtkWidget* row, GtkSpinButton* spin ) : m_row( row ), m_spin( spin ){
+DialogSpinnerRow( ui::Widget row, ui::SpinButton spin ) : m_row( row ), m_spin( spin ){
}
-GtkWidget* m_row;
-GtkSpinButton* m_spin;
+ui::Widget m_row;
+ui::SpinButton m_spin;
};
DialogSpinnerRow DialogSpinnerRow_new( const char* name, double value, double lower, double upper, int fraction ){
- GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 );
- gtk_widget_show( alignment );
+ auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
+ alignment.show();
- GtkSpinButton* spin = DialogSpinner_new( value, lower, upper, fraction );
- gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( spin ) );
+ auto spin = DialogSpinner_new( value, lower, upper, fraction );
+ alignment.add(spin);
- return DialogSpinnerRow( GTK_WIDGET( DialogRow_new( name, alignment ) ), spin );
+ return DialogSpinnerRow( ui::Widget(DialogRow_new( name, alignment )), spin );
}
+struct BoolToggle {
+ static void Export(const ui::ToggleButton &self, const Callback<void(bool)> &returnz) {
+ returnz(self.active());
+ }
-template<
- typename Type_,
- typename Other_,
- void( *Import ) ( Type_&, Other_ ),
- void( *Export ) ( Type_&, const Callback1<Other_>& )
- >
-class ImportExport
-{
-public:
-typedef Type_ Type;
-typedef Other_ Other;
-
-typedef ReferenceCaller1<Type, Other, Import> ImportCaller;
-typedef ReferenceCaller1<Type, const Callback1<Other>&, Export> ExportCaller;
+ static void Import(ui::ToggleButton &self, bool value) {
+ self.active(value);
+ }
};
-typedef ImportExport<bool, bool, BoolImport, BoolExport> BoolImportExport;
-typedef ImportExport<int, int, IntImport, IntExport> IntImportExport;
-typedef ImportExport<std::size_t, std::size_t, SizeImport, SizeExport> SizeImportExport;
-typedef ImportExport<float, float, FloatImport, FloatExport> FloatImportExport;
-typedef ImportExport<CopiedString, const char*, StringImport, StringExport> StringImportExport;
+using BoolToggleImportExport = PropertyAdaptor<ui::ToggleButton, bool, BoolToggle>;
+struct IntEntry {
+ static void Export(const ui::Entry &self, const Callback<void(int)> &returnz) {
+ returnz(atoi(gtk_entry_get_text(self)));
+ }
+ static void Import(ui::Entry &self, int value) {
+ entry_set_int(self, value);
+ }
+};
-void BoolToggleImport( GtkToggleButton& widget, bool value ){
- gtk_toggle_button_set_active( &widget, value );
-}
-void BoolToggleExport( GtkToggleButton& widget, const BoolImportCallback& importCallback ){
- importCallback( gtk_toggle_button_get_active( &widget ) != FALSE );
-}
-typedef ImportExport<GtkToggleButton, bool, BoolToggleImport, BoolToggleExport> BoolToggleImportExport;
+using IntEntryImportExport = PropertyAdaptor<ui::Entry, int, IntEntry>;
+struct IntRadio {
+ static void Export(const ui::RadioButton &self, const Callback<void(int)> &returnz) {
+ returnz(radio_button_get_active(self));
+ }
-void IntRadioImport( GtkRadioButton& widget, int index ){
- radio_button_set_active( &widget, index );
-}
-void IntRadioExport( GtkRadioButton& widget, const IntImportCallback& importCallback ){
- importCallback( radio_button_get_active( &widget ) );
-}
-typedef ImportExport<GtkRadioButton, int, IntRadioImport, IntRadioExport> IntRadioImportExport;
+ static void Import(ui::RadioButton &self, int value) {
+ radio_button_set_active(self, value);
+ }
+};
-void TextEntryImport( GtkEntry& widget, const char* text ){
- gtk_entry_set_text( &widget, text );
-}
-void TextEntryExport( GtkEntry& widget, const StringImportCallback& importCallback ){
- importCallback( gtk_entry_get_text( &widget ) );
-}
-typedef ImportExport<GtkEntry, const char*, TextEntryImport, TextEntryExport> TextEntryImportExport;
+using IntRadioImportExport = PropertyAdaptor<ui::RadioButton, int, IntRadio>;
+struct IntCombo {
+ static void Export(const ui::ComboBox &self, const Callback<void(int)> &returnz) {
+ returnz(gtk_combo_box_get_active(self));
+ }
-void IntEntryImport( GtkEntry& widget, int value ){
- entry_set_int( &widget, value );
-}
-void IntEntryExport( GtkEntry& widget, const IntImportCallback& importCallback ){
- importCallback( atoi( gtk_entry_get_text( &widget ) ) );
-}
-typedef ImportExport<GtkEntry, int, IntEntryImport, IntEntryExport> IntEntryImportExport;
+ static void Import(ui::ComboBox &self, int value) {
+ gtk_combo_box_set_active(self, value);
+ }
+};
+using IntComboImportExport = PropertyAdaptor<ui::ComboBox, int, IntCombo>;
-void SizeEntryImport( GtkEntry& widget, std::size_t value ){
- entry_set_int( &widget, int(value) );
-}
-void SizeEntryExport( GtkEntry& widget, const SizeImportCallback& importCallback ){
- int value = atoi( gtk_entry_get_text( &widget ) );
- if ( value < 0 ) {
- value = 0;
+struct IntAdjustment {
+ static void Export(const ui::Adjustment &self, const Callback<void(int)> &returnz) {
+ returnz(int(gtk_adjustment_get_value(self)));
}
- importCallback( value );
-}
-typedef ImportExport<GtkEntry, std::size_t, SizeEntryImport, SizeEntryExport> SizeEntryImportExport;
+ static void Import(ui::Adjustment &self, int value) {
+ gtk_adjustment_set_value(self, value);
+ }
+};
-void FloatEntryImport( GtkEntry& widget, float value ){
- entry_set_float( &widget, value );
-}
-void FloatEntryExport( GtkEntry& widget, const FloatImportCallback& importCallback ){
- importCallback( (float)atof( gtk_entry_get_text( &widget ) ) );
-}
-typedef ImportExport<GtkEntry, float, FloatEntryImport, FloatEntryExport> FloatEntryImportExport;
+using IntAdjustmentImportExport = PropertyAdaptor<ui::Adjustment, int, IntAdjustment>;
+struct IntSpinner {
+ static void Export(const ui::SpinButton &self, const Callback<void(int)> &returnz) {
+ returnz(gtk_spin_button_get_value_as_int(self));
+ }
-void FloatSpinnerImport( GtkSpinButton& widget, float value ){
- gtk_spin_button_set_value( &widget, value );
-}
-void FloatSpinnerExport( GtkSpinButton& widget, const FloatImportCallback& importCallback ){
- importCallback( float(gtk_spin_button_get_value_as_float( &widget ) ) );
-}
-typedef ImportExport<GtkSpinButton, float, FloatSpinnerImport, FloatSpinnerExport> FloatSpinnerImportExport;
+ static void Import(ui::SpinButton &self, int value) {
+ gtk_spin_button_set_value(self, value);
+ }
+};
+using IntSpinnerImportExport = PropertyAdaptor<ui::SpinButton, int, IntSpinner>;
-void IntSpinnerImport( GtkSpinButton& widget, int value ){
- gtk_spin_button_set_value( &widget, value );
-}
-void IntSpinnerExport( GtkSpinButton& widget, const IntImportCallback& importCallback ){
- importCallback( gtk_spin_button_get_value_as_int( &widget ) );
-}
-typedef ImportExport<GtkSpinButton, int, IntSpinnerImport, IntSpinnerExport> IntSpinnerImportExport;
+struct TextEntry {
+ static void Export(const ui::Entry &self, const Callback<void(const char *)> &returnz) {
+ returnz(gtk_entry_get_text(self));
+ }
+ static void Import(ui::Entry &self, const char *value) {
+ self.text(value);
+ }
+};
-void IntAdjustmentImport( GtkAdjustment& widget, int value ){
- gtk_adjustment_set_value( &widget, value );
-}
-void IntAdjustmentExport( GtkAdjustment& widget, const IntImportCallback& importCallback ){
- importCallback( (int)gtk_adjustment_get_value( &widget ) );
-}
-typedef ImportExport<GtkAdjustment, int, IntAdjustmentImport, IntAdjustmentExport> IntAdjustmentImportExport;
+using TextEntryImportExport = PropertyAdaptor<ui::Entry, const char *, TextEntry>;
+struct SizeEntry {
+ static void Export(const ui::Entry &self, const Callback<void(std::size_t)> &returnz) {
+ int value = atoi(gtk_entry_get_text(self));
+ if (value < 0) {
+ value = 0;
+ }
+ returnz(value);
+ }
-void IntComboImport( GtkComboBox& widget, int value ){
- gtk_combo_box_set_active( &widget, value );
-}
-void IntComboExport( GtkComboBox& widget, const IntImportCallback& importCallback ){
- importCallback( gtk_combo_box_get_active( &widget ) );
-}
-typedef ImportExport<GtkComboBox, int, IntComboImport, IntComboExport> IntComboImportExport;
+ static void Import(ui::Entry &self, std::size_t value) {
+ entry_set_int(self, int(value));
+ }
+};
+using SizeEntryImportExport = PropertyAdaptor<ui::Entry, std::size_t, SizeEntry>;
-template<typename FirstArgument>
-class CallbackDialogData : public DLG_DATA
-{
-public:
-typedef Callback1<FirstArgument> ImportCallback;
-typedef Callback1<const ImportCallback&> ExportCallback;
+struct FloatEntry {
+ static void Export(const ui::Entry &self, const Callback<void(float)> &returnz) {
+ returnz(float(atof(gtk_entry_get_text(self))));
+ }
-private:
-ImportCallback m_importWidget;
-ExportCallback m_exportWidget;
-ImportCallback m_importViewer;
-ExportCallback m_exportViewer;
+ static void Import(ui::Entry &self, float value) {
+ entry_set_float(self, value);
+ }
+};
-public:
-CallbackDialogData( const ImportCallback& importWidget, const ExportCallback& exportWidget, const ImportCallback& importViewer, const ExportCallback& exportViewer )
- : m_importWidget( importWidget ), m_exportWidget( exportWidget ), m_importViewer( importViewer ), m_exportViewer( exportViewer ){
-}
-void release(){
- delete this;
-}
-void importData() const {
- m_exportViewer( m_importWidget );
-}
-void exportData() const {
- m_exportWidget( m_importViewer );
-}
+using FloatEntryImportExport = PropertyAdaptor<ui::Entry, float, FloatEntry>;
+
+struct FloatSpinner {
+ static void Export(const ui::SpinButton &self, const Callback<void(float)> &returnz) {
+ returnz(float(gtk_spin_button_get_value(self)));
+ }
+
+ static void Import(ui::SpinButton &self, float value) {
+ gtk_spin_button_set_value(self, value);
+ }
};
-template<typename Widget, typename Viewer>
-class AddData
-{
-DialogDataList& m_data;
+using FloatSpinnerImportExport = PropertyAdaptor<ui::SpinButton, float, FloatSpinner>;
+
+
+
+template<typename T>
+class CallbackDialogData : public DLG_DATA {
+ Property<T> m_pWidget;
+ Property<T> m_pData;
+
public:
-AddData( DialogDataList& data ) : m_data( data ){
-}
-void apply( typename Widget::Type& widget, typename Viewer::Type& viewer ) const {
- m_data.push_back(
- new CallbackDialogData<typename Widget::Other>(
- typename Widget::ImportCaller( widget ),
- typename Widget::ExportCaller( widget ),
- typename Viewer::ImportCaller( viewer ),
- typename Viewer::ExportCaller( viewer )
- )
- );
-}
+ CallbackDialogData(const Property<T> &pWidget, const Property<T> &pData)
+ : m_pWidget(pWidget), m_pData(pData) {
+ }
+
+ void release() {
+ delete this;
+ }
+
+ void importData() const {
+ m_pData.get(m_pWidget.set);
+ }
+
+ void exportData() const {
+ m_pWidget.get(m_pData.set);
+ }
};
-template<typename Widget>
-class AddCustomData
-{
-DialogDataList& m_data;
-public:
-AddCustomData( DialogDataList& data ) : m_data( data ){
-}
-void apply(
- typename Widget::Type& widget,
- const Callback1<typename Widget::Other>& importViewer,
- const Callback1<const Callback1<typename Widget::Other>&>& exportViewer
- ) const {
- m_data.push_back(
- new CallbackDialogData<typename Widget::Other>(
- typename Widget::ImportCaller( widget ),
- typename Widget::ExportCaller( widget ),
- importViewer,
- exportViewer
- )
- );
+template<class Widget>
+void AddDataCustom(DialogDataList &self, typename Widget::Type widget, Property<typename Widget::Other> const &property) {
+ using Self = typename Widget::Type;
+ using T = typename Widget::Other;
+ using native = typename std::remove_pointer<typename Self::native>::type;
+ struct Wrapper {
+ static void Export(const native &self, const Callback<void(T)> &returnz) {
+ native *p = &const_cast<native &>(self);
+ auto widget = Self::from(p);
+ Widget::Get::thunk_(widget, returnz);
+ }
+
+ static void Import(native &self, T value) {
+ native *p = &self;
+ auto widget = Self::from(p);
+ Widget::Set::thunk_(widget, value);
+ }
+ };
+ self.push_back(new CallbackDialogData<typename Widget::Other>(
+ make_property<PropertyAdaptor<native, T, Wrapper>>(*static_cast<native *>(widget)),
+ property
+ ));
+}
+
+template<class Widget, class D>
+void AddData(DialogDataList &self, typename Widget::Type widget, D &data) {
+ AddDataCustom<Widget>(self, widget, make_property<PropertyAdaptor<D, typename Widget::Other>>(data));
}
-};
// =============================================================================
// Dialog class
-Dialog::Dialog() : m_window( 0 ), m_parent( 0 ){
+Dialog::Dialog() : m_window( ui::null ), m_parent( ui::null ){
}
Dialog::~Dialog(){
( *i )->release();
}
- ASSERT_MESSAGE( m_window == 0, "dialog window not destroyed" );
+ ASSERT_MESSAGE( !m_window, "dialog window not destroyed" );
}
void Dialog::ShowDlg(){
- ASSERT_MESSAGE( m_window != 0, "dialog was not constructed" );
+ ASSERT_MESSAGE( m_window, "dialog was not constructed" );
importData();
- gtk_widget_show( GTK_WIDGET( m_window ) );
+ m_window.show();
}
void Dialog::HideDlg(){
- ASSERT_MESSAGE( m_window != 0, "dialog was not constructed" );
+ ASSERT_MESSAGE( m_window, "dialog was not constructed" );
exportData();
- gtk_widget_hide( GTK_WIDGET( m_window ) );
+ m_window.hide();
}
-static gint delete_event_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
+static gint delete_event_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
reinterpret_cast<Dialog*>( data )->HideDlg();
reinterpret_cast<Dialog*>( data )->EndModal( eIDCANCEL );
return TRUE;
}
void Dialog::Create(){
- ASSERT_MESSAGE( m_window == 0, "dialog cannot be constructed" );
+ ASSERT_MESSAGE( !m_window, "dialog cannot be constructed" );
m_window = BuildDialog();
- g_signal_connect( G_OBJECT( m_window ), "delete_event", G_CALLBACK( delete_event_callback ), this );
+ m_window.connect( "delete_event", G_CALLBACK( delete_event_callback ), this );
}
void Dialog::Destroy(){
- ASSERT_MESSAGE( m_window != 0, "dialog cannot be destroyed" );
+ ASSERT_MESSAGE( m_window, "dialog cannot be destroyed" );
- gtk_widget_destroy( GTK_WIDGET( m_window ) );
- m_window = 0;
+ m_window.destroy();
+ m_window = ui::Window{ui::null};
}
-void Dialog::AddBoolToggleData( GtkToggleButton& widget, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
- AddCustomData<BoolToggleImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddBoolToggleData( ui::ToggleButton widget, Property<bool> const &cb ){
+ AddDataCustom<BoolToggleImportExport>( m_data, widget, cb );
}
-void Dialog::AddIntRadioData( GtkRadioButton& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- AddCustomData<IntRadioImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddIntRadioData( ui::RadioButton widget, Property<int> const &cb ){
+ AddDataCustom<IntRadioImportExport>( m_data, widget, cb );
}
-void Dialog::AddTextEntryData( GtkEntry& widget, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){
- AddCustomData<TextEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddTextEntryData( ui::Entry widget, Property<const char *> const &cb ){
+ AddDataCustom<TextEntryImportExport>( m_data, widget, cb );
}
-void Dialog::AddIntEntryData( GtkEntry& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- AddCustomData<IntEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddIntEntryData( ui::Entry widget, Property<int> const &cb ){
+ AddDataCustom<IntEntryImportExport>( m_data, widget, cb );
}
-void Dialog::AddSizeEntryData( GtkEntry& widget, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
- AddCustomData<SizeEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddSizeEntryData( ui::Entry widget, Property<std::size_t> const &cb ){
+ AddDataCustom<SizeEntryImportExport>( m_data, widget, cb );
}
-void Dialog::AddFloatEntryData( GtkEntry& widget, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
- AddCustomData<FloatEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddFloatEntryData( ui::Entry widget, Property<float> const &cb ){
+ AddDataCustom<FloatEntryImportExport>( m_data, widget, cb );
}
-void Dialog::AddFloatSpinnerData( GtkSpinButton& widget, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
- AddCustomData<FloatSpinnerImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddFloatSpinnerData( ui::SpinButton widget, Property<float> const &cb ){
+ AddDataCustom<FloatSpinnerImportExport>( m_data, widget, cb );
}
-void Dialog::AddIntSpinnerData( GtkSpinButton& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- AddCustomData<IntSpinnerImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddIntSpinnerData( ui::SpinButton widget, Property<int> const &cb ){
+ AddDataCustom<IntSpinnerImportExport>( m_data, widget, cb );
}
-void Dialog::AddIntAdjustmentData( GtkAdjustment& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- AddCustomData<IntAdjustmentImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddIntAdjustmentData( ui::Adjustment widget, Property<int> const &cb ){
+ AddDataCustom<IntAdjustmentImportExport>( m_data, widget, cb );
}
-void Dialog::AddIntComboData( GtkComboBox& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- AddCustomData<IntComboImportExport>( m_data ).apply( widget, importViewer, exportViewer );
+void Dialog::AddIntComboData( ui::ComboBox widget, Property<int> const &cb ){
+ AddDataCustom<IntComboImportExport>( m_data, widget, cb );
}
-void Dialog::AddDialogData( GtkToggleButton& widget, bool& data ){
- AddData<BoolToggleImportExport, BoolImportExport>( m_data ).apply( widget, data );
+void Dialog::AddDialogData( ui::ToggleButton widget, bool& data ){
+ AddData<BoolToggleImportExport>( m_data, widget, data );
}
-void Dialog::AddDialogData( GtkRadioButton& widget, int& data ){
- AddData<IntRadioImportExport, IntImportExport>( m_data ).apply( widget, data );
+void Dialog::AddDialogData( ui::RadioButton widget, int& data ){
+ AddData<IntRadioImportExport>( m_data, widget, data );
}
-void Dialog::AddDialogData( GtkEntry& widget, CopiedString& data ){
- AddData<TextEntryImportExport, StringImportExport>( m_data ).apply( widget, data );
+void Dialog::AddDialogData( ui::Entry widget, CopiedString& data ){
+ AddData<TextEntryImportExport>( m_data, widget, data );
}
-void Dialog::AddDialogData( GtkEntry& widget, int& data ){
- AddData<IntEntryImportExport, IntImportExport>( m_data ).apply( widget, data );
+void Dialog::AddDialogData( ui::Entry widget, int& data ){
+ AddData<IntEntryImportExport>( m_data, widget, data );
}
-void Dialog::AddDialogData( GtkEntry& widget, std::size_t& data ){
- AddData<SizeEntryImportExport, SizeImportExport>( m_data ).apply( widget, data );
+void Dialog::AddDialogData( ui::Entry widget, std::size_t& data ){
+ AddData<SizeEntryImportExport>( m_data, widget, data );
}
-void Dialog::AddDialogData( GtkEntry& widget, float& data ){
- AddData<FloatEntryImportExport, FloatImportExport>( m_data ).apply( widget, data );
+void Dialog::AddDialogData( ui::Entry widget, float& data ){
+ AddData<FloatEntryImportExport>( m_data, widget, data );
}
-void Dialog::AddDialogData( GtkSpinButton& widget, float& data ){
- AddData<FloatSpinnerImportExport, FloatImportExport>( m_data ).apply( widget, data );
+void Dialog::AddDialogData( ui::SpinButton widget, float& data ){
+ AddData<FloatSpinnerImportExport>( m_data, widget, data );
}
-void Dialog::AddDialogData( GtkSpinButton& widget, int& data ){
- AddData<IntSpinnerImportExport, IntImportExport>( m_data ).apply( widget, data );
+void Dialog::AddDialogData( ui::SpinButton widget, int& data ){
+ AddData<IntSpinnerImportExport>( m_data, widget, data );
}
-void Dialog::AddDialogData( GtkAdjustment& widget, int& data ){
- AddData<IntAdjustmentImportExport, IntImportExport>( m_data ).apply( widget, data );
+void Dialog::AddDialogData( ui::Adjustment widget, int& data ){
+ AddData<IntAdjustmentImportExport>( m_data, widget, data );
}
-void Dialog::AddDialogData( GtkComboBox& widget, int& data ){
- AddData<IntComboImportExport, IntImportExport>( m_data ).apply( widget, data );
+void Dialog::AddDialogData( ui::ComboBox widget, int& data ){
+ AddData<IntComboImportExport>( m_data, widget, data );
}
void Dialog::exportData(){
PreModal();
EMessageBoxReturn ret = modal_dialog_show( m_window, m_modal );
- ASSERT_NOTNULL( m_window );
+ ASSERT_TRUE( (bool) m_window );
if ( ret == eIDOK ) {
exportData();
}
- gtk_widget_hide( GTK_WIDGET( m_window ) );
+ m_window.hide();
PostModal( m_modal.ret );
}
-GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
- GtkWidget* check = gtk_check_button_new_with_label( flag );
- gtk_widget_show( check );
- AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer );
+ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, Property<bool> const &cb ){
+ auto check = ui::CheckButton( flag );
+ check.show();
+ AddBoolToggleData( check, cb );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, check ) ) );
+ DialogVBox_packRow( vbox, ui::Widget(DialogRow_new( name, check ) ));
return check;
}
-GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* flag, bool& data ){
- return addCheckBox( vbox, name, flag, BoolImportCaller( data ), BoolExportCaller( data ) );
+ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, bool& data ){
+ return addCheckBox(vbox, name, flag, make_property(data));
}
-void Dialog::addCombo( GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 );
- gtk_widget_show( alignment );
+void Dialog::addCombo( ui::VBox vbox, const char* name, StringArrayRange values, Property<int> const &cb ){
+ auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
+ alignment.show();
{
- GtkWidget* combo = gtk_combo_box_new_text();
+ auto combo = ui::ComboBoxText(ui::New);
for ( StringArrayRange::Iterator i = values.first; i != values.last; ++i )
{
- gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), *i );
+ gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), *i );
}
- AddIntComboData( *GTK_COMBO_BOX( combo ), importViewer, exportViewer );
+ AddIntComboData( combo, cb );
- gtk_widget_show( combo );
- gtk_container_add( GTK_CONTAINER( alignment ), combo );
+ combo.show();
+ alignment.add(combo);
}
- GtkTable* row = DialogRow_new( name, alignment );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+ auto row = DialogRow_new( name, alignment );
+ DialogVBox_packRow( vbox, row );
}
-void Dialog::addCombo( GtkWidget* vbox, const char* name, int& data, StringArrayRange values ){
- addCombo( vbox, name, values, IntImportCaller( data ), IntExportCaller( data ) );
+void Dialog::addCombo( ui::VBox vbox, const char* name, int& data, StringArrayRange values ){
+ addCombo(vbox, name, values, make_property(data));
}
-void Dialog::addSlider( GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
+void Dialog::addSlider( ui::VBox vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
#if 0
if ( draw_value == FALSE ) {
- GtkWidget* hbox2 = gtk_hbox_new( FALSE, 0 );
- gtk_widget_show( hbox2 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 );
+ auto hbox2 = ui::HBox( FALSE, 0 );
+ hbox2.show();
+ vbox.pack_start( hbox2 , FALSE, FALSE, 0 );
{
- GtkWidget* label = gtk_label_new( low );
- gtk_widget_show( label );
- gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
+ ui::Widget label = ui::Label( low );
+ label.show();
+ hbox2.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkWidget* label = gtk_label_new( high );
- gtk_widget_show( label );
- gtk_box_pack_end( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
+ ui::Widget label = ui::Label( high );
+ label.show();
+ hbox2.pack_end(label, FALSE, FALSE, 0);
}
}
#endif
// adjustment
- GtkObject* adj = gtk_adjustment_new( value, lower, upper, step_increment, page_increment, 0 );
- AddIntAdjustmentData( *GTK_ADJUSTMENT( adj ), IntImportCaller( data ), IntExportCaller( data ) );
+ auto adj = ui::Adjustment( value, lower, upper, step_increment, page_increment, 0 );
+ AddIntAdjustmentData(adj, make_property(data));
// scale
- GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 1.0, 0.0 );
- gtk_widget_show( alignment );
+ auto alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 );
+ alignment.show();
- GtkWidget* scale = gtk_hscale_new( GTK_ADJUSTMENT( adj ) );
+ ui::Widget scale = ui::HScale( adj );
gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_LEFT );
- gtk_widget_show( scale );
- gtk_container_add( GTK_CONTAINER( alignment ), scale );
+ scale.show();
+ alignment.add(scale);
gtk_scale_set_draw_value( GTK_SCALE( scale ), draw_value );
gtk_scale_set_digits( GTK_SCALE( scale ), 0 );
- GtkTable* row = DialogRow_new( name, alignment );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+ auto row = DialogRow_new( name, alignment );
+ DialogVBox_packRow( vbox, row );
}
-void Dialog::addRadio( GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 );
- gtk_widget_show( alignment );
+void Dialog::addRadio( ui::VBox vbox, const char* name, StringArrayRange names, Property<int> const &cb ){
+ auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
+ alignment.show();;
{
RadioHBox radioBox = RadioHBox_new( names );
- gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( radioBox.m_hbox ) );
- AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), importViewer, exportViewer );
+ alignment.add(radioBox.m_hbox);
+ AddIntRadioData( radioBox.m_radio, cb );
}
- GtkTable* row = DialogRow_new( name, alignment );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+ auto row = DialogRow_new( name, alignment );
+ DialogVBox_packRow( vbox, row );
}
-void Dialog::addRadio( GtkWidget* vbox, const char* name, int& data, StringArrayRange names ){
- addRadio( vbox, name, names, IntImportCaller( data ), IntExportCaller( data ) );
+void Dialog::addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRange names ){
+ addRadio(vbox, name, names, make_property(data));
}
-void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
- GtkWidget* table = gtk_table_new( 2, static_cast<guint>( icons.last - icons.first ), FALSE );
- gtk_widget_show( table );
+void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, Property<int> const &cb ){
+ auto table = ui::Table(2, icons.last - icons.first, FALSE);
+ table.show();
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
GSList* group = 0;
- GtkWidget* radio = 0;
+ ui::RadioButton radio{ui::null};
for ( StringArrayRange::Iterator icon = icons.first; icon != icons.last; ++icon )
{
guint pos = static_cast<guint>( icon - icons.first );
- GtkImage* image = new_local_image( *icon );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( image ), pos, pos + 1, 0, 1,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
-
- radio = gtk_radio_button_new( group );
- gtk_widget_show( radio );
- gtk_table_attach( GTK_TABLE( table ), radio, pos, pos + 1, 1, 2,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto image = new_local_image( *icon );
+ image.show();
+ table.attach(image, {pos, pos + 1, 0, 1}, {0, 0});
+
+ radio = ui::RadioButton::from(gtk_radio_button_new( group ));
+ radio.show();
+ table.attach(radio, {pos, pos + 1, 1, 2}, {0, 0});
group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) );
}
- AddIntRadioData( *GTK_RADIO_BUTTON( radio ), importViewer, exportViewer );
+ AddIntRadioData( radio, cb );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, table ) ) );
+ DialogVBox_packRow( vbox, DialogRow_new( name, table ) );
}
-void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, int& data, StringArrayRange icons ){
- addRadioIcons( vbox, name, icons, IntImportCaller( data ), IntExportCaller( data ) );
+void Dialog::addRadioIcons( ui::VBox vbox, const char* name, int& data, StringArrayRange icons ){
+ addRadioIcons(vbox, name, icons, make_property(data));
}
-GtkWidget* Dialog::addIntEntry( GtkWidget* vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+ui::Widget Dialog::addIntEntry( ui::VBox vbox, const char* name, Property<int> const &cb ){
DialogEntryRow row( DialogEntryRow_new( name ) );
- AddIntEntryData( *row.m_entry, importViewer, exportViewer );
- DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
+ AddIntEntryData( row.m_entry, cb );
+ DialogVBox_packRow( vbox, row.m_row );
return row.m_row;
}
-GtkWidget* Dialog::addSizeEntry( GtkWidget* vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
+ui::Widget Dialog::addSizeEntry( ui::VBox vbox, const char* name, Property<std::size_t> const &cb ){
DialogEntryRow row( DialogEntryRow_new( name ) );
- AddSizeEntryData( *row.m_entry, importViewer, exportViewer );
- DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
+ AddSizeEntryData( row.m_entry, cb );
+ DialogVBox_packRow( vbox, row.m_row );
return row.m_row;
}
-GtkWidget* Dialog::addFloatEntry( GtkWidget* vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
+ui::Widget Dialog::addFloatEntry( ui::VBox vbox, const char* name, Property<float> const &cb ){
DialogEntryRow row( DialogEntryRow_new( name ) );
- AddFloatEntryData( *row.m_entry, importViewer, exportViewer );
- DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
+ AddFloatEntryData( row.m_entry, cb );
+ DialogVBox_packRow( vbox, row.m_row );
return row.m_row;
}
-GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){
+ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, Property<const char *> const &cb ){
PathEntry pathEntry = PathEntry_new();
- g_signal_connect( G_OBJECT( pathEntry.m_button ), "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry );
+ pathEntry.m_button.connect( "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry );
- AddTextEntryData( *GTK_ENTRY( pathEntry.m_entry ), importViewer, exportViewer );
+ AddTextEntryData( pathEntry.m_entry, cb );
- GtkTable* row = DialogRow_new( name, GTK_WIDGET( pathEntry.m_frame ) );
- DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+ auto row = DialogRow_new( name, ui::Widget(pathEntry.m_frame ) );
+ DialogVBox_packRow( vbox, row );
- return GTK_WIDGET( row );
+ return row;
}
-GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, CopiedString& data, bool browse_directory ){
- return addPathEntry( vbox, name, browse_directory, StringImportCallback( StringImportCaller( data ) ), StringExportCallback( StringExportCaller( data ) ) );
+ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, CopiedString& data, bool browse_directory ){
+ return addPathEntry(vbox, name, browse_directory, make_property<CopiedString, const char *>(data));
}
-GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
+ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, Property<int> const &cb ){
DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) );
- AddIntSpinnerData( *row.m_spin, importViewer, exportViewer );
- DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
- return row.m_row;
+ AddIntSpinnerData( row.m_spin, cb );
+ DialogVBox_packRow( vbox, row.m_row );
+ return row.m_spin;
}
-GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper ){
- return addSpinner( vbox, name, value, lower, upper, IntImportCallback( IntImportCaller( data ) ), IntExportCallback( IntExportCaller( data ) ) );
+ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, int& data, double value, double lower, double upper ){
+ return addSpinner(vbox, name, value, lower, upper, make_property(data));
}
-GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
+ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, Property<float> const &cb ){
DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) );
- AddFloatSpinnerData( *row.m_spin, importViewer, exportViewer );
- DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
- return row.m_row;
+ AddFloatSpinnerData( row.m_spin, cb );
+ DialogVBox_packRow( vbox, row.m_row );
+ return row.m_spin;
}
#define INCLUDED_DIALOG_H
#include <list>
+#include <uilib/uilib.h>
+#include "property.h"
+#include "generic/callback.h"
#include "gtkutil/dialog.h"
#include "generic/callback.h"
#include "string/string.h"
-template<typename Environment, typename FirstArgument, void( *func ) ( Environment&, FirstArgument )>
-class ReferenceCaller1;
+struct DLG_DATA
+{
+ virtual ~DLG_DATA() = default;
+ virtual void release() = 0;
+ virtual void importData() const = 0;
+ virtual void exportData() const = 0;
+};
-inline void BoolImport( bool& self, bool value ){
- self = value;
-}
-typedef ReferenceCaller1<bool, bool, BoolImport> BoolImportCaller;
-inline void BoolExport( bool& self, const BoolImportCallback& importCallback ){
- importCallback( self );
-}
-typedef ReferenceCaller1<bool, const BoolImportCallback&, BoolExport> BoolExportCaller;
+template<typename FirstArgument>
+class CallbackDialogData;
+typedef std::list<DLG_DATA*> DialogDataList;
-inline void IntImport( int& self, int value ){
- self = value;
-}
-typedef ReferenceCaller1<int, int, IntImport> IntImportCaller;
+class Dialog {
+ ui::Window m_window;
+ DialogDataList m_data;
+public:
+ ModalDialog m_modal;
+ ui::Window m_parent;
-inline void IntExport( int& self, const IntImportCallback& importCallback ){
- importCallback( self );
-}
-typedef ReferenceCaller1<int, const IntImportCallback&, IntExport> IntExportCaller;
+ Dialog();
+ virtual ~Dialog();
-inline void SizeImport( std::size_t& self, std::size_t value ){
- self = value;
-}
-typedef ReferenceCaller1<std::size_t, std::size_t, SizeImport> SizeImportCaller;
+/*!
+ start modal dialog box
+ you need to use AddModalButton to select eIDOK eIDCANCEL buttons
+ */
+ EMessageBoxReturn DoModal();
-inline void SizeExport( std::size_t& self, const SizeImportCallback& importCallback ){
- importCallback( self );
-}
-typedef ReferenceCaller1<std::size_t, const SizeImportCallback&, SizeExport> SizeExportCaller;
+ void EndModal(EMessageBoxReturn code);
+ virtual ui::Window BuildDialog() = 0;
-inline void FloatImport( float& self, float value ){
- self = value;
-}
-typedef ReferenceCaller1<float, float, FloatImport> FloatImportCaller;
+ virtual void exportData();
-inline void FloatExport( float& self, const FloatImportCallback& importCallback ){
- importCallback( self );
-}
-typedef ReferenceCaller1<float, const FloatImportCallback&, FloatExport> FloatExportCaller;
+ virtual void importData();
+ virtual void PreModal() {};
-inline void StringImport( CopiedString& self, const char* value ){
- self = value;
-}
-typedef ReferenceCaller1<CopiedString, const char*, StringImport> StringImportCaller;
-inline void StringExport( CopiedString& self, const StringImportCallback& importCallback ){
- importCallback( self.c_str() );
-}
-typedef ReferenceCaller1<CopiedString, const StringImportCallback&, StringExport> StringExportCaller;
+ virtual void PostModal(EMessageBoxReturn code) {};
+ virtual void ShowDlg();
-struct DLG_DATA
-{
- virtual void release() = 0;
- virtual void importData() const = 0;
- virtual void exportData() const = 0;
-};
+ virtual void HideDlg();
-typedef struct _GtkWindow GtkWindow;
-typedef struct _GtkToggleButton GtkToggleButton;
-typedef struct _GtkRadioButton GtkRadioButton;
-typedef struct _GtkSpinButton GtkSpinButton;
-typedef struct _GtkComboBox GtkComboBox;
-typedef struct _GtkEntry GtkEntry;
-typedef struct _GtkAdjustment GtkAdjustment;
+ void Create();
-template<typename FirstArgument>
-class CallbackDialogData;
+ void Destroy();
-typedef std::list<DLG_DATA*> DialogDataList;
+ ui::Window GetWidget() {
+ return m_window;
+ }
-class Dialog
-{
-GtkWindow* m_window;
-DialogDataList m_data;
-public:
-ModalDialog m_modal;
-GtkWindow* m_parent;
+ const ui::Window GetWidget() const {
+ return m_window;
+ }
-Dialog();
-virtual ~Dialog();
+ ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, Property<bool> const &cb);
-/*!
- start modal dialog box
- you need to use AddModalButton to select eIDOK eIDCANCEL buttons
- */
-EMessageBoxReturn DoModal();
-void EndModal( EMessageBoxReturn code );
-virtual GtkWindow* BuildDialog() = 0;
-virtual void exportData();
-virtual void importData();
-virtual void PreModal() { };
-virtual void PostModal( EMessageBoxReturn code ) { };
-virtual void ShowDlg();
-virtual void HideDlg();
-void Create();
-void Destroy();
-GtkWindow* GetWidget(){
- return m_window;
-}
-const GtkWindow* GetWidget() const {
- return m_window;
-}
-
-GtkWidget* addCheckBox( GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback );
-GtkWidget* addCheckBox( GtkWidget* vbox, const char* name, const char* flag, bool& data );
-void addCombo( GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void addCombo( GtkWidget* vbox, const char* name, int& data, StringArrayRange values );
-void addSlider( GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment );
-void addRadio( GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void addRadio( GtkWidget* vbox, const char* name, int& data, StringArrayRange names );
-void addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void addRadioIcons( GtkWidget* vbox, const char* name, int& data, StringArrayRange icons );
-GtkWidget* addIntEntry( GtkWidget* vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-GtkWidget* addEntry( GtkWidget* vbox, const char* name, int& data ){
- return addIntEntry( vbox, name, IntImportCaller( data ), IntExportCaller( data ) );
-}
-GtkWidget* addSizeEntry( GtkWidget* vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback );
-GtkWidget* addEntry( GtkWidget* vbox, const char* name, std::size_t& data ){
- return addSizeEntry( vbox, name, SizeImportCaller( data ), SizeExportCaller( data ) );
-}
-GtkWidget* addFloatEntry( GtkWidget* vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
-GtkWidget* addEntry( GtkWidget* vbox, const char* name, float& data ){
- return addFloatEntry( vbox, name, FloatImportCaller( data ), FloatExportCaller( data ) );
-}
-GtkWidget* addPathEntry( GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback );
-GtkWidget* addPathEntry( GtkWidget* vbox, const char* name, CopiedString& data, bool directory );
-GtkWidget* addSpinner( GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper );
-GtkWidget* addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-GtkWidget* addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
+ ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, bool &data);
+
+ void addCombo(ui::VBox vbox, const char *name, StringArrayRange values, Property<int> const &cb);
+
+ void addCombo(ui::VBox vbox, const char *name, int &data, StringArrayRange values);
+
+ void addSlider(ui::VBox vbox, const char *name, int &data, gboolean draw_value, const char *low, const char *high,
+ double value, double lower, double upper, double step_increment, double page_increment);
+
+ void addRadio(ui::VBox vbox, const char *name, StringArrayRange names, Property<int> const &cb);
+
+ void addRadio(ui::VBox vbox, const char *name, int &data, StringArrayRange names);
+
+ void addRadioIcons(ui::VBox vbox, const char *name, StringArrayRange icons, Property<int> const &cb);
+
+ void addRadioIcons(ui::VBox vbox, const char *name, int &data, StringArrayRange icons);
+
+ ui::Widget addIntEntry(ui::VBox vbox, const char *name, Property<int> const &cb);
+
+ ui::Widget addEntry(ui::VBox vbox, const char *name, int &data) {
+ return addIntEntry(vbox, name, make_property(data));
+ }
+
+ ui::Widget addSizeEntry(ui::VBox vbox, const char *name, Property<std::size_t> const &cb);
+
+ ui::Widget addEntry(ui::VBox vbox, const char *name, std::size_t &data) {
+ return addSizeEntry(vbox, name, make_property(data));
+ }
+
+ ui::Widget addFloatEntry(ui::VBox vbox, const char *name, Property<float> const &cb);
+
+ ui::Widget addEntry(ui::VBox vbox, const char *name, float &data) {
+ return addFloatEntry(vbox, name, make_property(data));
+ }
+
+ ui::Widget addPathEntry(ui::VBox vbox, const char *name, bool browse_directory, Property<const char *> const &cb);
+
+ ui::Widget addPathEntry(ui::VBox vbox, const char *name, CopiedString &data, bool directory);
+
+ ui::SpinButton addSpinner(ui::VBox vbox, const char *name, int &data, double value, double lower, double upper);
+
+ ui::SpinButton
+ addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper, Property<int> const &cb);
+
+ ui::SpinButton
+ addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper, Property<float> const &cb);
protected:
-void AddBoolToggleData( GtkToggleButton& object, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback );
-void AddIntRadioData( GtkRadioButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void AddTextEntryData( GtkEntry& object, const StringImportCallback& importCallback, const StringExportCallback& exportCallback );
-void AddIntEntryData( GtkEntry& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void AddSizeEntryData( GtkEntry& object, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback );
-void AddFloatEntryData( GtkEntry& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
-void AddFloatSpinnerData( GtkSpinButton& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback );
-void AddIntSpinnerData( GtkSpinButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void AddIntAdjustmentData( GtkAdjustment& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-void AddIntComboData( GtkComboBox& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback );
-
-void AddDialogData( GtkToggleButton& object, bool& data );
-void AddDialogData( GtkRadioButton& object, int& data );
-void AddDialogData( GtkEntry& object, CopiedString& data );
-void AddDialogData( GtkEntry& object, int& data );
-void AddDialogData( GtkEntry& object, std::size_t& data );
-void AddDialogData( GtkEntry& object, float& data );
-void AddDialogData( GtkSpinButton& object, float& data );
-void AddDialogData( GtkSpinButton& object, int& data );
-void AddDialogData( GtkAdjustment& object, int& data );
-void AddDialogData( GtkComboBox& object, int& data );
+ void AddBoolToggleData(ui::ToggleButton object, Property<bool> const &cb);
+
+ void AddIntRadioData(ui::RadioButton object, Property<int> const &cb);
+
+ void AddTextEntryData(ui::Entry object, Property<const char *> const &cb);
+
+ void AddIntEntryData(ui::Entry object, Property<int> const &cb);
+
+ void AddSizeEntryData(ui::Entry object, Property<std::size_t> const &cb);
+
+ void AddFloatEntryData(ui::Entry object, Property<float> const &cb);
+
+ void AddFloatSpinnerData(ui::SpinButton object, Property<float> const &cb);
+
+ void AddIntSpinnerData(ui::SpinButton object, Property<int> const &cb);
+
+ void AddIntAdjustmentData(ui::Adjustment object, Property<int> const &cb);
+
+ void AddIntComboData(ui::ComboBox object, Property<int> const &cb);
+
+ void AddDialogData(ui::ToggleButton object, bool &data);
+
+ void AddDialogData(ui::RadioButton object, int &data);
+
+ void AddDialogData(ui::Entry object, CopiedString &data);
+
+ void AddDialogData(ui::Entry object, int &data);
+
+ void AddDialogData(ui::Entry object, std::size_t &data);
+
+ void AddDialogData(ui::Entry object, float &data);
+
+ void AddDialogData(ui::SpinButton object, float &data);
+
+ void AddDialogData(ui::SpinButton object, int &data);
+
+ void AddDialogData(ui::Adjustment object, int &data);
+
+ void AddDialogData(ui::ComboBox object, int &data);
};
#endif
typedef std::map<CopiedString, const char*, PathLess> Paths;
-class PathsInsert
-{
-Paths& m_paths;
-const char* m_directory;
-public:
-PathsInsert( Paths& paths, const char* directory ) : m_paths( paths ), m_directory( directory ){
-}
-void operator()( const char* name ) const {
- m_paths.insert( Paths::value_type( name, m_directory ) );
-}
-};
-
-
void EntityClassQuake3_constructDirectory( const char* directory, const char* extension, Paths& paths ){
globalOutputStream() << "EntityClass: searching " << makeQuoted( directory ) << " for *." << extension << '\n';
- Directory_forEach( directory, matchFileExtension( extension, PathsInsert( paths, directory ) ) );
+ Directory_forEach(directory, matchFileExtension(extension, [&](const char *name) {
+ paths.insert(Paths::value_type(name, directory));
+ }));
}
m_eclassmanager.realise = &EntityClass_realise;
m_eclassmanager.unrealise = &EntityClass_unrealise;
- GlobalRadiant().attachGameToolsPathObserver( g_EntityClassQuake3 );
- GlobalRadiant().attachGameModeObserver( g_EntityClassQuake3 );
- GlobalRadiant().attachGameNameObserver( g_EntityClassQuake3 );
+ Radiant_attachGameToolsPathObserver( g_EntityClassQuake3 );
+ Radiant_attachGameModeObserver( g_EntityClassQuake3 );
+ Radiant_attachGameNameObserver( g_EntityClassQuake3 );
}
~EclassManagerAPI(){
- GlobalRadiant().detachGameNameObserver( g_EntityClassQuake3 );
- GlobalRadiant().detachGameModeObserver( g_EntityClassQuake3 );
- GlobalRadiant().detachGameToolsPathObserver( g_EntityClassQuake3 );
+ Radiant_detachGameNameObserver( g_EntityClassQuake3 );
+ Radiant_detachGameModeObserver( g_EntityClassQuake3 );
+ Radiant_detachGameToolsPathObserver( g_EntityClassQuake3 );
EntityClassQuake3_destroy();
}
globalErrorStream() << message;
}
-#define PARSE_RETURN_FALSE_IF_FAIL( expression ) if ( !( expression ) ) { printParseError( FILE_LINE "\nparse failed: " # expression "\n" ); return false; } else
+#define PARSE_RETURN_FALSE_IF_FAIL(expression) do { if (!( expression)) { printParseError(FILE_LINE "\nparse failed: " #expression "\n"); return false; } } while (0)
bool EntityClassDoom3_parseToken( Tokeniser& tokeniser ){
const char* token = tokeniser.getToken();
else
{
CopiedString tmp( key );
- //ASSERT_MESSAGE( !string_equal_n( key, "editor_", 7 ), "unsupported editor key: " << makeQuoted( key ) );
if ( string_equal_n( key, "editor_", 7 ) ) {
globalErrorStream() << "unsupported editor key " << makeQuoted( key ) ;
}
void realise(){
if ( --m_unrealised == 0 ) {
globalOutputStream() << "searching vfs directory " << makeQuoted( "def" ) << " for *.def\n";
- GlobalFileSystem().forEachFile( "def/", "def", FreeCaller1<const char*, EntityClassDoom3_loadFile>() );
+ GlobalFileSystem().forEachFile( "def/", "def", makeCallbackF(EntityClassDoom3_loadFile) );
{
for ( Models::iterator i = g_models.begin(); i != g_models.end(); ++i )
#include "ifilesystem.h"
#include "iscriplib.h"
#include "qerplugin.h"
+#include "mainframe.h"
#include "string/string.h"
#include "eclasslib.h"
return string_equal( tokeniser.getToken(), token );
}
-#define PARSE_ERROR "error parsing entity class definition"
+const char *PARSE_ERROR = "error parsing entity class definition";
void EntityClassFGD_parseSplitString( Tokeniser& tokeniser, CopiedString& string ){
StringOutputStream buffer( 256 );
m_eclassmanager.realise = &EntityClassFGD_realise;
m_eclassmanager.unrealise = &EntityClassFGD_unrealise;
- GlobalRadiant().attachGameToolsPathObserver( g_EntityClassFGD );
- GlobalRadiant().attachGameNameObserver( g_EntityClassFGD );
+ Radiant_attachGameToolsPathObserver( g_EntityClassFGD );
+ Radiant_attachGameNameObserver( g_EntityClassFGD );
}
~EntityClassFGDAPI(){
- GlobalRadiant().detachGameNameObserver( g_EntityClassFGD );
- GlobalRadiant().detachGameToolsPathObserver( g_EntityClassFGD );
+ Radiant_detachGameNameObserver( g_EntityClassFGD );
+ Radiant_detachGameToolsPathObserver( g_EntityClassFGD );
EntityClassFGD_destroy();
}
#include "select.h"
#include "map.h"
#include "preferences.h"
+#include "preferencesystem.h"
+#include "stringio.h"
#include "gtkdlgs.h"
#include "mainframe.h"
#include "qe3.h"
#include "brushmanip.h"
#include "patchmanip.h"
+#include "uilib/uilib.h"
+
struct entity_globals_t
{
Vector3 color_entity;
EntitySetKeyValueSelected( const char* key, const char* value )
: m_key( key ), m_value( value ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
return true;
}
+
void post( const scene::Path& path, scene::Instance& instance ) const {
Entity* entity = Node_getEntity( path.top() );
if ( entity != 0
public:
mutable const scene::Path *groupPath;
mutable scene::Instance *groupInstance;
+
EntityFindSelected() : groupPath( 0 ), groupInstance( 0 ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
return true;
}
+
void post( const scene::Path& path, scene::Instance& instance ) const {
Entity* entity = Node_getEntity( path.top() );
if ( entity != 0
public:
EntityGroupSelected( const scene::Path &p ) : group( p.top().get() ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
return true;
}
+
void post( const scene::Path& path, scene::Instance& instance ) const {
Selectable *selectable = Instance_getSelectable( instance );
if ( selectable && selectable->isSelected() ) {
}
-
void Entity_connectSelected(){
if ( GlobalSelectionSystem().countSelected() == 2 ) {
GlobalEntityCreator().connectEntities(
void Entity_createFromSelection( const char* name, const Vector3& origin ){
#if 0
if ( string_equal_nocase( name, "worldspawn" ) ) {
- gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "Can't create an entity with worldspawn.", "info" );
+ ui::alert( MainFrame_getWindow( ), "Can't create an entity with worldspawn.", "info" );
return;
}
#endif
}
if ( isModel ) {
- const char* model = misc_model_dialog( GTK_WIDGET( MainFrame_getWindow() ) );
+ const char* model = misc_model_dialog(MainFrame_getWindow());
if ( model != 0 ) {
Node_getEntity( node )->setKeyValue( "model", model );
}
#if 0
bool DoNormalisedColor( Vector3& color ){
- if ( !color_dialog( GTK_WIDGET( MainFrame_getWindow() ), color ) ) {
+ if ( !color_dialog( MainFrame_getWindow( ), color ) ) {
return false;
}
/*
g_entity_globals.color_entity = rgb;
}
}
- if ( color_dialog( GTK_WIDGET( MainFrame_getWindow() ), g_entity_globals.color_entity ) ) {
+ if ( color_dialog( MainFrame_getWindow(), g_entity_globals.color_entity ) ) {
char buffer[128];
sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0],
g_entity_globals.color_entity[1],
}
}
-const char* misc_model_dialog( GtkWidget* parent ){
- StringOutputStream buffer( 1024 );
-
- buffer << g_qeglobals.m_userGamePath.c_str() << "models/";
+CopiedString g_strLastModelFolder = "";
- if ( !file_readable( buffer.c_str() ) ) {
- // just go to fsmain
- buffer.clear();
- buffer << g_qeglobals.m_userGamePath.c_str() << "/";
+const char *getLastModelFolderPath(){
+ if ( g_strLastModelFolder.empty() ) {
+ GlobalPreferenceSystem().registerPreference( "LastModelFolder", make_property_string( g_strLastModelFolder ) );
+ if ( g_strLastModelFolder.empty() ) {
+ StringOutputStream buffer( 1024 );
+ buffer << g_qeglobals.m_userGamePath.c_str() << "models/";
+ if ( !file_readable( buffer.c_str() ) ) {
+ // just go to fsmain
+ buffer.clear();
+ buffer << g_qeglobals.m_userGamePath.c_str() << "/";
+ }
+ g_strLastModelFolder = buffer.c_str();
+ }
}
+ return g_strLastModelFolder.c_str();
+}
+
+const char *misc_model_dialog( ui::Widget parent ){
+ const char *filename = parent.file_dialog( TRUE, "Choose Model", getLastModelFolderPath(), ModelLoader::Name() );
- const char *filename = file_dialog( parent, TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name() );
- if ( filename != 0 ) {
+ if ( filename != NULL ) {
+ g_strLastModelFolder = g_path_get_dirname( filename );
// use VFS to get the correct relative path
- const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) );
+ const char *relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) );
if ( relative == filename ) {
globalOutputStream() << "WARNING: could not extract the relative path, using full path instead\n";
}
return 0;
}
/*
-void LightRadiiImport( EntityCreator& self, bool value ){
- self.setLightRadii( value );
-}
-typedef ReferenceCaller1<EntityCreator, bool, LightRadiiImport> LightRadiiImportCaller;
+struct LightRadii {
+ static void Export(const EntityCreator &self, const Callback<void(bool)> &returnz) {
+ returnz(self.getLightRadii());
+ }
-void LightRadiiExport( EntityCreator& self, const BoolImportCallback& importer ){
- importer( self.getLightRadii() );
-}
-typedef ReferenceCaller1<EntityCreator, const BoolImportCallback&, LightRadiiExport> LightRadiiExportCaller;
+ static void Import(EntityCreator &self, bool value) {
+ self.setLightRadii(value);
+ }
+};
void Entity_constructPreferences( PreferencesPage& page ){
page.appendCheckBox(
- "Show", "Light Radii",
- LightRadiiImportCaller( GlobalEntityCreator() ),
- LightRadiiExportCaller( GlobalEntityCreator() )
- );
+ "Show", "Light Radii",
+ make_property<LightRadii>(GlobalEntityCreator())
+ );
}
void Entity_constructPage( PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Entities", "Entity Display Preferences" ) );
Entity_constructPreferences( page );
}
+
void Entity_registerPreferencesPage(){
- PreferencesDialog_addDisplayPage( FreeCaller1<PreferenceGroup&, Entity_constructPage>() );
+ PreferencesDialog_addDisplayPage( makeCallbackF(Entity_constructPage) );
}
*/
-void ShowLightRadiiExport( const BoolImportCallback& importer ){
- importer( GlobalEntityCreator().getLightRadii() );
-}
-typedef FreeCaller1<const BoolImportCallback&, ShowLightRadiiExport> ShowLightRadiiExportCaller;
-ShowLightRadiiExportCaller g_show_lightradii_caller;
-ToggleItem g_show_lightradii_item( g_show_lightradii_caller );
-void ToggleShowLightRadii(){
+void ShowLightRadiiToggle(){
GlobalEntityCreator().setLightRadii( !GlobalEntityCreator().getLightRadii() );
- g_show_lightradii_item.update();
UpdateAllWindows();
}
+typedef FreeCaller<void(), ShowLightRadiiToggle> ShowLightRadiiToggleCaller;
+void ShowLightRadiiExport( const Callback<void(bool)> & importer ){
+ GlobalEntityCreator().getLightRadii();
+}
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowLightRadiiExport> ShowLightRadiiExportCaller;
+
+ShowLightRadiiExportCaller g_show_lightradii_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_lightradii_callback( g_show_lightradii_caller );
+ToggleItem g_show_lightradii( g_show_lightradii_callback );
-void Entity_constructMenu( GtkMenu* menu ){
+void Entity_constructMenu( ui::Menu menu ){
create_menu_item_with_mnemonic( menu, "_Regroup", "GroupSelection" );
create_menu_item_with_mnemonic( menu, "_Ungroup", "UngroupSelection" );
create_menu_item_with_mnemonic( menu, "_Connect", "ConnectSelection" );
}
-
-#include "preferencesystem.h"
-#include "stringio.h"
-
void Entity_Construct(){
- GlobalCommands_insert( "EntityColor", FreeCaller<Entity_setColour>(), Accelerator( 'K' ) );
- GlobalCommands_insert( "NormalizeColor", FreeCaller<Entity_normalizeColor>() );
- GlobalCommands_insert( "ConnectSelection", FreeCaller<Entity_connectSelected>(), Accelerator( 'K', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "KillConnectSelection", FreeCaller<Entity_killconnectSelected>(), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK ) ) );
- GlobalCommands_insert( "GroupSelection", FreeCaller<Entity_groupSelected>() );
- GlobalCommands_insert( "UngroupSelection", FreeCaller<Entity_ungroupSelected>() );
+ GlobalCommands_insert( "EntityColor", makeCallbackF(Entity_setColour), Accelerator( 'K' ) );
+ GlobalCommands_insert( "NormalizeColor", makeCallbackF(Entity_normalizeColor) );
+ GlobalCommands_insert( "ConnectSelection", makeCallbackF(Entity_connectSelected), Accelerator( 'K', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "KillConnectSelection", makeCallbackF(Entity_killconnectSelected), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK ) ) );
+ GlobalCommands_insert( "GroupSelection", makeCallbackF(Entity_groupSelected) );
+ GlobalCommands_insert( "UngroupSelection", makeCallbackF(Entity_ungroupSelected) );
- GlobalToggles_insert( "ShowLightRadiuses", FreeCaller<ToggleShowLightRadii>(), ToggleItem::AddCallbackCaller( g_show_lightradii_item ) );
+ GlobalToggles_insert( "ShowLightRadiuses", makeCallbackF( ShowLightRadiiToggle ), ToggleItem::AddCallbackCaller( g_show_lightradii ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors5", Vector3ImportStringCaller( g_entity_globals.color_entity ), Vector3ExportStringCaller( g_entity_globals.color_entity ) );
- GlobalPreferenceSystem().registerPreference( "LastLightIntensity", IntImportStringCaller( g_iLastLightIntensity ), IntExportStringCaller( g_iLastLightIntensity ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors5", make_property_string( g_entity_globals.color_entity ) );
+ GlobalPreferenceSystem().registerPreference( "LastLightIntensity", make_property_string( g_iLastLightIntensity ) );
// Entity_registerPreferencesPage();
}
#if !defined( INCLUDED_ENTITY_H )
#define INCLUDED_ENTITY_H
+#include <uilib/uilib.h>
+
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
void Entity_createFromSelection( const char* name, const Vector3& origin );
void Scene_EntitySetClassname_Selected( const char* classname );
-typedef struct _GtkWidget GtkWidget;
-const char* misc_model_dialog( GtkWidget* parent );
+const char* misc_model_dialog( ui::Widget parent );
-typedef struct _GtkMenu GtkMenu;
-void Entity_constructMenu( GtkMenu* menu );
+void Entity_constructMenu( ui::Menu menu );
void Entity_Construct();
void Entity_Destroy();
#include "entityinspector.h"
#include "debugging/debugging.h"
+#include <gtk/gtk.h>
#include "ientity.h"
#include "ifilesystem.h"
#include <map>
#include <set>
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtktreemodel.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkliststore.h>
-#include <gtk/gtktextview.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtktogglebutton.h>
-#include <gtk/gtkcheckbutton.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkvpaned.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkcombobox.h>
+#include <uilib/uilib.h>
#include "os/path.h"
#include "textureentry.h"
#include "groupdialog.h"
-GtkEntry* numeric_entry_new(){
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 );
+ui::Entry numeric_entry_new(){
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ entry.dimensions(64, -1);
return entry;
}
class EntityAttribute
{
public:
-virtual GtkWidget* getWidget() const = 0;
+virtual ~EntityAttribute() = default;
+virtual ui::Widget getWidget() const = 0;
virtual void update() = 0;
virtual void release() = 0;
};
class BooleanAttribute : public EntityAttribute
{
CopiedString m_key;
-GtkCheckButton* m_check;
+ui::CheckButton m_check;
-static gboolean toggled( GtkWidget *widget, BooleanAttribute* self ){
+static gboolean toggled( ui::Widget widget, BooleanAttribute* self ){
self->apply();
return FALSE;
}
public:
BooleanAttribute( const char* key ) :
m_key( key ),
- m_check( 0 ){
- GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new() );
- gtk_widget_show( GTK_WIDGET( check ) );
+ m_check( ui::null ){
+ auto check = ui::CheckButton(ui::New);
+ check.show();
m_check = check;
- guint handler = g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( toggled ), this );
+ guint handler = check.connect( "toggled", G_CALLBACK( toggled ), this );
g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler ) );
update();
}
-GtkWidget* getWidget() const {
- return GTK_WIDGET( m_check );
+ui::Widget getWidget() const {
+ return m_check;
}
void release(){
delete this;
}
void apply(){
- Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( m_check ) ) ? "1" : "0" );
+ Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), m_check.active() ? "1" : "0" );
}
-typedef MemberCaller<BooleanAttribute, &BooleanAttribute::apply> ApplyCaller;
+typedef MemberCaller<BooleanAttribute, void(), &BooleanAttribute::apply> ApplyCaller;
void update(){
const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
if ( !string_empty( value ) ) {
- toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_check ), atoi( value ) != 0 );
+ toggle_button_set_active_no_signal( m_check, atoi( value ) != 0 );
}
else
{
- toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_check ), false );
+ toggle_button_set_active_no_signal( m_check, false );
}
}
-typedef MemberCaller<BooleanAttribute, &BooleanAttribute::update> UpdateCaller;
+typedef MemberCaller<BooleanAttribute, void(), &BooleanAttribute::update> UpdateCaller;
};
class StringAttribute : public EntityAttribute
{
CopiedString m_key;
-GtkEntry* m_entry;
+ui::Entry m_entry;
NonModalEntry m_nonModal;
public:
StringAttribute( const char* key ) :
m_key( key ),
- m_entry( 0 ),
+ m_entry( ui::null ),
m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_widget_set_size_request( GTK_WIDGET( entry ), 50, -1 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ entry.dimensions(50, -1);
m_entry = entry;
m_nonModal.connect( m_entry );
}
-GtkWidget* getWidget() const {
- return GTK_WIDGET( m_entry );
+ui::Widget getWidget() const {
+ return m_entry;
}
-GtkEntry* getEntry() const {
+ui::Entry getEntry() const {
return m_entry;
}
}
void apply(){
StringOutputStream value( 64 );
- value << gtk_entry_get_text( m_entry );
+ value << m_entry.text();
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), value.c_str() );
}
-typedef MemberCaller<StringAttribute, &StringAttribute::apply> ApplyCaller;
+typedef MemberCaller<StringAttribute, void(), &StringAttribute::apply> ApplyCaller;
void update(){
StringOutputStream value( 64 );
value << SelectedEntity_getValueForKey( m_key.c_str() );
- gtk_entry_set_text( m_entry, value.c_str() );
+ m_entry.text(value.c_str());
}
-typedef MemberCaller<StringAttribute, &StringAttribute::update> UpdateCaller;
+typedef MemberCaller<StringAttribute, void(), &StringAttribute::update> UpdateCaller;
};
class ShaderAttribute : public StringAttribute
void release(){
delete this;
}
-GtkWidget* getWidget() const {
- return GTK_WIDGET( m_entry.m_entry.m_frame );
+ui::Widget getWidget() const {
+ return m_entry.m_entry.m_frame;
}
void apply(){
StringOutputStream value( 64 );
- value << gtk_entry_get_text( GTK_ENTRY( m_entry.m_entry.m_entry ) );
+ value << m_entry.m_entry.m_entry.text();
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), value.c_str() );
}
-typedef MemberCaller<ModelAttribute, &ModelAttribute::apply> ApplyCaller;
+typedef MemberCaller<ModelAttribute, void(), &ModelAttribute::apply> ApplyCaller;
void update(){
StringOutputStream value( 64 );
value << SelectedEntity_getValueForKey( m_key.c_str() );
- gtk_entry_set_text( GTK_ENTRY( m_entry.m_entry.m_entry ), value.c_str() );
+ m_entry.m_entry.m_entry.text(value.c_str());
}
-typedef MemberCaller<ModelAttribute, &ModelAttribute::update> UpdateCaller;
+typedef MemberCaller<ModelAttribute, void(), &ModelAttribute::update> UpdateCaller;
void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
- const char *filename = misc_model_dialog( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) );
+ const char *filename = misc_model_dialog( m_entry.m_entry.m_frame.window() );
if ( filename != 0 ) {
setPath( filename );
apply();
}
}
-typedef MemberCaller1<ModelAttribute, const BrowsedPathEntry::SetPathCallback&, &ModelAttribute::browse> BrowseCaller;
+typedef MemberCaller<ModelAttribute, void(const BrowsedPathEntry::SetPathCallback&), &ModelAttribute::browse> BrowseCaller;
};
-const char* browse_sound( GtkWidget* parent ){
+const char* browse_sound( ui::Widget parent ){
StringOutputStream buffer( 1024 );
buffer << g_qeglobals.m_userGamePath.c_str() << "sound/";
buffer << g_qeglobals.m_userGamePath.c_str() << "/";
}
- const char* filename = file_dialog( parent, TRUE, "Open Wav File", buffer.c_str(), "sound" );
+ const char* filename = parent.file_dialog(TRUE, "Open Wav File", buffer.c_str(), "sound" );
if ( filename != 0 ) {
const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) );
if ( relative == filename ) {
void release(){
delete this;
}
-GtkWidget* getWidget() const {
- return GTK_WIDGET( m_entry.m_entry.m_frame );
+ui::Widget getWidget() const {
+ return ui::Widget(m_entry.m_entry.m_frame );
}
void apply(){
StringOutputStream value( 64 );
- value << gtk_entry_get_text( GTK_ENTRY( m_entry.m_entry.m_entry ) );
+ value << m_entry.m_entry.m_entry.text();
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), value.c_str() );
}
-typedef MemberCaller<SoundAttribute, &SoundAttribute::apply> ApplyCaller;
+typedef MemberCaller<SoundAttribute, void(), &SoundAttribute::apply> ApplyCaller;
void update(){
StringOutputStream value( 64 );
value << SelectedEntity_getValueForKey( m_key.c_str() );
- gtk_entry_set_text( GTK_ENTRY( m_entry.m_entry.m_entry ), value.c_str() );
+ m_entry.m_entry.m_entry.text(value.c_str());
}
-typedef MemberCaller<SoundAttribute, &SoundAttribute::update> UpdateCaller;
+typedef MemberCaller<SoundAttribute, void(), &SoundAttribute::update> UpdateCaller;
void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
- const char *filename = browse_sound( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) );
+ const char *filename = browse_sound( m_entry.m_entry.m_frame.window() );
if ( filename != 0 ) {
setPath( filename );
apply();
}
}
-typedef MemberCaller1<SoundAttribute, const BrowsedPathEntry::SetPathCallback&, &SoundAttribute::browse> BrowseCaller;
+typedef MemberCaller<SoundAttribute, void(const BrowsedPathEntry::SetPathCallback&), &SoundAttribute::browse> BrowseCaller;
};
inline double angle_normalised( double angle ){
class AngleAttribute : public EntityAttribute
{
CopiedString m_key;
-GtkEntry* m_entry;
+ui::Entry m_entry;
NonModalEntry m_nonModal;
public:
AngleAttribute( const char* key ) :
m_key( key ),
- m_entry( 0 ),
+ m_entry( ui::null ),
m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
- GtkEntry* entry = numeric_entry_new();
+ auto entry = numeric_entry_new();
m_entry = entry;
m_nonModal.connect( m_entry );
}
void release(){
delete this;
}
-GtkWidget* getWidget() const {
- return GTK_WIDGET( m_entry );
+ui::Widget getWidget() const {
+ return ui::Widget(m_entry );
}
void apply(){
StringOutputStream angle( 32 );
angle << angle_normalised( entry_get_float( m_entry ) );
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), angle.c_str() );
}
-typedef MemberCaller<AngleAttribute, &AngleAttribute::apply> ApplyCaller;
+typedef MemberCaller<AngleAttribute, void(), &AngleAttribute::apply> ApplyCaller;
void update(){
const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
if ( !string_empty( value ) ) {
StringOutputStream angle( 32 );
angle << angle_normalised( atof( value ) );
- gtk_entry_set_text( m_entry, angle.c_str() );
+ m_entry.text(angle.c_str());
}
else
{
- gtk_entry_set_text( m_entry, "0" );
+ m_entry.text("0");
}
}
-typedef MemberCaller<AngleAttribute, &AngleAttribute::update> UpdateCaller;
+typedef MemberCaller<AngleAttribute, void(), &AngleAttribute::update> UpdateCaller;
};
namespace
class DirectionAttribute : public EntityAttribute
{
CopiedString m_key;
-GtkEntry* m_entry;
+ui::Entry m_entry;
NonModalEntry m_nonModal;
RadioHBox m_radio;
NonModalRadio m_nonModalRadio;
-GtkHBox* m_hbox;
+ui::HBox m_hbox{ui::null};
public:
DirectionAttribute( const char* key ) :
m_key( key ),
- m_entry( 0 ),
+ m_entry( ui::null ),
m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ),
m_radio( RadioHBox_new( STRING_ARRAY_RANGE( buttons ) ) ),
m_nonModalRadio( ApplyRadioCaller( *this ) ){
- GtkEntry* entry = numeric_entry_new();
+ auto entry = numeric_entry_new();
m_entry = entry;
m_nonModal.connect( m_entry );
m_nonModalRadio.connect( m_radio.m_radio );
- m_hbox = GTK_HBOX( gtk_hbox_new( FALSE, 4 ) );
- gtk_widget_show( GTK_WIDGET( m_hbox ) );
+ m_hbox = ui::HBox( FALSE, 4 );
+ m_hbox.show();
- gtk_box_pack_start( GTK_BOX( m_hbox ), GTK_WIDGET( m_radio.m_hbox ), TRUE, TRUE, 0 );
- gtk_box_pack_start( GTK_BOX( m_hbox ), GTK_WIDGET( m_entry ), TRUE, TRUE, 0 );
+ m_hbox.pack_start( m_radio.m_hbox, TRUE, TRUE, 0 );
+ m_hbox.pack_start( m_entry, TRUE, TRUE, 0 );
}
void release(){
delete this;
}
-GtkWidget* getWidget() const {
- return GTK_WIDGET( m_hbox );
+ui::Widget getWidget() const {
+ return ui::Widget(m_hbox );
}
void apply(){
StringOutputStream angle( 32 );
angle << angle_normalised( entry_get_float( m_entry ) );
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), angle.c_str() );
}
-typedef MemberCaller<DirectionAttribute, &DirectionAttribute::apply> ApplyCaller;
+typedef MemberCaller<DirectionAttribute, void(), &DirectionAttribute::apply> ApplyCaller;
void update(){
const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
if ( !string_empty( value ) ) {
float f = float(atof( value ) );
if ( f == -1 ) {
- gtk_widget_set_sensitive( GTK_WIDGET( m_entry ), FALSE );
+ gtk_widget_set_sensitive( m_entry , FALSE );
radio_button_set_active_no_signal( m_radio.m_radio, 0 );
- gtk_entry_set_text( m_entry, "" );
+ m_entry.text("");
}
else if ( f == -2 ) {
- gtk_widget_set_sensitive( GTK_WIDGET( m_entry ), FALSE );
+ gtk_widget_set_sensitive( m_entry , FALSE );
radio_button_set_active_no_signal( m_radio.m_radio, 1 );
- gtk_entry_set_text( m_entry, "" );
+ m_entry.text("");
}
else
{
- gtk_widget_set_sensitive( GTK_WIDGET( m_entry ), TRUE );
+ gtk_widget_set_sensitive( m_entry , TRUE );
radio_button_set_active_no_signal( m_radio.m_radio, 2 );
StringOutputStream angle( 32 );
angle << angle_normalised( f );
- gtk_entry_set_text( m_entry, angle.c_str() );
+ m_entry.text(angle.c_str());
}
}
else
{
- gtk_entry_set_text( m_entry, "0" );
+ m_entry.text("0");
}
}
-typedef MemberCaller<DirectionAttribute, &DirectionAttribute::update> UpdateCaller;
+typedef MemberCaller<DirectionAttribute, void(), &DirectionAttribute::update> UpdateCaller;
void applyRadio(){
int index = radio_button_get_active( m_radio.m_radio );
apply();
}
}
-typedef MemberCaller<DirectionAttribute, &DirectionAttribute::applyRadio> ApplyRadioCaller;
+typedef MemberCaller<DirectionAttribute, void(), &DirectionAttribute::applyRadio> ApplyRadioCaller;
};
class AnglesEntry
{
public:
-GtkEntry* m_roll;
-GtkEntry* m_pitch;
-GtkEntry* m_yaw;
-AnglesEntry() : m_roll( 0 ), m_pitch( 0 ), m_yaw( 0 ){
+ui::Entry m_roll;
+ui::Entry m_pitch;
+ui::Entry m_yaw;
+AnglesEntry() : m_roll( ui::null ), m_pitch( ui::null ), m_yaw( ui::null ){
}
};
CopiedString m_key;
AnglesEntry m_angles;
NonModalEntry m_nonModal;
-GtkBox* m_hbox;
+ui::HBox m_hbox;
public:
AnglesAttribute( const char* key ) :
m_key( key ),
- m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
- m_hbox = GTK_BOX( gtk_hbox_new( TRUE, 4 ) );
- gtk_widget_show( GTK_WIDGET( m_hbox ) );
+ m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ),
+ m_hbox(ui::HBox( TRUE, 4 ))
+{
+ m_hbox.show();
{
- GtkEntry* entry = numeric_entry_new();
- gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ auto entry = numeric_entry_new();
+ m_hbox.pack_start( entry, TRUE, TRUE, 0 );
m_angles.m_pitch = entry;
m_nonModal.connect( m_angles.m_pitch );
}
{
- GtkEntry* entry = numeric_entry_new();
- gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ auto entry = numeric_entry_new();
+ m_hbox.pack_start( entry, TRUE, TRUE, 0 );
m_angles.m_yaw = entry;
m_nonModal.connect( m_angles.m_yaw );
}
{
- GtkEntry* entry = numeric_entry_new();
- gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ auto entry = numeric_entry_new();
+ m_hbox.pack_start( entry, TRUE, TRUE, 0 );
m_angles.m_roll = entry;
m_nonModal.connect( m_angles.m_roll );
}
void release(){
delete this;
}
-GtkWidget* getWidget() const {
- return GTK_WIDGET( m_hbox );
+ui::Widget getWidget() const {
+ return ui::Widget(m_hbox );
}
void apply(){
StringOutputStream angles( 64 );
<< " " << angle_normalised( entry_get_float( m_angles.m_roll ) );
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), angles.c_str() );
}
-typedef MemberCaller<AnglesAttribute, &AnglesAttribute::apply> ApplyCaller;
+typedef MemberCaller<AnglesAttribute, void(), &AnglesAttribute::apply> ApplyCaller;
void update(){
StringOutputStream angle( 32 );
}
angle << angle_normalised( pitch_yaw_roll.x() );
- gtk_entry_set_text( m_angles.m_pitch, angle.c_str() );
+ m_angles.m_pitch.text(angle.c_str());
angle.clear();
angle << angle_normalised( pitch_yaw_roll.y() );
- gtk_entry_set_text( m_angles.m_yaw, angle.c_str() );
+ m_angles.m_yaw.text(angle.c_str());
angle.clear();
angle << angle_normalised( pitch_yaw_roll.z() );
- gtk_entry_set_text( m_angles.m_roll, angle.c_str() );
+ m_angles.m_roll.text(angle.c_str());
angle.clear();
}
else
{
- gtk_entry_set_text( m_angles.m_pitch, "0" );
- gtk_entry_set_text( m_angles.m_yaw, "0" );
- gtk_entry_set_text( m_angles.m_roll, "0" );
+ m_angles.m_pitch.text("0");
+ m_angles.m_yaw.text("0");
+ m_angles.m_roll.text("0");
}
}
-typedef MemberCaller<AnglesAttribute, &AnglesAttribute::update> UpdateCaller;
+typedef MemberCaller<AnglesAttribute, void(), &AnglesAttribute::update> UpdateCaller;
};
class Vector3Entry
{
public:
-GtkEntry* m_x;
-GtkEntry* m_y;
-GtkEntry* m_z;
-Vector3Entry() : m_x( 0 ), m_y( 0 ), m_z( 0 ){
+ui::Entry m_x;
+ui::Entry m_y;
+ui::Entry m_z;
+Vector3Entry() : m_x( ui::null ), m_y( ui::null ), m_z( ui::null ){
}
};
CopiedString m_key;
Vector3Entry m_vector3;
NonModalEntry m_nonModal;
-GtkBox* m_hbox;
+ui::Box m_hbox{ui::null};
public:
Vector3Attribute( const char* key ) :
m_key( key ),
m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
- m_hbox = GTK_BOX( gtk_hbox_new( TRUE, 4 ) );
- gtk_widget_show( GTK_WIDGET( m_hbox ) );
+ m_hbox = ui::HBox( TRUE, 4 );
+ m_hbox.show();
{
- GtkEntry* entry = numeric_entry_new();
- gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ auto entry = numeric_entry_new();
+ m_hbox.pack_start( entry, TRUE, TRUE, 0 );
m_vector3.m_x = entry;
m_nonModal.connect( m_vector3.m_x );
}
{
- GtkEntry* entry = numeric_entry_new();
- gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ auto entry = numeric_entry_new();
+ m_hbox.pack_start( entry, TRUE, TRUE, 0 );
m_vector3.m_y = entry;
m_nonModal.connect( m_vector3.m_y );
}
{
- GtkEntry* entry = numeric_entry_new();
- gtk_box_pack_start( m_hbox, GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ auto entry = numeric_entry_new();
+ m_hbox.pack_start( entry, TRUE, TRUE, 0 );
m_vector3.m_z = entry;
m_nonModal.connect( m_vector3.m_z );
}
void release(){
delete this;
}
-GtkWidget* getWidget() const {
- return GTK_WIDGET( m_hbox );
+ui::Widget getWidget() const {
+ return ui::Widget(m_hbox );
}
void apply(){
StringOutputStream vector3( 64 );
<< " " << entry_get_float( m_vector3.m_z );
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), vector3.c_str() );
}
-typedef MemberCaller<Vector3Attribute, &Vector3Attribute::apply> ApplyCaller;
+typedef MemberCaller<Vector3Attribute, void(), &Vector3Attribute::apply> ApplyCaller;
void update(){
StringOutputStream buffer( 32 );
}
buffer << x_y_z.x();
- gtk_entry_set_text( m_vector3.m_x, buffer.c_str() );
+ m_vector3.m_x.text(buffer.c_str());
buffer.clear();
buffer << x_y_z.y();
- gtk_entry_set_text( m_vector3.m_y, buffer.c_str() );
+ m_vector3.m_y.text(buffer.c_str());
buffer.clear();
buffer << x_y_z.z();
- gtk_entry_set_text( m_vector3.m_z, buffer.c_str() );
+ m_vector3.m_z.text(buffer.c_str());
buffer.clear();
}
else
{
- gtk_entry_set_text( m_vector3.m_x, "0" );
- gtk_entry_set_text( m_vector3.m_y, "0" );
- gtk_entry_set_text( m_vector3.m_z, "0" );
+ m_vector3.m_x.text("0");
+ m_vector3.m_y.text("0");
+ m_vector3.m_z.text("0");
}
}
-typedef MemberCaller<Vector3Attribute, &Vector3Attribute::update> UpdateCaller;
+typedef MemberCaller<Vector3Attribute, void(), &Vector3Attribute::update> UpdateCaller;
};
class NonModalComboBox
{
-Callback m_changed;
+Callback<void()> m_changed;
guint m_changedHandler;
-static gboolean changed( GtkComboBox *widget, NonModalComboBox* self ){
+static gboolean changed( ui::ComboBox widget, NonModalComboBox* self ){
self->m_changed();
return FALSE;
}
public:
-NonModalComboBox( const Callback& changed ) : m_changed( changed ), m_changedHandler( 0 ){
+NonModalComboBox( const Callback<void()>& changed ) : m_changed( changed ), m_changedHandler( 0 ){
}
-void connect( GtkComboBox* combo ){
- m_changedHandler = g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( changed ), this );
+void connect( ui::ComboBox combo ){
+ m_changedHandler = combo.connect( "changed", G_CALLBACK( changed ), this );
}
-void setActive( GtkComboBox* combo, int value ){
+void setActive( ui::ComboBox combo, int value ){
g_signal_handler_disconnect( G_OBJECT( combo ), m_changedHandler );
gtk_combo_box_set_active( combo, value );
connect( combo );
class ListAttribute : public EntityAttribute
{
CopiedString m_key;
-GtkComboBox* m_combo;
+ui::ComboBox m_combo;
NonModalComboBox m_nonModal;
const ListAttributeType& m_type;
public:
ListAttribute( const char* key, const ListAttributeType& type ) :
m_key( key ),
- m_combo( 0 ),
+ m_combo( ui::null ),
m_nonModal( ApplyCaller( *this ) ),
m_type( type ){
- GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
+ auto combo = ui::ComboBoxText(ui::New);
for ( ListAttributeType::const_iterator i = type.begin(); i != type.end(); ++i )
{
- gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), ( *i ).first.c_str() );
+ gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), ( *i ).first.c_str() );
}
- gtk_widget_show( GTK_WIDGET( combo ) );
+ combo.show();
m_nonModal.connect( combo );
m_combo = combo;
void release(){
delete this;
}
-GtkWidget* getWidget() const {
- return GTK_WIDGET( m_combo );
+ui::Widget getWidget() const {
+ return ui::Widget(m_combo );
}
void apply(){
Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), m_type[gtk_combo_box_get_active( m_combo )].second.c_str() );
}
-typedef MemberCaller<ListAttribute, &ListAttribute::apply> ApplyCaller;
+typedef MemberCaller<ListAttribute, void(), &ListAttribute::apply> ApplyCaller;
void update(){
const char* value = SelectedEntity_getValueForKey( m_key.c_str() );
m_nonModal.setActive( m_combo, 0 );
}
}
-typedef MemberCaller<ListAttribute, &ListAttribute::update> UpdateCaller;
+typedef MemberCaller<ListAttribute, void(), &ListAttribute::update> UpdateCaller;
};
namespace
{
GtkWidget* g_entity_split0 = 0;
-GtkWidget* g_entity_split1 = 0;
-GtkWidget* g_entity_split2 = 0;
+ui::Widget g_entity_split1{ui::null};
+ui::Widget g_entity_split2{ui::null};
int g_entitysplit0_position;
int g_entitysplit1_position;
int g_entitysplit2_position;
bool g_entityInspector_windowConstructed = false;
-GtkTreeView* g_entityClassList;
-GtkTextView* g_entityClassComment;
+ui::TreeView g_entityClassList{ui::null};
+ui::TextView g_entityClassComment{ui::null};
GtkCheckButton* g_entitySpawnflagsCheck[MAX_FLAGS];
-GtkEntry* g_entityKeyEntry;
-GtkEntry* g_entityValueEntry;
+ui::Entry g_entityKeyEntry{ui::null};
+ui::Entry g_entityValueEntry{ui::null};
-GtkListStore* g_entlist_store;
-GtkListStore* g_entprops_store;
+ui::ListStore g_entlist_store{ui::null};
+ui::ListStore g_entprops_store{ui::null};
const EntityClass* g_current_flags = 0;
const EntityClass* g_current_comment = 0;
const EntityClass* g_current_attributes = 0;
int spawn_table[MAX_FLAGS];
// we change the layout depending on how many spawn flags we need to display
// the table is a 4x4 in which we need to put the comment box g_entityClassComment and the spawn flags..
-GtkTable* g_spawnflagsTable;
+ui::Table g_spawnflagsTable{ui::null};
-GtkVBox* g_attributeBox = 0;
+ui::VBox g_attributeBox{ui::null};
typedef std::vector<EntityAttribute*> EntityAttributes;
EntityAttributes g_entityAttributes;
}
class EntityClassListStoreAppend : public EntityClassVisitor
{
-GtkListStore* store;
+ui::ListStore store;
public:
-EntityClassListStoreAppend( GtkListStore* store_ ) : store( store_ ){
+EntityClassListStoreAppend( ui::ListStore store_ ) : store( store_ ){
}
void visit( EntityClass* e ){
- GtkTreeIter iter;
- gtk_list_store_append( store, &iter );
- gtk_list_store_set( store, &iter, 0, e->name(), 1, e, -1 );
+ store.append(0, e->name(), 1, e);
}
};
}
void EntityClassList_clear(){
- gtk_list_store_clear( g_entlist_store );
+ g_entlist_store.clear();
}
void SetComment( EntityClass* eclass ){
g_current_comment = eclass;
- GtkTextBuffer* buffer = gtk_text_view_get_buffer( g_entityClassComment );
- gtk_text_buffer_set_text( buffer, eclass->comments(), -1 );
+ g_entityClassComment.text(eclass->comments());
}
void SurfaceFlags_setEntityClass( EntityClass* eclass ){
g_current_flags = eclass;
- int spawnflag_count = 0;
+ unsigned int spawnflag_count = 0;
{
// do a first pass to count the spawn flags, don't touch the widgets, we don't know in what state they are
{
for ( int i = 0; i < g_spawnflag_count; ++i )
{
- GtkWidget* widget = GTK_WIDGET( g_entitySpawnflagsCheck[i] );
- gtk_label_set_text( GTK_LABEL( GTK_BIN( widget )->child ), " " );
- gtk_widget_hide( widget );
- gtk_widget_ref( widget );
- gtk_container_remove( GTK_CONTAINER( g_spawnflagsTable ), widget );
+ auto widget = ui::CheckButton::from(g_entitySpawnflagsCheck[i]);
+ auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(widget)));
+ label.text(" ");
+ widget.hide();
+ widget.ref();
+ g_spawnflagsTable.remove(widget);
}
}
g_spawnflag_count = spawnflag_count;
{
- for ( int i = 0; i < g_spawnflag_count; ++i )
+ for (unsigned int i = 0; (int) i < g_spawnflag_count; ++i)
{
- GtkWidget* widget = GTK_WIDGET( g_entitySpawnflagsCheck[i] );
- gtk_widget_show( widget );
+ auto widget = ui::CheckButton::from(g_entitySpawnflagsCheck[i] );
+ widget.show();
StringOutputStream str( 16 );
str << LowerCase( eclass->flagnames[spawn_table[i]] );
- gtk_table_attach( g_spawnflagsTable, widget, i % 4, i % 4 + 1, i / 4, i / 4 + 1,
- (GtkAttachOptions)( GTK_FILL ),
- (GtkAttachOptions)( GTK_FILL ), 0, 0 );
- gtk_widget_unref( widget );
+ g_spawnflagsTable.attach(widget, {i % 4, i % 4 + 1, i / 4, i / 4 + 1}, {GTK_FILL, GTK_FILL});
+ widget.unref();
- gtk_label_set_text( GTK_LABEL( GTK_BIN( widget )->child ), str.c_str() );
+ auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(widget)) );
+ label.text(str.c_str());
}
}
}
void EntityClassList_selectEntityClass( EntityClass* eclass ){
- GtkTreeModel* model = GTK_TREE_MODEL( g_entlist_store );
+ auto model = g_entlist_store;
GtkTreeIter iter;
for ( gboolean good = gtk_tree_model_get_iter_first( model, &iter ); good != FALSE; good = gtk_tree_model_iter_next( model, &iter ) )
{
char* text;
gtk_tree_model_get( model, &iter, 0, &text, -1 );
if ( strcmp( text, eclass->name() ) == 0 ) {
- GtkTreeView* view = g_entityClassList;
- GtkTreePath* path = gtk_tree_model_get_path( model, &iter );
+ auto view = ui::TreeView(g_entityClassList);
+ auto path = gtk_tree_model_get_path( model, &iter );
gtk_tree_selection_select_path( gtk_tree_view_get_selection( view ), path );
- if ( GTK_WIDGET_REALIZED( view ) ) {
+ if ( gtk_widget_get_realized( view ) ) {
gtk_tree_view_scroll_to_cell( view, path, 0, FALSE, 0, 0 );
}
gtk_tree_path_free( path );
}
void EntityInspector_appendAttribute( const char* name, EntityAttribute& attribute ){
- GtkTable* row = DialogRow_new( name, attribute.getWidget() );
- DialogVBox_packRow( g_attributeBox, GTK_WIDGET( row ) );
+ auto row = DialogRow_new( name, attribute.getWidget() );
+ DialogVBox_packRow( ui::VBox(g_attributeBox), row );
}
if ( eclass != g_current_attributes ) {
g_current_attributes = eclass;
- container_remove_all( GTK_CONTAINER( g_attributeBox ) );
+ container_remove_all( g_attributeBox );
GlobalEntityAttributes_clear();
for ( EntityClassAttributes::const_iterator i = eclass->m_attributes.begin(); i != eclass->m_attributes.end(); ++i )
{
int v = !!( f & ( 1 << spawn_table[i] ) );
- toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] ), v );
+ toggle_button_set_active_no_signal( ui::ToggleButton::from( g_entitySpawnflagsCheck[i] ), v );
}
}
{
// take care of the remaining ones
for ( int i = g_spawnflag_count; i < MAX_FLAGS; ++i )
{
- toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( g_entitySpawnflagsCheck[i] ), FALSE );
+ toggle_button_set_active_no_signal( ui::ToggleButton::from( g_entitySpawnflagsCheck[i] ), FALSE );
}
}
}
EntityInspector_updateSpawnflags();
- GtkListStore* store = g_entprops_store;
+ ui::ListStore store = g_entprops_store;
// save current key/val pair around filling epair box
// row_select wipes it and sets to first in list
- CopiedString strKey( gtk_entry_get_text( g_entityKeyEntry ) );
- CopiedString strVal( gtk_entry_get_text( g_entityValueEntry ) );
+ CopiedString strKey( g_entityKeyEntry.text() );
+ CopiedString strVal( g_entityValueEntry.text() );
- gtk_list_store_clear( store );
+ store.clear();
// Walk through list and add pairs
for ( KeyValues::iterator i = g_selectedKeyValues.begin(); i != g_selectedKeyValues.end(); ++i )
{
- GtkTreeIter iter;
- gtk_list_store_append( store, &iter );
StringOutputStream key( 64 );
key << ( *i ).first.c_str();
StringOutputStream value( 64 );
value << ( *i ).second.c_str();
- gtk_list_store_set( store, &iter, 0, key.c_str(), 1, value.c_str(), -1 );
+ store.append(0, key.c_str(), 1, value.c_str());
}
- gtk_entry_set_text( g_entityKeyEntry, strKey.c_str() );
- gtk_entry_set_text( g_entityValueEntry, strVal.c_str() );
+ g_entityKeyEntry.text( strKey.c_str() );
+ g_entityValueEntry.text( strVal.c_str() );
for ( EntityAttributes::const_iterator i = g_entityAttributes.begin(); i != g_entityAttributes.end(); ++i )
{
{
IdleDraw m_idleDraw;
public:
-EntityInspectorDraw() : m_idleDraw( FreeCaller<EntityInspector_updateKeyValues>( ) ){
+EntityInspectorDraw() : m_idleDraw( makeCallbackF(EntityInspector_updateKeyValues) ){
}
void queueDraw(){
m_idleDraw.queueDraw();
// Creates a new entity based on the currently selected brush and entity type.
//
void EntityClassList_createEntity(){
- GtkTreeView* view = g_entityClassList;
+ auto view = g_entityClassList;
// find out what type of entity we are trying to create
GtkTreeModel* model;
GtkTreeIter iter;
- if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( view ), &model, &iter ) == FALSE ) {
- gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityClassList ) ), "You must have a selected class to create an entity", "info" );
+ if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( g_entityClassList ), &model, &iter ) == FALSE ) {
+ ui::alert( view.window(), "You must have a selected class to create an entity", "info" );
return;
}
// TTimo: if you change the classname to worldspawn you won't merge back in the structural brushes but create a parasite entity
if ( !strcmp( key.c_str(), "classname" ) && !strcmp( value.c_str(), "worldspawn" ) ) {
- gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry ) ), "Cannot change \"classname\" key back to worldspawn.", 0, eMB_OK );
+ ui::alert( g_entityKeyEntry.window(), "Cannot change \"classname\" key back to worldspawn.", 0, ui::alert_type::OK );
return;
}
// RR2DO2: we don't want spaces in entity keys
if ( strstr( key.c_str(), " " ) ) {
- gtk_MessageBox( gtk_widget_get_toplevel( GTK_WIDGET( g_entityKeyEntry ) ), "No spaces are allowed in entity keys.", 0, eMB_OK );
+ ui::alert( g_entityKeyEntry.window(), "No spaces are allowed in entity keys.", 0, ui::alert_type::OK );
return;
}
// =============================================================================
// callbacks
-static void EntityClassList_selection_changed( GtkTreeSelection* selection, gpointer data ){
+static void EntityClassList_selection_changed( ui::TreeSelection selection, gpointer data ){
GtkTreeModel* model;
GtkTreeIter selected;
if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) {
}
}
-static gint EntityClassList_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
+static gint EntityClassList_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
if ( event->type == GDK_2BUTTON_PRESS ) {
EntityClassList_createEntity();
return TRUE;
return FALSE;
}
-static gint EntityClassList_keypress( GtkWidget* widget, GdkEventKey* event, gpointer data ){
+static gint EntityClassList_keypress( ui::Widget widget, GdkEventKey* event, gpointer data ){
unsigned int code = gdk_keyval_to_upper( event->keyval );
- if ( event->keyval == GDK_Return ) {
+ if ( event->keyval == GDK_KEY_Return ) {
EntityClassList_createEntity();
return TRUE;
}
// select the entity that starts with the key pressed
if ( code <= 'Z' && code >= 'A' ) {
- GtkTreeView* view = g_entityClassList;
+ auto view = ui::TreeView(g_entityClassList);
GtkTreeModel* model;
GtkTreeIter iter;
if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( view ), &model, &iter ) == FALSE
gtk_tree_model_get( model, &iter, 0, &text, -1 );
if ( toupper( text[0] ) == (int)code ) {
- GtkTreePath* path = gtk_tree_model_get_path( model, &iter );
+ auto path = gtk_tree_model_get_path( model, &iter );
gtk_tree_selection_select_path( gtk_tree_view_get_selection( view ), path );
- if ( GTK_WIDGET_REALIZED( view ) ) {
+ if ( gtk_widget_get_realized( view ) ) {
gtk_tree_view_scroll_to_cell( view, path, 0, FALSE, 0, 0 );
}
gtk_tree_path_free( path );
return FALSE;
}
-static void EntityProperties_selection_changed( GtkTreeSelection* selection, gpointer data ){
+static void EntityProperties_selection_changed( ui::TreeSelection selection, gpointer data ){
// find out what type of entity we are trying to create
GtkTreeModel* model;
GtkTreeIter iter;
char* val;
gtk_tree_model_get( model, &iter, 0, &key, 1, &val, -1 );
- gtk_entry_set_text( g_entityKeyEntry, key );
- gtk_entry_set_text( g_entityValueEntry, val );
+ g_entityKeyEntry.text( key );
+ g_entityValueEntry.text( val );
g_free( key );
g_free( val );
}
-static void SpawnflagCheck_toggled( GtkWidget *widget, gpointer data ){
+static void SpawnflagCheck_toggled( ui::Widget widget, gpointer data ){
EntityInspector_applySpawnflags();
}
-static gint EntityEntry_keypress( GtkEntry* widget, GdkEventKey* event, gpointer data ){
- if ( event->keyval == GDK_Return ) {
- if ( widget == g_entityKeyEntry ) {
- gtk_entry_set_text( g_entityValueEntry, "" );
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), GTK_WIDGET( g_entityValueEntry ) );
+static gint EntityEntry_keypress( ui::Entry widget, GdkEventKey* event, gpointer data ){
+ if ( event->keyval == GDK_KEY_Return ) {
+ if ( widget._handle == g_entityKeyEntry._handle ) {
+ g_entityValueEntry.text( "" );
+ gtk_window_set_focus( widget.window(), g_entityValueEntry );
}
else
{
return TRUE;
}
if ( event->keyval == GDK_Tab ) {
- if ( widget == g_entityKeyEntry ) {
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), GTK_WIDGET( g_entityValueEntry ) );
+ if ( widget._handle == g_entityKeyEntry._handle ) {
+ gtk_window_set_focus( widget.window(), g_entityValueEntry );
}
else
{
- gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), GTK_WIDGET( g_entityKeyEntry ) );
+ gtk_window_set_focus( widget.window(), g_entityKeyEntry );
}
return TRUE;
}
if ( event->keyval == GDK_Escape ) {
- //gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), NULL );
- GroupDialog_showPage( g_page_entity );
+ // gtk_window_set_focus( widget.window(), NULL );
return TRUE;
}
return FALSE;
}
-void EntityInspector_destroyWindow( GtkWidget* widget, gpointer data ){
+void EntityInspector_destroyWindow( ui::Widget widget, gpointer data ){
g_entitysplit0_position = gtk_paned_get_position( GTK_PANED( g_entity_split0 ) );
g_entitysplit1_position = gtk_paned_get_position( GTK_PANED( g_entity_split1 ) );
g_entitysplit2_position = gtk_paned_get_position( GTK_PANED( g_entity_split2 ) );
return FALSE;
}
-GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){
- GtkWidget* vbox = gtk_vbox_new( FALSE, 2 );
- gtk_widget_show( vbox );
+ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){
+ auto vbox = ui::VBox( FALSE, 2 );
+ vbox.show();
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 2 );
g_signal_connect( G_OBJECT( toplevel ), "key_press_event", G_CALLBACK( EntityInspector_hideWindowKB ), 0 );
- g_signal_connect( G_OBJECT( vbox ), "destroy", G_CALLBACK( EntityInspector_destroyWindow ), 0 );
+ vbox.connect( "destroy", G_CALLBACK( EntityInspector_destroyWindow ), 0 );
{
- GtkWidget* split1 = gtk_vpaned_new();
- gtk_box_pack_start( GTK_BOX( vbox ), split1, TRUE, TRUE, 0 );
- gtk_widget_show( split1 );
+ auto split1 = ui::VPaned(ui::New);
+ vbox.pack_start( split1, TRUE, TRUE, 0 );
+ split1.show();
g_entity_split1 = split1;
{
- GtkWidget* split2 = gtk_vpaned_new();
+ ui::Widget split2 = ui::VPaned(ui::New);
//gtk_paned_add1( GTK_PANED( split1 ), split2 );
gtk_paned_pack1( GTK_PANED( split1 ), split2, FALSE, FALSE );
- gtk_widget_show( split2 );
+ split2.show();
g_entity_split2 = split2;
{
// class list
- GtkWidget* scr = gtk_scrolled_window_new( 0, 0 );
- gtk_widget_show( scr );
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
//gtk_paned_add1( GTK_PANED( split2 ), scr );
gtk_paned_pack1( GTK_PANED( split2 ), scr, FALSE, FALSE );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
{
- GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER );
+ ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ));
- GtkTreeView* view = GTK_TREE_VIEW( gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) ) );
- gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE );
+ auto view = ui::TreeView( ui::TreeModel::from( store._handle ));
+ gtk_tree_view_set_enable_search(view, FALSE );
gtk_tree_view_set_headers_visible( view, FALSE );
- g_signal_connect( G_OBJECT( view ), "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 );
- g_signal_connect( G_OBJECT( view ), "key_press_event", G_CALLBACK( EntityClassList_keypress ), 0 );
+ view.connect( "button_press_event", G_CALLBACK( EntityClassList_button_press ), 0 );
+ view.connect( "key_press_event", G_CALLBACK( EntityClassList_keypress ), 0 );
{
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Key", renderer, "text", 0, 0 );
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "Key", renderer, {{"text", 0}} );
gtk_tree_view_append_column( view, column );
}
{
- GtkTreeSelection* selection = gtk_tree_view_get_selection( view );
- g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( EntityClassList_selection_changed ), 0 );
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection( view ));
+ selection.connect( "changed", G_CALLBACK( EntityClassList_selection_changed ), 0 );
}
- gtk_widget_show( GTK_WIDGET( view ) );
+ view.show();
- gtk_container_add( GTK_CONTAINER( scr ), GTK_WIDGET( view ) );
+ scr.add(view);
- g_object_unref( G_OBJECT( store ) );
+ store.unref();
g_entityClassList = view;
g_entlist_store = store;
}
}
{
- GtkWidget* scr = gtk_scrolled_window_new( 0, 0 );
- gtk_widget_show( scr );
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
//gtk_paned_add2( GTK_PANED( split2 ), scr );
gtk_paned_pack2( GTK_PANED( split2 ), scr, FALSE, FALSE );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
{
- GtkTextView* text = GTK_TEXT_VIEW( gtk_text_view_new() );
- gtk_widget_set_size_request( GTK_WIDGET( text ), 0, -1 ); // allow shrinking
+ auto text = ui::TextView(ui::New);
+ text.dimensions(0, -1); // allow shrinking
gtk_text_view_set_wrap_mode( text, GTK_WRAP_WORD );
gtk_text_view_set_editable( text, FALSE );
- gtk_widget_show( GTK_WIDGET( text ) );
- gtk_container_add( GTK_CONTAINER( scr ), GTK_WIDGET( text ) );
+ text.show();
+ scr.add(text);
g_entityClassComment = text;
}
}
}
{
- GtkWidget* split0 = gtk_vpaned_new();
+ ui::Widget split0 = ui::VPaned(ui::New);
//gtk_paned_add2( GTK_PANED( split1 ), split0 );
gtk_paned_pack2( GTK_PANED( split1 ), split0, FALSE, FALSE );
- gtk_widget_show( split0 );
+ split0.show();
g_entity_split0 = split0;
{
- GtkWidget* vbox2 = gtk_vbox_new( FALSE, 2 );
- gtk_widget_show( vbox2 );
+ auto vbox2 = ui::VBox( FALSE, 2 );
+ vbox2.show();
gtk_paned_pack1( GTK_PANED( split0 ), vbox2, FALSE, FALSE );
{
// Spawnflags (4 colums wide max, or window gets too wide.)
- GtkTable* table = GTK_TABLE( gtk_table_new( 4, 4, FALSE ) );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), FALSE, TRUE, 0 );
- gtk_widget_show( GTK_WIDGET( table ) );
+ auto table = ui::Table( 4, 4, FALSE );
+ vbox2.pack_start( table, FALSE, TRUE, 0 );
+ table.show();
g_spawnflagsTable = table;
for ( int i = 0; i < MAX_FLAGS; i++ )
{
- GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( "" ) );
- gtk_widget_ref( GTK_WIDGET( check ) );
- g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( SpawnflagCheck_toggled ), 0 ) ) );
+ auto check = ui::CheckButton( "" );
+ check.ref();
+ g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( check.connect( "toggled", G_CALLBACK( SpawnflagCheck_toggled ), 0 ) ) );
g_entitySpawnflagsCheck[i] = check;
}
}
{
// key/value list
- GtkWidget* scr = gtk_scrolled_window_new( 0, 0 );
- gtk_widget_show( scr );
- gtk_box_pack_start( GTK_BOX( vbox2 ), scr, TRUE, TRUE, 0 );
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
+ vbox2.pack_start( scr, TRUE, TRUE, 0 );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
{
- GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING );
+ ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING ));
- GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) );
- gtk_tree_view_set_enable_search( GTK_TREE_VIEW( view ), FALSE );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
+ gtk_tree_view_set_enable_search(view, FALSE );
+ gtk_tree_view_set_headers_visible(view, FALSE );
g_signal_connect( G_OBJECT( view ), "key_press_event", G_CALLBACK( EntityInspector_clearKeyValueKB ), 0 );
{
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
}
{
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 1, 0 );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", 1}} );
+ gtk_tree_view_append_column(view, column );
}
{
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
- g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( EntityProperties_selection_changed ), 0 );
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view));
+ selection.connect( "changed", G_CALLBACK( EntityProperties_selection_changed ), 0 );
}
- gtk_widget_show( view );
+ view.show();
- gtk_container_add( GTK_CONTAINER( scr ), view );
+ scr.add(view);
- g_object_unref( G_OBJECT( store ) );
+ store.unref();
g_entprops_store = store;
}
{
// key/value entry
- GtkTable* table = GTK_TABLE( gtk_table_new( 2, 2, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), FALSE, TRUE, 0 );
+ auto table = ui::Table( 2, 2, FALSE );
+ table.show();
+ vbox2.pack_start( table, FALSE, TRUE, 0 );
gtk_table_set_row_spacings( table, 3 );
gtk_table_set_col_spacings( table, 5 );
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_events( GTK_WIDGET( entry ), GDK_KEY_PRESS_MASK );
- g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ gtk_widget_set_events( entry , GDK_KEY_PRESS_MASK );
+ entry.connect( "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
g_entityKeyEntry = entry;
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_events( GTK_WIDGET( entry ), GDK_KEY_PRESS_MASK );
- g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ gtk_widget_set_events( entry , GDK_KEY_PRESS_MASK );
+ entry.connect( "key_press_event", G_CALLBACK( EntityEntry_keypress ), 0 );
g_entityValueEntry = entry;
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Value" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
- (GtkAttachOptions)( GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Value" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Key" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions)( GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Key" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
}
{
- GtkBox* hbox = GTK_BOX( gtk_hbox_new( TRUE, 4 ) );
- gtk_widget_show( GTK_WIDGET( hbox ) );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 );
+ auto hbox = ui::HBox( TRUE, 4 );
+ hbox.show();
+ vbox2.pack_start( hbox, FALSE, TRUE, 0 );
{
- GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Clear All" ) );
- gtk_widget_show( GTK_WIDGET( button ) );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( EntityInspector_clearAllKeyValues ), 0 );
- gtk_box_pack_start( hbox, GTK_WIDGET( button ), TRUE, TRUE, 0 );
+ auto button = ui::Button( "Clear All" );
+ button.show();
+ button.connect( "clicked", G_CALLBACK( EntityInspector_clearAllKeyValues ), 0 );
+ hbox.pack_start( button, TRUE, TRUE, 0 );
}
{
- GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Delete Key" ) );
- gtk_widget_show( GTK_WIDGET( button ) );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( EntityInspector_clearKeyValue ), 0 );
- gtk_box_pack_start( hbox, GTK_WIDGET( button ), TRUE, TRUE, 0 );
+ auto button = ui::Button( "Delete Key" );
+ button.show();
+ button.connect( "clicked", G_CALLBACK( EntityInspector_clearKeyValue ), 0 );
+ hbox.pack_start( button, TRUE, TRUE, 0 );
}
}
}
{
- GtkWidget* scr = gtk_scrolled_window_new( 0, 0 );
- gtk_widget_show( scr );
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
- GtkWidget* viewport = gtk_viewport_new( 0, 0 );
- gtk_widget_show( viewport );
+ auto viewport = ui::Container::from(gtk_viewport_new( 0, 0 ));
+ viewport.show();
gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport ), GTK_SHADOW_NONE );
- g_attributeBox = GTK_VBOX( gtk_vbox_new( FALSE, 2 ) );
- gtk_widget_show( GTK_WIDGET( g_attributeBox ) );
+ g_attributeBox = ui::VBox( FALSE, 2 );
+ g_attributeBox.show();
- gtk_container_add( GTK_CONTAINER( viewport ), GTK_WIDGET( g_attributeBox ) );
- gtk_container_add( GTK_CONTAINER( scr ), viewport );
+ viewport.add(g_attributeBox);
+ scr.add(viewport);
gtk_paned_pack2( GTK_PANED( split0 ), scr, FALSE, FALSE );
}
}
g_entityInspector_windowConstructed = true;
EntityClassList_fill();
- typedef FreeCaller1<const Selectable&, EntityInspector_selectionChanged> EntityInspectorSelectionChangedCaller;
+ typedef FreeCaller<void(const Selectable&), EntityInspector_selectionChanged> EntityInspectorSelectionChangedCaller;
GlobalSelectionSystem().addSelectionChangeCallback( EntityInspectorSelectionChangedCaller() );
GlobalEntityCreator().setKeyValueChangedFunc( EntityInspector_keyValueChanged );
void EntityInspector_construct(){
GlobalEntityClassManager().attach( g_EntityInspector );
- GlobalPreferenceSystem().registerPreference( "EntitySplit0", IntImportStringCaller( g_entitysplit0_position ), IntExportStringCaller( g_entitysplit0_position ) );
- GlobalPreferenceSystem().registerPreference( "EntitySplit1", IntImportStringCaller( g_entitysplit1_position ), IntExportStringCaller( g_entitysplit1_position ) );
- GlobalPreferenceSystem().registerPreference( "EntitySplit2", IntImportStringCaller( g_entitysplit2_position ), IntExportStringCaller( g_entitysplit2_position ) );
+ GlobalPreferenceSystem().registerPreference( "EntitySplit0", make_property_string( g_entitysplit0_position ) );
+ GlobalPreferenceSystem().registerPreference( "EntitySplit1", make_property_string( g_entitysplit1_position ) );
+ GlobalPreferenceSystem().registerPreference( "EntitySplit2", make_property_string( g_entitysplit2_position ) );
}
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_ENTITYINSPECTOR_H )
#define INCLUDED_ENTITYINSPECTOR_H
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-GtkWidget* EntityInspector_constructWindow( GtkWindow* parent );
+ui::Widget EntityInspector_constructWindow( ui::Window parent );
void EntityInspector_construct();
void EntityInspector_destroy();
const char *EntityInspector_getCurrentKey();
#include "iselection.h"
-#include <gtk/gtktreemodel.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkcellrenderertext.h>
+#include <uilib/uilib.h>
+#include <gtk/gtk.h>
#include "string/string.h"
#include "scenelib.h"
#include "treemodel.h"
void RedrawEntityList();
-typedef FreeCaller<RedrawEntityList> RedrawEntityListCaller;
+typedef FreeCaller<void(), RedrawEntityList> RedrawEntityListCaller;
-typedef struct _GtkTreeView GtkTreeView;
class EntityList
{
IdleDraw m_idleDraw;
WindowPositionTracker m_positionTracker;
-GtkWindow* m_window;
-GtkTreeView* m_tree_view;
-GraphTreeModel* m_tree_model;
+ui::Window m_window;
+ui::TreeView m_tree_view{ui::null};
+ui::TreeModel m_tree_model{ui::null};
bool m_selection_disabled;
EntityList() :
m_dirty( EntityList::eDefault ),
m_idleDraw( RedrawEntityListCaller() ),
- m_window( 0 ),
+ m_window( ui::null ),
m_selection_disabled( false ){
}
-bool visible() const {
- return GTK_WIDGET_VISIBLE( GTK_WIDGET( m_window ) );
+bool visible() {
+ return m_window.visible();
}
};
}
template<typename value_type>
-inline void gtk_tree_model_get_pointer( GtkTreeModel* model, GtkTreeIter* iter, gint column, value_type** pointer ){
+inline void gtk_tree_model_get_pointer( ui::TreeModel model, GtkTreeIter* iter, gint column, value_type** pointer ){
GValue value = GValue_default();
gtk_tree_model_get_value( model, iter, column, &value );
*pointer = (value_type*)g_value_get_pointer( &value );
-void entitylist_treeviewcolumn_celldatafunc( GtkTreeViewColumn* column, GtkCellRenderer* renderer, GtkTreeModel* model, GtkTreeIter* iter, gpointer data ){
+void entitylist_treeviewcolumn_celldatafunc( ui::TreeViewColumn column, ui::CellRenderer renderer, ui::TreeModel model, GtkTreeIter* iter, gpointer data ){
scene::Node* node;
gtk_tree_model_get_pointer( model, iter, 0, &node );
scene::Instance* instance;
if ( node != 0 ) {
gtk_cell_renderer_set_fixed_size( renderer, -1, -1 );
char* name = const_cast<char*>( node_get_name( *node ) );
- g_object_set( G_OBJECT( renderer ), "text", name, "visible", TRUE, 0 );
+ g_object_set( G_OBJECT( renderer ), "text", name, "visible", TRUE, NULL );
//globalOutputStream() << "rendering cell " << makeQuoted(name) << "\n";
- GtkStyle* style = gtk_widget_get_style( GTK_WIDGET( getEntityList().m_tree_view ) );
+ auto style = gtk_widget_get_style( ui::TreeView( getEntityList().m_tree_view ) );
if ( instance->childSelected() ) {
- g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_ACTIVE], 0 );
+ g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_ACTIVE], NULL );
}
else
{
- g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_NORMAL], 0 );
+ g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_NORMAL], NULL );
}
}
else
{
gtk_cell_renderer_set_fixed_size( renderer, -1, 0 );
- g_object_set( G_OBJECT( renderer ), "text", "", "visible", FALSE, 0 );
+ g_object_set( G_OBJECT( renderer ), "text", "", "visible", FALSE, NULL );
}
}
-static gboolean entitylist_tree_select( GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer data ){
+static gboolean entitylist_tree_select( ui::TreeSelection selection, ui::TreeModel model, ui::TreePath path, gboolean path_currently_selected, gpointer data ){
GtkTreeIter iter;
gtk_tree_model_get_iter( model, &iter, path );
scene::Node* node;
return FALSE;
}
-static gboolean entitylist_tree_select_null( GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer data ){
+static gboolean entitylist_tree_select_null( ui::TreeSelection selection, ui::TreeModel model, ui::TreePath path, gboolean path_currently_selected, gpointer data ){
return TRUE;
}
-void EntityList_ConnectSignals( GtkTreeView* view ){
- GtkTreeSelection* select = gtk_tree_view_get_selection( view );
- gtk_tree_selection_set_select_function( select, entitylist_tree_select, NULL, 0 );
+void EntityList_ConnectSignals( ui::TreeView view ){
+ auto select = gtk_tree_view_get_selection( view );
+ gtk_tree_selection_set_select_function(select, reinterpret_cast<GtkTreeSelectionFunc>(entitylist_tree_select), NULL, 0 );
}
-void EntityList_DisconnectSignals( GtkTreeView* view ){
- GtkTreeSelection* select = gtk_tree_view_get_selection( view );
- gtk_tree_selection_set_select_function( select, entitylist_tree_select_null, 0, 0 );
+void EntityList_DisconnectSignals( ui::TreeView view ){
+ auto select = gtk_tree_view_get_selection( view );
+ gtk_tree_selection_set_select_function(select, reinterpret_cast<GtkTreeSelectionFunc>(entitylist_tree_select_null), 0, 0 );
}
-gboolean treemodel_update_selection( GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data ){
- GtkTreeView* view = reinterpret_cast<GtkTreeView*>( data );
+gboolean treemodel_update_selection( ui::TreeModel model, ui::TreePath path, GtkTreeIter* iter, gpointer data ){
+ auto view = ui::TreeView::from( data );
scene::Instance* instance;
gtk_tree_model_get_pointer( model, iter, 1, &instance );
Selectable* selectable = Instance_getSelectable( *instance );
if ( selectable != 0 ) {
- GtkTreeSelection* selection = gtk_tree_view_get_selection( view );
+ auto selection = gtk_tree_view_get_selection( view );
if ( selectable->isSelected() ) {
gtk_tree_selection_select_path( selection, path );
}
return FALSE;
}
-void EntityList_UpdateSelection( GtkTreeModel* model, GtkTreeView* view ){
+void EntityList_UpdateSelection( ui::TreeModel model, ui::TreeView view ){
EntityList_DisconnectSignals( view );
- gtk_tree_model_foreach( model, treemodel_update_selection, view );
+ gtk_tree_model_foreach(model, reinterpret_cast<GtkTreeModelForeachFunc>(treemodel_update_selection), view._handle );
EntityList_ConnectSignals( view );
}
{
case EntityList::eInsertRemove:
case EntityList::eSelection:
- EntityList_UpdateSelection( GTK_TREE_MODEL( getEntityList().m_tree_model ), getEntityList().m_tree_view );
+ EntityList_UpdateSelection( getEntityList().m_tree_model, getEntityList().m_tree_view );
default:
break;
}
EntityList_SelectionUpdate();
}
-void entitylist_treeview_rowcollapsed( GtkTreeView* view, GtkTreeIter* iter, GtkTreePath* path, gpointer user_data ){
+void entitylist_treeview_rowcollapsed( ui::TreeView view, GtkTreeIter* iter, ui::TreePath path, gpointer user_data ){
}
-void entitylist_treeview_row_expanded( GtkTreeView* view, GtkTreeIter* iter, GtkTreePath* path, gpointer user_data ){
+void entitylist_treeview_row_expanded( ui::TreeView view, GtkTreeIter* iter, ui::TreePath path, gpointer user_data ){
EntityList_SelectionUpdate();
}
void EntityList_SetShown( bool shown ){
- widget_set_visible( GTK_WIDGET( getEntityList().m_window ), shown );
+ getEntityList().m_window.visible(shown);
}
void EntityList_toggleShown(){
EntityList_SetShown( !getEntityList().visible() );
}
-gint graph_tree_model_compare_name( GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data ){
+gint graph_tree_model_compare_name( ui::TreeModel model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data ){
scene::Node* first;
gtk_tree_model_get( model, a, 0, (gpointer*)&first, -1 );
scene::Node* second;
extern GraphTreeModel* scene_graph_get_tree_model();
void AttachEntityTreeModel(){
- getEntityList().m_tree_model = scene_graph_get_tree_model();
+ getEntityList().m_tree_model = ui::TreeModel::from(scene_graph_get_tree_model());
- gtk_tree_view_set_model( getEntityList().m_tree_view, GTK_TREE_MODEL( getEntityList().m_tree_model ) );
+ gtk_tree_view_set_model( getEntityList().m_tree_view, getEntityList().m_tree_model );
}
void DetachEntityTreeModel(){
- getEntityList().m_tree_model = 0;
+ getEntityList().m_tree_model = ui::TreeModel(ui::null);
gtk_tree_view_set_model( getEntityList().m_tree_view, 0 );
}
-void EntityList_constructWindow( GtkWindow* main_window ){
- ASSERT_MESSAGE( getEntityList().m_window == 0, "error" );
+void EntityList_constructWindow( ui::Window main_window ){
+ ASSERT_TRUE( !getEntityList().m_window );
- GtkWindow* window = create_persistent_floating_window( "Entity List", main_window );
+ auto window = ui::Window(create_persistent_floating_window( "Entity List", main_window ));
- gtk_window_add_accel_group( window, global_accel );
+ window.add_accel_group(global_accel);
getEntityList().m_positionTracker.connect( window );
getEntityList().m_window = window;
{
- GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( scr ) );
+ auto scr = create_scrolled_window( ui::Policy::AUTOMATIC, ui::Policy::AUTOMATIC );
+ window.add(scr);
{
- GtkWidget* view = gtk_tree_view_new();
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
+ auto view = ui::TreeView(ui::New);
+ gtk_tree_view_set_headers_visible(view, FALSE );
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new();
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = gtk_tree_view_column_new();
gtk_tree_view_column_pack_start( column, renderer, TRUE );
- gtk_tree_view_column_set_cell_data_func( column, renderer, entitylist_treeviewcolumn_celldatafunc, 0, 0 );
+ gtk_tree_view_column_set_cell_data_func(column, renderer, reinterpret_cast<GtkTreeCellDataFunc>(entitylist_treeviewcolumn_celldatafunc), 0, 0 );
- GtkTreeSelection* select = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
+ auto select = gtk_tree_view_get_selection(view );
gtk_tree_selection_set_mode( select, GTK_SELECTION_MULTIPLE );
- g_signal_connect( G_OBJECT( view ), "row_expanded", G_CALLBACK( entitylist_treeview_row_expanded ), 0 );
- g_signal_connect( G_OBJECT( view ), "row_collapsed", G_CALLBACK( entitylist_treeview_rowcollapsed ), 0 );
+ view.connect( "row_expanded", G_CALLBACK( entitylist_treeview_row_expanded ), 0 );
+ view.connect( "row_collapsed", G_CALLBACK( entitylist_treeview_rowcollapsed ), 0 );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ gtk_tree_view_append_column(view, column );
- gtk_widget_show( view );
- gtk_container_add( GTK_CONTAINER( scr ), view );
- getEntityList().m_tree_view = GTK_TREE_VIEW( view );
+ view.show();
+ scr.add(view);
+ getEntityList().m_tree_view = view;
}
}
getEntityList().m_positionTracker.setPosition( c_default_window_pos );
- GlobalPreferenceSystem().registerPreference( "EntityInfoDlg", WindowPositionTrackerImportStringCaller( getEntityList().m_positionTracker ), WindowPositionTrackerExportStringCaller( getEntityList().m_positionTracker ) );
+ GlobalPreferenceSystem().registerPreference( "EntityInfoDlg", make_property<WindowPositionTracker_String>( getEntityList().m_positionTracker ) );
- typedef FreeCaller1<const Selectable&, EntityList_SelectionChanged> EntityListSelectionChangedCaller;
+ typedef FreeCaller<void(const Selectable&), EntityList_SelectionChanged> EntityListSelectionChangedCaller;
GlobalSelectionSystem().addSelectionChangeCallback( EntityListSelectionChangedCaller() );
}
void EntityList_Destroy(){
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_ENTITYLIST_H )
#define INCLUDED_ENTITYLIST_H
void EntityList_Construct();
void EntityList_Destroy();
-typedef struct _GtkWindow GtkWindow;
-void EntityList_constructWindow( GtkWindow* main_window );
+void EntityList_constructWindow( ui::Window main_window );
void EntityList_destroyWindow();
void EntityList_toggleShown();
*/
#include "environment.h"
+#include "globaldefs.h"
#include "stream/textstream.h"
#include "string/string.h"
#include "cmdlib.h"
int g_argc;
-char** g_argv;
+char const** g_argv;
-void args_init( int argc, char* argv[] ){
+void args_init( int argc, char const* argv[] ){
int i, j, k;
for ( i = 1; i < argc; i++ )
{
for ( k = i; k < argc; k++ )
+ {
if ( argv[k] != 0 ) {
break;
}
+ }
if ( k > i ) {
k -= i;
for ( j = i + k; j < argc; j++ )
+ {
argv[j - k] = argv[j];
+ }
argc -= k;
}
}
g_argv = argv;
}
-char *gamedetect_argv_buffer[1024];
-void gamedetect_found_game( char *game, char *path ){
+char const *gamedetect_argv_buffer[1024];
+
+void gamedetect_found_game( char const *game, char *path ){
int argc;
static char buf[128];
g_argv = gamedetect_argv_buffer;
}
-bool gamedetect_check_game( char *gamefile, const char *checkfile1, const char *checkfile2, char *buf /* must have 64 bytes free after bufpos */, int bufpos ){
+bool gamedetect_check_game( char const *gamefile, const char *checkfile1, const char *checkfile2, char *buf /* must have 64 bytes free after bufpos */, int bufpos ){
buf[bufpos] = '/';
strcpy( buf + bufpos + 1, checkfile1 );
bool nogamedetect = true;
int i;
for ( i = 1; i < g_argc - 1; ++i )
+ {
if ( g_argv[i][0] == '-' ) {
if ( !strcmp( g_argv[i], "-gamedetect" ) ) {
nogamedetect = !strcmp( g_argv[i + 1], "false" );
}
++i;
}
+ }
if ( !nogamedetect ) {
static char buf[1024 + 64];
strncpy( buf, environment_get_app_path(), sizeof( buf ) );
// TODO add more games to this
// try to detect Nexuiz installs
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "nexuiz.exe", buf, p - buf ) )
-#elif defined( __APPLE__ )
+#elif GDEF_OS_MACOS
if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "Nexuiz.app/Contents/Info.plist", buf, p - buf ) )
#else
if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "nexuiz-linux-glx.sh", buf, p - buf ) )
#endif
{ return; }
- // try to detect Q2World installs
- if ( gamedetect_check_game( "q2w.game", "default/quake2world.version", NULL, buf, p - buf ) ) {
+ // try to detect Quetoo installs
+ if ( gamedetect_check_game( "quetoo.game", "default/icons/quetoo.png", NULL, buf, p - buf ) ) {
return;
}
}
-char* openCmdMap;
+const char* openCmdMap;
void cmdMap(){
openCmdMap = NULL;
}
}
-#if defined( POSIX )
+#if GDEF_OS_POSIX
#include <stdlib.h>
#include <pwd.h>
#include <glib.h>
const char* LINK_NAME =
-#if defined ( __linux__ )
+#if GDEF_OS_LINUX
"/proc/self/exe"
#else // FreeBSD and OSX
"/proc/curproc/file"
;
/// brief Returns the filename of the executable belonging to the current process, or 0 if not found.
-char* getexename( char *buf ){
+char const* getexename( char *buf ){
/* Now read the symbolic link */
int ret = readlink( LINK_NAME, buf, PATH_MAX );
return buf;
}
-void environment_init( int argc, char* argv[] ){
+void environment_init( int argc, char const* argv[] ){
// Give away unnecessary root privileges.
// Important: must be done before calling gtk_init().
char *loginname;
if ( !portable_app_setup() ) {
StringOutputStream home( 256 );
- home << DirectoryCleaned( g_get_home_dir() ) << ".netradiant/";
+ home << DirectoryCleaned( g_get_user_config_dir() ) << "netradiant/";
Q_mkdir( home.c_str() );
home_path = home.c_str();
}
cmdMap();
}
-#elif defined( WIN32 )
+#elif GDEF_OS_WINDOWS
#include <windows.h>
-void environment_init( int argc, char* argv[] ){
+void environment_init( int argc, char const* argv[] ){
args_init( argc, argv );
{
if ( !portable_app_setup() ) {
char *appdata = getenv( "APPDATA" );
StringOutputStream home( 256 );
- if ( !appdata || string_empty( appdata ) ) {
- ERROR_MESSAGE( "Application Data folder not available.\n"
- "Radiant will use C:\\ for user preferences.\n" );
- home << "C:";
- }
- else
- {
- home << PathCleaned( appdata );
- }
+ home << PathCleaned( appdata );
home << "/NetRadiantSettings/";
Q_mkdir( home.c_str() );
home_path = home.c_str();
#if !defined( INCLUDED_ENVIRONMENT_H )
#define INCLUDED_ENVIRONMENT_H
-void environment_init( int argc, char* argv[] );
+void environment_init( int argc, char const* argv[] );
const char* environment_get_home_path();
const char* environment_get_app_path();
extern int g_argc;
-extern char** g_argv;
-
-extern char* openCmdMap;
+extern char const** g_argv;
+extern const char* openCmdMap;
#endif
*/
#include "error.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
#include "igl.h"
#include "preferences.h"
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#define UNICODE
#include <windows.h>
#else
strcat( text, "\n" );
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
if ( GetLastError() != 0 ) {
LPVOID lpMsgBuf;
FormatMessage(
#include "feedback.h"
+#include <gtk/gtk.h>
+
#include "debugging/debugging.h"
#include "igl.h"
#include "iselection.h"
-#include <gtk/gtktreeview.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkliststore.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkscrolledwindow.h>
-
#include "map.h"
#include "dialog.h"
#include "mainframe.h"
}
// triggered when the user selects an entry in the feedback box
-static void feedback_selection_changed( GtkTreeSelection* selection, gpointer data ){
+static void feedback_selection_changed( ui::TreeSelection selection, gpointer data ){
g_DbgDlg.DropHighlight();
GtkTreeModel* model;
GtkTreeIter selected;
if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) {
- GtkTreePath* path = gtk_tree_model_get_path( model, &selected );
+ auto path = gtk_tree_model_get_path( model, &selected );
g_DbgDlg.SetHighlight( gtk_tree_path_get_indices( path )[0] );
gtk_tree_path_free( path );
}
g_ptr_array_remove_index( m_pFeedbackElements, 0 );
}
- if ( m_clist != NULL ) {
- gtk_list_store_clear( m_clist );
+ if ( m_clist ) {
+ m_clist.clear();
}
}
// push in the list
g_ptr_array_add( m_pFeedbackElements, (void *)pHandler );
- if ( GetWidget() == 0 ) {
+ if ( !GetWidget() ) {
Create();
}
// put stuff in the list
- gtk_list_store_clear( m_clist );
+ m_clist.clear();
for ( std::size_t i = 0; i < static_cast<std::size_t>( m_pFeedbackElements->len ); ++i )
{
- GtkTreeIter iter;
- gtk_list_store_append( m_clist, &iter );
- gtk_list_store_set( m_clist, &iter, 0, GetElement( i )->getName(), -1 );
+ m_clist.append(0, GetElement(i)->getName());
}
ShowDlg();
}
-GtkWindow* CDbgDlg::BuildDialog(){
- GtkWindow* window = create_floating_window( "Q3Map debug window", MainFrame_getWindow() );
+ui::Window CDbgDlg::BuildDialog(){
+ auto window = MainFrame_getWindow().create_floating_window("Q3Map debug window" );
- GtkWidget* scr = gtk_scrolled_window_new( NULL, NULL );
- gtk_widget_show( scr );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( scr ) );
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
+ window.add(scr);
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
{
- GtkListStore* store = gtk_list_store_new( 1, G_TYPE_STRING );
+ ui::ListStore store = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
- GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
+ gtk_tree_view_set_headers_visible(view, FALSE );
{
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, NULL );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
}
{
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view ));
gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE );
- g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( feedback_selection_changed ), NULL );
+ selection.connect( "changed", G_CALLBACK( feedback_selection_changed ), NULL );
}
- gtk_widget_show( view );
+ view.show();
- gtk_container_add( GTK_CONTAINER( scr ), view );
+ scr.add(view);
- g_object_unref( G_OBJECT( store ) );
+ store.unref();
m_clist = store;
}
#include "math/vector.h"
#include "stream/stringstream.h"
-#include <glib.h>
#include "xmlstuff.h"
#include "dialog.h"
#include "xywindow.h"
class IGL2DWindow
{
public:
+virtual ~IGL2DWindow() = default;
// Increment the number of references to this object
virtual void IncRef() = 0;
// Decrement the reference count
void Draw2D( VIEWTYPE vt );
};
-typedef struct _GtkListStore GtkListStore;
class CDbgDlg : public Dialog
{
GPtrArray *m_pFeedbackElements;
// the list widget we use in the dialog
-GtkListStore* m_clist;
+ui::ListStore m_clist{ui::null};
ISAXHandler *m_pHighlight;
IGL2DWindow* m_pDraw2D;
public:
}
}
void destroyWindow(){
- if ( GetWidget() != 0 ) {
+ if ( GetWidget() ) {
Destroy();
}
}
// void HideDlg();
protected:
-GtkWindow* BuildDialog();
+ui::Window BuildDialog();
};
extern CDbgDlg g_DbgDlg;
struct filetype_copy_t
{
filetype_copy_t( const char* moduleName, const filetype_t other )
- : m_moduleName( moduleName ), m_name( other.name ), m_pattern( other.pattern ), m_can_load( other.can_load ), m_can_import( other.can_import ), m_can_save( other.can_save ){
+ : m_can_load( other.can_load ), m_can_import( other.can_import ), m_can_save( other.can_save ), m_moduleName( moduleName ), m_name( other.name ), m_pattern( other.pattern ) {
}
const char* getModuleName() const {
return m_moduleName.c_str();
#include "filterbar.h"
-#include <gtk/gtktoolbar.h>
+
+#include "gtk/gtk.h"
+
#include "gtkmisc.h"
#include "gtkutil/widget.h"
#include "stream/stringstream.h"
#include "generic/callback.h"
#include "entity.h"
-
-
int ToggleActions = 0;
int ButtonNum = 0;
-gboolean ToggleActions0( GtkWidget *widget, GdkEvent *event, gpointer user_data ){
+
+gboolean ToggleActions0( ui::Widget widget, GdkEvent *event, gpointer user_data ){
ToggleActions = 0;
return FALSE;
//globalOutputStream() << "ToggleActions\n";
}
+
void SetCommonShader( const char* key, const char* shader ){
const char* gotShader = g_pGameDescription->getKeyValue( key );
UndoableCommand undo( "textureNameSetSelected" );
}
-gboolean Areaportals_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
+gboolean Areaportals_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
if ( ButtonNum == 1 ){
ToggleActions %= 2;
}
-gboolean Caulk_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
+gboolean Caulk_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
SetCommonShader( "shader_caulk", "textures/common/caulk" );
ToggleActions = 0;
return FALSE;
}
-gboolean Clip_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
+
+gboolean Clip_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
if ( ButtonNum == 3 ){
ToggleActions %= 2;
return FALSE;
}
-gboolean Liquids_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
+
+gboolean Liquids_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
if ( ButtonNum == 4 ){
ToggleActions %= 3;
}
-gboolean Hint_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
+gboolean Hint_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
if ( ButtonNum == 5 ){
ToggleActions %= 3;
return FALSE;
}
-gboolean Trigger_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
+
+gboolean Trigger_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
SetCommonShader( "shader_trigger", "textures/common/trigger" );
ToggleActions = 0;
return FALSE;
}
-gboolean Detail_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
+
+gboolean Detail_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
GlobalCommands_find( "MakeDetail" ).m_callback();
ToggleActions = 0;
return FALSE;
}
-gboolean Structural_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
+
+gboolean Structural_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
GlobalCommands_find( "MakeStructural" ).m_callback();
ToggleActions = 0;
return FALSE;
}
-gboolean Region_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
+gboolean Region_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
GlobalCommands_find( "RegionOff" ).m_callback();
ToggleActions = 0;
return FALSE;
}
-GtkToolbar* create_filter_toolbar(){
- GtkToolbar* toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
+ui::Toolbar create_filter_toolbar(){
+ auto toolbar = ui::Toolbar::from( gtk_toolbar_new() );
+ gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL );
gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS );
// gtk_toolbar_set_show_arrow( toolbar, TRUE );
- gtk_widget_show( GTK_WIDGET( toolbar ) );
- g_signal_connect( G_OBJECT( toolbar ), "enter_notify_event", G_CALLBACK( ToggleActions0 ), 0 );
+ toolbar.show();
- GtkToggleButton* button;
- toolbar_append_toggle_button( toolbar, "World (ALT + 1)", "f-world.png", "FilterWorldBrushes" );
-
- button = toolbar_append_toggle_button( toolbar, "Structural (CTRL + SHIFT + D)\nRightClick: MakeStructural", "f-structural.png", "FilterStructural" );
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Structural_button_press ), 0 );
+ auto space = [&]() {
+ auto btn = ui::ToolItem::from(gtk_separator_tool_item_new());
+ btn.show();
+ toolbar.add(btn);
+ };
- button = toolbar_append_toggle_button( toolbar, "Details (CTRL + D)\nRightClick: MakeDetail", "f-details.png", "FilterDetails" );
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Detail_button_press ), 0 );
+ g_signal_connect( G_OBJECT( toolbar ), "enter_notify_event", G_CALLBACK( ToggleActions0 ), 0 );
- button = toolbar_append_toggle_button( toolbar, "Func_Groups\nRightClick: create func_group", "f-funcgroups.png", "FilterFuncGroups" );
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Func_Groups_button_press ), 0 );
+ toolbar_append_toggle_button( toolbar, "World (ALT + 1)", "f-world.png", "FilterWorldBrushes" );
- toolbar_append_toggle_button( toolbar, "Patches (CTRL + P)", "patch_wireframe.png", "FilterPatches" );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ {
+ auto button = toolbar_append_toggle_button( toolbar, "Structural (CTRL + SHIFT + D)\nRightClick: MakeStructural", "f-structural.png", "FilterStructural" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Structural_button_press ), 0 );
+ }
- if ( g_pGameDescription->mGameType == "doom3" ) {
- button = toolbar_append_toggle_button( toolbar, "Visportals (ALT + 3)\nRightClick: toggle tex\n\tnoDraw\n\tnoDrawNonSolid", "f-areaportal.png", "FilterVisportals" );
+ {
+ auto button = toolbar_append_toggle_button( toolbar, "Details (CTRL + D)\nRightClick: MakeDetail", "f-details.png", "FilterDetails" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Detail_button_press ), 0 );
}
- else{
- button = toolbar_append_toggle_button( toolbar, "Areaportals (ALT + 3)\nRightClick: toggle tex\n\tnoDraw\n\tnoDrawNonSolid", "f-areaportal.png", "FilterAreaportals" );
+
+ {
+ auto button = toolbar_append_toggle_button( toolbar, "Func_Groups\nRightClick: create func_group", "f-funcgroups.png", "FilterFuncGroups" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Func_Groups_button_press ), 0 );
+
+ toolbar_append_toggle_button( toolbar, "Patches (CTRL + P)", "patch_wireframe.png", "FilterPatches" );
}
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Areaportals_button_press ), 0 );
+ space();
+
+ {
+ if ( g_pGameDescription->mGameType == "doom3" ) {
+ auto button = toolbar_append_toggle_button( toolbar, "Areaportals (ALT + 3)\nRightClick: toggle tex\n\tnoDraw\n\tnoDrawNonSolid", "f-areaportal.png", "FilterVisportals" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Areaportals_button_press ), 0 );
+ }
+ else{
+ auto button = toolbar_append_toggle_button( toolbar, "Areaportals (ALT + 3)\nRightClick: toggle tex\n\tnoDraw\n\tnoDrawNonSolid", "f-areaportal.png", "FilterAreaportals" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Areaportals_button_press ), 0 );
+ }
+ }
toolbar_append_toggle_button( toolbar, "Translucent (ALT + 4)", "f-translucent.png", "FilterTranslucent" );
- button = toolbar_append_toggle_button( toolbar, "Liquids (ALT + 5)\nRightClick: toggle tex\n\twaterCaulk\n\tlavaCaulk\n\tslimeCaulk", "f-liquids.png", "FilterLiquids" );
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Liquids_button_press ), 0 );
+ {
+ auto button = toolbar_append_toggle_button( toolbar, "Liquids (ALT + 5)\nRightClick: toggle tex\n\twaterCaulk\n\tlavaCaulk\n\tslimeCaulk", "f-liquids.png", "FilterLiquids" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Liquids_button_press ), 0 );
+ }
- button = toolbar_append_toggle_button( toolbar, "Caulk (ALT + 6)\nRightClick: tex Caulk", "f-caulk.png", "FilterCaulk" );
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Caulk_button_press ), 0 );
+ {
+ auto button = toolbar_append_toggle_button( toolbar, "Caulk (ALT + 6)\nRightClick: tex Caulk", "f-caulk.png", "FilterCaulk" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Caulk_button_press ), 0 );
+ }
- button = toolbar_append_toggle_button( toolbar, "Clips (ALT + 7)\nRightClick: toggle tex\n\tplayerClip\n\tweapClip", "f-clip.png", "FilterClips" );
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Clip_button_press ), 0 );
+ {
+ auto button = toolbar_append_toggle_button( toolbar, "Clips (ALT + 7)\nRightClick: toggle tex\n\tplayerClip\n\tweapClip", "f-clip.png", "FilterClips" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Clip_button_press ), 0 );
+ }
- button = toolbar_append_toggle_button( toolbar, "HintsSkips (CTRL + H)\nRightClick: toggle tex\n\thint\n\thintLocal\n\thintSkip", "f-hint.png", "FilterHintsSkips" );
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Hint_button_press ), 0 );
+ {
+ auto button = toolbar_append_toggle_button( toolbar, "HintsSkips (CTRL + H)\nRightClick: toggle tex\n\thint\n\thintLocal\n\thintSkip", "f-hint.png", "FilterHintsSkips" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Hint_button_press ), 0 );
+ }
//toolbar_append_toggle_button( toolbar, "Paths (ALT + 8)", "texture_lock.png", "FilterPaths" );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+
+ space();
+
toolbar_append_toggle_button( toolbar, "Entities (ALT + 2)", "f-entities.png", "FilterEntities" );
toolbar_append_toggle_button( toolbar, "Lights (ALT + 0)", "f-lights.png", "FilterLights" );
toolbar_append_toggle_button( toolbar, "Models (SHIFT + M)", "f-models.png", "FilterModels" );
- button = toolbar_append_toggle_button( toolbar, "Triggers (CTRL + SHIFT + T)\nRightClick: tex Trigger", "f-triggers.png", "FilterTriggers" );
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Trigger_button_press ), 0 );
+ {
+ auto button = toolbar_append_toggle_button( toolbar, "Triggers (CTRL + SHIFT + T)\nRightClick: tex Trigger", "f-triggers.png", "FilterTriggers" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Trigger_button_press ), 0 );
+ }
//toolbar_append_toggle_button( toolbar, "Decals (SHIFT + D)", "f-decals.png", "FilterDecals" );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
- //toolbar_append_button( toolbar, "InvertFilters", "f-invert.png", "InvertFilters" );
+
+ space();
+
+ toolbar_append_button( toolbar, "InvertFilters", "f-invert.png", "InvertFilters" );
toolbar_append_button( toolbar, "ResetFilters", "f-reset.png", "ResetFilters" );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
- button = toolbar_append_toggle_button( toolbar, "Region Set Selection (CTRL + SHIFT + R)\nRightClick: Region Off", "f-region.png", "RegionSetSelection" );
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Region_button_press ), 0 );
+ space();
+
+ {
+ auto button = toolbar_append_toggle_button( toolbar, "Region Set Selection (CTRL + SHIFT + R)\nRightClick: Region Off", "f-region.png", "RegionSetSelection" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Region_button_press ), 0 );
+ }
- button = toolbar_append_toggle_button( toolbar, "Hide Selected (H)\nRightClick: Show Hidden (SHIFT + H)", "f-hide.png", "HideSelected" );
- g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Hide_button_press ), 0 );
+ {
+ auto button = toolbar_append_toggle_button( toolbar, "Hide Selected (H)\nRightClick: Show Hidden (SHIFT + H)", "f-hide.png", "HideSelected" );
+ g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Hide_button_press ), 0 );
+ }
return toolbar;
}
#if !defined( INCLUDED_FILTERBAR_H )
#define INCLUDED_FILTERBAR_H
-#include <gtk/gtktoolbar.h>
-
-
-
-
-
-
-
-GtkToolbar* create_filter_toolbar();
-
+#include <uilib/uilib.h>
+ui::Toolbar create_filter_toolbar();
#endif
}
ToggleFilterFlag( const ToggleFilterFlag& other ) : m_mask( other.m_mask ), m_item( ActiveCaller( *this ) ){
}
-void active( const BoolImportCallback& importCallback ){
+void active( const Callback<void(bool)> &importCallback ){
importCallback( ( g_filters_globals.exclude & m_mask ) != 0 );
}
-typedef MemberCaller1<ToggleFilterFlag, const BoolImportCallback&, &ToggleFilterFlag::active> ActiveCaller;
+typedef MemberCaller<ToggleFilterFlag, void(const Callback<void(bool)>&), &ToggleFilterFlag::active> ActiveCaller;
void toggle(){
g_filters_globals.exclude ^= m_mask;
m_item.update();
m_item.update();
PerformFiltering();
}
-typedef MemberCaller<ToggleFilterFlag, &ToggleFilterFlag::toggle> ToggleCaller;
+typedef MemberCaller<ToggleFilterFlag, void(), &ToggleFilterFlag::toggle> ToggleCaller;
};
}
}
-void Filters_constructMenu( GtkMenu* menu_in_menu ){
+void Filters_constructMenu( ui::Menu menu_in_menu ){
create_check_menu_item_with_mnemonic( menu_in_menu, "World", "FilterWorldBrushes" );
create_check_menu_item_with_mnemonic( menu_in_menu, "Entities", "FilterEntities" );
if ( g_pGameDescription->mGameType == "doom3" ) {
#include "stringio.h"
void ConstructFilters(){
- GlobalPreferenceSystem().registerPreference( "SI_Exclude", SizeImportStringCaller( g_filters_globals.exclude ), SizeExportStringCaller( g_filters_globals.exclude ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Exclude", make_property_string( g_filters_globals.exclude ) );
- GlobalCommands_insert( "InvertFilters", FreeCaller<InvertFilters>() );
- GlobalCommands_insert( "ResetFilters", FreeCaller<ResetFilters>() );
+ GlobalCommands_insert( "InvertFilters", makeCallbackF(InvertFilters) );
+ GlobalCommands_insert( "ResetFilters", makeCallbackF(ResetFilters) );
add_filter_command( EXCLUDE_WORLD, "FilterWorldBrushes", Accelerator( '1', (GdkModifierType)GDK_MOD1_MASK ) );
add_filter_command( EXCLUDE_ENT, "FilterEntities", Accelerator( '2', (GdkModifierType)GDK_MOD1_MASK ) );
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_FILTERS_H )
#define INCLUDED_FILTERS_H
-typedef struct _GtkMenu GtkMenu;
-void Filters_constructMenu( GtkMenu* menu_in_menu );
+void Filters_constructMenu( ui::Menu menu_in_menu );
#endif
#include "findtexturedialog.h"
+#include <gtk/gtk.h>
+
#include "debugging/debugging.h"
#include "ishaders.h"
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtktogglebutton.h>
-#include <gtk/gtkcheckbutton.h>
-#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkarrow.h>
-
#include "gtkutil/window.h"
#include "stream/stringstream.h"
static void setFindStr( const char* name );
static bool isOpen();
static void show();
-typedef FreeCaller<&FindTextureDialog::show> ShowCaller;
+typedef FreeCaller<void(), &FindTextureDialog::show> ShowCaller;
static void updateTextures( const char* name );
FindTextureDialog();
virtual ~FindTextureDialog();
-GtkWindow* BuildDialog();
+ui::Window BuildDialog();
-void constructWindow( GtkWindow* parent ){
+void constructWindow( ui::Window parent ){
m_parent = parent;
Create();
}
FindReplaceTextures( find.c_str(), replace.c_str(), g_FindTextureDialog.m_bSelectedOnly );
}
-static void OnApply( GtkWidget* widget, gpointer data ){
+static void OnApply( ui::Widget widget, gpointer data ){
g_FindTextureDialog.exportData();
FindTextureDialog_apply();
}
-static void OnFind( GtkWidget* widget, gpointer data ){
+static void OnFind( ui::Widget widget, gpointer data ){
g_FindTextureDialog.exportData();
FindTextureDialog_apply();
}
-static void OnOK( GtkWidget* widget, gpointer data ){
+static void OnOK( ui::Widget widget, gpointer data ){
g_FindTextureDialog.exportData();
FindTextureDialog_apply();
g_FindTextureDialog.HideDlg();
}
-static void OnClose( GtkWidget* widget, gpointer data ){
+static void OnClose( ui::Widget widget, gpointer data ){
g_FindTextureDialog.HideDlg();
}
-static gint find_focus_in( GtkWidget* widget, GdkEventFocus *event, gpointer data ){
+static gint find_focus_in( ui::Widget widget, GdkEventFocus *event, gpointer data ){
g_bFindActive = true;
return FALSE;
}
-static gint replace_focus_in( GtkWidget* widget, GdkEventFocus *event, gpointer data ){
+static gint replace_focus_in( ui::Widget widget, GdkEventFocus *event, gpointer data ){
g_bFindActive = false;
return FALSE;
}
FindTextureDialog::~FindTextureDialog(){
}
-GtkWindow* FindTextureDialog::BuildDialog(){
- GtkWidget* vbox, *hbox, *table, *label;
- GtkWidget* button, *check, *entry;
+ui::Window FindTextureDialog::BuildDialog(){
+ ui::Widget label{ui::null};
+ ui::Widget button{ui::null};
+ ui::Entry entry{ui::null};
- GtkWindow* dlg = create_floating_window( "Find / Replace Texture(s)", m_parent );
+ auto dlg = ui::Window(create_floating_window( "Find / Replace Texture(s)", m_parent ));
m_position_tracker.connect( dlg );
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( hbox ) );
+ auto hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ dlg.add(hbox);
gtk_container_set_border_width( GTK_CONTAINER( hbox ), 5 );
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
-
- table = gtk_table_new( 2, 2, FALSE );
- gtk_widget_show( table );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
-
- label = gtk_label_new( "Find:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
+
+ auto table = ui::Table(2, 2, FALSE);
+ table.show();
+ vbox.pack_start( table, TRUE, TRUE, 0 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
+
+ label = ui::Label( "Find:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
- label = gtk_label_new( "Replace:*" );
+ label = ui::Label( "Replace:*" );
gtk_widget_set_tooltip_text( label, "Empty = search mode" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
- entry = gtk_entry_new();
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( entry ), "focus_in_event",
+ entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ entry.connect( "focus_in_event",
G_CALLBACK( find_focus_in ), 0 );
- AddDialogData( *GTK_ENTRY( entry ), m_strFind );
- GlobalTextureEntryCompletion::instance().connect( GTK_ENTRY( entry ) );
+ AddDialogData( entry, m_strFind );
+ GlobalTextureEntryCompletion::instance().connect( entry );
- entry = gtk_entry_new();
+ entry = ui::Entry(ui::New);
gtk_widget_set_tooltip_text( entry, "Empty = search mode" );
- gtk_widget_show( entry );
- gtk_table_attach( GTK_TABLE( table ), entry, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( entry ), "focus_in_event",
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ entry.connect( "focus_in_event",
G_CALLBACK( replace_focus_in ), 0 );
- AddDialogData( *GTK_ENTRY( entry ), m_strReplace );
- GlobalTextureEntryCompletion::instance().connect( GTK_ENTRY( entry ) );
-
- check = gtk_check_button_new_with_label( "Within selected brushes only" );
- gtk_widget_show( check );
- gtk_box_pack_start( GTK_BOX( vbox ), check, TRUE, TRUE, 0 );
- AddDialogData( *GTK_TOGGLE_BUTTON( check ), m_bSelectedOnly );
-
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
-
- button = gtk_button_new_with_label( "Apply" );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ AddDialogData( entry, m_strReplace );
+ GlobalTextureEntryCompletion::instance().connect( entry );
+
+ auto check = ui::CheckButton( "Within selected brushes only" );
+ check.show();
+ vbox.pack_start( check, TRUE, TRUE, 0 );
+ AddDialogData( check, m_bSelectedOnly );
+
+ vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
+
+ button = ui::Button( "Apply" );
+ button.show();
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ button.connect( "clicked",
G_CALLBACK( OnApply ), 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
- button = gtk_button_new_with_label( "Close" );
- gtk_widget_show( button );
- gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ button = ui::Button( "Close" );
+ button.show();
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ button.connect( "clicked",
G_CALLBACK( OnClose ), 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
return dlg;
}
}
bool FindTextureDialog::isOpen(){
- return GTK_WIDGET_VISIBLE( g_FindTextureDialog.GetWidget() ) == TRUE;
+ return g_FindTextureDialog.GetWidget().visible();
}
void FindTextureDialog::setFindStr( const char* name ){
}
-void FindTextureDialog_constructWindow( GtkWindow* main_window ){
+void FindTextureDialog_constructWindow( ui::Window main_window ){
g_FindTextureDialog.constructWindow( main_window );
}
void FindTextureDialog_Construct(){
GlobalCommands_insert( "FindReplaceTextures", FindTextureDialog::ShowCaller() );
- GlobalPreferenceSystem().registerPreference( "FindReplacehWnd", WindowPositionTrackerImportStringCaller( g_FindTextureDialog.m_position_tracker ), WindowPositionTrackerExportStringCaller( g_FindTextureDialog.m_position_tracker ) );
+ GlobalPreferenceSystem().registerPreference( "FindReplacehWnd", make_property_string<WindowPositionTracker_String>( g_FindTextureDialog.m_position_tracker ) );
}
void FindTextureDialog_Destroy(){
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_FINDTEXTUREDIALOG_H )
#define INCLUDED_FINDTEXTUREDIALOG_H
void FindTextureDialog_Construct();
void FindTextureDialog_Destroy();
-typedef struct _GtkWindow GtkWindow;
-void FindTextureDialog_constructWindow( GtkWindow* main_window );
+void FindTextureDialog_constructWindow( ui::Window main_window );
void FindTextureDialog_destroyWindow();
bool FindTextureDialog_isOpen();
void FindTextureDialog_selectTexture( const char* name );
m_item.update();
setGridPower( m_id );
}
-typedef MemberCaller<GridMenuItem, &GridMenuItem::set> SetCaller;
-void active( const BoolImportCallback& importCallback ){
+typedef MemberCaller<GridMenuItem, void(), &GridMenuItem::set> SetCaller;
+void active( const Callback<void(bool)> &importCallback ){
importCallback( g_grid_power == m_id );
}
-typedef MemberCaller1<GridMenuItem, const BoolImportCallback&, &GridMenuItem::active> ExportCaller;
+typedef MemberCaller<GridMenuItem, void(const Callback<void(bool)>&), &GridMenuItem::active> ExportCaller;
};
GridMenuItem g_gridMenu0125( GRIDPOWER_0125 );
}
void Grid_registerCommands(){
- GlobalCommands_insert( "GridDown", FreeCaller<GridPrev>(), Accelerator( '[' ) );
- GlobalCommands_insert( "GridUp", FreeCaller<GridNext>(), Accelerator( ']' ) );
+ GlobalCommands_insert( "GridDown", makeCallbackF(GridPrev), Accelerator( '[' ) );
+ GlobalCommands_insert( "GridUp", makeCallbackF(GridNext), Accelerator( ']' ) );
- GlobalCommands_insert( "ToggleGridSnap", FreeCaller<ToggleGridSnap>() );
+ GlobalCommands_insert( "ToggleGridSnap", makeCallbackF(ToggleGridSnap) );
GlobalToggles_insert( "SetGrid0.125", GridMenuItem::SetCaller( g_gridMenu0125 ), ToggleItem::AddCallbackCaller( g_gridMenu0125.m_item ) );
GlobalToggles_insert( "SetGrid0.25", GridMenuItem::SetCaller( g_gridMenu025 ), ToggleItem::AddCallbackCaller( g_gridMenu025.m_item ) );
}
-void Grid_constructMenu( GtkMenu* menu ){
+void Grid_constructMenu( ui::Menu menu ){
create_check_menu_item_with_mnemonic( menu, "Grid0.125", "SetGrid0.125" );
create_check_menu_item_with_mnemonic( menu, "Grid0.25", "SetGrid0.25" );
create_check_menu_item_with_mnemonic( menu, "Grid0.5", "SetGrid0.5" );
Grid_constructPreferences( page );
}
void Grid_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Grid_constructPage>() );
+ PreferencesDialog_addSettingsPage( makeCallbackF(Grid_constructPage) );
}
void Grid_construct(){
g_grid_default = GridDefault_forGridPower( GRIDPOWER_8 );
- GlobalPreferenceSystem().registerPreference( "GridDefault", IntImportStringCaller( g_grid_default ), IntExportStringCaller( g_grid_default ) );
+ GlobalPreferenceSystem().registerPreference( "GridDefault", make_property_string( g_grid_default ) );
g_grid_power = GridPower_forGridDefault( g_grid_default );
g_gridsize = GridSize_forGridPower( g_grid_power );
#if !defined( INCLUDED_GRID_H )
#define INCLUDED_GRID_H
+#include <uilib/uilib.h>
#include "signal/signalfwd.h"
float GetSnapGridSize();
void AddGridChangeCallback( const SignalHandler& handler );
void Grid_registerCommands();
-typedef struct _GtkMenu GtkMenu;
-void Grid_constructMenu( GtkMenu* menu );
+void Grid_constructMenu( ui::Menu menu );
void Grid_registerShortcuts();
//
#include "groupdialog.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
#include <vector>
-
-#include <gtk/gtknotebook.h>
-#include <gtk/gtktextview.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtk.h>
#include "gtkutil/widget.h"
#include "gtkutil/accelerator.h"
#include "commands.h"
-#include <gtk/gtkwidget.h>
#include "gtkutil/window.h"
class GroupDlg
{
public:
-GtkWidget* m_pNotebook;
-GtkWindow* m_window;
+ui::Widget m_pNotebook{ui::null};
+ui::Window m_window{ui::null};
GroupDlg();
-void Create( GtkWindow* parent );
+void Create( ui::Window parent );
void Show(){
// workaround for strange gtk behaviour - modifying the contents of a window while it is not visible causes the window position to change without sending a configure_event
m_position_tracker.sync( m_window );
+#define GARUX_GTK_WORKAROUND
+#ifndef GARUX_GTK_WORKAROUND
/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( m_window ), "glwidget" ) );
if ( glwidget ){
gtk_widget_hide( glwidget );
gtk_widget_show( glwidget );
}
- gtk_widget_show( GTK_WIDGET( m_window ) );
+#endif
+ m_window.show();
}
void Hide(){
- gtk_widget_hide( GTK_WIDGET( m_window ) );
+ m_window.hide();
}
WindowPositionTracker m_position_tracker;
GroupDlg g_GroupDlg;
std::size_t g_current_page;
-std::vector<StringExportCallback> g_pages;
+std::vector<Callback<void(const Callback<void(const char *)> &)>> g_pages;
}
-void GroupDialog_updatePageTitle( GtkWindow* window, std::size_t pageIndex ){
+void GroupDialog_updatePageTitle( ui::Window window, std::size_t pageIndex ){
if ( pageIndex < g_pages.size() ) {
- g_pages[pageIndex]( PointerCaller1<GtkWindow, const char*, gtk_window_set_title>( window ) );
+ g_pages[pageIndex]( PointerCaller<GtkWindow, void(const char*), gtk_window_set_title>( window ) );
}
}
-static gboolean switch_page( GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data ){
- GroupDialog_updatePageTitle( GTK_WINDOW( data ), page_num );
+static gboolean switch_page( GtkNotebook *notebook, gpointer page, guint page_num, gpointer data ){
+ GroupDialog_updatePageTitle( ui::Window::from(data), page_num );
g_current_page = page_num;
return FALSE;
}
-GroupDlg::GroupDlg() : m_window( 0 ){
+GroupDlg::GroupDlg() : m_window( ui::null ){
m_position_tracker.setPosition( c_default_window_pos );
}
-void GroupDlg::Create( GtkWindow* parent ){
- ASSERT_MESSAGE( m_window == 0, "dialog already created" );
+void GroupDlg::Create( ui::Window parent ){
+ ASSERT_MESSAGE( !m_window, "dialog already created" );
- GtkWindow* window = create_persistent_floating_window( "Entities", parent );
+ auto window = ui::Window(create_persistent_floating_window( "Entities", parent ));
global_accel_connect_window( window );
m_window = window;
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
if ( g_multimon_globals.m_bStartOnPrimMon ) {
WindowPosition pos( m_position_tracker.getPosition() );
PositionWindowOnPrimaryScreen( pos );
m_position_tracker.connect( window );
{
- GtkWidget* notebook = gtk_notebook_new();
- gtk_widget_show( notebook );
- gtk_container_add( GTK_CONTAINER( window ), notebook );
+ ui::Widget notebook = ui::Widget::from(gtk_notebook_new());
+ notebook.show();
+ window.add(notebook);
gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_BOTTOM );
m_pNotebook = notebook;
- g_signal_connect( G_OBJECT( notebook ), "switch_page", G_CALLBACK( switch_page ), window );
+ notebook.connect( "switch_page", G_CALLBACK( switch_page ), (gpointer) window );
}
}
-GtkWidget* GroupDialog_addPage( const char* tabLabel, GtkWidget* widget, const StringExportCallback& title ){
- GtkWidget* w = gtk_label_new( tabLabel );
- gtk_widget_show( w );
- GtkWidget* page = gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gtk_notebook_insert_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), widget, w, -1 ) );
+ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const Callback<void(const Callback<void(const char *)> &)>& title ){
+ ui::Widget w = ui::Label( tabLabel );
+ w.show();
+ auto page = ui::Widget::from(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gtk_notebook_insert_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), widget, w, -1 ) ));
g_pages.push_back( title );
return page;
bool GroupDialog_isShown(){
- return widget_is_visible( GTK_WIDGET( g_GroupDlg.m_window ) );
+ return g_GroupDlg.m_window.visible();
}
void GroupDialog_setShown( bool shown ){
shown ? g_GroupDlg.Show() : g_GroupDlg.Hide();
GroupDialog_setShown( !GroupDialog_isShown() );
}
-void GroupDialog_constructWindow( GtkWindow* main_window ){
+void GroupDialog_constructWindow( ui::Window main_window ){
g_GroupDlg.Create( main_window );
}
void GroupDialog_destroyWindow(){
- ASSERT_NOTNULL( g_GroupDlg.m_window );
+ ASSERT_TRUE( g_GroupDlg.m_window );
destroy_floating_window( g_GroupDlg.m_window );
- g_GroupDlg.m_window = 0;
+ g_GroupDlg.m_window = ui::Window{ui::null};
}
-GtkWindow* GroupDialog_getWindow(){
- return g_GroupDlg.m_window;
+ui::Window GroupDialog_getWindow(){
+ return ui::Window(g_GroupDlg.m_window);
}
void GroupDialog_show(){
g_GroupDlg.Show();
}
-GtkWidget* GroupDialog_getPage(){
- return gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) );
+ui::Widget GroupDialog_getPage(){
+ return ui::Widget::from(gtk_notebook_get_nth_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) ));
}
-void GroupDialog_setPage( GtkWidget* page ){
+void GroupDialog_setPage( ui::Widget page ){
g_current_page = gtk_notebook_page_num( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), page );
gtk_notebook_set_current_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) );
}
-void GroupDialog_showPage( GtkWidget* page ){
+void GroupDialog_showPage( ui::Widget page ){
if ( GroupDialog_getPage() == page ) {
GroupDialog_ToggleShow();
}
else
{
- gtk_widget_show( GTK_WIDGET( g_GroupDlg.m_window ) );
+ g_GroupDlg.m_window.show();
GroupDialog_setPage( page );
}
}
gtk_notebook_set_current_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) );
}
-void GroupDialog_updatePageTitle( GtkWidget* page ){
+void GroupDialog_updatePageTitle( ui::Widget page ){
if ( GroupDialog_getPage() == page ) {
GroupDialog_updatePageTitle( g_GroupDlg.m_window, g_current_page );
}
#include "preferencesystem.h"
void GroupDialog_Construct(){
- GlobalPreferenceSystem().registerPreference( "EntityWnd", WindowPositionTrackerImportStringCaller( g_GroupDlg.m_position_tracker ), WindowPositionTrackerExportStringCaller( g_GroupDlg.m_position_tracker ) );
+ GlobalPreferenceSystem().registerPreference( "EntityWnd", make_property<WindowPositionTracker_String>( g_GroupDlg.m_position_tracker ) );
- GlobalCommands_insert( "ViewEntityInfo", FreeCaller<GroupDialog_ToggleShow>(), Accelerator( 'N' ) );
+ GlobalCommands_insert( "ViewEntityInfo", makeCallbackF(GroupDialog_ToggleShow), Accelerator( 'N' ) );
}
void GroupDialog_Destroy(){
}
#if !defined( INCLUDED_GROUPDIALOG_H )
#define INCLUDED_GROUPDIALOG_H
+#include <uilib/uilib.h>
+#include "property.h"
#include "generic/callback.h"
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-
void GroupDialog_Construct();
void GroupDialog_Destroy();
-void GroupDialog_constructWindow( GtkWindow* main_window );
+void GroupDialog_constructWindow( ui::Window main_window );
void GroupDialog_destroyWindow();
-GtkWindow* GroupDialog_getWindow();
+ui::Window GroupDialog_getWindow();
void GroupDialog_show();
-inline void RawStringExport( const char* string, const StringImportCallback& importer ){
+inline void RawStringExport( const char* string, const Callback<void(const char *)> &importer ){
importer( string );
}
-typedef ConstPointerCaller1<char, const StringImportCallback&, RawStringExport> RawStringExportCaller;
-GtkWidget* GroupDialog_addPage( const char* tabLabel, GtkWidget* widget, const StringExportCallback& title );
+typedef ConstPointerCaller<char, void(const Callback<void(const char *)> &), RawStringExport> RawStringExportCaller;
+ui::Widget GroupDialog_addPage( const char* tabLabel, ui::Widget widget, const Callback<void(const Callback<void(const char *)> &)>& title );
-void GroupDialog_showPage( GtkWidget* page );
-void GroupDialog_updatePageTitle( GtkWidget* page );
+void GroupDialog_showPage( ui::Widget page );
+void GroupDialog_updatePageTitle( ui::Widget page );
bool GroupDialog_isShown();
-GtkWidget* GroupDialog_getPage();
+ui::Widget GroupDialog_getPage();
#endif
//
#include "gtkdlgs.h"
+#include "globaldefs.h"
+
+#include <gtk/gtk.h>
#include "debugging/debugging.h"
#include "version.h"
#include "iselection.h"
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkcombobox.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktextview.h>
-#include <gtk/gtktextbuffer.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkliststore.h>
+#include <uilib/uilib.h>
#include <gtk/gtkspinbutton.h>
#include "os/path.h"
struct GameCombo
{
- GtkComboBox* game_select;
- GtkEntry* fsgame_entry;
+ ui::ComboBoxText game_select{ui::null};
+ ui::Entry fsgame_entry{ui::null};
};
-gboolean OnSelchangeComboWhatgame( GtkWidget *widget, GameCombo* combo ){
+gboolean OnSelchangeComboWhatgame( ui::Widget widget, GameCombo* combo ){
const char *gamename;
{
GtkTreeIter iter;
gamecombo_t gamecombo = gamecombo_for_gamename( gamename );
- gtk_entry_set_text( combo->fsgame_entry, gamecombo.fs_game );
- gtk_widget_set_sensitive( GTK_WIDGET( combo->fsgame_entry ), gamecombo.sensitive );
+ combo->fsgame_entry.text( gamecombo.fs_game );
+ gtk_widget_set_sensitive( combo->fsgame_entry , gamecombo.sensitive );
return FALSE;
}
{
public:
GameCombo game_combo;
-GtkComboBox* gamemode_combo;
+ui::ComboBox gamemode_combo{ui::null};
};
-GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Project Settings", G_CALLBACK( dialog_delete_callback ), &modal );
+ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){
+ auto window = MainFrame_getWindow().create_dialog_window("Project Settings", G_CALLBACK(dialog_delete_callback ), &modal );
{
- GtkTable* table1 = create_dialog_table( 1, 2, 4, 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( table1 ) );
+ auto table1 = create_dialog_table( 1, 2, 4, 4, 4 );
+ window.add(table1);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_table_attach( table1, GTK_WIDGET( vbox ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ table1.attach(vbox, {1, 2, 0, 1}, {GTK_FILL, GTK_FILL});
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &modal );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &modal );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
}
}
{
- GtkFrame* frame = create_dialog_frame( "Project settings" );
- gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ auto frame = create_dialog_frame( "Project settings" );
+ table1.attach(frame, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
{
- GtkTable* table2 = create_dialog_table( ( globalMappingMode().do_mapping_mode ) ? 4 : 3, 2, 4, 4, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table2 ) );
+ auto table2 = create_dialog_table( ( globalMappingMode().do_mapping_mode ) ? 4 : 3, 2, 4, 4, 4 );
+ frame.add(table2);
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Select mod" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Select mod" );
+ label.show();
+ table2.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
}
{
- dialog.game_combo.game_select = GTK_COMBO_BOX( gtk_combo_box_new_text() );
+ dialog.game_combo.game_select = ui::ComboBoxText(ui::New);
- gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().basegame );
+ gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().basegame );
if ( globalGameComboConfiguration().known[0] != '\0' ) {
- gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().known );
+ gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().known );
}
- gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().custom );
+ gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().custom );
- gtk_widget_show( GTK_WIDGET( dialog.game_combo.game_select ) );
- gtk_table_attach( table2, GTK_WIDGET( dialog.game_combo.game_select ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ dialog.game_combo.game_select.show();
+ table2.attach(dialog.game_combo.game_select, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
- g_signal_connect( G_OBJECT( dialog.game_combo.game_select ), "changed", G_CALLBACK( OnSelchangeComboWhatgame ), &dialog.game_combo );
+ dialog.game_combo.game_select.connect( "changed", G_CALLBACK( OnSelchangeComboWhatgame ), &dialog.game_combo );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "fs_game" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "fs_game" );
+ label.show();
+ table2.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table2, GTK_WIDGET( entry ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table2.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
dialog.game_combo.fsgame_entry = entry;
}
if ( globalMappingMode().do_mapping_mode ) {
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Mapping mode" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 3, 4,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Mapping mode" );
+ label.show();
+ table2.attach(label, {0, 1, 3, 4}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
- GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
- gtk_combo_box_append_text( combo, globalMappingMode().sp_mapping_mode );
- gtk_combo_box_append_text( combo, globalMappingMode().mp_mapping_mode );
+ auto combo = ui::ComboBoxText(ui::New);
+ gtk_combo_box_text_append_text( combo, globalMappingMode().sp_mapping_mode );
+ gtk_combo_box_text_append_text( combo, globalMappingMode().mp_mapping_mode );
- gtk_widget_show( GTK_WIDGET( combo ) );
- gtk_table_attach( table2, GTK_WIDGET( combo ), 1, 2, 3, 4,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ combo.show();
+ table2.attach(combo, {1, 2, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
dialog.gamemode_combo = combo;
}
gamecombo_t gamecombo = gamecombo_for_dir( dir );
gtk_combo_box_set_active( dialog.game_combo.game_select, gamecombo.game );
- gtk_entry_set_text( dialog.game_combo.fsgame_entry, gamecombo.fs_game );
- gtk_widget_set_sensitive( GTK_WIDGET( dialog.game_combo.fsgame_entry ), gamecombo.sensitive );
+ dialog.game_combo.fsgame_entry.text( gamecombo.fs_game );
+ gtk_widget_set_sensitive( dialog.game_combo.fsgame_entry , gamecombo.sensitive );
if ( globalMappingMode().do_mapping_mode ) {
const char *gamemode = gamemode_get();
ModalDialog modal;
ProjectSettingsDialog dialog;
- GtkWindow* window = ProjectSettingsDialog_construct( dialog, modal );
+ ui::Window window = ProjectSettingsDialog_construct( dialog, modal );
if ( modal_dialog_show( window, modal ) == eIDOK ) {
ProjectSettingsDialog_ok( dialog );
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
//}
}
//GtkEntry* sides_entry;
GtkWidget* sides_spin;
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Arbitrary sides", G_CALLBACK( dialog_delete_callback ), &dialog );
+ auto window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog );
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel );
+ auto sides_entry = ui::Entry(ui::New);
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Sides:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( "Sides:" );
+ label.show();
+ hbox.pack_start( label, FALSE, FALSE, 0 );
}
// {
-// GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
-// gtk_widget_show( GTK_WIDGET( entry ) );
-// gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( entry ), FALSE, FALSE, 0 );
-// sides_entry = entry;
-// gtk_widget_grab_focus( GTK_WIDGET( entry ) );
+// auto entry = sides_entry;
+// entry.show();
+// hbox.pack_start( entry, FALSE, FALSE, 0 );
+// gtk_widget_grab_focus( entry );
// }
{
GtkAdjustment* adj;
sides_spin = spin;
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
}
}
Scene_BrushConstructPrefab( GlobalSceneGraph(), (EBrushPrefab)type, sides, TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
}
// =============================================================================
// About dialog (no program is complete without one)
-void about_button_changelog( GtkWidget *widget, gpointer data ){
+void about_button_changelog( ui::Widget widget, gpointer data ){
StringOutputStream log( 256 );
- log << AppPath_get() << "changelog.txt";
+ log << "https://gitlab.com/xonotic/netradiant/commits/master";
OpenURL( log.c_str() );
}
-void about_button_credits( GtkWidget *widget, gpointer data ){
+void about_button_credits( ui::Widget widget, gpointer data ){
+ StringOutputStream cred( 256 );
+ cred << "https://gitlab.com/xonotic/netradiant/graphs/master";
+ OpenURL( cred.c_str() );
+}
+
+void about_button_issues( ui::Widget widget, gpointer data ){
StringOutputStream cred( 256 );
- cred << AppPath_get() << "credits.html";
+ cred << "https://gitlab.com/xonotic/netradiant/issues";
OpenURL( cred.c_str() );
}
ModalDialog dialog;
ModalDialogButton ok_button( dialog, eIDOK );
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "About NetRadiant", dialog );
+ auto window = MainFrame_getWindow().create_modal_dialog_window("About NetRadiant", dialog );
{
- GtkVBox* vbox = create_dialog_vbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) );
+ auto vbox = create_dialog_vbox( 4, 4 );
+ window.add(vbox);
{
- GtkHBox* hbox = create_dialog_hbox( 4 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 );
+ auto hbox = create_dialog_hbox( 4 );
+ vbox.pack_start( hbox, FALSE, TRUE, 0 );
{
- GtkVBox* vbox2 = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), TRUE, FALSE, 0 );
+ auto vbox2 = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox2, TRUE, FALSE, 0 );
{
- //GtkFrame* frame = create_dialog_frame( 0, GTK_SHADOW_IN );
- //gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), FALSE, FALSE, 0 );
+ auto frame = create_dialog_frame( 0, ui::Shadow::IN );
+ vbox2.pack_start( frame, FALSE, FALSE, 0 );
{
- GtkImage* image = new_local_image( "logo.png" );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( image ), FALSE, FALSE, 0 );
- //gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( image ) );
+ auto image = new_local_image( "logo.png" );
+ image.show();
+ frame.add(image);
}
}
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "NetRadiant " RADIANT_VERSION "\n"
- __DATE__ "\n\n"
- RADIANT_ABOUTMSG "\n\n"
- "By alientrap.org\n\n"
- "This program is free software\n"
- "licensed under the GNU GPL.\n"
- ) );
-
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ char const *label_text = "NetRadiant " RADIANT_VERSION "\n"
+ __DATE__ "\n\n"
+ RADIANT_ABOUTMSG "\n\n"
+ "This program is free software\n"
+ "licensed under the GNU GPL.\n\n"
+ "NetRadiant is unsupported, however\n"
+ "you may report your problems at\n"
+ "https://gitlab.com/xonotic/netradiant/issues";
+
+ auto label = ui::Label( label_text );
+
+ label.show();
+ hbox.pack_start( label, FALSE, FALSE, 0 );
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
gtk_label_set_justify( label, GTK_JUSTIFY_LEFT );
}
{
- GtkVBox* vbox2 = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), FALSE, TRUE, 0 );
+ auto vbox2 = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox2, FALSE, TRUE, 0 );
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox2.pack_start( button, FALSE, FALSE, 0 );
}
{
- GtkButton* button = create_dialog_button( "Credits", G_CALLBACK( about_button_credits ), 0 );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Credits", G_CALLBACK( about_button_credits ), 0 );
+ vbox2.pack_start( button, FALSE, FALSE, 0 );
gtk_widget_set_sensitive( GTK_WIDGET( button ), FALSE);
}
{
- GtkButton* button = create_dialog_button( "Changelog", G_CALLBACK( about_button_changelog ), 0 );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Changes", G_CALLBACK( about_button_changelog ), 0 );
+ vbox2.pack_start( button, FALSE, FALSE, 0 );
+ }
+ {
+ auto button = create_dialog_button( "Issues", G_CALLBACK( about_button_issues ), 0 );
+ vbox2.pack_start( button, FALSE, FALSE, 0 );
gtk_widget_set_sensitive( GTK_WIDGET( button ), FALSE);
}
}
}
{
- GtkFrame* frame = create_dialog_frame( "OpenGL Properties" );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 );
+ auto frame = create_dialog_frame( "OpenGL Properties" );
+ vbox.pack_start( frame, FALSE, FALSE, 0 );
{
- GtkTable* table = create_dialog_table( 3, 2, 4, 4, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table ) );
+ auto table = create_dialog_table( 3, 2, 4, 4, 4 );
+ frame.add(table);
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Vendor:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Vendor:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Version:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Version:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Renderer:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Renderer:" );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast<const char*>( glGetString( GL_VENDOR ) ) ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( reinterpret_cast<const char*>( glGetString( GL_VENDOR ) ) );
+ label.show();
+ table.attach(label, {1, 2, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast<const char*>( glGetString( GL_VERSION ) ) ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( reinterpret_cast<const char*>( glGetString( GL_VERSION ) ) );
+ label.show();
+ table.attach(label, {1, 2, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast<const char*>( glGetString( GL_RENDERER ) ) ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( reinterpret_cast<const char*>( glGetString( GL_RENDERER ) ) );
+ label.show();
+ table.attach(label, {1, 2, 2, 3}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
}
{
- GtkFrame* frame = create_dialog_frame( "OpenGL Extensions" );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+ auto frame = create_dialog_frame( "OpenGL Extensions" );
+ vbox.pack_start( frame, TRUE, TRUE, 0 );
{
- GtkScrolledWindow* sc_extensions = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( sc_extensions ) );
+ auto sc_extensions = create_scrolled_window( ui::Policy::AUTOMATIC, ui::Policy::ALWAYS, 4 );
+ frame.add(sc_extensions);
{
- GtkWidget* text_extensions = gtk_text_view_new();
- gtk_text_view_set_editable( GTK_TEXT_VIEW( text_extensions ), FALSE );
- gtk_container_add( GTK_CONTAINER( sc_extensions ), text_extensions );
- GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_extensions ) );
- gtk_text_buffer_set_text( buffer, reinterpret_cast<const char*>( glGetString( GL_EXTENSIONS ) ), -1 );
- gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text_extensions ), GTK_WRAP_WORD );
- gtk_widget_show( text_extensions );
+ auto text_extensions = ui::TextView(ui::New);
+ gtk_text_view_set_editable( text_extensions, FALSE );
+ sc_extensions.add(text_extensions);
+ text_extensions.text(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
+ gtk_text_view_set_wrap_mode( text_extensions, GTK_WRAP_WORD );
+ text_extensions.show();
}
}
}
modal_dialog_show( window, dialog );
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
}
// =============================================================================
ModalDialog dialog;
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
- GtkEntry* x;
- GtkEntry* y;
+ ui::Entry x{ui::null};
+ ui::Entry y{ui::null};
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Patch texture layout", dialog );
+ auto window = MainFrame_getWindow().create_modal_dialog_window("Patch texture layout", dialog );
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture will be fit across the patch based\n"
+ auto label = ui::Label( "Texture will be fit across the patch based\n"
"on the x and y values given. Values of 1x1\n"
"will \"fit\" the texture. 2x2 will repeat\n"
- "it twice, etc." ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), TRUE, TRUE, 0 );
+ "it twice, etc." );
+ label.show();
+ vbox.pack_start( label, TRUE, TRUE, 0 );
gtk_label_set_justify( label, GTK_JUSTIFY_LEFT );
}
{
- GtkTable* table = create_dialog_table( 2, 2, 4, 4 );
- gtk_widget_show( GTK_WIDGET( table ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = create_dialog_table( 2, 2, 4, 4 );
+ table.show();
+ vbox.pack_start( table, TRUE, TRUE, 0 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture x:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Texture x:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture y:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Texture y:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
x = entry;
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
y = entry;
}
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_modal_dialog_button( "Cancel", cancel_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
}
}
char buf[16];
sprintf( buf, "%f", last_used_texture_layout_scale_x );
- gtk_entry_set_text( x, buf );
+ x.text( buf );
sprintf( buf, "%f", last_used_texture_layout_scale_y );
- gtk_entry_set_text( y, buf );
+ y.text( buf );
// Set focus after intializing the values
- gtk_widget_grab_focus( GTK_WIDGET( x ) );
+ gtk_widget_grab_focus( x );
EMessageBoxReturn ret = modal_dialog_show( window, dialog );
if ( ret == eIDOK ) {
last_used_texture_layout_scale_y = *fy;
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
return ret;
}
// Text Editor dialog
// master window widget
-static GtkWidget *text_editor = 0;
-static GtkWidget *text_widget; // slave, text widget from the gtk editor
+static ui::Window text_editor{ui::null};
+static ui::Widget text_widget{ui::null}; // slave, text widget from the gtk editor
static GtkTextBuffer* text_buffer_;
-static gint editor_delete( GtkWidget *widget, gpointer data ){
-/* if ( gtk_MessageBox( widget, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) {
+static gint editor_delete( ui::Widget widget, gpointer data ){
+/* if ( ui::alert( widget.window(), "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
return TRUE;
}
*/
- gtk_widget_hide( text_editor );
+ text_editor.hide();
return TRUE;
}
-static void editor_save( GtkWidget *widget, gpointer data ){
+static void editor_save( ui::Widget widget, gpointer data ){
FILE *f = fopen( (char*)g_object_get_data( G_OBJECT( data ), "filename" ), "w" );
//gpointer text = g_object_get_data( G_OBJECT( data ), "text" );
if ( f == 0 ) {
- gtk_MessageBox( GTK_WIDGET( data ), "Error saving file !" );
+ ui::alert( ui::Widget::from(data).window(), "Error saving file !" );
return;
}
g_free (str);
}
-static void editor_close( GtkWidget *widget, gpointer data ){
-/* if ( gtk_MessageBox( text_editor, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) {
+static void editor_close( ui::Widget widget, gpointer data ){
+/* if ( ui::alert( text_editor.window(), "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
return;
}
*/
- gtk_widget_hide( text_editor );
+ text_editor.hide();
}
static void CreateGtkTextEditor(){
- GtkWidget *dlg;
- GtkWidget *vbox, *hbox, *button, *scr, *text;
+ auto dlg = ui::Window( ui::window_type::TOP );
- GtkWindow* dlg_wnd = create_dialog_window( MainFrame_getWindow(), "", G_CALLBACK( editor_delete ), 0, 400, 600 );
- dlg = GTK_WIDGET( dlg_wnd );
+ dlg.connect( "", G_CALLBACK( editor_delete ), 0 );
+ gtk_window_set_default_size( dlg, 400, 600 );
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( vbox ) );
+ auto vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
+ dlg.add(vbox);
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- scr = gtk_scrolled_window_new( 0, 0 );
- gtk_widget_show( scr );
- gtk_box_pack_start( GTK_BOX( vbox ), scr, TRUE, TRUE, 0 );
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
+ vbox.pack_start( scr, TRUE, TRUE, 0 );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
- text = gtk_text_view_new();
- gtk_container_add( GTK_CONTAINER( scr ), text );
- gtk_widget_show( text );
- g_object_set_data( G_OBJECT( dlg ), "text", text );
- gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), TRUE );
+ auto text = ui::TextView(ui::New);
+ scr.add(text);
+ text.show();
+ g_object_set_data( G_OBJECT( dlg ), "text", (gpointer) text );
+ gtk_text_view_set_editable( text, TRUE );
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 );
+ auto hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox.pack_start( hbox, FALSE, TRUE, 0 );
- button = gtk_button_new_with_label( "Close" );
- gtk_widget_show( button );
- gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ auto button = ui::Button( "Close" );
+ button.show();
+ hbox.pack_end(button, FALSE, FALSE, 0);
+ button.connect( "clicked",
G_CALLBACK( editor_close ), dlg );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
- button = gtk_button_new_with_label( "Save" );
- gtk_widget_show( button );
- gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ button = ui::Button( "Save" );
+ button.show();
+ hbox.pack_end(button, FALSE, FALSE, 0);
+ button.connect( "clicked",
G_CALLBACK( editor_save ), dlg );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
text_editor = dlg;
text_widget = text;
if ( f == 0 ) {
globalOutputStream() << "Unable to load file " << filename << " in shader editor.\n";
- gtk_widget_hide( text_editor );
+ text_editor.hide();
}
else
{
rewind( f );
fread( buf, 1, len, f );
- gtk_window_set_title( GTK_WINDOW( text_editor ), filename );
+ gtk_window_set_title( text_editor, filename );
- GtkTextBuffer* text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_widget ) );
+ auto text_buffer = gtk_text_view_get_buffer(ui::TextView::from(text_widget));
gtk_text_buffer_set_text( text_buffer, (char*)buf, length );
old_filename = g_object_get_data( G_OBJECT( text_editor ), "filename" );
g_object_set_data( G_OBJECT( text_editor ), "filename", strdup( filename ) );
// trying to show later
- gtk_widget_show( text_editor );
+ text_editor.show();
gtk_window_present( GTK_WINDOW( text_editor ) );
-#ifdef WIN32
- process_gui();
+#if GDEF_OS_WINDOWS
+ ui::process();
#endif
// only move the cursor if it's not exceeding the size..
gtk_text_view_scroll_to_iter( GTK_TEXT_VIEW( text_widget ), &text_iter, 0, TRUE, 0, 0);
}
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
gtk_widget_queue_draw( text_widget );
#endif
EMessageBoxReturn DoLightIntensityDlg( int *intensity ){
ModalDialog dialog;
- GtkEntry* intensity_entry;
+ ui::Entry intensity_entry{ui::null};
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Light intensity", dialog, -1, -1 );
+ ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Light intensity", dialog, -1, -1 );
- GtkAccelGroup *accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel_group );
+ auto accel_group = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel_group );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "ESC for default, ENTER to validate" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( "ESC for default, ENTER to validate" );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ vbox.pack_start( entry, TRUE, TRUE, 0 );
- gtk_widget_grab_focus( GTK_WIDGET( entry ) );
+ gtk_widget_grab_focus( entry );
intensity_entry = entry;
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
{
- GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "Cancel", cancel_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
}
}
char buf[16];
sprintf( buf, "%d", *intensity );
- gtk_entry_set_text( intensity_entry, buf );
+ intensity_entry.text(buf);
EMessageBoxReturn ret = modal_dialog_show( window, dialog );
if ( ret == eIDOK ) {
*intensity = atoi( gtk_entry_get_text( intensity_entry ) );
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
return ret;
}
// =============================================================================
// Add new shader tag dialog
-EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){
+EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){
ModalDialog dialog;
- GtkEntry* textentry;
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), title, dialog, -1, -1 );
+ auto window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 );
- GtkAccelGroup *accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel_group );
+ auto accel_group = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel_group );
+ auto textentry = ui::Entry(ui::New);
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
//GtkLabel* label = GTK_LABEL(gtk_label_new("Enter one ore more tags separated by spaces"));
- GtkLabel* label = GTK_LABEL( gtk_label_new( "ESC to cancel, ENTER to validate" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( "ESC to cancel, ENTER to validate" );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
-
- gtk_widget_grab_focus( GTK_WIDGET( entry ) );
+ auto entry = textentry;
+ entry.show();
+ vbox.pack_start( entry, TRUE, TRUE, 0 );
- textentry = entry;
+ gtk_widget_grab_focus( entry );
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
{
- GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "Cancel", cancel_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
}
}
*tag = gtk_entry_get_text( textentry );
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
return ret;
}
-EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* title ){
+EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const char* title ){
ModalDialog dialog;
ModalDialogButton ok_button( dialog, eIDOK );
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), title, dialog, -1, -1 );
+ auto window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 );
- GtkAccelGroup *accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel_group );
+ auto accel_group = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel_group );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "The selected shader" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( "The selected shader" );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( name ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( name );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "is located in file" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( "is located in file" );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( filename ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( filename );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
}
}
EMessageBoxReturn ret = modal_dialog_show( window, dialog );
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
return ret;
}
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <gdk/gdkwin32.h>
#endif
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
// use the file associations to open files instead of builtin Gtk editor
bool g_TextEditor_useWin32Editor = false;
#else
#endif
void DoTextEditor( const char* filename, int cursorpos, int length ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
if ( g_TextEditor_useWin32Editor ) {
StringOutputStream path( 256 );
StringOutputStream modpath( 256 );
modpath << enginePath << gamename << '/' << filename;
if ( file_exists( modpath.c_str() ) ){
globalOutputStream() << "opening file '" << modpath.c_str() << "' (line " << cursorpos << " info ignored)\n";
- ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", modpath.c_str(), 0, 0, SW_SHOW );
+ ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "open", modpath.c_str(), 0, 0, SW_SHOW );
}
else if ( file_exists( path.c_str() ) ){
globalOutputStream() << "opening file '" << path.c_str() << "' (line " << cursorpos << " info ignored)\n";
- ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", path.c_str(), 0, 0, SW_SHOW );
+ ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "open", path.c_str(), 0, 0, SW_SHOW );
}
else{
globalOutputStream() << "Failed to open '" << filename << "'\nOne sits in .pk3 most likely!\n";
#if !defined( INCLUDED_GTKDLGS_H )
#define INCLUDED_GTKDLGS_H
+#include "globaldefs.h"
#include "qerplugin.h"
#include "string/string.h"
EMessageBoxReturn DoLightIntensityDlg( int *intensity );
-EMessageBoxReturn DoShaderTagDlg( CopiedString *tag, char* title );
-EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* title );
+EMessageBoxReturn DoShaderTagDlg( CopiedString *tag, const char* title );
+EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const char* title );
EMessageBoxReturn DoTextureLayout( float *fx, float *fy );
void DoTextEditor( const char* filename, int cursorpos, int length );
void DoAbout();
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
extern bool g_TextEditor_useWin32Editor;
#else
#include "string/stringfwd.h"
// Small functions to help with GTK
//
+#include <gtk/gtk.h>
#include "gtkmisc.h"
-#include <gtk/gtkcolorseldialog.h>
-#include <gtk/gtkentry.h>
+#include "uilib/uilib.h"
#include "math/vector.h"
#include "os/path.h"
#include "gtkutil/dialog.h"
#include "gtkutil/filechooser.h"
#include "gtkutil/menu.h"
-#include "gtkutil/toolbar.h"
#include "commands.h"
global_accel_group_disconnect( toggle.m_command.m_accelerator, toggle.m_command.m_callback );
}
-GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const char* commandName ){
+ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const char* commandName ){
GlobalShortcuts_register( commandName, 2 );
const Toggle& toggle = GlobalToggles_find( commandName );
global_accel_group_connect( toggle.m_command.m_accelerator, toggle.m_command.m_callback );
return create_check_menu_item_with_mnemonic( menu, mnemonic, toggle );
}
-GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu* menu, const char *mnemonic, const char* commandName ){
+ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const char* commandName ){
GlobalShortcuts_register( commandName, 1 );
const Command& command = GlobalCommands_find( commandName );
global_accel_group_connect( command.m_accelerator, command.m_callback );
return create_menu_item_with_mnemonic( menu, mnemonic, command );
}
-GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ){
+ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const char* commandName ){
return toolbar_append_button( toolbar, description, icon, GlobalCommands_find( commandName ) );
}
-GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName ){
+ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const char* commandName ){
return toolbar_append_toggle_button( toolbar, description, icon, GlobalToggles_find( commandName ) );
}
// =============================================================================
// File dialog
-bool color_dialog( GtkWidget *parent, Vector3& color, const char* title ){
- GtkWidget* dlg;
- double clr[3];
+bool color_dialog( ui::Window parent, Vector3& color, const char* title ){
+ GdkColor clr = { 0, guint16(color[0] * 65535), guint16(color[1] * 65535), guint16(color[2] * 65535) };
ModalDialog dialog;
- clr[0] = color[0];
- clr[1] = color[1];
- clr[2] = color[2];
+ auto dlg = ui::Window::from(gtk_color_selection_dialog_new( title ));
+ gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG( dlg )) ), &clr );
+ dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog );
+ GtkWidget *ok_button, *cancel_button;
+ g_object_get(G_OBJECT(dlg), "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr);
+ ui::Widget::from(ok_button).connect( "clicked", G_CALLBACK( dialog_button_ok ), &dialog );
+ ui::Widget::from(cancel_button).connect( "clicked", G_CALLBACK( dialog_button_cancel ), &dialog );
- dlg = gtk_color_selection_dialog_new( title );
- gtk_color_selection_set_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), clr );
- g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog );
- g_signal_connect( G_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->ok_button ), "clicked", G_CALLBACK( dialog_button_ok ), &dialog );
- g_signal_connect( G_OBJECT( GTK_COLOR_SELECTION_DIALOG( dlg )->cancel_button ), "clicked", G_CALLBACK( dialog_button_cancel ), &dialog );
-
- if ( parent != 0 ) {
- gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( parent ) );
+ if ( parent ) {
+ gtk_window_set_transient_for( dlg, parent );
}
- bool ok = modal_dialog_show( GTK_WINDOW( dlg ), dialog ) == eIDOK;
+ bool ok = modal_dialog_show( dlg, dialog ) == eIDOK;
if ( ok ) {
- GdkColor gdkcolor;
- gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( GTK_COLOR_SELECTION_DIALOG( dlg )->colorsel ), &gdkcolor );
- clr[0] = gdkcolor.red / 65535.0;
- clr[1] = gdkcolor.green / 65535.0;
- clr[2] = gdkcolor.blue / 65535.0;
-
- color[0] = (float)clr[0];
- color[1] = (float)clr[1];
- color[2] = (float)clr[2];
+ gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG( dlg )) ), &clr );
+ color[0] = clr.red / 65535.0f;
+ color[1] = clr.green / 65535.0f;
+ color[2] = clr.blue / 65535.0f;
}
- gtk_widget_destroy( dlg );
+ dlg.destroy();
return ok;
}
-void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry ){
- const char *filename = file_dialog( gtk_widget_get_toplevel( widget ), TRUE, "Choose File", gtk_entry_get_text( entry ) );
+void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry ){
+ const char *filename = widget.file_dialog( TRUE, "Choose File", gtk_entry_get_text( entry ) );
if ( filename != 0 ) {
- gtk_entry_set_text( entry, filename );
+ entry.text(filename);
}
}
-void button_clicked_entry_browse_directory( GtkWidget* widget, GtkEntry* entry ){
+void button_clicked_entry_browse_directory( ui::Widget widget, ui::Entry entry ){
const char* text = gtk_entry_get_text( entry );
- char *dir = dir_dialog( gtk_widget_get_toplevel( widget ), "Choose Directory", path_is_absolute( text ) ? text : "" );
+ char *dir = dir_dialog( widget.window(), "Choose Directory", path_is_absolute( text ) ? text : "" );
if ( dir != 0 ) {
gchar* converted = g_filename_to_utf8( dir, -1, 0, 0, 0 );
- gtk_entry_set_text( entry, converted );
+ entry.text(converted);
g_free( dir );
g_free( converted );
}
#if !defined( INCLUDED_GTKMISC_H )
#define INCLUDED_GTKMISC_H
-#include <gtk/gtkmain.h>
-
-inline void process_gui(){
- while ( gtk_events_pending() )
- {
- gtk_main_iteration();
- }
-}
+#include <uilib/uilib.h>
+#include "gtkutil/toolbar.h"
void command_connect_accelerator( const char* commandName );
void command_disconnect_accelerator( const char* commandName );
void toggle_add_accelerator( const char* commandName );
void toggle_remove_accelerator( const char* name );
-typedef struct _GtkMenu GtkMenu;
-typedef struct _GtkMenuItem GtkMenuItem;
-typedef struct _GtkCheckMenuItem GtkCheckMenuItem;
-
// this also sets up the shortcut using command_connect_accelerator
-GtkMenuItem* create_menu_item_with_mnemonic( GtkMenu *menu, const char *mnemonic, const char* commandName );
+ui::MenuItem create_menu_item_with_mnemonic( ui::Menu menu, const char *mnemonic, const char* commandName );
// this also sets up the shortcut using command_connect_accelerator
-GtkCheckMenuItem* create_check_menu_item_with_mnemonic( GtkMenu* menu, const char* mnemonic, const char* commandName );
+ui::CheckMenuItem create_check_menu_item_with_mnemonic( ui::Menu menu, const char* mnemonic, const char* commandName );
-typedef struct _GtkButton GtkButton;
-typedef struct _GtkToggleButton GtkToggleButton;
-typedef struct _GtkToolbar GtkToolbar;
// this DOES NOT set up the shortcut using command_connect_accelerator
-GtkButton* toolbar_append_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName );
+ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const char* commandName );
// this DOES NOT set up the shortcut using command_connect_accelerator
-GtkToggleButton* toolbar_append_toggle_button( GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName );
+ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const char* description, const char* icon, const char* commandName );
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
-bool color_dialog( GtkWidget *parent, Vector3& color, const char* title = "Choose Color" );
+bool color_dialog( ui::Window parent, Vector3& color, const char* title = "Choose Color" );
-typedef struct _GtkEntry GtkEntry;
-void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry );
-void button_clicked_entry_browse_directory( GtkWidget* widget, GtkEntry* entry );
+void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry );
+void button_clicked_entry_browse_directory( ui::Widget widget, ui::Entry entry );
#endif
email : ashaduri '@' gmail.com
***************************************************************************/
+#define GARUX_DISABLE_GTKTHEME
+#ifndef GARUX_DISABLE_GTKTHEME
#include <iostream>
#include <fstream>
}
+
+#endif // GARUX_DISABLE_GTKTHEME
email : ashaduri '@' gmail.com
***************************************************************************/
+#define GARUX_DISABLE_GTKTHEME
+#ifndef GARUX_DISABLE_GTKTHEME
+
#ifndef _GTKTHEME_H_
#define _GTKTHEME_H_
void gtkThemeDlg();
#endif
+
+#endif // GARUX_DISABLE_GTKTHEME
OpenURL( str.c_str() );
}
-void process_xlink( const char* filename, const char *menu_name, const char *base_url, GtkMenu *menu ){
+void process_xlink( const char* filename, const char *menu_name, const char *base_url, ui::Menu menu ){
if ( file_exists( filename ) ) {
xmlDocPtr pDoc = xmlParseFile( filename );
if ( pDoc ) {
globalOutputStream() << "Processing .xlink file '" << filename << "'\n";
// create sub menu
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, menu_name );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, menu_name );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
xmlChar* prop = xmlGetProp( pNode, reinterpret_cast<const xmlChar*>( "url" ) );
ASSERT_NOTNULL( prop );
- if ( strstr( reinterpret_cast<const char*>( prop ), "http://" ) ) {
+ if ( strstr( reinterpret_cast<const char*>( prop ), "http://" ) ||
+ strstr( reinterpret_cast<const char*>( prop ), "https://" ) ) {
// complete URL
url = reinterpret_cast<const char*>( prop );
}
prop = xmlGetProp( pNode, reinterpret_cast<const xmlChar*>( "name" ) );
ASSERT_NOTNULL( prop );
- create_menu_item_with_mnemonic( menu_in_menu, reinterpret_cast<const char*>( prop ), ReferenceCaller<CopiedString, HandleHelpCommand>( mHelpURLs.back() ) );
+ create_menu_item_with_mnemonic( menu_in_menu, reinterpret_cast<const char*>( prop ), ReferenceCaller<CopiedString, void(), HandleHelpCommand>( mHelpURLs.back() ) );
xmlFree( prop );
}
pNode = pNode->next;
}
}
-void create_game_help_menu( GtkMenu *menu ){
+void create_game_help_menu( ui::Menu menu ){
StringOutputStream filename( 256 );
filename << AppPath_get() << "global.xlink";
process_xlink( filename.c_str(), "General", AppPath_get(), menu );
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_HELP_H )
#define INCLUDED_HELP_H
-typedef struct _GtkMenu GtkMenu;
-void create_game_help_menu( GtkMenu *menu );
+void create_game_help_menu( ui::Menu menu );
#endif
\link math/plane.h math/plane.h \endlink - Planes \n
\link math/aabb.h math/aabb.h \endlink - AABBs \n
- Callback MemberCaller FunctionCaller - callbacks similar to using boost::function with boost::bind \n
+ Callback MemberCaller0 FunctionCaller - callbacks similar to using boost::function with boost::bind \n
SmartPointer SmartReference - smart-pointer and smart-reference similar to Loki's SmartPtr \n
\link generic/bitfield.h generic/bitfield.h \endlink - Type-safe bitfield \n
*/
#include "main.h"
+#include "globaldefs.h"
#include "version.h"
#include "iundo.h"
-#include <gtk/gtkmain.h>
+#include "uilib/uilib.h"
#include "cmdlib.h"
#include "os/file.h"
#include "referencecache.h"
#include "stacktrace.h"
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <windows.h>
#endif
// spam it...
globalErrorStream() << buf << "\n";
- // FIXME why are warnings is_fatal?
-#ifndef _DEBUG
- if ( is_fatal )
-#endif
- ERROR_MESSAGE( "GTK+ error: " << buf );
+ if (is_fatal) {
+ ERROR_MESSAGE( "GTK+ error: " << buf );
+ }
}
-#if defined ( _DEBUG ) && defined ( WIN32 ) && defined ( _MSC_VER )
+#if GDEF_COMPILER_MSVC && GDEF_DEBUG
#include "crtdbg.h"
#endif
void crt_init(){
-#if defined ( _DEBUG ) && defined ( WIN32 ) && defined ( _MSC_VER )
+#if GDEF_COMPILER_MSVC && GDEF_DEBUG
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
}
globalErrorStream() << m_buffer.c_str();
if ( !m_lock.locked() ) {
ScopedLock lock( m_lock );
-#if defined _DEBUG
- m_buffer << "Break into the debugger?\n";
- bool handled = gtk_MessageBox( 0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_YESNO, eMB_ICONERROR ) == eIDNO;
- m_buffer.clear();
- return handled;
-#else
- m_buffer << "Please report this error to the developers\n";
- gtk_MessageBox( 0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_OK, eMB_ICONERROR );
- m_buffer.clear();
-#endif
+ if (GDEF_DEBUG) {
+ m_buffer << "Break into the debugger?\n";
+ bool handled = ui::alert(ui::root, m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error) == ui::alert_response::NO;
+ m_buffer.clear();
+ return handled;
+ } else {
+ m_buffer << "Please report this error to the developers\n";
+ ui::alert(ui::root, m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::OK, ui::alert_icon::Error);
+ m_buffer.clear();
+ }
}
return true;
}
}
void paths_init(){
- const char* home = environment_get_home_path();
- Q_mkdir( home );
-
- {
- StringOutputStream path( 256 );
- path << home << "1." << RADIANT_MAJOR_VERSION "." << RADIANT_MINOR_VERSION << '/';
- g_strSettingsPath = path.c_str();
- }
+ g_strSettingsPath = environment_get_home_path();
Q_mkdir( g_strSettingsPath.c_str() );
// make something idiot proof and someone will make better idiots, this may be overkill
// let's leave it disabled in debug mode in any case
// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=431
-#ifndef _DEBUG
-#define CHECK_VERSION
-#endif
-#ifdef CHECK_VERSION
- // locate and open RADIANT_MAJOR and RADIANT_MINOR
- bool bVerIsGood = true;
- {
- StringOutputStream ver_file_name( 256 );
- ver_file_name << AppPath_get() << "RADIANT_MAJOR";
- bVerIsGood = check_version_file( ver_file_name.c_str(), RADIANT_MAJOR_VERSION );
- }
- {
- StringOutputStream ver_file_name( 256 );
- ver_file_name << AppPath_get() << "RADIANT_MINOR";
- bVerIsGood = check_version_file( ver_file_name.c_str(), RADIANT_MINOR_VERSION );
- }
-
- if ( !bVerIsGood ) {
- StringOutputStream msg( 256 );
- msg << "This editor binary (" RADIANT_VERSION ") doesn't match what the latest setup has configured in this directory\n"
- "Make sure you run the right/latest editor binary you installed\n"
- << AppPath_get();
- gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONDEFAULT );
- }
- return bVerIsGood;
-#else
- return true;
-#endif
+ if (GDEF_DEBUG) {
+ return true;
+ }
+ // locate and open RADIANT_MAJOR and RADIANT_MINOR
+ bool bVerIsGood = true;
+ {
+ StringOutputStream ver_file_name(256);
+ ver_file_name << AppPath_get() << "RADIANT_MAJOR";
+ bVerIsGood = check_version_file(ver_file_name.c_str(), RADIANT_MAJOR_VERSION);
+ }
+ {
+ StringOutputStream ver_file_name(256);
+ ver_file_name << AppPath_get() << "RADIANT_MINOR";
+ bVerIsGood = check_version_file(ver_file_name.c_str(), RADIANT_MINOR_VERSION);
+ }
+
+ if (!bVerIsGood) {
+ StringOutputStream msg(256);
+ msg
+ << "This editor binary (" RADIANT_VERSION ") doesn't match what the latest setup has configured in this directory\n"
+ "Make sure you run the right/latest editor binary you installed\n"
+ << AppPath_get();
+ ui::alert(ui::root, msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Default);
+ }
+ return bVerIsGood;
}
void create_global_pid(){
if ( remove( g_pidFile.c_str() ) == -1 ) {
StringOutputStream msg( 256 );
msg << "WARNING: Could not delete " << g_pidFile.c_str();
- gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR );
+ ui::alert( ui::root, msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
}
// in debug, never prompt to clean registry, turn console logging auto after a failed start
-#if !defined( _DEBUG )
- StringOutputStream msg( 256 );
- msg << "Radiant failed to start properly the last time it was run.\n"
- "The failure may be related to current global preferences.\n"
- "Do you want to reset global preferences to defaults?";
-
- if ( gtk_MessageBox( 0, msg.c_str(), "Radiant - Startup Failure", eMB_YESNO, eMB_ICONQUESTION ) == eIDYES ) {
- g_GamesDialog.Reset();
- }
+ if (!GDEF_DEBUG) {
+ StringOutputStream msg(256);
+ msg << "Radiant failed to start properly the last time it was run.\n"
+ "The failure may be related to current global preferences.\n"
+ "Do you want to reset global preferences to defaults?";
+
+ if (ui::alert(ui::root, msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question) == ui::alert_response::YES) {
+ g_GamesDialog.Reset();
+ }
- msg.clear();
- msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again.";
+ msg.clear();
+ msg << "Logging console output to " << SettingsPath_get()
+ << "radiant.log\nRefer to the log if Radiant fails to start again.";
- gtk_MessageBox( 0, msg.c_str(), "Radiant - Console Log", eMB_OK );
-#endif
+ ui::alert(ui::root, msg.c_str(), "Radiant - Console Log", ui::alert_type::OK);
+ }
// set without saving, the class is not in a coherent state yet
// just do the value change and call to start logging, CGamesDialog will pickup when relevant
if ( remove( g_pidFile.c_str() ) == -1 ) {
StringOutputStream msg( 256 );
msg << "WARNING: Could not delete " << g_pidFile.c_str();
- gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR );
+ ui::alert( ui::root, msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
}
}
if ( remove( g_pidGameFile.c_str() ) == -1 ) {
StringOutputStream msg;
msg << "WARNING: Could not delete " << g_pidGameFile.c_str();
- gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONERROR );
+ ui::alert( ui::root, msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
}
// in debug, never prompt to clean registry, turn console logging auto after a failed start
-#if !defined( _DEBUG )
- StringOutputStream msg;
- msg << "Radiant failed to start properly the last time it was run.\n"
- "The failure may be caused by current preferences.\n"
- "Do you want to reset all preferences to defaults?";
-
- if ( gtk_MessageBox( 0, msg.c_str(), "Radiant - Startup Failure", eMB_YESNO, eMB_ICONQUESTION ) == eIDYES ) {
- Preferences_Reset();
- }
+ if (!GDEF_DEBUG) {
+ StringOutputStream msg;
+ msg << "Radiant failed to start properly the last time it was run.\n"
+ "The failure may be caused by current preferences.\n"
+ "Do you want to reset all preferences to defaults?";
- msg.clear();
- msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again.";
+ if (ui::alert(ui::root, msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question) == ui::alert_response::YES) {
+ Preferences_Reset();
+ }
- gtk_MessageBox( 0, msg.c_str(), "Radiant - Console Log", eMB_OK );
-#endif
+ msg.clear();
+ msg << "Logging console output to " << SettingsPath_get()
+ << "radiant.log\nRefer to the log if Radiant fails to start again.";
+
+ ui::alert(ui::root, msg.c_str(), "Radiant - Console Log", ui::alert_type::OK);
+ }
// force console logging on! (will go in prefs too)
g_GamesDialog.m_bForceLogConsole = true;
}
void add_local_rc_files(){
+#define GARUX_DISABLE_GTKTHEME
+#ifndef GARUX_DISABLE_GTKTHEME
+/* FIXME: HACK: not GTK3 compatible
+ https://developer.gnome.org/gtk2/stable/gtk2-Resource-Files.html#gtk-rc-add-default-file
+ https://developer.gnome.org/gtk3/stable/gtk3-Resource-Files.html#gtk-rc-add-default-file
+ > gtk_rc_add_default_file has been deprecated since version 3.0 and should not be used in newly-written code.
+ > Use GtkStyleContext with a custom GtkStyleProvider instead
+*/
+
{
StringOutputStream path( 512 );
path << AppPath_get() << ".gtkrc-2.0.radiant";
gtk_rc_add_default_file( path.c_str() );
}
#endif
+#endif // GARUX_DISABLE_GTKTHEME
}
int main( int argc, char* argv[] ){
streams_init();
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
HMODULE lib;
lib = LoadLibrary( "dwmapi.dll" );
if ( lib != 0 ) {
_setmaxstdio(2048);
#endif
- gtk_disable_setlocale();
+ const char* mapname = NULL;
+ char const *error = NULL;
+ if ( !ui::init( &argc, &argv, "<filename.map>", &error) ) {
+ g_print( "%s\n", error );
+ return -1;
+ }
- gtk_init( &argc, &argv );
+ // Gtk already removed parsed `--options`
+ if (argc == 2) {
+ if ( strlen( argv[1] ) > 1 ) {
+ if ( g_str_has_suffix( argv[1], ".map" ) ) {
+ if ( g_path_is_absolute( argv[1] ) ) {
+ mapname = argv[1];
+ }
+ else {
+ mapname = g_build_filename( g_get_current_dir(), argv[1], NULL );
+ }
+ }
+ else {
+ g_print( "bad file name, will not load: %s\n", argv[1] );
+ }
+ }
+ }
+ else if (argc > 2) {
+ g_print ( "%s\n", "too many arguments" );
+ return -1;
+ }
// redirect Gtk warnings to the console
g_log_set_handler( "Gdk", (GLogLevelFlags)( G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING |
GlobalDebugMessageHandler::instance().setHandler( GlobalPopupDebugMessageHandler::instance() );
- environment_init( argc, argv );
+ environment_init(argc, (char const **) argv);
paths_init();
Radiant_Initialise();
- global_accel_init();
-
user_shortcuts_init();
g_pParentWnd = 0;
if( openCmdMap && *openCmdMap ){
Map_LoadFile( openCmdMap );
}
+ else if ( mapname != NULL ) {
+ Map_LoadFile( mapname );
+ }
else if ( g_bLoadLastMap && !g_strLastMap.empty() ) {
Map_LoadFile( g_strLastMap.c_str() );
}
remove_local_pid();
- gtk_main();
+ ui::main();
// avoid saving prefs when the app is minimized
if ( g_pParentWnd->IsSleeping() ) {
user_shortcuts_save();
- global_accel_destroy();
-
Radiant_Shutdown();
// close the log file if any
//
#include "mainframe.h"
+#include "globaldefs.h"
-#include "debugging/debugging.h"
-#include "version.h"
+#include <gtk/gtk.h>
#include "ifilesystem.h"
#include "iundo.h"
-#include "ifilter.h"
-#include "itoolbar.h"
#include "editable.h"
#include "ientity.h"
#include "ishaders.h"
#include <ctime>
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkhpaned.h>
-#include <gtk/gtkvpaned.h>
-#include <gtk/gtktoolbar.h>
-#include <gtk/gtkmenubar.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtktable.h>
#include "cmdlib.h"
-#include "scenelib.h"
#include "stream/stringstream.h"
#include "signal/isignal.h"
#include "os/path.h"
#include "moduleobservers.h"
#include "gtkutil/clipboard.h"
-#include "gtkutil/container.h"
#include "gtkutil/frame.h"
-#include "gtkutil/glfont.h"
#include "gtkutil/glwidget.h"
#include "gtkutil/image.h"
#include "gtkutil/menu.h"
#include "gtkutil/paned.h"
-#include "gtkutil/widget.h"
#include "autosave.h"
#include "build.h"
#include "pluginmanager.h"
#include "pluginmenu.h"
#include "plugintoolbar.h"
-#include "points.h"
#include "preferences.h"
#include "qe3.h"
#include "qgl.h"
#include "renderstate.h"
#include "feedback.h"
#include "referencecache.h"
-
+#include "texwindow.h"
#include "filterbar.h"
+
+#define GARUX_DISABLE_GTKTHEME
+#ifndef GARUX_DISABLE_GTKTHEME
#include "gtktheme.h"
+#endif
struct layout_globals_t
// VFS
+
+bool g_vfsInitialized = false;
+
+void VFS_Init(){
+ if ( g_vfsInitialized ) return;
+ QE_InitVFS();
+ GlobalFileSystem().initialise();
+ g_vfsInitialized = true;
+}
+
+void VFS_Shutdown(){
+ if ( !g_vfsInitialized ) return;
+ GlobalFileSystem().shutdown();
+ g_vfsInitialized = false;
+}
+
+void VFS_Refresh(){
+ if ( !g_vfsInitialized ) return;
+ GlobalFileSystem().clear();
+ QE_InitVFS();
+ GlobalFileSystem().refresh();
+ g_vfsInitialized = true;
+ // also refresh models
+ RefreshReferences();
+ // also refresh texture browser
+ TextureBrowser_RefreshShaders();
+}
+
+void VFS_Restart(){
+ VFS_Shutdown();
+ VFS_Init();
+}
+
class VFSModuleObserver : public ModuleObserver
{
-std::size_t m_unrealised;
public:
-VFSModuleObserver() : m_unrealised( 1 ){
-}
void realise(){
- if ( --m_unrealised == 0 ) {
- QE_InitVFS();
- GlobalFileSystem().initialise();
+ VFS_Init();
}
-}
+
void unrealise(){
- if ( ++m_unrealised == 1 ) {
- GlobalFileSystem().shutdown();
- }
+ VFS_Shutdown();
}
};
void VFS_Construct(){
Radiant_attachHomePathsObserver( g_VFSModuleObserver );
}
+
void VFS_Destroy(){
Radiant_detachHomePathsObserver( g_VFSModuleObserver );
}
// Home Paths
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <shlobj.h>
#include <objbase.h>
const GUID qFOLDERID_SavedGames = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D, 0x72, 0xE5, 0x4E, 0xAA, 0xA4}};
typedef HRESULT ( WINAPI qSHGetKnownFolderPath_t )( qREFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath );
static qSHGetKnownFolderPath_t *qSHGetKnownFolderPath;
#endif
+
void HomePaths_Realise(){
do
{
if ( !string_empty( prefix ) ) {
StringOutputStream path( 256 );
-#if defined( __APPLE__ )
+#if GDEF_OS_MACOS
path.clear();
path << DirectoryCleaned( g_get_home_dir() ) << "Library/Application Support" << ( prefix + 1 ) << "/";
if ( file_is_directory( path.c_str() ) ) {
g_qeglobals.m_userEnginePath = path.c_str();
break;
}
+ path.clear();
+ path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/";
#endif
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
TCHAR mydocsdir[MAX_PATH + 1];
wchar_t *mydocsdirw;
HMODULE shfolder = LoadLibrary( "shfolder.dll" );
}
#endif
-#if defined( POSIX )
+#if GDEF_OS_POSIX
path.clear();
path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/";
g_qeglobals.m_userEnginePath = path.c_str();
public:
HomePathsModuleObserver() : m_unrealised( 1 ){
}
+
void realise(){
if ( --m_unrealised == 0 ) {
HomePaths_Realise();
g_homePathObservers.realise();
}
}
+
void unrealise(){
if ( ++m_unrealised == 1 ) {
g_homePathObservers.unrealise();
void HomePaths_Construct(){
Radiant_attachEnginePathObserver( g_HomePathsModuleObserver );
}
+
void HomePaths_Destroy(){
Radiant_detachEnginePathObserver( g_HomePathsModuleObserver );
}
}
}
+// Pak Path
+
+CopiedString g_strPakPath[g_pakPathCount] = { "", "", "", "", "" };
+ModuleObservers g_pakPathObservers[g_pakPathCount];
+std::size_t g_pakpath_unrealised[g_pakPathCount] = { 1, 1, 1, 1, 1 };
+
+void Radiant_attachPakPathObserver( int num, ModuleObserver& observer ){
+ g_pakPathObservers[num].attach( observer );
+}
+
+void Radiant_detachPakPathObserver( int num, ModuleObserver& observer ){
+ g_pakPathObservers[num].detach( observer );
+}
+
+
+void PakPath_Realise( int num ){
+ if ( --g_pakpath_unrealised[num] == 0 ) {
+ g_pakPathObservers[num].realise();
+ }
+}
+
+const char* PakPath_get( int num ){
+ std::string message = "PakPath_get: pak path " + std::to_string(num) + " not realised";
+ ASSERT_MESSAGE( g_pakpath_unrealised[num] == 0, message.c_str() );
+ return g_strPakPath[num].c_str();
+}
+
+void PakPath_Unrealise( int num ){
+ if ( ++g_pakpath_unrealised[num] == 1 ) {
+ g_pakPathObservers[num].unrealise();
+ }
+}
+
+void setPakPath( int num, const char* path ){
+ if (!g_strcmp0( path, "")) {
+ g_strPakPath[num] = "";
+ return;
+ }
+
+ StringOutputStream buffer( 256 );
+ buffer << DirectoryCleaned( path );
+ if ( !path_equal( buffer.c_str(), g_strPakPath[num].c_str() ) ) {
+ std::string message = "Changing Pak Path " + std::to_string(num);
+ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", message.c_str() );
+
+ PakPath_Unrealise(num);
+
+ g_strPakPath[num] = buffer.c_str();
+
+ PakPath_Realise(num);
+ }
+}
+
// App Path
/// directory for temp files
/// NOTE: on *nix this is were we check for .pid
CopiedString g_strSettingsPath;
+
const char* SettingsPath_get(){
return g_strSettingsPath.c_str();
}
return g_strGameToolsPath.c_str();
}
-void EnginePathImport( CopiedString& self, const char* value ){
+struct EnginePath {
+ static void Export(const CopiedString &self, const Callback<void(const char *)> &returnz) {
+ returnz(self.c_str());
+ }
+
+ static void Import(CopiedString &self, const char *value) {
setEnginePath( value );
}
-typedef ReferenceCaller1<CopiedString, const char*, EnginePathImport> EnginePathImportCaller;
+};
+
+struct PakPath0 {
+ static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
+ returnz( self.c_str() );
+ }
+
+ static void Import( CopiedString &self, const char *value ) {
+ setPakPath( 0, value );
+ }
+};
+
+struct PakPath1 {
+ static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
+ returnz( self.c_str() );
+ }
+
+ static void Import( CopiedString &self, const char *value ) {
+ setPakPath( 1, value );
+ }
+};
+
+struct PakPath2 {
+ static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
+ returnz( self.c_str() );
+ }
+
+ static void Import( CopiedString &self, const char *value ) {
+ setPakPath( 2, value );
+ }
+};
+
+struct PakPath3 {
+ static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
+ returnz( self.c_str() );
+ }
+
+ static void Import( CopiedString &self, const char *value ) {
+ setPakPath( 3, value );
+ }
+};
+
+struct PakPath4 {
+ static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
+ returnz( self.c_str() );
+ }
+
+ static void Import( CopiedString &self, const char *value ) {
+ setPakPath( 4, value );
+ }
+};
+
+bool g_disableEnginePath = false;
+bool g_disableHomePath = false;
void Paths_constructPreferences( PreferencesPage& page ){
- page.appendPathEntry( "Engine Path", true,
- StringImportCallback( EnginePathImportCaller( g_strEnginePath ) ),
- StringExportCallback( StringExportCaller( g_strEnginePath ) )
+ page.appendPathEntry( "Engine Path", true, make_property<EnginePath>(g_strEnginePath) );
+
+ page.appendCheckBox(
+ "", "Do not use Engine Path",
+ g_disableEnginePath
);
+
+ page.appendCheckBox(
+ "", "Do not use Home Path",
+ g_disableHomePath
+ );
+
+ for ( int i = 0; i < g_pakPathCount; i++ ) {
+ std::string label = "Pak Path " + std::to_string(i);
+ switch (i) {
+ case 0:
+ page.appendPathEntry( label.c_str(), true, make_property<PakPath0>( g_strPakPath[i] ) );
+ break;
+ case 1:
+ page.appendPathEntry( label.c_str(), true, make_property<PakPath1>( g_strPakPath[i] ) );
+ break;
+ case 2:
+ page.appendPathEntry( label.c_str(), true, make_property<PakPath2>( g_strPakPath[i] ) );
+ break;
+ case 3:
+ page.appendPathEntry( label.c_str(), true, make_property<PakPath3>( g_strPakPath[i] ) );
+ break;
+ case 4:
+ page.appendPathEntry( label.c_str(), true, make_property<PakPath4>( g_strPakPath[i] ) );
+ break;
+}
+ }
}
+
void Paths_constructPage( PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Paths", "Path Settings" ) );
Paths_constructPreferences( page );
}
+
void Paths_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Paths_constructPage>() );
+ PreferencesDialog_addSettingsPage( makeCallbackF(Paths_constructPage) );
}
class PathsDialog : public Dialog
{
public:
-GtkWindow* BuildDialog(){
- GtkFrame* frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN );
+ui::Window BuildDialog(){
+ auto frame = create_dialog_frame( "Path settings", ui::Shadow::ETCHED_IN );
- GtkVBox* vbox2 = create_dialog_vbox( 0, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
+ auto vbox2 = create_dialog_vbox( 0, 4 );
+ frame.add(vbox2);
{
- PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) );
+ PreferencesPage preferencesPage( *this, vbox2 );
Paths_constructPreferences( preferencesPage );
}
- return create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, GTK_WIDGET( frame ) );
+ return ui::Window(create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, frame ));
}
};
}
}
-#include "os/dir.h"
-class CLoadModule
-{
-const char* m_path;
-public:
-CLoadModule( const char* path ) : m_path( path ){
-}
-void operator()( const char* name ) const {
- char fullname[1024];
- ASSERT_MESSAGE( strlen( m_path ) + strlen( name ) < 1024, "" );
- strcpy( fullname, m_path );
- strcat( fullname, name );
- globalOutputStream() << "Found '" << fullname << "'\n";
- GlobalModuleServer_loadModule( fullname );
-}
-};
+#include "os/dir.h"
const char* const c_library_extension =
-#if defined( WIN32 )
+#if defined( CMAKE_SHARED_MODULE_SUFFIX )
+ CMAKE_SHARED_MODULE_SUFFIX
+#elif GDEF_OS_WINDOWS
"dll"
-#elif defined ( __APPLE__ )
+#elif GDEF_OS_MACOS
"dylib"
-#elif defined( __linux__ ) || defined ( __FreeBSD__ )
+#elif GDEF_OS_LINUX || GDEF_OS_BSD
"so"
#endif
;
void Radiant_loadModules( const char* path ){
- Directory_forEach( path, MatchFileExtension<CLoadModule>( c_library_extension, CLoadModule( path ) ) );
+ Directory_forEach(path, matchFileExtension(c_library_extension, [&](const char *name) {
+ char fullname[1024];
+ ASSERT_MESSAGE(strlen(path) + strlen(name) < 1024, "");
+ strcpy(fullname, path);
+ strcat(fullname, name);
+ globalOutputStream() << "Found '" << fullname << "'\n";
+ GlobalModuleServer_loadModule(fullname);
+ }));
}
void Radiant_loadModulesFromRoot( const char* directory ){
public:
WorldspawnColourEntityClassObserver() : m_unrealised( 1 ){
}
+
void realise(){
if ( --m_unrealised == 0 ) {
SetWorldspawnColour( g_xywindow_globals.color_brushes );
}
}
+
void unrealise(){
if ( ++m_unrealised == 1 ) {
}
XY_UpdateAllWindows();
}
-typedef Callback1<Vector3&> GetColourCallback;
-typedef Callback1<const Vector3&> SetColourCallback;
+typedef Callback<void(Vector3&)> GetColourCallback;
+typedef Callback<void(const Vector3&)> SetColourCallback;
class ChooseColour
{
ChooseColour( const GetColourCallback& get, const SetColourCallback& set )
: m_get( get ), m_set( set ){
}
+
void operator()(){
Vector3 colour;
m_get( colour );
- color_dialog( GTK_WIDGET( MainFrame_getWindow() ), colour );
+ color_dialog( MainFrame_getWindow(), colour );
m_set( colour );
}
};
-
void Colour_get( const Vector3& colour, Vector3& other ){
other = colour;
}
-typedef ConstReferenceCaller1<Vector3, Vector3&, Colour_get> ColourGetCaller;
+
+typedef ConstReferenceCaller<Vector3, void(Vector3&), Colour_get> ColourGetCaller;
void Colour_set( Vector3& colour, const Vector3& other ){
colour = other;
SceneChangeNotify();
}
-typedef ReferenceCaller1<Vector3, const Vector3&, Colour_set> ColourSetCaller;
+
+typedef ReferenceCaller<Vector3, void(const Vector3&), Colour_set> ColourSetCaller;
void BrushColour_set( const Vector3& other ){
g_xywindow_globals.color_brushes = other;
SetWorldspawnColour( g_xywindow_globals.color_brushes );
SceneChangeNotify();
}
-typedef FreeCaller1<const Vector3&, BrushColour_set> BrushColourSetCaller;
+
+typedef FreeCaller<void(const Vector3&), BrushColour_set> BrushColourSetCaller;
void ClipperColour_set( const Vector3& other ){
g_xywindow_globals.color_clipper = other;
Brush_clipperColourChanged();
SceneChangeNotify();
}
-typedef FreeCaller1<const Vector3&, ClipperColour_set> ClipperColourSetCaller;
+
+typedef FreeCaller<void(const Vector3&), ClipperColour_set> ClipperColourSetCaller;
void TextureBrowserColour_get( Vector3& other ){
other = TextureBrowser_getBackgroundColour( GlobalTextureBrowser() );
}
-typedef FreeCaller1<Vector3&, TextureBrowserColour_get> TextureBrowserColourGetCaller;
+
+typedef FreeCaller<void(Vector3&), TextureBrowserColour_get> TextureBrowserColourGetCaller;
void TextureBrowserColour_set( const Vector3& other ){
TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), other );
}
-typedef FreeCaller1<const Vector3&, TextureBrowserColour_set> TextureBrowserColourSetCaller;
+
+typedef FreeCaller<void(const Vector3&), TextureBrowserColour_set> TextureBrowserColourSetCaller;
class ColoursMenu
ColoursMenu g_ColoursMenu;
-GtkMenuItem* create_colours_menu(){
- GtkMenuItem* colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" );
- GtkMenu* menu_in_menu = GTK_MENU( gtk_menu_item_get_submenu( colours_menu_item ) );
+ui::MenuItem create_colours_menu(){
+ auto colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" );
+ auto menu_in_menu = ui::Menu::from( gtk_menu_item_get_submenu( colours_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
- GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Themes" );
+ auto menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Themes" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_3 );
}
create_menu_item_with_mnemonic( menu_3, "Black and Green", "ColorSchemeBlackAndGreen" );
create_menu_item_with_mnemonic( menu_3, "Maya/Max/Lightwave Emulation", "ColorSchemeYdnar" );
+#ifndef GARUX_DISABLE_GTKTHEME
create_menu_item_with_mnemonic( menu_in_menu, "GTK Theme...", "gtkThemeDlg" );
+#endif
menu_separator( menu_in_menu );
g_pParentWnd->OnSleep();
}
-void OpenUpdateURL(){
- // build the URL
- StringOutputStream URL( 256 );
- URL << "http://www.icculus.org/netradiant/?cmd=update&data=dlupdate&query_dlup=1";
-#ifdef WIN32
- URL << "&OS_dlup=1";
-#elif defined( __APPLE__ )
- URL << "&OS_dlup=2";
-#else
- URL << "&OS_dlup=3";
-#endif
- URL << "&Version_dlup=" RADIANT_VERSION;
- g_GamesDialog.AddPacksURL( URL );
- OpenURL( URL.c_str() );
-}
-
-// open the Q3Rad manual
void OpenHelpURL(){
- // at least on win32, AppPath + "docs/index.html"
- StringOutputStream help( 256 );
- help << AppPath_get() << "docs/index.html";
- OpenURL( help.c_str() );
+ OpenURL( "https://gitlab.com/xonotic/xonotic/wikis/Mapping" );
}
void OpenBugReportURL(){
- OpenURL( "http://www.icculus.org/netradiant/?cmd=bugs" );
+ OpenURL( "https://gitlab.com/xonotic/netradiant/issues" );
}
-GtkWidget* g_page_console;
+ui::Widget g_page_console{ui::null};
void Console_ToggleShow(){
GroupDialog_showPage( g_page_console );
}
-GtkWidget* g_page_entity;
+ui::Widget g_page_entity{ui::null};
void EntityInspector_ToggleShow(){
GroupDialog_showPage( g_page_entity );
}
-
void SetClipMode( bool enable );
+
void ModeChangeNotify();
typedef void ( *ToolMode )();
+
ToolMode g_currentToolMode = 0;
bool g_currentToolModeSupportsComponentEditing = false;
ToolMode g_defaultToolMode = 0;
-
void SelectionSystem_DefaultMode(){
GlobalSelectionSystem().SetMode( SelectionSystem::ePrimitive );
GlobalSelectionSystem().SetComponentMode( SelectionSystem::eDefault );
class BoolFunctionExport
{
public:
-static void apply( const BoolImportCallback& importCallback ){
+static void apply( const Callback<void(bool)> & importCallback ){
importCallback( BoolFunction() );
}
};
-typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
EdgeModeApplyCaller g_edgeMode_button_caller;
-BoolExportCallback g_edgeMode_button_callback( g_edgeMode_button_caller );
+Callback<void(const Callback<void(bool)> &)> g_edgeMode_button_callback( g_edgeMode_button_caller );
ToggleItem g_edgeMode_button( g_edgeMode_button_callback );
-typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
VertexModeApplyCaller g_vertexMode_button_caller;
-BoolExportCallback g_vertexMode_button_callback( g_vertexMode_button_caller );
+Callback<void(const Callback<void(bool)> &)> g_vertexMode_button_callback( g_vertexMode_button_caller );
ToggleItem g_vertexMode_button( g_vertexMode_button_callback );
-typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
FaceModeApplyCaller g_faceMode_button_caller;
-BoolExportCallback g_faceMode_button_callback( g_faceMode_button_caller );
+Callback<void(const Callback<void(bool)> &)> g_faceMode_button_callback( g_faceMode_button_caller );
ToggleItem g_faceMode_button( g_faceMode_button_callback );
void ComponentModeChanged(){
public:
CloneSelected( bool d ) : doMakeUnique( d ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.size() == 1 ) {
return true;
return true;
}
+
void post( const scene::Path& path, scene::Instance& instance ) const {
if ( path.size() == 1 ) {
return;
Vector3 x;
Vector3 y;
Vector3 z;
+
AxisBase( const Vector3& x_, const Vector3& y_, const Vector3& z_ )
: x( x_ ), y( y_ ), z( z_ ){
}
}
-void TranslateToolExport( const BoolImportCallback& importCallback ){
+void TranslateToolExport( const Callback<void(bool)> & importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eTranslate );
}
-void RotateToolExport( const BoolImportCallback& importCallback ){
+void RotateToolExport( const Callback<void(bool)> & importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eRotate );
}
-void ScaleToolExport( const BoolImportCallback& importCallback ){
+void ScaleToolExport( const Callback<void(bool)> & importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eScale );
}
-void DragToolExport( const BoolImportCallback& importCallback ){
+void DragToolExport( const Callback<void(bool)> & importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eDrag );
}
-void ClipperToolExport( const BoolImportCallback& importCallback ){
+void ClipperToolExport( const Callback<void(bool)> & importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eClip );
}
-FreeCaller1<const BoolImportCallback&, TranslateToolExport> g_translatemode_button_caller;
-BoolExportCallback g_translatemode_button_callback( g_translatemode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), TranslateToolExport> g_translatemode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_translatemode_button_callback( g_translatemode_button_caller );
ToggleItem g_translatemode_button( g_translatemode_button_callback );
-FreeCaller1<const BoolImportCallback&, RotateToolExport> g_rotatemode_button_caller;
-BoolExportCallback g_rotatemode_button_callback( g_rotatemode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), RotateToolExport> g_rotatemode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_rotatemode_button_callback( g_rotatemode_button_caller );
ToggleItem g_rotatemode_button( g_rotatemode_button_callback );
-FreeCaller1<const BoolImportCallback&, ScaleToolExport> g_scalemode_button_caller;
-BoolExportCallback g_scalemode_button_callback( g_scalemode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), ScaleToolExport> g_scalemode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_scalemode_button_callback( g_scalemode_button_caller );
ToggleItem g_scalemode_button( g_scalemode_button_callback );
-FreeCaller1<const BoolImportCallback&, DragToolExport> g_dragmode_button_caller;
-BoolExportCallback g_dragmode_button_callback( g_dragmode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), DragToolExport> g_dragmode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_dragmode_button_callback( g_dragmode_button_caller );
ToggleItem g_dragmode_button( g_dragmode_button_callback );
-FreeCaller1<const BoolImportCallback&, ClipperToolExport> g_clipper_button_caller;
-BoolExportCallback g_clipper_button_callback( g_clipper_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), ClipperToolExport> g_clipper_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_clipper_button_callback( g_clipper_button_caller );
ToggleItem g_clipper_button( g_clipper_button_callback );
void ToolChanged(){
SnappableSnapToGridSelected( float snap )
: m_snap( snap ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Snappable* snappable = Node_getSnappable( path.top() );
ComponentSnappableSnapToGridSelected( float snap )
: m_snap( snap ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
ComponentSnappable* componentSnappable = Instance_getComponentSnappable( instance );
void EverySecondTimer_enable(){
if ( s_qe_every_second_id == 0 ) {
- s_qe_every_second_id = gtk_timeout_add( 1000, qe_every_second, 0 );
+ s_qe_every_second_id = g_timeout_add( 1000, qe_every_second, 0 );
}
}
void EverySecondTimer_disable(){
if ( s_qe_every_second_id != 0 ) {
- gtk_timeout_remove( s_qe_every_second_id );
+ g_source_remove( s_qe_every_second_id );
s_qe_every_second_id = 0;
}
}
-gint window_realize_remove_decoration( GtkWidget* widget, gpointer data ){
- gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) );
+gint window_realize_remove_decoration( ui::Widget widget, gpointer data ){
+ gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) );
return FALSE;
}
class WaitDialog
{
public:
-GtkWindow* m_window;
-GtkLabel* m_label;
+ui::Window m_window{ui::null};
+ui::Label m_label{ui::null};
};
WaitDialog create_wait_dialog( const char* title, const char* text ){
WaitDialog dialog;
- dialog.m_window = create_floating_window( title, MainFrame_getWindow() );
+ dialog.m_window = MainFrame_getWindow().create_floating_window(title);
gtk_window_set_resizable( dialog.m_window, FALSE );
gtk_container_set_border_width( GTK_CONTAINER( dialog.m_window ), 0 );
gtk_window_set_position( dialog.m_window, GTK_WIN_POS_CENTER_ON_PARENT );
- g_signal_connect( G_OBJECT( dialog.m_window ), "realize", G_CALLBACK( window_realize_remove_decoration ), 0 );
+ dialog.m_window.connect( "realize", G_CALLBACK( window_realize_remove_decoration ), 0 );
{
- dialog.m_label = GTK_LABEL( gtk_label_new( text ) );
+ dialog.m_label = ui::Label( text );
gtk_misc_set_alignment( GTK_MISC( dialog.m_label ), 0.0, 0.5 );
gtk_label_set_justify( dialog.m_label, GTK_JUSTIFY_LEFT );
- gtk_widget_show( GTK_WIDGET( dialog.m_label ) );
- gtk_widget_set_size_request( GTK_WIDGET( dialog.m_label ), 200, -1 );
+ dialog.m_label.show();
+ dialog.m_label.dimensions(200, -1);
- gtk_container_add( GTK_CONTAINER( dialog.m_window ), GTK_WIDGET( dialog.m_label ) );
+ dialog.m_window.add(dialog.m_label);
}
return dialog;
}
for ( GList* i = list; i != 0; i = g_list_next( i ) )
{
//globalOutputStream() << "toplevel.. ";
- if ( gtk_window_is_active( GTK_WINDOW( i->data ) ) ) {
+ if ( gtk_window_is_active( ui::Window::from( i->data ) ) ) {
//globalOutputStream() << "is active\n";
return true;
}
}
void ScreenUpdates_process(){
- if ( redrawRequired() && GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
- process_gui();
+ if ( redrawRequired() && g_wait.m_window.visible() ) {
+ ui::process();
}
}
if ( g_wait_stack.empty() ) {
EverySecondTimer_disable();
- process_gui();
+ ui::process();
bool isActiveApp = MainFrame_isActiveApp();
g_wait = create_wait_dialog( title, message );
- gtk_grab_add( GTK_WIDGET( g_wait.m_window ) );
+ gtk_grab_add( g_wait.m_window );
if ( isActiveApp ) {
- gtk_widget_show( GTK_WIDGET( g_wait.m_window ) );
+ g_wait.m_window.show();
ScreenUpdates_process();
}
}
- else if ( GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
- gtk_label_set_text( g_wait.m_label, message );
+ else if ( g_wait.m_window.visible() ) {
+ g_wait.m_label.text(message);
ScreenUpdates_process();
}
g_wait_stack.push_back( message );
g_wait_stack.pop_back();
if ( g_wait_stack.empty() ) {
EverySecondTimer_enable();
- //gtk_widget_set_sensitive(GTK_WIDGET(MainFrame_getWindow()), TRUE);
+ //gtk_widget_set_sensitive(MainFrame_getWindow(), TRUE);
- gtk_grab_remove( GTK_WIDGET( g_wait.m_window ) );
+ gtk_grab_remove( g_wait.m_window );
destroy_floating_window( g_wait.m_window );
- g_wait.m_window = 0;
+ g_wait.m_window = ui::Window{ui::null};
//gtk_window_present(MainFrame_getWindow());
}
- else if ( GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
- gtk_label_set_text( g_wait.m_label, g_wait_stack.back().c_str() );
+ else if ( g_wait.m_window.visible() ) {
+ g_wait.m_label.text(g_wait_stack.back().c_str());
ScreenUpdates_process();
}
}
-
void GlobalCamera_UpdateWindow(){
if ( g_pParentWnd != 0 ) {
CamWnd_Update( *g_pParentWnd->GetCamWnd() );
}
-LatchedInt g_Layout_viewStyle( 0, "Window Layout" );
-LatchedBool g_Layout_enableDetachableMenus( true, "Detachable Menus" );
-LatchedBool g_Layout_enableMainToolbar( true, "Main Toolbar" );
-LatchedBool g_Layout_enablePatchToolbar( true, "Patch Toolbar" );
-LatchedBool g_Layout_enablePluginToolbar( true, "Plugin Toolbar" );
-LatchedBool g_Layout_enableFilterToolbar( true, "Filter Toolbar" );
-
+LatchedValue<int> g_Layout_viewStyle( 0, "Window Layout" );
+LatchedValue<bool> g_Layout_enableDetachableMenus( true, "Detachable Menus" );
+LatchedValue<bool> g_Layout_enableMainToolbar( true, "Main Toolbar" );
+LatchedValue<bool> g_Layout_enablePatchToolbar( true, "Patch Toolbar" );
+LatchedValue<bool> g_Layout_enablePluginToolbar( true, "Plugin Toolbar" );
+LatchedValue<bool> g_Layout_enableFilterToolbar( true, "Filter Toolbar" );
-GtkMenuItem* create_file_menu(){
+ui::MenuItem create_file_menu(){
// File menu
- GtkMenuItem* file_menu_item = new_sub_menu_item_with_mnemonic( "_File" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( file_menu_item ) );
+ auto file_menu_item = new_sub_menu_item_with_mnemonic( "_File" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( file_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
menu_separator( menu );
create_menu_item_with_mnemonic( menu, "_Save", "SaveMap" );
create_menu_item_with_mnemonic( menu, "Save _as...", "SaveMapAs" );
- create_menu_item_with_mnemonic( menu, "Save s_elected...", "SaveSelected" );
+ create_menu_item_with_mnemonic( menu, "_Export selected...", "ExportSelected" );
create_menu_item_with_mnemonic( menu, "Save re_gion...", "SaveRegion" );
menu_separator( menu );
// menu_separator( menu );
return file_menu_item;
}
-GtkMenuItem* create_edit_menu(){
+ui::MenuItem create_edit_menu(){
// Edit menu
- GtkMenuItem* edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( edit_menu_item ) );
+ auto edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( edit_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
menu_separator( menu );
-// GtkMenu* convert_menu = create_sub_menu_with_mnemonic( menu, "E_xpand Selection" );
+// auto convert_menu = create_sub_menu_with_mnemonic( menu, "E_xpand Selection" );
// if ( g_Layout_enableDetachableMenus.m_value ) {
// menu_tearoff( convert_menu );
// }
}
-GtkWidget* g_toggle_z_item = 0;
-GtkWidget* g_toggle_console_item = 0;
-GtkWidget* g_toggle_entity_item = 0;
-GtkWidget* g_toggle_entitylist_item = 0;
+ui::Widget g_toggle_z_item{ui::null};
+ui::Widget g_toggle_console_item{ui::null};
+ui::Widget g_toggle_entity_item{ui::null};
+ui::Widget g_toggle_entitylist_item{ui::null};
-GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
+ui::MenuItem create_view_menu( MainFrame::EViewStyle style ){
// View menu
- GtkMenuItem* view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( view_menu_item ) );
+ auto view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( view_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
menu_separator( menu );
{
- GtkMenu* camera_menu = create_sub_menu_with_mnemonic( menu, "Camera" );
+ auto camera_menu = create_sub_menu_with_mnemonic( menu, "Camera" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( camera_menu );
}
}
menu_separator( menu );
{
- GtkMenu* orthographic_menu = create_sub_menu_with_mnemonic( menu, "Orthographic" );
+ auto orthographic_menu = create_sub_menu_with_mnemonic( menu, "Orthographic" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( orthographic_menu );
}
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Show" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Show" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
}
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Filter" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Filter" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
}
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Region" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Region" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
return view_menu_item;
}
-GtkMenuItem* create_selection_menu(){
+ui::MenuItem create_selection_menu(){
// Selection menu
- GtkMenuItem* selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( selection_menu_item ) );
+ auto selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( selection_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Components" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Components" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Nudge" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Nudge" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
create_menu_item_with_mnemonic( menu_in_menu, "Nudge -Z", "MoveSelectionDOWN" );
}
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
create_menu_item_with_mnemonic( menu_in_menu, "Rotate Anticlockwise", "RotateSelectionAnticlockwise" );
}
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Flip" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Flip" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
return selection_menu_item;
}
-GtkMenuItem* create_bsp_menu(){
+ui::MenuItem create_bsp_menu(){
// BSP menu
- GtkMenuItem* bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( bsp_menu_item ) );
+ auto bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( bsp_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
return bsp_menu_item;
}
-GtkMenuItem* create_grid_menu(){
+ui::MenuItem create_grid_menu(){
// Grid menu
- GtkMenuItem* grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( grid_menu_item ) );
+ auto grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( grid_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
return grid_menu_item;
}
-GtkMenuItem* create_misc_menu(){
+ui::MenuItem create_misc_menu(){
// Misc menu
- GtkMenuItem* misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( misc_menu_item ) );
+ auto misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( misc_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
#if 0
- create_menu_item_with_mnemonic( menu, "_Benchmark", FreeCaller<GlobalCamera_Benchmark>() );
+ create_menu_item_with_mnemonic( menu, "_Benchmark", makeCallbackF(GlobalCamera_Benchmark) );
#endif
- gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( create_colours_menu() ) );
+ menu.add(create_colours_menu());
create_menu_item_with_mnemonic( menu, "Find brush...", "FindBrush" );
create_menu_item_with_mnemonic( menu, "Map Info...", "MapInfo" );
// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394
-// create_menu_item_with_mnemonic(menu, "_Print XY View", FreeCaller<WXY_Print>());
- create_menu_item_with_mnemonic( menu, "_Background image...", FreeCaller<WXY_BackgroundSelect>() );
+// create_menu_item_with_mnemonic(menu, "_Print XY View", makeCallbackF( WXY_Print ));
+ create_menu_item_with_mnemonic( menu, "_Background image...", makeCallbackF(WXY_BackgroundSelect) );
create_menu_item_with_mnemonic( menu, "Fullscreen", "Fullscreen" );
create_menu_item_with_mnemonic( menu, "Maximize view", "MaximizeView" );
return misc_menu_item;
}
-GtkMenuItem* create_entity_menu(){
+ui::MenuItem create_entity_menu(){
// Brush menu
- GtkMenuItem* entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( entity_menu_item ) );
+ auto entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( entity_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
return entity_menu_item;
}
-GtkMenuItem* create_brush_menu(){
+ui::MenuItem create_brush_menu(){
// Brush menu
- GtkMenuItem* brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( brush_menu_item ) );
+ auto brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( brush_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
return brush_menu_item;
}
-GtkMenuItem* create_patch_menu(){
+ui::MenuItem create_patch_menu(){
// Curve menu
- GtkMenuItem* patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( patch_menu_item ) );
+ auto patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( patch_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
return patch_menu_item;
}
-GtkMenuItem* create_help_menu(){
+ui::MenuItem create_help_menu(){
// Help menu
- GtkMenuItem* help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( help_menu_item ) );
+ auto help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( help_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
// it will take care of hooking the Sys_OpenURL calls etc.
create_game_help_menu( menu );
-// create_menu_item_with_mnemonic( menu, "Bug report", FreeCaller<OpenBugReportURL>() );
- create_menu_item_with_mnemonic( menu, "Shortcuts", FreeCaller<DoCommandListDlg>() );
- create_menu_item_with_mnemonic( menu, "_About", FreeCaller<DoAbout>() );
+ create_menu_item_with_mnemonic( menu, "Bug report", makeCallbackF(OpenBugReportURL) );
+ create_menu_item_with_mnemonic( menu, "Shortcuts", makeCallbackF(DoCommandListDlg) );
+ create_menu_item_with_mnemonic( menu, "_About", makeCallbackF(DoAbout) );
return help_menu_item;
}
-GtkMenuBar* create_main_menu( MainFrame::EViewStyle style ){
- GtkMenuBar* menu_bar = GTK_MENU_BAR( gtk_menu_bar_new() );
- gtk_widget_show( GTK_WIDGET( menu_bar ) );
+ui::MenuBar create_main_menu( MainFrame::EViewStyle style ){
+ auto menu_bar = ui::MenuBar::from( gtk_menu_bar_new() );
+ menu_bar.show();
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_file_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_edit_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_view_menu( style ) ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_selection_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_bsp_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_grid_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_misc_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_entity_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_brush_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_patch_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_plugins_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_help_menu() ) );
+ menu_bar.add(create_file_menu());
+ menu_bar.add(create_edit_menu());
+ menu_bar.add(create_view_menu(style));
+ menu_bar.add(create_selection_menu());
+ menu_bar.add(create_bsp_menu());
+ menu_bar.add(create_grid_menu());
+ menu_bar.add(create_misc_menu());
+ menu_bar.add(create_entity_menu());
+ menu_bar.add(create_brush_menu());
+ menu_bar.add(create_patch_menu());
+ menu_bar.add(create_plugins_menu());
+ menu_bar.add(create_help_menu());
return menu_bar;
}
}
void Patch_registerShortcuts(){
-// command_connect_accelerator( "InvertCurveTextureX" );
-// command_connect_accelerator( "InvertCurveTextureY" );
-// command_connect_accelerator( "PatchInsertInsertColumn" );
-// command_connect_accelerator( "PatchInsertInsertRow" );
-// command_connect_accelerator( "PatchDeleteLastColumn" );
-// command_connect_accelerator( "PatchDeleteLastRow" );
-// command_connect_accelerator( "NaturalizePatch" );
- //command_connect_accelerator("CapCurrentCurve");
+ command_connect_accelerator( "InvertCurveTextureX" );
+ command_connect_accelerator( "InvertCurveTextureY" );
+ command_connect_accelerator( "PatchInsertInsertColumn" );
+ command_connect_accelerator( "PatchInsertInsertRow" );
+ command_connect_accelerator( "PatchDeleteLastColumn" );
+ command_connect_accelerator( "PatchDeleteLastRow" );
+ command_connect_accelerator( "NaturalizePatch" );
+ command_connect_accelerator( "CapCurrentCurve");
}
void Manipulators_registerShortcuts(){
Misc_registerShortcuts();
}
-void File_constructToolbar( GtkToolbar* toolbar ){
+void File_constructToolbar( ui::Toolbar toolbar ){
toolbar_append_button( toolbar, "Open an existing map (CTRL + O)", "file_open.png", "OpenMap" );
toolbar_append_button( toolbar, "Save the active map (CTRL + S)", "file_save.png", "SaveMap" );
}
-void UndoRedo_constructToolbar( GtkToolbar* toolbar ){
+void UndoRedo_constructToolbar( ui::Toolbar toolbar ){
toolbar_append_button( toolbar, "Undo (CTRL + Z)", "undo.png", "Undo" );
toolbar_append_button( toolbar, "Redo (CTRL + Y)", "redo.png", "Redo" );
}
-void RotateFlip_constructToolbar( GtkToolbar* toolbar ){
+void RotateFlip_constructToolbar( ui::Toolbar toolbar ){
// toolbar_append_button( toolbar, "x-axis Flip", "brush_flipx.png", "MirrorSelectionX" );
// toolbar_append_button( toolbar, "x-axis Rotate", "brush_rotatex.png", "RotateSelectionX" );
// toolbar_append_button( toolbar, "y-axis Flip", "brush_flipy.png", "MirrorSelectionY" );
toolbar_append_button( toolbar, "Rotate Anticlockwise", "brush_rotate_anti.png", "RotateSelectionAnticlockwise" );
}
-void Select_constructToolbar( GtkToolbar* toolbar ){
+void Select_constructToolbar( ui::Toolbar toolbar ){
toolbar_append_button( toolbar, "Select touching", "selection_selecttouching.png", "SelectTouching" );
toolbar_append_button( toolbar, "Select inside", "selection_selectinside.png", "SelectInside" );
}
-void CSG_constructToolbar( GtkToolbar* toolbar ){
+void CSG_constructToolbar( ui::Toolbar toolbar ){
toolbar_append_button( toolbar, "CSG Subtract (SHIFT + U)", "selection_csgsubtract.png", "CSGSubtract" );
toolbar_append_button( toolbar, "CSG Merge (CTRL + U)", "selection_csgmerge.png", "CSGMerge" );
- toolbar_append_button( toolbar, "Room", "selection_makeroom.png", "CSGroom" );
+ toolbar_append_button( toolbar, "Make Room", "selection_makeroom.png", "CSGRoom" );
toolbar_append_button( toolbar, "CSG Tool", "ellipsis.png", "CSGTool" );
}
-void ComponentModes_constructToolbar( GtkToolbar* toolbar ){
+void ComponentModes_constructToolbar( ui::Toolbar toolbar ){
toolbar_append_toggle_button( toolbar, "Select Vertices (V)", "modify_vertices.png", "DragVertices" );
toolbar_append_toggle_button( toolbar, "Select Edges (E)", "modify_edges.png", "DragEdges" );
toolbar_append_toggle_button( toolbar, "Select Faces (F)", "modify_faces.png", "DragFaces" );
}
-void Clipper_constructToolbar( GtkToolbar* toolbar ){
+void Clipper_constructToolbar( ui::Toolbar toolbar ){
toolbar_append_toggle_button( toolbar, "Clipper (X)", "view_clipper.png", "ToggleClipper" );
}
-void XYWnd_constructToolbar( GtkToolbar* toolbar ){
+void XYWnd_constructToolbar( ui::Toolbar toolbar ){
toolbar_append_button( toolbar, "Change views (CTRL + TAB)", "view_change.png", "NextView" );
}
-void Manipulators_constructToolbar( GtkToolbar* toolbar ){
+void Manipulators_constructToolbar( ui::Toolbar toolbar ){
toolbar_append_toggle_button( toolbar, "Translate (W)", "select_mousetranslate.png", "MouseTranslate" );
toolbar_append_toggle_button( toolbar, "Rotate (R)", "select_mouserotate.png", "MouseRotate" );
toolbar_append_toggle_button( toolbar, "Scale (Q)", "select_mousescale.png", "MouseScale" );
Clipper_constructToolbar( toolbar );
}
-GtkToolbar* create_main_toolbar( MainFrame::EViewStyle style ){
- GtkToolbar* toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
- gtk_toolbar_set_orientation( toolbar, GTK_ORIENTATION_HORIZONTAL );
+ui::Toolbar create_main_toolbar( MainFrame::EViewStyle style ){
+ auto toolbar = ui::Toolbar::from( gtk_toolbar_new() );
+ gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL );
gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS );
// gtk_toolbar_set_show_arrow( toolbar, TRUE );
//gtk_orientable_set_orientation( GTK_ORIENTABLE( toolbar ), GTK_ORIENTATION_HORIZONTAL );
//toolbar_append_space( toolbar );
- gtk_widget_show( GTK_WIDGET( toolbar ) );
+ toolbar.show();
+
+ auto space = [&]() {
+ auto btn = ui::ToolItem::from(gtk_separator_tool_item_new());
+ btn.show();
+ toolbar.add(btn);
+ };
File_constructToolbar( toolbar );
- gtk_toolbar_append_space( toolbar );
+
+ space();
UndoRedo_constructToolbar( toolbar );
- gtk_toolbar_append_space( toolbar );
+
+ space();
RotateFlip_constructToolbar( toolbar );
- gtk_toolbar_append_space( toolbar );
+
+ space();
Select_constructToolbar( toolbar );
- gtk_toolbar_append_space( toolbar );
+
+ space();
CSG_constructToolbar( toolbar );
- gtk_toolbar_append_space( toolbar );
+
+ space();
ComponentModes_constructToolbar( toolbar );
- gtk_toolbar_append_space( toolbar );
if ( style != MainFrame::eSplit ) {
+ space();
+
XYWnd_constructToolbar( toolbar );
- gtk_toolbar_append_space( toolbar );
}
+ space();
+
CamWnd_constructToolbar( toolbar );
- gtk_toolbar_append_space( toolbar );
+
+ space();
Manipulators_constructToolbar( toolbar );
- gtk_toolbar_append_space( toolbar );
if ( g_Layout_enablePatchToolbar.m_value ) {
+ space();
+
Patch_constructToolbar( toolbar );
- gtk_toolbar_append_space( toolbar );
}
+ space();
+
toolbar_append_toggle_button( toolbar, "Texture Lock (SHIFT + T)", "texture_lock.png", "TogTexLock" );
- gtk_toolbar_append_space( toolbar );
+
+ space();
toolbar_append_button( toolbar, "Entities (N)", "entities.png", "ToggleEntityInspector" );
// disable the console and texture button in the regular layouts
toolbar_append_button( toolbar, "Console (O)", "console.png", "ToggleConsole" );
toolbar_append_button( toolbar, "Texture Browser (T)", "texture_browser.png", "ToggleTextures" );
}
-
// TODO: call light inspector
//GtkButton* g_view_lightinspector_button = toolbar_append_button(toolbar, "Light Inspector", "lightinspector.png", "ToggleLightInspector");
- gtk_toolbar_append_space( toolbar );
+ space();
+
toolbar_append_button( toolbar, "Refresh Models", "refresh_models.png", "RefreshReferences" );
return toolbar;
}
-GtkWidget* create_main_statusbar( GtkWidget *pStatusLabel[c_count_status] ){
- GtkTable* table = GTK_TABLE( gtk_table_new( 1, c_count_status, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
+ui::Widget create_main_statusbar( ui::Widget pStatusLabel[c_count_status] ){
+ auto table = ui::Table( 1, c_count_status, FALSE );
+ table.show();
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) );
+ auto label = ui::Label( "Label" );
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
gtk_misc_set_padding( GTK_MISC( label ), 4, 2 );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach_defaults( table, GTK_WIDGET( label ), 0, 1, 0, 1 );
- pStatusLabel[c_command_status] = GTK_WIDGET( label );
+ label.show();
+ table.attach(label, {0, 1, 0, 1});
+ pStatusLabel[c_command_status] = ui::Widget(label );
}
- for ( int i = 1; i < c_count_status; ++i )
+ for (unsigned int i = 1; (int) i < c_count_status; ++i)
{
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( 0 ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
- gtk_table_attach_defaults( table, GTK_WIDGET( frame ), i, i + 1, 0, 1 );
+ auto frame = ui::Frame();
+ frame.show();
+ table.attach(frame, {i, i + 1, 0, 1});
gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN );
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) );
+ auto label = ui::Label( "Label" );
gtk_label_set_ellipsize( label, PANGO_ELLIPSIZE_END );
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
gtk_misc_set_padding( GTK_MISC( label ), 4, 2 );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( label ) );
- pStatusLabel[i] = GTK_WIDGET( label );
+ label.show();
+ frame.add(label);
+ pStatusLabel[i] = ui::Widget(label );
}
- return GTK_WIDGET( table );
+ return ui::Widget(table );
}
#if 0
{
const char* m_name;
-static gboolean frame_event( GtkWidget *widget, GdkEvent* event, WindowFocusPrinter* self ){
+static gboolean frame_event( ui::Widget widget, GdkEvent* event, WindowFocusPrinter* self ){
globalOutputStream() << self->m_name << " frame_event\n";
return FALSE;
}
-static gboolean keys_changed( GtkWidget *widget, WindowFocusPrinter* self ){
+static gboolean keys_changed( ui::Widget widget, WindowFocusPrinter* self ){
globalOutputStream() << self->m_name << " keys_changed\n";
return FALSE;
}
-static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* self ){
+static gboolean notify( ui::Window window, gpointer dummy, WindowFocusPrinter* self ){
if ( gtk_window_is_active( window ) ) {
globalOutputStream() << self->m_name << " takes toplevel focus\n";
}
public:
WindowFocusPrinter( const char* name ) : m_name( name ){
}
-void connect( GtkWindow* toplevel_window ){
- g_signal_connect( G_OBJECT( toplevel_window ), "notify::has_toplevel_focus", G_CALLBACK( notify ), this );
- g_signal_connect( G_OBJECT( toplevel_window ), "notify::is_active", G_CALLBACK( notify ), this );
- g_signal_connect( G_OBJECT( toplevel_window ), "keys_changed", G_CALLBACK( keys_changed ), this );
- g_signal_connect( G_OBJECT( toplevel_window ), "frame_event", G_CALLBACK( frame_event ), this );
+void connect( ui::Window toplevel_window ){
+ toplevel_window.connect( "notify::has_toplevel_focus", G_CALLBACK( notify ), this );
+ toplevel_window.connect( "notify::is_active", G_CALLBACK( notify ), this );
+ toplevel_window.connect( "keys_changed", G_CALLBACK( keys_changed ), this );
+ toplevel_window.connect( "frame_event", G_CALLBACK( frame_event ), this );
}
};
class MainWindowActive
{
-static gboolean notify( GtkWindow* window, gpointer dummy, MainWindowActive* self ){
- if ( g_wait.m_window != 0 && gtk_window_is_active( window ) && !GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
- gtk_widget_show( GTK_WIDGET( g_wait.m_window ) );
+static gboolean notify( ui::Window window, gpointer dummy, MainWindowActive* self ){
+ if ( g_wait.m_window && gtk_window_is_active( window ) && !g_wait.m_window.visible() ) {
+ g_wait.m_window.show();
}
return FALSE;
}
+
public:
-void connect( GtkWindow* toplevel_window ){
- g_signal_connect( G_OBJECT( toplevel_window ), "notify::is-active", G_CALLBACK( notify ), this );
+void connect( ui::Window toplevel_window ){
+ toplevel_window.connect( "notify::is-active", G_CALLBACK( notify ), this );
}
};
MainFrame* g_pParentWnd = 0;
-GtkWindow* MainFrame_getWindow(){
- if ( g_pParentWnd == 0 ) {
- return 0;
- }
- return g_pParentWnd->m_window;
+ui::Window MainFrame_getWindow()
+{
+ return g_pParentWnd ? g_pParentWnd->m_window : ui::Window{ui::null};
}
-std::vector<GtkWidget*> g_floating_windows;
+std::vector<ui::Widget> g_floating_windows;
-MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusTextCaller( *this ) ){
+MainFrame::MainFrame() : m_idleRedrawStatusText( RedrawStatusTextCaller( *this ) ){
m_pXYWnd = 0;
m_pCamWnd = 0;
m_pZWnd = 0;
m_pXZWnd = 0;
m_pActiveXY = 0;
- for ( int n = 0; n < c_count_status; n++ )
- {
- m_pStatusLabel[n] = 0;
+ for (auto &n : m_pStatusLabel) {
+ n = NULL;
}
m_bSleeping = false;
MainFrame::~MainFrame(){
SaveWindowInfo();
- gtk_widget_hide( GTK_WIDGET( m_window ) );
+ m_window.hide();
Shutdown();
- for ( std::vector<GtkWidget*>::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i )
+ for ( std::vector<ui::Widget>::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i )
{
- gtk_widget_destroy( *i );
+ i->destroy();
}
- gtk_widget_destroy( GTK_WIDGET( m_window ) );
+ m_window.destroy();
}
void MainFrame::SetActiveXY( XYWnd* p ){
#endif
}
-#ifdef _DEBUG
+#if GDEF_DEBUG
//#define DBG_SLEEP
#endif
}
-GtkWindow* create_splash(){
- GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) );
- gtk_window_set_decorated( window, FALSE );
- gtk_window_set_resizable( window, FALSE );
- gtk_window_set_modal( window, TRUE );
+ui::Window create_splash(){
+ auto window = ui::Window( ui::window_type::TOP );
+ gtk_window_set_decorated(window, false);
+ gtk_window_set_resizable(window, false);
+ gtk_window_set_modal(window, true);
gtk_window_set_default_size( window, -1, -1 );
gtk_window_set_position( window, GTK_WIN_POS_CENTER );
- gtk_container_set_border_width( GTK_CONTAINER( window ), 0 );
+ gtk_container_set_border_width(window, 0);
- GtkImage* image = new_local_image( "splash.png" );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( image ) );
+ auto image = new_local_image( "splash.png" );
+ image.show();
+ window.add(image);
if( gtk_image_get_storage_type( image ) == GTK_IMAGE_PIXBUF ){
GdkBitmap* mask;
gtk_widget_shape_combine_mask ( GTK_WIDGET( window ), mask, 0, 0 );
}
- gtk_widget_set_size_request( GTK_WIDGET( window ), -1, -1 );
- gtk_widget_show( GTK_WIDGET( window ) );
+ window.dimensions(-1, -1);
+ window.show();
return window;
}
-static GtkWindow *splash_screen = 0;
+static ui::Window splash_screen{ui::null};
void show_splash(){
splash_screen = create_splash();
- process_gui();
+ ui::process();
}
void hide_splash(){
- gtk_widget_destroy( GTK_WIDGET( splash_screen ) );
+ splash_screen.destroy();
}
WindowPositionTracker g_posCamWnd;
WindowPositionTracker g_posXZWnd;
WindowPositionTracker g_posYZWnd;
-static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data ){
+static gint mainframe_delete( ui::Widget widget, GdkEvent *event, gpointer data ){
if ( ConfirmModified( "Exit Radiant" ) ) {
gtk_main_quit();
}
}
void MainFrame::Create(){
- GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) );
+ ui::Window window = ui::Window( ui::window_type::TOP );
GlobalWindowObservers_connectTopLevel( window );
gtk_window_set_transient_for( splash_screen, window );
-#if !defined( WIN32 )
+#if !GDEF_OS_WINDOWS
{
GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" );
if ( pixbuf != 0 ) {
}
#endif
- gtk_widget_add_events( GTK_WIDGET( window ), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK );
- g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( mainframe_delete ), this );
+ gtk_widget_add_events( window , GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK );
+ window.connect( "delete_event", G_CALLBACK( mainframe_delete ), this );
m_position_tracker.connect( window );
g_MainWindowActive.connect( window );
- GetPlugInMgr().Init( GTK_WIDGET( window ) );
+ GetPlugInMgr().Init( window );
- GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 0 );
+ window.add(vbox);
+ vbox.show();
gtk_container_set_focus_chain( GTK_CONTAINER( vbox ), NULL );
global_accel_connect_window( window );
register_shortcuts();
- GtkMenuBar* main_menu = create_main_menu( CurrentStyle() );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_menu ), FALSE, FALSE, 0 );
+ auto main_menu = create_main_menu( CurrentStyle() );
+ vbox.pack_start( main_menu, FALSE, FALSE, 0 );
if( g_Layout_enableMainToolbar.m_value ){
GtkToolbar* main_toolbar = create_main_toolbar( CurrentStyle() );
gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_toolbar ), FALSE, FALSE, 0 );
}
-
if ( g_Layout_enablePluginToolbar.m_value || g_Layout_enableFilterToolbar.m_value ){
- GtkWidget* PFbox = gtk_hbox_new( FALSE, 3 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( PFbox ), FALSE, FALSE, 0 );
- gtk_widget_show( PFbox );
+ auto PFbox = ui::HBox( FALSE, 3 );
+ vbox.pack_start( PFbox, FALSE, FALSE, 0 );
+ PFbox.show();
if ( g_Layout_enablePluginToolbar.m_value ){
- GtkToolbar* plugin_toolbar = create_plugin_toolbar();
+ auto plugin_toolbar = create_plugin_toolbar();
if ( g_Layout_enableFilterToolbar.m_value ){
- gtk_box_pack_start( GTK_BOX( PFbox ), GTK_WIDGET( plugin_toolbar ), FALSE, FALSE, 0 );
+ PFbox.pack_start( plugin_toolbar, FALSE, FALSE, 0 );
}
else{
- gtk_box_pack_start( GTK_BOX( PFbox ), GTK_WIDGET( plugin_toolbar ), TRUE, TRUE, 0 );
+ PFbox.pack_start( plugin_toolbar, TRUE, TRUE, 0 );
}
}
if ( g_Layout_enableFilterToolbar.m_value ){
- GtkToolbar* filter_toolbar = create_filter_toolbar();
- gtk_box_pack_start( GTK_BOX( PFbox ), GTK_WIDGET( filter_toolbar ), TRUE, TRUE, 0 );
+ ui::Toolbar filter_toolbar = create_filter_toolbar();
+ PFbox.pack_start( filter_toolbar, TRUE, TRUE, 0 );
}
}
gtk_widget_hide( GTK_WIDGET( plugin_toolbar ) );
}*/
-
-
-
- GtkWidget* main_statusbar = create_main_statusbar( m_pStatusLabel );
- gtk_box_pack_end( GTK_BOX( vbox ), main_statusbar, FALSE, TRUE, 2 );
+ ui::Widget main_statusbar = create_main_statusbar(reinterpret_cast<ui::Widget *>(m_pStatusLabel));
+ vbox.pack_end(main_statusbar, FALSE, TRUE, 2);
GroupDialog_constructWindow( window );
g_page_console = GroupDialog_addPage( "Console", Console_constructWindow( GroupDialog_getWindow() ), RawStringExportCaller( "Console" ) );
}
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
if ( g_multimon_globals.m_bStartOnPrimMon ) {
PositionWindowOnPrimaryScreen( g_layout_globals.m_position );
}
m_window = window;
- gtk_widget_show( GTK_WIDGET( window ) );
+ window.show();
if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) {
{
- GtkWidget* hsplit = gtk_hpaned_new();
+ ui::Widget hsplit = ui::HPaned(ui::New);
m_hSplit = hsplit;
- gtk_box_pack_start( GTK_BOX( vbox ), hsplit, TRUE, TRUE, 0 );
- gtk_widget_show( hsplit );
+
+ vbox.pack_start( hsplit, TRUE, TRUE, 0 );
+ hsplit.show();
+
{
- GtkWidget* vsplit = gtk_vpaned_new();
- gtk_widget_show( vsplit );
+ ui::Widget vsplit = ui::VPaned(ui::New);
+ vsplit.show();
m_vSplit = vsplit;
- GtkWidget* vsplit2 = gtk_vpaned_new();
- gtk_widget_show( vsplit2 );
+
+ ui::Widget vsplit2 = ui::VPaned(ui::New);
+ vsplit2.show();
m_vSplit2 = vsplit2;
+
if ( CurrentStyle() == eRegular ){
gtk_paned_pack1( GTK_PANED( hsplit ), vsplit, TRUE, TRUE );
gtk_paned_pack2( GTK_PANED( hsplit ), vsplit2, TRUE, TRUE );
gtk_paned_pack2( GTK_PANED( hsplit ), vsplit, TRUE, TRUE );
gtk_paned_pack1( GTK_PANED( hsplit ), vsplit2, TRUE, TRUE );
}
+
// console
- GtkWidget* console_window = Console_constructWindow( window );
+ ui::Widget console_window = Console_constructWindow( window );
gtk_paned_pack2( GTK_PANED( vsplit ), console_window, TRUE, TRUE );
-
+
// xy
m_pXYWnd = new XYWnd();
m_pXYWnd->SetViewType( XY );
- GtkWidget* xy_window = GTK_WIDGET( create_framed_widget( m_pXYWnd->GetWidget() ) );
+ ui::Widget xy_window = ui::Widget(create_framed_widget( m_pXYWnd->GetWidget( ) ));
gtk_paned_pack1( GTK_PANED( vsplit ), xy_window, TRUE, TRUE );
+
{
// camera
m_pCamWnd = NewCamWnd();
GlobalCamera_setCamWnd( *m_pCamWnd );
CamWnd_setParent( *m_pCamWnd, window );
- GtkFrame* camera_window = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) );
+ auto camera_window = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) );
- gtk_paned_pack1( GTK_PANED( vsplit2 ), GTK_WIDGET( camera_window ), TRUE, TRUE );
+ gtk_paned_pack1( GTK_PANED( vsplit2 ), GTK_WIDGET( camera_window ) , TRUE, TRUE);
// textures
- GtkFrame* texture_window = create_framed_widget( TextureBrowser_constructWindow( window ) );
+ auto texture_window = create_framed_widget( TextureBrowser_constructWindow( window ) );
gtk_paned_pack2( GTK_PANED( vsplit2 ), GTK_WIDGET( texture_window ), TRUE, TRUE );
}
}
else if ( CurrentStyle() == eFloating ) {
{
- GtkWindow* window = create_persistent_floating_window( "Camera", m_window );
+ ui::Window window = ui::Window(create_persistent_floating_window( "Camera", m_window ));
global_accel_connect_window( window );
g_posCamWnd.connect( window );
- gtk_widget_show( GTK_WIDGET( window ) );
+ window.show();
m_pCamWnd = NewCamWnd();
GlobalCamera_setCamWnd( *m_pCamWnd );
{
- GtkFrame* frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
+ auto frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) );
+ window.add(frame);
}
CamWnd_setParent( *m_pCamWnd, window );
+#define GARUX_GTK_WORKAROUND
+#ifndef GARUX_GTK_WORKAROUND
/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
g_object_set_data( G_OBJECT( window ), "glwidget", CamWnd_getWidget( *m_pCamWnd ) );
+#endif
- g_floating_windows.push_back( GTK_WIDGET( window ) );
+ g_floating_windows.push_back( window );
}
{
- GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XY ), m_window );
+ ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XY ), m_window ));
global_accel_connect_window( window );
g_posXYWnd.connect( window );
{
- GtkFrame* frame = create_framed_widget( m_pXYWnd->GetWidget() );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
+ auto frame = create_framed_widget( m_pXYWnd->GetWidget() );
+ window.add(frame);
}
XY_Top_Shown_Construct( window );
+#ifndef GARUX_GTK_WORKAROUND
/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
g_object_set_data( G_OBJECT( window ), "glwidget", m_pXYWnd->GetWidget() );
+#endif
- g_floating_windows.push_back( GTK_WIDGET( window ) );
+ g_floating_windows.push_back( window );
}
{
- GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XZ ), m_window );
+ ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XZ ), m_window ));
global_accel_connect_window( window );
g_posXZWnd.connect( window );
m_pXZWnd->SetViewType( XZ );
{
- GtkFrame* frame = create_framed_widget( m_pXZWnd->GetWidget() );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
+ auto frame = create_framed_widget( m_pXZWnd->GetWidget() );
+ window.add(frame);
}
XZ_Front_Shown_Construct( window );
+#ifndef GARUX_GTK_WORKAROUND
/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
g_object_set_data( G_OBJECT( window ), "glwidget", m_pXZWnd->GetWidget() );
+#endif
- g_floating_windows.push_back( GTK_WIDGET( window ) );
+ g_floating_windows.push_back( window );
}
{
- GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( YZ ), m_window );
+ ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( YZ ), m_window ));
global_accel_connect_window( window );
g_posYZWnd.connect( window );
m_pYZWnd->SetViewType( YZ );
{
- GtkFrame* frame = create_framed_widget( m_pYZWnd->GetWidget() );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
+ auto frame = create_framed_widget( m_pYZWnd->GetWidget() );
+ window.add(frame);
}
YZ_Side_Shown_Construct( window );
+#ifndef GARUX_GTK_WORKAROUND
/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
g_object_set_data( G_OBJECT( window ), "glwidget", m_pYZWnd->GetWidget() );
+#endif
- g_floating_windows.push_back( GTK_WIDGET( window ) );
+ g_floating_windows.push_back( window );
}
{
- GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
- g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() );
+ auto frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
+ g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() );
+#ifndef GARUX_GTK_WORKAROUND
/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() );
+#endif
}
- m_vSplit = 0;
- m_hSplit = 0;
- m_vSplit2 = 0;
+ // FIXME: find a way to do it with newer syntax
+ // m_vSplit = 0;
+ // m_hSplit = 0;
+ // m_vSplit2 = 0;
GroupDialog_show();
}
GlobalCamera_setCamWnd( *m_pCamWnd );
CamWnd_setParent( *m_pCamWnd, window );
- GtkWidget* camera = CamWnd_getWidget( *m_pCamWnd );
+ ui::Widget camera = CamWnd_getWidget( *m_pCamWnd );
m_pYZWnd = new XYWnd();
m_pYZWnd->SetViewType( YZ );
- GtkWidget* yz = m_pYZWnd->GetWidget();
+ ui::Widget yz = m_pYZWnd->GetWidget();
m_pXYWnd = new XYWnd();
m_pXYWnd->SetViewType( XY );
- GtkWidget* xy = m_pXYWnd->GetWidget();
+ ui::Widget xy = m_pXYWnd->GetWidget();
m_pXZWnd = new XYWnd();
m_pXZWnd->SetViewType( XZ );
- GtkWidget* xz = m_pXZWnd->GetWidget();
+ ui::Widget xz = m_pXZWnd->GetWidget();
m_hSplit = create_split_views( camera, yz, xy, xz, m_vSplit, m_vSplit2 );
- gtk_box_pack_start( GTK_BOX( vbox ), m_hSplit, TRUE, TRUE, 0 );
+ vbox.pack_start( m_hSplit, TRUE, TRUE, 0 );
{
- GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
- g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() );
+ auto frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
+ g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() );
+#ifndef GARUX_GTK_WORKAROUND
/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() );
+#endif
}
}
SetActiveXY( m_pXYWnd );
AddGridChangeCallback( SetGridStatusCaller( *this ) );
- AddGridChangeCallback( ReferenceCaller<MainFrame, XY_UpdateAllWindows>( *this ) );
+ AddGridChangeCallback( ReferenceCaller<MainFrame, void(), XY_UpdateAllWindows>( *this ) );
g_defaultToolMode = DragMode;
g_defaultToolMode();
g_layout_globals.m_position = m_position_tracker.getPosition();
}
- g_layout_globals.nState = gdk_window_get_state( GTK_WIDGET( m_window )->window );
+ g_layout_globals.nState = gdk_window_get_state( gtk_widget_get_window(m_window ) );
}
void MainFrame::Shutdown(){
}
void MainFrame::RedrawStatusText(){
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_command_status] ), m_command_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_position_status] ), m_position_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_brushcount_status] ), m_brushcount_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_texture_status] ), m_texture_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_grid_status] ), m_grid_status.c_str() );
+ ui::Label::from(m_pStatusLabel[c_command_status]).text(m_command_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_position_status]).text(m_position_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_brushcount_status]).text(m_brushcount_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_texture_status]).text(m_texture_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_grid_status]).text(m_grid_status.c_str());
}
void MainFrame::UpdateStatusText(){
}
float ( *GridStatus_getGridSize )() = GetGridSize;
+
int ( *GridStatus_getRotateIncrement )() = getRotateIncrement;
+
int ( *GridStatus_getFarClipDistance )() = getFarClipDistance;
+
bool ( *GridStatus_getTextureLockEnabled )();
void MainFrame::SetGridStatus(){
globalOutputStream() << "GL_VENDOR: " << reinterpret_cast<const char*>( glGetString( GL_VENDOR ) ) << "\n";
globalOutputStream() << "GL_RENDERER: " << reinterpret_cast<const char*>( glGetString( GL_RENDERER ) ) << "\n";
globalOutputStream() << "GL_VERSION: " << reinterpret_cast<const char*>( glGetString( GL_VERSION ) ) << "\n";
- globalOutputStream() << "GL_EXTENSIONS: " << reinterpret_cast<const char*>( glGetString( GL_EXTENSIONS ) ) << "\n";
+ const auto extensions = reinterpret_cast<const char*>( glGetString(GL_EXTENSIONS ) );
+ globalOutputStream() << "GL_EXTENSIONS: " << (extensions ? extensions : "") << "\n";
QGL_sharedContextCreated( GlobalOpenGL() );
GlobalShaderCache().realise();
Textures_Realise();
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
/* win32 is dodgy here, just use courier new then */
g_font = glfont_create( "arial 9" );
#else
- GtkSettings *settings = gtk_settings_get_default();
+ auto settings = gtk_settings_get_default();
gchar *fontname;
g_object_get( settings, "gtk-font-name", &fontname, NULL );
g_font = glfont_create( fontname );
page.appendRadioIcons(
"Window Layout",
STRING_ARRAY_RANGE( layouts ),
- LatchedIntImportCaller( g_Layout_viewStyle ),
- IntExportCaller( g_Layout_viewStyle.m_latched )
+ make_property( g_Layout_viewStyle )
);
}
page.appendCheckBox(
"", "Detachable Menus",
- LatchedBoolImportCaller( g_Layout_enableDetachableMenus ),
- BoolExportCaller( g_Layout_enableDetachableMenus.m_latched )
+ make_property( g_Layout_enableDetachableMenus )
);
page.appendCheckBox(
"", "Main Toolbar",
- LatchedBoolImportCaller( g_Layout_enableMainToolbar ),
- BoolExportCaller( g_Layout_enableMainToolbar.m_latched )
+ make_property( g_Layout_enableMainToolbar )
);
if ( !string_empty( g_pGameDescription->getKeyValue( "no_patch" ) ) ) {
page.appendCheckBox(
"", "Patch Toolbar",
- LatchedBoolImportCaller( g_Layout_enablePatchToolbar ),
- BoolExportCaller( g_Layout_enablePatchToolbar.m_latched )
+ make_property( g_Layout_enablePatchToolbar )
);
}
page.appendCheckBox(
"", "Plugin Toolbar",
- LatchedBoolImportCaller( g_Layout_enablePluginToolbar ),
- BoolExportCaller( g_Layout_enablePluginToolbar.m_latched )
+ make_property( g_Layout_enablePluginToolbar )
);
page.appendCheckBox(
"", "Filter Toolbar",
- LatchedBoolImportCaller( g_Layout_enableFilterToolbar ),
- BoolExportCaller( g_Layout_enableFilterToolbar.m_latched )
+ make_property( g_Layout_enableFilterToolbar )
);
}
}
void Layout_registerPreferencesPage(){
- PreferencesDialog_addInterfacePage( FreeCaller1<PreferenceGroup&, Layout_constructPage>() );
+ PreferencesDialog_addInterfacePage( makeCallbackF(Layout_constructPage) );
}
void MainFrame_toggleFullscreen(){
m_hSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_hSplit ) );
int vSplitX, vSplitY, vSplit2X, vSplit2Y, hSplitX, hSplitY;
- gdk_window_get_origin( g_pParentWnd->m_vSplit->window, &vSplitX, &vSplitY );
- gdk_window_get_origin( g_pParentWnd->m_vSplit2->window, &vSplit2X, &vSplit2Y );
- gdk_window_get_origin( g_pParentWnd->m_hSplit->window, &hSplitX, &hSplitY );
+ gdk_window_get_origin( GTK_WIDGET( g_pParentWnd->m_vSplit )->window, &vSplitX, &vSplitY );
+ gdk_window_get_origin( GTK_WIDGET( g_pParentWnd->m_vSplit2 )->window, &vSplit2X, &vSplit2Y );
+ gdk_window_get_origin( GTK_WIDGET( g_pParentWnd->m_hSplit )->window, &hSplitX, &hSplitY );
vSplitY += m_vSplitPos;
vSplit2Y += m_vSplit2Pos;
#include "stringio.h"
void MainFrame_Construct(){
- GlobalCommands_insert( "OpenManual", FreeCaller<OpenHelpURL>(), Accelerator( GDK_F1 ) );
-
- GlobalCommands_insert( "Sleep", FreeCaller<thunk_OnSleep>(), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "NewMap", FreeCaller<NewMap>() );
- GlobalCommands_insert( "OpenMap", FreeCaller<OpenMap>(), Accelerator( 'O', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "ImportMap", FreeCaller<ImportMap>() );
- GlobalCommands_insert( "SaveMap", FreeCaller<SaveMap>(), Accelerator( 'S', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "SaveMapAs", FreeCaller<SaveMapAs>() );
- GlobalCommands_insert( "SaveSelected", FreeCaller<ExportMap>() );
- GlobalCommands_insert( "SaveRegion", FreeCaller<SaveRegion>() );
- GlobalCommands_insert( "RefreshReferences", FreeCaller<RefreshReferences>() );
- GlobalCommands_insert( "ProjectSettings", FreeCaller<DoProjectSettings>() );
- GlobalCommands_insert( "CheckForUpdate", FreeCaller<OpenUpdateURL>() );
- GlobalCommands_insert( "Exit", FreeCaller<Exit>() );
-
- GlobalCommands_insert( "Undo", FreeCaller<Undo>(), Accelerator( 'Z', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "Redo", FreeCaller<Redo>(), Accelerator( 'Y', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "Copy", FreeCaller<Copy>(), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "Paste", FreeCaller<Paste>(), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "PasteToCamera", FreeCaller<PasteToCamera>(), Accelerator( 'V', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "CloneSelection", FreeCaller<Selection_Clone>(), Accelerator( GDK_space ) );
- GlobalCommands_insert( "CloneSelectionAndMakeUnique", FreeCaller<Selection_Clone_MakeUnique>(), Accelerator( GDK_space, (GdkModifierType)GDK_SHIFT_MASK ) );
-// GlobalCommands_insert( "DeleteSelection", FreeCaller<deleteSelection>(), Accelerator( GDK_BackSpace ) );
- GlobalCommands_insert( "DeleteSelection2", FreeCaller<deleteSelection>(), Accelerator( GDK_BackSpace ) );
- GlobalCommands_insert( "DeleteSelection", FreeCaller<deleteSelection>(), Accelerator( 'Z' ) );
- GlobalCommands_insert( "ParentSelection", FreeCaller<Scene_parentSelected>() );
-// GlobalCommands_insert( "UnSelectSelection", FreeCaller<Selection_Deselect>(), Accelerator( GDK_Escape ) );
- GlobalCommands_insert( "UnSelectSelection2", FreeCaller<Selection_Deselect>(), Accelerator( GDK_Escape ) );
- GlobalCommands_insert( "UnSelectSelection", FreeCaller<Selection_Deselect>(), Accelerator( 'C' ) );
- GlobalCommands_insert( "InvertSelection", FreeCaller<Select_Invert>(), Accelerator( 'I' ) );
- GlobalCommands_insert( "SelectInside", FreeCaller<Select_Inside>() );
- GlobalCommands_insert( "SelectTouching", FreeCaller<Select_Touching>() );
- GlobalCommands_insert( "ExpandSelectionToEntities", FreeCaller<Scene_ExpandSelectionToEntities>(), Accelerator( 'E', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "Preferences", FreeCaller<PreferencesDialog_showDialog>(), Accelerator( 'P' ) );
-
- GlobalCommands_insert( "ToggleConsole", FreeCaller<Console_ToggleShow>(), Accelerator( 'O' ) );
- GlobalCommands_insert( "ToggleEntityInspector", FreeCaller<EntityInspector_ToggleShow>(), Accelerator( 'N' ) );
- GlobalCommands_insert( "EntityList", FreeCaller<EntityList_toggleShown>(), Accelerator( 'L' ) );
-
-// GlobalCommands_insert( "ShowHidden", FreeCaller<Select_ShowAllHidden>(), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) );
-// GlobalCommands_insert( "HideSelected", FreeCaller<HideSelected>(), Accelerator( 'H' ) );
+ GlobalCommands_insert( "OpenManual", makeCallbackF(OpenHelpURL), Accelerator( GDK_KEY_F1 ) );
+
+ GlobalCommands_insert( "Sleep", makeCallbackF(thunk_OnSleep), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "NewMap", makeCallbackF(NewMap) );
+ GlobalCommands_insert( "OpenMap", makeCallbackF(OpenMap), Accelerator( 'O', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "ImportMap", makeCallbackF(ImportMap) );
+ GlobalCommands_insert( "SaveMap", makeCallbackF(SaveMap), Accelerator( 'S', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "SaveMapAs", makeCallbackF(SaveMapAs) );
+ GlobalCommands_insert( "ExportSelected", makeCallbackF(ExportMap) );
+ GlobalCommands_insert( "SaveRegion", makeCallbackF(SaveRegion) );
+ GlobalCommands_insert( "RefreshReferences", makeCallbackF(VFS_Refresh) );
+ GlobalCommands_insert( "ProjectSettings", makeCallbackF(DoProjectSettings) );
+ GlobalCommands_insert( "Exit", makeCallbackF(Exit) );
+
+ GlobalCommands_insert( "Undo", makeCallbackF(Undo), Accelerator( 'Z', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "Redo", makeCallbackF(Redo), Accelerator( 'Y', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "Copy", makeCallbackF(Copy), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "Paste", makeCallbackF(Paste), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "PasteToCamera", makeCallbackF(PasteToCamera), Accelerator( 'V', (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "CloneSelection", makeCallbackF(Selection_Clone), Accelerator( GDK_KEY_space ) );
+ GlobalCommands_insert( "CloneSelectionAndMakeUnique", makeCallbackF(Selection_Clone_MakeUnique), Accelerator( GDK_KEY_space, (GdkModifierType)GDK_SHIFT_MASK ) );
+// GlobalCommands_insert( "DeleteSelection", makeCallbackF(deleteSelection), Accelerator( GDK_KEY_BackSpace ) );
+ GlobalCommands_insert( "DeleteSelection2", makeCallbackF(deleteSelection), Accelerator( GDK_KEY_BackSpace ) );
+ GlobalCommands_insert( "DeleteSelection", makeCallbackF(deleteSelection), Accelerator( 'Z' ) );
+ GlobalCommands_insert( "ParentSelection", makeCallbackF(Scene_parentSelected) );
+// GlobalCommands_insert( "UnSelectSelection", makeCallbackF(Selection_Deselect), Accelerator( GDK_KEY_Escape ) );
+ GlobalCommands_insert( "UnSelectSelection2", makeCallbackF(Selection_Deselect), Accelerator( GDK_KEY_Escape ) );
+ GlobalCommands_insert( "UnSelectSelection", makeCallbackF(Selection_Deselect), Accelerator( 'C' ) );
+ GlobalCommands_insert( "InvertSelection", makeCallbackF(Select_Invert), Accelerator( 'I' ) );
+ GlobalCommands_insert( "SelectInside", makeCallbackF(Select_Inside) );
+ GlobalCommands_insert( "SelectTouching", makeCallbackF(Select_Touching) );
+ GlobalCommands_insert( "ExpandSelectionToEntities", makeCallbackF(Scene_ExpandSelectionToEntities), Accelerator( 'E', (GdkModifierType)( GDK_MOD1_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "Preferences", makeCallbackF(PreferencesDialog_showDialog), Accelerator( 'P' ) );
+
+ GlobalCommands_insert( "ToggleConsole", makeCallbackF(Console_ToggleShow), Accelerator( 'O' ) );
+ GlobalCommands_insert( "ToggleEntityInspector", makeCallbackF(EntityInspector_ToggleShow), Accelerator( 'N' ) );
+ GlobalCommands_insert( "EntityList", makeCallbackF(EntityList_toggleShown), Accelerator( 'L' ) );
+
+// GlobalCommands_insert( "ShowHidden", makeCallbackF( Select_ShowAllHidden ), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) );
+// GlobalCommands_insert( "HideSelected", makeCallbackF( HideSelected ), Accelerator( 'H' ) );
+
Select_registerCommands();
- GlobalToggles_insert( "DragVertices", FreeCaller<SelectVertexMode>(), ToggleItem::AddCallbackCaller( g_vertexMode_button ), Accelerator( 'V' ) );
- GlobalToggles_insert( "DragEdges", FreeCaller<SelectEdgeMode>(), ToggleItem::AddCallbackCaller( g_edgeMode_button ), Accelerator( 'E' ) );
- GlobalToggles_insert( "DragFaces", FreeCaller<SelectFaceMode>(), ToggleItem::AddCallbackCaller( g_faceMode_button ), Accelerator( 'F' ) );
+ GlobalToggles_insert( "DragVertices", makeCallbackF(SelectVertexMode), ToggleItem::AddCallbackCaller( g_vertexMode_button ), Accelerator( 'V' ) );
+ GlobalToggles_insert( "DragEdges", makeCallbackF(SelectEdgeMode), ToggleItem::AddCallbackCaller( g_edgeMode_button ), Accelerator( 'E' ) );
+ GlobalToggles_insert( "DragFaces", makeCallbackF(SelectFaceMode), ToggleItem::AddCallbackCaller( g_faceMode_button ), Accelerator( 'F' ) );
- GlobalCommands_insert( "ArbitraryRotation", FreeCaller<DoRotateDlg>(), Accelerator( 'R', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "ArbitraryScale", FreeCaller<DoScaleDlg>(), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "ArbitraryRotation", makeCallbackF(DoRotateDlg), Accelerator( 'R', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "ArbitraryScale", makeCallbackF(DoScaleDlg), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "BuildMenuCustomize", FreeCaller<DoBuildMenu>() );
- GlobalCommands_insert( "Build_runRecentExecutedBuild", FreeCaller<Build_runRecentExecutedBuild>(), Accelerator( GDK_F5 ) );
+ GlobalCommands_insert( "BuildMenuCustomize", makeCallbackF(DoBuildMenu) );
+ GlobalCommands_insert( "Build_runRecentExecutedBuild", makeCallbackF(Build_runRecentExecutedBuild), Accelerator( GDK_F5 ) );
- GlobalCommands_insert( "FindBrush", FreeCaller<DoFind>() );
+ GlobalCommands_insert( "FindBrush", makeCallbackF(DoFind) );
- GlobalCommands_insert( "MapInfo", FreeCaller<DoMapInfo>(), Accelerator( 'M' ) );
+ GlobalCommands_insert( "MapInfo", makeCallbackF(DoMapInfo), Accelerator( 'M' ) );
- GlobalToggles_insert( "ToggleClipper", FreeCaller<ClipperMode>(), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) );
+ GlobalToggles_insert( "ToggleClipper", makeCallbackF(ClipperMode), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) );
- GlobalToggles_insert( "MouseTranslate", FreeCaller<TranslateMode>(), ToggleItem::AddCallbackCaller( g_translatemode_button ), Accelerator( 'W' ) );
- GlobalToggles_insert( "MouseRotate", FreeCaller<RotateMode>(), ToggleItem::AddCallbackCaller( g_rotatemode_button ), Accelerator( 'R' ) );
- GlobalToggles_insert( "MouseScale", FreeCaller<ScaleMode>(), ToggleItem::AddCallbackCaller( g_scalemode_button ) );
- GlobalToggles_insert( "MouseDrag", FreeCaller<DragMode>(), ToggleItem::AddCallbackCaller( g_dragmode_button ) );
- GlobalCommands_insert( "MouseRotateOrScale", FreeCaller<ToggleRotateScaleModes>() );
- GlobalCommands_insert( "MouseDragOrScale", FreeCaller<ToggleDragScaleModes>(), Accelerator( 'Q' ) );
+ GlobalToggles_insert( "MouseTranslate", makeCallbackF(TranslateMode), ToggleItem::AddCallbackCaller( g_translatemode_button ), Accelerator( 'W' ) );
+ GlobalToggles_insert( "MouseRotate", makeCallbackF(RotateMode), ToggleItem::AddCallbackCaller( g_rotatemode_button ), Accelerator( 'R' ) );
+ GlobalToggles_insert( "MouseScale", makeCallbackF(ScaleMode), ToggleItem::AddCallbackCaller( g_scalemode_button ) );
+ GlobalToggles_insert( "MouseDrag", makeCallbackF(DragMode), ToggleItem::AddCallbackCaller( g_dragmode_button ) );
+ GlobalCommands_insert( "MouseRotateOrScale", makeCallbackF(ToggleRotateScaleModes) );
+ GlobalCommands_insert( "MouseDragOrScale", makeCallbackF(ToggleDragScaleModes), Accelerator( 'Q' ) );
- GlobalCommands_insert( "gtkThemeDlg", FreeCaller<gtkThemeDlg>() );
- GlobalCommands_insert( "ColorSchemeOriginal", FreeCaller<ColorScheme_Original>() );
- GlobalCommands_insert( "ColorSchemeQER", FreeCaller<ColorScheme_QER>() );
- GlobalCommands_insert( "ColorSchemeBlackAndGreen", FreeCaller<ColorScheme_Black>() );
- GlobalCommands_insert( "ColorSchemeYdnar", FreeCaller<ColorScheme_Ydnar>() );
+#ifndef GARUX_DISABLE_GTKTHEME
+ GlobalCommands_insert( "gtkThemeDlg", makeCallbackF(gtkThemeDlg) );
+#endif
+ GlobalCommands_insert( "ColorSchemeOriginal", makeCallbackF(ColorScheme_Original) );
+ GlobalCommands_insert( "ColorSchemeQER", makeCallbackF(ColorScheme_QER) );
+ GlobalCommands_insert( "ColorSchemeBlackAndGreen", makeCallbackF(ColorScheme_Black) );
+ GlobalCommands_insert( "ColorSchemeYdnar", makeCallbackF(ColorScheme_Ydnar) );
GlobalCommands_insert( "ChooseTextureBackgroundColor", makeCallback( g_ColoursMenu.m_textureback ) );
GlobalCommands_insert( "ChooseGridBackgroundColor", makeCallback( g_ColoursMenu.m_xyback ) );
GlobalCommands_insert( "ChooseGridMajorColor", makeCallback( g_ColoursMenu.m_gridmajor ) );
GlobalCommands_insert( "ChooseClipperColor", makeCallback( g_ColoursMenu.m_clipper ) );
GlobalCommands_insert( "ChooseOrthoViewNameColor", makeCallback( g_ColoursMenu.m_viewname ) );
- GlobalCommands_insert( "Fullscreen", FreeCaller<MainFrame_toggleFullscreen>(), Accelerator( GDK_F11 ) );
- GlobalCommands_insert( "MaximizeView", FreeCaller<Maximize_View>(), Accelerator( GDK_F12 ) );
+ GlobalCommands_insert( "Fullscreen", makeCallbackF( MainFrame_toggleFullscreen ), Accelerator( GDK_F11 ) );
+ GlobalCommands_insert( "MaximizeView", makeCallbackF( Maximize_View ), Accelerator( GDK_F12 ) );
- GlobalCommands_insert( "CSGSubtract", FreeCaller<CSG_Subtract>(), Accelerator( 'U', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "CSGMerge", FreeCaller<CSG_Merge>(), Accelerator( 'U', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "CSGroom", FreeCaller<CSG_MakeRoom>() );
- GlobalCommands_insert( "CSGTool", FreeCaller<CSG_Tool>() );
+ GlobalCommands_insert( "CSGSubtract", makeCallbackF(CSG_Subtract), Accelerator( 'U', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "CSGMerge", makeCallbackF(CSG_Merge), Accelerator( 'U', (GdkModifierType) GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "CSGRoom", makeCallbackF(CSG_MakeRoom) );
+ GlobalCommands_insert( "CSGTool", makeCallbackF(CSG_Tool) );
Grid_registerCommands();
- GlobalCommands_insert( "SnapToGrid", FreeCaller<Selection_SnapToGrid>(), Accelerator( 'G', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "SnapToGrid", makeCallbackF(Selection_SnapToGrid), Accelerator( 'G', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "SelectAllOfType", FreeCaller<Select_AllOfType>(), Accelerator( 'A', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "SelectAllOfType", makeCallbackF(Select_AllOfType), Accelerator( 'A', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexRotateClock", FreeCaller<Texdef_RotateClockwise>(), Accelerator( GDK_Next, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexRotateCounter", FreeCaller<Texdef_RotateAntiClockwise>(), Accelerator( GDK_Prior, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexScaleUp", FreeCaller<Texdef_ScaleUp>(), Accelerator( GDK_Up, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "TexScaleDown", FreeCaller<Texdef_ScaleDown>(), Accelerator( GDK_Down, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "TexScaleLeft", FreeCaller<Texdef_ScaleLeft>(), Accelerator( GDK_Left, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "TexScaleRight", FreeCaller<Texdef_ScaleRight>(), Accelerator( GDK_Right, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "TexShiftUp", FreeCaller<Texdef_ShiftUp>(), Accelerator( GDK_Up, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexShiftDown", FreeCaller<Texdef_ShiftDown>(), Accelerator( GDK_Down, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexShiftLeft", FreeCaller<Texdef_ShiftLeft>(), Accelerator( GDK_Left, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexShiftRight", FreeCaller<Texdef_ShiftRight>(), Accelerator( GDK_Right, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexRotateClock", makeCallbackF(Texdef_RotateClockwise), Accelerator( GDK_KEY_Next, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexRotateCounter", makeCallbackF(Texdef_RotateAntiClockwise), Accelerator( GDK_KEY_Prior, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexScaleUp", makeCallbackF(Texdef_ScaleUp), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "TexScaleDown", makeCallbackF(Texdef_ScaleDown), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "TexScaleLeft", makeCallbackF(Texdef_ScaleLeft), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "TexScaleRight", makeCallbackF(Texdef_ScaleRight), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "TexShiftUp", makeCallbackF(Texdef_ShiftUp), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexShiftDown", makeCallbackF(Texdef_ShiftDown), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexShiftLeft", makeCallbackF(Texdef_ShiftLeft), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexShiftRight", makeCallbackF(Texdef_ShiftRight), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "MoveSelectionDOWN", FreeCaller<Selection_MoveDown>(), Accelerator( GDK_KP_Subtract ) );
- GlobalCommands_insert( "MoveSelectionUP", FreeCaller<Selection_MoveUp>(), Accelerator( GDK_KP_Add ) );
+ GlobalCommands_insert( "MoveSelectionDOWN", makeCallbackF(Selection_MoveDown), Accelerator( GDK_KEY_KP_Subtract ) );
+ GlobalCommands_insert( "MoveSelectionUP", makeCallbackF(Selection_MoveUp), Accelerator( GDK_KEY_KP_Add ) );
- GlobalCommands_insert( "SelectNudgeLeft", FreeCaller<Selection_NudgeLeft>(), Accelerator( GDK_Left, (GdkModifierType)GDK_MOD1_MASK ) );
- GlobalCommands_insert( "SelectNudgeRight", FreeCaller<Selection_NudgeRight>(), Accelerator( GDK_Right, (GdkModifierType)GDK_MOD1_MASK ) );
- GlobalCommands_insert( "SelectNudgeUp", FreeCaller<Selection_NudgeUp>(), Accelerator( GDK_Up, (GdkModifierType)GDK_MOD1_MASK ) );
- GlobalCommands_insert( "SelectNudgeDown", FreeCaller<Selection_NudgeDown>(), Accelerator( GDK_Down, (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "SelectNudgeLeft", makeCallbackF(Selection_NudgeLeft), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "SelectNudgeRight", makeCallbackF(Selection_NudgeRight), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "SelectNudgeUp", makeCallbackF(Selection_NudgeUp), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "SelectNudgeDown", makeCallbackF(Selection_NudgeDown), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_MOD1_MASK ) );
Patch_registerCommands();
XYShow_registerCommands();
- typedef FreeCaller1<const Selectable&, ComponentMode_SelectionChanged> ComponentModeSelectionChangedCaller;
+ typedef FreeCaller<void(const Selectable&), ComponentMode_SelectionChanged> ComponentModeSelectionChangedCaller;
GlobalSelectionSystem().addSelectionChangeCallback( ComponentModeSelectionChangedCaller() );
- GlobalPreferenceSystem().registerPreference( "DetachableMenus", BoolImportStringCaller( g_Layout_enableDetachableMenus.m_latched ), BoolExportStringCaller( g_Layout_enableDetachableMenus.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "MainToolBar", BoolImportStringCaller( g_Layout_enableMainToolbar.m_latched ), BoolExportStringCaller( g_Layout_enableMainToolbar.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "PatchToolBar", BoolImportStringCaller( g_Layout_enablePatchToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePatchToolbar.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "PluginToolBar", BoolImportStringCaller( g_Layout_enablePluginToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePluginToolbar.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "FilterToolBar", BoolImportStringCaller( g_Layout_enableFilterToolbar.m_latched ), BoolExportStringCaller( g_Layout_enableFilterToolbar.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", IntImportStringCaller( g_Layout_viewStyle.m_latched ), IntExportStringCaller( g_Layout_viewStyle.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "XYHeight", IntImportStringCaller( g_layout_globals.nXYHeight ), IntExportStringCaller( g_layout_globals.nXYHeight ) );
- GlobalPreferenceSystem().registerPreference( "XYWidth", IntImportStringCaller( g_layout_globals.nXYWidth ), IntExportStringCaller( g_layout_globals.nXYWidth ) );
- GlobalPreferenceSystem().registerPreference( "CamWidth", IntImportStringCaller( g_layout_globals.nCamWidth ), IntExportStringCaller( g_layout_globals.nCamWidth ) );
- GlobalPreferenceSystem().registerPreference( "CamHeight", IntImportStringCaller( g_layout_globals.nCamHeight ), IntExportStringCaller( g_layout_globals.nCamHeight ) );
-
- GlobalPreferenceSystem().registerPreference( "State", IntImportStringCaller( g_layout_globals.nState ), IntExportStringCaller( g_layout_globals.nState ) );
- GlobalPreferenceSystem().registerPreference( "PositionX", IntImportStringCaller( g_layout_globals.m_position.x ), IntExportStringCaller( g_layout_globals.m_position.x ) );
- GlobalPreferenceSystem().registerPreference( "PositionY", IntImportStringCaller( g_layout_globals.m_position.y ), IntExportStringCaller( g_layout_globals.m_position.y ) );
- GlobalPreferenceSystem().registerPreference( "Width", IntImportStringCaller( g_layout_globals.m_position.w ), IntExportStringCaller( g_layout_globals.m_position.w ) );
- GlobalPreferenceSystem().registerPreference( "Height", IntImportStringCaller( g_layout_globals.m_position.h ), IntExportStringCaller( g_layout_globals.m_position.h ) );
-
- GlobalPreferenceSystem().registerPreference( "CamWnd", WindowPositionTrackerImportStringCaller( g_posCamWnd ), WindowPositionTrackerExportStringCaller( g_posCamWnd ) );
- GlobalPreferenceSystem().registerPreference( "XYWnd", WindowPositionTrackerImportStringCaller( g_posXYWnd ), WindowPositionTrackerExportStringCaller( g_posXYWnd ) );
- GlobalPreferenceSystem().registerPreference( "YZWnd", WindowPositionTrackerImportStringCaller( g_posYZWnd ), WindowPositionTrackerExportStringCaller( g_posYZWnd ) );
- GlobalPreferenceSystem().registerPreference( "XZWnd", WindowPositionTrackerImportStringCaller( g_posXZWnd ), WindowPositionTrackerExportStringCaller( g_posXZWnd ) );
-
- GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
-
- GlobalPreferenceSystem().registerPreference( "NudgeAfterClone", BoolImportStringCaller( g_bNudgeAfterClone ), BoolExportStringCaller( g_bNudgeAfterClone ) );
+ GlobalPreferenceSystem().registerPreference( "DetachableMenus", make_property_string( g_Layout_enableDetachableMenus.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "MainToolBar", make_property_string( g_Layout_enableMainToolbar.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "PatchToolBar", make_property_string( g_Layout_enablePatchToolbar.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "PluginToolBar", make_property_string( g_Layout_enablePluginToolbar.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "FilterToolBar", make_property_string( g_Layout_enableFilterToolbar.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", make_property_string( g_Layout_viewStyle.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "XYHeight", make_property_string( g_layout_globals.nXYHeight ) );
+ GlobalPreferenceSystem().registerPreference( "XYWidth", make_property_string( g_layout_globals.nXYWidth ) );
+ GlobalPreferenceSystem().registerPreference( "CamWidth", make_property_string( g_layout_globals.nCamWidth ) );
+ GlobalPreferenceSystem().registerPreference( "CamHeight", make_property_string( g_layout_globals.nCamHeight ) );
+
+ GlobalPreferenceSystem().registerPreference( "State", make_property_string( g_layout_globals.nState ) );
+ GlobalPreferenceSystem().registerPreference( "PositionX", make_property_string( g_layout_globals.m_position.x ) );
+ GlobalPreferenceSystem().registerPreference( "PositionY", make_property_string( g_layout_globals.m_position.y ) );
+ GlobalPreferenceSystem().registerPreference( "Width", make_property_string( g_layout_globals.m_position.w ) );
+ GlobalPreferenceSystem().registerPreference( "Height", make_property_string( g_layout_globals.m_position.h ) );
+
+ GlobalPreferenceSystem().registerPreference( "CamWnd", make_property<WindowPositionTracker_String>(g_posCamWnd) );
+ GlobalPreferenceSystem().registerPreference( "XYWnd", make_property<WindowPositionTracker_String>(g_posXYWnd) );
+ GlobalPreferenceSystem().registerPreference( "YZWnd", make_property<WindowPositionTracker_String>(g_posYZWnd) );
+ GlobalPreferenceSystem().registerPreference( "XZWnd", make_property<WindowPositionTracker_String>(g_posXZWnd) );
+
+ GlobalPreferenceSystem().registerPreference( "EnginePath", make_property_string( g_strEnginePath ) );
+
+ GlobalPreferenceSystem().registerPreference( "NudgeAfterClone", make_property_string( g_bNudgeAfterClone ) );
if ( g_strEnginePath.empty() )
{
g_strEnginePath_was_empty_1st_start = true;
const char* ENGINEPATH_ATTRIBUTE =
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
"enginepath_win32"
-#elif defined( __linux__ ) || defined ( __FreeBSD__ )
- "enginepath_linux"
-#elif defined( __APPLE__ )
+#elif GDEF_OS_MACOS
"enginepath_macos"
+#elif GDEF_OS_LINUX || GDEF_OS_BSD
+ "enginepath_linux"
#else
#error "unknown platform"
#endif
StringOutputStream path( 256 );
path << DirectoryCleaned( g_pGameDescription->getRequiredKeyValue( ENGINEPATH_ATTRIBUTE ) );
g_strEnginePath = path.c_str();
- GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
+ GlobalPreferenceSystem().registerPreference( "EnginePath", make_property_string( g_strEnginePath ) );
}
+ GlobalPreferenceSystem().registerPreference( "DisableEnginePath", make_property_string( g_disableEnginePath ) );
+ GlobalPreferenceSystem().registerPreference( "DisableHomePath", make_property_string( g_disableHomePath ) );
+ for ( int i = 0; i < g_pakPathCount; i++ ) {
+ std::string label = "PakPath" + std::to_string( i );
+ GlobalPreferenceSystem().registerPreference( label.c_str(), make_property_string( g_strPakPath[i] ) );
+ }
g_Layout_viewStyle.useLatched();
g_Layout_enableDetachableMenus.useLatched();
Layout_registerPreferencesPage();
Paths_registerPreferencesPage();
- PreferencesDialog_addSettingsPreferences( FreeCaller1<PreferencesPage&, Nudge_constructPreferences>() );
+ PreferencesDialog_addSettingsPreferences( FreeCaller<void(PreferencesPage&), Nudge_constructPreferences>() );
- g_brushCount.setCountChangedCallback( FreeCaller<QE_brushCountChanged>() );
- g_entityCount.setCountChangedCallback( FreeCaller<QE_entityCountChanged>() );
+ g_brushCount.setCountChangedCallback( makeCallbackF(QE_brushCountChanged) );
+ g_entityCount.setCountChangedCallback( makeCallbackF(QE_entityCountChanged) );
GlobalEntityCreator().setCounter( &g_entityCount );
GLWidget_sharedContextCreated = GlobalGL_sharedContextCreated;
GlobalEntityClassManager().detach( g_WorldspawnColourEntityClassObserver );
GlobalEntityCreator().setCounter( 0 );
- g_entityCount.setCountChangedCallback( Callback() );
- g_brushCount.setCountChangedCallback( Callback() );
+ g_entityCount.setCountChangedCallback( Callback<void()>() );
+ g_brushCount.setCountChangedCallback( Callback<void()>() );
}
void GLWindow_Construct(){
-// GlobalPreferenceSystem().registerPreference( "MouseButtons", IntImportStringCaller( g_glwindow_globals.m_nMouseType ), IntExportStringCaller( g_glwindow_globals.m_nMouseType ) );
+// GlobalPreferenceSystem().registerPreference( "MouseButtons", make_property_string( g_glwindow_globals.m_nMouseType ) );
}
void GLWindow_Destroy(){
#if !defined( INCLUDED_MAINFRAME_H )
#define INCLUDED_MAINFRAME_H
+#include <uilib/uilib.h>
#include "gtkutil/window.h"
#include "gtkutil/idledraw.h"
#include "gtkutil/widget.h"
class CamWnd;
class ZWnd;
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
const int c_command_status = 0;
const int c_position_status = 1;
MainFrame();
~MainFrame();
-GtkWindow* m_window;
+ui::Window m_window{ui::null};
CopiedString m_command_status;
CopiedString m_position_status;
void Shutdown();
public:
-GtkWidget* m_vSplit;
-GtkWidget* m_hSplit;
-GtkWidget* m_vSplit2;
+ui::Widget m_vSplit{ui::null};
+ui::Widget m_hSplit{ui::null};
+ui::Widget m_vSplit2{ui::null};
private:
bool m_bSleeping;
-GtkWidget *m_pStatusLabel[c_count_status];
+void *m_pStatusLabel[c_count_status];
EViewStyle m_nCurrentStyle;
void SetStatusText( CopiedString& status_text, const char* pText );
void UpdateStatusText();
void RedrawStatusText();
-typedef MemberCaller<MainFrame, &MainFrame::RedrawStatusText> RedrawStatusTextCaller;
+typedef MemberCaller<MainFrame, void(), &MainFrame::RedrawStatusText> RedrawStatusTextCaller;
void SetGridStatus();
-typedef MemberCaller<MainFrame, &MainFrame::SetGridStatus> SetGridStatusCaller;
+typedef MemberCaller<MainFrame, void(), &MainFrame::SetGridStatus> SetGridStatusCaller;
void SetActiveXY( XYWnd* p );
XYWnd* ActiveXY(){
extern MainFrame* g_pParentWnd;
-GtkWindow* MainFrame_getWindow();
+ui::Window MainFrame_getWindow();
/*
enum EMouseButtonMode
{
//extern glwindow_globals_t g_glwindow_globals;
template<typename Value>
class LatchedValue;
-typedef LatchedValue<bool> LatchedBool;
-extern LatchedBool g_Layout_enableDetachableMenus;
+extern LatchedValue<bool> g_Layout_enableDetachableMenus;
void deleteSelection();
const char* EnginePath_get();
const char* QERApp_GetGamePath();
+extern bool g_disableEnginePath;
+extern bool g_disableHomePath;
+
+const int g_pakPathCount = 5;
+extern CopiedString g_strPakPath[g_pakPathCount];
+const char* PakPath_get( int num );
+
extern CopiedString g_strAppPath;
const char* AppPath_get();
void Radiant_attachGameModeObserver( ModuleObserver& observer );
void Radiant_detachGameModeObserver( ModuleObserver& observer );
-
-
+void VFS_Refresh();
+void VFS_Restart();
void VFS_Construct();
void VFS_Destroy();
MouseEventHandlerId XYWindowMouseDown_connect( const MouseEventHandler& handler );
void XYWindowMouseDown_disconnect( MouseEventHandlerId id );
-extern GtkWidget* g_page_entity;
+extern ui::Widget g_page_entity;
#endif
#include "map.h"
+#include <gtk/gtk.h>
+
#include "debugging/debugging.h"
#include "imap.h"
+
MapModules& ReferenceAPI_getMapModules();
+
#include "iselection.h"
#include "iundo.h"
#include "ibrush.h"
#include "irender.h"
#include "ientity.h"
#include "editable.h"
+#include "iarchive.h"
#include "ifilesystem.h"
#include "namespace.h"
#include "moduleobserver.h"
#include <set>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkbox.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtktreemodel.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtkliststore.h>
-#include <gtk/gtkcellrenderertext.h>
+#include <gdk/gdkkeysyms.h>
+#include "uilib/uilib.h"
#include "scenelib.h"
#include "transformlib.h"
#include "cmdlib.h"
#include "stream/textfilestream.h"
#include "os/path.h"
+#include "os/file.h"
#include "uniquenames.h"
#include "modulesystem/singletonmodule.h"
#include "modulesystem/moduleregistry.h"
#include "xywindow.h"
#include "mainframe.h"
#include "preferences.h"
+#include "preferencesystem.h"
#include "referencecache.h"
#include "mru.h"
#include "commands.h"
#include "brush.h"
#include "patch.h"
+bool g_writeMapComments = true;
+
class NameObserver
{
UniqueNames& m_names;
m_names.insert( name_read( c_str() ) );
}
}
+
void destroy(){
if ( !empty() ) {
//globalOutputStream() << "destroy " << makeQuoted(c_str()) << "\n";
}
NameObserver& operator=( const NameObserver& other );
+
public:
NameObserver( UniqueNames& names ) : m_names( names ){
construct();
NameObserver( const NameObserver& other ) : m_names( other.m_names ), m_name( other.m_name ){
construct();
}
+
~NameObserver(){
destroy();
}
+
bool empty() const {
return string_empty( c_str() );
}
+
const char* c_str() const {
return m_name.c_str();
}
+
void nameChanged( const char* name ){
destroy();
m_name = name;
construct();
}
-typedef MemberCaller1<NameObserver, const char*, &NameObserver::nameChanged> NameChangedCaller;
+
+typedef MemberCaller<NameObserver, void(const char*), &NameObserver::nameChanged> NameChangedCaller;
};
class BasicNamespace : public Namespace
~BasicNamespace(){
ASSERT_MESSAGE( m_names.empty(), "namespace: names still registered at shutdown" );
}
+
void attach( const NameCallback& setName, const NameCallbackCallback& attachObserver ){
std::pair<Names::iterator, bool> result = m_names.insert( Names::value_type( setName, m_uniqueNames ) );
ASSERT_MESSAGE( result.second, "cannot attach name" );
attachObserver( NameObserver::NameChangedCaller( ( *result.first ).second ) );
//globalOutputStream() << "attach: " << reinterpret_cast<const unsigned int&>(setName) << "\n";
}
+
void detach( const NameCallback& setName, const NameCallbackCallback& detachObserver ){
Names::iterator i = m_names.find( setName );
ASSERT_MESSAGE( i != m_names.end(), "cannot detach name" );
Namespace* m_namespace;
public:
typedef Namespace Type;
+
STRING_CONSTANT( Name, "*" );
NamespaceAPI(){
m_namespace = &g_defaultNamespace;
}
+
Namespace* getTable(){
return m_namespace;
}
WorldNode()
: m_node( 0 ){
}
+
void set( scene::Node* node ){
if ( m_node != 0 ) {
m_node->DecRef();
m_node->IncRef();
}
}
+
scene::Node* get() const {
return m_node;
}
class Map;
void Map_SetValid( Map& map, bool valid );
+
void Map_UpdateTitle( const Map& map );
+
void Map_SetWorldspawn( Map& map, scene::Node* node );
bool m_valid;
bool m_modified;
+
void ( *m_modified_changed )( const Map& );
Signal0 m_mapValidCallbacks;
Map_SetValid( g_map, true );
}
}
+
void unrealise(){
if ( m_resource != 0 ) {
Map_SetValid( g_map, false );
}
-
scene::Node* Map_GetWorldspawn( const Map& map ){
return map.m_world_node.get();
}
float g_MinWorldCoord = -64 * 1024;
void AddRegionBrushes( void );
+
void RemoveRegionBrushes( void );
EntityFindByClassname( const char* name, Entity*& entity ) : m_name( name ), m_entity( entity ){
m_entity = 0;
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( m_entity == 0 ) {
Entity* entity = Node_getEntity( path.top() );
public:
CollectAllWalker( scene::Node& root, UnsortedNodeSet& nodes ) : m_root( root ), m_nodes( nodes ){
}
+
bool pre( scene::Node& node ) const {
m_nodes.insert( NodeSmartReference( node ) );
Node_getTraversable( m_root )->erase( node );
MapMergeAll( const scene::Path& root )
: m_path( root ){
}
+
bool pre( scene::Node& node ) const {
Node_getTraversable( m_path.top() )->insert( node );
m_path.push( makeReference( node ) );
selectPath( m_path, true );
return false;
}
+
void post( scene::Node& node ) const {
m_path.pop();
}
MapMergeEntities( const scene::Path& root )
: m_path( root ){
}
+
bool pre( scene::Node& node ) const {
if ( node_is_worldspawn( node ) ) {
scene::Node* world_node = Map_FindWorldspawn( g_map );
}
return false;
}
+
void post( scene::Node& node ) const {
m_path.pop();
}
TypeCasts(){
NodeContainedCast<BasicContainer, scene::Traversable>::install( m_casts );
}
+
NodeTypeCastTable& get(){
return m_casts;
}
BasicContainer() : m_node( this, this, StaticTypeCasts::instance().get() ){
}
+
void release(){
delete this;
}
+
scene::Node& node(){
return m_node;
}
void MergeMap( scene::Node& node ){
Node_getTraversable( node )->traverse( MapMergeEntities( scene::Path( makeReference( GlobalSceneGraph().root() ) ) ) );
}
+
void Map_ImportSelected( TextInputStream& in, const MapFormat& format ){
NodeSmartReference node( ( new BasicContainer )->node() );
format.readGraph( node, in, GlobalEntityCreator() );
CloneAll( scene::Node& root )
: m_path( makeReference( root ) ){
}
+
bool pre( scene::Node& node ) const {
if ( node.isRoot() ) {
return false;
return true;
}
+
void post( scene::Node& node ) const {
if ( node.isRoot() ) {
return;
EntityBreakdownWalker( EntityBreakdown& entitymap )
: m_entitymap( entitymap ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
Entity* entity = Node_getEntity( path.top() );
if ( entity != 0 ) {
const EntityClass& eclass = entity->getEntityClass();
if ( m_entitymap.find( eclass.name() ) == m_entitymap.end() ) {
m_entitymap[eclass.name()] = 1;
+ } else
+ {
+ ++m_entitymap[eclass.name()];
}
- else{ ++m_entitymap[eclass.name()]; }
}
return true;
}
void DoMapInfo(){
ModalDialog dialog;
+ ui::Widget w_brushes{ui::null};
+ ui::Widget w_patches{ui::null};
+ ui::Widget w_ents{ui::null};
+ ui::Widget w_ents_ingame{ui::null};
+ ui::Widget w_groupents{ui::null};
+ ui::Widget w_groupents_ingame{ui::null};
- GtkWidget* w_brushes;
- GtkWidget* w_patches;
- GtkWidget* w_ents;
- GtkWidget* w_ents_ingame;
- GtkWidget* w_groupents;
- GtkWidget* w_groupents_ingame;
-
- GtkListStore* EntityBreakdownWalker;
+ ui::ListStore EntityBreakdownWalker{ui::null};
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Map Info", G_CALLBACK( dialog_delete_callback ), &dialog );
+ ui::Window window = MainFrame_getWindow().create_dialog_window("Map Info", G_CALLBACK(dialog_delete_callback ), &dialog );
window_set_position( window, g_posMapInfoWnd );
{
- GtkVBox* vbox = create_dialog_vbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) );
+ auto vbox = create_dialog_vbox( 4, 4 );
+ window.add(vbox);
{
- GtkHBox* hbox = create_dialog_hbox( 4 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, FALSE, 0 );
+ auto hbox = create_dialog_hbox( 4 );
+ vbox.pack_start( hbox, FALSE, FALSE, 0 );
{
- GtkTable* table = create_dialog_table( 3, 4, 4, 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = create_dialog_table( 3, 4, 4, 4 );
+ hbox.pack_start( table, TRUE, TRUE, 0 );
+
{
- GtkWidget* label = gtk_label_new( "Total Brushes:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Total Brushes:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
}
{
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
- gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
+ auto label = ui::Label( "" );
+ label.show();
+ table.attach(label, {1, 2, 0, 1}, {GTK_FILL | GTK_EXPAND, 0}, {3, 0});
w_brushes = label;
}
{
- GtkWidget* label = gtk_label_new( "Total Patches:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
+ auto label = ui::Label( "Total Patches" );
+ label.show();
+ table.attach(label, {2, 3, 0, 1}, {GTK_FILL, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
- gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
+ auto label = ui::Label( "" );
+ label.show();
+ table.attach(label, {3, 4, 0, 1}, {GTK_FILL, 0}, {3, 0});
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
w_patches = label;
}
{
- GtkWidget* label = gtk_label_new( "Total Entities:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Total Entities:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
}
{
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
+ auto label = ui::Label( "" );
+ label.show();
+ table.attach(label, {1, 2, 1, 2}, {GTK_FILL | GTK_EXPAND, 0}, {3, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
w_ents = label;
}
{
- GtkWidget* label = gtk_label_new( "Ingame Entities:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Ingame Entities:" );
+ label.show();
+ table.attach(label, {2, 3, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
}
{
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 1, 2,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
+ auto label = ui::Label( "" );
+ label.show();
+ table.attach(label, {3, 4, 1, 2}, {GTK_FILL | GTK_EXPAND, 0 }, {3, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
w_ents_ingame = label;
}
{
- GtkWidget* label = gtk_label_new( "Group Entities:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Group Entities:" );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
}
{
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
+ auto label = ui::Label( "" );
+ label.show();
+ table.attach(label, {1, 2, 2, 3}, {GTK_FILL | GTK_EXPAND, 0}, {3, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
w_groupents = label;
}
{
- GtkWidget* label = gtk_label_new( "Ingame Group Entities:" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Ingame Group Entities:" );
+ label.show();
+ table.attach(label, {2, 3, 2, 3}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
}
{
- GtkWidget* label = gtk_label_new( "" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 2, 3,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 3, 0 );
+ auto label = ui::Label( "" );
+ label.show();
+ table.attach(label, {3, 4, 2, 3}, {GTK_FILL | GTK_EXPAND, 0}, {3, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 );
w_groupents_ingame = label;
}
}
{
- GtkVBox* vbox2 = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), FALSE, FALSE, 0 );
+ auto vbox2 = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox2, FALSE, FALSE, 0 );
{
- GtkButton* button = create_dialog_button( "Close", G_CALLBACK( dialog_button_ok ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Close", G_CALLBACK( dialog_button_ok ), &dialog );
+ vbox2.pack_start( button, FALSE, FALSE, 0 );
}
}
}
{
- GtkWidget* label = gtk_label_new( "*** Entity breakdown ***" );
- gtk_widget_show( label );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, TRUE, 0 );
- gtk_misc_set_alignment( GTK_MISC( label ), 0.5, 0.5 );
+ ui::Widget label = ui::Label( "*** Entity breakdown ***" );
+ label.show();
+ vbox.pack_start( label, FALSE, TRUE, 0 );
+ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( scr ), TRUE, TRUE, 0 );
+ auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
+ vbox.pack_start( scr, TRUE, TRUE, 0 );
{
- GtkListStore* store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_UINT );
+ auto store = ui::ListStore::from(gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_UINT ));
- GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) );
- gtk_tree_view_set_headers_clickable( GTK_TREE_VIEW( view ), TRUE );
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
+ gtk_tree_view_set_headers_clickable(view, TRUE );
{
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Entity", renderer, "text", 0, 0 );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "Entity", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
gtk_tree_view_column_set_sort_column_id( column, 0 );
}
{
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Count", renderer, "text", 1, 0 );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "Count", renderer, {{"text", 1}} );
+ gtk_tree_view_append_column(view, column );
gtk_tree_view_column_set_sort_column_id( column, 1 );
}
- gtk_widget_show( view );
+ view.show();
- gtk_container_add( GTK_CONTAINER( scr ), view );
+ scr.add(view);
EntityBreakdownWalker = store;
}
for ( EntityBreakdown::iterator i = entitymap.begin(); i != entitymap.end(); ++i )
{
- GtkTreeIter iter;
- gtk_list_store_append( GTK_LIST_STORE( EntityBreakdownWalker ), &iter );
- gtk_list_store_set( GTK_LIST_STORE( EntityBreakdownWalker ), &iter, 0, ( *i ).first.c_str(), 1, Unsigned( ( *i ).second ), -1 );
+ char tmp[16];
+ sprintf( tmp, "%u", Unsigned( ( *i ).second ) );
+ EntityBreakdownWalker.append(0, (*i).first.c_str(), 1, tmp);
}
}
- g_object_unref( G_OBJECT( EntityBreakdownWalker ) );
+ EntityBreakdownWalker.unref();
int n_patches = 0;
int n_ents_ingame = 0;
gtk_label_set_markup( GTK_LABEL( w_groupents_ingame ), markup );
g_free( markup );
+
modal_dialog_show( window, dialog );
// save before exit
window_get_position( window, g_posMapInfoWnd );
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
}
: m_message( message ){
m_timer.start();
}
+
~ScopeTimer(){
double elapsed_time = m_timer.elapsed_msec() / 1000.f;
globalOutputStream() << m_message << " timer: " << FloatFormat( elapsed_time, 5, 2 ) << " second(s) elapsed\n";
}
};
+CopiedString g_strLastMapFolder = "";
+
/*
================
Map_LoadFile
*/
void Map_LoadFile( const char *filename ){
+ g_map.m_name = filename;
+
+ // refresh VFS to apply new pak filtering based on mapname
+ // needed for daemon DPK VFS
+ VFS_Refresh();
+
globalOutputStream() << "Loading map from " << filename << "\n";
ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Map" );
+ MRU_AddFile( filename );
+ g_strLastMapFolder = g_path_get_dirname( filename );
+
{
ScopeTimer timer( "map load" );
Map_Free();
}
Brush_toggleFormat( i );
- g_map.m_name = filename;
Map_UpdateTitle( g_map );
+
g_map.m_resource = GlobalReferenceCache().capture( g_map.m_name.c_str() );
if ( format ) {
format->wrongFormat = false;
ExcludeWalker( const scene::Traversable::Walker& walker, const Excluder& exclude )
: m_walker( walker ), m_exclude( &exclude ), m_skip( false ){
}
+
bool pre( scene::Node& node ) const {
if ( m_exclude->excluded( node ) || node.isRoot() ) {
m_skip = true;
}
return true;
}
+
void post( scene::Node& node ) const {
if ( m_skip ) {
m_skip = false;
AnyInstanceSelected( bool& selected ) : m_selected( selected ){
m_selected = false;
}
+
void visit( scene::Instance& instance ) const {
Selectable* selectable = Instance_getSelectable( instance );
if ( selectable != 0
bool selectedParent() const {
return m_selected != 0;
}
+
public:
IncludeSelectedWalker( const scene::Traversable::Walker& walker )
: m_walker( walker ), m_selected( 0 ), m_skip( false ){
}
+
bool pre( scene::Node& node ) const {
// include node if:
// node is not a 'root' AND ( node is selected OR any child of node is selected OR any parent of node is selected )
return false;
}
}
+
void post( scene::Node& node ) const {
if ( m_skip ) {
m_skip = false;
}
void Map_ExportSelected( TextOutputStream& out, const MapFormat& format ){
- format.writeGraph( GlobalSceneGraph().root(), Map_Traverse_Selected, out );
+ format.writeGraph( GlobalSceneGraph().root(), Map_Traverse_Selected, out, g_writeMapComments );
}
void Map_Traverse( scene::Node& root, const scene::Traversable::Walker& walker ){
Map_UpdateTitle( g_map );
g_map.m_resource->attach( g_map );
+ // refresh VFS to apply new pak filtering based on mapname
+ // needed for daemon DPK VFS
+ VFS_Refresh();
}
void Map_Rename( const char* filename ){
FocusViews( g_vector3_identity, 0 );
g_currentMap = &g_map;
+
+ // restart VFS to apply new pak filtering based on mapname
+ // needed for daemon DPK VFS
+ VFS_Restart();
}
extern void ConstructRegionBrushes( scene::Node * brushes[6], const Vector3 ®ion_mins, const Vector3 ®ion_maxs );
*/
bool region_active = false;
-BoolExportCaller g_region_caller( region_active );
+ConstReferenceCaller<bool, void(const Callback<void(bool)> &), PropertyImpl<bool>::Export> g_region_caller( region_active );
+
ToggleItem g_region_item( g_region_caller );
+/*void Map_ToggleRegion(){
+ region_active = !region_active;
+ g_region_item.update();
+}*/
+
Vector3 region_mins( g_MinWorldCoord, g_MinWorldCoord, g_MinWorldCoord );
Vector3 region_maxs( g_MaxWorldCoord, g_MaxWorldCoord, g_MaxWorldCoord );
ExcludeAllWalker( bool exclude )
: m_exclude( exclude ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
exclude_node( path.top(), m_exclude );
ExcludeSelectedWalker( bool exclude )
: m_exclude( exclude ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
exclude_node( path.top(), ( instance.isSelected() || instance.childSelected() || instance.parentSelected() ) == m_exclude );
return true;
ExcludeRegionedWalker( bool exclude )
: m_exclude( exclude ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
exclude_node(
path.top(),
bool Map_ImportFile( const char* filename ){
ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Map" );
+ g_strLastMapFolder = g_path_get_dirname( filename );
+
bool success = false;
if ( extension_equal( path_get_extension( filename ), "bsp" ) ) {
output.push_string( EnginePath_get() );
output.push_string( "\" -fs_homepath \"" );
output.push_string( g_qeglobals.m_userEnginePath.c_str() );
- output.push_string( "\" -fs_game " );
+ output.push_string( "\"" );
+
+ // extra pakpaths
+ for ( int i = 0; i < g_pakPathCount; i++ ) {
+ if ( g_strcmp0( g_strPakPath[i].c_str(), "") ) {
+ output.push_string( " -fs_pakpath \"" );
+ output.push_string( g_strPakPath[i].c_str() );
+ output.push_string( "\"" );
+ }
+ }
+
+ // extra switches
+ if ( g_disableEnginePath ) {
+ output.push_string( " -fs_nobasepath " );
+ }
+
+ if ( g_disableHomePath ) {
+ output.push_string( " -fs_nohomepath " );
+ }
+
+ output.push_string( " -fs_game " );
output.push_string( gamename_get() );
output.push_string( " -convert -format " );
output.push_string( Brush::m_type == eBrushTypeQuake3BP ? "map_bp" : "map" );
*/
bool Map_SaveFile( const char* filename ){
ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Saving Map" );
- return MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse, filename );
+ bool success = MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse, filename );
+ if ( success ) {
+ // refresh VFS to apply new pak filtering based on mapname
+ // needed for daemon DPK VFS
+ VFS_Refresh();
+ }
+ return success;
}
//
public:
ParentSelectedBrushesToEntityWalker( scene::Node& parent ) : m_parent( parent ), m_emptyOldParent( false ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get_pointer() != &m_parent && ( Node_isPrimitive( path.top() ) || m_emptyOldParent ) ) {
Selectable* selectable = Instance_getSelectable( instance );
}
return true;
}
+
void post( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get_pointer() == &m_parent )
return;
CountSelectedBrushes( std::size_t& count ) : m_count( count ), m_depth( 0 ){
m_count = 0;
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( ++m_depth != 1 && path.top().get().isRoot() ) {
return false;
}
return true;
}
+
void post( const scene::Path& path, scene::Instance& instance ) const {
--m_depth;
}
public:
ParentSelectedBrushesToEntityWalker( const scene::Path& parent ) : m_parent( parent ){
}
+
void visit( scene::Instance& instance ) const {
if ( &m_parent != &instance.path() ) {
Path_parent( m_parent, instance.path() );
}
-
void NewMap(){
if ( ConfirmModified( "New Map" ) ) {
Map_RegionOff();
return g_mapsPath.c_str();
}
+const char* getLastMapFolderPath(){
+ if (g_strLastMapFolder.empty()) {
+ GlobalPreferenceSystem().registerPreference( "LastMapFolder", make_property_string( g_strLastMapFolder ) );
+ if (g_strLastMapFolder.empty()) {
+ StringOutputStream buffer( 1024 );
+ buffer << getMapsPath();
+ if ( !file_readable( buffer.c_str() ) ) {
+ buffer.clear();
+ buffer << g_qeglobals.m_userGamePath.c_str() << "/";
+ }
+ g_strLastMapFolder = buffer.c_str();
+ }
+ }
+ return g_strLastMapFolder.c_str();
+}
+
const char* map_open( const char* title ){
- return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getMapsPath(), MapFormat::Name(), true, false, false );
+ return MainFrame_getWindow().file_dialog( TRUE, title, getLastMapFolderPath(), MapFormat::Name(), true, false, false );
}
const char* map_import( const char* title ){
- return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getMapsPath(), MapFormat::Name(), false, true, false );
+ return MainFrame_getWindow().file_dialog( TRUE, title, getLastMapFolderPath(), MapFormat::Name(), false, true, false );
}
const char* map_save( const char* title ){
- return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, title, getMapsPath(), MapFormat::Name(), false, false, true );
+ return MainFrame_getWindow().file_dialog( FALSE, title, getLastMapFolderPath(), MapFormat::Name(), false, false, true );
}
void OpenMap(){
const char* filename = map_open( "Open Map" );
- if ( filename != 0 ) {
+ if ( filename != NULL ) {
MRU_AddFile( filename );
Map_RegionOff();
Map_Free();
void ImportMap(){
const char* filename = map_import( "Import Map" );
- if ( filename != 0 ) {
+ if ( filename != NULL ) {
UndoableCommand undo( "mapImport" );
Map_ImportFile( filename );
}
bool Map_SaveAs(){
const char* filename = map_save( "Save Map" );
- if ( filename != 0 ) {
+ if ( filename != NULL ) {
+ g_strLastMapFolder = g_path_get_dirname( filename );
MRU_AddFile( filename );
Map_Rename( filename );
return Map_Save();
void ExportMap(){
const char* filename = map_save( "Export Selection" );
- if ( filename != 0 ) {
+ if ( filename != NULL ) {
+ g_strLastMapFolder = g_path_get_dirname( filename );
Map_SaveSelected( filename );
}
}
void SaveRegion(){
const char* filename = map_save( "Export Region" );
- if ( filename != 0 ) {
+ if ( filename != NULL ) {
+ g_strLastMapFolder = g_path_get_dirname( filename );
Map_SaveRegion( filename );
}
}
BrushFindByIndexWalker( std::size_t index, scene::Path& path )
: m_index( index ), m_path( path ){
}
+
bool pre( scene::Node& node ) const {
if ( Node_isPrimitive( node ) && m_index-- == 0 ) {
m_path.push( makeReference( node ) );
EntityFindByIndexWalker( std::size_t index, scene::Path& path )
: m_index( index ), m_path( path ){
}
+
bool pre( scene::Node& node ) const {
if ( Node_isEntity( node ) && m_index-- == 0 ) {
m_path.push( makeReference( node ) );
BrushFindIndexWalker( const scene::Node& node, std::size_t& count )
: m_node( &node ), m_count( count ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( Node_isPrimitive( path.top() ) ) {
if ( m_node == path.top().get_pointer() ) {
EntityFindIndexWalker( const scene::Node& node, std::size_t& count )
: m_node( &node ), m_count( count ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( Node_isEntity( path.top() ) ) {
if ( m_node == path.top().get_pointer() ) {
void DoFind(){
ModalDialog dialog;
- GtkEntry* entity;
- GtkEntry* brush;
+ ui::Entry entity{ui::null};
+ ui::Entry brush{ui::null};
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Find Brush", G_CALLBACK( dialog_delete_callback ), &dialog );
+ ui::Window window = MainFrame_getWindow().create_dialog_window("Find Brush", G_CALLBACK(dialog_delete_callback ), &dialog );
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel );
{
- GtkVBox* vbox = create_dialog_vbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) );
+ auto vbox = create_dialog_vbox( 4, 4 );
+ window.add(vbox);
{
- GtkTable* table = create_dialog_table( 2, 2, 4, 4 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = create_dialog_table( 2, 2, 4, 4 );
+ vbox.pack_start( table, TRUE, TRUE, 0 );
{
- GtkWidget* label = gtk_label_new( "Entity number" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( "Entity number" );
+ label.show();
+ (table).attach(label, {0, 1, 0, 1}, {0, 0});
}
{
- GtkWidget* label = gtk_label_new( "Brush number" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( "Brush number" );
+ label.show();
+ (table).attach(label, {0, 1, 1, 2}, {0, 0});
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_grab_focus( GTK_WIDGET( entry ) );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ gtk_widget_grab_focus( entry );
entity = entry;
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
brush = entry;
}
}
{
- GtkHBox* hbox = create_dialog_hbox( 4 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), TRUE, TRUE, 0 );
+ auto hbox = create_dialog_hbox( 4 );
+ vbox.pack_start( hbox, TRUE, TRUE, 0 );
{
- GtkButton* button = create_dialog_button( "Find", G_CALLBACK( dialog_button_ok ), &dialog );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Find", G_CALLBACK( dialog_button_ok ), &dialog );
+ hbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Close", G_CALLBACK( dialog_button_cancel ), &dialog );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Close", G_CALLBACK( dialog_button_cancel ), &dialog );
+ hbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
}
}
GetSelectionIndex( &ent, &br );
sprintf( buf, "%i", ent );
- gtk_entry_set_text( entity, buf );
+ entity.text(buf);
sprintf( buf, "%i", br );
- gtk_entry_set_text( brush, buf );
+ brush.text(buf);
if ( modal_dialog_show( window, dialog ) == eIDOK ) {
const char *entstr = gtk_entry_get_text( entity );
SelectBrush( atoi( entstr ), atoi( brushstr ) );
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
}
void Map_constructPreferences( PreferencesPage& page ){
page.appendCheckBox( "", "Load last map at startup", g_bLoadLastMap );
+ page.appendCheckBox( "", "Add entity and brush number comments on map write", g_writeMapComments );
}
public:
MapEntityClasses() : m_unrealised( 1 ){
}
+
void realise(){
if ( --m_unrealised == 0 ) {
if ( g_map.m_resource != 0 ) {
}
}
}
+
void unrealise(){
if ( ++m_unrealised == 1 ) {
if ( g_map.m_resource != 0 ) {
public:
MapModuleObserver() : m_unrealised( 1 ){
}
+
void realise(){
if ( --m_unrealised == 0 ) {
ASSERT_MESSAGE( !string_empty( g_qeglobals.m_userGamePath.c_str() ), "maps_directory: user-game-path is empty" );
g_mapsPath = buffer.c_str();
}
}
+
void unrealise(){
if ( ++m_unrealised == 1 ) {
g_mapsPath = "";
MapModuleObserver g_MapModuleObserver;
-#include "preferencesystem.h"
-
CopiedString g_strLastMap;
bool g_bLoadLastMap = false;
void Map_Construct(){
- GlobalCommands_insert( "RegionOff", FreeCaller<RegionOff>() );
- GlobalCommands_insert( "RegionSetXY", FreeCaller<RegionXY>() );
- GlobalCommands_insert( "RegionSetBrush", FreeCaller<RegionBrush>() );
- //GlobalCommands_insert( "RegionSetSelection", FreeCaller<RegionSelected>(), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalToggles_insert( "RegionSetSelection", FreeCaller<RegionSelected>(), ToggleItem::AddCallbackCaller( g_region_item ), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
-
- GlobalPreferenceSystem().registerPreference( "LastMap", CopiedStringImportStringCaller( g_strLastMap ), CopiedStringExportStringCaller( g_strLastMap ) );
- GlobalPreferenceSystem().registerPreference( "LoadLastMap", BoolImportStringCaller( g_bLoadLastMap ), BoolExportStringCaller( g_bLoadLastMap ) );
- GlobalPreferenceSystem().registerPreference( "MapInfoDlg", WindowPositionImportStringCaller( g_posMapInfoWnd ), WindowPositionExportStringCaller( g_posMapInfoWnd ) );
-
- PreferencesDialog_addSettingsPreferences( FreeCaller1<PreferencesPage&, Map_constructPreferences>() );
+ GlobalCommands_insert( "RegionOff", makeCallbackF(RegionOff) );
+ GlobalCommands_insert( "RegionSetXY", makeCallbackF(RegionXY) );
+ GlobalCommands_insert( "RegionSetBrush", makeCallbackF(RegionBrush) );
+ //GlobalCommands_insert( "RegionSetSelection", makeCallbackF(RegionSelected), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalToggles_insert( "RegionSetSelection", makeCallbackF(RegionSelected), ToggleItem::AddCallbackCaller( g_region_item ), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+
+ GlobalPreferenceSystem().registerPreference( "LastMap", make_property_string( g_strLastMap ) );
+ GlobalPreferenceSystem().registerPreference( "LoadLastMap", make_property_string( g_bLoadLastMap ) );
+ GlobalPreferenceSystem().registerPreference( "MapInfoDlg", make_property<WindowPosition_String>( g_posMapInfoWnd ) );
+ GlobalPreferenceSystem().registerPreference( "WriteMapComments", make_property_string( g_writeMapComments ) );
+
+ PreferencesDialog_addSettingsPreferences( makeCallbackF(Map_constructPreferences) );
GlobalEntityClassManager().attach( g_MapEntityClasses );
Radiant_attachHomePathsObserver( g_MapModuleObserver );
class DeferredDraw
{
-Callback m_draw;
+Callback<void()> m_draw;
bool m_defer;
bool m_deferred;
public:
-DeferredDraw( const Callback& draw ) : m_draw( draw ), m_defer( false ), m_deferred( false ){
+DeferredDraw( const Callback<void()>& draw ) : m_draw( draw ), m_defer( false ), m_deferred( false ){
}
void defer(){
m_defer = true;
self.defer();
}
}
-typedef ReferenceCaller<DeferredDraw, DeferredDraw_onMapValidChanged> DeferredDrawOnMapValidChangedCaller;
+typedef ReferenceCaller<DeferredDraw, void(), DeferredDraw_onMapValidChanged> DeferredDrawOnMapValidChangedCaller;
#include <string.h>
#include <stdio.h>
-#include <gtk/gtklabel.h>
+#include <gtk/gtk.h>
#include "os/file.h"
#include "generic/callback.h"
MRU_SetText( i, MRU_GetText( i - 1 ) );
MRU_SetText( 0, str );
- gtk_widget_set_sensitive( GTK_WIDGET( MRU_items[0] ), TRUE );
- gtk_widget_show( GTK_WIDGET( MRU_items[MRU_used - 1] ) );
+ gtk_widget_set_sensitive( ui::MenuItem::from(MRU_items[0]) , TRUE );
+ ui::MenuItem::from(MRU_items[MRU_used - 1] ).show();
}
void MRU_Init(){
}
}
-void MRU_AddWidget( GtkMenuItem *widget, std::size_t pos ){
+void MRU_AddWidget( ui::MenuItem widget, std::size_t pos ){
if ( pos < MRU_MAX ) {
MRU_items[pos] = widget;
if ( pos < MRU_used ) {
MRU_updateWidget( pos, MRU_GetText( pos ) );
- gtk_widget_set_sensitive( GTK_WIDGET( MRU_items[0] ), TRUE );
- gtk_widget_show( GTK_WIDGET( MRU_items[pos] ) );
+ gtk_widget_set_sensitive( ui::MenuItem::from(MRU_items[0]) , TRUE );
+ ui::MenuItem::from(MRU_items[pos]).show();
}
}
}
MRU_SetText( i, MRU_GetText( i + 1 ) );
if ( MRU_used == 0 ) {
- gtk_label_set_text( GTK_LABEL( GTK_BIN( MRU_items[0] )->child ), "Recent Files" );
- gtk_widget_set_sensitive( GTK_WIDGET( MRU_items[0] ), FALSE );
+ auto label = ui::Label::from(gtk_bin_get_child(GTK_BIN(MRU_items[0] )) );
+ label.text("Recent Files");
+ gtk_widget_set_sensitive( ui::MenuItem::from(MRU_items[0]), FALSE );
}
else
{
- gtk_widget_hide( GTK_WIDGET( MRU_items[MRU_used] ) );
+ ui::MenuItem::from(MRU_items[MRU_used]).hide();
}
}
}
}
};
-typedef MemberCaller<LoadMRU, &LoadMRU::load> LoadMRUCaller;
+typedef MemberCaller<LoadMRU, void(), &LoadMRU::load> LoadMRUCaller;
LoadMRU g_load_mru1( 1 );
LoadMRU g_load_mru2( 2 );
LoadMRU g_load_mru8( 8 );
LoadMRU g_load_mru9( 9 );
-void MRU_constructMenu( GtkMenu* menu ){
+void MRU_constructMenu( ui::Menu menu ){
{
- GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_1", LoadMRUCaller( g_load_mru1 ) );
- gtk_widget_set_sensitive( GTK_WIDGET( item ), FALSE );
+ auto item = create_menu_item_with_mnemonic( menu, "_1", LoadMRUCaller( g_load_mru1 ) );
+ gtk_widget_set_sensitive( item , FALSE );
MRU_AddWidget( item, 0 );
}
{
- GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_2", LoadMRUCaller( g_load_mru2 ) );
- gtk_widget_hide( GTK_WIDGET( item ) );
+ auto item = create_menu_item_with_mnemonic( menu, "_2", LoadMRUCaller( g_load_mru2 ) );
+ item.hide();
MRU_AddWidget( item, 1 );
}
{
- GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_3", LoadMRUCaller( g_load_mru3 ) );
- gtk_widget_hide( GTK_WIDGET( item ) );
+ auto item = create_menu_item_with_mnemonic( menu, "_3", LoadMRUCaller( g_load_mru3 ) );
+ item.hide();
MRU_AddWidget( item, 2 );
}
{
- GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_4", LoadMRUCaller( g_load_mru4 ) );
- gtk_widget_hide( GTK_WIDGET( item ) );
+ auto item = create_menu_item_with_mnemonic( menu, "_4", LoadMRUCaller( g_load_mru4 ) );
+ item.hide();
MRU_AddWidget( item, 3 );
}
- {
- GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_5", LoadMRUCaller( g_load_mru5 ) );
- gtk_widget_hide( GTK_WIDGET( item ) );
+ {
+ auto item = create_menu_item_with_mnemonic( menu, "_5", LoadMRUCaller( g_load_mru5 ) );
+ item.hide();
MRU_AddWidget( item, 4 );
}
{
- GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_6", LoadMRUCaller( g_load_mru6 ) );
- gtk_widget_hide( GTK_WIDGET( item ) );
+ auto item = create_menu_item_with_mnemonic( menu, "_6", LoadMRUCaller( g_load_mru6 ) );
+ item.hide();
MRU_AddWidget( item, 5 );
}
{
- GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_7", LoadMRUCaller( g_load_mru7 ) );
- gtk_widget_hide( GTK_WIDGET( item ) );
+ auto item = create_menu_item_with_mnemonic( menu, "_7", LoadMRUCaller( g_load_mru7 ) );
+ item.hide();
MRU_AddWidget( item, 6 );
}
- {
- GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_8", LoadMRUCaller( g_load_mru8 ) );
- gtk_widget_hide( GTK_WIDGET( item ) );
+ {
+ auto item = create_menu_item_with_mnemonic( menu, "_8", LoadMRUCaller( g_load_mru8 ) );
+ item.hide();
MRU_AddWidget( item, 7 );
}
{
- GtkMenuItem* item = create_menu_item_with_mnemonic( menu, "_9", LoadMRUCaller( g_load_mru9 ) );
- gtk_widget_hide( GTK_WIDGET( item ) );
+ auto item = create_menu_item_with_mnemonic( menu, "_9", LoadMRUCaller( g_load_mru9 ) );
+ item.hide();
MRU_AddWidget( item, 8 );
}
}
#include "stringio.h"
void MRU_Construct(){
- GlobalPreferenceSystem().registerPreference( "Count", SizeImportStringCaller( MRU_used ), SizeExportStringCaller( MRU_used ) );
+ GlobalPreferenceSystem().registerPreference( "Count", make_property_string( MRU_used ) );
for ( std::size_t i = 0; i != MRU_MAX; ++i )
{
- GlobalPreferenceSystem().registerPreference( MRU_keys[i], CopiedStringImportStringCaller( MRU_filenames[i] ), CopiedStringExportStringCaller( MRU_filenames[i] ) );
+ GlobalPreferenceSystem().registerPreference( MRU_keys[i], make_property_string( MRU_filenames[i] ) );
}
MRU_Init();
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_MRU_H )
#define INCLUDED_MRU_H
void MRU_AddFile( const char *str );
-typedef struct _GtkMenu GtkMenu;
-void MRU_constructMenu( GtkMenu* menu );
+void MRU_constructMenu( ui::Menu menu );
void MRU_Construct();
void MRU_Destroy();
multimon_globals_t g_multimon_globals;
-//LatchedBool g_Multimon_enableSysMenuPopups( false, "Floating windows sysmenu icons" );
+//LatchedValue<bool> g_Multimon_enableSysMenuPopups( false, "Floating windows sysmenu icons" );
void MultiMonitor_constructPreferences( PreferencesPage& page ){
- GtkWidget* primary_monitor = page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon );
-// GtkWidget* popup = page.appendCheckBox(
+ ui::CheckButton primary_monitor = page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon );
+// ui::CheckButton popup = page.appendCheckBox(
// "", "Disable system menu on popup windows",
-// LatchedBoolImportCaller( g_Multimon_enableSysMenuPopups ),
-// BoolExportCaller( g_Multimon_enableSysMenuPopups.m_latched )
+// mkImportExportCallback( g_Multimon_enableSysMenuPopups )
// );
// Widget_connectToggleDependency( popup, primary_monitor );
}
#include "preferencesystem.h"
#include "stringio.h"
-#include <gdk/gdkdisplay.h>
+#include <gdk/gdk.h>
namespace
{
g_multimon_globals.m_bStartOnPrimMon = true;
}
- GlobalPreferenceSystem().registerPreference( "StartOnPrimMon", BoolImportStringCaller( g_multimon_globals.m_bStartOnPrimMon ), BoolExportStringCaller( g_multimon_globals.m_bStartOnPrimMon ) );
-// GlobalPreferenceSystem().registerPreference( "NoSysMenuPopups", BoolImportStringCaller( g_Multimon_enableSysMenuPopups.m_latched ), BoolExportStringCaller( g_Multimon_enableSysMenuPopups.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "StartOnPrimMon", make_property_string( g_multimon_globals.m_bStartOnPrimMon ) );
+// GlobalPreferenceSystem().registerPreference( "NoSysMenuPopups", make_property_string( g_Multimon_enableSysMenuPopups.m_latched ) );
// g_Multimon_enableSysMenuPopups.useLatched();
- PreferencesDialog_addInterfacePreferences( FreeCaller1<PreferencesPage&, MultiMonitor_constructPreferences>() );
+ PreferencesDialog_addInterfacePreferences( makeCallbackF(MultiMonitor_constructPreferences) );
}
+
void MultiMon_Destroy(){
}
#if !defined( INCLUDED_MULTIMON_H )
#define INCLUDED_MULTIMON_H
+#include "globaldefs.h"
+
struct WindowPosition;
void PositionWindowOnPrimaryScreen( WindowPosition& position );
extern multimon_globals_t g_multimon_globals;
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
void MultiMon_Construct();
void MultiMon_Destroy();
#else
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#define _USE_MATH_DEFINES
#include "patch.h"
#include <glib.h>
// vPos[1] = aabb.origin;
// vPos[2] = vector3_added(aabb.origin, aabb.extents);
- int i, j;
float f = 1 / cos( M_PI / n );
- for ( i = 0; i < width; ++i )
+ for ( std::size_t i = 0; i < width; ++i )
{
float angle = ( M_PI * i ) / n; // 0 to 2pi
float x = vPos[1][0] + ( vPos[2][0] - vPos[1][0] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f );
float y = vPos[1][1] + ( vPos[2][1] - vPos[1][1] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f );
- for ( j = 0; j < height; ++j )
+ for ( std::size_t j = 0; j < height; ++j )
{
float z = vPos[0][2] + ( vPos[2][2] - vPos[0][2] ) * ( j / (float)( height - 1 ) );
PatchControl *v;
// vPos[1] = aabb.origin;
// vPos[2] = vector3_added(aabb.origin, aabb.extents);
- int i, j;
float f = 1 / cos( M_PI / n );
- for ( i = 0; i < width; ++i )
+ for ( std::size_t i = 0; i < width; ++i )
{
float angle = ( M_PI * i ) / n;
- for ( j = 0; j < height; ++j )
+ for ( std::size_t j = 0; j < height; ++j )
{
float x = vPos[1][0] + ( 1.0f - ( j / (float)( height - 1 ) ) ) * ( vPos[2][0] - vPos[1][0] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f );
float y = vPos[1][1] + ( 1.0f - ( j / (float)( height - 1 ) ) ) * ( vPos[2][1] - vPos[1][1] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f );
// vPos[1] = aabb.origin;
// vPos[2] = vector3_added(aabb.origin, aabb.extents);
- int i, j;
float f = 1 / cos( M_PI / n );
float g = 1 / cos( M_PI / ( 2 * m ) );
- for ( i = 0; i < width; ++i )
+ for ( std::size_t i = 0; i < width; ++i )
{
float angle = ( M_PI * i ) / n;
- for ( j = 0; j < height; ++j )
+ for ( std::size_t j = 0; j < height; ++j )
{
float angle2 = ( M_PI * j ) / ( 2 * m );
float x = vPos[1][0] + ( vPos[2][0] - vPos[1][0] ) * sin( angle2 ) * ( ( j & 1 ) ? g : 1.0f ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f );
glEnd();
}
-#define DEGEN_0a 0x01
-#define DEGEN_1a 0x02
-#define DEGEN_2a 0x04
-#define DEGEN_0b 0x08
-#define DEGEN_1b 0x10
-#define DEGEN_2b 0x20
-#define SPLIT 0x40
-#define AVERAGE 0x80
+const int DEGEN_0a = 0x01;
+const int DEGEN_1a = 0x02;
+const int DEGEN_2a = 0x04;
+const int DEGEN_0b = 0x08;
+const int DEGEN_1b = 0x10;
+const int DEGEN_2b = 0x20;
+const int SPLIT = 0x40;
+const int AVERAGE = 0x80;
unsigned int subarray_get_degen( PatchControlIter subarray, std::size_t strideU, std::size_t strideV ){
/// The surface is recursively tesselated until the angle between each triangle
/// edge is smaller than a specified tolerance.
-
+#include "globaldefs.h"
#include "nameable.h"
#include "ifilter.h"
#include "imap.h"
}
}
-#if defined( _DEBUG )
+#if GDEF_DEBUG
RenderNormals();
#endif
}
bool m_bOverlay;
bool m_transformChanged;
-Callback m_evaluateTransform;
-Callback m_boundsChanged;
+Callback<void()> m_evaluateTransform;
+Callback<void()> m_boundsChanged;
void construct(){
m_bOverlay = false;
}
public:
-Callback m_lightsChanged;
+Callback<void()> m_lightsChanged;
static int m_CycleCapIndex; // = 0;
static EPatchType m_type;
STRING_CONSTANT( Name, "Patch" );
-Patch( scene::Node& node, const Callback& evaluateTransform, const Callback& boundsChanged ) :
+Patch( scene::Node& node, const Callback<void()>& evaluateTransform, const Callback<void()>& boundsChanged ) :
m_node( &node ),
m_shader( texdef_name_default() ),
m_state( 0 ),
m_boundsChanged( boundsChanged ){
construct();
}
-Patch( const Patch& other, scene::Node& node, const Callback& evaluateTransform, const Callback& boundsChanged ) :
+Patch( const Patch& other, scene::Node& node, const Callback<void()>& evaluateTransform, const Callback<void()>& boundsChanged ) :
m_node( &node ),
m_shader( texdef_name_default() ),
m_state( 0 ),
m_lightsChanged();
SceneChangeNotify();
}
-typedef MemberCaller<Patch, &Patch::transformChanged> TransformChangedCaller;
+typedef MemberCaller<Patch, void(), &Patch::transformChanged> TransformChangedCaller;
void evaluateTransform(){
if ( m_transformChanged ) {
void lightsChanged(){
m_lightList->lightsChanged();
}
-typedef MemberCaller<PatchInstance, &PatchInstance::lightsChanged> LightsChangedCaller;
+typedef MemberCaller<PatchInstance, void(), &PatchInstance::lightsChanged> LightsChangedCaller;
STRING_CONSTANT( Name, "PatchInstance" );
Instance::setTransformChangedCallback( LightsChangedCaller( *this ) );
}
~PatchInstance(){
- Instance::setTransformChangedCallback( Callback() );
+ Instance::setTransformChangedCallback( Callback<void()>() );
- m_patch.m_lightsChanged = Callback();
+ m_patch.m_lightsChanged = Callback<void()>();
GlobalShaderCache().detach( *this );
m_patch.detach( this );
Instance::selectedChanged();
}
-typedef MemberCaller1<PatchInstance, const Selectable&, &PatchInstance::selectedChanged> SelectedChangedCaller;
+typedef MemberCaller<PatchInstance, void(const Selectable&), &PatchInstance::selectedChanged> SelectedChangedCaller;
void selectedChangedComponent( const Selectable& selectable ){
GlobalSelectionSystem().getObserver ( SelectionSystem::eComponent )( selectable );
GlobalSelectionSystem().onComponentSelection( *this, selectable );
}
-typedef MemberCaller1<PatchInstance, const Selectable&, &PatchInstance::selectedChangedComponent> SelectedChangedComponentCaller;
+typedef MemberCaller<PatchInstance, void(const Selectable&), &PatchInstance::selectedChangedComponent> SelectedChangedComponentCaller;
Patch& getPatch(){
return m_patch;
evaluateTransform();
m_patch.freezeTransform();
}
-typedef MemberCaller<PatchInstance, &PatchInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<PatchInstance, void(), &PatchInstance::applyTransform> ApplyTransformCaller;
bool testLight( const RendererLight& light ) const {
#include "patchdialog.h"
+#include <gtk/gtk.h>
+
#include "itexdef.h"
#include "debugging/debugging.h"
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkcombobox.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkspinbutton.h>
-#include <gtk/gtkcheckbutton.h>
-
#include "gtkutil/idledraw.h"
#include "gtkutil/entry.h"
#include "gtkutil/button.h"
#endif
}
-class PatchSetFixedSubdivisions
-{
-const PatchFixedSubdivisions& m_subdivisions;
-public:
-PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions ) : m_subdivisions( subdivisions ){
-}
-void operator()( Patch& patch ) const {
- Patch_setFixedSubdivisions( patch, m_subdivisions );
-}
-};
-
void Scene_PatchSetFixedSubdivisions( const PatchFixedSubdivisions& subdivisions ){
UndoableCommand command( "patchSetFixedSubdivisions" );
- Scene_forEachVisibleSelectedPatch( PatchSetFixedSubdivisions( subdivisions ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ Patch_setFixedSubdivisions(patch, subdivisions);
+ });
}
-typedef struct _GtkCheckButton GtkCheckButton;
class Subdivisions
{
public:
-GtkCheckButton* m_enabled;
-GtkEntry* m_horizontal;
-GtkEntry* m_vertical;
-Subdivisions() : m_enabled( 0 ), m_horizontal( 0 ), m_vertical( 0 ){
+ui::CheckButton m_enabled;
+ui::Entry m_horizontal;
+ui::Entry m_vertical;
+Subdivisions() : m_enabled( ui::null ), m_horizontal( ui::null ), m_vertical( ui::null ){
}
void update(){
PatchFixedSubdivisions subdivisions;
Scene_PatchGetFixedSubdivisions( subdivisions );
- toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( m_enabled ), subdivisions.m_enabled );
+ toggle_button_set_active_no_signal( m_enabled, subdivisions.m_enabled );
if ( subdivisions.m_enabled ) {
entry_set_int( m_horizontal, static_cast<int>( subdivisions.m_x ) );
entry_set_int( m_vertical, static_cast<int>( subdivisions.m_y ) );
- gtk_widget_set_sensitive( GTK_WIDGET( m_horizontal ), TRUE );
- gtk_widget_set_sensitive( GTK_WIDGET( m_vertical ), TRUE );
+ gtk_widget_set_sensitive( m_horizontal , TRUE );
+ gtk_widget_set_sensitive( m_vertical , TRUE );
}
else
{
- gtk_entry_set_text( m_horizontal, "" );
- gtk_entry_set_text( m_vertical, "" );
- gtk_widget_set_sensitive( GTK_WIDGET( m_horizontal ), FALSE );
- gtk_widget_set_sensitive( GTK_WIDGET( m_vertical ), FALSE );
+ m_horizontal.text("");
+ m_vertical.text("");
+ gtk_widget_set_sensitive( m_horizontal , FALSE );
+ gtk_widget_set_sensitive( m_vertical , FALSE );
}
}
void cancel(){
update();
}
-typedef MemberCaller<Subdivisions, &Subdivisions::cancel> CancelCaller;
+typedef MemberCaller<Subdivisions, void(), &Subdivisions::cancel> CancelCaller;
void apply(){
Scene_PatchSetFixedSubdivisions(
PatchFixedSubdivisions(
)
);
}
-typedef MemberCaller<Subdivisions, &Subdivisions::apply> ApplyCaller;
-static void applyGtk( GtkToggleButton* toggle, Subdivisions* self ){
+typedef MemberCaller<Subdivisions, void(), &Subdivisions::apply> ApplyCaller;
+static void applyGtk( ui::ToggleButton toggle, Subdivisions* self ){
self->apply();
}
};
class PatchInspector : public Dialog
{
-GtkWindow* BuildDialog();
+ui::Window BuildDialog();
Subdivisions m_subdivisions;
NonModalEntry m_horizontalSubdivisionsEntry;
NonModalEntry m_verticalSubdivisionsEntry;
float m_fVShift; */
int m_nCol;
int m_nRow;
-GtkComboBox *m_pRowCombo;
-GtkComboBox *m_pColCombo;
+ui::ComboBoxText m_pRowCombo{ui::null};
+ui::ComboBoxText m_pColCombo{ui::null};
std::size_t m_countRows;
std::size_t m_countCols;
PatchInspector() :
m_horizontalSubdivisionsEntry( Subdivisions::ApplyCaller( m_subdivisions ), Subdivisions::CancelCaller( m_subdivisions ) ),
m_verticalSubdivisionsEntry( Subdivisions::ApplyCaller( m_subdivisions ), Subdivisions::CancelCaller( m_subdivisions ) ),
- m_idleDraw( MemberCaller<PatchInspector, &PatchInspector::GetPatchInfo>( *this ) ){
+ m_idleDraw( MemberCaller<PatchInspector, void(), &PatchInspector::GetPatchInfo>( *this ) ){
m_fS = 0.0f;
m_fT = 0.0f;
m_fX = 0.0f;
}
bool visible(){
- return GTK_WIDGET_VISIBLE( GetWidget() );
+ return GetWidget().visible();
}
// void UpdateInfo();
PatchInspector g_PatchInspector;
-void PatchInspector_constructWindow( GtkWindow* main_window ){
+void PatchInspector_constructWindow( ui::Window main_window ){
g_PatchInspector.m_parent = main_window;
g_PatchInspector.Create();
}
// static functions
// memorize the current state (that is don't try to undo our do before changing something else)
-static void OnApply( GtkWidget *widget, gpointer data ){
+static void OnApply( ui::Widget widget, gpointer data ){
g_PatchInspector.exportData();
if ( g_PatchInspector.m_Patch != 0 ) {
UndoableCommand command( "patchSetTexture" );
}
}
-static void OnSelchangeComboColRow( GtkWidget *widget, gpointer data ){
+static void OnSelchangeComboColRow( ui::Widget widget, gpointer data ){
if ( !g_PatchInspector.m_bListenChanged ) {
return;
}
g_PatchInspector.importData();
}
-class PatchSetTextureRepeat
-{
-float m_s, m_t;
-public:
-PatchSetTextureRepeat( float s, float t ) : m_s( s ), m_t( t ){
-}
-void operator()( Patch& patch ) const {
- patch.SetTextureRepeat( m_s, m_t );
-}
-};
-
void Scene_PatchTileTexture_Selected( scene::Graph& graph, float s, float t ){
- Scene_forEachVisibleSelectedPatch( PatchSetTextureRepeat( s, t ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.SetTextureRepeat(s, t);
+ });
SceneChangeNotify();
}
-static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){
+static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){
Patch_CapTexture();
}
-static void OnBtnPatchfit( GtkWidget *widget, gpointer data ){
+static void OnBtnPatchfit( ui::Widget widget, gpointer data ){
Patch_FitTexture();
}
-static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){
+static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){
Patch_NaturalTexture();
}
-static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){
+static void OnBtnPatchreset( ui::Widget widget, gpointer data ){
Patch_ResetTexture();
}
-static void OnBtnPatchFlipX( GtkWidget *widget, gpointer data ){
+static void OnBtnPatchFlipX( ui::Widget widget, gpointer data ){
Patch_FlipTextureX();
}
-static void OnBtnPatchFlipY( GtkWidget *widget, gpointer data ){
+static void OnBtnPatchFlipY( ui::Widget widget, gpointer data ){
Patch_FlipTextureY();
}
-struct PatchRotateTexture
-{
- float m_angle;
-public:
- PatchRotateTexture( float angle ) : m_angle( angle ){
- }
- void operator()( Patch& patch ) const {
- patch.RotateTexture( m_angle );
- }
-};
-
void Scene_PatchRotateTexture_Selected( scene::Graph& graph, float angle ){
- Scene_forEachVisibleSelectedPatch( PatchRotateTexture( angle ) );
-}
-
-class PatchScaleTexture
-{
-float m_s, m_t;
-public:
-PatchScaleTexture( float s, float t ) : m_s( s ), m_t( t ){
-}
-void operator()( Patch& patch ) const {
- patch.ScaleTexture( m_s, m_t );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.RotateTexture(angle);
+ });
}
-};
float Patch_convertScale( float scale ){
if ( scale > 0 ) {
}
void Scene_PatchScaleTexture_Selected( scene::Graph& graph, float s, float t ){
- Scene_forEachVisibleSelectedPatch( PatchScaleTexture( Patch_convertScale( s ), Patch_convertScale( t ) ) );
+ s = Patch_convertScale(s);
+ t = Patch_convertScale(t);
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.ScaleTexture(s, t);
+ });
}
-class PatchTranslateTexture
-{
-float m_s, m_t;
-public:
-PatchTranslateTexture( float s, float t )
- : m_s( s ), m_t( t ){
-}
-void operator()( Patch& patch ) const {
- patch.TranslateTexture( m_s, m_t );
+void Scene_PatchTranslateTexture_Selected( scene::Graph& graph, float s, float t ){
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.TranslateTexture(s, t);
+ });
}
-};
-void Scene_PatchTranslateTexture_Selected( scene::Graph& graph, float s, float t ){
- Scene_forEachVisibleSelectedPatch( PatchTranslateTexture( s, t ) );
+static void OnBtnPatchAutoCap( ui::Widget widget, gpointer data ){
+ Patch_AutoCapTexture();
}
-static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){
+static void OnSpinChanged(ui::Adjustment adj, gpointer data ){
texdef_t td;
td.rotate = 0;
td.scale[0] = td.scale[1] = 0;
td.shift[0] = td.shift[1] = 0;
- if ( adj->value == 0 ) {
+ if ( gtk_adjustment_get_value(adj) == 0 ) {
return;
}
if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "hshift_adj" ) ) {
g_pi_globals.shift[0] = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
- if ( adj->value > 0 ) {
+ if ( gtk_adjustment_get_value(adj) > 0 ) {
td.shift[0] = g_pi_globals.shift[0];
}
else{
else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "vshift_adj" ) ) {
g_pi_globals.shift[1] = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
- if ( adj->value > 0 ) {
+ if ( gtk_adjustment_get_value(adj) > 0 ) {
td.shift[1] = g_pi_globals.shift[1];
}
else{
if ( g_pi_globals.scale[0] == 0.0f ) {
return;
}
- if ( adj->value > 0 ) {
+ if ( gtk_adjustment_get_value(adj) > 0 ) {
td.scale[0] = g_pi_globals.scale[0];
}
else{
if ( g_pi_globals.scale[1] == 0.0f ) {
return;
}
- if ( adj->value > 0 ) {
+ if ( gtk_adjustment_get_value(adj) > 0 ) {
td.scale[1] = g_pi_globals.scale[1];
}
else{
else if ( adj == g_object_get_data( G_OBJECT( g_PatchInspector.GetWidget() ), "rotate_adj" ) ) {
g_pi_globals.rotate = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( data ) ) ) );
- if ( adj->value > 0 ) {
+ if ( gtk_adjustment_get_value(adj) > 0 ) {
td.rotate = g_pi_globals.rotate;
}
else{
}
}
- adj->value = 0;
+ gtk_adjustment_set_value(adj, 0);
// will scale shift rotate the patch accordingly
}
// update the point-by-point view
- OnSelchangeComboColRow( 0,0 );
+ OnSelchangeComboColRow( ui::root, 0 );
}
-static gint OnDialogKey( GtkWidget* widget, GdkEventKey* event, gpointer data ){
- if ( event->keyval == GDK_Return ) {
- OnApply( 0, 0 );
+static gint OnDialogKey( ui::Widget widget, GdkEventKey* event, gpointer data ){
+ if ( event->keyval == GDK_KEY_Return ) {
+ OnApply( ui::root, 0 );
return TRUE;
}
- else if ( event->keyval == GDK_Escape ) {
+ else if ( event->keyval == GDK_KEY_Escape ) {
g_PatchInspector.GetPatchInfo();
return TRUE;
}
// =============================================================================
// PatchInspector class
-GtkWindow* PatchInspector::BuildDialog(){
- GtkWindow* window = create_floating_window( "Patch Properties", m_parent );
+ui::Window PatchInspector::BuildDialog(){
+ ui::Window window = ui::Window(create_floating_window( "Patch Properties", m_parent ));
m_position_tracker.connect( window );
{
- GtkVBox* vbox = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) );
+ auto vbox = ui::VBox( FALSE, 5 );
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- gtk_widget_show( GTK_WIDGET( vbox ) );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) );
+ vbox.show();
+ window.add(vbox);
{
- GtkHBox* hbox = GTK_HBOX( gtk_hbox_new( FALSE, 5 ) );
- gtk_widget_show( GTK_WIDGET( hbox ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), TRUE, TRUE, 0 );
+ auto hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox.pack_start( hbox, TRUE, TRUE, 0 );
{
- GtkVBox* vbox2 = GTK_VBOX( gtk_vbox_new( FALSE, 0 ) );
+ auto vbox2 = ui::VBox( FALSE, 0 );
gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 0 );
- gtk_widget_show( GTK_WIDGET( vbox2 ) );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), TRUE, TRUE, 0 );
+ vbox2.show();
+ hbox.pack_start( vbox2, TRUE, TRUE, 0 );
{
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Details" ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+ auto frame = ui::Frame( "Details" );
+ frame.show();
+ vbox2.pack_start( frame, TRUE, TRUE, 0 );
{
- GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) );
+ auto vbox3 = ui::VBox( FALSE, 5 );
gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 );
- gtk_widget_show( GTK_WIDGET( vbox3 ) );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) );
+ vbox3.show();
+ frame.add(vbox3);
{
- GtkTable* table = GTK_TABLE( gtk_table_new( 2, 2, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
- gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = ui::Table( 2, 2, FALSE );
+ table.show();
+ vbox3.pack_start( table, TRUE, TRUE, 0 );
gtk_table_set_row_spacings( table, 5 );
gtk_table_set_col_spacings( table, 5 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Row:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Row:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0)}, {0, 0});
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Column:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Column:" );
+ label.show();
+ table.attach(label, {1, 2, 0, 1}, {(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0)}, {0, 0});
}
{
- GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
- g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this );
- AddDialogData( *combo, m_nRow );
-
- gtk_widget_show( GTK_WIDGET( combo ) );
- gtk_table_attach( table, GTK_WIDGET( combo ), 0, 1, 1, 2,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( combo ), 60, -1 );
+ auto combo = ui::ComboBoxText(ui::New);
+ combo.connect( "changed", G_CALLBACK( OnSelchangeComboColRow ), this );
+ AddDialogData( combo, m_nRow );
+
+ combo.show();
+ table.attach(combo, {0, 1, 1, 2}, {(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0)}, {0, 0});
+ combo.dimensions(60, -1);
m_pRowCombo = combo;
}
{
- GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
- g_signal_connect( G_OBJECT( combo ), "changed", G_CALLBACK( OnSelchangeComboColRow ), this );
- AddDialogData( *combo, m_nCol );
-
- gtk_widget_show( GTK_WIDGET( combo ) );
- gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 1, 2,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( combo ), 60, -1 );
+ auto combo = ui::ComboBoxText(ui::New);
+ combo.connect( "changed", G_CALLBACK( OnSelchangeComboColRow ), this );
+ AddDialogData( combo, m_nCol );
+
+ combo.show();
+ table.attach(combo, {1, 2, 1, 2}, {(GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0)}, {0, 0});
+ combo.dimensions(60, -1);
m_pColCombo = combo;
}
}
- GtkTable* table = GTK_TABLE( gtk_table_new( 5, 2, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
- gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = ui::Table( 5, 2, FALSE );
+ table.show();
+ vbox3.pack_start( table, TRUE, TRUE, 0 );
gtk_table_set_row_spacings( table, 5 );
gtk_table_set_col_spacings( table, 5 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "X:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "X:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Y:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Y:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Z:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Z:" );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {GTK_EXPAND | GTK_FILL, 0});
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "S:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 3, 4,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "S:" );
+ label.show();
+ table.attach(label, {0, 1, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "T:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 4, 5,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "T:" );
+ label.show();
+ table.attach(label, {0, 1, 4, 5}, {GTK_EXPAND | GTK_FILL, 0});
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- AddDialogData( *entry, m_fX );
-
- g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ AddDialogData( entry, m_fX );
+
+ entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- AddDialogData( *entry, m_fY );
-
- g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ AddDialogData( entry, m_fY );
+
+ entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- AddDialogData( *entry, m_fZ );
-
- g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0});
+ AddDialogData( entry, m_fZ );
+
+ entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 3, 4,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- AddDialogData( *entry, m_fS );
-
- g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
+ AddDialogData( entry, m_fS );
+
+ entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 4, 5,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- AddDialogData( *entry, m_fT );
-
- g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 4, 5}, {GTK_EXPAND | GTK_FILL, 0});
+ AddDialogData( entry, m_fT );
+
+ entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
}
}
}
if ( g_pGameDescription->mGameType == "doom3" ) {
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Tesselation" ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+ auto frame = ui::Frame( "Tesselation" );
+ frame.show();
+ vbox2.pack_start( frame, TRUE, TRUE, 0 );
{
- GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) );
+ auto vbox3 = ui::VBox( FALSE, 5 );
gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 );
- gtk_widget_show( GTK_WIDGET( vbox3 ) );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) );
+ vbox3.show();
+ frame.add(vbox3);
{
- GtkTable* table = GTK_TABLE( gtk_table_new( 3, 2, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
- gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = ui::Table( 3, 2, FALSE );
+ table.show();
+ vbox3.pack_start( table, TRUE, TRUE, 0 );
gtk_table_set_row_spacings( table, 5 );
gtk_table_set_col_spacings( table, 5 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Fixed" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Fixed" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
}
{
- GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new() );
- gtk_widget_show( GTK_WIDGET( check ) );
- gtk_table_attach( table, GTK_WIDGET( check ), 1, 2, 0, 1,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto check = ui::CheckButton::from( gtk_check_button_new() );
+ check.show();
+ table.attach(check, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
m_subdivisions.m_enabled = check;
- guint handler_id = g_signal_connect( G_OBJECT( check ), "toggled", G_CALLBACK( &Subdivisions::applyGtk ), &m_subdivisions );
+ guint handler_id = check.connect( "toggled", G_CALLBACK( &Subdivisions::applyGtk ), &m_subdivisions );
g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Horizontal" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
m_subdivisions.m_horizontal = entry;
m_horizontalSubdivisionsEntry.connect( entry );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Vertical" );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {GTK_EXPAND | GTK_FILL, 0});
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 2, 3,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0});
m_subdivisions.m_vertical = entry;
m_verticalSubdivisionsEntry.connect( entry );
}
}
}
{
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Texturing" ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+ auto frame = ui::Frame( "Texturing" );
+ frame.show();
+ hbox.pack_start( frame, TRUE, TRUE, 0 );
{
- GtkVBox* vbox2 = GTK_VBOX( gtk_vbox_new( FALSE, 5 ) );
- gtk_widget_show( GTK_WIDGET( vbox2 ) );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
+ auto vbox2 = ui::VBox( FALSE, 5 );
+ vbox2.show();
+ frame.add(vbox2);
gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Name:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( label ), TRUE, TRUE, 0 );
+ auto label = ui::Label( "Name:" );
+ label.show();
+ vbox2.pack_start( label, TRUE, TRUE, 0 );
gtk_label_set_justify( label, GTK_JUSTIFY_LEFT );
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- // gtk_entry_set_editable (GTK_ENTRY (entry), false);
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
- AddDialogData( *entry, m_strName );
+ auto entry = ui::Entry(ui::New);
+ // gtk_editable_set_editable (GTK_ENTRY (entry), false);
+ entry.show();
+ vbox2.pack_start( entry, TRUE, TRUE, 0 );
+ AddDialogData( entry, m_strName );
- g_signal_connect( G_OBJECT( entry ), "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
+ entry.connect( "key_press_event", G_CALLBACK( OnDialogKey ), 0 );
}
{
- GtkTable* table = GTK_TABLE( gtk_table_new( 5, 4, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = ui::Table( 5, 4, FALSE );
+ table.show();
+ vbox2.pack_start( table, TRUE, TRUE, 0 );
gtk_table_set_row_spacings( table, 5 );
gtk_table_set_col_spacings( table, 5 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Shift Step" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 0, 1,
- (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Horizontal Shift Step" );
+ label.show();
+ table.attach(label, {2, 4, 0, 1}, {GTK_FILL | GTK_EXPAND, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Shift Step" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 1, 2,
- (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Vertical Shift Step" );
+ label.show();
+ table.attach(label, {2, 4, 1, 2}, {GTK_FILL | GTK_EXPAND, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Horizontal Stretch Step" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 2, 3,
- (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Horizontal Stretch Step" );
+ label.show();
+ table.attach(label, {2, 3, 2, 3}, {GTK_FILL | GTK_EXPAND, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "FlipX" ) );
- gtk_widget_show( GTK_WIDGET( button ) );
- gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 2, 3,
- (GtkAttachOptions)( GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipX ), 0 );
- gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
+ auto button = ui::Button( "Flip" );
+ button.show();
+ table.attach(button, {3, 4, 2, 3}, {GTK_FILL, 0});
+ button.connect( "clicked", G_CALLBACK( OnBtnPatchFlipX ), 0 );
+ button.dimensions(60, -1);
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Vertical Stretch Step" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 3, 4,
- (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Vertical Stretch Step" );
+ label.show();
+ table.attach(label, {2, 3, 3, 4}, {GTK_FILL | GTK_EXPAND, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "FlipY" ) );
- gtk_widget_show( GTK_WIDGET( button ) );
- gtk_table_attach( table, GTK_WIDGET( button ), 3, 4, 3, 4,
- (GtkAttachOptions)( GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchFlipY ), 0 );
- gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
+ auto button = ui::Button( "Flip" );
+ button.show();
+ table.attach(button, {3, 4, 3, 4}, {GTK_FILL, 0});
+ button.connect( "clicked", G_CALLBACK( OnBtnPatchFlipY ), 0 );
+ button.dimensions(60, -1);
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Rotate Step" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 2, 4, 4, 5,
- (GtkAttachOptions)( GTK_FILL|GTK_EXPAND ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto label = ui::Label( "Rotate Step" );
+ label.show();
+ table.attach(label, {2, 4, 4, 5}, {GTK_FILL | GTK_EXPAND, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 0, 1,
- (GtkAttachOptions)( GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
- g_object_set_data( G_OBJECT( window ), "hshift_entry", entry );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {0, 1, 0, 1}, {GTK_FILL, 0});
+ entry.dimensions(50, -1);
+ g_object_set_data( G_OBJECT( window ), "hshift_entry", (void *) entry );
// we fill in this data, if no patch is selected the widgets are unmodified when the inspector is raised
// so we need to have at least one initialisation somewhere
entry_set_float( entry, g_pi_globals.shift[0] );
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 ) );
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
- g_object_set_data( G_OBJECT( window ), "hshift_adj", adj );
-
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1,
- (GtkAttachOptions)( 0 ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( spin ), 16, -2 );
- GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS );
+ auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 );
+ adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), (gpointer) entry );
+ g_object_set_data( G_OBJECT( window ), "hshift_adj", (gpointer) adj );
+
+ auto spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ table.attach(spin, {1, 2, 0, 1}, {0, 0});
+ spin.dimensions(16, -2);
+ gtk_widget_set_can_focus( spin, false );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 1, 2,
- (GtkAttachOptions)( GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {0, 1, 1, 2}, {GTK_FILL, 0});
+ entry.dimensions(50, -1);
entry_set_float( entry, g_pi_globals.shift[1] );
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 ) );
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
- g_object_set_data( G_OBJECT( window ), "vshift_adj", adj );
-
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2,
- (GtkAttachOptions)( 0 ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( spin ), 16, -2 );
- GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS );
+ auto adj = ui::Adjustment( 0, -8192, 8192, 1, 1, 0 );
+ adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry );
+ g_object_set_data( G_OBJECT( window ), "vshift_adj", (gpointer) adj );
+
+ auto spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ table.attach(spin, {1, 2, 1, 2}, {0, 0});
+ spin.dimensions(16, -2);
+ gtk_widget_set_can_focus( spin, false );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 2, 3,
- (GtkAttachOptions)( GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {0, 1, 2, 3}, {GTK_FILL, 0});
+ entry.dimensions(50, -1);
entry_set_float( entry, g_pi_globals.scale[0] );
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) );
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
- g_object_set_data( G_OBJECT( window ), "hscale_adj", adj );
-
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3,
- (GtkAttachOptions)( 0 ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( spin ), 16, -2 );
- GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS );
+ auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 );
+ adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry );
+ g_object_set_data( G_OBJECT( window ), "hscale_adj", (gpointer) adj );
+
+ auto spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ table.attach(spin, {1, 2, 2, 3}, {0, 0});
+ spin.dimensions(16, -2);
+ gtk_widget_set_can_focus( spin, false );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 3, 4,
- (GtkAttachOptions)( GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {0, 1, 3, 4}, {GTK_FILL, 0});
+ entry.dimensions(50, -1);
entry_set_float( entry, g_pi_globals.scale[1] );
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) );
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
- g_object_set_data( G_OBJECT( window ), "vscale_adj", adj );
-
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 3, 4,
- (GtkAttachOptions)( 0 ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( spin ), 16, -2 );
- GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS );
+ auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 );
+ adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry );
+ g_object_set_data( G_OBJECT( window ), "vscale_adj", (gpointer) adj );
+
+ auto spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ table.attach(spin, {1, 2, 3, 4}, {0, 0});
+ spin.dimensions(16, -2);
+ gtk_widget_set_can_focus( spin, false );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 0, 1, 4, 5,
- (GtkAttachOptions)( GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {0, 1, 4, 5}, {GTK_FILL, 0});
+ entry.dimensions(50, -1);
entry_set_float( entry, g_pi_globals.rotate );
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ) ); // NOTE: Arnout - this really should be 360 but can't change it anymore as it could break existing maps
- g_signal_connect( G_OBJECT( adj ), "value_changed", G_CALLBACK( OnSpinChanged ), entry );
- g_object_set_data( G_OBJECT( window ), "rotate_adj", adj );
-
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 4, 5,
- (GtkAttachOptions)( 0 ),
- (GtkAttachOptions)( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( spin ), 16, -2 );
- GTK_WIDGET_UNSET_FLAGS( spin, GTK_CAN_FOCUS );
+ auto adj = ui::Adjustment( 0, -1000, 1000, 1, 1, 0 ); // NOTE: Arnout - this really should be 360 but can't change it anymore as it could break existing maps
+ adj.connect( "value_changed", G_CALLBACK( OnSpinChanged ), entry );
+ g_object_set_data( G_OBJECT( window ), "rotate_adj", (gpointer) adj );
+
+ auto spin = ui::SpinButton( adj, 1, 0 );
+ spin.show();
+ table.attach(spin, {1, 2, 4, 5}, {0, 0});
+ spin.dimensions(16, -2);
+ gtk_widget_set_can_focus( spin, false );
}
}
- GtkHBox* hbox2 = GTK_HBOX( gtk_hbox_new( TRUE, 5 ) );
- gtk_widget_show( GTK_WIDGET( hbox2 ) );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( hbox2 ), TRUE, FALSE, 0 );
+ auto hbox2 = ui::HBox( TRUE, 5 );
+ hbox2.show();
+ vbox2.pack_start( hbox2, TRUE, FALSE, 0 );
+ {
+ auto button = ui::Button( "Auto Cap" );
+ button.show();
+ hbox2.pack_end(button, TRUE, FALSE, 0);
+ button.connect( "clicked", G_CALLBACK( OnBtnPatchAutoCap ), 0 );
+ button.dimensions(60, -1);
+ }
{
- GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "CAP" ) );
- gtk_widget_show( GTK_WIDGET( button ) );
- gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 );
- gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
+ auto button = ui::Button( "CAP" );
+ button.show();
+ hbox2.pack_end(button, TRUE, FALSE, 0);
+ button.connect( "clicked", G_CALLBACK( OnBtnPatchdetails ), 0 );
+ button.dimensions(60, -1);
}
{
- GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Set..." ) );
- gtk_widget_show( GTK_WIDGET( button ) );
- gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchreset ), 0 );
- gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
+ auto button = ui::Button( "Set..." );
+ button.show();
+ hbox2.pack_end(button, TRUE, FALSE, 0);
+ button.connect( "clicked", G_CALLBACK( OnBtnPatchreset ), 0 );
+ button.dimensions(60, -1);
}
{
- GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Natural" ) );
- gtk_widget_show( GTK_WIDGET( button ) );
- gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 );
- gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
+ auto button = ui::Button( "Natural" );
+ button.show();
+ hbox2.pack_end(button, TRUE, FALSE, 0);
+ button.connect( "clicked", G_CALLBACK( OnBtnPatchnatural ), 0 );
+ button.dimensions(60, -1);
}
{
- GtkButton* button = GTK_BUTTON( gtk_button_new_with_label( "Fit" ) );
- gtk_widget_show( GTK_WIDGET( button ) );
- gtk_box_pack_end( GTK_BOX( hbox2 ), GTK_WIDGET( button ), TRUE, FALSE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnPatchfit ), 0 );
- gtk_widget_set_usize( GTK_WIDGET( button ), 60, -1 );
+ auto button = ui::Button( "Fit" );
+ button.show();
+ hbox2.pack_end(button, TRUE, FALSE, 0);
+ button.connect( "clicked", G_CALLBACK( OnBtnPatchfit ), 0 );
+ button.dimensions(60, -1);
}
}
}
for ( std::size_t i = 0; i < m_countRows; ++i )
{
- gtk_combo_box_remove_text( m_pRowCombo, gint( m_countRows - i - 1 ) );
+ gtk_combo_box_text_remove( m_pRowCombo, gint( m_countRows - i - 1 ) );
}
m_countRows = m_Patch->getHeight();
{
char buffer[16];
sprintf( buffer, "%u", Unsigned( i ) );
- gtk_combo_box_append_text( m_pRowCombo, buffer );
+ gtk_combo_box_text_append_text( m_pRowCombo, buffer );
}
gtk_combo_box_set_active( m_pRowCombo, 0 );
for ( std::size_t i = 0; i < m_countCols; ++i )
{
- gtk_combo_box_remove_text( m_pColCombo, gint( m_countCols - i - 1 ) );
+ gtk_combo_box_text_remove( m_pColCombo, gint( m_countCols - i - 1 ) );
}
m_countCols = m_Patch->getWidth();
{
char buffer[16];
sprintf( buffer, "%u", Unsigned( i ) );
- gtk_combo_box_append_text( m_pColCombo, buffer );
+ gtk_combo_box_text_append_text( m_pColCombo, buffer );
}
gtk_combo_box_set_active( m_pColCombo, 0 );
void PatchInspector_Construct(){
- GlobalCommands_insert( "PatchInspector", FreeCaller<PatchInspector_toggleShown>(), Accelerator( 'S', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "PatchInspector", makeCallbackF(PatchInspector_toggleShown), Accelerator( 'S', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalPreferenceSystem().registerPreference( "PatchWnd", WindowPositionTrackerImportStringCaller( g_PatchInspector.m_position_tracker ), WindowPositionTrackerExportStringCaller( g_PatchInspector.m_position_tracker ) );
- GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale1", FloatImportStringCaller( g_pi_globals.scale[0] ), FloatExportStringCaller( g_pi_globals.scale[0] ) );
- GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale2", FloatImportStringCaller( g_pi_globals.scale[1] ), FloatExportStringCaller( g_pi_globals.scale[1] ) );
- GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift1", FloatImportStringCaller( g_pi_globals.shift[0] ), FloatExportStringCaller( g_pi_globals.shift[0] ) );
- GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift2", FloatImportStringCaller( g_pi_globals.shift[1] ), FloatExportStringCaller( g_pi_globals.shift[1] ) );
- GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Rotate", FloatImportStringCaller( g_pi_globals.rotate ), FloatExportStringCaller( g_pi_globals.rotate ) );
+ GlobalPreferenceSystem().registerPreference( "PatchWnd", make_property<WindowPositionTracker_String>( g_PatchInspector.m_position_tracker ) );
+ GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale1", make_property_string( g_pi_globals.scale[0] ) );
+ GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Scale2", make_property_string( g_pi_globals.scale[1] ) );
+ GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift1", make_property_string( g_pi_globals.shift[0] ) );
+ GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Shift2", make_property_string( g_pi_globals.shift[1] ) );
+ GlobalPreferenceSystem().registerPreference( "SI_PatchTexdef_Rotate", make_property_string( g_pi_globals.rotate ) );
- typedef FreeCaller1<const Selectable&, PatchInspector_SelectionChanged> PatchInspectorSelectionChangedCaller;
+ typedef FreeCaller<void(const Selectable&), PatchInspector_SelectionChanged> PatchInspectorSelectionChangedCaller;
GlobalSelectionSystem().addSelectionChangeCallback( PatchInspectorSelectionChangedCaller() );
- typedef FreeCaller<PatchInspector_queueDraw> PatchInspectorQueueDrawCaller;
+ typedef FreeCaller<void(), PatchInspector_queueDraw> PatchInspectorQueueDrawCaller;
Patch_addTextureChangedCallback( PatchInspectorQueueDrawCaller() );
}
void PatchInspector_Destroy(){
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_PATCHDIALOG_H )
#define INCLUDED_PATCHDIALOG_H
void PatchInspector_Construct();
void PatchInspector_Destroy();
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-void PatchInspector_constructWindow( GtkWindow* main_window );
+void PatchInspector_constructWindow( ui::Window main_window );
void PatchInspector_destroyWindow();
namespace scene
#include "patchmanip.h"
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
#include "debugging/debugging.h"
}
}
+void PatchAutoCapTexture( Patch& patch ) {
+
+ AABB box = patch.localAABB();
+ float x = box.extents.x();
+ float y = box.extents.y();
+ float z = box.extents.z();
+
+ int cap_direction = -1;
+ if ( x < y && x < z )
+ cap_direction = 0;
+ else if ( y < x && y < z )
+ cap_direction = 1;
+ else if ( z < x && z < x )
+ cap_direction = 2;
+
+ if ( cap_direction >= 0 )
+ patch.ProjectTexture(cap_direction);
+ else
+ patch.NaturalTexture();
+}
+
+void Patch_AutoCapTexture(){
+ UndoableCommand command( "patchAutoCapTexture" );
+ Scene_forEachVisibleSelectedPatch( &PatchAutoCapTexture );
+ SceneChangeNotify();
+}
void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, const char* shader ){
if ( ( type == eCapEndCap || type == eCapIEndCap )
NodeSmartReference cap( g_patchCreator->createPatch() );
Node_getTraversable( instance.path().parent() )->insert( cap );
- patch.MakeCap( Node_getPatch( cap ), type, ROW, true );
- Node_getPatch( cap )->SetShader( shader );
+ Patch* cap_patch = Node_getPatch( cap );
+ patch.MakeCap( cap_patch, type, ROW, true );
+ cap_patch->SetShader( shader );
+ PatchAutoCapTexture(*cap_patch);
scene::Path path( instance.path() );
path.pop();
NodeSmartReference cap( g_patchCreator->createPatch() );
Node_getTraversable( instance.path().parent() )->insert( cap );
- patch.MakeCap( Node_getPatch( cap ), type, ROW, false );
- Node_getPatch( cap )->SetShader( shader );
+ Patch* cap_patch = Node_getPatch( cap );
+ patch.MakeCap( cap_patch, type, ROW, false );
+ cap_patch->SetShader( shader );
+ PatchAutoCapTexture(*cap_patch);
scene::Path path( instance.path() );
path.pop();
typedef std::vector<scene::Instance*> InstanceVector;
-class PatchStoreInstance
-{
-InstanceVector& m_instances;
-public:
-PatchStoreInstance( InstanceVector& instances ) : m_instances( instances ){
-}
-void operator()( PatchInstance& patch ) const {
- m_instances.push_back( &patch );
-}
-};
-
enum ECapDialog {
PATCHCAP_BEVEL = 0,
PATCHCAP_ENDCAP,
}
InstanceVector instances;
- Scene_forEachVisibleSelectedPatchInstance( PatchStoreInstance( instances ) );
+ Scene_forEachVisibleSelectedPatchInstance([&](PatchInstance &patch) {
+ instances.push_back(&patch);
+ });
for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
{
Patch_makeCaps( *Node_getPatch( ( *i )->path().top() ), *( *i ), eType, shader );
void Scene_PatchDeform( scene::Graph& graph, const int deform, const int axis )
{
InstanceVector instances;
- Scene_forEachVisibleSelectedPatchInstance( PatchStoreInstance( instances ) );
+ Scene_forEachVisibleSelectedPatchInstance([&](PatchInstance &patch) {
+ instances.push_back(&patch);
+ });
for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
{
Patch_deform( *Node_getPatch( ( *i )->path().top() ), *( *i ), deform, axis );
void Scene_PatchThicken( scene::Graph& graph, const int thickness, bool seams, const int axis )
{
InstanceVector instances;
- Scene_forEachVisibleSelectedPatchInstance( PatchStoreInstance( instances ) );
+ Scene_forEachVisibleSelectedPatchInstance([&](PatchInstance &patch) {
+ instances.push_back(&patch);
+ });
for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
{
Patch_thicken( *Node_getPatch( ( *i )->path().top() ), *( *i ), thickness, seams, axis );
}
-class PatchCapTexture
-{
-public:
-void operator()( Patch& patch ) const {
- patch.ProjectTexture( Patch::m_CycleCapIndex );
-}
-};
-
void Scene_PatchCapTexture_Selected( scene::Graph& graph ){
- Scene_forEachVisibleSelectedPatch( PatchCapTexture() );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.ProjectTexture(Patch::m_CycleCapIndex);
+ });
Patch::m_CycleCapIndex = ( Patch::m_CycleCapIndex == 0 ) ? 1 : ( Patch::m_CycleCapIndex == 1 ) ? 2 : 0;
SceneChangeNotify();
}
-class PatchFlipTexture
-{
-int m_axis;
-public:
-PatchFlipTexture( int axis ) : m_axis( axis ){
-}
-void operator()( Patch& patch ) const {
- patch.FlipTexture( m_axis );
-}
-};
-
void Scene_PatchFlipTexture_Selected( scene::Graph& graph, int axis ){
- Scene_forEachVisibleSelectedPatch( PatchFlipTexture( axis ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.FlipTexture(axis);
+ });
}
-class PatchNaturalTexture
-{
-public:
-void operator()( Patch& patch ) const {
- patch.NaturalTexture();
-}
-};
-
void Scene_PatchNaturalTexture_Selected( scene::Graph& graph ){
- Scene_forEachVisibleSelectedPatch( PatchNaturalTexture() );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.NaturalTexture();
+ });
SceneChangeNotify();
}
-class PatchInsertRemove
-{
-bool m_insert, m_column, m_first;
-public:
-PatchInsertRemove( bool insert, bool column, bool first ) : m_insert( insert ), m_column( column ), m_first( first ){
-}
-void operator()( Patch& patch ) const {
- patch.InsertRemove( m_insert, m_column, m_first );
-}
-};
-
void Scene_PatchInsertRemove_Selected( scene::Graph& graph, bool bInsert, bool bColumn, bool bFirst ){
- Scene_forEachVisibleSelectedPatch( PatchInsertRemove( bInsert, bColumn, bFirst ) );
-}
-
-class PatchInvertMatrix
-{
-public:
-void operator()( Patch& patch ) const {
- patch.InvertMatrix();
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.InsertRemove(bInsert, bColumn, bFirst);
+ });
}
-};
void Scene_PatchInvert_Selected( scene::Graph& graph ){
- Scene_forEachVisibleSelectedPatch( PatchInvertMatrix() );
-}
-
-class PatchRedisperse
-{
-EMatrixMajor m_major;
-public:
-PatchRedisperse( EMatrixMajor major ) : m_major( major ){
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.InvertMatrix();
+ });
}
-void operator()( Patch& patch ) const {
- patch.Redisperse( m_major );
-}
-};
void Scene_PatchRedisperse_Selected( scene::Graph& graph, EMatrixMajor major ){
- Scene_forEachVisibleSelectedPatch( PatchRedisperse( major ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.Redisperse(major);
+ });
}
-class PatchSmooth
-{
-EMatrixMajor m_major;
-public:
-PatchSmooth( EMatrixMajor major ) : m_major( major ){
-}
-void operator()( Patch& patch ) const {
- patch.Smooth( m_major );
-}
-};
-
void Scene_PatchSmooth_Selected( scene::Graph& graph, EMatrixMajor major ){
- Scene_forEachVisibleSelectedPatch( PatchSmooth( major ) );
-}
-
-class PatchTransposeMatrix
-{
-public:
-void operator()( Patch& patch ) const {
- patch.TransposeMatrix();
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.Smooth(major);
+ });
}
-};
void Scene_PatchTranspose_Selected( scene::Graph& graph ){
- Scene_forEachVisibleSelectedPatch( PatchTransposeMatrix() );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.TransposeMatrix();
+ });
}
-class PatchSetShader
-{
-const char* m_name;
-public:
-PatchSetShader( const char* name )
- : m_name( name ){
-}
-void operator()( Patch& patch ) const {
- patch.SetShader( m_name );
-}
-};
-
void Scene_PatchSetShader_Selected( scene::Graph& graph, const char* name ){
- Scene_forEachVisibleSelectedPatch( PatchSetShader( name ) );
+ Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+ patch.SetShader(name);
+ });
SceneChangeNotify();
}
};
void Scene_PatchSelectByShader( scene::Graph& graph, const char* name ){
- Scene_forEachVisiblePatchInstance( PatchSelectByShader( name ) );
+ Scene_forEachVisiblePatchInstance([&](PatchInstance &patch) {
+ if (shader_equal(patch.getPatch().GetShader(), name)) {
+ patch.setSelected(true);
+ }
+ });
}
void Patch_CapTexture(){
UndoableCommand command( "patchCapTexture" );
+
Scene_PatchCapTexture_Selected( GlobalSceneGraph() );
}
void Patch_FitTexture(){
UndoableCommand command( "patchFitTexture" );
+
Scene_PatchTileTexture_Selected( GlobalSceneGraph(), 1, 1 );
}
}
-
#include "ifilter.h"
Patch_constructPreferences( page );
}
void Patch_registerPreferencesPage(){
- PreferencesDialog_addDisplayPage( FreeCaller1<PreferenceGroup&, Patch_constructPage>() );
+ PreferencesDialog_addDisplayPage( makeCallbackF(Patch_constructPage) );
}
#include "preferencesystem.h"
void PatchPreferences_construct(){
- GlobalPreferenceSystem().registerPreference( "Subdivisions", IntImportStringCaller( g_PatchSubdivideThreshold ), IntExportStringCaller( g_PatchSubdivideThreshold ) );
+ GlobalPreferenceSystem().registerPreference( "Subdivisions", make_property_string( g_PatchSubdivideThreshold ) );
}
#include "generic/callback.h"
void Patch_registerCommands(){
- GlobalCommands_insert( "InvertCurveTextureX", FreeCaller<Patch_FlipTextureX>(), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "InvertCurveTextureY", FreeCaller<Patch_FlipTextureY>(), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "NaturalizePatch", FreeCaller<Patch_NaturalTexture>(), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "PatchCylinder", FreeCaller<Patch_Cylinder>() );
-// GlobalCommands_insert( "PatchDenseCylinder", FreeCaller<Patch_DenseCylinder>() );
-// GlobalCommands_insert( "PatchVeryDenseCylinder", FreeCaller<Patch_VeryDenseCylinder>() );
- GlobalCommands_insert( "PatchSquareCylinder", FreeCaller<Patch_SquareCylinder>() );
- GlobalCommands_insert( "PatchXactCylinder", FreeCaller<Patch_XactCylinder>() );
- GlobalCommands_insert( "PatchXactSphere", FreeCaller<Patch_XactSphere>() );
- GlobalCommands_insert( "PatchXactCone", FreeCaller<Patch_XactCone>() );
- GlobalCommands_insert( "PatchEndCap", FreeCaller<Patch_Endcap>() );
- GlobalCommands_insert( "PatchBevel", FreeCaller<Patch_Bevel>() );
-// GlobalCommands_insert( "PatchSquareBevel", FreeCaller<Patch_SquareBevel>() );
-// GlobalCommands_insert( "PatchSquareEndcap", FreeCaller<Patch_SquareEndcap>() );
- GlobalCommands_insert( "PatchCone", FreeCaller<Patch_Cone>() );
- GlobalCommands_insert( "PatchSphere", FreeCaller<Patch_Sphere>() );
- GlobalCommands_insert( "SimplePatchMesh", FreeCaller<Patch_Plane>(), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "PatchInsertFirstColumn", FreeCaller<Patch_InsertFirstColumn>(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "PatchInsertLastColumn", FreeCaller<Patch_InsertLastColumn>() );
- GlobalCommands_insert( "PatchInsertFirstRow", FreeCaller<Patch_InsertFirstRow>(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "PatchInsertLastRow", FreeCaller<Patch_InsertLastRow>() );
- GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller<Patch_DeleteFirstColumn>() );
- GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller<Patch_DeleteLastColumn>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller<Patch_DeleteFirstRow>() );
- GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller<Patch_DeleteLastRow>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "InvertCurve", FreeCaller<Patch_Invert>(), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "RedisperseRows", FreeCaller<Patch_RedisperseRows>(), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "RedisperseCols", FreeCaller<Patch_RedisperseCols>(), Accelerator( 'E', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "SmoothRows", FreeCaller<Patch_SmoothRows>(), Accelerator( 'W', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "SmoothCols", FreeCaller<Patch_SmoothCols>(), Accelerator( 'W', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "MatrixTranspose", FreeCaller<Patch_Transpose>(), Accelerator( 'M', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "CapCurrentCurve", FreeCaller<Patch_Cap>(), Accelerator( 'C', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "CycleCapTexturePatch", FreeCaller<Patch_CycleProjection>(), Accelerator( 'N', (GdkModifierType)GDK_SHIFT_MASK ) );
-// GlobalCommands_insert( "MakeOverlayPatch", FreeCaller<Patch_OverlayOn>(), Accelerator( 'Y' ) );
-// GlobalCommands_insert( "ClearPatchOverlays", FreeCaller<Patch_OverlayOff>(), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "PatchDeform", FreeCaller<Patch_Deform>() );
- GlobalCommands_insert( "PatchThicken", FreeCaller<Patch_Thicken>(), Accelerator( 'T', (GdkModifierType)GDK_CONTROL_MASK ) );
-}
-
-void Patch_constructToolbar( GtkToolbar* toolbar ){
- toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "curve_cap.png", "CapCurrentCurve" );
-}
-
-void Patch_constructMenu( GtkMenu* menu ){
+ GlobalCommands_insert( "InvertCurveTextureX", makeCallbackF(Patch_FlipTextureX), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "InvertCurveTextureY", makeCallbackF(Patch_FlipTextureY), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "NaturalizePatch", makeCallbackF(Patch_NaturalTexture), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "PatchCylinder", makeCallbackF(Patch_Cylinder) );
+// GlobalCommands_insert( "PatchDenseCylinder", makeCallbackF(Patch_DenseCylinder) );
+// GlobalCommands_insert( "PatchVeryDenseCylinder", makeCallbackF(Patch_VeryDenseCylinder) );
+ GlobalCommands_insert( "PatchSquareCylinder", makeCallbackF(Patch_SquareCylinder) );
+ GlobalCommands_insert( "PatchXactCylinder", makeCallbackF(Patch_XactCylinder) );
+ GlobalCommands_insert( "PatchXactSphere", makeCallbackF(Patch_XactSphere) );
+ GlobalCommands_insert( "PatchXactCone", makeCallbackF(Patch_XactCone) );
+ GlobalCommands_insert( "PatchEndCap", makeCallbackF(Patch_Endcap) );
+ GlobalCommands_insert( "PatchBevel", makeCallbackF(Patch_Bevel) );
+// GlobalCommands_insert( "PatchSquareBevel", makeCallbackF(Patch_SquareBevel) );
+// GlobalCommands_insert( "PatchSquareEndcap", makeCallbackF(Patch_SquareEndcap) );
+ GlobalCommands_insert( "PatchCone", makeCallbackF(Patch_Cone) );
+ GlobalCommands_insert( "PatchSphere", makeCallbackF(Patch_Sphere) );
+ GlobalCommands_insert( "SimplePatchMesh", makeCallbackF(Patch_Plane), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "PatchInsertFirstColumn", makeCallbackF(Patch_InsertFirstColumn), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "PatchInsertLastColumn", makeCallbackF(Patch_InsertLastColumn) );
+ GlobalCommands_insert( "PatchInsertFirstRow", makeCallbackF(Patch_InsertFirstRow), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "PatchInsertLastRow", makeCallbackF(Patch_InsertLastRow) );
+ GlobalCommands_insert( "PatchDeleteFirstColumn", makeCallbackF(Patch_DeleteFirstColumn) );
+ GlobalCommands_insert( "PatchDeleteLastColumn", makeCallbackF(Patch_DeleteLastColumn), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "PatchDeleteFirstRow", makeCallbackF(Patch_DeleteFirstRow), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "PatchDeleteLastRow", makeCallbackF(Patch_DeleteLastRow) );
+ GlobalCommands_insert( "InvertCurve", makeCallbackF(Patch_Invert), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "RedisperseRows", makeCallbackF(Patch_RedisperseRows), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "RedisperseCols", makeCallbackF(Patch_RedisperseCols), Accelerator( 'E', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "SmoothRows", makeCallbackF(Patch_SmoothRows), Accelerator( 'W', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "SmoothCols", makeCallbackF(Patch_SmoothCols), Accelerator( 'W', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "MatrixTranspose", makeCallbackF(Patch_Transpose), Accelerator( 'M', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "CapCurrentCurve", makeCallbackF(Patch_Cap), Accelerator( 'C', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "CycleCapTexturePatch", makeCallbackF(Patch_CycleProjection), Accelerator( 'N', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+// GlobalCommands_insert( "MakeOverlayPatch", makeCallbackF(Patch_OverlayOn), Accelerator( 'Y' ) );
+// GlobalCommands_insert( "ClearPatchOverlays", makeCallbackF(Patch_OverlayOff), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "PatchDeform", makeCallbackF(Patch_Deform) );
+ GlobalCommands_insert( "PatchThicken", makeCallbackF(Patch_Thicken), Accelerator( 'T', (GdkModifierType)GDK_CONTROL_MASK ) );
+}
+
+void Patch_constructToolbar( ui::Toolbar toolbar ){
+ toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "cap_curve.png", "CapCurrentCurve" );
+}
+
+void Patch_constructMenu( ui::Menu menu ){
create_menu_item_with_mnemonic( menu, "Simple Patch Mesh...", "SimplePatchMesh" );
create_menu_item_with_mnemonic( menu, "Bevel", "PatchBevel" );
create_menu_item_with_mnemonic( menu, "End cap", "PatchEndCap" );
create_menu_item_with_mnemonic( menu, "Sphere (9x5)", "PatchSphere" );
create_menu_item_with_mnemonic( menu, "Exact Sphere...", "PatchXactSphere" );
// {
-// GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" );
+// ui::Menu menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" );
// if ( g_Layout_enableDetachableMenus.m_value ) {
// menu_tearoff( menu_in_menu );
// }
create_menu_item_with_mnemonic( menu, "Cap Selection", "CapCurrentCurve" );
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert/Delete" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert/Delete" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
}
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Matrix" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Matrix" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
}
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Texture" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Texture" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
}
// menu_separator( menu );
-// { //unfinished
-// GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" );
+// {
+// auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" );
// if ( g_Layout_enableDetachableMenus.m_value ) {
// menu_tearoff( menu_in_menu );
// }
}
-#include <gtk/gtkbox.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtktogglebutton.h>
-#include <gtk/gtkradiobutton.h>
-#include <gtk/gtkcombobox.h>
-#include <gtk/gtkspinbutton.h>
-#include <gtk/gtklabel.h>
#include "gtkutil/dialog.h"
#include "gtkutil/widget.h"
void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, int defcols, int maxrows, int maxcols ){
ModalDialog dialog;
- GtkComboBox* width;
- GtkComboBox* height;
GtkWidget* redisperseCheckBox;
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch density", G_CALLBACK( dialog_delete_callback ), &dialog );
-
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel );
+ ui::Window window = MainFrame_getWindow().create_dialog_window("Patch density", G_CALLBACK(dialog_delete_callback ), &dialog );
+ auto accel = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel );
+ auto width = ui::ComboBoxText(ui::New);
+ auto height = ui::ComboBoxText(ui::New);
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkTable* table = create_dialog_table( 3, 2, 4, 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = create_dialog_table( 3, 2, 4, 4 );
+ hbox.pack_start( table, TRUE, TRUE, 0 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Width:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Width:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Height:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Height:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
-#define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_append_text( combo, # x )
+ auto combo = width;
+#define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_text_append_text( combo, #x )
D_ITEM( 3 );
D_ITEM( 5 );
D_ITEM( 7 );
D_ITEM( 29 );
D_ITEM( 31 ); // MAX_PATCH_SIZE is 32, so we should be able to do 31...
#undef D_ITEM
- gtk_widget_show( GTK_WIDGET( combo ) );
- gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
-
- width = combo;
+ combo.show();
+ table.attach(combo, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
}
{
- GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
-#define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_append_text( combo, # x )
+ auto combo = height;
+#define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_text_append_text( combo, #x )
D_ITEM( 3 );
D_ITEM( 5 );
D_ITEM( 7 );
D_ITEM( 29 );
D_ITEM( 31 ); // MAX_PATCH_SIZE is 32, so we should be able to do 31...
#undef D_ITEM
- gtk_widget_show( GTK_WIDGET( combo ) );
- gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
-
- height = combo;
+ combo.show();
+ table.attach(combo, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
}
if( prefab != ePlane ){
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_grab_focus( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_grab_focus( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
}
}
Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), prefab, GlobalXYWnd_getCurrentViewType(), w, h, redisperse );
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
}
GtkWidget* rndY;
GtkWidget* rndX;
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch deform", G_CALLBACK( dialog_delete_callback ), &dialog );
+ ui::Window window = create_dialog_window( MainFrame_getWindow(), "Patch deform", G_CALLBACK( dialog_delete_callback ), &dialog );
GtkAccelGroup* accel = gtk_accel_group_new();
gtk_window_add_accel_group( window, accel );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
+ auto hbox = create_dialog_hbox( 4, 4 );
gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
{
- GtkTable* table = create_dialog_table( 2, 2, 4, 4 );
+ auto table = create_dialog_table( 2, 2, 4, 4 );
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
{
GtkLabel* label = GTK_LABEL( gtk_label_new( "Max deform:" ) );
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_grab_focus( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_grab_focus( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
}
}
ModalDialog dialog;
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
- GtkWidget* bevel;
- GtkWidget* ibevel;
- GtkWidget* endcap;
- GtkWidget* iendcap;
- GtkWidget* cylinder;
+ ui::Widget bevel{ui::null};
+ ui::Widget ibevel{ui::null};
+ ui::Widget endcap{ui::null};
+ ui::Widget iendcap{ui::null};
+ ui::Widget cylinder{ui::null};
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Cap", dialog );
+ ui::Window window = MainFrame_getWindow().create_modal_dialog_window( "Cap", dialog );
- GtkAccelGroup *accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel_group );
+ auto accel_group = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel_group );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
// Gef: Added a vbox to contain the toggle buttons
- GtkVBox* radio_vbox = create_dialog_vbox( 4 );
- gtk_container_add( GTK_CONTAINER( hbox ), GTK_WIDGET( radio_vbox ) );
+ auto radio_vbox = create_dialog_vbox( 4 );
+ hbox.add(radio_vbox);
{
- GtkTable* table = GTK_TABLE( gtk_table_new( 5, 2, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
- gtk_box_pack_start( GTK_BOX( radio_vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = ui::Table( 5, 2, FALSE );
+ table.show();
+ radio_vbox.pack_start( table, TRUE, TRUE, 0 );
gtk_table_set_row_spacings( table, 5 );
gtk_table_set_col_spacings( table, 5 );
{
- GtkImage* image = new_local_image( "cap_bevel.png" );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto image = new_local_image( "cap_bevel.png" );
+ image.show();
+ table.attach(image, {0, 1, 0, 1}, {GTK_FILL, 0});
}
{
- GtkImage* image = new_local_image( "cap_endcap.png" );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto image = new_local_image( "cap_endcap.png" );
+ image.show();
+ table.attach(image, {0, 1, 1, 2}, {GTK_FILL, 0});
}
{
- GtkImage* image = new_local_image( "cap_ibevel.png" );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto image = new_local_image( "cap_ibevel.png" );
+ image.show();
+ table.attach(image, {0, 1, 2, 3}, {GTK_FILL, 0});
}
{
- GtkImage* image = new_local_image( "cap_iendcap.png" );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 3, 4,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto image = new_local_image( "cap_iendcap.png" );
+ image.show();
+ table.attach(image, {0, 1, 3, 4}, {GTK_FILL, 0});
}
{
- GtkImage* image = new_local_image( "cap_cylinder.png" );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 4, 5,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto image = new_local_image( "cap_cylinder.png" );
+ image.show();
+ table.attach(image, {0, 1, 4, 5}, {GTK_FILL, 0});
}
GSList* group = 0;
{
- GtkWidget* button = gtk_radio_button_new_with_label( group, "Bevel" );
- gtk_widget_show( button );
- gtk_table_attach( table, button, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
+ ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Bevel" ));
+ button.show();
+ table.attach(button, {1, 2, 0, 1}, {GTK_FILL | GTK_EXPAND, 0});
+ group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
bevel = button;
}
{
- GtkWidget* button = gtk_radio_button_new_with_label( group, "Endcap" );
- gtk_widget_show( button );
- gtk_table_attach( table, button, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
+ ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Endcap" ));
+ button.show();
+ table.attach(button, {1, 2, 1, 2}, {GTK_FILL | GTK_EXPAND, 0});
+ group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
endcap = button;
}
{
- GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Bevel" );
- gtk_widget_show( button );
- gtk_table_attach( table, button, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
+ ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Inverted Bevel" ));
+ button.show();
+ table.attach(button, {1, 2, 2, 3}, {GTK_FILL | GTK_EXPAND, 0});
+ group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
ibevel = button;
}
{
- GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Endcap" );
- gtk_widget_show( button );
- gtk_table_attach( table, button, 1, 2, 3, 4,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
+ ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Inverted Endcap" ));
+ button.show();
+ table.attach(button, {1, 2, 3, 4}, {GTK_FILL | GTK_EXPAND, 0});
+ group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
iendcap = button;
}
{
- GtkWidget* button = gtk_radio_button_new_with_label( group, "Cylinder" );
- gtk_widget_show( button );
- gtk_table_attach( table, button, 1, 2, 4, 5,
- (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
+ ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Cylinder" ));
+ button.show();
+ table.attach(button, {1, 2, 4, 5}, {GTK_FILL | GTK_EXPAND, 0});
+ group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
cylinder = button;
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
{
- GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "Cancel", cancel_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
}
}
}
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
return ret;
}
GtkWidget* radY;
GtkWidget* radZ;
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch thicken", G_CALLBACK( dialog_delete_callback ), &dialog );
+ ui::Window window = create_dialog_window( MainFrame_getWindow(), "Patch thicken", G_CALLBACK( dialog_delete_callback ), &dialog );
GtkAccelGroup* accel = gtk_accel_group_new();
gtk_window_add_accel_group( window, accel );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
+ auto hbox = create_dialog_hbox( 4, 4 );
gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
{
- GtkTable* table = create_dialog_table( 2, 4, 4, 4 );
+ auto table = create_dialog_table( 2, 4, 4, 4 );
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
{
GtkLabel* label = GTK_LABEL( gtk_label_new( "Thickness:" ) );
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_grab_focus( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_grab_focus( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
}
}
#if !defined ( INCLUDED_PATCHMANIP_H )
#define INCLUDED_PATCHMANIP_H
+#include <uilib/uilib.h>
#include "string/stringfwd.h"
void Patch_registerCommands();
-typedef struct _GtkToolbar GtkToolbar;
-typedef struct _GtkMenu GtkMenu;
-void Patch_constructToolbar( GtkToolbar* toolbar );
-void Patch_constructMenu( GtkMenu* menu );
+void Patch_constructToolbar( ui::Toolbar toolbar );
+void Patch_constructMenu( ui::Menu menu );
namespace scene
{
void Patch_registerPreferencesPage();
+void Patch_NaturalTexture();
+void Patch_CapTexture();
+void Patch_ResetTexture();
+void Patch_FitTexture();
+void Patch_FlipTextureX();
+void Patch_FlipTextureY();
+void Patch_AutoCapTexture();
+
void Patch_NaturalTexture();
void Patch_CapTexture();
void Patch_ResetTexture();
return TextureBrowser_GetSelectedShader( GlobalTextureBrowser() );
}
+const char* getGameFile(){
+ return g_GamesDialog.m_sGameFile.c_str();
+}
+
class RadiantCoreAPI
{
_QERFuncTable_1 m_radiantcore;
m_radiantcore.getSettingsPath = &SettingsPath_get;
m_radiantcore.getMapsPath = &getMapsPath;
+ m_radiantcore.getGameFile = &getGameFile;
m_radiantcore.getGameName = &gamename_get;
m_radiantcore.getGameMode = &gamemode_get;
m_radiantcore.getGameDescriptionKeyValue = &GameDescription_getKeyValue;
m_radiantcore.getRequiredGameDescriptionKeyValue = &GameDescription_getRequiredKeyValue;
- m_radiantcore.attachGameToolsPathObserver = Radiant_attachGameToolsPathObserver;
- m_radiantcore.detachGameToolsPathObserver = Radiant_detachGameToolsPathObserver;
- m_radiantcore.attachEnginePathObserver = Radiant_attachEnginePathObserver;
- m_radiantcore.detachEnginePathObserver = Radiant_detachEnginePathObserver;
- m_radiantcore.attachGameNameObserver = Radiant_attachGameNameObserver;
- m_radiantcore.detachGameNameObserver = Radiant_detachGameNameObserver;
- m_radiantcore.attachGameModeObserver = Radiant_attachGameModeObserver;
- m_radiantcore.detachGameModeObserver = Radiant_detachGameModeObserver;
-
m_radiantcore.XYWindowDestroyed_connect = XYWindowDestroyed_connect;
m_radiantcore.XYWindowDestroyed_disconnect = XYWindowDestroyed_disconnect;
m_radiantcore.XYWindowMouseDown_connect = XYWindowMouseDown_connect;
#if 0
CamWnd* camwnd = g_pParentWnd->GetCamWnd();
- gtk_window_get_position( GTK_WINDOW( camwnd->m_window ), x, y );
+ gtk_window_get_position( camwnd->m_window, x, y );
*width = camwnd->Camera()->width;
*height = camwnd->Camera()->height;
/*!
build directly from a SYN_PROVIDE interface
*/
-CPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table );
+CPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table );
/*!
dispatching a command by name to the plugin
*/
};
-CPluginSlot::CPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ){
+CPluginSlot::CPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ){
mpTable = &table;
m_menu_name = name;
public:
virtual ~CPluginSlots();
-void AddPluginSlot( GtkWidget* main_window, const char* name, const _QERPluginTable& table ){
+void AddPluginSlot( ui::Widget main_window, const char* name, const _QERPluginTable& table ){
mSlots.push_back( new CPluginSlot( main_window, name, table ) );
}
CPluginSlots g_plugin_slots;
-void FillPluginSlots( CPluginSlots& slots, GtkWidget* main_window ){
+void FillPluginSlots( CPluginSlots& slots, ui::Widget main_window ){
class AddPluginVisitor : public PluginModules::Visitor
{
CPluginSlots& m_slots;
- GtkWidget* m_main_window;
+ ui::Widget m_main_window;
public:
- AddPluginVisitor( CPluginSlots& slots, GtkWidget* main_window )
+ AddPluginVisitor( CPluginSlots& slots, ui::Widget main_window )
: m_slots( slots ), m_main_window( main_window ){
}
void visit( const char* name, const _QERPluginTable& table ) const {
g_plugin_slots.Dispatch( n, p );
}
-void CPlugInManager::Init( GtkWidget* main_window ){
+void CPlugInManager::Init( ui::Widget main_window ){
FillPluginSlots( g_plugin_slots, main_window );
}
#define INCLUDED_PLUGINMANAGER_H
#include <cstddef>
+#include <uilib/uilib.h>
-typedef struct _GtkWidget GtkWidget;
/*!
\class IPlugin
{
public:
void Dispatch( std::size_t n, const char *p );
-void Init( GtkWidget* main_window );
+void Init( ui::Widget main_window );
void constructMenu( PluginsVisitor& menu );
void Shutdown();
};
#include "pluginmenu.h"
-#include "stream/textstream.h"
+#include <gtk/gtk.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkmenuitem.h>
+#include "stream/textstream.h"
#include "gtkutil/pointer.h"
#include "gtkutil/menu.h"
int m_nNextPlugInID = 0;
-void plugin_activated( GtkWidget* widget, gpointer data ){
+void plugin_activated( ui::Widget widget, gpointer data ){
const char* str = (const char*)g_object_get_data( G_OBJECT( widget ),"command" );
GetPlugInMgr().Dispatch( gpointer_to_int( data ), str );
}
#include <stack>
-typedef std::stack<GtkWidget*> WidgetStack;
-void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){
- GtkWidget *menu, *item, *parent, *subMenu;
+void PlugInMenu_Add( ui::Menu plugin_menu, IPlugIn* pPlugIn ){
+ ui::Widget item{ui::null}, parent{ui::null};
+ ui::Menu menu{ui::null}, subMenu{ui::null};
const char *menuText, *menuCommand;
- WidgetStack menuStack;
+ std::stack<ui::Menu> menuStack;
- parent = gtk_menu_item_new_with_label( pPlugIn->getMenuName() );
- gtk_widget_show( parent );
- gtk_container_add( GTK_CONTAINER( plugin_menu ), parent );
+ parent = ui::MenuItem( pPlugIn->getMenuName() );
+ parent.show();
+ plugin_menu.add(parent);
std::size_t nCount = pPlugIn->getCommandCount();
if ( nCount > 0 ) {
- menu = gtk_menu_new();
+ menu = ui::Menu(ui::New);
if ( g_Layout_enableDetachableMenus.m_value ) {
- menu_tearoff( GTK_MENU( menu ) );
+ menu_tearoff( menu );
}
while ( nCount > 0 )
{
if ( menuText != 0 && strlen( menuText ) > 0 ) {
if ( !strcmp( menuText, "-" ) ) {
- item = gtk_menu_item_new();
+ item = ui::Widget::from(gtk_menu_item_new());
gtk_widget_set_sensitive( item, FALSE );
}
else if ( !strcmp( menuText, ">" ) ) {
continue;
}
- item = gtk_menu_item_new_with_label( menuText );
- gtk_widget_show( item );
- gtk_container_add( GTK_CONTAINER( menu ), item );
+ item = ui::MenuItem( menuText );
+ item.show();
+ menu.add(item);
- subMenu = gtk_menu_new();
+ subMenu = ui::Menu(ui::New);
gtk_menu_item_set_submenu( GTK_MENU_ITEM( item ), subMenu );
menuStack.push( menu );
menu = subMenu;
}
else
{
- item = gtk_menu_item_new_with_label( menuText );
+ item = ui::MenuItem( menuText );
g_object_set_data( G_OBJECT( item ),"command", const_cast<gpointer>( static_cast<const void*>( menuCommand ) ) );
- g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( plugin_activated ), gint_to_pointer( m_nNextPlugInID ) );
+ item.connect( "activate", G_CALLBACK( plugin_activated ), gint_to_pointer( m_nNextPlugInID ) );
}
- gtk_widget_show( item );
- gtk_container_add( GTK_CONTAINER( menu ), item );
+ item.show();
+ menu.add(item);
pPlugIn->addMenuID( m_nNextPlugInID++ );
}
}
}
}
-GtkMenu* g_plugins_menu = 0;
-GtkMenuItem* g_plugins_menu_separator = 0;
+ui::Menu g_plugins_menu{ui::null};
+ui::MenuItem g_plugins_menu_separator{ui::null};
void PluginsMenu_populate(){
class PluginsMenuConstructor : public PluginsVisitor
{
- GtkMenu* m_menu;
+ ui::Menu m_menu;
public:
- PluginsMenuConstructor( GtkMenu* menu ) : m_menu( menu ){
+ PluginsMenuConstructor( ui::Menu menu ) : m_menu( menu ){
}
void visit( IPlugIn& plugin ){
PlugInMenu_Add( m_menu, &plugin );
void PluginsMenu_clear(){
m_nNextPlugInID = 0;
- GList* lst = g_list_find( gtk_container_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) );
+ GList* lst = g_list_find( gtk_container_get_children( GTK_CONTAINER( g_plugins_menu ) ), g_plugins_menu_separator._handle );
while ( lst->next )
{
- gtk_container_remove( GTK_CONTAINER( g_plugins_menu ), GTK_WIDGET( lst->next->data ) );
- lst = g_list_find( gtk_container_children( GTK_CONTAINER( g_plugins_menu ) ), GTK_WIDGET( g_plugins_menu_separator ) );
+ g_plugins_menu.remove(ui::Widget::from(lst->next->data));
+ lst = g_list_find( gtk_container_get_children( GTK_CONTAINER( g_plugins_menu ) ), g_plugins_menu_separator._handle );
}
}
-GtkMenuItem* create_plugins_menu(){
+ui::MenuItem create_plugins_menu(){
// Plugins menu
- GtkMenuItem* plugins_menu_item = new_sub_menu_item_with_mnemonic( "_Plugins" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( plugins_menu_item ) );
+ auto plugins_menu_item = new_sub_menu_item_with_mnemonic( "_Plugins" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( plugins_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
//TODO: some modules/plugins do not yet support refresh
#if 0
- create_menu_item_with_mnemonic( menu, "Refresh", FreeCaller<Restart>() );
+ create_menu_item_with_mnemonic( menu, "Refresh", makeCallbackF(Restart) );
// NOTE: the seperator is used when doing a refresh of the list, everything past the seperator is removed
g_plugins_menu_separator = menu_separator( menu );
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_PLUGINMENU_H )
#define INCLUDED_PLUGINMENU_H
-typedef struct _GtkMenuItem GtkMenuItem;
-GtkMenuItem* create_plugins_menu();
+ui::MenuItem create_plugins_menu();
-typedef struct _GtkMenu GtkMenu;
-typedef struct _GtkMenuItem GtkMenuItem;
void PluginsMenu_populate();
void PluginsMenu_clear();
#include "plugintoolbar.h"
+#include <gtk/gtk.h>
#include "itoolbar.h"
#include "modulesystem.h"
-#include <gtk/gtktoolbar.h>
-
#include "stream/stringstream.h"
#include "gtkutil/image.h"
#include "gtkutil/container.h"
#include "mainframe.h"
#include "plugin.h"
-GtkImage* new_plugin_image( const char* filename ){
+ui::Image new_plugin_image( const char* filename ){
{
StringOutputStream fullpath( 256 );
fullpath << AppPath_get() << g_pluginsDir << "bitmaps/" << filename;
- GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() );
- if ( image != 0 ) {
- return image;
- }
+ if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image;
}
{
StringOutputStream fullpath( 256 );
fullpath << GameToolsPath_get() << g_pluginsDir << "bitmaps/" << filename;
- GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() );
- if ( image != 0 ) {
- return image;
- }
+ if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image;
}
{
StringOutputStream fullpath( 256 );
fullpath << AppPath_get() << g_modulesDir << "bitmaps/" << filename;
- GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() );
- if ( image != 0 ) {
- return image;
- }
+ if ( auto image = image_new_from_file_with_mask(fullpath.c_str()) ) return image;
}
return image_new_missing();
}
-inline GtkToolbarChildType gtktoolbarchildtype_for_toolbarbuttontype( IToolbarButton::EType type ){
- switch ( type )
- {
- case IToolbarButton::eSpace:
- return GTK_TOOLBAR_CHILD_SPACE;
- case IToolbarButton::eButton:
- return GTK_TOOLBAR_CHILD_BUTTON;
- case IToolbarButton::eToggleButton:
- return GTK_TOOLBAR_CHILD_TOGGLEBUTTON;
- case IToolbarButton::eRadioButton:
- return GTK_TOOLBAR_CHILD_RADIOBUTTON;
+void toolbar_insert( ui::Toolbar toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GCallback handler, gpointer data ){
+ if (type == IToolbarButton::eSpace) {
+ auto it = ui::ToolItem::from(gtk_separator_tool_item_new());
+ it.show();
+ toolbar.add(it);
+ return;
}
- ERROR_MESSAGE( "invalid toolbar button type" );
- return (GtkToolbarChildType)0;
-}
-
-void toolbar_insert( GtkToolbar *toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GtkSignalFunc handler, gpointer data ){
- GtkWidget* widget = gtk_toolbar_append_element( toolbar, gtktoolbarchildtype_for_toolbarbuttontype( type ), 0, text, tooltip, "", GTK_WIDGET( new_plugin_image( icon ) ), handler, data );
- if( type != IToolbarButton::eSpace ){
+ #define GARUX_DISABLE_SPACER_NOFOCUS
+ #ifndef GARUX_DISABLE_SPACER_NOFOCUS
+ else {
GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_FOCUS );
GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_DEFAULT );
}
+ #endif // GARUX_DISABLE_SPACER_NOFOCUS
+
+ if (type == IToolbarButton::eButton) {
+ auto button = ui::ToolButton::from(gtk_tool_button_new(new_plugin_image(icon), text));
+ gtk_widget_set_tooltip_text(button, tooltip);
+ gtk_widget_show_all(button);
+ button.connect("clicked", G_CALLBACK(handler), data);
+ toolbar.add(button);
+ return;
+ }
+
+ if (type == IToolbarButton::eToggleButton) {
+ auto button = ui::ToolButton::from(gtk_toggle_tool_button_new());
+ gtk_tool_button_set_icon_widget(button, new_plugin_image(icon));
+ gtk_tool_button_set_label(button, text);
+ gtk_widget_set_tooltip_text(button, tooltip);
+ gtk_widget_show_all(button);
+ button.connect("toggled", G_CALLBACK(handler), data);
+ toolbar.add(button);
+ return;
+ }
+
+ ERROR_MESSAGE( "invalid toolbar button type" );
}
-void ActivateToolbarButton( GtkWidget *widget, gpointer data ){
- const_cast<const IToolbarButton*>( reinterpret_cast<IToolbarButton*>( data ) )->activate();
+void ActivateToolbarButton( ui::ToolButton widget, gpointer data ){
+ (const_cast<const IToolbarButton *>( reinterpret_cast<IToolbarButton *>( data )))->activate();
}
-void PlugInToolbar_AddButton( GtkToolbar* toolbar, const IToolbarButton* button ){
- toolbar_insert( toolbar, button->getImage(), button->getText(), button->getTooltip(), button->getType(), GTK_SIGNAL_FUNC( ActivateToolbarButton ), reinterpret_cast<gpointer>( const_cast<IToolbarButton*>( button ) ) );
+void PlugInToolbar_AddButton( ui::Toolbar toolbar, const IToolbarButton* button ){
+ toolbar_insert( toolbar, button->getImage(), button->getText(), button->getTooltip(), button->getType(), G_CALLBACK( ActivateToolbarButton ), reinterpret_cast<gpointer>( const_cast<IToolbarButton*>( button ) ) );
}
-GtkToolbar* g_plugin_toolbar = 0;
+ui::Toolbar g_plugin_toolbar{ui::null};
void PluginToolbar_populate(){
class AddToolbarItemVisitor : public ToolbarModules::Visitor
{
- GtkToolbar* m_toolbar;
+ ui::Toolbar m_toolbar;
public:
- AddToolbarItemVisitor( GtkToolbar* toolbar )
+ AddToolbarItemVisitor( ui::Toolbar toolbar )
: m_toolbar( toolbar ){
}
void visit( const char* name, const _QERPlugToolbarTable& table ) const {
}
void PluginToolbar_clear(){
- container_remove_all( GTK_CONTAINER( g_plugin_toolbar ) );
+ container_remove_all( g_plugin_toolbar );
}
-GtkToolbar* create_plugin_toolbar(){
- GtkToolbar *toolbar;
+ui::Toolbar create_plugin_toolbar(){
- toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
- gtk_toolbar_set_orientation( toolbar, GTK_ORIENTATION_HORIZONTAL );
+ auto toolbar = ui::Toolbar::from( gtk_toolbar_new() );
+ gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL );
gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS );
// gtk_toolbar_set_show_arrow( toolbar, TRUE );
- gtk_widget_show( GTK_WIDGET( toolbar ) );
+ toolbar.show();
g_plugin_toolbar = toolbar;
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_PLUGINTOOLBAR_H )
#define INCLUDED_PLUGINTOOLBAR_H
-typedef struct _GtkToolbar GtkToolbar;
-GtkToolbar* create_plugin_toolbar();
+ui::Toolbar create_plugin_toolbar();
+
void PluginToolbar_populate();
void PluginToolbar_clear();
-typedef struct _GtkImage GtkImage;
-GtkImage* new_plugin_image( const char* filename ); // filename is relative to plugin bitmaps path
+ui::Image new_plugin_image( const char* filename ); // filename is relative to plugin bitmaps path
#endif
GlobalShaderCache().attachRenderable( s_pointfile );
- GlobalCommands_insert( "TogglePointfile", FreeCaller<Pointfile_Toggle>() );
- GlobalCommands_insert( "NextLeakSpot", FreeCaller<Pointfile_Next>(), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "PrevLeakSpot", FreeCaller<Pointfile_Prev>(), Accelerator( 'L', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "TogglePointfile", makeCallbackF(Pointfile_Toggle) );
+ GlobalCommands_insert( "NextLeakSpot", makeCallbackF(Pointfile_Next), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "PrevLeakSpot", makeCallbackF(Pointfile_Prev), Accelerator( 'L', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
}
void Pointfile_Destroy(){
{
class PreferenceEntry
{
-StringImportCallback m_importer;
-StringExportCallback m_exporter;
+Property<const char *> m_cb;
public:
-PreferenceEntry( const StringImportCallback& importer, const StringExportCallback& exporter )
- : m_importer( importer ), m_exporter( exporter ){
+PreferenceEntry( const Property<const char *>& cb )
+ : m_cb( cb ){
}
void importString( const char* string ){
- m_importer( string );
+ m_cb.set( string );
}
-void exportString( const StringImportCallback& importer ){
- m_exporter( importer );
+void exportString( const Callback<void(const char *)> & importer ){
+ m_cb.get( importer );
}
};
return m_preferences.find( name );
}
-void registerPreference( const char* name, const StringImportCallback& importer, const StringExportCallback& exporter ){
- m_preferences.insert( PreferenceEntries::value_type( name, PreferenceEntry( importer, exporter ) ) );
+void registerPreference( const char* name, const Property<const char *>& cb ){
+ m_preferences.insert( PreferenceEntries::value_type( name, PreferenceEntry( cb ) ) );
PreferenceCache::iterator i = m_cache.find( name );
if ( i != m_cache.end() ) {
- importer( ( *i ).second.c_str() );
+ cb.set( i->second.c_str() );
m_cache.erase( i );
}
}
inline void XMLPreference_importString( XMLImporter& importer, const char* value ){
importer.write( value, string_length( value ) );
}
-typedef ReferenceCaller1<XMLImporter, const char*, XMLPreference_importString> XMLPreferenceImportStringCaller;
+typedef ReferenceCaller<XMLImporter, void(const char*), XMLPreference_importString> XMLPreferenceImportStringCaller;
class XMLPreferenceDictionaryExporter : public XMLExporter
{
//
#include "preferences.h"
+#include "globaldefs.h"
+
+#include <gtk/gtk.h>
#include "environment.h"
#include "debugging/debugging.h"
-#include <gtk/gtkmain.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktogglebutton.h>
-#include <gtk/gtkspinbutton.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktreemodel.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtktreestore.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtknotebook.h>
-
#include "generic/callback.h"
#include "math/vector.h"
#include "string/string.h"
}
void Interface_constructPreferences( PreferencesPage& page ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
page.appendCheckBox( "", "External Shader Editor", g_TextEditor_useWin32Editor );
#else
{
- GtkWidget* use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor );
- GtkWidget* custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true );
+ ui::CheckButton use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor );
+ ui::Widget custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true );
Widget_connectToggleDependency( custom_editor, use_custom );
}
#endif
Mouse_constructPreferences( page );
}
void Mouse_registerPreferencesPage(){
- PreferencesDialog_addInterfacePage( FreeCaller1<PreferenceGroup&, Mouse_constructPage>() );
+ PreferencesDialog_addInterfacePage( makeCallbackF(Mouse_constructPage) );
}
*/
#include <map>
+#include <uilib/uilib.h>
inline const char* xmlAttr_getName( xmlAttrPtr attr ){
return reinterpret_cast<const char*>( attr->name );
}
+struct LogConsole {
+ static void Export(const Callback<void(bool)> &returnz) {
+ returnz(g_Console_enableLogging);
+ }
-void LogConsole_importString( const char* string ){
- g_Console_enableLogging = string_equal( string, "true" );
- Sys_LogFile( g_Console_enableLogging );
-}
-typedef FreeCaller1<const char*, LogConsole_importString> LogConsoleImportStringCaller;
+ static void Import(bool value) {
+ g_Console_enableLogging = value;
+ Sys_LogFile(g_Console_enableLogging);
+ }
+};
void RegisterGlobalPreferences( PreferenceSystem& preferences ){
- preferences.registerPreference( "gamefile", CopiedStringImportStringCaller( g_GamesDialog.m_sGameFile ), CopiedStringExportStringCaller( g_GamesDialog.m_sGameFile ) );
- preferences.registerPreference( "gamePrompt", BoolImportStringCaller( g_GamesDialog.m_bGamePrompt ), BoolExportStringCaller( g_GamesDialog.m_bGamePrompt ) );
- preferences.registerPreference( "log console", LogConsoleImportStringCaller(), BoolExportStringCaller( g_Console_enableLogging ) );
+ preferences.registerPreference( "gamefile", make_property_string( g_GamesDialog.m_sGameFile ) );
+ preferences.registerPreference( "gamePrompt", make_property_string( g_GamesDialog.m_bGamePrompt ) );
+ preferences.registerPreference( "log console", make_property_string<LogConsole>() );
}
m_sGameFile = ( *iGame )->mGameFile;
}
-void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) const {
+void CGameDialog::GameFileExport( const Callback<void(int)> & importCallback ) const {
// use m_sGameFile to set value
std::list<CGameDescription *>::const_iterator iGame;
int i = 0;
importCallback( m_nComboSelect );
}
-void CGameDialog_GameFileImport( CGameDialog& self, int value ){
- self.GameFileImport( value );
-}
+struct CGameDialog_GameFile {
+ static void Export(const CGameDialog &self, const Callback<void(int)> &returnz) {
+ self.GameFileExport(returnz);
+ }
-void CGameDialog_GameFileExport( CGameDialog& self, const IntImportCallback& importCallback ){
- self.GameFileExport( importCallback );
-}
+ static void Import(CGameDialog &self, int value) {
+ self.GameFileImport(value);
+ }
+};
void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){
std::vector<const char*> games;
page.appendCombo(
"Select the game",
StringArrayRange( &( *games.begin() ), &( *games.end() ) ),
- ReferenceCaller1<CGameDialog, int, CGameDialog_GameFileImport>( *this ),
- ReferenceCaller1<CGameDialog, const IntImportCallback&, CGameDialog_GameFileExport>( *this )
+ make_property<CGameDialog_GameFile>(*this)
);
page.appendCheckBox( "Startup", "Show Global Preferences", m_bGamePrompt );
}
-GtkWindow* CGameDialog::BuildDialog(){
- GtkFrame* frame = create_dialog_frame( "Game settings", GTK_SHADOW_ETCHED_IN );
+ui::Window CGameDialog::BuildDialog(){
+ auto frame = create_dialog_frame( "Game settings", ui::Shadow::ETCHED_IN );
- GtkVBox* vbox2 = create_dialog_vbox( 0, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
+ auto vbox2 = create_dialog_vbox( 0, 4 );
+ frame.add(vbox2);
{
- PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) );
+ PreferencesPage preferencesPage( *this, vbox2 );
Global_constructPreferences( preferencesPage );
CreateGlobalFrame( preferencesPage );
}
- return create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) );
-}
-
-class LoadGameFile
-{
-std::list<CGameDescription*>& mGames;
-const char* mPath;
-public:
-LoadGameFile( std::list<CGameDescription*>& games, const char* path ) : mGames( games ), mPath( path ){
-}
-void operator()( const char* name ) const {
- if ( !extension_equal( path_get_extension( name ), "game" ) ) {
- return;
- }
- StringOutputStream strPath( 256 );
- strPath << mPath << name;
- globalOutputStream() << strPath.c_str() << '\n';
-
- xmlDocPtr pDoc = xmlParseFile( strPath.c_str() );
- if ( pDoc ) {
- mGames.push_front( new CGameDescription( pDoc, name ) );
- xmlFreeDoc( pDoc );
- }
- else
- {
- globalErrorStream() << "XML parser failed on '" << strPath.c_str() << "'\n";
- }
+ return create_simple_modal_dialog_window( "Global Preferences", m_modal, frame );
}
-};
void CGameDialog::ScanForGames(){
StringOutputStream strGamesPath( 256 );
(if that's really needed)
*/
- Directory_forEach( path, LoadGameFile( mGames, path ) );
+ Directory_forEach(path, [&](const char *name) {
+ if (!extension_equal(path_get_extension(name), "game")) {
+ return;
+ }
+ StringOutputStream strPath(256);
+ strPath << path << name;
+ globalOutputStream() << strPath.c_str() << '\n';
+
+ xmlDocPtr pDoc = xmlParseFile(strPath.c_str());
+ if (pDoc) {
+ mGames.push_front(new CGameDescription(pDoc, name));
+ xmlFreeDoc(pDoc);
+ } else {
+ globalErrorStream() << "XML parser failed on '" << strPath.c_str() << "'\n";
+ }
+ });
}
CGameDescription* CGameDialog::GameDescriptionForComboItem(){
delete ( *iGame );
*iGame = 0;
}
- if ( GetWidget() != 0 ) {
+ if ( GetWidget() ) {
Destroy();
}
}
return identifier;
}
-void CGameDialog::AddPacksURL( StringOutputStream &URL ){
- // add the URLs for the list of game packs installed
- // FIXME: this is kinda hardcoded for now..
- std::list<CGameDescription *>::iterator iGame;
- for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame )
- {
- URL << "&Games_dlup%5B%5D=" << GameDescription_getIdentifier( *( *iGame ) );
- }
-}
CGameDialog g_GamesDialog;
// =============================================================================
// Widget callbacks for PrefsDlg
-static void OnButtonClean( GtkWidget *widget, gpointer data ){
+static void OnButtonClean( ui::Widget widget, gpointer data ){
// make sure this is what the user wants
- if ( gtk_MessageBox( GTK_WIDGET( g_Preferences.GetWidget() ), "This will close Radiant and clean the corresponding registry entries.\n"
+ if ( ui::alert( g_Preferences.GetWidget(), "This will close Radiant and clean the corresponding registry entries.\n"
"Next time you start Radiant it will be good as new. Do you wish to continue?",
- "Reset Registry", eMB_YESNO, eMB_ICONASTERISK ) == eIDYES ) {
+ "Reset Registry", ui::alert_type::YESNO, ui::alert_icon::Asterisk ) == ui::alert_response::YES ) {
PrefsDlg *dlg = (PrefsDlg*)data;
dlg->EndModal( eIDCANCEL );
========
*/
-#define PREFS_LOCAL_FILENAME "local.pref"
+const char *PREFS_LOCAL_FILENAME = "local.pref";
void PrefsDlg::Init(){
// m_global_rc_path has been set above
g_string_append( m_inipath, PREFS_LOCAL_FILENAME );
}
-void notebook_set_page( GtkWidget* notebook, GtkWidget* page ){
+void notebook_set_page( ui::Widget notebook, ui::Widget page ){
int pagenum = gtk_notebook_page_num( GTK_NOTEBOOK( notebook ), page );
if ( gtk_notebook_get_current_page( GTK_NOTEBOOK( notebook ) ) != pagenum ) {
gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook ), pagenum );
}
}
-void PrefsDlg::showPrefPage( GtkWidget* prefpage ){
+void PrefsDlg::showPrefPage( ui::Widget prefpage ){
notebook_set_page( m_notebook, prefpage );
return;
}
-static void treeSelection( GtkTreeSelection* selection, gpointer data ){
+static void treeSelection( ui::TreeSelection selection, gpointer data ){
PrefsDlg *dlg = (PrefsDlg*)data;
GtkTreeModel* model;
GtkTreeIter selected;
if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) {
- GtkWidget* prefpage;
+ ui::Widget prefpage{ui::null};
gtk_tree_model_get( model, &selected, 1, (gpointer*)&prefpage, -1 );
dlg->showPrefPage( prefpage );
}
PreferenceGroupCallbacks_pushBack( g_settingsCallbacks, callback );
}
-void Widget_updateDependency( GtkWidget* self, GtkWidget* toggleButton ){
- gtk_widget_set_sensitive( self, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggleButton ) ) && GTK_WIDGET_IS_SENSITIVE( toggleButton ) );
+void Widget_updateDependency( ui::Widget self, ui::Widget toggleButton ){
+ gtk_widget_set_sensitive( self, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggleButton ) ) && gtk_widget_is_sensitive( toggleButton ) );
}
-void ToggleButton_toggled_Widget_updateDependency( GtkWidget *toggleButton, GtkWidget* self ){
+void ToggleButton_toggled_Widget_updateDependency( ui::Widget toggleButton, ui::Widget self ){
Widget_updateDependency( self, toggleButton );
}
-void ToggleButton_state_changed_Widget_updateDependency( GtkWidget* toggleButton, GtkStateType state, GtkWidget* self ){
+void ToggleButton_state_changed_Widget_updateDependency( ui::Widget toggleButton, GtkStateType state, ui::Widget self ){
if ( state == GTK_STATE_INSENSITIVE ) {
Widget_updateDependency( self, toggleButton );
}
}
-void Widget_connectToggleDependency( GtkWidget* self, GtkWidget* toggleButton ){
- g_signal_connect( G_OBJECT( toggleButton ), "state_changed", G_CALLBACK( ToggleButton_state_changed_Widget_updateDependency ), self );
- g_signal_connect( G_OBJECT( toggleButton ), "toggled", G_CALLBACK( ToggleButton_toggled_Widget_updateDependency ), self );
+void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton ){
+ toggleButton.connect( "state_changed", G_CALLBACK( ToggleButton_state_changed_Widget_updateDependency ), self );
+ toggleButton.connect( "toggled", G_CALLBACK( ToggleButton_toggled_Widget_updateDependency ), self );
Widget_updateDependency( self, toggleButton );
}
-inline GtkWidget* getVBox( GtkWidget* page ){
- return gtk_bin_get_child( GTK_BIN( page ) );
+inline ui::VBox getVBox( ui::Bin page ){
+ return ui::VBox::from(gtk_bin_get_child(page));
}
-GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, GtkWidget* page ){
+GtkTreeIter PreferenceTree_appendPage( ui::TreeStore store, GtkTreeIter* parent, const char* name, ui::Widget page ){
GtkTreeIter group;
gtk_tree_store_append( store, &group, parent );
gtk_tree_store_set( store, &group, 0, name, 1, page, -1 );
return group;
}
-GtkWidget* PreferencePages_addPage( GtkWidget* notebook, const char* name ){
- GtkWidget* preflabel = gtk_label_new( name );
- gtk_widget_show( preflabel );
+ui::Bin PreferencePages_addPage( ui::Widget notebook, const char* name ){
+ ui::Widget preflabel = ui::Label( name );
+ preflabel.show();
- GtkWidget* pageframe = gtk_frame_new( name );
+ auto pageframe = ui::Frame( name );
gtk_container_set_border_width( GTK_CONTAINER( pageframe ), 4 );
- gtk_widget_show( pageframe );
+ pageframe.show();
- GtkWidget* vbox = gtk_vbox_new( FALSE, 4 );
- gtk_widget_show( vbox );
+ ui::Widget vbox = ui::VBox( FALSE, 4 );
+ vbox.show();
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 4 );
- gtk_container_add( GTK_CONTAINER( pageframe ), vbox );
+ pageframe.add(vbox);
// Add the page to the notebook
gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), pageframe, preflabel );
class PreferenceTreeGroup : public PreferenceGroup
{
Dialog& m_dialog;
-GtkWidget* m_notebook;
-GtkTreeStore* m_store;
+ui::Widget m_notebook;
+ui::TreeStore m_store;
GtkTreeIter m_group;
public:
-PreferenceTreeGroup( Dialog& dialog, GtkWidget* notebook, GtkTreeStore* store, GtkTreeIter group ) :
+PreferenceTreeGroup( Dialog& dialog, ui::Widget notebook, ui::TreeStore store, GtkTreeIter group ) :
m_dialog( dialog ),
m_notebook( notebook ),
m_store( store ),
m_group( group ){
}
PreferencesPage createPage( const char* treeName, const char* frameName ){
- GtkWidget* page = PreferencePages_addPage( m_notebook, frameName );
+ auto page = PreferencePages_addPage( m_notebook, frameName );
PreferenceTree_appendPage( m_store, &m_group, treeName, page );
return PreferencesPage( m_dialog, getVBox( page ) );
}
};
-GtkWindow* PrefsDlg::BuildDialog(){
- PreferencesDialog_addInterfacePreferences( FreeCaller1<PreferencesPage&, Interface_constructPreferences>() );
+ui::Window PrefsDlg::BuildDialog(){
+ PreferencesDialog_addInterfacePreferences( makeCallbackF(Interface_constructPreferences) );
Mouse_registerPreferencesPage();
- GtkWindow* dialog = create_floating_window( "NetRadiant Preferences", m_parent );
+ ui::Window dialog = ui::Window(create_floating_window( "NetRadiant Preferences", m_parent ));
{
- GtkWidget* mainvbox = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( dialog ), mainvbox );
+ auto mainvbox = ui::VBox( FALSE, 5 );
+ dialog.add(mainvbox);
gtk_container_set_border_width( GTK_CONTAINER( mainvbox ), 5 );
- gtk_widget_show( mainvbox );
+ mainvbox.show();
{
- GtkWidget* hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_end( GTK_BOX( mainvbox ), hbox, FALSE, TRUE, 0 );
+ auto hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ mainvbox.pack_end(hbox, FALSE, TRUE, 0);
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &m_modal );
- gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &m_modal );
+ hbox.pack_end(button, FALSE, FALSE, 0);
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &m_modal );
- gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &m_modal );
+ hbox.pack_end(button, FALSE, FALSE, 0);
}
{
- GtkButton* button = create_dialog_button( "Clean", G_CALLBACK( OnButtonClean ), this );
- gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Clean", G_CALLBACK( OnButtonClean ), this );
+ hbox.pack_end(button, FALSE, FALSE, 0);
}
}
{
- GtkWidget* hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( mainvbox ), hbox, TRUE, TRUE, 0 );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 5 );
+ mainvbox.pack_start( hbox, TRUE, TRUE, 0 );
+ hbox.show();
{
- GtkWidget* sc_win = gtk_scrolled_window_new( 0, 0 );
+ auto sc_win = ui::ScrolledWindow(ui::New);
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( sc_win ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
- gtk_box_pack_start( GTK_BOX( hbox ), sc_win, FALSE, FALSE, 0 );
- gtk_widget_show( sc_win );
+ hbox.pack_start( sc_win, FALSE, FALSE, 0 );
+ sc_win.show();
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( sc_win ), GTK_SHADOW_IN );
// prefs pages notebook
- m_notebook = gtk_notebook_new();
+ m_notebook = ui::Widget::from(gtk_notebook_new());
// hide the notebook tabs since its not supposed to look like a notebook
gtk_notebook_set_show_tabs( GTK_NOTEBOOK( m_notebook ), FALSE );
- gtk_box_pack_start( GTK_BOX( hbox ), m_notebook, TRUE, TRUE, 0 );
- gtk_widget_show( m_notebook );
+ hbox.pack_start( m_notebook, TRUE, TRUE, 0 );
+ m_notebook.show();
{
- GtkTreeStore* store = gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER );
+ auto store = ui::TreeStore::from(gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ));
- GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
+ gtk_tree_view_set_headers_visible(view, FALSE );
{
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Preferences", renderer, "text", 0, NULL );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "Preferences", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
}
{
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
- g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( treeSelection ), this );
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view));
+ selection.connect( "changed", G_CALLBACK( treeSelection ), this );
}
- gtk_widget_show( view );
+ view.show();
- gtk_container_add( GTK_CONTAINER( sc_win ), view );
+ sc_win.add(view);
{
/********************************************************************/
PreferencePages_addPage( m_notebook, "Front Page" );
{
- GtkWidget* global = PreferencePages_addPage( m_notebook, "Global Preferences" );
+ auto global = PreferencePages_addPage( m_notebook, "Global Preferences" );
{
PreferencesPage preferencesPage( *this, getVBox( global ) );
Global_constructPreferences( preferencesPage );
}
- GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Global", global );
+ auto group = PreferenceTree_appendPage( store, 0, "Global", global );
{
- GtkWidget* game = PreferencePages_addPage( m_notebook, "Game" );
+ auto game = PreferencePages_addPage( m_notebook, "Game" );
PreferencesPage preferencesPage( *this, getVBox( game ) );
g_GamesDialog.CreateGlobalFrame( preferencesPage );
}
{
- GtkWidget* interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" );
+ auto interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" );
{
PreferencesPage preferencesPage( *this, getVBox( interfacePage ) );
PreferencesPageCallbacks_constructPage( g_interfacePreferences, preferencesPage );
}
- GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Interface", interfacePage );
+ auto group = PreferenceTree_appendPage( store, 0, "Interface", interfacePage );
PreferenceTreeGroup preferenceGroup( *this, m_notebook, store, group );
PreferenceGroupCallbacks_constructGroup( g_interfaceCallbacks, preferenceGroup );
}
{
- GtkWidget* display = PreferencePages_addPage( m_notebook, "Display Preferences" );
+ auto display = PreferencePages_addPage( m_notebook, "Display Preferences" );
{
PreferencesPage preferencesPage( *this, getVBox( display ) );
PreferencesPageCallbacks_constructPage( g_displayPreferences, preferencesPage );
}
- GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Display", display );
+ auto group = PreferenceTree_appendPage( store, 0, "Display", display );
PreferenceTreeGroup preferenceGroup( *this, m_notebook, store, group );
PreferenceGroupCallbacks_constructGroup( g_displayCallbacks, preferenceGroup );
}
{
- GtkWidget* settings = PreferencePages_addPage( m_notebook, "General Settings" );
+ auto settings = PreferencePages_addPage( m_notebook, "General Settings" );
{
PreferencesPage preferencesPage( *this, getVBox( settings ) );
PreferencesPageCallbacks_constructPage( g_settingsPreferences, preferencesPage );
}
- GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Settings", settings );
+ auto group = PreferenceTree_appendPage( store, 0, "Settings", settings );
PreferenceTreeGroup preferenceGroup( *this, m_notebook, store, group );
PreferenceGroupCallbacks_constructGroup( g_settingsCallbacks, preferenceGroup );
}
}
- gtk_tree_view_expand_all( GTK_TREE_VIEW( view ) );
+ gtk_tree_view_expand_all(view );
g_object_unref( G_OBJECT( store ) );
}
}
}
- gtk_notebook_set_page( GTK_NOTEBOOK( m_notebook ), 0 );
+ gtk_notebook_set_current_page( GTK_NOTEBOOK( m_notebook ), 0 );
return dialog;
}
PrefsDlg g_Preferences; // global prefs instance
-void PreferencesDialog_constructWindow( GtkWindow* main_window ){
+void PreferencesDialog_constructWindow( ui::Window main_window ){
g_Preferences.m_parent = main_window;
g_Preferences.Create();
}
{
message << ( *i ) << '\n';
}
- gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), message.c_str() );
+ ui::alert( MainFrame_getWindow(), message.c_str() );
g_restart_required.clear();
}
}
}
+struct GameName {
+ static void Export(const Callback<void(const char *)> &returnz) {
+ returnz(gamename_get());
+ }
+ static void Import(const char *value) {
+ gamename_set(value);
+ }
+};
+struct GameMode {
+ static void Export(const Callback<void(const char *)> &returnz) {
+ returnz(gamemode_get());
+ }
-
-void GameName_importString( const char* value ){
- gamename_set( value );
-}
-typedef FreeCaller1<const char*, GameName_importString> GameNameImportStringCaller;
-void GameName_exportString( const StringImportCallback& importer ){
- importer( gamename_get() );
-}
-typedef FreeCaller1<const StringImportCallback&, GameName_exportString> GameNameExportStringCaller;
-
-void GameMode_importString( const char* value ){
- gamemode_set( value );
-}
-typedef FreeCaller1<const char*, GameMode_importString> GameModeImportStringCaller;
-void GameMode_exportString( const StringImportCallback& importer ){
- importer( gamemode_get() );
-}
-typedef FreeCaller1<const StringImportCallback&, GameMode_exportString> GameModeExportStringCaller;
-
+ static void Import(const char *value) {
+ gamemode_set(value);
+ }
+};
void RegisterPreferences( PreferenceSystem& preferences ){
-#ifdef WIN32
- preferences.registerPreference( "UseCustomShaderEditor", BoolImportStringCaller( g_TextEditor_useWin32Editor ), BoolExportStringCaller( g_TextEditor_useWin32Editor ) );
+#if GDEF_OS_WINDOWS
+ preferences.registerPreference( "UseCustomShaderEditor", make_property_string( g_TextEditor_useWin32Editor ) );
#else
- preferences.registerPreference( "UseCustomShaderEditor", BoolImportStringCaller( g_TextEditor_useCustomEditor ), BoolExportStringCaller( g_TextEditor_useCustomEditor ) );
- preferences.registerPreference( "CustomShaderEditorCommand", CopiedStringImportStringCaller( g_TextEditor_editorCommand ), CopiedStringExportStringCaller( g_TextEditor_editorCommand ) );
+ preferences.registerPreference( "UseCustomShaderEditor", make_property_string( g_TextEditor_useCustomEditor ) );
+ preferences.registerPreference( "CustomShaderEditorCommand", make_property_string( g_TextEditor_editorCommand ) );
#endif
- preferences.registerPreference( "GameName", GameNameImportStringCaller(), GameNameExportStringCaller() );
- preferences.registerPreference( "GameMode", GameModeImportStringCaller(), GameModeExportStringCaller() );
+ preferences.registerPreference( "GameName", make_property<GameName>() );
+ preferences.registerPreference( "GameMode", make_property<GameMode>() );
}
void Preferences_Init(){
#include "dialog.h"
#include <list>
#include <map>
+#include "property.h"
-void Widget_connectToggleDependency( GtkWidget* self, GtkWidget* toggleButton );
+void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton );
class PreferencesPage
{
Dialog& m_dialog;
-GtkWidget* m_vbox;
+ui::VBox m_vbox;
public:
-PreferencesPage( Dialog& dialog, GtkWidget* vbox ) : m_dialog( dialog ), m_vbox( vbox ){
+PreferencesPage( Dialog& dialog, ui::VBox vbox ) : m_dialog( dialog ), m_vbox( vbox ){
}
-GtkWidget* appendCheckBox( const char* name, const char* flag, bool& data ){
+ui::CheckButton appendCheckBox( const char* name, const char* flag, bool& data ){
return m_dialog.addCheckBox( m_vbox, name, flag, data );
}
-GtkWidget* appendCheckBox( const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ){
- return m_dialog.addCheckBox( m_vbox, name, flag, importCallback, exportCallback );
+ui::CheckButton appendCheckBox( const char* name, const char* flag, Property<bool> const &cb ){
+ return m_dialog.addCheckBox( m_vbox, name, flag, cb );
}
-void appendCombo( const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- m_dialog.addCombo( m_vbox, name, values, importCallback, exportCallback );
+void appendCombo( const char* name, StringArrayRange values, Property<int> const &cb ){
+ m_dialog.addCombo( m_vbox, name, values, cb );
}
void appendCombo( const char* name, int& data, StringArrayRange values ){
m_dialog.addCombo( m_vbox, name, data, values );
void appendSlider( const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
m_dialog.addSlider( m_vbox, name, data, draw_value, low, high, value, lower, upper, step_increment, page_increment );
}
-void appendRadio( const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- m_dialog.addRadio( m_vbox, name, names, importCallback, exportCallback );
+void appendRadio( const char* name, StringArrayRange names, Property<int> const &cb ){
+ m_dialog.addRadio( m_vbox, name, names, cb );
}
void appendRadio( const char* name, int& data, StringArrayRange names ){
m_dialog.addRadio( m_vbox, name, data, names );
}
-void appendRadioIcons( const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- m_dialog.addRadioIcons( m_vbox, name, icons, importCallback, exportCallback );
+void appendRadioIcons( const char* name, StringArrayRange icons, Property<int> const &cb ){
+ m_dialog.addRadioIcons( m_vbox, name, icons, cb );
}
void appendRadioIcons( const char* name, int& data, StringArrayRange icons ){
m_dialog.addRadioIcons( m_vbox, name, data, icons );
}
-GtkWidget* appendEntry( const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- return m_dialog.addIntEntry( m_vbox, name, importCallback, exportCallback );
+ui::Widget appendEntry( const char* name, Property<int> const &cb ){
+ return m_dialog.addIntEntry( m_vbox, name, cb );
}
-GtkWidget* appendEntry( const char* name, int& data ){
+ui::Widget appendEntry( const char* name, int& data ){
return m_dialog.addEntry( m_vbox, name, data );
}
-GtkWidget* appendEntry( const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ){
- return m_dialog.addSizeEntry( m_vbox, name, importCallback, exportCallback );
+ui::Widget appendEntry( const char* name, Property<std::size_t> const &cb){
+ return m_dialog.addSizeEntry( m_vbox, name, cb );
}
-GtkWidget* appendEntry( const char* name, std::size_t& data ){
+ui::Widget appendEntry( const char* name, std::size_t& data ){
return m_dialog.addEntry( m_vbox, name, data );
}
-GtkWidget* appendEntry( const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){
- return m_dialog.addFloatEntry( m_vbox, name, importCallback, exportCallback );
+ui::Widget appendEntry( const char* name, Property<float> const &cb ){
+ return m_dialog.addFloatEntry( m_vbox, name, cb );
}
-GtkWidget* appendEntry( const char* name, float& data ){
+ui::Widget appendEntry( const char* name, float& data ){
return m_dialog.addEntry( m_vbox, name, data );
}
-GtkWidget* appendPathEntry( const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ){
- return m_dialog.addPathEntry( m_vbox, name, browse_directory, importCallback, exportCallback );
+ui::Widget appendPathEntry( const char* name, bool browse_directory, Property<const char *> const &cb ){
+ return m_dialog.addPathEntry( m_vbox, name, browse_directory, cb );
}
-GtkWidget* appendPathEntry( const char* name, CopiedString& data, bool directory ){
+ui::Widget appendPathEntry( const char* name, CopiedString& data, bool directory ){
return m_dialog.addPathEntry( m_vbox, name, data, directory );
}
-GtkWidget* appendSpinner( const char* name, int& data, double value, double lower, double upper ){
+ui::SpinButton appendSpinner( const char* name, int& data, double value, double lower, double upper ){
return m_dialog.addSpinner( m_vbox, name, data, value, lower, upper );
}
-GtkWidget* appendSpinner( const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback );
+ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, Property<int> const &cb ){
+ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, cb );
}
-GtkWidget* appendSpinner( const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){
- return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback );
+ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, Property<float> const &cb ){
+ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, cb );
}
};
-typedef Callback1<PreferencesPage&> PreferencesPageCallback;
+typedef Callback<void(PreferencesPage&)> PreferencesPageCallback;
class PreferenceGroup
{
virtual PreferencesPage createPage( const char* treeName, const char* frameName ) = 0;
};
-typedef Callback1<PreferenceGroup&> PreferenceGroupCallback;
+typedef Callback<void(PreferenceGroup&)> PreferenceGroupCallback;
void PreferencesDialog_addInterfacePreferences( const PreferencesPageCallback& callback );
void PreferencesDialog_addInterfacePage( const PreferenceGroupCallback& callback );
void PreferencesDialog_restartRequired( const char* staticName );
template<typename Value>
-class LatchedValue
-{
+class LatchedValue {
public:
-Value m_value;
-Value m_latched;
-const char* m_description;
+ Value m_value;
+ Value m_latched;
+ const char *m_description;
-LatchedValue( Value value, const char* description ) : m_latched( value ), m_description( description ){
-}
-void useLatched(){
- m_value = m_latched;
-}
-void import( Value value ){
- m_latched = value;
- if ( m_latched != m_value ) {
- PreferencesDialog_restartRequired( m_description );
- }
-}
+ LatchedValue(Value value, const char *description) : m_latched(value), m_description(description) {
+ }
+
+ void useLatched() {
+ m_value = m_latched;
+ }
};
-typedef LatchedValue<bool> LatchedBool;
-typedef MemberCaller1<LatchedBool, bool, &LatchedBool::import> LatchedBoolImportCaller;
+template<class T>
+struct PropertyImpl<LatchedValue<T>, T> {
+ static void Export(const LatchedValue<T> &self, const Callback<void(T)> &returnz) {
+ returnz(self.m_latched);
+ }
+
+ static void Import(LatchedValue<T> &self, T value) {
+ self.m_latched = value;
+ if (value != self.m_value) {
+ PreferencesDialog_restartRequired(self.m_description);
+ }
+ }
+};
-typedef LatchedValue<int> LatchedInt;
-typedef MemberCaller1<LatchedInt, int, &LatchedInt::import> LatchedIntImportCaller;
+template<class T>
+Property<T> make_property(LatchedValue<T> &self) {
+ return make_property<LatchedValue<T>, T>(self);
+}
/*!
holds information for a given game
extern CGameDescription *g_pGameDescription;
-typedef struct _GtkWidget GtkWidget;
class PrefsDlg;
class PreferencesPage;
}
virtual ~CGameDialog();
-void AddPacksURL( StringOutputStream &s );
-
/*!
intialize the game dialog, called at CPrefsDlg::Init
will scan for games, load prefs, and do game selection dialog if needed
Dialog API
this is only called when the dialog is built at startup for main engine select
*/
-GtkWindow* BuildDialog();
+ui::Window BuildDialog();
void GameFileImport( int value );
-void GameFileExport( const IntImportCallback& importCallback ) const;
+void GameFileExport( const Callback<void(int)> & importCallback ) const;
/*!
construction of the dialog frame
public:
-GtkWidget *m_notebook;
+ui::Widget m_notebook{ui::null};
virtual ~PrefsDlg(){
g_string_free( m_rc_path, true );
void Init();
/*! Utility function for swapping notebook pages for tree list selections */
-void showPrefPage( GtkWidget* prefpage );
+void showPrefPage( ui::Widget prefpage );
protected:
/*! Dialog API */
-GtkWindow* BuildDialog();
+ui::Window BuildDialog();
void PostModal( EMessageBoxReturn code );
};
};
extern preferences_globals_t g_preferences_globals;
-typedef struct _GtkWindow GtkWindow;
-void PreferencesDialog_constructWindow( GtkWindow* main_window );
+void PreferencesDialog_constructWindow( ui::Window main_window );
void PreferencesDialog_destroyWindow();
void PreferencesDialog_showDialog();
// Leonardo Zide (leo@lokigames.com)
//
+#include "defaults.h"
#include "qe3.h"
+#include "globaldefs.h"
+
+#include <gtk/gtk.h>
#include "debugging/debugging.h"
#include <map>
-#include <gtk/gtktearoffmenuitem.h>
+#include <uilib/uilib.h>
#include "stream/textfilestream.h"
#include "cmdlib.h"
QEGlobals_t g_qeglobals;
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
#define PATH_MAX 260
#endif
const char* userRoot = g_qeglobals.m_userEnginePath.c_str();
const char* globalRoot = EnginePath_get();
+ // editor builtin VFS
+ StringOutputStream editorGamePath( 256 );
+ editorGamePath << GlobalRadiant().getAppPath() << DEFAULT_EDITORVFS_DIRNAME;
+ GlobalFileSystem().initDirectory( editorGamePath.c_str() );
+
// if we have a mod dir
if ( !string_equal( gamename, basegame ) ) {
// ~/.<gameprefix>/<fs_game>
- if ( userRoot && !string_equal( globalRoot, userRoot ) ) {
+ if ( userRoot && !string_equal( globalRoot, userRoot ) && !g_disableHomePath ) {
StringOutputStream userGamePath( 256 );
userGamePath << userRoot << gamename << '/';
GlobalFileSystem().initDirectory( userGamePath.c_str() );
}
// <fs_basepath>/<fs_game>
- {
+ if ( !g_disableEnginePath ) {
StringOutputStream globalGamePath( 256 );
globalGamePath << globalRoot << gamename << '/';
GlobalFileSystem().initDirectory( globalGamePath.c_str() );
}
// ~/.<gameprefix>/<fs_main>
- if ( userRoot && !string_equal( globalRoot, userRoot ) ) {
+ if ( userRoot && !string_equal( globalRoot, userRoot ) && !g_disableHomePath ) {
StringOutputStream userBasePath( 256 );
userBasePath << userRoot << basegame << '/';
GlobalFileSystem().initDirectory( userBasePath.c_str() );
}
// <fs_basepath>/<fs_main>
- {
+ if ( !g_disableEnginePath ) {
StringOutputStream globalBasePath( 256 );
globalBasePath << globalRoot << basegame << '/';
GlobalFileSystem().initDirectory( globalBasePath.c_str() );
}
+
+ // extra pakpaths
+ for ( int i = 0; i < g_pakPathCount; i++ ) {
+ if (g_strcmp0( g_strPakPath[i].c_str(), "")) {
+ GlobalFileSystem().initDirectory( g_strPakPath[i].c_str() );
+ }
+ }
}
int g_numbrushes = 0;
return true;
}
- EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "The current map has changed since it was last saved.\nDo you want to save the current map before continuing?", title, eMB_YESNOCANCEL, eMB_ICONQUESTION );
- if ( result == eIDCANCEL ) {
+ auto result = ui::alert( MainFrame_getWindow(), "The current map has changed since it was last saved.\nDo you want to save the current map before continuing?", title, ui::alert_type::YESNOCANCEL, ui::alert_icon::Question );
+ if ( result == ui::alert_response::CANCEL ) {
return false;
}
- if ( result == eIDYES ) {
+ if ( result == ui::alert_response::YES ) {
if ( Map_Unnamed( g_map ) ) {
return Map_SaveAs();
}
build_set_variable( "MonitorAddress", ( g_WatchBSP_Enabled ) ? "127.0.0.1:39000" : "" );
build_set_variable( "GameName", gamename_get() );
+ StringBuffer ExtraQ3map2Args;
+ // extra pakpaths
+ for ( int i = 0; i < g_pakPathCount; i++ ) {
+ if ( g_strcmp0( g_strPakPath[i].c_str(), "") ) {
+ ExtraQ3map2Args.push_string( " -fs_pakpath \"" );
+ ExtraQ3map2Args.push_string( g_strPakPath[i].c_str() );
+ ExtraQ3map2Args.push_string( "\"" );
+ }
+ }
+
+ // extra switches
+ if ( g_disableEnginePath ) {
+ ExtraQ3map2Args.push_string( " -fs_nobasepath " );
+ }
+
+ if ( g_disableHomePath ) {
+ ExtraQ3map2Args.push_string( " -fs_nohomepath " );
+ }
+
+ build_set_variable( "ExtraQ3map2Args", ExtraQ3map2Args.c_str() );
+
const char* mapname = Map_Name( g_map );
StringOutputStream name( 256 );
name << StringRange( mapname, path_get_filename_base_end( mapname ) ) << ".bsp";
ArrayCommandListener(){
m_array = g_ptr_array_new();
}
+
~ArrayCommandListener(){
g_ptr_array_free( m_array, TRUE );
}
strcat( junkpath, "junk.txt" );
char batpath[PATH_MAX];
-#if defined( POSIX )
+#if GDEF_OS_POSIX
strcpy( batpath, SettingsPath_get() );
strcat( batpath, "qe3bsp.sh" );
-#elif defined( WIN32 )
+#elif GDEF_OS_WINDOWS
strcpy( batpath, SettingsPath_get() );
strcat( batpath, "qe3bsp.bat" );
#else
{
TextFileOutputStream batchFile( batpath );
if ( !batchFile.failed() ) {
-#if defined ( POSIX )
+#if GDEF_OS_POSIX
batchFile << "#!/bin/sh \n\n";
#endif
BatchCommandListener listener( batchFile, junkpath );
}
}
if ( written ) {
-#if defined ( POSIX )
+#if GDEF_OS_POSIX
chmod( batpath, 0744 );
#endif
globalOutputStream() << "Writing the compile script to '" << batpath << "'\n";
title << " *";
}
- gtk_window_set_title( MainFrame_getWindow(), title.c_str() );
+ gtk_window_set_title(MainFrame_getWindow(), title.c_str() );
}
bool g_bWaitCursor = false;
void Sys_BeginWait( void ){
ScreenUpdates_Disable( "Processing...", "Please Wait" );
GdkCursor *cursor = gdk_cursor_new( GDK_WATCH );
- gdk_window_set_cursor( GTK_WIDGET( MainFrame_getWindow() )->window, cursor );
+ gdk_window_set_cursor( gtk_widget_get_window(MainFrame_getWindow()), cursor );
gdk_cursor_unref( cursor );
g_bWaitCursor = true;
}
void Sys_EndWait( void ){
ScreenUpdates_Enable();
- gdk_window_set_cursor( GTK_WIDGET( MainFrame_getWindow() )->window, 0 );
+ gdk_window_set_cursor(gtk_widget_get_window(MainFrame_getWindow()), 0 );
g_bWaitCursor = false;
}
#include "qgl.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
#include <stdlib.h>
#include <string.h>
-#if defined( _WIN32 )
+#if GDEF_OS_WINDOWS
#define WINGDIAPI __declspec( dllimport )
#define APIENTRY __stdcall
#endif
+#if GDEF_OS_MACOS && !defined( XWINDOWS )
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
-#if defined( _WIN32 )
+#if GDEF_OS_WINDOWS
#undef WINGDIAPI
#undef APIENTRY
#endif
-#if defined( _WIN32 )
+#if GDEF_OS_WINDOWS
#include <wtypes.h>
#include <GL/glx.h>
#include <dlfcn.h>
-#include <gdk/gdkx.h>
Bool ( *qglXQueryExtension )( Display *dpy, int *errorb, int *event );
void* ( *qglXGetProcAddressARB )( const GLubyte * procName );
typedef void* ( *glXGetProcAddressARBProc )( const GLubyte *procName );
+#elif GDEF_OS_MACOS
+#include <mach-o/dyld.h>
+#include <stdlib.h>
+#include <string.h>
#else
#error "unsupported platform"
#endif
void QGL_Shutdown( OpenGLBinding& table ){
globalOutputStream() << "Shutting down OpenGL module...";
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
qwglGetProcAddress = 0;
#elif defined( XWINDOWS )
qglXQueryExtension = glXQueryExtension;
qglXGetProcAddressARB = 0;
+#elif GDEF_OS_MACOS
#else
#error "unsupported platform"
#endif
}
extensions = GlobalOpenGL().m_glGetString( GL_EXTENSIONS );
-#ifndef __APPLE__
+#if !GDEF_OS_MACOS
if ( !extensions ) {
return false;
}
{
return (QGLFunctionPointer) qglXGetProcAddressARB( reinterpret_cast<const GLubyte*>( symbol ) );
}
-#elif defined( WIN32 )
+#elif GDEF_OS_MACOS
+ // Prepend a '_' for the Unix C symbol mangling convention
+ char *symbolName = (char *) malloc(strlen(symbol) + 2);
+ strcpy(symbolName + 1, symbol);
+ symbolName[0] = '_';
+ NSSymbol nssymbol = NULL;
+ if (NSIsSymbolNameDefined(symbolName)) nssymbol = NSLookupAndBindSymbol(symbolName);
+ free(symbolName);
+ return nssymbol ? reinterpret_cast<QGLFunctionPointer>(NSAddressOfSymbol(nssymbol)) : reinterpret_cast<QGLFunctionPointer>(glInvalidFunction);
+#elif GDEF_OS_WINDOWS
ASSERT_NOTNULL( qwglGetProcAddress );
return (QGLFunctionPointer) qwglGetProcAddress( symbol );
#else
int QGL_Init( OpenGLBinding& table ){
QGL_clear( table );
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
qwglGetProcAddress = wglGetProcAddress;
#elif defined( XWINDOWS )
qglXGetProcAddressARB = (glXGetProcAddressARBProc)dlsym( RTLD_DEFAULT, "glXGetProcAddressARB" );
- if ( ( qglXQueryExtension == 0 ) || ( qglXQueryExtension( GDK_DISPLAY(),0,0 ) != True ) ) {
+ if ( ( qglXQueryExtension == 0 ) || ( qglXQueryExtension(XOpenDisplay(nullptr), 0, 0) != True ) ) {
return 0;
}
+#elif GDEF_OS_MACOS
#else
#error "unsupported platform"
#endif
*/
#include "referencecache.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
#include "iselection.h"
#include "iundo.h"
#include "imap.h"
+
MapModules& ReferenceAPI_getMapModules();
+
#include "imodel.h"
+
ModelModules& ReferenceAPI_getModelModules();
+
#include "ifilesystem.h"
#include "iarchive.h"
#include "ifiletypes.h"
#include "map.h"
#include "filetypes.h"
+extern bool g_writeMapComments;
bool References_Saved();
if ( !file.failed() ) {
globalOutputStream() << "success\n";
ScopeDisableScreenUpdates disableScreenUpdates( path_get_filename_start( filename ), "Saving Map" );
- format.writeGraph( root, traverse, file );
+ format.writeGraph( root, traverse, file, g_writeMapComments );
return true;
}
inline hash_t path_hash( const char* path, hash_t previous = 0 ){
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
return string_hash_nocase( path, previous );
#else // UNIX
return string_hash( path, previous );
struct PathHash
{
typedef hash_t hash_type;
+
hash_type operator()( const CopiedString& path ) const {
return path_hash( path.c_str() );
}
struct ModelKeyHash
{
typedef hash_t hash_type;
+
hash_type operator()( const ModelKey& key ) const {
return hash_combine( path_hash( key.first.c_str() ), path_hash( key.second.c_str() ) );
}
realise();
}
}
+
~ModelResource(){
if ( realised() ) {
unrealise();
}
ASSERT_MESSAGE( !realised(), "ModelResource::~ModelResource: resource reference still realised: " << makeQuoted( m_name.c_str() ) );
}
+
// NOT COPYABLE
ModelResource( const ModelResource& );
+
// NOT ASSIGNABLE
ModelResource& operator=( const ModelResource& );
void setModel( const NodeSmartReference& model ){
m_model = model;
}
+
void clearModel(){
m_model = g_nullModel;
}
return m_model != g_nullModel;
}
+
bool save(){
if ( !mapSaved() ) {
const char* moduleName = findModuleName( GetFileTypeRegistry(), MapFormat::Name(), m_type.c_str() );
}
return false;
}
+
void flush(){
if ( realised() ) {
ModelCache_flush( m_path.c_str(), m_name.c_str() );
}
}
+
scene::Node* getNode(){
//if(m_model != g_nullModel)
{
}
//return 0;
}
+
void setNode( scene::Node* node ){
ModelCache::iterator i = ModelCache_find( m_path.c_str(), m_name.c_str() );
if ( i != g_modelCache.end() ) {
connectMap();
}
+
void attach( ModuleObserver& observer ){
if ( realised() ) {
observer.realise();
}
m_observers.attach( observer );
}
+
void detach( ModuleObserver& observer ){
if ( realised() ) {
observer.unrealise();
}
m_observers.detach( observer );
}
+
bool realised(){
return m_unrealised == 0;
}
+
void realise(){
ASSERT_MESSAGE( m_unrealised != 0, "ModelResource::realise: already realised" );
if ( --m_unrealised == 0 ) {
m_observers.realise();
}
}
+
void unrealise(){
if ( ++m_unrealised == 1 ) {
m_observers.unrealise();
clearModel();
}
}
+
bool isMap() const {
return Node_getMapFile( m_model ) != 0;
}
+
void connectMap(){
MapFile* map = Node_getMapFile( m_model );
if ( map != 0 ) {
- map->setChangedCallback( FreeCaller<MapChanged>() );
+ map->setChangedCallback( makeCallbackF(MapChanged) );
}
}
+
std::time_t modified() const {
StringOutputStream fullpath( 256 );
fullpath << m_path.c_str() << m_name.c_str();
return file_modified( fullpath.c_str() );
}
+
void mapSave(){
m_modified = modified();
MapFile* map = Node_getMapFile( m_model );
map->save();
}
}
+
bool mapSaved() const {
MapFile* map = Node_getMapFile( m_model );
if ( map != 0 ) {
}
return true;
}
+
bool isModified() const {
return ( ( !string_empty( m_path.c_str() ) // had or has an absolute path
&& m_modified != modified() ) // AND disk timestamp changed
|| !path_equal( rootPath( m_originalName.c_str() ), m_path.c_str() ) ); // OR absolute vfs-root changed
}
+
void refresh(){
if ( isModified() ) {
flush();
Iterators m_iterators;
public:
typedef Iterators::iterator iterator;
+
ModelReferencesSnapshot( ModelReferences& references ) : m_references( references ){
for ( ModelReferences::iterator i = m_references.begin(); i != m_references.end(); ++i )
{
m_iterators.push_back( i );
}
}
+
~ModelReferencesSnapshot(){
for ( Iterators::iterator i = m_iterators.begin(); i != m_iterators.end(); ++i )
{
m_references.release( *i );
}
}
+
iterator begin(){
return m_iterators.begin();
}
+
iterator end(){
return m_iterators.end();
}
iterator begin(){
return m_references.begin();
}
+
iterator end(){
return m_references.end();
}
//globalOutputStream() << "capture: \"" << path << "\"\n";
return m_references.capture( CopiedString( path ) ).get();
}
+
void release( const char* path ){
m_references.release( CopiedString( path ) );
//globalOutputStream() << "release: \"" << path << "\"\n";
bool realised() const {
return m_unrealised == 0;
}
+
void realise(){
ASSERT_MESSAGE( m_unrealised != 0, "HashtableReferenceCache::realise: already realised" );
if ( --m_unrealised == 0 ) {
}
}
}
+
void unrealise(){
if ( ++m_unrealised == 1 ) {
g_realised = false;
ModelCache_clear();
}
}
+
void refresh(){
ModelReferencesSnapshot snapshot( m_references );
for ( ModelReferencesSnapshot::iterator i = snapshot.begin(); i != snapshot.end(); ++i )
m_map_modules( GlobalRadiant().getRequiredGameDescriptionKeyValue( "maptypes" ) )
{
}
+
ModelModules& getModelModules(){
return m_model_modules.get();
}
+
MapModules& getMapModules(){
return m_map_modules.get();
}
ReferenceCache* m_reference;
public:
typedef ReferenceCache Type;
+
STRING_CONSTANT( Name, "*" );
ReferenceAPI(){
m_reference = &GetReferenceCache();
}
+
~ReferenceAPI(){
GlobalFileSystem().detach( g_referenceCache );
g_nullModel = g_nullNode;
}
+
ReferenceCache* getTable(){
return m_reference;
}
ModelModules& ReferenceAPI_getModelModules(){
return StaticReferenceModule::instance().getDependencies().getModelModules();
}
+
MapModules& ReferenceAPI_getMapModules(){
return StaticReferenceModule::instance().getDependencies().getMapModules( );
}
break;
}
}
-typedef ConstMemberCaller1<RenderHighlighted, const Renderable&, &RenderHighlighted::render> RenderCaller;
+typedef ConstMemberCaller<RenderHighlighted, void(const Renderable&), &RenderHighlighted::render> RenderCaller;
bool pre( const scene::Path& path, scene::Instance& instance, VolumeIntersectionValue parentVisible ) const {
m_renderer.PushState();
#include "camwindow.h"
-
#define DEBUG_RENDER 0
inline void debug_string( const char* string ){
glDeleteObjectARB( m_program );
m_program = 0;
}
+
void enable(){
glUseProgramObjectARB( m_program );
GlobalOpenGL_debugAssertNoErrors();
debug_string( "enable depthfill" );
g_depthfillPass_enabled = true;
}
+
void disable(){
glUseProgramObjectARB( 0 );
GlobalOpenGL_debugAssertNoErrors();
}
-
-
/// \brief A container of Renderable references.
/// May contain the same Renderable multiple times, with different transforms.
class OpenGLStateBucket
public:
OpenGLStateBucket(){
}
+
void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview, const RendererLight* light = 0 ){
m_renderables.push_back( RenderTransform( renderable, modelview, light ) );
}
const OpenGLRenderable& m_renderable;
const Matrix4& m_modelview;
public:
-typedef const RendererLight& first_argument_type;
+using func = void(const RendererLight&);
OpenGLStateBucketAdd( OpenGLStateBucket& bucket, const OpenGLRenderable& renderable, const Matrix4& modelview ) :
m_bucket( bucket ), m_renderable( renderable ), m_modelview( modelview ){
}
+
void operator()( const RendererLight& light ){
m_bucket.addRenderable( m_renderable, m_modelview, &light );
}
{
std::size_t m_count;
public:
-typedef RendererLight& first_argument_type;
+using func = void(RendererLight&);
CountLights() : m_count( 0 ){
}
+
void operator()( const RendererLight& light ){
++m_count;
}
+
std::size_t count() const {
return m_count;
}
public:
OpenGLShader() : m_shader( 0 ), m_used( 0 ){
}
+
~OpenGLShader(){
}
+
void construct( const char* name );
+
void destroy(){
if ( m_shader ) {
m_shader->DecRef();
}
m_passes.clear();
}
+
void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview, const LightList* lights ){
for ( Passes::iterator i = m_passes.begin(); i != m_passes.end(); ++i )
{
if ( ( ( *i )->state().m_state & RENDER_BUMP ) != 0 ) {
if ( lights != 0 ) {
OpenGLStateBucketAdd add( *( *i ), renderable, modelview );
- lights->forEachLight( makeCallback1( add ) );
+ lights->forEachLight(makeCallback( add ) );
}
}
else
}
}
}
+
void incrementUsed(){
if ( ++m_used == 1 && m_shader != 0 ) {
m_shader->SetInUse( true );
}
}
+
void decrementUsed(){
if ( --m_used == 0 && m_shader != 0 ) {
m_shader->SetInUse( false );
}
}
+
bool realised() const {
return m_shader != 0;
}
+
void attach( ModuleObserver& observer ){
if ( realised() ) {
observer.realise();
}
m_observers.attach( observer );
}
+
void detach( ModuleObserver& observer ){
if ( realised() ) {
observer.unrealise();
}
m_observers.detach( observer );
}
+
void realise( const CopiedString& name ){
construct( name.c_str() );
m_observers.realise();
}
+
void unrealise(){
m_observers.unrealise();
destroy();
}
+
qtexture_t& getTexture() const {
ASSERT_NOTNULL( m_shader );
return *m_shader->getTexture();
}
+
unsigned int getFlags() const {
ASSERT_NOTNULL( m_shader );
return m_shader->getFlags();
}
+
IShader& getShader() const {
ASSERT_NOTNULL( m_shader );
return *m_shader;
}
+
OpenGLState& appendDefaultPass(){
m_passes.push_back( new OpenGLStateBucket );
OpenGLState& state = m_passes.back()->state();
{
LightCullable& m_cullable;
RendererLights& m_allLights;
-Callback m_evaluateChanged;
+Callback<void()> m_evaluateChanged;
typedef std::list<RendererLight*> Lights;
mutable Lights m_lights;
mutable bool m_lightsChanged;
public:
-LinearLightList( LightCullable& cullable, RendererLights& lights, const Callback& evaluateChanged ) :
+LinearLightList( LightCullable& cullable, RendererLights& lights, const Callback<void()>& evaluateChanged ) :
m_cullable( cullable ), m_allLights( lights ), m_evaluateChanged( evaluateChanged ){
m_lightsChanged = true;
}
+
void evaluateLights() const {
m_evaluateChanged();
if ( m_lightsChanged ) {
}
#endif
}
+
void forEachLight( const RendererLightCallback& callback ) const {
evaluateLights();
callback( *( *i ) );
}
}
+
void lightsChanged() const {
m_lightsChanged = true;
}
explicit CreateOpenGLShader( OpenGLShaderCache* cache = 0 )
: m_cache( cache ){
}
+
OpenGLShader* construct( const CopiedString& name ){
OpenGLShader* shader = new OpenGLShader;
if ( m_cache->realised() ) {
}
return shader;
}
+
void destroy( OpenGLShader* shader ){
if ( m_cache->realised() ) {
shader->unrealise();
m_lightsChanged( true ),
m_traverseRenderablesMutex( false ){
}
+
~OpenGLShaderCache(){
for ( Shaders::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i )
{
globalOutputStream() << "leaked shader: " << makeQuoted( ( *i ).key.c_str() ) << "\n";
}
}
+
Shader* capture( const char* name ){
ASSERT_MESSAGE( name[0] == '$'
|| *name == '['
#endif
return m_shaders.capture( name ).get();
}
+
void release( const char *name ){
#if DEBUG_SHADERS
globalOutputStream() << "shaders release: " << makeQuoted( name ) << '\n';
}
debug_string( "end rendering" );
}
+
void realise(){
if ( --m_unrealised == 0 ) {
if ( lightingSupported() && lightingEnabled() ) {
}
}
}
+
void unrealise(){
if ( ++m_unrealised == 1 ) {
for ( Shaders::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i )
}
}
}
+
bool realised(){
return m_unrealised == 0;
}
bool lightingEnabled() const {
return m_lightingEnabled;
}
+
bool lightingSupported() const {
return m_lightingSupported;
}
+
bool useShaderLanguage() const {
return m_useShaderLanguage;
}
+
void setLighting( bool supported, bool enabled ){
bool refresh = ( m_lightingSupported && m_lightingEnabled ) != ( supported && enabled );
realise();
}
}
+
void extensionsInitialised(){
setLighting( GlobalOpenGL().GL_1_3()
&& GlobalOpenGL().ARB_vertex_program()
}
}
}
+
void setLightingEnabled( bool enabled ){
setLighting( m_lightingSupported, enabled );
}
const LightList& attach( LightCullable& cullable ){
return ( *m_lightLists.insert( LightLists::value_type( &cullable, LinearLightList( cullable, m_lights, EvaluateChangedCaller( *this ) ) ) ).first ).second;
}
+
void detach( LightCullable& cullable ){
m_lightLists.erase( &cullable );
}
+
void changed( LightCullable& cullable ){
LightLists::iterator i = m_lightLists.find( &cullable );
ASSERT_MESSAGE( i != m_lightLists.end(), "cullable not attached" );
( *i ).second.lightsChanged();
}
+
void attach( RendererLight& light ){
ASSERT_MESSAGE( m_lights.find( &light ) == m_lights.end(), "light could not be attached" );
m_lights.insert( &light );
changed( light );
}
+
void detach( RendererLight& light ){
ASSERT_MESSAGE( m_lights.find( &light ) != m_lights.end(), "light could not be detached" );
m_lights.erase( &light );
changed( light );
}
+
void changed( RendererLight& light ){
m_lightsChanged = true;
}
+
void evaluateChanged(){
if ( m_lightsChanged ) {
m_lightsChanged = false;
}
}
}
-typedef MemberCaller<OpenGLShaderCache, &OpenGLShaderCache::evaluateChanged> EvaluateChangedCaller;
+
+typedef MemberCaller<OpenGLShaderCache, void(), &OpenGLShaderCache::evaluateChanged> EvaluateChangedCaller;
typedef std::set<const Renderable*> Renderables;
Renderables m_renderables;
ASSERT_MESSAGE( m_renderables.find( &renderable ) == m_renderables.end(), "renderable could not be attached" );
m_renderables.insert( &renderable );
}
+
void detachRenderable( const Renderable& renderable ){
ASSERT_MESSAGE( !m_traverseRenderablesMutex, "detaching renderable during traversal" );
ASSERT_MESSAGE( m_renderables.find( &renderable ) != m_renderables.end(), "renderable could not be detached" );
m_renderables.erase( &renderable );
}
+
void forEachRenderable( const RenderableCallback& callback ) const {
ASSERT_MESSAGE( !m_traverseRenderablesMutex, "for-each during traversal" );
m_traverseRenderablesMutex = true;
}
typedef States::iterator iterator;
+
iterator begin(){
return m_states.begin();
}
+
iterator end(){
return m_states.end();
}
bool inserted = m_states.insert( States::value_type( name, state ) ).second;
ASSERT_MESSAGE( inserted, "OpenGLStateMap::insert: " << name << " already exists" );
}
+
void erase( const char* name ){
std::size_t count = m_states.erase( name );
ASSERT_MESSAGE( count == 1, "OpenGLStateMap::erase: " << name << " does not exist" );
{
case IShader::eAlways:
state.m_alphafunc = GL_ALWAYS;
+ break;
case IShader::eEqual:
state.m_alphafunc = GL_EQUAL;
+ break;
case IShader::eLess:
state.m_alphafunc = GL_LESS;
+ break;
case IShader::eGreater:
state.m_alphafunc = GL_GREATER;
+ break;
case IShader::eLEqual:
state.m_alphafunc = GL_LEQUAL;
+ break;
case IShader::eGEqual:
state.m_alphafunc = GL_GEQUAL;
+ break;
}
}
reinterpret_cast<Vector3&>( state.m_colour ) = m_shader->getTexture()->color;
OpenGLStateMap m_stateMap;
public:
typedef OpenGLStateLibrary Type;
+
STRING_CONSTANT( Name, "*" );
OpenGLStateLibraryAPI(){
g_openglStates = &m_stateMap;
}
+
~OpenGLStateLibraryAPI(){
g_openglStates = 0;
}
+
OpenGLStateLibrary* getTable(){
return &m_stateMap;
}
ShaderCache* m_shaderCache;
public:
typedef ShaderCache Type;
+
STRING_CONSTANT( Name, "*" );
ShaderCacheAPI(){
m_shaderCache = GetShaderCache();
}
+
~ShaderCacheAPI(){
ShaderCache_Destroy();
}
+
ShaderCache* getTable(){
return m_shaderCache;
}
#include "instancelib.h"
#include "treemodel.h"
-class StringEqualPredicate
-{
-const char* m_string;
-public:
-StringEqualPredicate( const char* string ) : m_string( string ){
-}
-bool operator()( const char* other ) const {
- return string_equal( m_string, other );
-}
-};
-
template<std::size_t SIZE>
class TypeIdMap
{
TypeIdMap() : m_typeNamesEnd( m_typeNames ){
}
TypeId getTypeId( const char* name ){
- TypeName* i = std::find_if( m_typeNames, m_typeNamesEnd, StringEqualPredicate( name ) );
+ TypeName *i = std::find_if(m_typeNames, m_typeNamesEnd, [&](const char *other) {
+ return string_equal(name, other);
+ });
if ( i == m_typeNamesEnd ) {
ASSERT_MESSAGE( m_typeNamesEnd != m_typeNames + SIZE, "reached maximum number of type names supported (" << Unsigned( SIZE ) << ")" );
*m_typeNamesEnd++ = name;
#include "select.h"
+#include <gtk/gtk.h>
+
#include "debugging/debugging.h"
#include "ientity.h"
Select_GetBounds( g_select_workzone.d_work_min, g_select_workzone.d_work_max );
}
}
-typedef FreeCaller<Selection_UpdateWorkzone> SelectionUpdateWorkzoneCaller;
+typedef FreeCaller<void(), Selection_UpdateWorkzone> SelectionUpdateWorkzoneCaller;
IdleDraw g_idleWorkzone = IdleDraw( SelectionUpdateWorkzoneCaller() );
}
bool g_nodes_be_hidden = false;
-BoolExportCaller g_hidden_caller( g_nodes_be_hidden );
+ConstReferenceCaller<bool, void(const Callback<void(bool)> &), PropertyImpl<bool>::Export> g_hidden_caller( g_nodes_be_hidden );
+
ToggleItem g_hidden_item( g_hidden_caller );
class HideSelectedWalker : public scene::Graph::Walker
void Select_registerCommands(){
- GlobalCommands_insert( "ShowHidden", FreeCaller<Select_ShowAllHidden>(), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalToggles_insert( "HideSelected", FreeCaller<HideSelected>(), ToggleItem::AddCallbackCaller( g_hidden_item ), Accelerator( 'H' ) );
+ GlobalCommands_insert( "ShowHidden", makeCallbackF( Select_ShowAllHidden ), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalToggles_insert( "HideSelected", makeCallbackF( HideSelected ), ToggleItem::AddCallbackCaller( g_hidden_item ), Accelerator( 'H' ) );
- GlobalCommands_insert( "MirrorSelectionX", FreeCaller<Selection_Flipx>() );
- GlobalCommands_insert( "RotateSelectionX", FreeCaller<Selection_Rotatex>() );
- GlobalCommands_insert( "MirrorSelectionY", FreeCaller<Selection_Flipy>() );
- GlobalCommands_insert( "RotateSelectionY", FreeCaller<Selection_Rotatey>() );
- GlobalCommands_insert( "MirrorSelectionZ", FreeCaller<Selection_Flipz>() );
- GlobalCommands_insert( "RotateSelectionZ", FreeCaller<Selection_Rotatez>() );
+ GlobalCommands_insert( "MirrorSelectionX", makeCallbackF( Selection_Flipx ) );
+ GlobalCommands_insert( "RotateSelectionX", makeCallbackF( Selection_Rotatex ) );
+ GlobalCommands_insert( "MirrorSelectionY", makeCallbackF( Selection_Flipy ) );
+ GlobalCommands_insert( "RotateSelectionY", makeCallbackF( Selection_Rotatey ) );
+ GlobalCommands_insert( "MirrorSelectionZ", makeCallbackF( Selection_Flipz ) );
+ GlobalCommands_insert( "RotateSelectionZ", makeCallbackF( Selection_Rotatez ) );
- GlobalCommands_insert( "MirrorSelectionHorizontally", FreeCaller<Selection_FlipHorizontally>() );
- GlobalCommands_insert( "MirrorSelectionVertically", FreeCaller<Selection_FlipVertically>() );
+ GlobalCommands_insert( "MirrorSelectionHorizontally", makeCallbackF( Selection_FlipHorizontally ) );
+ GlobalCommands_insert( "MirrorSelectionVertically", makeCallbackF( Selection_FlipVertically ) );
- GlobalCommands_insert( "RotateSelectionClockwise", FreeCaller<Selection_RotateClockwise>() );
- GlobalCommands_insert( "RotateSelectionAnticlockwise", FreeCaller<Selection_RotateAnticlockwise>() );
+ GlobalCommands_insert( "RotateSelectionClockwise", makeCallbackF( Selection_RotateClockwise ) );
+ GlobalCommands_insert( "RotateSelectionAnticlockwise", makeCallbackF( Selection_RotateAnticlockwise ) );
}
SignalHandlerId Selection_boundsChanged;
void Selection_construct(){
- typedef FreeCaller1<const Selectable&, SceneSelectionChange> SceneSelectionChangeCaller;
+ typedef FreeCaller<void(const Selectable&), SceneSelectionChange> SceneSelectionChangeCaller;
GlobalSelectionSystem().addSelectionChangeCallback( SceneSelectionChangeCaller() );
- typedef FreeCaller1<const Selectable&, UpdateWorkzone_ForSelectionChanged> UpdateWorkzoneForSelectionChangedCaller;
+ typedef FreeCaller<void(const Selectable&), UpdateWorkzone_ForSelectionChanged> UpdateWorkzoneForSelectionChangedCaller;
GlobalSelectionSystem().addSelectionChangeCallback( UpdateWorkzoneForSelectionChangedCaller() );
- typedef FreeCaller<UpdateWorkzone_ForSelection> UpdateWorkzoneForSelectionCaller;
+ typedef FreeCaller<void(), UpdateWorkzone_ForSelection> UpdateWorkzoneForSelectionCaller;
Selection_boundsChanged = GlobalSceneGraph().addBoundsChangedCallback( UpdateWorkzoneForSelectionCaller() );
}
#include "gtkdlgs.h"
-#include <gtk/gtkbox.h>
-#include <gtk/gtkspinbutton.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtklabel.h>
#include <gdk/gdkkeysyms.h>
struct RotateDialog
{
- GtkSpinButton* x;
- GtkSpinButton* y;
- GtkSpinButton* z;
- GtkWindow *window;
+ ui::SpinButton x{ui::null};
+ ui::SpinButton y{ui::null};
+ ui::SpinButton z{ui::null};
+ ui::Window window{ui::null};
};
-static gboolean rotatedlg_apply( GtkWidget *widget, RotateDialog* rotateDialog ){
+static gboolean rotatedlg_apply( ui::Widget widget, RotateDialog* rotateDialog ){
Vector3 eulerXYZ;
gtk_spin_button_update ( rotateDialog->x );
return TRUE;
}
-static gboolean rotatedlg_cancel( GtkWidget *widget, RotateDialog* rotateDialog ){
- gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) );
+static gboolean rotatedlg_cancel( ui::Widget widget, RotateDialog* rotateDialog ){
+ rotateDialog->window.hide();
gtk_spin_button_set_value( rotateDialog->x, 0.0f ); // reset to 0 on close
gtk_spin_button_set_value( rotateDialog->y, 0.0f );
return TRUE;
}
-static gboolean rotatedlg_ok( GtkWidget *widget, RotateDialog* rotateDialog ){
+static gboolean rotatedlg_ok( ui::Widget widget, RotateDialog* rotateDialog ){
rotatedlg_apply( widget, rotateDialog );
// rotatedlg_cancel( widget, rotateDialog );
- gtk_widget_hide( GTK_WIDGET( rotateDialog->window ) );
+ rotateDialog->window.hide();
return TRUE;
}
-static gboolean rotatedlg_delete( GtkWidget *widget, GdkEventAny *event, RotateDialog* rotateDialog ){
+static gboolean rotatedlg_delete( ui::Widget widget, GdkEventAny *event, RotateDialog* rotateDialog ){
rotatedlg_cancel( widget, rotateDialog );
return TRUE;
}
RotateDialog g_rotate_dialog;
void DoRotateDlg(){
- if ( g_rotate_dialog.window == NULL ) {
- g_rotate_dialog.window = create_dialog_window( MainFrame_getWindow(), "Arbitrary rotation", G_CALLBACK( rotatedlg_delete ), &g_rotate_dialog );
+ if ( !g_rotate_dialog.window ) {
+ g_rotate_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary rotation", G_CALLBACK(rotatedlg_delete ), &g_rotate_dialog );
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( g_rotate_dialog.window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ g_rotate_dialog.window.add_accel_group( accel );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( g_rotate_dialog.window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ g_rotate_dialog.window.add(hbox);
{
- GtkTable* table = create_dialog_table( 3, 2, 4, 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = create_dialog_table( 3, 2, 4, 4 );
+ hbox.pack_start( table, TRUE, TRUE, 0 );
{
- GtkWidget* label = gtk_label_new( " X " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 0, 1,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " X " );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {0, 0});
}
{
- GtkWidget* label = gtk_label_new( " Y " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 1, 2,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " Y " );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {0, 0});
}
{
- GtkWidget* label = gtk_label_new( " Z " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 2, 3,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " Z " );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {0, 0});
}
{
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 1 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 );
+ auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
+ auto spin = ui::SpinButton( adj, 1, 1 );
+ spin.show();
+ table.attach(spin, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ spin.dimensions(64, -1);
gtk_spin_button_set_wrap( spin, TRUE );
- gtk_widget_grab_focus( GTK_WIDGET( spin ) );
+ gtk_widget_grab_focus( spin );
g_rotate_dialog.x = spin;
}
{
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 1 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 );
+ auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
+ auto spin = ui::SpinButton( adj, 1, 1 );
+ spin.show();
+ table.attach(spin, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ spin.dimensions(64, -1);
gtk_spin_button_set_wrap( spin, TRUE );
g_rotate_dialog.y = spin;
}
{
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0, -359, 359, 1, 10, 0 ) );
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 1 ) );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( table, GTK_WIDGET( spin ), 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 );
+ auto adj = ui::Adjustment( 0, -359, 359, 1, 10, 0 );
+ auto spin = ui::SpinButton( adj, 1, 1 );
+ spin.show();
+ table.attach(spin, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0});
+ spin.dimensions(64, -1);
gtk_spin_button_set_wrap( spin, TRUE );
g_rotate_dialog.z = spin;
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( rotatedlg_ok ), &g_rotate_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( rotatedlg_ok ), &g_rotate_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( rotatedlg_cancel ), &g_rotate_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( rotatedlg_cancel ), &g_rotate_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Apply", G_CALLBACK( rotatedlg_apply ), &g_rotate_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Apply", G_CALLBACK( rotatedlg_apply ), &g_rotate_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
}
}
}
}
- gtk_widget_show( GTK_WIDGET( g_rotate_dialog.window ) );
+ g_rotate_dialog.window.show();
}
struct ScaleDialog
{
- GtkWidget* x;
- GtkWidget* y;
- GtkWidget* z;
- GtkWindow *window;
+ ui::Entry x{ui::null};
+ ui::Entry y{ui::null};
+ ui::Entry z{ui::null};
+ ui::Window window{ui::null};
};
-static gboolean scaledlg_apply( GtkWidget *widget, ScaleDialog* scaleDialog ){
+static gboolean scaledlg_apply( ui::Widget widget, ScaleDialog* scaleDialog ){
float sx, sy, sz;
sx = static_cast<float>( atof( gtk_entry_get_text( GTK_ENTRY( scaleDialog->x ) ) ) );
return TRUE;
}
-static gboolean scaledlg_cancel( GtkWidget *widget, ScaleDialog* scaleDialog ){
- gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) );
+static gboolean scaledlg_cancel( ui::Widget widget, ScaleDialog* scaleDialog ){
+ scaleDialog->window.hide();
- gtk_entry_set_text( GTK_ENTRY( scaleDialog->x ), "1.0" );
- gtk_entry_set_text( GTK_ENTRY( scaleDialog->y ), "1.0" );
- gtk_entry_set_text( GTK_ENTRY( scaleDialog->z ), "1.0" );
+ scaleDialog->x.text("1.0");
+ scaleDialog->y.text("1.0");
+ scaleDialog->z.text("1.0");
return TRUE;
}
-static gboolean scaledlg_ok( GtkWidget *widget, ScaleDialog* scaleDialog ){
+static gboolean scaledlg_ok( ui::Widget widget, ScaleDialog* scaleDialog ){
scaledlg_apply( widget, scaleDialog );
//scaledlg_cancel( widget, scaleDialog );
- gtk_widget_hide( GTK_WIDGET( scaleDialog->window ) );
+ scaleDialog->window.hide();
return TRUE;
}
-static gboolean scaledlg_delete( GtkWidget *widget, GdkEventAny *event, ScaleDialog* scaleDialog ){
+static gboolean scaledlg_delete( ui::Widget widget, GdkEventAny *event, ScaleDialog* scaleDialog ){
scaledlg_cancel( widget, scaleDialog );
return TRUE;
}
ScaleDialog g_scale_dialog;
void DoScaleDlg(){
- if ( g_scale_dialog.window == NULL ) {
- g_scale_dialog.window = create_dialog_window( MainFrame_getWindow(), "Arbitrary scale", G_CALLBACK( scaledlg_delete ), &g_scale_dialog );
+ if ( !g_scale_dialog.window ) {
+ g_scale_dialog.window = MainFrame_getWindow().create_dialog_window("Arbitrary scale", G_CALLBACK(scaledlg_delete ), &g_scale_dialog );
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( g_scale_dialog.window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ g_scale_dialog.window.add_accel_group( accel );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( g_scale_dialog.window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ g_scale_dialog.window.add(hbox);
{
- GtkTable* table = create_dialog_table( 3, 2, 4, 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = create_dialog_table( 3, 2, 4, 4 );
+ hbox.pack_start( table, TRUE, TRUE, 0 );
{
- GtkWidget* label = gtk_label_new( " X " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 0, 1,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " X " );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {0, 0});
}
{
- GtkWidget* label = gtk_label_new( " Y " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 1, 2,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " Y " );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {0, 0});
}
{
- GtkWidget* label = gtk_label_new( " Z " );
- gtk_widget_show( label );
- gtk_table_attach( table, label, 0, 1, 2, 3,
- (GtkAttachOptions) ( 0 ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( " Z " );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {0, 0});
}
{
- GtkWidget* entry = gtk_entry_new();
- gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" );
- gtk_widget_show( entry );
- gtk_table_attach( table, entry, 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.text("1.0");
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
g_scale_dialog.x = entry;
}
{
- GtkWidget* entry = gtk_entry_new();
- gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" );
- gtk_widget_show( entry );
- gtk_table_attach( table, entry, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.text("1.0");
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
g_scale_dialog.y = entry;
}
{
- GtkWidget* entry = gtk_entry_new();
- gtk_entry_set_text( GTK_ENTRY( entry ), "1.0" );
- gtk_widget_show( entry );
- gtk_table_attach( table, entry, 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.text("1.0");
+ entry.show();
+ table.attach(entry, {1, 2, 2, 3}, {GTK_EXPAND | GTK_FILL, 0});
g_scale_dialog.z = entry;
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( scaledlg_ok ), &g_scale_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( scaledlg_ok ), &g_scale_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( scaledlg_cancel ), &g_scale_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( scaledlg_cancel ), &g_scale_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Apply", G_CALLBACK( scaledlg_apply ), &g_scale_dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Apply", G_CALLBACK( scaledlg_apply ), &g_scale_dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
}
}
}
}
- gtk_widget_show( GTK_WIDGET( g_scale_dialog.window ) );
+ g_scale_dialog.window.show();
}
*/
#include "selection.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
}
-#if defined( _DEBUG )
+#if GDEF_DEBUG
class test_quat
{
public:
class Rotatable
{
public:
+virtual ~Rotatable() = default;
virtual void rotate( const Quaternion& rotation ) = 0;
};
class Translatable
{
public:
+virtual ~Translatable() = default;
virtual void translate( const Vector3& translation ) = 0;
};
class Scalable
{
public:
+virtual ~Scalable() = default;
virtual void scale( const Vector3& scaling ) = 0;
};
}
};
-#if defined( _DEBUG )
+#if GDEF_DEBUG
#define DEBUG_SELECTION
#endif
bool contains( const Plane3& plane ) const {
return PlaneSet_contains( m_selectedPlanes, plane );
}
-typedef MemberCaller1<SelectedPlaneSet, const Plane3&, &SelectedPlaneSet::insert> InsertCaller;
+typedef MemberCaller<SelectedPlaneSet, void(const Plane3&), &SelectedPlaneSet::insert> InsertCaller;
};
class SelectionCounter
{
public:
-typedef const Selectable& first_argument_type;
+using func = void(const Selectable &);
SelectionCounter( const SelectionChangeCallback& onchanged )
: m_count( 0 ), m_onchanged( onchanged ){
m_pivotChanged = true;
SceneChangeNotify();
}
-typedef ConstMemberCaller<RadiantSelectionSystem, &RadiantSelectionSystem::pivotChanged> PivotChangedCaller;
+typedef ConstMemberCaller<RadiantSelectionSystem, void(), &RadiantSelectionSystem::pivotChanged> PivotChangedCaller;
void pivotChangedSelection( const Selectable& selectable ){
pivotChanged();
}
-typedef MemberCaller1<RadiantSelectionSystem, const Selectable&, &RadiantSelectionSystem::pivotChangedSelection> PivotChangedSelectionCaller;
+typedef MemberCaller<RadiantSelectionSystem, void(const Selectable&), &RadiantSelectionSystem::pivotChangedSelection> PivotChangedSelectionCaller;
void SetMode( EMode mode ){
if ( m_mode != mode ) {
SelectionChangeCallback getObserver( EMode mode ){
if ( mode == ePrimitive ) {
- return makeCallback1( m_count_primitive );
+ return makeCallback( m_count_primitive );
}
else
{
- return makeCallback1( m_count_component );
+ return makeCallback( m_count_component );
}
}
std::size_t countSelected() const {
void selectionChanged( const Selectable& selectable ){
m_selectionChanged_callbacks( selectable );
}
-typedef MemberCaller1<RadiantSelectionSystem, const Selectable&, &RadiantSelectionSystem::selectionChanged> SelectionChangedCaller;
+typedef MemberCaller<RadiantSelectionSystem, void(const Selectable&), &RadiantSelectionSystem::selectionChanged> SelectionChangedCaller;
void startMove(){
SelectionSystem_constructPreferences( page );
}
void SelectionSystem_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, SelectionSystem_constructPage>() );
+ PreferencesDialog_addSettingsPage( FreeCaller<void(PreferenceGroup&), SelectionSystem_constructPage>() );
}
g_RadiantSelectionSystem = new RadiantSelectionSystem;
- SelectionSystem_boundsChanged = GlobalSceneGraph().addBoundsChangedCallback( FreeCaller<SelectionSystem_OnBoundsChanged>() );
+ SelectionSystem_boundsChanged = GlobalSceneGraph().addBoundsChangedCallback( FreeCaller<void(), SelectionSystem_OnBoundsChanged>() );
GlobalShaderCache().attachRenderable( getSelectionSystem() );
- GlobalPreferenceSystem().registerPreference( "PreferPointEntsIn2D", BoolImportStringCaller( getSelectionSystem().m_bPreferPointEntsIn2D ), BoolExportStringCaller( getSelectionSystem().m_bPreferPointEntsIn2D ) );
- GlobalPreferenceSystem().registerPreference( "LeftMouseClickSelector", BoolImportStringCaller( g_bLeftMouseClickSelector ), BoolExportStringCaller( g_bLeftMouseClickSelector ) );
+ GlobalPreferenceSystem().registerPreference( "PreferPointEntsIn2D", make_property_string( getSelectionSystem().m_bPreferPointEntsIn2D ) );
+ GlobalPreferenceSystem().registerPreference( "LeftMouseClickSelector", make_property_string( g_bLeftMouseClickSelector ) );
SelectionSystem_registerPreferencesPage();
}
return WindowVector( window_constrained( window.x(), x, width ), window_constrained( window.y(), y, height ) );
}
-typedef Callback1<DeviceVector> MouseEventCallback;
+typedef Callback<void(DeviceVector)> MouseEventCallback;
Single<MouseEventCallback> g_mouseMovedCallback;
Single<MouseEventCallback> g_mouseUpCallback;
( m_state & c_modifier_face ) != c_modifierNone );
}
}
-typedef MemberCaller1<Selector_, DeviceVector, &Selector_::mouseMoved> MouseMovedCaller;
+typedef MemberCaller<Selector_, void(DeviceVector), &Selector_::mouseMoved> MouseMovedCaller;
void mouseUp( DeviceVector position ){
if( m_mouse2 ){
g_mouseMovedCallback.clear();
g_mouseUpCallback.clear();
}
-typedef MemberCaller1<Selector_, DeviceVector, &Selector_::mouseUp> MouseUpCaller;
+typedef MemberCaller<Selector_, void(DeviceVector), &Selector_::mouseUp> MouseUpCaller;
};
void mouseMoved( DeviceVector position ){
getSelectionSystem().MoveSelected( *m_view, &position[0], ( m_state & c_modifierShift ) == c_modifierShift, ( m_state & c_modifierControl ) == c_modifierControl );
}
-typedef MemberCaller1<Manipulator_, DeviceVector, &Manipulator_::mouseMoved> MouseMovedCaller;
+typedef MemberCaller<Manipulator_, void(DeviceVector), &Manipulator_::mouseMoved> MouseMovedCaller;
void mouseUp( DeviceVector position ){
getSelectionSystem().endMove();
g_mouseMovedCallback.clear();
g_mouseUpCallback.clear();
}
-typedef MemberCaller1<Manipulator_, DeviceVector, &Manipulator_::mouseUp> MouseUpCaller;
+typedef MemberCaller<Manipulator_, void(DeviceVector), &Manipulator_::mouseUp> MouseUpCaller;
void setState( ModifierFlags state ){
m_state = state;
#define INCLUDED_SELECTION_H
#include "windowobserver.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
struct rect_t
{
float max[2];
};
-typedef Callback1<rect_t> RectangleCallback;
+typedef Callback<void(rect_t)> RectangleCallback;
class View;
class SelectionSystemWindowObserver : public WindowObserver
{
public:
+virtual ~SelectionSystemWindowObserver() = default;
virtual void setView( const View& view ) = 0;
virtual void setRectangleDrawCallback( const RectangleCallback& callback ) = 0;
};
*/
#include "server.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
#include "warnings.h"
}
void registerModule( const char* type, int version, const char* name, Module& module ){
- ASSERT_NOTNULL( &module );
if ( !m_modules.insert( Modules_::value_type( ModuleKey( ModuleType( type, version ), name ), &module ) ).second ) {
globalErrorStream() << "module already registered: type=" << makeQuoted( type ) << " name=" << makeQuoted( name ) << "\n";
}
};
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
#include <windows.h>
-#define FORMAT_BUFSIZE 2048
+const int FORMAT_BUFSIZE = 2048;
const char* FormatGetLastError(){
static char buf[FORMAT_BUFSIZE];
FormatMessage(
}
};
-#elif defined( POSIX )
+#elif GDEF_OS_POSIX
#include <dlfcn.h>
#define RTLD_DEEPBIND 0
#endif
-class DynamicLibrary
-{
-void* m_library;
+class DynamicLibrary {
+ void *m_library;
public:
typedef int ( *FunctionPointer )();
-
#include "sockets.h"
+#include "globaldefs.h"
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
#include <winsock2.h>
-#elif defined ( POSIX )
+#elif GDEF_OS_POSIX
#include <sys/time.h>
-#define SOCKET_ERROR -1
+const int SOCKET_ERROR = -1;
#else
#error "unsupported platform"
#endif
-#ifdef __APPLE__
+#if GDEF_OS_MACOS
#include <unistd.h>
#endif
int Net_Wait( socket_t *sock, long sec, long usec ){
// used for select()
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
TIMEVAL tout = { sec, usec };
#endif
-#if defined ( POSIX )
+#if GDEF_OS_POSIX
timeval tout;
tout.tv_sec = sec;
tout.tv_usec = usec;
*/
#include "stacktrace.h"
+#include "globaldefs.h"
+
#include "stream/textstream.h"
#include "environment.h"
-#ifdef __linux__
+#if GDEF_OS_LINUX
#include <execinfo.h>
void write_stack_trace( TextOutputStream& outputStream ){
free( symbol_names );
}
}
-#elif defined ( WIN32 ) && defined ( _MSC_VER )
+#elif GDEF_COMPILER_MSVC
#include "windows.h"
#include "winnt.h"
}
}
-#elif defined ( WIN32 )
+#elif GDEF_OS_WINDOWS
void write_stack_trace( TextOutputStream& outputStream ){
outputStream << "\nStacktrace is disabled on this compiler\n";
}
#include "surfacedialog.h"
+#include <gtk/gtk.h>
+
#include "debugging/debugging.h"
#include "warnings.h"
#include "iundo.h"
#include "iselection.h"
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkspinbutton.h>
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkcheckbutton.h> //Shamus: For Textool
#include "signal/isignal.h"
#include "generic/object.h"
{
//Shamus: Textool function prototypes
-gboolean size_allocate( GtkWidget *, GtkAllocation *, gpointer );
-gboolean expose( GtkWidget *, GdkEventExpose *, gpointer );
-gboolean button_press( GtkWidget *, GdkEventButton *, gpointer );
-gboolean button_release( GtkWidget *, GdkEventButton *, gpointer );
-gboolean motion( GtkWidget *, GdkEventMotion *, gpointer );
-void flipX( GtkToggleButton *, gpointer );
-void flipY( GtkToggleButton *, gpointer );
+gboolean size_allocate( ui::Widget, GtkAllocation *, gpointer );
+gboolean expose( ui::Widget, GdkEventExpose *, gpointer );
+gboolean button_press( ui::Widget, GdkEventButton *, gpointer );
+gboolean button_release( ui::Widget, GdkEventButton *, gpointer );
+gboolean motion( ui::Widget, GdkEventMotion *, gpointer );
+void flipX( ui::ToggleButton, gpointer );
+void flipY( ui::ToggleButton, gpointer );
//End Textool function prototypes
//Shamus: Textool globals
-GtkWidget * g_textoolWin;
+ui::Widget g_textoolWin;
//End Textool globals
void queueDraw(){
#endif
-inline void spin_button_set_step( GtkSpinButton* spin, gfloat step ){
+inline void spin_button_set_step( ui::SpinButton spin, gfloat step ){
#if 1
- gtk_spin_button_get_adjustment( spin )->step_increment = step;
+ gtk_adjustment_set_step_increment(gtk_spin_button_get_adjustment( spin ), step);
#else
GValue gvalue = GValue_default();
g_value_init( &gvalue, G_TYPE_DOUBLE );
{
float& m_f;
public:
-GtkSpinButton* m_spin;
-GtkEntry* m_entry;
-Increment( float& f ) : m_f( f ), m_spin( 0 ), m_entry( 0 ){
+ui::SpinButton m_spin;
+ui::Entry m_entry;
+Increment( float& f ) : m_f( f ), m_spin( ui::null ), m_entry( ui::null ){
}
void cancel(){
entry_set_float( m_entry, m_f );
}
-typedef MemberCaller<Increment, &Increment::cancel> CancelCaller;
+typedef MemberCaller<Increment, void(), &Increment::cancel> CancelCaller;
void apply(){
m_f = static_cast<float>( entry_get_float( m_entry ) );
spin_button_set_step( m_spin, m_f );
}
-typedef MemberCaller<Increment, &Increment::apply> ApplyCaller;
+typedef MemberCaller<Increment, void(), &Increment::apply> ApplyCaller;
};
void SurfaceInspector_GridChange();
class SurfaceInspector : public Dialog
{
-GtkWindow* BuildDialog();
+ui::Window BuildDialog();
NonModalEntry m_textureEntry;
NonModalSpinner m_hshiftSpinner;
GtkCheckButton* m_contentFlags[32];
NonModalEntry m_valueEntry;
-GtkEntry* m_valueEntryWidget;
+ui::Entry m_valueEntryWidget{ui::null};
public:
WindowPositionTracker m_positionTracker;
-WindowPositionTrackerImportStringCaller m_importPosition;
-WindowPositionTrackerExportStringCaller m_exportPosition;
// Dialog Data
float m_fitHorizontal;
Increment m_hscaleIncrement;
Increment m_vscaleIncrement;
Increment m_rotateIncrement;
-GtkEntry* m_texture;
+ui::Entry m_texture{ui::null};
SurfaceInspector() :
m_textureEntry( ApplyShaderCaller( *this ), UpdateCaller( *this ) ),
m_rotateEntry( Increment::ApplyCaller( m_rotateIncrement ), Increment::CancelCaller( m_rotateIncrement ) ),
m_idleDraw( UpdateCaller( *this ) ),
m_valueEntry( ApplyFlagsCaller( *this ), UpdateCaller( *this ) ),
- m_importPosition( m_positionTracker ),
- m_exportPosition( m_positionTracker ),
m_hshiftIncrement( g_si_globals.shift[0] ),
m_vshiftIncrement( g_si_globals.shift[1] ),
m_hscaleIncrement( g_si_globals.scale[0] ),
m_positionTracker.setPosition( c_default_window_pos );
}
-void constructWindow( GtkWindow* main_window ){
+void constructWindow( ui::Window main_window ){
m_parent = main_window;
Create();
- AddGridChangeCallback( FreeCaller<SurfaceInspector_GridChange>() );
+ AddGridChangeCallback( FreeCaller<void(), SurfaceInspector_GridChange>() );
}
void destroyWindow(){
Destroy();
}
-bool visible() const {
- return GTK_WIDGET_VISIBLE( const_cast<GtkWindow*>( GetWidget() ) );
+bool visible() {
+ return GetWidget().visible();
}
void queueDraw(){
if ( visible() ) {
}
void Update();
-typedef MemberCaller<SurfaceInspector, &SurfaceInspector::Update> UpdateCaller;
+typedef MemberCaller<SurfaceInspector, void(), &SurfaceInspector::Update> UpdateCaller;
void ApplyShader();
-typedef MemberCaller<SurfaceInspector, &SurfaceInspector::ApplyShader> ApplyShaderCaller;
+typedef MemberCaller<SurfaceInspector, void(), &SurfaceInspector::ApplyShader> ApplyShaderCaller;
void ApplyTexdef();
-typedef MemberCaller<SurfaceInspector, &SurfaceInspector::ApplyTexdef> ApplyTexdefCaller;
+typedef MemberCaller<SurfaceInspector, void(), &SurfaceInspector::ApplyTexdef> ApplyTexdefCaller;
void ApplyFlags();
-typedef MemberCaller<SurfaceInspector, &SurfaceInspector::ApplyFlags> ApplyFlagsCaller;
+typedef MemberCaller<SurfaceInspector, void(), &SurfaceInspector::ApplyFlags> ApplyFlagsCaller;
};
namespace
}
}
-void SurfaceInspector_constructWindow( GtkWindow* main_window ){
+void SurfaceInspector_constructWindow( ui::Window main_window ){
getSurfaceInspector().constructWindow( main_window );
}
void SurfaceInspector_destroyWindow(){
// we move the textures in pixels, not world units. (i.e. increment values are in pixel)
// depending on the texture scale it doesn't take the same amount of pixels to move of GetGridSize()
// increment * scale = gridsize
-static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){
+static void OnBtnMatchGrid( ui::Widget widget, gpointer data ){
float hscale, vscale;
- hscale = static_cast<float>( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_hscaleIncrement.m_spin ) );
- vscale = static_cast<float>( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_vscaleIncrement.m_spin ) );
+ hscale = static_cast<float>( gtk_spin_button_get_value( getSurfaceInspector().m_hscaleIncrement.m_spin ) );
+ vscale = static_cast<float>( gtk_spin_button_get_value( getSurfaceInspector().m_vscaleIncrement.m_spin ) );
if ( hscale == 0.0f || vscale == 0.0f ) {
globalOutputStream() << "ERROR: unexpected scale == 0.0f\n";
// or update it because something new has been selected
// Shamus: It does get called when the SI is hidden, but not when you select something new. ;-)
void DoSurface( void ){
- if ( getSurfaceInspector().GetWidget() == 0 ) {
+ if ( !getSurfaceInspector().GetWidget() ) {
getSurfaceInspector().Create();
}
Select_FitTexture( 0, getSurfaceInspector().m_fitVertical );
}
-static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){
+static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){
Patch_CapTexture();
}
-static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){
+static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){
Patch_NaturalTexture();
}
-static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){
+static void OnBtnPatchreset( ui::Widget widget, gpointer data ){
Patch_ResetTexture();
}
-static void OnBtnPatchFit( GtkWidget *widget, gpointer data ){
+static void OnBtnPatchFit( ui::Widget widget, gpointer data ){
Patch_FitTexture();
}
-static void OnBtnAxial( GtkWidget *widget, gpointer data ){
+static void OnBtnAxial( ui::Widget widget, gpointer data ){
//globalOutputStream() << "--> [OnBtnAxial]...\n";
UndoableCommand undo( "textureDefault" );
TextureProjection projection;
Select_SetTexdef( projection );
}
-static void OnBtnFaceFit( GtkWidget *widget, gpointer data ){
+static void OnBtnFaceFit( ui::Widget widget, gpointer data ){
getSurfaceInspector().exportData();
SurfaceInspector_FitTexture();
}
// =============================================================================
// SurfaceInspector class
-guint togglebutton_connect_toggled( GtkToggleButton* button, const Callback& callback ){
+guint togglebutton_connect_toggled( ui::ToggleButton button, const Callback<void()>& callback ){
return g_signal_connect_swapped( G_OBJECT( button ), "toggled", G_CALLBACK( callback.getThunk() ), callback.getEnvironment() );
}
-GtkWindow* SurfaceInspector::BuildDialog(){
- GtkWindow* window = create_floating_window( "Surface Inspector", m_parent );
+ui::Window SurfaceInspector::BuildDialog(){
+ ui::Window window = ui::Window(create_floating_window( "Surface Inspector", m_parent ));
m_positionTracker.connect( window );
{
// replaced by only the vbox:
- GtkWidget* vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) );
+ auto vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
+ window.add(vbox);
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
{
- GtkWidget* hbox2 = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox2 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 );
+ auto hbox2 = ui::HBox( FALSE, 5 );
+ hbox2.show();
+ vbox.pack_start( hbox2, FALSE, FALSE, 0 );
{
- GtkWidget* label = gtk_label_new( "Texture" );
- gtk_widget_show( label );
- gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 );
+ ui::Widget label = ui::Label( "Texture" );
+ label.show();
+ hbox2.pack_start( label, FALSE, TRUE, 0 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_box_pack_start( GTK_BOX( hbox2 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ hbox2.pack_start( entry, TRUE, TRUE, 0 );
m_texture = entry;
m_textureEntry.connect( entry );
GlobalTextureEntryCompletion::instance().connect( entry );
{
- GtkWidget* table = gtk_table_new( 6, 4, FALSE );
- gtk_widget_show( table );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), FALSE, FALSE, 0 );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ auto table = ui::Table(6, 4, FALSE);
+ table.show();
+ vbox.pack_start( table, FALSE, FALSE, 0 );
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
{
- GtkWidget* label = gtk_label_new( "Horizontal shift" );
- gtk_widget_show( label );
+ ui::Widget label = ui::Label( "Horizontal shift" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
}
{
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) );
+ auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 );
m_hshiftIncrement.m_spin = spin;
m_hshiftSpinner.connect( spin );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 );
+ spin.show();
+ table.attach(spin, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ spin.dimensions(60, -1);
}
{
- GtkWidget* label = gtk_label_new( "Step" );
- gtk_widget_show( label );
+ ui::Widget label = ui::Label( "Step" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(label, {2, 3, 0, 1}, {GTK_FILL, 0});
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {3, 4, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+ entry.dimensions(50, -1);
m_hshiftIncrement.m_entry = entry;
m_hshiftEntry.connect( entry );
}
{
- GtkWidget* label = gtk_label_new( "Vertical shift" );
- gtk_widget_show( label );
+ ui::Widget label = ui::Label( "Vertical shift" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
}
{
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) );
+ auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 );
m_vshiftIncrement.m_spin = spin;
m_vshiftSpinner.connect( spin );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 );
+ spin.show();
+ table.attach(spin, {1, 2, 1, 2}, {GTK_FILL, 0});
+ spin.dimensions(60, -1);
}
{
- GtkWidget* label = gtk_label_new( "Step" );
- gtk_widget_show( label );
+ ui::Widget label = ui::Label( "Step" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(label, {2, 3, 1, 2}, {GTK_FILL, 0});
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {3, 4, 1, 2}, {GTK_FILL, 0});
+ entry.dimensions(50, -1);
m_vshiftIncrement.m_entry = entry;
m_vshiftEntry.connect( entry );
}
{
- GtkWidget* label = gtk_label_new( "Horizontal stretch" );
- gtk_widget_show( label );
+ ui::Widget label = ui::Label( "Horizontal stretch" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(label, {0, 1, 2, 3}, {GTK_FILL, 0});
}
{
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 5 ) );
+ auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 );
m_hscaleIncrement.m_spin = spin;
m_hscaleSpinner.connect( spin );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 );
+ spin.show();
+ table.attach(spin, {1, 2, 2, 3}, {GTK_FILL, 0});
+ spin.dimensions(60, -1);
}
{
- GtkWidget* label = gtk_label_new( "Step" );
- gtk_widget_show( label );
+ ui::Widget label = ui::Label( "Step" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 2, 3 );
+ table.attach(label, {2, 3, 2, 3}, {GTK_FILL, 0});
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 2, 3 );
- gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {3, 4, 2, 3}, {GTK_FILL, 0});
+ entry.dimensions(50, -1);
m_hscaleIncrement.m_entry = entry;
m_hscaleEntry.connect( entry );
}
{
- GtkWidget* label = gtk_label_new( "Vertical stretch" );
- gtk_widget_show( label );
+ ui::Widget label = ui::Label( "Vertical stretch" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 3, 4,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(label, {0, 1, 3, 4}, {GTK_FILL, 0});
}
{
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 5 ) );
+ auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 5 );
m_vscaleIncrement.m_spin = spin;
m_vscaleSpinner.connect( spin );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 3, 4,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 );
+ spin.show();
+ table.attach(spin, {1, 2, 3, 4}, {GTK_FILL, 0});
+ spin.dimensions(60, -1);
}
{
- GtkWidget* label = gtk_label_new( "Step" );
- gtk_widget_show( label );
+ ui::Widget label = ui::Label( "Step" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 3, 4,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(label, {2, 3, 3, 4}, {GTK_FILL, 0});
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 3, 4,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {3, 4, 3, 4}, {GTK_FILL, 0});
+ entry.dimensions(50, -1);
m_vscaleIncrement.m_entry = entry;
m_vscaleEntry.connect( entry );
}
{
- GtkWidget* label = gtk_label_new( "Rotate" );
- gtk_widget_show( label );
+ ui::Widget label = ui::Label( "Rotate" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 4, 5,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(label, {0, 1, 4, 5}, {GTK_FILL, 0});
}
{
- GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 2 ) );
+ auto spin = ui::SpinButton( ui::Adjustment( 0, -8192, 8192, 2, 8, 0 ), 0, 2 );
m_rotateIncrement.m_spin = spin;
m_rotateSpinner.connect( spin );
- gtk_widget_show( GTK_WIDGET( spin ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( spin ), 1, 2, 4, 5,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( spin ), 60, -2 );
+ spin.show();
+ table.attach(spin, {1, 2, 4, 5}, {GTK_FILL, 0});
+ spin.dimensions(60, -1);
gtk_spin_button_set_wrap( spin, TRUE );
}
{
- GtkWidget* label = gtk_label_new( "Step" );
- gtk_widget_show( label );
+ ui::Widget label = ui::Label( "Step" );
+ label.show();
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
- gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 4, 5,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ table.attach(label, {2, 3, 4, 5}, {GTK_FILL, 0});
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( entry ), 3, 4, 4, 5,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( GTK_WIDGET( entry ), 50, -2 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {3, 4, 4, 5}, {GTK_FILL, 0});
+ entry.dimensions(50, -1);
m_rotateIncrement.m_entry = entry;
m_rotateEntry.connect( entry );
}
{
// match grid button
- GtkWidget* button = gtk_button_new_with_label( "Match Grid" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 2, 4, 5, 6,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( OnBtnMatchGrid ), 0 );
+ ui::Widget button = ui::Button( "Match Grid" );
+ button.show();
+ table.attach(button, {2, 4, 5, 6}, {GTK_EXPAND | GTK_FILL, 0});
+ button.connect( "clicked", G_CALLBACK( OnBtnMatchGrid ), 0 );
}
}
{
- GtkWidget* frame = gtk_frame_new( "Texturing" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 );
+ auto frame = ui::Frame( "Texturing" );
+ frame.show();
+ vbox.pack_start( frame, FALSE, FALSE, 0 );
{
- GtkWidget* table = gtk_table_new( 4, 4, FALSE );
- gtk_widget_show( table );
- gtk_container_add( GTK_CONTAINER( frame ), table );
- gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
- gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
+ auto table = ui::Table(4, 4, FALSE);
+ table.show();
+ frame.add(table);
+ gtk_table_set_row_spacings(table, 5);
+ gtk_table_set_col_spacings(table, 5);
gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
{
- GtkWidget* label = gtk_label_new( "Brush" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( "Brush" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
}
{
- GtkWidget* label = gtk_label_new( "Patch" );
- gtk_widget_show( label );
- gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ ui::Widget label = ui::Label( "Patch" );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {GTK_FILL, 0});
}
{
- GtkWidget* button = gtk_button_new_with_label( "Width" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
- G_CALLBACK( OnBtnFaceFitW ), 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ ui::Widget label = ui::Label( "Width" );
+ label.show();
+ table.attach(label, {2, 3, 0, 1}, {GTK_FILL, 0});
}
{
- GtkWidget* button = gtk_button_new_with_label( "Height" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
- G_CALLBACK( OnBtnFaceFitH ), 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ ui::Widget label = ui::Label( "Height" );
+ label.show();
+ table.attach(label, {3, 4, 0, 1}, {GTK_FILL, 0});
}
{
- GtkWidget* button = gtk_button_new_with_label( "Axial" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ ui::Widget button = ui::Button( "Axial" );
+ button.show();
+ table.attach(button, {0, 1, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ button.connect( "clicked",
G_CALLBACK( OnBtnAxial ), 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
}
{
- GtkWidget* button = gtk_button_new_with_label( "Fit" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ ui::Widget button = ui::Button( "Fit" );
+ button.show();
+ table.attach(button, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ button.connect( "clicked",
G_CALLBACK( OnBtnFaceFit ), 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
}
{
- GtkWidget* button = gtk_button_new_with_label( "CAP" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 3, 4,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ ui::Widget button = ui::Button( "CAP" );
+ button.show();
+ table.attach(button, {0, 1, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
+ button.connect( "clicked",
G_CALLBACK( OnBtnPatchdetails ), 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
}
{
- GtkWidget* button = gtk_button_new_with_label( "Set..." );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 3, 4,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ ui::Widget button = ui::Button( "Set..." );
+ button.show();
+ table.attach(button, {1, 2, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
+ button.connect( "clicked",
G_CALLBACK( OnBtnPatchreset ), 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
}
{
- GtkWidget* button = gtk_button_new_with_label( "Natural" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 3, 4,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ ui::Widget button = ui::Button( "Natural" );
+ button.show();
+ table.attach(button, {2, 3, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
+ button.connect( "clicked",
G_CALLBACK( OnBtnPatchnatural ), 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
}
{
- GtkWidget* button = gtk_button_new_with_label( "Fit" );
- gtk_widget_show( button );
- gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 3, 4,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ ui::Widget button = ui::Button( "Fit" );
+ button.show();
+ table.attach(button, {3, 4, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
+ button.connect( "clicked",
G_CALLBACK( OnBtnPatchFit ), 0 );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
}
{
- GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 );
- gtk_widget_show( spin );
- gtk_table_attach( GTK_TABLE( table ), spin, 2, 3, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( spin, 60, -2 );
- AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitHorizontal );
+ auto spin = ui::SpinButton( ui::Adjustment( 1, 0, 1 << 16, 1, 10, 0 ), 0, 6 );
+ spin.show();
+ table.attach(spin, {2, 3, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ spin.dimensions(60, -1);
+ AddDialogData( spin, m_fitHorizontal );
}
{
- GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 );
- gtk_widget_show( spin );
- gtk_table_attach( GTK_TABLE( table ), spin, 3, 4, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
- gtk_widget_set_usize( spin, 60, -2 );
- AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitVertical );
+ auto spin = ui::SpinButton( ui::Adjustment( 1, 0, 1 << 16, 1, 10, 0 ), 0, 6 );
+ spin.show();
+ table.attach(spin, {3, 4, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+ spin.dimensions(60, -1);
+ AddDialogData( spin, m_fitVertical );
}
}
}
if ( !string_empty( g_pGameDescription->getKeyValue( "si_flags" ) ) ) {
{
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Surface Flags" ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+ auto frame = ui::Frame( "Surface Flags" );
+ frame.show();
+ vbox.pack_start( frame, TRUE, TRUE, 0 );
{
- GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) );
+ auto vbox3 = ui::VBox( FALSE, 4 );
//gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4);
- gtk_widget_show( GTK_WIDGET( vbox3 ) );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) );
+ vbox3.show();
+ frame.add(vbox3);
{
- GtkTable* table = GTK_TABLE( gtk_table_new( 8, 4, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
- gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = ui::Table( 8, 4, FALSE );
+ table.show();
+ vbox3.pack_start( table, TRUE, TRUE, 0 );
gtk_table_set_row_spacings( table, 0 );
gtk_table_set_col_spacings( table, 0 );
GtkCheckButton** p = m_surfaceFlags;
- for ( int c = 0; c != 4; ++c )
+ for (unsigned int c = 0; c != 4; ++c)
{
- for ( int r = 0; r != 8; ++r )
+ for (unsigned int r = 0; r != 8; ++r)
{
- GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( getSurfaceFlagName( c * 8 + r ) ) );
- gtk_widget_show( GTK_WIDGET( check ) );
- gtk_table_attach( table, GTK_WIDGET( check ), c, c + 1, r, r + 1,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto check = ui::CheckButton( getSurfaceFlagName( c * 8 + r ) );
+ check.show();
+ table.attach(check, {c, c + 1, r, r + 1}, {GTK_EXPAND | GTK_FILL, 0});
*p++ = check;
- guint handler_id = togglebutton_connect_toggled( GTK_TOGGLE_BUTTON( check ), ApplyFlagsCaller( *this ) );
+ guint handler_id = togglebutton_connect_toggled( check, ApplyFlagsCaller( *this ) );
g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) );
}
}
}
}
{
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Content Flags" ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+ auto frame = ui::Frame( "Content Flags" );
+ frame.show();
+ vbox.pack_start( frame, TRUE, TRUE, 0 );
{
- GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) );
+ auto vbox3 = ui::VBox( FALSE, 4 );
//gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4);
- gtk_widget_show( GTK_WIDGET( vbox3 ) );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) );
+ vbox3.show();
+ frame.add(vbox3);
{
- GtkTable* table = GTK_TABLE( gtk_table_new( 8, 4, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
- gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = ui::Table( 8, 4, FALSE );
+ table.show();
+ vbox3.pack_start( table, TRUE, TRUE, 0 );
gtk_table_set_row_spacings( table, 0 );
gtk_table_set_col_spacings( table, 0 );
GtkCheckButton** p = m_contentFlags;
- for ( int c = 0; c != 4; ++c )
+ for (unsigned int c = 0; c != 4; ++c)
{
- for ( int r = 0; r != 8; ++r )
+ for (unsigned int r = 0; r != 8; ++r)
{
- GtkCheckButton* check = GTK_CHECK_BUTTON( gtk_check_button_new_with_label( getContentFlagName( c * 8 + r ) ) );
- gtk_widget_show( GTK_WIDGET( check ) );
- gtk_table_attach( table, GTK_WIDGET( check ), c, c + 1, r, r + 1,
- (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions)( 0 ), 0, 0 );
+ auto check = ui::CheckButton( getContentFlagName( c * 8 + r ) );
+ check.show();
+ table.attach(check, {c, c + 1, r, r + 1}, {GTK_EXPAND | GTK_FILL, 0});
*p++ = check;
- guint handler_id = togglebutton_connect_toggled( GTK_TOGGLE_BUTTON( check ), ApplyFlagsCaller( *this ) );
+ guint handler_id = togglebutton_connect_toggled( check, ApplyFlagsCaller( *this ) );
g_object_set_data( G_OBJECT( check ), "handler", gint_to_pointer( handler_id ) );
}
}
// not allowed to modify detail flag using Surface Inspector
- gtk_widget_set_sensitive( GTK_WIDGET( m_contentFlags[BRUSH_DETAIL_FLAG] ), FALSE );
+ gtk_widget_set_sensitive( ui::CheckButton::from(m_contentFlags[BRUSH_DETAIL_FLAG]), FALSE );
}
}
}
{
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( "Value" ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+ auto frame = ui::Frame( "Value" );
+ frame.show();
+ vbox.pack_start( frame, TRUE, TRUE, 0 );
{
- GtkVBox* vbox3 = GTK_VBOX( gtk_vbox_new( FALSE, 4 ) );
+ auto vbox3 = ui::VBox( FALSE, 4 );
gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 4 );
- gtk_widget_show( GTK_WIDGET( vbox3 ) );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) );
+ vbox3.show();
+ frame.add(vbox3);
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_box_pack_start( GTK_BOX( vbox3 ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ vbox3.pack_start( entry, TRUE, TRUE, 0 );
m_valueEntryWidget = entry;
m_valueEntry.connect( entry );
}
#if TEXTOOL_ENABLED
if ( g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_BRUSHPRIMITIVES ) {
// Shamus: Textool goodies...
- GtkWidget * frame = gtk_frame_new( "Textool" );
- gtk_widget_show( frame );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 );
+ ui::Widget frame = ui::Frame( "Textool" );
+ frame.show();
+ vbox.pack_start( frame , FALSE, FALSE, 0 );
{
//Prolly should make this a member or global var, so the SI can draw on it...
TexTool::g_textoolWin = glwidget_new( FALSE );
// --> Dunno, but this stuff may be necessary... (Looks like it!)
- gtk_widget_ref( TexTool::g_textoolWin );
+ g_object_ref( TexTool::g_textoolWin );
gtk_widget_set_events( TexTool::g_textoolWin, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK );
- GTK_WIDGET_SET_FLAGS( TexTool::g_textoolWin, GTK_CAN_FOCUS );
+ gtk_widget_set_can_focus( TexTool::g_textoolWin, true );
// <-- end stuff...
- gtk_widget_show( TexTool::g_textoolWin );
- gtk_widget_set_usize( TexTool::g_textoolWin, -1, 240 ); //Yeah!
- gtk_container_add( GTK_CONTAINER( frame ), TexTool::g_textoolWin );
-
- g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "size_allocate", G_CALLBACK( TexTool::size_allocate ), NULL );
- g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "expose_event", G_CALLBACK( TexTool::expose ), NULL );
- g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "button_press_event", G_CALLBACK( TexTool::button_press ), NULL );
- g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "button_release_event", G_CALLBACK( TexTool::button_release ), NULL );
- g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "motion_notify_event", G_CALLBACK( TexTool::motion ), NULL );
+ TexTool::g_textoolWin.show();
+ TexTool::g_textoolWin.dimensions( -1, 240 ); //Yeah!
+ frame.add(TexTool::g_textoolWin);
+
+ TexTool::g_textoolWin.connect( "size_allocate", G_CALLBACK( TexTool::size_allocate ), NULL );
+ TexTool::g_textoolWin.connect( "expose_event", G_CALLBACK( TexTool::expose ), NULL );
+ TexTool::g_textoolWin.connect( "button_press_event", G_CALLBACK( TexTool::button_press ), NULL );
+ TexTool::g_textoolWin.connect( "button_release_event", G_CALLBACK( TexTool::button_release ), NULL );
+ TexTool::g_textoolWin.connect( "motion_notify_event", G_CALLBACK( TexTool::motion ), NULL );
}
{
- GtkWidget * hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, FALSE, 0 );
+ ui::Widget hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox.pack_start( hbox , FALSE, FALSE, 0 );
// Checkboxes go here... (Flip X/Y)
- GtkWidget * flipX = gtk_check_button_new_with_label( "Flip X axis" );
- GtkWidget * flipY = gtk_check_button_new_with_label( "Flip Y axis" );
- gtk_widget_show( flipX );
- gtk_widget_show( flipY );
- gtk_box_pack_start( GTK_BOX( hbox ), flipX, FALSE, FALSE, 0 );
- gtk_box_pack_start( GTK_BOX( hbox ), flipY, FALSE, FALSE, 0 );
+ ui::Widget flipX = ui::CheckButton( "Flip X axis" );
+ ui::Widget flipY = ui::CheckButton( "Flip Y axis" );
+ flipX.show();
+ flipY.show();
+ hbox.pack_start( flipX, FALSE, FALSE, 0 );
+ hbox.pack_start( flipY, FALSE, FALSE, 0 );
//Instead of this, we probably need to create a vbox to put into the frame, then the
//window, then the hbox. !!! FIX !!!
-// gtk_container_add(GTK_CONTAINER(frame), hbox);
+// frame.add(hbox);
//Hmm. Do we really need g_object_set_data? Mebbe not... And we don't! :-)
-// g_object_set_data(G_OBJECT(flipX), "handler", gint_to_pointer(g_signal_connect(G_OBJECT(flipX), "toggled", G_CALLBACK(TexTool::flipX), 0)));
-// g_object_set_data(G_OBJECT(flipY), "handler", gint_to_pointer(g_signal_connect(G_OBJECT(flipY), "toggled", G_CALLBACK(TexTool::flipY), 0)));
+// g_object_set_data(G_OBJECT(flipX), "handler", gint_to_pointer(flipX.connect("toggled", G_CALLBACK(TexTool::flipX), 0)));
+// g_object_set_data(G_OBJECT(flipY), "handler", gint_to_pointer(flipY.connect("toggled", G_CALLBACK(TexTool::flipY), 0)));
//Instead, just do:
- g_signal_connect( G_OBJECT( flipX ), "toggled", G_CALLBACK( TexTool::flipX ), NULL );
- g_signal_connect( G_OBJECT( flipY ), "toggled", G_CALLBACK( TexTool::flipY ), NULL );
+ flipX.connect( "toggled", G_CALLBACK( TexTool::flipX ), NULL );
+ flipY.connect( "toggled", G_CALLBACK( TexTool::flipY ), NULL );
}
}
#endif
===============
*/
-void spin_button_set_value_no_signal( GtkSpinButton* spin, gdouble value ){
+void spin_button_set_value_no_signal( ui::SpinButton spin, gdouble value ){
guint handler_id = gpointer_to_int( g_object_get_data( G_OBJECT( spin ), "handler" ) );
g_signal_handler_block( G_OBJECT( gtk_spin_button_get_adjustment( spin ) ), handler_id );
gtk_spin_button_set_value( spin, value );
g_signal_handler_unblock( G_OBJECT( gtk_spin_button_get_adjustment( spin ) ), handler_id );
}
-void spin_button_set_step_increment( GtkSpinButton* spin, gdouble value ){
- GtkAdjustment* adjust = gtk_spin_button_get_adjustment( spin );
- adjust->step_increment = value;
+void spin_button_set_step_increment( ui::SpinButton spin, gdouble value ){
+ auto adjust = gtk_spin_button_get_adjustment( spin );
+ gtk_adjustment_set_step_increment(adjust, value);
}
void SurfaceInspector::Update(){
const char * name = SurfaceInspector_GetSelectedShader();
if ( shader_is_texture( name ) ) {
- gtk_entry_set_text( m_texture, shader_get_textureName( name ) );
+ m_texture.text(shader_get_textureName(name));
}
else
{
- gtk_entry_set_text( m_texture, "" );
+ m_texture.text("");
}
texdef_t shiftScaleRotate;
for ( GtkCheckButton** p = m_surfaceFlags; p != m_surfaceFlags + 32; ++p )
{
- toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) );
+ toggle_button_set_active_no_signal( ui::CheckButton::from( *p ), flags.m_surfaceFlags & ( 1 << ( p - m_surfaceFlags ) ) );
}
for ( GtkCheckButton** p = m_contentFlags; p != m_contentFlags + 32; ++p )
{
- toggle_button_set_active_no_signal( GTK_TOGGLE_BUTTON( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) );
+ toggle_button_set_active_no_signal( ui::CheckButton::from( *p ), flags.m_contentFlags & ( 1 << ( p - m_contentFlags ) ) );
}
}
}
void SurfaceInspector::ApplyTexdef(){
texdef_t shiftScaleRotate;
- shiftScaleRotate.shift[0] = static_cast<float>( gtk_spin_button_get_value_as_float( m_hshiftIncrement.m_spin ) );
- shiftScaleRotate.shift[1] = static_cast<float>( gtk_spin_button_get_value_as_float( m_vshiftIncrement.m_spin ) );
- shiftScaleRotate.scale[0] = static_cast<float>( gtk_spin_button_get_value_as_float( m_hscaleIncrement.m_spin ) );
- shiftScaleRotate.scale[1] = static_cast<float>( gtk_spin_button_get_value_as_float( m_vscaleIncrement.m_spin ) );
- shiftScaleRotate.rotate = static_cast<float>( gtk_spin_button_get_value_as_float( m_rotateIncrement.m_spin ) );
+ shiftScaleRotate.shift[0] = static_cast<float>( gtk_spin_button_get_value( m_hshiftIncrement.m_spin ) );
+ shiftScaleRotate.shift[1] = static_cast<float>( gtk_spin_button_get_value( m_vshiftIncrement.m_spin ) );
+ shiftScaleRotate.scale[0] = static_cast<float>( gtk_spin_button_get_value( m_hscaleIncrement.m_spin ) );
+ shiftScaleRotate.scale[1] = static_cast<float>( gtk_spin_button_get_value( m_vscaleIncrement.m_spin ) );
+ shiftScaleRotate.rotate = static_cast<float>( gtk_spin_button_get_value( m_rotateIncrement.m_spin ) );
TextureProjection projection;
//Shamus: This is the other place that screws up, it seems, since it doesn't seem to do the
face.GetTexdef( projection );
flags = face.getShader().m_flags;
}
-typedef Function4<Face&, CopiedString&, TextureProjection&, ContentsFlagsValue&, void, Face_getTexture> FaceGetTexture;
+typedef Function<void(Face&, CopiedString&, TextureProjection&, ContentsFlagsValue&), Face_getTexture> FaceGetTexture;
void Face_setTexture( Face& face, const char* shader, const TextureProjection& projection, const ContentsFlagsValue& flags ){
face.SetShader( shader );
face.SetTexdef( projection );
face.SetFlags( flags );
}
-typedef Function4<Face&, const char*, const TextureProjection&, const ContentsFlagsValue&, void, Face_setTexture> FaceSetTexture;
+typedef Function<void(Face&, const char*, const TextureProjection&, const ContentsFlagsValue&), Face_setTexture> FaceSetTexture;
void Patch_getTexture( Patch& patch, CopiedString& shader, TextureProjection& projection, ContentsFlagsValue& flags ){
projection = TextureProjection( texdef_t(), brushprimit_texdef_t(), Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ) );
flags = ContentsFlagsValue( 0, 0, 0, false );
}
-typedef Function4<Patch&, CopiedString&, TextureProjection&, ContentsFlagsValue&, void, Patch_getTexture> PatchGetTexture;
+typedef Function<void(Patch&, CopiedString&, TextureProjection&, ContentsFlagsValue&), Patch_getTexture> PatchGetTexture;
void Patch_setTexture( Patch& patch, const char* shader, const TextureProjection& projection, const ContentsFlagsValue& flags ){
patch.SetShader( shader );
}
-typedef Function4<Patch&, const char*, const TextureProjection&, const ContentsFlagsValue&, void, Patch_setTexture> PatchSetTexture;
+typedef Function<void(Patch&, const char*, const TextureProjection&, const ContentsFlagsValue&), Patch_setTexture> PatchSetTexture;
-typedef Callback3<CopiedString&, TextureProjection&, ContentsFlagsValue&> GetTextureCallback;
-typedef Callback3<const char*, const TextureProjection&, const ContentsFlagsValue&> SetTextureCallback;
+typedef Callback<void(CopiedString&, TextureProjection&, ContentsFlagsValue&)> GetTextureCallback;
+typedef Callback<void(const char*, const TextureProjection&, const ContentsFlagsValue&)> SetTextureCallback;
struct Texturable
{
if ( intersection.valid()
&& SelectionIntersection_closer( intersection, bestIntersection ) ) {
bestIntersection = intersection;
- texturable.setTexture = makeCallback3( FaceSetTexture(), face );
- texturable.getTexture = makeCallback3( FaceGetTexture(), face );
+ texturable.setTexture = makeCallback( FaceSetTexture(), face );
+ texturable.getTexture = makeCallback( FaceGetTexture(), face );
}
}
if ( occluded ) {
Patch* patch = Node_getPatch( path.top() );
if ( patch != 0 ) {
- m_texturable.setTexture = makeCallback3( PatchSetTexture(), *patch );
- m_texturable.getTexture = makeCallback3( PatchGetTexture(), *patch );
+ m_texturable.setTexture = makeCallback( PatchSetTexture(), *patch );
+ m_texturable.getTexture = makeCallback( PatchGetTexture(), *patch );
}
else
{
SurfaceInspector_constructPreferences( page );
}
void SurfaceInspector_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, SurfaceInspector_constructPage>() );
+ PreferencesDialog_addSettingsPage( makeCallbackF(SurfaceInspector_constructPage) );
}
void SurfaceInspector_registerCommands(){
- GlobalCommands_insert( "FitTexture", FreeCaller<SurfaceInspector_FitTexture>(), Accelerator( 'F', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "SurfaceInspector", FreeCaller<SurfaceInspector_toggleShown>(), Accelerator( 'S' ) );
+ GlobalCommands_insert( "FitTexture", makeCallbackF(SurfaceInspector_FitTexture), Accelerator( 'B', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "SurfaceInspector", makeCallbackF(SurfaceInspector_toggleShown), Accelerator( 'S' ) );
- GlobalCommands_insert( "FaceCopyTexture", FreeCaller<SelectedFaces_copyTexture>() );
- GlobalCommands_insert( "FacePasteTexture", FreeCaller<SelectedFaces_pasteTexture>() );
+ GlobalCommands_insert( "FaceCopyTexture", makeCallbackF(SelectedFaces_copyTexture) );
+ GlobalCommands_insert( "FacePasteTexture", makeCallbackF(SelectedFaces_pasteTexture) );
}
FaceTextureClipboard_setDefault();
- GlobalPreferenceSystem().registerPreference( "SurfaceWnd", getSurfaceInspector().m_importPosition, getSurfaceInspector().m_exportPosition );
- GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale1", FloatImportStringCaller( g_si_globals.scale[0] ), FloatExportStringCaller( g_si_globals.scale[0] ) );
- GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale2", FloatImportStringCaller( g_si_globals.scale[1] ), FloatExportStringCaller( g_si_globals.scale[1] ) );
- GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift1", FloatImportStringCaller( g_si_globals.shift[0] ), FloatExportStringCaller( g_si_globals.shift[0] ) );
- GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift2", FloatImportStringCaller( g_si_globals.shift[1] ), FloatExportStringCaller( g_si_globals.shift[1] ) );
- GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Rotate", FloatImportStringCaller( g_si_globals.rotate ), FloatExportStringCaller( g_si_globals.rotate ) );
- GlobalPreferenceSystem().registerPreference( "SnapTToGrid", BoolImportStringCaller( g_si_globals.m_bSnapTToGrid ), BoolExportStringCaller( g_si_globals.m_bSnapTToGrid ) );
+ GlobalPreferenceSystem().registerPreference( "SurfaceWnd", make_property<WindowPositionTracker_String>( getSurfaceInspector().m_positionTracker) );
+ GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale1", make_property_string( g_si_globals.scale[0] ) );
+ GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Scale2", make_property_string( g_si_globals.scale[1] ) );
+ GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift1", make_property_string( g_si_globals.shift[0] ) );
+ GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Shift2", make_property_string( g_si_globals.shift[1] ) );
+ GlobalPreferenceSystem().registerPreference( "SI_SurfaceTexdef_Rotate", make_property_string( g_si_globals.rotate ) );
+ GlobalPreferenceSystem().registerPreference( "SnapTToGrid", make_property_string( g_si_globals.m_bSnapTToGrid ) );
- typedef FreeCaller1<const Selectable&, SurfaceInspector_SelectionChanged> SurfaceInspectorSelectionChangedCaller;
+ typedef FreeCaller<void(const Selectable&), SurfaceInspector_SelectionChanged> SurfaceInspectorSelectionChangedCaller;
GlobalSelectionSystem().addSelectionChangeCallback( SurfaceInspectorSelectionChangedCaller() );
- typedef FreeCaller<SurfaceInspector_updateSelection> SurfaceInspectorUpdateSelectionCaller;
+ typedef FreeCaller<void(), SurfaceInspector_updateSelection> SurfaceInspectorUpdateSelectionCaller;
Brush_addTextureChangedCallback( SurfaceInspectorUpdateSelectionCaller() );
Patch_addTextureChangedCallback( SurfaceInspectorUpdateSelectionCaller() );
// << extents.maxX << ", " << extents.minY << ", " << extents.maxY << "\n";
}
-gboolean size_allocate( GtkWidget * win, GtkAllocation * a, gpointer ){
+gboolean size_allocate( ui::Widget win, GtkAllocation * a, gpointer ){
windowSize.x() = a->width;
windowSize.y() = a->height;
queueDraw();
return false;
}
-gboolean expose( GtkWidget * win, GdkEventExpose * e, gpointer ){
+gboolean expose( ui::Widget win, GdkEventExpose * e, gpointer ){
// globalOutputStream() << "--> Textool Window was exposed!\n";
// globalOutputStream() << " (window width/height: " << cc << "/" << e->area.height << ")\n";
Vector2 trans2;
Vector2 dragPoint; // Defined in terms of window space (+x/-y)
Vector2 oldTrans;
-gboolean button_press( GtkWidget * win, GdkEventButton * e, gpointer ){
+gboolean button_press( ui::Widget win, GdkEventButton * e, gpointer ){
// globalOutputStream() << "--> Textool button press...\n";
if ( e->button == 1 ) {
return false;
}
-gboolean button_release( GtkWidget * win, GdkEventButton * e, gpointer ){
+gboolean button_release( ui::Widget win, GdkEventButton * e, gpointer ){
// globalOutputStream() << "--> Textool button release...\n";
if ( e->button == 1 ) {
c[1] = ((float)(y))/((float)(m_rect.bottom-m_rect.top))*(m_Maxs[1]-m_Mins[1])+m_Mins[1];
}
*/
-gboolean motion( GtkWidget * win, GdkEventMotion * e, gpointer ){
+gboolean motion( ui::Widget win, GdkEventMotion * e, gpointer ){
// globalOutputStream() << "--> Textool motion...\n";
if ( lButtonDown ) {
//It seems the fake tex coords conversion is screwing this stuff up... !!! FIX !!!
//This is still wrong... Prolly need to do something with the oldScaleX/Y stuff...
-void flipX( GtkToggleButton *, gpointer ){
+void flipX( ui::ToggleButton, gpointer ){
// globalOutputStream() << "--> Flip X...\n";
//Shamus:
// SurfaceInspector_GetSelectedBPTexdef(); // Refresh g_selectedBrushPrimitTexdef...
UpdateControlPoints();
}
-void flipY( GtkToggleButton *, gpointer ){
+void flipY( ui::ToggleButton, gpointer ){
// globalOutputStream() << "--> Flip Y...\n";
// tm.coords[0][1] = -tm.coords[0][1];
// tm.coords[1][1] = -tm.coords[1][1];
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <uilib/uilib.h>
+
#if !defined( INCLUDED_SURFACEDIALOG_H )
#define INCLUDED_SURFACEDIALOG_H
void SurfaceInspector_Construct();
void SurfaceInspector_Destroy();
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-void SurfaceInspector_constructWindow( GtkWindow* widget );
+void SurfaceInspector_constructWindow( ui::Window widget );
void SurfaceInspector_destroyWindow();
bool SelectedFaces_empty();
*/
#include "textureentry.h"
+
+#include <gtk/gtk.h>
+
+template<class StringList>
+void EntryCompletion<StringList>::connect(ui::Entry entry)
+{
+ if (!m_store) {
+ m_store = ui::ListStore::from(gtk_list_store_new(1, G_TYPE_STRING));
+
+ fill();
+
+ StringList().connect(IdleDraw::QueueDrawCaller(m_idleUpdate));
+ }
+
+ auto completion = ui::EntryCompletion::from(gtk_entry_completion_new());
+ gtk_entry_set_completion(entry, completion);
+ gtk_entry_completion_set_model(completion, m_store);
+ gtk_entry_completion_set_text_column(completion, 0);
+}
+
+template<class StringList>
+void EntryCompletion<StringList>::append(const char *string)
+{
+ m_store.append(0, string);
+}
+
+template<class StringList>
+void EntryCompletion<StringList>::fill()
+{
+ StringList().forEach(AppendCaller(*this));
+}
+
+template<class StringList>
+void EntryCompletion<StringList>::clear()
+{
+ m_store.clear();
+}
+
+template<class StringList>
+void EntryCompletion<StringList>::update()
+{
+ clear();
+ fill();
+}
+
+template
+class EntryCompletion<TextureNameList>;
+
+template
+class EntryCompletion<ShaderList>;
#if !defined( INCLUDED_TEXTUREENTRY_H )
#define INCLUDED_TEXTUREENTRY_H
-
-#include <gtk/gtkentry.h>
-#include <gtk/gtkliststore.h>
#include "gtkutil/idledraw.h"
#include "generic/static.h"
#include "texwindow.h"
template<typename StringList>
-class EntryCompletion
-{
-GtkListStore* m_store;
-IdleDraw m_idleUpdate;
+class EntryCompletion {
+ ui::ListStore m_store;
+ IdleDraw m_idleUpdate;
public:
-EntryCompletion() : m_store( 0 ), m_idleUpdate( UpdateCaller( *this ) ){
-}
-
-void connect( GtkEntry* entry ){
- if ( m_store == 0 ) {
- m_store = gtk_list_store_new( 1, G_TYPE_STRING );
-
- fill();
-
- StringList().connect( IdleDraw::QueueDrawCaller( m_idleUpdate ) );
- }
-
- GtkEntryCompletion* completion = gtk_entry_completion_new();
- gtk_entry_set_completion( entry, completion );
- gtk_entry_completion_set_model( completion, GTK_TREE_MODEL( m_store ) );
- gtk_entry_completion_set_text_column( completion, 0 );
-}
-
-void append( const char* string ){
- GtkTreeIter iter;
- gtk_list_store_append( m_store, &iter );
- gtk_list_store_set( m_store, &iter, 0, string, -1 );
-}
-typedef MemberCaller1<EntryCompletion, const char*, &EntryCompletion::append> AppendCaller;
-
-void fill(){
- StringList().forEach( AppendCaller( *this ) );
-}
-
-void clear(){
- gtk_list_store_clear( m_store );
-}
-
-void update(){
- clear();
- fill();
-}
-typedef MemberCaller<EntryCompletion, &EntryCompletion::update> UpdateCaller;
+ EntryCompletion() : m_store(ui::null), m_idleUpdate(UpdateCaller(*this))
+ {
+ }
+
+ void connect(ui::Entry entry);
+
+ void append(const char *string);
+
+ using AppendCaller = MemberCaller<EntryCompletion, void(const char *), &EntryCompletion::append>;
+
+ void fill();
+
+ void clear();
+
+ void update();
+
+ using UpdateCaller = MemberCaller<EntryCompletion, void(), &EntryCompletion::update>;
};
-class TextureNameList
-{
+class TextureNameList {
public:
-void forEach( const ShaderNameCallback& callback ) const {
- for ( QERApp_ActiveShaders_IteratorBegin(); !QERApp_ActiveShaders_IteratorAtEnd(); QERApp_ActiveShaders_IteratorIncrement() )
- {
- IShader *shader = QERApp_ActiveShaders_IteratorCurrent();
-
- if ( shader_equal_prefix( shader->getName(), "textures/" ) ) {
- callback( shader->getName() + 9 );
- }
- }
-}
-void connect( const SignalHandler& update ) const {
- TextureBrowser_addActiveShadersChangedCallback( update );
-}
+ void forEach(const ShaderNameCallback &callback) const
+ {
+ for (QERApp_ActiveShaders_IteratorBegin(); !QERApp_ActiveShaders_IteratorAtEnd(); QERApp_ActiveShaders_IteratorIncrement()) {
+ IShader *shader = QERApp_ActiveShaders_IteratorCurrent();
+
+ if (shader_equal_prefix(shader->getName(), "textures/")) {
+ callback(shader->getName() + 9);
+ }
+ }
+ }
+
+ void connect(const SignalHandler &update) const
+ {
+ TextureBrowser_addActiveShadersChangedCallback(update);
+ }
};
-typedef Static< EntryCompletion<TextureNameList> > GlobalTextureEntryCompletion;
+typedef Static<EntryCompletion<TextureNameList> > GlobalTextureEntryCompletion;
-class ShaderList
-{
+class ShaderList {
public:
-void forEach( const ShaderNameCallback& callback ) const {
- GlobalShaderSystem().foreachShaderName( callback );
-}
-void connect( const SignalHandler& update ) const {
- TextureBrowser_addShadersRealiseCallback( update );
-}
+ void forEach(const ShaderNameCallback &callback) const
+ {
+ GlobalShaderSystem().foreachShaderName(callback);
+ }
+
+ void connect(const SignalHandler &update) const
+ {
+ TextureBrowser_addShadersRealiseCallback(update);
+ }
};
-typedef Static< EntryCompletion<ShaderList> > GlobalShaderEntryCompletion;
+typedef Static<EntryCompletion<ShaderList> > GlobalShaderEntryCompletion;
#endif
int max_tex_size = 0;
const int max_texture_quality = 3;
-LatchedInt g_Textures_textureQuality( 3, "Texture Quality" );
+LatchedValue<int> g_Textures_textureQuality( 3, "Texture Quality" );
/// \brief This function does the actual processing of raw RGBA data into a GL texture.
/// It will also resample to power-of-two dimensions, generate the mipmaps and adjust gamma.
std::size_t m_unrealised;
public:
+virtual ~TexturesMap() = default;
TexturesMap() : m_qtextures( TextureConstructor( this ) ), m_observer( 0 ), m_unrealised( 1 ){
}
typedef qtextures_t::iterator iterator;
}
-Callback g_texturesModeChangedNotify;
+Callback<void()> g_texturesModeChangedNotify;
-void Textures_setModeChangedNotify( const Callback& notify ){
+void Textures_setModeChangedNotify( const Callback<void()>& notify ){
g_texturesModeChangedNotify = notify;
}
Textures_setTextureComponents( texture_components );
}
-void TextureCompressionImport( TextureCompressionFormat& self, int value ){
- if ( !g_texture_globals.m_bOpenGLCompressionSupported
- && g_texture_globals.m_bS3CompressionSupported
- && value >= 1 ) {
- ++value;
- }
- switch ( value )
- {
- case 0:
- self = TEXTURECOMPRESSION_NONE;
- break;
- case 1:
- self = TEXTURECOMPRESSION_RGBA;
- break;
- case 2:
- self = TEXTURECOMPRESSION_RGBA_S3TC_DXT1;
- break;
- case 3:
- self = TEXTURECOMPRESSION_RGBA_S3TC_DXT3;
- break;
- case 4:
- self = TEXTURECOMPRESSION_RGBA_S3TC_DXT5;
- break;
- }
- Textures_UpdateTextureCompressionFormat();
-}
-typedef ReferenceCaller1<TextureCompressionFormat, int, TextureCompressionImport> TextureCompressionImportCaller;
+struct TextureCompression {
+ static void Export(const TextureCompressionFormat &self, const Callback<void(int)> &returnz) {
+ returnz(self);
+ }
+
+ static void Import(TextureCompressionFormat &self, int value) {
+ if (!g_texture_globals.m_bOpenGLCompressionSupported
+ && g_texture_globals.m_bS3CompressionSupported
+ && value >= 1) {
+ ++value;
+ }
+ switch (value) {
+ case 0:
+ self = TEXTURECOMPRESSION_NONE;
+ break;
+ case 1:
+ self = TEXTURECOMPRESSION_RGBA;
+ break;
+ case 2:
+ self = TEXTURECOMPRESSION_RGBA_S3TC_DXT1;
+ break;
+ case 3:
+ self = TEXTURECOMPRESSION_RGBA_S3TC_DXT3;
+ break;
+ case 4:
+ self = TEXTURECOMPRESSION_RGBA_S3TC_DXT5;
+ break;
+ }
+ Textures_UpdateTextureCompressionFormat();
+ }
+};
-void TextureGammaImport( float& self, float value ){
- if ( self != value ) {
- Textures_Unrealise();
- self = value;
- Textures_Realise();
+struct TextureGamma {
+ static void Export(const float &self, const Callback<void(float)> &returnz) {
+ returnz(self);
}
-}
-typedef ReferenceCaller1<float, float, TextureGammaImport> TextureGammaImportCaller;
-void TextureModeImport( ETexturesMode& self, int value ){
- switch ( value )
- {
- case 0:
- Textures_SetMode( eTextures_NEAREST );
- break;
- case 1:
- Textures_SetMode( eTextures_NEAREST_MIPMAP_NEAREST );
- break;
- case 2:
- Textures_SetMode( eTextures_LINEAR );
- break;
- case 3:
- Textures_SetMode( eTextures_NEAREST_MIPMAP_LINEAR );
- break;
- case 4:
- Textures_SetMode( eTextures_LINEAR_MIPMAP_NEAREST );
- break;
- case 5:
- Textures_SetMode( eTextures_LINEAR_MIPMAP_LINEAR );
- break;
- case 6:
- Textures_SetMode( eTextures_MAX_ANISOTROPY );
+ static void Import(float &self, float value) {
+ if (value != self) {
+ Textures_Unrealise();
+ self = value;
+ Textures_Realise();
+ }
}
-}
-typedef ReferenceCaller1<ETexturesMode, int, TextureModeImport> TextureModeImportCaller;
+};
-void TextureModeExport( ETexturesMode& self, const IntImportCallback& importer ){
- switch ( self )
- {
- case eTextures_NEAREST:
- importer( 0 );
- break;
- case eTextures_NEAREST_MIPMAP_NEAREST:
- importer( 1 );
- break;
- case eTextures_LINEAR:
- importer( 2 );
- break;
- case eTextures_NEAREST_MIPMAP_LINEAR:
- importer( 3 );
- break;
- case eTextures_LINEAR_MIPMAP_NEAREST:
- importer( 4 );
- break;
- case eTextures_LINEAR_MIPMAP_LINEAR:
- importer( 5 );
- break;
- case eTextures_MAX_ANISOTROPY:
- importer( 6 );
- break;
- default:
- importer( 4 );
- }
-}
-typedef ReferenceCaller1<ETexturesMode, const IntImportCallback&, TextureModeExport> TextureModeExportCaller;
+struct TextureMode {
+ static void Export(const ETexturesMode &self, const Callback<void(int)> &returnz) {
+ switch (self) {
+ case eTextures_NEAREST:
+ returnz(0);
+ break;
+ case eTextures_NEAREST_MIPMAP_NEAREST:
+ returnz(1);
+ break;
+ case eTextures_LINEAR:
+ returnz(2);
+ break;
+ case eTextures_NEAREST_MIPMAP_LINEAR:
+ returnz(3);
+ break;
+ case eTextures_LINEAR_MIPMAP_NEAREST:
+ returnz(4);
+ break;
+ case eTextures_LINEAR_MIPMAP_LINEAR:
+ returnz(5);
+ break;
+ case eTextures_MAX_ANISOTROPY:
+ returnz(6);
+ break;
+ default:
+ returnz(4);
+ }
+ }
+
+ static void Import(ETexturesMode &self, int value) {
+ switch (value) {
+ case 0:
+ Textures_SetMode(eTextures_NEAREST);
+ break;
+ case 1:
+ Textures_SetMode(eTextures_NEAREST_MIPMAP_NEAREST);
+ break;
+ case 2:
+ Textures_SetMode(eTextures_LINEAR);
+ break;
+ case 3:
+ Textures_SetMode(eTextures_NEAREST_MIPMAP_LINEAR);
+ break;
+ case 4:
+ Textures_SetMode(eTextures_LINEAR_MIPMAP_NEAREST);
+ break;
+ case 5:
+ Textures_SetMode(eTextures_LINEAR_MIPMAP_LINEAR);
+ break;
+ case 6:
+ Textures_SetMode(eTextures_MAX_ANISOTROPY);
+ }
+ }
+};
void Textures_constructPreferences( PreferencesPage& page ){
{
page.appendRadio(
"Texture Quality",
STRING_ARRAY_RANGE( percentages ),
- LatchedIntImportCaller( g_Textures_textureQuality ),
- IntExportCaller( g_Textures_textureQuality.m_latched )
+ make_property( g_Textures_textureQuality )
);
}
page.appendSpinner(
1.0,
0.0,
1.0,
- FloatImportCallback( TextureGammaImportCaller( g_texture_globals.fGamma ) ),
- FloatExportCallback( FloatExportCaller( g_texture_globals.fGamma ) )
+ make_property<TextureGamma>(g_texture_globals.fGamma)
);
{
const char* texture_mode[] = { "Nearest", "Nearest Mipmap", "Linear", "Bilinear", "Bilinear Mipmap", "Trilinear", "Anisotropy" };
page.appendCombo(
"Texture Render Mode",
STRING_ARRAY_RANGE( texture_mode ),
- IntImportCallback( TextureModeImportCaller( g_texture_mode ) ),
- IntExportCallback( TextureModeExportCaller( g_texture_mode ) )
+ make_property<TextureMode>(g_texture_mode)
);
}
{
page.appendCombo(
"Hardware Texture Compression",
compression,
- TextureCompressionImportCaller( g_texture_globals.m_nTextureCompressionFormat ),
- IntExportCaller( reinterpret_cast<int&>( g_texture_globals.m_nTextureCompressionFormat ) )
+ make_property<TextureCompression>(g_texture_globals.m_nTextureCompressionFormat)
);
}
}
Textures_constructPreferences( page );
}
void Textures_registerPreferencesPage(){
- PreferencesDialog_addDisplayPage( FreeCaller1<PreferenceGroup&, Textures_constructPage>() );
+ PreferencesDialog_addDisplayPage( makeCallbackF(Textures_constructPage) );
}
-void TextureCompression_importString( const char* string ){
- g_texture_globals.m_nTextureCompressionFormat = static_cast<TextureCompressionFormat>( atoi( string ) );
- Textures_UpdateTextureCompressionFormat();
-}
-typedef FreeCaller1<const char*, TextureCompression_importString> TextureCompressionImportStringCaller;
+struct TextureCompressionPreference {
+ static void Export(const Callback<void(int)> &returnz) {
+ returnz(g_texture_globals.m_nTextureCompressionFormat);
+ }
+ static void Import(int value) {
+ g_texture_globals.m_nTextureCompressionFormat = static_cast<TextureCompressionFormat>( value );
+ Textures_UpdateTextureCompressionFormat();
+ }
+};
void Textures_Construct(){
g_texturesmap = new TexturesMap;
- GlobalPreferenceSystem().registerPreference( "TextureCompressionFormat", TextureCompressionImportStringCaller(), IntExportStringCaller( reinterpret_cast<int&>( g_texture_globals.m_nTextureCompressionFormat ) ) );
- GlobalPreferenceSystem().registerPreference( "TextureFiltering", IntImportStringCaller( reinterpret_cast<int&>( g_texture_mode ) ), IntExportStringCaller( reinterpret_cast<int&>( g_texture_mode ) ) );
- GlobalPreferenceSystem().registerPreference( "TextureQuality", IntImportStringCaller( g_Textures_textureQuality.m_latched ), IntExportStringCaller( g_Textures_textureQuality.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "SI_Gamma", FloatImportStringCaller( g_texture_globals.fGamma ), FloatExportStringCaller( g_texture_globals.fGamma ) );
+ GlobalPreferenceSystem().registerPreference( "TextureCompressionFormat", make_property_string<TextureCompressionPreference>() );
+ GlobalPreferenceSystem().registerPreference( "TextureFiltering", make_property_string( reinterpret_cast<int&>( g_texture_mode ) ) );
+ GlobalPreferenceSystem().registerPreference( "TextureQuality", make_property_string( g_Textures_textureQuality.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Gamma", make_property_string( g_texture_globals.fGamma ) );
g_Textures_textureQuality.useLatched();
#if !defined ( INCLUDED_TEXTURES_H )
#define INCLUDED_TEXTURES_H
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
void Textures_Realise();
void Textures_Unrealise();
void Textures_sharedContextDestroyed();
-void Textures_setModeChangedNotify( const Callback& notify );
+void Textures_setModeChangedNotify( const Callback<void()>& notify );
#endif
#include "texwindow.h"
+#include <gtk/gtk.h>
+
#include "debugging/debugging.h"
#include "warnings.h"
+#include "defaults.h"
#include "ifilesystem.h"
#include "iundo.h"
#include "igl.h"
#include <string>
#include <vector>
-#include <gtk/gtk.h>
-#include <gtk/gtkrange.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkvscrollbar.h>
+#include <uilib/uilib.h>
#include "signal/signal.h"
#include "math/vector.h"
#endif
}
}
-typedef ReferenceCaller1<TextureGroups, const char*, TextureGroups_addWad> TextureGroupsAddWadCaller;
+
+typedef ReferenceCaller<TextureGroups, void(const char*), TextureGroups_addWad> TextureGroupsAddWadCaller;
+
+namespace
+{
+bool g_TextureBrowser_shaderlistOnly = false;
+bool g_TextureBrowser_fixedSize = true;
+bool g_TextureBrowser_filterMissing = false;
+bool g_TextureBrowser_filterFallback = true;
+bool g_TextureBrowser_enableAlpha = false;
+}
+
+CopiedString g_notex;
+CopiedString g_shadernotex;
+
+bool isMissing(const char* name);
+
+bool isNotex(const char* name);
+
+bool isMissing(const char* name){
+ if ( string_equal( g_notex.c_str(), name ) ) {
+ return true;
+ }
+ if ( string_equal( g_shadernotex.c_str(), name ) ) {
+ return true;
+ }
+ return false;
+}
+
+bool isNotex(const char* name){
+ if ( string_equal_suffix( name, "/" DEFAULT_NOTEX_BASENAME ) ) {
+ return true;
+ }
+ if ( string_equal_suffix( name, "/" DEFAULT_SHADERNOTEX_BASENAME ) ) {
+ return true;
+ }
+ return false;
+}
void TextureGroups_addShader( TextureGroups& groups, const char* shaderName ){
const char* texture = path_make_relative( shaderName, "textures/" );
+
+ // hide notex / shadernotex images
+ if ( g_TextureBrowser_filterFallback ) {
+ if ( isNotex( shaderName ) ) {
+ return;
+ }
+ if ( isNotex( texture ) ) {
+ return;
+ }
+ }
+
if ( texture != shaderName ) {
const char* last = path_remove_directory( texture );
if ( !string_empty( last ) ) {
}
}
}
-typedef ReferenceCaller1<TextureGroups, const char*, TextureGroups_addShader> TextureGroupsAddShaderCaller;
+
+typedef ReferenceCaller<TextureGroups, void(const char*), TextureGroups_addShader> TextureGroupsAddShaderCaller;
void TextureGroups_addDirectory( TextureGroups& groups, const char* directory ){
groups.insert( directory );
}
-typedef ReferenceCaller1<TextureGroups, const char*, TextureGroups_addDirectory> TextureGroupsAddDirectoryCaller;
-namespace
-{
-bool g_TextureBrowser_shaderlistOnly = false;
-bool g_TextureBrowser_fixedSize = true;
-bool g_TextureBrowser_filterNotex = false;
-bool g_TextureBrowser_enableAlpha = false;
-}
+typedef ReferenceCaller<TextureGroups, void(const char*), TextureGroups_addDirectory> TextureGroupsAddDirectoryCaller;
class DeferredAdjustment
{
gdouble m_value;
guint m_handler;
+
typedef void ( *ValueChangedFunction )( void* data, gdouble value );
+
ValueChangedFunction m_function;
void* m_data;
reinterpret_cast<DeferredAdjustment*>( data )->m_value = 0;
return FALSE;
}
+
public:
DeferredAdjustment( ValueChangedFunction function, void* data ) : m_value( 0 ), m_handler( 0 ), m_function( function ), m_data( data ){
}
+
void flush(){
if ( m_handler != 0 ) {
g_source_remove( m_handler );
deferred_value_changed( this );
}
}
+
void value_changed( gdouble value ){
m_value = value;
if ( m_handler == 0 ) {
m_handler = g_idle_add( deferred_value_changed, this );
}
}
-static void adjustment_value_changed( GtkAdjustment *adjustment, DeferredAdjustment* self ){
- self->value_changed( adjustment->value );
+
+static void adjustment_value_changed(ui::Adjustment adjustment, DeferredAdjustment* self ){
+ self->value_changed( gtk_adjustment_get_value(adjustment) );
}
};
-
class TextureBrowser;
-typedef ReferenceCaller<TextureBrowser, TextureBrowser_queueDraw> TextureBrowserQueueDrawCaller;
+typedef ReferenceCaller<TextureBrowser, void(), TextureBrowser_queueDraw> TextureBrowserQueueDrawCaller;
void TextureBrowser_scrollChanged( void* data, gdouble value );
STARTUPSHADERS_COMMON,
};
-void TextureBrowser_hideUnusedExport( const BoolImportCallback& importer );
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
+void TextureBrowser_hideUnusedExport( const Callback<void(bool)> & importer );
+
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
+
+void TextureBrowser_showShadersExport( const Callback<void(bool)> & importer );
+
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
+
+void TextureBrowser_showTexturesExport( const Callback<void(bool)> & importer );
+
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_showTexturesExport> TextureBrowserShowTexturesExport;
+
+void TextureBrowser_showShaderlistOnly( const Callback<void(bool)> & importer );
+
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
+
+void TextureBrowser_fixedSize( const Callback<void(bool)> & importer );
-void TextureBrowser_showShadersExport( const BoolImportCallback& importer );
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_fixedSize> TextureBrowserFixedSizeExport;
-void TextureBrowser_showTexturesExport( const BoolImportCallback& importer );
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_showTexturesExport> TextureBrowserShowTexturesExport;
+void TextureBrowser_filterMissing( const Callback<void(bool)> & importer );
-void TextureBrowser_showShaderlistOnly( const BoolImportCallback& importer );
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_filterMissing> TextureBrowserFilterMissingExport;
-void TextureBrowser_fixedSize( const BoolImportCallback& importer );
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_fixedSize> TextureBrowserFixedSizeExport;
+void TextureBrowser_filterFallback( const Callback<void(bool)> & importer );
-void TextureBrowser_filterNotex( const BoolImportCallback& importer );
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterNotex> TextureBrowserFilterNotexExport;
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_filterFallback> TextureBrowserFilterFallbackExport;
-void TextureBrowser_enableAlpha( const BoolImportCallback& importer );
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_enableAlpha> TextureBrowserEnableAlphaExport;
+void TextureBrowser_enableAlpha( const Callback<void(bool)> & importer );
+
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_enableAlpha> TextureBrowserEnableAlphaExport;
class TextureBrowser
{
CopiedString shader;
-GtkWindow* m_parent;
-GtkWidget* m_gl_widget;
-GtkWidget* m_texture_scroll;
-GtkWidget* m_treeViewTree;
-GtkWidget* m_treeViewTags;
-GtkWidget* m_tag_frame;
-GtkListStore* m_assigned_store;
-GtkListStore* m_available_store;
-GtkWidget* m_assigned_tree;
-GtkWidget* m_available_tree;
-GtkWidget* m_scr_win_tree;
-GtkWidget* m_scr_win_tags;
-GtkWidget* m_tag_notebook;
-GtkWidget* m_search_button;
-GtkWidget* m_shader_info_item;
+ui::Window m_parent{ui::null};
+ui::GLArea m_gl_widget{ui::null};
+ui::Widget m_texture_scroll{ui::null};
+ui::TreeView m_treeViewTree{ui::New};
+ui::TreeView m_treeViewTags{ui::null};
+ui::Frame m_tag_frame{ui::null};
+ui::ListStore m_assigned_store{ui::null};
+ui::ListStore m_available_store{ui::null};
+ui::TreeView m_assigned_tree{ui::null};
+ui::TreeView m_available_tree{ui::null};
+ui::Widget m_scr_win_tree{ui::null};
+ui::Widget m_scr_win_tags{ui::null};
+ui::Widget m_tag_notebook{ui::null};
+ui::Button m_search_button{ui::null};
+ui::Widget m_shader_info_item{ui::null};
std::set<CopiedString> m_all_tags;
-GtkListStore* m_all_tags_list;
+ui::ListStore m_all_tags_list{ui::null};
std::vector<CopiedString> m_copied_tags;
std::set<CopiedString> m_found_shaders;
ToggleItem m_hideunused_item;
+ToggleItem m_hidenotex_item;
ToggleItem m_showshaders_item;
ToggleItem m_showtextures_item;
ToggleItem m_showshaderlistonly_item;
}
TextureBrowser() :
- m_texture_scroll( 0 ),
+ m_texture_scroll( ui::null ),
m_hideunused_item( TextureBrowserHideUnusedExport() ),
+ m_hidenotex_item( TextureBrowserFilterFallbackExport() ),
m_showshaders_item( TextureBrowserShowShadersExport() ),
m_showtextures_item( TextureBrowserShowTexturesExport() ),
m_showshaderlistonly_item( TextureBrowserShowShaderlistOnlyExport() ),
m_fixedsize_item( TextureBrowserFixedSizeExport() ),
- m_filternotex_item( TextureBrowserFilterNotexExport() ),
+ m_filternotex_item( TextureBrowserFilterMissingExport() ),
m_enablealpha_item( TextureBrowserEnableAlphaExport() ),
m_heightChanged( true ),
m_originInvalid( true ),
}
}
-CopiedString g_notex;
-CopiedString g_shadernotex;
-
// if texture_showinuse jump over non in-use textures
bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bool hideUnused, bool hideNonShadersInCommon ){
- // filter notex / shadernotex images
- if ( g_TextureBrowser_filterNotex && ( string_equal( g_notex.c_str(), shader->getTexture()->name ) || string_equal( g_shadernotex.c_str(), shader->getTexture()->name ) ) ) {
- return false;
+ // filter missing shaders
+ // ugly: filter on built-in fallback name after substitution
+ if ( g_TextureBrowser_filterMissing ) {
+ if ( isMissing( shader->getTexture()->name ) ) {
+ return false;
+ }
+ }
+ // filter the fallback (notex/shadernotex) for missing shaders or editor image
+ if ( g_TextureBrowser_filterFallback ) {
+ if ( isNotex( shader->getName() ) ) {
+ return false;
+ }
+ if ( isNotex( shader->getTexture()->name ) ) {
+ return false;
+ }
}
if ( g_TextureBrowser_currentDirectory == "Untagged" ) {
/* texturebrowser tree update on vfs restart */
// TextureBrowser_constructTreeStore();
}
+
void unrealise(){
}
+
void insert( const SignalHandler& handler ){
m_realiseCallbacks.connectLast( handler );
}
g_activeShadersChangedCallbacks();
}
-void TextureBrowser_importShowScrollbar( TextureBrowser& textureBrowser, bool value ){
- textureBrowser.m_showTextureScrollbar = value;
- if ( textureBrowser.m_texture_scroll != 0 ) {
- widget_set_visible( textureBrowser.m_texture_scroll, textureBrowser.m_showTextureScrollbar );
- TextureBrowser_updateScroll( textureBrowser );
+struct TextureBrowser_ShowScrollbar {
+ static void Export(const TextureBrowser &self, const Callback<void(bool)> &returnz) {
+ returnz(self.m_showTextureScrollbar);
}
-}
-typedef ReferenceCaller1<TextureBrowser, bool, TextureBrowser_importShowScrollbar> TextureBrowserImportShowScrollbarCaller;
+
+ static void Import(TextureBrowser &self, bool value) {
+ self.m_showTextureScrollbar = value;
+ if (self.m_texture_scroll) {
+ self.m_texture_scroll.visible(self.m_showTextureScrollbar);
+ TextureBrowser_updateScroll(self);
+ }
+ }
+};
/*
endswith( strTemp.c_str(), ".diffuse" ) ||
endswith( strTemp.c_str(), ".blend" ) ||
endswith( strTemp.c_str(), ".alpha" ) ||
- endswith( strTemp.c_str(), "_norm" ) ||
+ endswith( strTemp.c_str(), "_alpha" ) ||
+ /* Quetoo */
+ endswith( strTemp.c_str(), "_h" ) ||
+ endswith( strTemp.c_str(), "_local" ) ||
+ endswith( strTemp.c_str(), "_nm" ) ||
+ endswith( strTemp.c_str(), "_s" ) ||
+ /* DarkPlaces */
endswith( strTemp.c_str(), "_bump" ) ||
endswith( strTemp.c_str(), "_glow" ) ||
endswith( strTemp.c_str(), "_gloss" ) ||
+ endswith( strTemp.c_str(), "_luma" ) ||
+ endswith( strTemp.c_str(), "_norm" ) ||
endswith( strTemp.c_str(), "_pants" ) ||
endswith( strTemp.c_str(), "_shirt" ) ||
endswith( strTemp.c_str(), "_reflect" ) ||
- endswith( strTemp.c_str(), "_alpha" ) ||
+ /* Unvanquished */
+ endswith( strTemp.c_str(), "_d" ) ||
+ endswith( strTemp.c_str(), "_n" ) ||
+ endswith( strTemp.c_str(), "_p" ) ||
+ endswith( strTemp.c_str(), "_g" ) ||
+ endswith( strTemp.c_str(), "_a" ) ||
0;
}
void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused );
-GtkWidget* g_page_textures;
+ui::Widget g_page_textures{ui::null};
void TextureBrowser_toggleShow(){
GroupDialog_showPage( g_page_textures );
}
-
class TextureCategoryLoadShader
{
const char* m_directory;
std::size_t& m_count;
public:
-typedef const char* first_argument_type;
+using func = void(const char *);
TextureCategoryLoadShader( const char* directory, std::size_t& count )
: m_directory( directory ), m_count( count ){
m_count = 0;
}
+
void operator()( const char* name ) const {
if ( shader_equal_prefix( name, "textures/" )
&& shader_equal_prefix( name + string_length( "textures/" ), m_directory ) ) {
IShader* shader = QERApp_Shader_ForName( name.c_str() );
shader->DecRef();
}
-typedef ConstPointerCaller1<char, const char*, TextureDirectory_loadTexture> TextureDirectoryLoadTextureCaller;
+
+typedef ConstPointerCaller<char, void(const char*), TextureDirectory_loadTexture> TextureDirectoryLoadTextureCaller;
class LoadTexturesByTypeVisitor : public ImageModules::Visitor
{
LoadTexturesByTypeVisitor( const char* dirstring )
: m_dirstring( dirstring ){
}
+
void visit( const char* minor, const _QERPlugImageTable& table ) const {
GlobalFileSystem().forEachFile( m_dirstring, minor, TextureDirectoryLoadTextureCaller( m_dirstring ) );
}
TextureBrowser_heightChanged( textureBrowser );
std::size_t shaders_count;
- GlobalShaderSystem().foreachShaderName( makeCallback1( TextureCategoryLoadShader( directory, shaders_count ) ) );
+ GlobalShaderSystem().foreachShaderName(makeCallback( TextureCategoryLoadShader( directory, shaders_count ) ) );
globalOutputStream() << "Showing " << Unsigned( shaders_count ) << " shaders.\n";
if ( g_pGameDescription->mGameType != "doom3" ) {
TextureBrowser_heightChanged( textureBrowser );
std::size_t shaders_count;
- GlobalShaderSystem().foreachShaderName( makeCallback1( TextureCategoryLoadShader( directory, shaders_count ) ) );
+ GlobalShaderSystem().foreachShaderName(makeCallback( TextureCategoryLoadShader( directory, shaders_count ) ) );
globalOutputStream() << "Showing " << Unsigned( shaders_count ) << " shaders.\n";
if ( g_pGameDescription->mGameType != "doom3" ) {
bool TextureBrowser_hideUnused();
-void TextureBrowser_hideUnusedExport( const BoolImportCallback& importer ){
+void TextureBrowser_hideUnusedExport( const Callback<void(bool)> & importer ){
importer( TextureBrowser_hideUnused() );
}
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
-void TextureBrowser_showShadersExport( const BoolImportCallback& importer ){
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
+
+void TextureBrowser_showShadersExport( const Callback<void(bool)> & importer ){
importer( GlobalTextureBrowser().m_showShaders );
}
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
-void TextureBrowser_showTexturesExport( const BoolImportCallback& importer ){
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
+
+void TextureBrowser_showTexturesExport( const Callback<void(bool)> & importer ){
importer( GlobalTextureBrowser().m_showTextures );
}
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_showTexturesExport> TextureBrowserShowTexturesExport;
-void TextureBrowser_showShaderlistOnly( const BoolImportCallback& importer ){
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_showTexturesExport> TextureBrowserShowTexturesExport;
+
+void TextureBrowser_showShaderlistOnly( const Callback<void(bool)> & importer ){
importer( g_TextureBrowser_shaderlistOnly );
}
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
-void TextureBrowser_fixedSize( const BoolImportCallback& importer ){
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
+
+void TextureBrowser_fixedSize( const Callback<void(bool)> & importer ){
importer( g_TextureBrowser_fixedSize );
}
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_fixedSize> TextureBrowser_FixedSizeExport;
-void TextureBrowser_filterNotex( const BoolImportCallback& importer ){
- importer( g_TextureBrowser_filterNotex );
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_fixedSize> TextureBrowser_FixedSizeExport;
+
+void TextureBrowser_filterMissing( const Callback<void(bool)> & importer ){
+ importer( g_TextureBrowser_filterMissing );
}
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterNotex> TextureBrowser_filterNotexExport;
-void TextureBrowser_enableAlpha( const BoolImportCallback& importer ){
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_filterMissing> TextureBrowser_filterMissingExport;
+
+void TextureBrowser_filterFallback( const Callback<void(bool)> & importer ){
+ importer( g_TextureBrowser_filterFallback );
+}
+
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_filterFallback> TextureBrowser_filterFallbackExport;
+
+void TextureBrowser_enableAlpha( const Callback<void(bool)> & importer ){
importer( g_TextureBrowser_enableAlpha );
}
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport;
+
+typedef FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_enableAlpha> TextureBrowser_enableAlphaExport;
void TextureBrowser_SetHideUnused( TextureBrowser& textureBrowser, bool hideUnused ){
textureBrowser.m_hideUnused = hideUnused;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glDisable( GL_DEPTH_TEST );
+
//glDisable( GL_BLEND );
if ( g_TextureBrowser_enableAlpha ) {
glEnable( GL_BLEND );
}
void TextureBrowser_queueDraw( TextureBrowser& textureBrowser ){
- if ( textureBrowser.m_gl_widget != 0 ) {
+ if ( textureBrowser.m_gl_widget ) {
gtk_widget_queue_draw( textureBrowser.m_gl_widget );
}
}
N_COLUMNS
};
-void BuildStoreAssignedTags( GtkListStore* store, const char* shader, TextureBrowser* textureBrowser ){
+void BuildStoreAssignedTags( ui::ListStore store, const char* shader, TextureBrowser* textureBrowser ){
GtkTreeIter iter;
- gtk_list_store_clear( store );
+ store.clear();
std::vector<CopiedString> assigned_tags;
TagBuilder.GetShaderTags( shader, assigned_tags );
for ( size_t i = 0; i < assigned_tags.size(); i++ )
{
- gtk_list_store_append( store, &iter );
- gtk_list_store_set( store, &iter, TAG_COLUMN, assigned_tags[i].c_str(), -1 );
+ store.append(TAG_COLUMN, assigned_tags[i].c_str());
}
}
-void BuildStoreAvailableTags( GtkListStore* storeAvailable,
- GtkListStore* storeAssigned,
+void BuildStoreAvailableTags( ui::ListStore storeAvailable,
+ ui::ListStore storeAssigned,
const std::set<CopiedString>& allTags,
TextureBrowser* textureBrowser ){
GtkTreeIter iterAssigned;
std::set<CopiedString>::const_iterator iterAll;
gchar* tag_assigned;
- gtk_list_store_clear( storeAvailable );
+ storeAvailable.clear();
- bool row = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( storeAssigned ), &iterAssigned ) != 0;
+ bool row = gtk_tree_model_get_iter_first(storeAssigned, &iterAssigned ) != 0;
if ( !row ) { // does the shader have tags assigned?
for ( iterAll = allTags.begin(); iterAll != allTags.end(); ++iterAll )
{
- gtk_list_store_append( storeAvailable, &iterAvailable );
- gtk_list_store_set( storeAvailable, &iterAvailable, TAG_COLUMN, ( *iterAll ).c_str(), -1 );
+ storeAvailable.append(TAG_COLUMN, (*iterAll).c_str());
}
}
else
{
while ( row ) // available tags = all tags - assigned tags
{
- gtk_tree_model_get( GTK_TREE_MODEL( storeAssigned ), &iterAssigned, TAG_COLUMN, &tag_assigned, -1 );
+ gtk_tree_model_get(storeAssigned, &iterAssigned, TAG_COLUMN, &tag_assigned, -1 );
for ( iterAll = allTags.begin(); iterAll != allTags.end(); ++iterAll )
{
if ( strcmp( (char*)tag_assigned, ( *iterAll ).c_str() ) != 0 ) {
- gtk_list_store_append( storeAvailable, &iterAvailable );
- gtk_list_store_set( storeAvailable, &iterAvailable, TAG_COLUMN, ( *iterAll ).c_str(), -1 );
+ storeAvailable.append(TAG_COLUMN, (*iterAll).c_str());
}
else
{
- row = gtk_tree_model_iter_next( GTK_TREE_MODEL( storeAssigned ), &iterAssigned ) != 0;
+ row = gtk_tree_model_iter_next(storeAssigned, &iterAssigned ) != 0;
if ( row ) {
- gtk_tree_model_get( GTK_TREE_MODEL( storeAssigned ), &iterAssigned, TAG_COLUMN, &tag_assigned, -1 );
+ gtk_tree_model_get(storeAssigned, &iterAssigned, TAG_COLUMN, &tag_assigned, -1 );
}
}
}
}
}
-gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_button_press( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){
if ( event->type == GDK_BUTTON_PRESS ) {
if ( event->button == 3 ) {
if ( GlobalTextureBrowser().m_tags ) {
BuildStoreAssignedTags( textureBrowser->m_assigned_store, textureBrowser->shader.c_str(), textureBrowser );
BuildStoreAvailableTags( textureBrowser->m_available_store, textureBrowser->m_assigned_store, textureBrowser->m_all_tags, textureBrowser );
textureBrowser->m_heightChanged = true;
- gtk_widget_show( textureBrowser->m_tag_frame );
+ textureBrowser->m_tag_frame.show();
- process_gui();
+ ui::process();
TextureBrowser_Focus( *textureBrowser, textureBrowser->shader.c_str() );
}
if ( GlobalTextureBrowser().m_tags ) {
textureBrowser->m_rmbSelected = false;
- gtk_widget_hide( textureBrowser->m_tag_frame );
+ textureBrowser->m_tag_frame.hide();
}
}
}
else if ( event->type == GDK_2BUTTON_PRESS && event->button == 1 ) {
+ #define GARUX_DISABLE_2BUTTON
+ #ifndef GARUX_DISABLE_2BUTTON
CopiedString texName = textureBrowser->shader;
//const char* sh = texName.c_str();
char* sh = const_cast<char*>( texName.c_str() );
}
}
}
+ #endif
}
else if ( event->type == GDK_2BUTTON_PRESS && event->button == 3 ) {
ScopeDisableScreenUpdates disableScreenUpdates( TextureBrowser_getComonShadersDir(), "Loading Textures" );
return FALSE;
}
-gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_button_release( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){
if ( event->type == GDK_BUTTON_RELEASE ) {
if ( event->button == 3 ) {
if ( !GlobalTextureBrowser().m_tags ) {
return FALSE;
}
-gboolean TextureBrowser_motion( GtkWidget *widget, GdkEventMotion *event, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_motion( ui::Widget widget, GdkEventMotion *event, TextureBrowser* textureBrowser ){
return FALSE;
}
-gboolean TextureBrowser_scroll( GtkWidget* widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_scroll( ui::Widget widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){
if ( event->direction == GDK_SCROLL_UP ) {
TextureBrowser_MouseWheel( *textureBrowser, true );
}
TextureBrowser_setOriginY( *reinterpret_cast<TextureBrowser*>( data ), -(int)value );
}
-static void TextureBrowser_verticalScroll( GtkAdjustment *adjustment, TextureBrowser* textureBrowser ){
- textureBrowser->m_scrollAdjustment.value_changed( adjustment->value );
+static void TextureBrowser_verticalScroll(ui::Adjustment adjustment, TextureBrowser* textureBrowser ){
+ textureBrowser->m_scrollAdjustment.value_changed( gtk_adjustment_get_value(adjustment) );
}
void TextureBrowser_updateScroll( TextureBrowser& textureBrowser ){
totalHeight = std::max( totalHeight, textureBrowser.height );
- GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( textureBrowser.m_texture_scroll ) );
+ auto vadjustment = gtk_range_get_adjustment( GTK_RANGE( textureBrowser.m_texture_scroll ) );
- vadjustment->value = -TextureBrowser_getOriginY( textureBrowser );
- vadjustment->page_size = textureBrowser.height;
- vadjustment->page_increment = textureBrowser.height / 2;
- vadjustment->step_increment = 20;
- vadjustment->lower = 0;
- vadjustment->upper = totalHeight;
+ gtk_adjustment_set_value(vadjustment, -TextureBrowser_getOriginY( textureBrowser ));
+ gtk_adjustment_set_page_size(vadjustment, textureBrowser.height);
+ gtk_adjustment_set_page_increment(vadjustment, textureBrowser.height / 2);
+ gtk_adjustment_set_step_increment(vadjustment, 20);
+ gtk_adjustment_set_lower(vadjustment, 0);
+ gtk_adjustment_set_upper(vadjustment, totalHeight);
g_signal_emit_by_name( G_OBJECT( vadjustment ), "changed" );
}
}
-gboolean TextureBrowser_size_allocate( GtkWidget* widget, GtkAllocation* allocation, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_size_allocate( ui::Widget widget, GtkAllocation* allocation, TextureBrowser* textureBrowser ){
textureBrowser->width = allocation->width;
textureBrowser->height = allocation->height;
TextureBrowser_heightChanged( *textureBrowser );
return FALSE;
}
-gboolean TextureBrowser_expose( GtkWidget* widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){
+gboolean TextureBrowser_expose( ui::Widget widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){
if ( glwidget_make_current( textureBrowser->m_gl_widget ) != FALSE ) {
GlobalOpenGL_debugAssertNoErrors();
TextureBrowser_evaluateHeight( *textureBrowser );
}
}
-void TextureGroups_constructTreeModel( TextureGroups groups, GtkTreeStore* store ){
+void TextureGroups_constructTreeModel( TextureGroups groups, ui::TreeStore store ){
// put the information from the old textures menu into a treeview
GtkTreeIter iter, child;
void TextureBrowser_constructTreeStore(){
TextureGroups groups = TextureGroups_constructTreeView();
- GtkTreeStore* store = gtk_tree_store_new( 1, G_TYPE_STRING );
+ auto store = ui::TreeStore::from(gtk_tree_store_new( 1, G_TYPE_STRING ));
TextureGroups_constructTreeModel( groups, store );
- //std::set<CopiedString>::iterator iter;
-
- GtkTreeModel* model = GTK_TREE_MODEL( store );
+ std::set<CopiedString>::iterator iter;
- gtk_tree_view_set_model( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), model );
+ gtk_tree_view_set_model(g_TextureBrowser.m_treeViewTree, store);
g_object_unref( G_OBJECT( store ) );
}
void TextureBrowser_constructTreeStoreTags(){
//TextureGroups groups;
- GtkTreeStore* store = gtk_tree_store_new( 1, G_TYPE_STRING );
- GtkTreeModel* model = GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list );
+ auto store = ui::TreeStore::from(gtk_tree_store_new( 1, G_TYPE_STRING ));
+ auto model = g_TextureBrowser.m_all_tags_list;
- gtk_tree_view_set_model( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), model );
+ gtk_tree_view_set_model(g_TextureBrowser.m_treeViewTags, model );
g_object_unref( G_OBJECT( store ) );
}
-void TreeView_onRowActivated( GtkTreeView* treeview, GtkTreePath* path, GtkTreeViewColumn* col, gpointer userdata ){
+void TreeView_onRowActivated( ui::TreeView treeview, ui::TreePath path, ui::TreeViewColumn col, gpointer userdata ){
GtkTreeIter iter;
- GtkTreeModel* model = gtk_tree_view_get_model( GTK_TREE_VIEW( treeview ) );
+ auto model = gtk_tree_view_get_model(treeview );
if ( gtk_tree_model_get_iter( model, &iter, path ) ) {
gchar dirName[1024];
}
void TextureBrowser_createTreeViewTree(){
- GtkCellRenderer* renderer;
- g_TextureBrowser.m_treeViewTree = GTK_WIDGET( gtk_tree_view_new() );
- gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE );
+ gtk_tree_view_set_enable_search(g_TextureBrowser.m_treeViewTree, FALSE );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), FALSE );
- g_signal_connect( g_TextureBrowser.m_treeViewTree, "row-activated", (GCallback) TreeView_onRowActivated, NULL );
+ gtk_tree_view_set_headers_visible(g_TextureBrowser.m_treeViewTree, FALSE );
+ g_TextureBrowser.m_treeViewTree.connect( "row-activated", (GCallback) TreeView_onRowActivated, NULL );
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), -1, "", renderer, "text", 0, NULL );
+ auto renderer = ui::CellRendererText(ui::New);
+ gtk_tree_view_insert_column_with_attributes(g_TextureBrowser.m_treeViewTree, -1, "", renderer, "text", 0, NULL );
TextureBrowser_constructTreeStore();
}
void TextureBrowser_addTag();
+
void TextureBrowser_renameTag();
+
void TextureBrowser_deleteTag();
-void TextureBrowser_createContextMenu( GtkWidget *treeview, GdkEventButton *event ){
- GtkWidget* menu = gtk_menu_new();
+void TextureBrowser_createContextMenu( ui::Widget treeview, GdkEventButton *event ){
+ ui::Widget menu = ui::Menu(ui::New);
- GtkWidget* menuitem = gtk_menu_item_new_with_label( "Add tag" );
- g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_addTag, treeview );
+ ui::Widget menuitem = ui::MenuItem( "Add tag" );
+ menuitem.connect( "activate", (GCallback)TextureBrowser_addTag, treeview );
gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem );
- menuitem = gtk_menu_item_new_with_label( "Rename tag" );
- g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_renameTag, treeview );
+ menuitem = ui::MenuItem( "Rename tag" );
+ menuitem.connect( "activate", (GCallback)TextureBrowser_renameTag, treeview );
gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem );
- menuitem = gtk_menu_item_new_with_label( "Delete tag" );
- g_signal_connect( menuitem, "activate", (GCallback)TextureBrowser_deleteTag, treeview );
+ menuitem = ui::MenuItem( "Delete tag" );
+ menuitem.connect( "activate", (GCallback)TextureBrowser_deleteTag, treeview );
gtk_menu_shell_append( GTK_MENU_SHELL( menu ), menuitem );
gtk_widget_show_all( menu );
void TextureBrowser_searchTags();
-gboolean TreeViewTags_onButtonPressed( GtkWidget *treeview, GdkEventButton *event ){
+gboolean TreeViewTags_onButtonPressed( ui::TreeView treeview, GdkEventButton *event ){
if ( event->type == GDK_BUTTON_PRESS && event->button == 3 ) {
GtkTreePath *path;
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( treeview ) );
+ auto selection = gtk_tree_view_get_selection(treeview );
- if ( gtk_tree_view_get_path_at_pos( GTK_TREE_VIEW( treeview ), event->x, event->y, &path, NULL, NULL, NULL ) ) {
+ if ( gtk_tree_view_get_path_at_pos(treeview, event->x, event->y, &path, NULL, NULL, NULL ) ) {
gtk_tree_selection_unselect_all( selection );
gtk_tree_selection_select_path( selection, path );
gtk_tree_path_free( path );
}
void TextureBrowser_createTreeViewTags(){
- GtkCellRenderer* renderer;
- g_TextureBrowser.m_treeViewTags = GTK_WIDGET( gtk_tree_view_new() );
- gtk_tree_view_set_enable_search( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE );
+ g_TextureBrowser.m_treeViewTags = ui::TreeView(ui::New);
+ gtk_tree_view_set_enable_search(g_TextureBrowser.m_treeViewTags, FALSE );
- g_signal_connect( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), "button-press-event", (GCallback)TreeViewTags_onButtonPressed, NULL );
+ g_TextureBrowser.m_treeViewTags.connect( "button-press-event", (GCallback)TreeViewTags_onButtonPressed, NULL );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), FALSE );
+ gtk_tree_view_set_headers_visible(g_TextureBrowser.m_treeViewTags, FALSE );
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ), -1, "", renderer, "text", 0, NULL );
+ auto renderer = ui::CellRendererText(ui::New);
+ gtk_tree_view_insert_column_with_attributes(g_TextureBrowser.m_treeViewTags, -1, "", renderer, "text", 0, NULL );
TextureBrowser_constructTreeStoreTags();
}
-GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* menu ){
- GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_View" );
+ui::MenuItem TextureBrowser_constructViewMenu( ui::Menu menu ){
+ ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_View" ));
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
create_check_menu_item_with_mnemonic( menu, "Hide _Unused", "ShowInUse" );
- create_menu_item_with_mnemonic( menu, "Show All", "ShowAllTextures" );
+ if ( string_empty( g_pGameDescription->getKeyValue( "show_wads" ) ) ) {
+ create_check_menu_item_with_mnemonic( menu, "Hide Image Missing", "FilterMissing" );
+ }
+
+ // hide notex and shadernotex on texture browser: no one wants to apply them
+ create_check_menu_item_with_mnemonic( menu, "Hide Fallback", "FilterFallback" );
+
menu_separator( menu );
if ( g_pGameDescription->mGameType != "doom3" && string_empty( g_pGameDescription->getKeyValue( "show_wads" ) ) ) {
create_check_menu_item_with_mnemonic( menu, "ShaderList Only", "ToggleShowShaderlistOnly" );
}
- if ( string_empty( g_pGameDescription->getKeyValue( "show_wads" ) ) ) {
- create_check_menu_item_with_mnemonic( menu, "Hide Image Missing", "FilterNotex" );
- menu_separator( menu );
- }
+ menu_separator( menu );
create_check_menu_item_with_mnemonic( menu, "Fixed Size", "FixedSize" );
create_check_menu_item_with_mnemonic( menu, "Transparency", "EnableAlpha" );
if ( string_empty( g_pGameDescription->getKeyValue( "show_wads" ) ) ) {
menu_separator( menu );
- g_TextureBrowser.m_shader_info_item = GTK_WIDGET( create_menu_item_with_mnemonic( menu, "Shader Info", "ShaderInfo" ) );
+ g_TextureBrowser.m_shader_info_item = ui::Widget(create_menu_item_with_mnemonic( menu, "Shader Info", "ShaderInfo" ));
gtk_widget_set_sensitive( g_TextureBrowser.m_shader_info_item, FALSE );
}
+
return textures_menu_item;
}
gtk_menu_popup( menu, NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time() );
}
-GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* menu ){
- GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "_Tools" );
+ui::MenuItem TextureBrowser_constructToolsMenu( ui::Menu menu ){
+ ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "_Tools" ));
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
return textures_menu_item;
}
-GtkMenuItem* TextureBrowser_constructTagsMenu( GtkMenu* menu ){
- GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic( "T_ags" );
+ui::MenuItem TextureBrowser_constructTagsMenu( ui::Menu menu ){
+ ui::MenuItem textures_menu_item = ui::MenuItem(new_sub_menu_item_with_mnemonic( "T_ags" ));
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
return textures_menu_item;
}
-gboolean TextureBrowser_tagMoveHelper( GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, GSList** selected ){
+gboolean TextureBrowser_tagMoveHelper( ui::TreeModel model, ui::TreePath path, GtkTreeIter iter, GSList** selected ){
g_assert( selected != NULL );
- GtkTreeRowReference* rowref = gtk_tree_row_reference_new( model, path );
+ auto rowref = gtk_tree_row_reference_new( model, path );
*selected = g_slist_append( *selected, rowref );
return FALSE;
GSList* node;
gchar* tag_assigned;
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) );
+ auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_available_tree );
gtk_tree_selection_selected_foreach( selection, (GtkTreeSelectionForeachFunc)TextureBrowser_tagMoveHelper, &selected );
if ( selected != NULL ) {
for ( node = selected; node != NULL; node = node->next )
{
- GtkTreePath* path = gtk_tree_row_reference_get_path( (GtkTreeRowReference*)node->data );
+ auto path = gtk_tree_row_reference_get_path( (GtkTreeRowReference*)node->data );
if ( path ) {
GtkTreeIter iter;
- if ( gtk_tree_model_get_iter( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ), &iter, path ) ) {
- gtk_tree_model_get( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ), &iter, TAG_COLUMN, &tag_assigned, -1 );
+ if ( gtk_tree_model_get_iter(g_TextureBrowser.m_available_store, &iter, path ) ) {
+ gtk_tree_model_get(g_TextureBrowser.m_available_store, &iter, TAG_COLUMN, &tag_assigned, -1 );
if ( !TagBuilder.CheckShaderTag( g_TextureBrowser.shader.c_str() ) ) {
// create a custom shader/texture entry
IShader* ishader = QERApp_Shader_ForName( g_TextureBrowser.shader.c_str() );
TagBuilder.AddShaderTag( g_TextureBrowser.shader.c_str(), (char*)tag_assigned, TAG );
gtk_list_store_remove( g_TextureBrowser.m_available_store, &iter );
- gtk_list_store_append( g_TextureBrowser.m_assigned_store, &iter );
- gtk_list_store_set( g_TextureBrowser.m_assigned_store, &iter, TAG_COLUMN, (char*)tag_assigned, -1 );
+ g_TextureBrowser.m_assigned_store.append(TAG_COLUMN, tag_assigned);
}
}
}
GSList* node;
gchar* tag;
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ) );
+ auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_assigned_tree );
gtk_tree_selection_selected_foreach( selection, (GtkTreeSelectionForeachFunc)TextureBrowser_tagMoveHelper, &selected );
if ( selected != NULL ) {
for ( node = selected; node != NULL; node = node->next )
{
- GtkTreePath* path = gtk_tree_row_reference_get_path( (GtkTreeRowReference*)node->data );
+ auto path = gtk_tree_row_reference_get_path( (GtkTreeRowReference*)node->data );
if ( path ) {
GtkTreeIter iter;
- if ( gtk_tree_model_get_iter( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ), &iter, path ) ) {
- gtk_tree_model_get( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ), &iter, TAG_COLUMN, &tag, -1 );
+ if ( gtk_tree_model_get_iter(g_TextureBrowser.m_assigned_store, &iter, path ) ) {
+ gtk_tree_model_get(g_TextureBrowser.m_assigned_store, &iter, TAG_COLUMN, &tag, -1 );
TagBuilder.DeleteShaderTag( g_TextureBrowser.shader.c_str(), tag );
gtk_list_store_remove( g_TextureBrowser.m_assigned_store, &iter );
}
}
void TextureBrowser_buildTagList(){
- GtkTreeIter treeIter;
- gtk_list_store_clear( g_TextureBrowser.m_all_tags_list );
+ g_TextureBrowser.m_all_tags_list.clear();
std::set<CopiedString>::iterator iter;
for ( iter = g_TextureBrowser.m_all_tags.begin(); iter != g_TextureBrowser.m_all_tags.end(); ++iter )
{
- gtk_list_store_append( g_TextureBrowser.m_all_tags_list, &treeIter );
- gtk_list_store_set( g_TextureBrowser.m_all_tags_list, &treeIter, TAG_COLUMN, ( *iter ).c_str(), -1 );
+ g_TextureBrowser.m_all_tags_list.append(TAG_COLUMN, (*iter).c_str());
}
}
char buffer[256];
char tags_searched[256];
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ) );
+ auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_treeViewTags );
gtk_tree_selection_selected_foreach( selection, (GtkTreeSelectionForeachFunc)TextureBrowser_tagMoveHelper, &selected );
for ( node = selected; node != NULL; node = node->next )
{
- GtkTreePath* path = gtk_tree_row_reference_get_path( (GtkTreeRowReference*)node->data );
+ auto path = gtk_tree_row_reference_get_path( (GtkTreeRowReference*)node->data );
if ( path ) {
GtkTreeIter iter;
- if ( gtk_tree_model_get_iter( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iter, path ) ) {
- gtk_tree_model_get( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iter, TAG_COLUMN, &tag, -1 );
+ if ( gtk_tree_model_get_iter(g_TextureBrowser.m_all_tags_list, &iter, path ) ) {
+ gtk_tree_model_get(g_TextureBrowser.m_all_tags_list, &iter, TAG_COLUMN, &tag, -1 );
strcat( buffer, tag );
strcat( tags_searched, tag );
gtk_widget_show_all( g_TextureBrowser.m_search_button );
}
else {
- gtk_widget_hide_all( g_TextureBrowser.m_search_button );
+ g_TextureBrowser.m_search_button.hide();
}
}
void TextureBrowser_constructTagNotebook(){
- g_TextureBrowser.m_tag_notebook = gtk_notebook_new();
- GtkWidget* labelTags = gtk_label_new( "Tags" );
- GtkWidget* labelTextures = gtk_label_new( "Textures" );
+ g_TextureBrowser.m_tag_notebook = ui::Widget::from(gtk_notebook_new());
+ ui::Widget labelTags = ui::Label( "Tags" );
+ ui::Widget labelTextures = ui::Label( "Textures" );
gtk_notebook_append_page( GTK_NOTEBOOK( g_TextureBrowser.m_tag_notebook ), g_TextureBrowser.m_scr_win_tree, labelTextures );
gtk_notebook_append_page( GTK_NOTEBOOK( g_TextureBrowser.m_tag_notebook ), g_TextureBrowser.m_scr_win_tags, labelTags );
- g_signal_connect( G_OBJECT( g_TextureBrowser.m_tag_notebook ), "switch-page", G_CALLBACK( TextureBrowser_toggleSearchButton ), NULL );
+ g_TextureBrowser.m_tag_notebook.connect( "switch-page", G_CALLBACK( TextureBrowser_toggleSearchButton ), NULL );
gtk_widget_show_all( g_TextureBrowser.m_tag_notebook );
}
void TextureBrowser_constructSearchButton(){
- GtkTooltips* tooltips = gtk_tooltips_new();
-
- GtkWidget* image = gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR );
- g_TextureBrowser.m_search_button = gtk_button_new();
- g_signal_connect( G_OBJECT( g_TextureBrowser.m_search_button ), "clicked", G_CALLBACK( TextureBrowser_searchTags ), NULL );
- gtk_tooltips_set_tip( GTK_TOOLTIPS( tooltips ), g_TextureBrowser.m_search_button, "Search with selected tags", "Search with selected tags" );
- gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_search_button ), image );
+ auto image = ui::Widget::from(gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR ));
+ g_TextureBrowser.m_search_button = ui::Button(ui::New);
+ g_TextureBrowser.m_search_button.connect( "clicked", G_CALLBACK( TextureBrowser_searchTags ), NULL );
+ gtk_widget_set_tooltip_text(g_TextureBrowser.m_search_button, "Search with selected tags");
+ g_TextureBrowser.m_search_button.add(image);
}
void TextureBrowser_checkTagFile(){
}
void TextureBrowser_SetNotex(){
- StringOutputStream name( 256 );
- name << GlobalRadiant().getAppPath() << "bitmaps/notex.png";
- g_notex = name.c_str();
+ IShader* notex = QERApp_Shader_ForName( DEFAULT_NOTEX_NAME );
+ IShader* shadernotex = QERApp_Shader_ForName( DEFAULT_SHADERNOTEX_NAME );
+
+ g_notex = notex->getTexture()->name;
+ g_shadernotex = shadernotex->getTexture()->name;
- name = NULL;
- name << GlobalRadiant().getAppPath() << "bitmaps/shadernotex.png";
- g_shadernotex = name.c_str();
+ notex->DecRef();
+ shadernotex->DecRef();
}
-GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){
+ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){
// The gl_widget and the tag assignment frame should be packed into a GtkVPaned with the slider
// position stored in local.pref. gtk_paned_get_position() and gtk_paned_set_position() don't
// seem to work in gtk 2.4 and the arrow buttons don't handle GTK_FILL, so here's another thing
TextureBrowser_checkTagFile();
TextureBrowser_SetNotex();
- GlobalShaderSystem().setActiveShadersChangedNotify( ReferenceCaller<TextureBrowser, TextureBrowser_activeShadersChanged>( g_TextureBrowser ) );
+ GlobalShaderSystem().setActiveShadersChangedNotify( ReferenceCaller<TextureBrowser, void(), TextureBrowser_activeShadersChanged>( g_TextureBrowser ) );
g_TextureBrowser.m_parent = toplevel;
- GtkWidget* table = gtk_table_new( 3, 3, FALSE );
- GtkWidget* frame_table = NULL;
- GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
- gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 0, 3, GTK_FILL, GTK_FILL, 0, 0 );
- gtk_widget_show( vbox );
+ auto table = ui::Table(3, 3, FALSE);
+ auto vbox = ui::VBox(FALSE, 0);
+ table.attach(vbox, {0, 1, 1, 3}, {GTK_FILL, GTK_FILL});
+ vbox.show();
- //GtkWidget* menu_bar;
- GtkToolbar* toolbar;
+ // ui::Widget menu_bar{ui::null};
+ auto toolbar = ui::Toolbar::from( gtk_toolbar_new() );
{ // menu bar
- //menu_bar = gtk_menu_bar_new();
- GtkWidget* menu_view = gtk_menu_new();
- //GtkWidget* view_item = (GtkWidget*)
- TextureBrowser_constructViewMenu( GTK_MENU( menu_view ) );
- gtk_menu_set_title( GTK_MENU( menu_view ), "View" );
- //gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view );
- //gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), view_item );
+ // menu_bar = ui::Widget::from(gtk_menu_bar_new());
+ auto menu_view = ui::Menu(ui::New);
+ // auto view_item = TextureBrowser_constructViewMenu( menu_view );
+ TextureBrowser_constructViewMenu( menu_view );
+ gtk_menu_set_title( menu_view, "View" );
+ // gtk_menu_item_set_submenu( GTK_MENU_ITEM( view_item ), menu_view );
+ // gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), view_item );
-
- toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
//gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( toolbar ), 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0 );
gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( toolbar ), FALSE, FALSE, 0 );
//view menu button
- GtkButton* button = GTK_BUTTON( gtk_button_new() );
- button_set_icon( button, "texbro_view.png" );
- gtk_widget_show( GTK_WIDGET( button ) );
- gtk_button_set_relief( button, GTK_RELIEF_NONE );
- gtk_widget_set_size_request( GTK_WIDGET( button ), 24, 24 );
- GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_FOCUS );
- GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_DEFAULT );
- gtk_toolbar_append_element( toolbar, GTK_TOOLBAR_CHILD_WIDGET, GTK_WIDGET( button ), "", "View", "", 0, 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( Popup_View_Menu ), menu_view );
-
- //to show detached menu over floating tex bro
- gtk_menu_attach_to_widget( GTK_MENU( menu_view ), GTK_WIDGET( button ), NULL );
-
- button = toolbar_append_button( toolbar, "Find / Replace...", "texbro_gtk-find-and-replace.png", "FindReplaceTextures" );
- gtk_widget_set_size_request( GTK_WIDGET( button ), 22, 22 );
-
+ {
+ auto button = toolbar_append_button( toolbar, "View", "texbro_view.png" );
+ button.dimensions( 22, 22 );
+ button.connect( "clicked", G_CALLBACK( Popup_View_Menu ), menu_view );
- button = toolbar_append_button( toolbar, "Flush & Reload Shaders", "texbro_refresh.png", "RefreshShaders" );
- gtk_widget_set_size_request( GTK_WIDGET( button ), 22, 22 );
- gtk_widget_show( GTK_WIDGET( toolbar ) );
+ //to show detached menu over floating tex bro
+ gtk_menu_attach_to_widget( GTK_MENU( menu_view ), GTK_WIDGET( button ), NULL );
+ }
+ {
+ auto button = toolbar_append_button( toolbar, "Find / Replace...", "texbro_gtk-find-and-replace.png", "FindReplaceTextures" );
+ button.dimensions( 22, 22 );
+ }
+ {
+ auto button = toolbar_append_button( toolbar, "Flush & Reload Shaders", "texbro_refresh.png", "RefreshShaders" );
+ button.dimensions( 22, 22 );
+ }
+ toolbar.show();
/*
- GtkWidget* menu_tools = gtk_menu_new();
- GtkWidget* tools_item = (GtkWidget*)TextureBrowser_constructToolsMenu( GTK_MENU( menu_tools ) );
+ auto menu_tools = ui::Menu(ui::New);
+ auto tools_item = TextureBrowser_constructToolsMenu( menu_tools );
gtk_menu_item_set_submenu( GTK_MENU_ITEM( tools_item ), menu_tools );
- gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tools_item );
+ gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tools_item );
*/
- //gtk_table_attach( GTK_TABLE( table ), menu_bar, 0, 3, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0 );
- //gtk_widget_show( menu_bar );
+ // table.attach(menu_bar, {0, 3, 0, 1}, {GTK_FILL, GTK_SHRINK});
+ // menu_bar.show();
}
{ // Texture TreeView
- g_TextureBrowser.m_scr_win_tree = gtk_scrolled_window_new( NULL, NULL );
+ g_TextureBrowser.m_scr_win_tree = ui::ScrolledWindow(ui::New);
gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tree ), 0 );
// vertical only scrolling for treeview
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
- gtk_widget_show( g_TextureBrowser.m_scr_win_tree );
+ g_TextureBrowser.m_scr_win_tree.show();
TextureBrowser_createTreeViewTree();
- //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) );
+ //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tree ), g_TextureBrowser.m_treeViewTree );
gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tree ), GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) );
- gtk_widget_show( GTK_WIDGET( g_TextureBrowser.m_treeViewTree ) );
+ g_TextureBrowser.m_treeViewTree.show();
}
{ // gl_widget scrollbar
- GtkWidget* w = gtk_vscrollbar_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0,0,0,1,1,0 ) ) );
- gtk_table_attach( GTK_TABLE( table ), w, 2, 3, 1, 2, GTK_SHRINK, GTK_FILL, 0, 0 );
- gtk_widget_show( w );
+ auto w = ui::Widget::from(gtk_vscrollbar_new( ui::Adjustment( 0,0,0,1,1,0 ) ));
+ table.attach(w, {2, 3, 1, 2}, {GTK_SHRINK, GTK_FILL});
+ w.show();
g_TextureBrowser.m_texture_scroll = w;
- GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) );
- g_signal_connect( G_OBJECT( vadjustment ), "value_changed", G_CALLBACK( TextureBrowser_verticalScroll ), &g_TextureBrowser );
+ auto vadjustment = ui::Adjustment::from(gtk_range_get_adjustment( GTK_RANGE( g_TextureBrowser.m_texture_scroll ) ));
+ vadjustment.connect( "value_changed", G_CALLBACK( TextureBrowser_verticalScroll ), &g_TextureBrowser );
- widget_set_visible( g_TextureBrowser.m_texture_scroll, g_TextureBrowser.m_showTextureScrollbar );
+ g_TextureBrowser.m_texture_scroll.visible(g_TextureBrowser.m_showTextureScrollbar);
}
{ // gl_widget
g_TextureBrowser.m_gl_widget = glwidget_new( FALSE );
- gtk_widget_ref( g_TextureBrowser.m_gl_widget );
+ g_object_ref( g_TextureBrowser.m_gl_widget._handle );
gtk_widget_set_events( g_TextureBrowser.m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK );
- GTK_WIDGET_SET_FLAGS( g_TextureBrowser.m_gl_widget, GTK_CAN_FOCUS );
+ gtk_widget_set_can_focus( g_TextureBrowser.m_gl_widget, true );
- gtk_table_attach_defaults( GTK_TABLE( table ), g_TextureBrowser.m_gl_widget, 1, 2, 1, 2 );
- gtk_widget_show( g_TextureBrowser.m_gl_widget );
+ table.attach(g_TextureBrowser.m_gl_widget, {1, 2, 1, 2});
+ g_TextureBrowser.m_gl_widget.show();
- g_TextureBrowser.m_sizeHandler = g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "size_allocate", G_CALLBACK( TextureBrowser_size_allocate ), &g_TextureBrowser );
- g_TextureBrowser.m_exposeHandler = g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "expose_event", G_CALLBACK( TextureBrowser_expose ), &g_TextureBrowser );
+ g_TextureBrowser.m_sizeHandler = g_TextureBrowser.m_gl_widget.connect( "size_allocate", G_CALLBACK( TextureBrowser_size_allocate ), &g_TextureBrowser );
+ g_TextureBrowser.m_exposeHandler = g_TextureBrowser.m_gl_widget.on_render( G_CALLBACK( TextureBrowser_expose ), &g_TextureBrowser );
- g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "button_press_event", G_CALLBACK( TextureBrowser_button_press ), &g_TextureBrowser );
- g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "button_release_event", G_CALLBACK( TextureBrowser_button_release ), &g_TextureBrowser );
- g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "motion_notify_event", G_CALLBACK( TextureBrowser_motion ), &g_TextureBrowser );
- g_signal_connect( G_OBJECT( g_TextureBrowser.m_gl_widget ), "scroll_event", G_CALLBACK( TextureBrowser_scroll ), &g_TextureBrowser );
+ g_TextureBrowser.m_gl_widget.connect( "button_press_event", G_CALLBACK( TextureBrowser_button_press ), &g_TextureBrowser );
+ g_TextureBrowser.m_gl_widget.connect( "button_release_event", G_CALLBACK( TextureBrowser_button_release ), &g_TextureBrowser );
+ g_TextureBrowser.m_gl_widget.connect( "motion_notify_event", G_CALLBACK( TextureBrowser_motion ), &g_TextureBrowser );
+ g_TextureBrowser.m_gl_widget.connect( "scroll_event", G_CALLBACK( TextureBrowser_scroll ), &g_TextureBrowser );
}
// tag stuff
if ( g_TextureBrowser.m_tags ) {
{ // fill tag GtkListStore
- g_TextureBrowser.m_all_tags_list = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING );
- GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_all_tags_list );
+ g_TextureBrowser.m_all_tags_list = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ));
+ auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_all_tags_list );
gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING );
TagBuilder.GetAllTags( g_TextureBrowser.m_all_tags );
TextureBrowser_buildTagList();
}
{ // tag menu bar
- GtkWidget* menu_tags = gtk_menu_new();
+ auto menu_tags = ui::Menu(ui::New);
gtk_menu_set_title( GTK_MENU( menu_tags ), "Tags" );
- //GtkWidget* tags_item = (GtkWidget*)
- TextureBrowser_constructTagsMenu( GTK_MENU( menu_tags ) );
- //gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags );
- //gtk_menu_bar_append( GTK_MENU_BAR( menu_bar ), tags_item );
-
- GtkButton* button = GTK_BUTTON( gtk_button_new() );
- //button_set_icon( button, "texbro_tags.png" );
- GtkWidget *label = gtk_label_new (">t");
- gtk_container_add (GTK_CONTAINER (button), label);
- gtk_widget_show (label);
-
- gtk_widget_show( GTK_WIDGET( button ) );
- gtk_button_set_relief( button, GTK_RELIEF_NONE );
- gtk_widget_set_size_request( GTK_WIDGET( button ), 22, 22 );
- GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_FOCUS );
- GTK_WIDGET_UNSET_FLAGS( GTK_WIDGET( button ), GTK_CAN_DEFAULT );
- gtk_toolbar_append_element( toolbar, GTK_TOOLBAR_CHILD_WIDGET, GTK_WIDGET( button ), "", "Tags", "", 0, 0, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( Popup_View_Menu ), menu_tags );
+ // auto tags_item = TextureBrowser_constructTagsMenu( menu_tags );
+ TextureBrowser_constructTagsMenu( menu_tags );
+ // gtk_menu_item_set_submenu( GTK_MENU_ITEM( tags_item ), menu_tags );
+ // gtk_menu_shell_append( GTK_MENU_SHELL( menu_bar ), tags_item );
+
+ auto button = toolbar_append_button( toolbar, "Tags", "texbro_tags.png" );
+ button.dimensions( 22, 22 );
+ button.connect( "clicked", G_CALLBACK( Popup_View_Menu ), menu_tags );
//to show detached menu over floating tex bro and main wnd...
gtk_menu_attach_to_widget( GTK_MENU( menu_tags ), GTK_WIDGET( button ), NULL );
}
{ // Tag TreeView
- g_TextureBrowser.m_scr_win_tags = gtk_scrolled_window_new( NULL, NULL );
+ g_TextureBrowser.m_scr_win_tags = ui::ScrolledWindow(ui::New);
gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tags ), 0 );
// vertical only scrolling for treeview
TextureBrowser_createTreeViewTags();
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ) );
+ auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_treeViewTags );
gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
- //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tags ), GTK_WIDGET( g_TextureBrowser.m_treeViewTags ) );
+ //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( g_TextureBrowser.m_scr_win_tags ), g_TextureBrowser.m_treeViewTags );
gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tags ), GTK_WIDGET( g_TextureBrowser.m_treeViewTags ) );
- gtk_widget_show( GTK_WIDGET( g_TextureBrowser.m_treeViewTags ) );
+ g_TextureBrowser.m_treeViewTags.show();
}
{ // Texture/Tag notebook
TextureBrowser_constructTagNotebook();
- gtk_box_pack_start( GTK_BOX( vbox ), g_TextureBrowser.m_tag_notebook, TRUE, TRUE, 0 );
+ vbox.pack_start( g_TextureBrowser.m_tag_notebook, TRUE, TRUE, 0 );
}
{ // Tag search button
TextureBrowser_constructSearchButton();
- gtk_box_pack_end( GTK_BOX( vbox ), g_TextureBrowser.m_search_button, FALSE, FALSE, 0 );
+ vbox.pack_end(g_TextureBrowser.m_search_button, FALSE, FALSE, 0);
}
+ auto frame_table = ui::Table(3, 3, FALSE);
{ // Tag frame
- frame_table = gtk_table_new( 3, 3, FALSE );
- g_TextureBrowser.m_tag_frame = gtk_frame_new( "Tag assignment" );
+ g_TextureBrowser.m_tag_frame = ui::Frame( "Tag assignment" );
gtk_frame_set_label_align( GTK_FRAME( g_TextureBrowser.m_tag_frame ), 0.5, 0.5 );
gtk_frame_set_shadow_type( GTK_FRAME( g_TextureBrowser.m_tag_frame ), GTK_SHADOW_NONE );
- gtk_table_attach( GTK_TABLE( table ), g_TextureBrowser.m_tag_frame, 1, 3, 2, 3, GTK_FILL, GTK_SHRINK, 0, 0 );
+ table.attach(g_TextureBrowser.m_tag_frame, {1, 3, 2, 3}, {GTK_FILL, GTK_SHRINK});
- gtk_widget_show( frame_table );
+ frame_table.show();
- gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_tag_frame ), frame_table );
+ g_TextureBrowser.m_tag_frame.add(frame_table);
}
{ // assigned tag list
- GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL );
+ ui::Widget scrolled_win = ui::ScrolledWindow(ui::New);
gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
- g_TextureBrowser.m_assigned_store = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING );
+ g_TextureBrowser.m_assigned_store = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ));
- GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_assigned_store );
+ auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_assigned_store );
gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING );
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+ auto renderer = ui::CellRendererText(ui::New);
- g_TextureBrowser.m_assigned_tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_assigned_store ) );
- g_object_unref( G_OBJECT( g_TextureBrowser.m_assigned_store ) );
- g_signal_connect( g_TextureBrowser.m_assigned_tree, "row-activated", (GCallback) TextureBrowser_removeTags, NULL );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), FALSE );
+ g_TextureBrowser.m_assigned_tree = ui::TreeView(ui::TreeModel::from(g_TextureBrowser.m_assigned_store._handle));
+ g_TextureBrowser.m_assigned_store.unref();
+ g_TextureBrowser.m_assigned_tree.connect( "row-activated", (GCallback) TextureBrowser_removeTags, NULL );
+ gtk_tree_view_set_headers_visible(g_TextureBrowser.m_assigned_tree, FALSE );
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ) );
+ auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_assigned_tree );
gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL );
- gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_assigned_tree ), column );
- gtk_widget_show( g_TextureBrowser.m_assigned_tree );
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} );
+ gtk_tree_view_append_column(g_TextureBrowser.m_assigned_tree, column );
+ g_TextureBrowser.m_assigned_tree.show();
- gtk_widget_show( scrolled_win );
- //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_assigned_tree ) );
- gtk_container_add( GTK_CONTAINER( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_assigned_tree ) );
+ scrolled_win.show();
+ //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), g_TextureBrowser.m_assigned_tree );
+ gtk_container_add( GTK_CONTAINER( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_available_tree ) );
- gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 0, 1, 1, 3, GTK_FILL, GTK_FILL, 0, 0 );
+ frame_table.attach(scrolled_win, {0, 1, 1, 3}, {GTK_FILL, GTK_FILL});
}
{ // available tag list
- GtkWidget* scrolled_win = gtk_scrolled_window_new( NULL, NULL );
+ ui::Widget scrolled_win = ui::ScrolledWindow(ui::New);
gtk_container_set_border_width( GTK_CONTAINER( scrolled_win ), 0 );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
- g_TextureBrowser.m_available_store = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING );
- GtkTreeSortable* sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_available_store );
+ g_TextureBrowser.m_available_store = ui::ListStore::from(gtk_list_store_new( N_COLUMNS, G_TYPE_STRING ));
+ auto sortable = GTK_TREE_SORTABLE( g_TextureBrowser.m_available_store );
gtk_tree_sortable_set_sort_column_id( sortable, TAG_COLUMN, GTK_SORT_ASCENDING );
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+ auto renderer = ui::CellRendererText(ui::New);
- g_TextureBrowser.m_available_tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( g_TextureBrowser.m_available_store ) );
- g_object_unref( G_OBJECT( g_TextureBrowser.m_available_store ) );
- g_signal_connect( g_TextureBrowser.m_available_tree, "row-activated", (GCallback) TextureBrowser_assignTags, NULL );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), FALSE );
+ g_TextureBrowser.m_available_tree = ui::TreeView(ui::TreeModel::from(g_TextureBrowser.m_available_store._handle));
+ g_TextureBrowser.m_available_store.unref();
+ g_TextureBrowser.m_available_tree.connect( "row-activated", (GCallback) TextureBrowser_assignTags, NULL );
+ gtk_tree_view_set_headers_visible(g_TextureBrowser.m_available_tree, FALSE );
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) );
+ auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_available_tree );
gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", TAG_COLUMN, NULL );
- gtk_tree_view_append_column( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ), column );
- gtk_widget_show( g_TextureBrowser.m_available_tree );
+ auto column = ui::TreeViewColumn( "", renderer, {{"text", TAG_COLUMN}} );
+ gtk_tree_view_append_column(g_TextureBrowser.m_available_tree, column );
+ g_TextureBrowser.m_available_tree.show();
- gtk_widget_show( scrolled_win );
- //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_available_tree ) );
+ scrolled_win.show();
+ //gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), g_TextureBrowser.m_available_tree );
gtk_container_add( GTK_CONTAINER( scrolled_win ), GTK_WIDGET( g_TextureBrowser.m_available_tree ) );
- gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 2, 3, 1, 3, GTK_FILL, GTK_FILL, 0, 0 );
+ frame_table.attach(scrolled_win, {2, 3, 1, 3}, {GTK_FILL, GTK_FILL});
}
{ // tag arrow buttons
- GtkWidget* m_btn_left = gtk_button_new();
- GtkWidget* m_btn_right = gtk_button_new();
- GtkWidget* m_arrow_left = gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT );
- GtkWidget* m_arrow_right = gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT );
- gtk_container_add( GTK_CONTAINER( m_btn_left ), m_arrow_left );
- gtk_container_add( GTK_CONTAINER( m_btn_right ), m_arrow_right );
+ auto m_btn_left = ui::Button(ui::New);
+ auto m_btn_right = ui::Button(ui::New);
+ auto m_arrow_left = ui::Widget::from(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT ));
+ auto m_arrow_right = ui::Widget::from(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT ));
+ m_btn_left.add(m_arrow_left);
+ m_btn_right.add(m_arrow_right);
// workaround. the size of the tag frame depends of the requested size of the arrow buttons.
- gtk_widget_set_size_request( m_arrow_left, -1, 68 );
- gtk_widget_set_size_request( m_arrow_right, -1, 68 );
+ m_arrow_left.dimensions(-1, 68);
+ m_arrow_right.dimensions(-1, 68);
- gtk_table_attach( GTK_TABLE( frame_table ), m_btn_left, 1, 2, 1, 2, GTK_SHRINK, GTK_EXPAND, 0, 0 );
- gtk_table_attach( GTK_TABLE( frame_table ), m_btn_right, 1, 2, 2, 3, GTK_SHRINK, GTK_EXPAND, 0, 0 );
+ frame_table.attach(m_btn_left, {1, 2, 1, 2}, {GTK_SHRINK, GTK_EXPAND});
+ frame_table.attach(m_btn_right, {1, 2, 2, 3}, {GTK_SHRINK, GTK_EXPAND});
- g_signal_connect( G_OBJECT( m_btn_left ), "clicked", G_CALLBACK( TextureBrowser_assignTags ), NULL );
- g_signal_connect( G_OBJECT( m_btn_right ), "clicked", G_CALLBACK( TextureBrowser_removeTags ), NULL );
+ m_btn_left.connect( "clicked", G_CALLBACK( TextureBrowser_assignTags ), NULL );
+ m_btn_right.connect( "clicked", G_CALLBACK( TextureBrowser_removeTags ), NULL );
- gtk_widget_show( m_btn_left );
- gtk_widget_show( m_btn_right );
- gtk_widget_show( m_arrow_left );
- gtk_widget_show( m_arrow_right );
+ m_btn_left.show();
+ m_btn_right.show();
+ m_arrow_left.show();
+ m_arrow_right.show();
}
{ // tag fram labels
- GtkWidget* m_lbl_assigned = gtk_label_new( "Assigned" );
- GtkWidget* m_lbl_unassigned = gtk_label_new( "Available" );
+ ui::Widget m_lbl_assigned = ui::Label( "Assigned" );
+ ui::Widget m_lbl_unassigned = ui::Label( "Available" );
- gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_assigned, 0, 1, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 );
- gtk_table_attach( GTK_TABLE( frame_table ), m_lbl_unassigned, 2, 3, 0, 1, GTK_EXPAND, GTK_SHRINK, 0, 0 );
+ frame_table.attach(m_lbl_assigned, {0, 1, 0, 1}, {GTK_EXPAND, GTK_SHRINK});
+ frame_table.attach(m_lbl_unassigned, {2, 3, 0, 1}, {GTK_EXPAND, GTK_SHRINK});
- gtk_widget_show( m_lbl_assigned );
- gtk_widget_show( m_lbl_unassigned );
+ m_lbl_assigned.show();
+ m_lbl_unassigned.show();
}
}
else { // no tag support, show the texture tree only
- gtk_box_pack_start( GTK_BOX( vbox ), g_TextureBrowser.m_scr_win_tree, TRUE, TRUE, 0 );
+ vbox.pack_start( g_TextureBrowser.m_scr_win_tree, TRUE, TRUE, 0 );
}
// TODO do we need this?
}
void TextureBrowser_destroyWindow(){
- GlobalShaderSystem().setActiveShadersChangedNotify( Callback() );
+ GlobalShaderSystem().setActiveShadersChangedNotify( Callback<void()>() );
g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_sizeHandler );
g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_exposeHandler );
- gtk_widget_unref( g_TextureBrowser.m_gl_widget );
+ g_TextureBrowser.m_gl_widget.unref();
}
const Vector3& TextureBrowser_getBackgroundColour( TextureBrowser& textureBrowser ){
TextureBrowser_queueDraw( textureBrowser );
}
-void TextureBrowser_selectionHelper( GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, GSList** selected ){
+void TextureBrowser_selectionHelper( ui::TreeModel model, ui::TreePath path, GtkTreeIter* iter, GSList** selected ){
g_assert( selected != NULL );
gchar* name;
EMessageBoxReturn result = DoShaderTagDlg( &tag, "Add shader tag" );
if ( result == eIDOK && !tag.empty() ) {
- GtkTreeIter iter, iter2;
+ GtkTreeIter iter;
g_TextureBrowser.m_all_tags.insert( tag.c_str() );
gtk_list_store_append( g_TextureBrowser.m_available_store, &iter );
gtk_list_store_set( g_TextureBrowser.m_available_store, &iter, TAG_COLUMN, tag.c_str(), -1 );
// Select the currently added tag in the available list
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_available_tree ) );
+ auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_available_tree );
gtk_tree_selection_select_iter( selection, &iter );
- gtk_list_store_append( g_TextureBrowser.m_all_tags_list, &iter2 );
- gtk_list_store_set( g_TextureBrowser.m_all_tags_list, &iter2, TAG_COLUMN, tag.c_str(), -1 );
+ g_TextureBrowser.m_all_tags_list.append(TAG_COLUMN, tag.c_str());
}
}
GSList* selected = NULL;
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ) );
+ auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_treeViewTags );
gtk_tree_selection_selected_foreach( selection, GtkTreeSelectionForeachFunc( TextureBrowser_selectionHelper ), &selected );
if ( g_slist_length( selected ) == 1 ) { // we only rename a single tag
gchar* rowTag;
gchar* oldTag = (char*)selected->data;
- bool row = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterList ) != 0;
+ bool row = gtk_tree_model_get_iter_first(g_TextureBrowser.m_all_tags_list, &iterList ) != 0;
while ( row )
{
- gtk_tree_model_get( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterList, TAG_COLUMN, &rowTag, -1 );
+ gtk_tree_model_get(g_TextureBrowser.m_all_tags_list, &iterList, TAG_COLUMN, &rowTag, -1 );
if ( strcmp( rowTag, oldTag ) == 0 ) {
gtk_list_store_set( g_TextureBrowser.m_all_tags_list, &iterList, TAG_COLUMN, newTag.c_str(), -1 );
}
- row = gtk_tree_model_iter_next( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterList ) != 0;
+ row = gtk_tree_model_iter_next(g_TextureBrowser.m_all_tags_list, &iterList ) != 0;
}
TagBuilder.RenameShaderTag( oldTag, newTag.c_str() );
}
else
{
- gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Select a single tag for renaming." );
+ ui::alert( g_TextureBrowser.m_parent, "Select a single tag for renaming." );
}
}
void TextureBrowser_deleteTag(){
GSList* selected = NULL;
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTags ) );
+ auto selection = gtk_tree_view_get_selection(g_TextureBrowser.m_treeViewTags );
gtk_tree_selection_selected_foreach( selection, GtkTreeSelectionForeachFunc( TextureBrowser_selectionHelper ), &selected );
if ( g_slist_length( selected ) == 1 ) { // we only delete a single tag
- EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Are you sure you want to delete the selected tag?", "Delete Tag", eMB_YESNO, eMB_ICONQUESTION );
+ auto result = ui::alert( g_TextureBrowser.m_parent, "Are you sure you want to delete the selected tag?", "Delete Tag", ui::alert_type::YESNO, ui::alert_icon::Question );
- if ( result == eIDYES ) {
+ if ( result == ui::alert_response::YES ) {
GtkTreeIter iterSelected;
gchar *rowTag;
gchar* tagSelected = (char*)selected->data;
- bool row = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterSelected ) != 0;
+ bool row = gtk_tree_model_get_iter_first(g_TextureBrowser.m_all_tags_list, &iterSelected ) != 0;
while ( row )
{
- gtk_tree_model_get( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterSelected, TAG_COLUMN, &rowTag, -1 );
+ gtk_tree_model_get(g_TextureBrowser.m_all_tags_list, &iterSelected, TAG_COLUMN, &rowTag, -1 );
if ( strcmp( rowTag, tagSelected ) == 0 ) {
gtk_list_store_remove( g_TextureBrowser.m_all_tags_list, &iterSelected );
break;
}
- row = gtk_tree_model_iter_next( GTK_TREE_MODEL( g_TextureBrowser.m_all_tags_list ), &iterSelected ) != 0;
+ row = gtk_tree_model_iter_next(g_TextureBrowser.m_all_tags_list, &iterSelected ) != 0;
}
TagBuilder.DeleteTag( tagSelected );
}
}
else {
- gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "Select a single tag for deletion." );
+ ui::alert( g_TextureBrowser.m_parent, "Select a single tag for deletion." );
}
}
BuildStoreAvailableTags( g_TextureBrowser.m_available_store, g_TextureBrowser.m_assigned_store, g_TextureBrowser.m_all_tags, &g_TextureBrowser );
}
-void RefreshShaders(){
+void TextureBrowser_RefreshShaders(){
/* When shaders are refreshed, forces reloading the textures as well.
Previously it would at best only display shaders, at worst mess up some textured objects. */
- GtkTreeSelection* selection = gtk_tree_view_get_selection((GtkTreeView*)GlobalTextureBrowser().m_treeViewTree);
+ auto selection = gtk_tree_view_get_selection(GlobalTextureBrowser().m_treeViewTree);
GtkTreeModel* model = NULL;
GtkTreeIter iter;
if ( gtk_tree_selection_get_selected (selection, &model, &iter) )
{
gchar dirName[1024];
+
gchar* buffer;
gtk_tree_model_get( model, &iter, 0, &buffer, -1 );
strcpy( dirName, buffer );
TextureBrowser_ShowDirectory( GlobalTextureBrowser(), dirName );
TextureBrowser_queueDraw( GlobalTextureBrowser() );
}
+
else{
ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" );
GlobalShaderSystem().refresh();
TextureBrowser_constructTreeStore();
UpdateAllWindows();
}
-
}
void TextureBrowser_ToggleShowShaders(){
}
void TextureBrowser_showUntagged(){
- EMessageBoxReturn result = gtk_MessageBox( GTK_WIDGET( g_TextureBrowser.m_parent ), "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", eMB_YESNO, eMB_ICONWARNING );
+ auto result = ui::alert( g_TextureBrowser.m_parent, "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", ui::alert_type::YESNO, ui::alert_icon::Warning );
- if ( result == eIDYES ) {
+ if ( result == ui::alert_response::YES ) {
g_TextureBrowser.m_found_shaders.clear();
TagBuilder.GetUntagged( g_TextureBrowser.m_found_shaders );
std::set<CopiedString>::iterator iter;
TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
}
-void TextureBrowser_FilterNotex(){
- g_TextureBrowser_filterNotex ^= 1;
+void TextureBrowser_FilterMissing(){
+ g_TextureBrowser_filterMissing ^= 1;
GlobalTextureBrowser().m_filternotex_item.update();
TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
+ TextureBrowser_RefreshShaders();
+}
+
+void TextureBrowser_FilterFallback(){
+ g_TextureBrowser_filterFallback ^= 1;
+ GlobalTextureBrowser().m_hidenotex_item.update();
+ TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
+ TextureBrowser_RefreshShaders();
}
void TextureBrowser_EnableAlpha(){
TextureBrowser_activeShadersChanged( GlobalTextureBrowser() );
}
-void TextureBrowser_exportTitle( const StringImportCallback& importer ){
+void TextureBrowser_exportTitle( const Callback<void(const char *)> & importer ){
StringOutputStream buffer( 64 );
buffer << "Textures: ";
if ( !string_empty( g_TextureBrowser_currentDirectory.c_str() ) ) {
importer( buffer.c_str() );
}
+struct TextureScale {
+ static void Export(const TextureBrowser &self, const Callback<void(int)> &returnz) {
+ switch (self.m_textureScale) {
+ case 10:
+ returnz(0);
+ break;
+ case 25:
+ returnz(1);
+ break;
+ case 50:
+ returnz(2);
+ break;
+ case 100:
+ returnz(3);
+ break;
+ case 200:
+ returnz(4);
+ break;
+ }
+ }
-void TextureScaleImport( TextureBrowser& textureBrowser, int value ){
- switch ( value )
- {
- case 0:
- TextureBrowser_setScale( textureBrowser, 10 );
- break;
- case 1:
- TextureBrowser_setScale( textureBrowser, 25 );
- break;
- case 2:
- TextureBrowser_setScale( textureBrowser, 50 );
- break;
- case 3:
- TextureBrowser_setScale( textureBrowser, 100 );
- break;
- case 4:
- TextureBrowser_setScale( textureBrowser, 200 );
- break;
- }
-}
-typedef ReferenceCaller1<TextureBrowser, int, TextureScaleImport> TextureScaleImportCaller;
-
-void TextureScaleExport( TextureBrowser& textureBrowser, const IntImportCallback& importer ){
- switch ( textureBrowser.m_textureScale )
- {
- case 10:
- importer( 0 );
- break;
- case 25:
- importer( 1 );
- break;
- case 50:
- importer( 2 );
- break;
- case 100:
- importer( 3 );
- break;
- case 200:
- importer( 4 );
- break;
+ static void Import(TextureBrowser &self, int value) {
+ switch (value) {
+ case 0:
+ TextureBrowser_setScale(self, 10);
+ break;
+ case 1:
+ TextureBrowser_setScale(self, 25);
+ break;
+ case 2:
+ TextureBrowser_setScale(self, 50);
+ break;
+ case 3:
+ TextureBrowser_setScale(self, 100);
+ break;
+ case 4:
+ TextureBrowser_setScale(self, 200);
+ break;
+ }
}
-}
-typedef ReferenceCaller1<TextureBrowser, const IntImportCallback&, TextureScaleExport> TextureScaleExportCaller;
+};
-void UniformTextureSizeImport( TextureBrowser& textureBrowser, int value ){
- if ( value >= 16 )
- TextureBrowser_setUniformSize( textureBrowser, value );
-}
-typedef ReferenceCaller1<TextureBrowser, int, UniformTextureSizeImport> UniformTextureSizeImportCaller;
+struct UniformTextureSize {
+ static void Export(const TextureBrowser &self, const Callback<void(int)> &returnz) {
+ returnz(g_TextureBrowser.m_uniformTextureSize);
+ }
-void UniformTextureMinSizeImport( TextureBrowser& textureBrowser, int value ){
- if ( value >= 16 )
- TextureBrowser_setUniformMinSize( textureBrowser, value );
-}
-typedef ReferenceCaller1<TextureBrowser, int, UniformTextureMinSizeImport> UniformTextureMinSizeImportCaller;
+ static void Import(TextureBrowser &self, int value) {
+ if (value > 16)
+ TextureBrowser_setUniformSize(self, value);
+ }
+};
+
+struct UniformTextureMinSize {
+ static void Export(const TextureBrowser &self, const Callback<void(int)> &returnz) {
+ returnz(g_TextureBrowser.m_uniformTextureMinSize);
+ }
+
+ static void Import(TextureBrowser &self, int value) {
+ if (value > 16)
+ TextureBrowser_setUniformSize(self, value);
+ }
+};
void TextureBrowser_constructPreferences( PreferencesPage& page ){
page.appendCheckBox(
"", "Texture scrollbar",
- TextureBrowserImportShowScrollbarCaller( GlobalTextureBrowser() ),
- BoolExportCaller( GlobalTextureBrowser().m_showTextureScrollbar )
+ make_property<TextureBrowser_ShowScrollbar>(GlobalTextureBrowser())
);
{
const char* texture_scale[] = { "10%", "25%", "50%", "100%", "200%" };
page.appendCombo(
"Texture Thumbnail Scale",
STRING_ARRAY_RANGE( texture_scale ),
- IntImportCallback( TextureScaleImportCaller( GlobalTextureBrowser() ) ),
- IntExportCallback( TextureScaleExportCaller( GlobalTextureBrowser() ) )
+ make_property<TextureScale>(GlobalTextureBrowser())
);
}
page.appendSpinner( "Thumbnails Max Size", GlobalTextureBrowser().m_uniformTextureSize, GlobalTextureBrowser().m_uniformTextureSize, 16, 8192 );
);
}
}
+
void TextureBrowser_constructPage( PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Texture Browser", "Texture Browser Preferences" ) );
TextureBrowser_constructPreferences( page );
}
+
void TextureBrowser_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, TextureBrowser_constructPage>() );
+ PreferencesDialog_addSettingsPage( makeCallbackF(TextureBrowser_constructPage) );
}
#include "preferencesystem.h"
#include "stringio.h"
-typedef ReferenceCaller1<TextureBrowser, std::size_t, TextureBrowser_setScale> TextureBrowserSetScaleCaller;
-
-
void TextureClipboard_textureSelected( const char* shader );
void TextureBrowser_Construct(){
- GlobalCommands_insert( "ShaderInfo", FreeCaller<TextureBrowser_shaderInfo>() );
- GlobalCommands_insert( "ShowUntagged", FreeCaller<TextureBrowser_showUntagged>() );
- GlobalCommands_insert( "AddTag", FreeCaller<TextureBrowser_addTag>() );
- GlobalCommands_insert( "RenameTag", FreeCaller<TextureBrowser_renameTag>() );
- GlobalCommands_insert( "DeleteTag", FreeCaller<TextureBrowser_deleteTag>() );
- GlobalCommands_insert( "CopyTag", FreeCaller<TextureBrowser_copyTag>() );
- GlobalCommands_insert( "PasteTag", FreeCaller<TextureBrowser_pasteTag>() );
- GlobalCommands_insert( "RefreshShaders", FreeCaller<RefreshShaders>() );
- GlobalToggles_insert( "ShowInUse", FreeCaller<TextureBrowser_ToggleHideUnused>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hideunused_item ), Accelerator( 'U' ) );
- GlobalCommands_insert( "ShowAllTextures", FreeCaller<TextureBrowser_showAll>(), Accelerator( 'A', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "ToggleTextures", FreeCaller<TextureBrowser_toggleShow>(), Accelerator( 'T' ) );
- GlobalToggles_insert( "ToggleShowShaders", FreeCaller<TextureBrowser_ToggleShowShaders>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaders_item ) );
- GlobalToggles_insert( "ToggleShowTextures", FreeCaller<TextureBrowser_ToggleShowTextures>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showtextures_item ) );
- GlobalToggles_insert( "ToggleShowShaderlistOnly", FreeCaller<TextureBrowser_ToggleShowShaderListOnly>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaderlistonly_item ) );
- GlobalToggles_insert( "FixedSize", FreeCaller<TextureBrowser_FixedSize>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_fixedsize_item ) );
- GlobalToggles_insert( "FilterNotex", FreeCaller<TextureBrowser_FilterNotex>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_filternotex_item ) );
- GlobalToggles_insert( "EnableAlpha", FreeCaller<TextureBrowser_EnableAlpha>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_enablealpha_item ) );
-
- GlobalPreferenceSystem().registerPreference( "TextureScale",
- makeSizeStringImportCallback( TextureBrowserSetScaleCaller( g_TextureBrowser ) ),
- SizeExportStringCaller( g_TextureBrowser.m_textureScale )
- );
- GlobalPreferenceSystem().registerPreference( "UniformTextureSize",
- makeIntStringImportCallback(UniformTextureSizeImportCaller(g_TextureBrowser)),
- IntExportStringCaller(g_TextureBrowser.m_uniformTextureSize) );
- GlobalPreferenceSystem().registerPreference( "UniformTextureMinSize",
- makeIntStringImportCallback(UniformTextureMinSizeImportCaller(g_TextureBrowser)),
- IntExportStringCaller(g_TextureBrowser.m_uniformTextureMinSize) );
- GlobalPreferenceSystem().registerPreference( "TextureScrollbar",
- makeBoolStringImportCallback( TextureBrowserImportShowScrollbarCaller( g_TextureBrowser ) ),
- BoolExportStringCaller( GlobalTextureBrowser().m_showTextureScrollbar )
- );
- GlobalPreferenceSystem().registerPreference( "ShowShaders", BoolImportStringCaller( GlobalTextureBrowser().m_showShaders ), BoolExportStringCaller( GlobalTextureBrowser().m_showShaders ) );
- GlobalPreferenceSystem().registerPreference( "ShowTextures", BoolImportStringCaller( GlobalTextureBrowser().m_showTextures ), BoolExportStringCaller( GlobalTextureBrowser().m_showTextures ) );
- GlobalPreferenceSystem().registerPreference( "ShowShaderlistOnly", BoolImportStringCaller( g_TextureBrowser_shaderlistOnly ), BoolExportStringCaller( g_TextureBrowser_shaderlistOnly ) );
- GlobalPreferenceSystem().registerPreference( "FixedSize", BoolImportStringCaller( g_TextureBrowser_fixedSize ), BoolExportStringCaller( g_TextureBrowser_fixedSize ) );
- GlobalPreferenceSystem().registerPreference( "FilterNotex", BoolImportStringCaller( g_TextureBrowser_filterNotex ), BoolExportStringCaller( g_TextureBrowser_filterNotex ) );
- GlobalPreferenceSystem().registerPreference( "EnableAlpha", BoolImportStringCaller( g_TextureBrowser_enableAlpha ), BoolExportStringCaller( g_TextureBrowser_enableAlpha ) );
- GlobalPreferenceSystem().registerPreference( "LoadShaders", IntImportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ), IntExportStringCaller( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ) );
- GlobalPreferenceSystem().registerPreference( "WheelMouseInc", SizeImportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ), SizeExportStringCaller( GlobalTextureBrowser().m_mouseWheelScrollIncrement ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors0", Vector3ImportStringCaller( GlobalTextureBrowser().color_textureback ), Vector3ExportStringCaller( GlobalTextureBrowser().color_textureback ) );
- GlobalPreferenceSystem().registerPreference( "HideNonShadersInCommon", BoolImportStringCaller( GlobalTextureBrowser().m_hideNonShadersInCommon ), BoolExportStringCaller( GlobalTextureBrowser().m_hideNonShadersInCommon ) );
+ GlobalCommands_insert( "ShaderInfo", makeCallbackF(TextureBrowser_shaderInfo) );
+ GlobalCommands_insert( "ShowUntagged", makeCallbackF(TextureBrowser_showUntagged) );
+ GlobalCommands_insert( "AddTag", makeCallbackF(TextureBrowser_addTag) );
+ GlobalCommands_insert( "RenameTag", makeCallbackF(TextureBrowser_renameTag) );
+ GlobalCommands_insert( "DeleteTag", makeCallbackF(TextureBrowser_deleteTag) );
+ GlobalCommands_insert( "CopyTag", makeCallbackF(TextureBrowser_copyTag) );
+ GlobalCommands_insert( "PasteTag", makeCallbackF(TextureBrowser_pasteTag) );
+ GlobalCommands_insert( "RefreshShaders", makeCallbackF(VFS_Refresh) );
+ GlobalToggles_insert( "ShowInUse", makeCallbackF(TextureBrowser_ToggleHideUnused), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hideunused_item ), Accelerator( 'U' ) );
+ GlobalCommands_insert( "ShowAllTextures", makeCallbackF(TextureBrowser_showAll), Accelerator( 'A', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "ToggleTextures", makeCallbackF(TextureBrowser_toggleShow), Accelerator( 'T' ) );
+ GlobalToggles_insert( "ToggleShowShaders", makeCallbackF(TextureBrowser_ToggleShowShaders), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaders_item ) );
+ GlobalToggles_insert( "ToggleShowTextures", makeCallbackF(TextureBrowser_ToggleShowTextures), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showtextures_item ) );
+ GlobalToggles_insert( "ToggleShowShaderlistOnly", makeCallbackF(TextureBrowser_ToggleShowShaderListOnly),
+ ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaderlistonly_item ) );
+ GlobalToggles_insert( "FixedSize", makeCallbackF(TextureBrowser_FixedSize), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_fixedsize_item ) );
+ GlobalToggles_insert( "FilterMissing", makeCallbackF(TextureBrowser_FilterMissing), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_filternotex_item ) );
+ GlobalToggles_insert( "FilterFallback", makeCallbackF(TextureBrowser_FilterFallback), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hidenotex_item ) );
+ GlobalToggles_insert( "EnableAlpha", makeCallbackF(TextureBrowser_EnableAlpha), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_enablealpha_item ) );
+
+ GlobalPreferenceSystem().registerPreference( "TextureScale", make_property_string<TextureScale>(g_TextureBrowser) );
+ GlobalPreferenceSystem().registerPreference( "UniformTextureSize", make_property_string<UniformTextureSize>(g_TextureBrowser) );
+ GlobalPreferenceSystem().registerPreference( "UniformTextureMinSize", make_property_string<UniformTextureMinSize>(g_TextureBrowser) );
+ GlobalPreferenceSystem().registerPreference( "TextureScrollbar", make_property_string<TextureBrowser_ShowScrollbar>(GlobalTextureBrowser()));
+ GlobalPreferenceSystem().registerPreference( "ShowShaders", make_property_string( GlobalTextureBrowser().m_showShaders ) );
+ GlobalPreferenceSystem().registerPreference( "ShowTextures", make_property_string( GlobalTextureBrowser().m_showTextures ) );
+ GlobalPreferenceSystem().registerPreference( "ShowShaderlistOnly", make_property_string( g_TextureBrowser_shaderlistOnly ) );
+ GlobalPreferenceSystem().registerPreference( "FixedSize", make_property_string( g_TextureBrowser_fixedSize ) );
+ GlobalPreferenceSystem().registerPreference( "FilterMissing", make_property_string( g_TextureBrowser_filterMissing ) );
+ GlobalPreferenceSystem().registerPreference( "EnableAlpha", make_property_string( g_TextureBrowser_enableAlpha ) );
+ GlobalPreferenceSystem().registerPreference( "LoadShaders", make_property_string( reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ) ) );
+ GlobalPreferenceSystem().registerPreference( "WheelMouseInc", make_property_string( GlobalTextureBrowser().m_mouseWheelScrollIncrement ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors0", make_property_string( GlobalTextureBrowser().color_textureback ) );
+ GlobalPreferenceSystem().registerPreference( "HideNonShadersInCommon", make_property_string( GlobalTextureBrowser().m_hideNonShadersInCommon ) );
g_TextureBrowser.shader = texdef_name_default();
- Textures_setModeChangedNotify( ReferenceCaller<TextureBrowser, TextureBrowser_queueDraw>( g_TextureBrowser ) );
+ Textures_setModeChangedNotify( ReferenceCaller<TextureBrowser, void(), TextureBrowser_queueDraw>( g_TextureBrowser ) );
TextureBrowser_registerPreferencesPage();
TextureBrowser_textureSelected = TextureClipboard_textureSelected;
}
+
void TextureBrowser_Destroy(){
GlobalShaderSystem().detach( g_ShadersObserver );
- Textures_setModeChangedNotify( Callback() );
+ Textures_setModeChangedNotify( Callback<void()>() );
}
-GtkWidget* TextureBrowser_getGLWidget(){
+ui::Widget TextureBrowser_getGLWidget(){
return GlobalTextureBrowser().m_gl_widget;
}
#if !defined( INCLUDED_TEXWINDOW_H )
#define INCLUDED_TEXWINDOW_H
+#include <uilib/uilib.h>
+#include "property.h"
#include "math/vector.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
#include "signal/signalfwd.h"
#include "xml/xmltextags.h"
-typedef struct _GtkWidget GtkWidget;
-
class TextureBrowser;
TextureBrowser& GlobalTextureBrowser();
-typedef struct _GtkWindow GtkWindow;
-GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel );
+ui::Widget TextureBrowser_constructWindow( ui::Window toplevel );
void TextureBrowser_destroyWindow();
void TextureBrowser_Construct();
void TextureBrowser_Destroy();
-typedef Callback1<const char*> StringImportCallback;
-template<typename FirstArgument, void( *func ) (FirstArgument)>
-class FreeCaller1;
-
-extern GtkWidget* g_page_textures;
-void TextureBrowser_exportTitle( const StringImportCallback& importer );
-typedef FreeCaller1<const StringImportCallback&, TextureBrowser_exportTitle> TextureBrowserExportTitleCaller;
+extern ui::Widget g_page_textures;
+void TextureBrowser_exportTitle( const Callback<void(const char *)> & importer );
+typedef FreeCaller<void(const Callback<void(const char *)> &), TextureBrowser_exportTitle> TextureBrowserExportTitleCaller;
const Vector3& TextureBrowser_getBackgroundColour( TextureBrowser& textureBrowser );
void TextureBrowser_setBackgroundColour( TextureBrowser& textureBrowser, const Vector3& colour );
void TextureBrowser_addActiveShadersChangedCallback( const SignalHandler& handler );
void TextureBrowser_addShadersRealiseCallback( const SignalHandler& handler );
-GtkWidget* TextureBrowser_getGLWidget();
+void TextureBrowser_RefreshShaders();
+
+ui::Widget TextureBrowser_getGLWidget();
#endif
*/
#include "timer.h"
+#include "globaldefs.h"
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
#include <windows.h>
-#elif defined( POSIX )
+#elif GDEF_OS_POSIX
#include <time.h>
#include "sys/time.h"
*/
#include "treemodel.h"
+#include "globaldefs.h"
#include "debugging/debugging.h"
#include <map>
-#include <gtk/gtktreemodel.h>
-#include <gtk/gtktreednd.h>
-#include <gtk/gtkmain.h>
+#include <gtk/gtk.h>
+#include <uilib/uilib.h>
#include "iscenegraph.h"
#include "nameable.h"
#include "gtkutil/gtktreestore.h"
template<typename value_type>
-inline void gtk_tree_model_get_pointer( GtkTreeModel* model, GtkTreeIter* iter, gint column, value_type** pointer ){
+inline void gtk_tree_model_get_pointer( ui::TreeModel model, GtkTreeIter* iter, gint column, value_type** pointer ){
GValue value = GValue_default();
gtk_tree_model_get_value( model, iter, column, &value );
*pointer = (value_type*)g_value_get_pointer( &value );
typedef GtkTreeStore GraphTreeModel;
-GtkTreeStore* graph_tree_model_new( graph_type* graph ){
+ui::TreeStore graph_tree_model_new( graph_type* graph ){
return gtk_tree_store_new( 2, G_TYPE_POINTER, G_TYPE_POINTER );
}
bool graph_tree_model_subtree_find_node( GraphTreeModel* model, GtkTreeIter* parent, const scene::Node& node, GtkTreeIter* iter ){
- for ( gboolean success = gtk_tree_model_iter_children( GTK_TREE_MODEL( model ), iter, parent );
+ for ( gboolean success = gtk_tree_model_iter_children( model, iter, parent );
success != FALSE;
- success = gtk_tree_model_iter_next( GTK_TREE_MODEL( model ), iter ) )
+ success = gtk_tree_model_iter_next( model, iter ) )
{
scene::Node* current;
- gtk_tree_model_get_pointer( GTK_TREE_MODEL( model ), iter, 0, ¤t );
+ gtk_tree_model_get_pointer( model, iter, 0, ¤t );
if ( current == node ) {
return true;
}
return true;
}
-void node_attach_name_changed_callback( scene::Node& node, const Callback& callback ){
+void node_attach_name_changed_callback( scene::Node& node, const Callback<void()>& callback ){
if ( node != 0 ) {
Nameable* nameable = Node_getNameable( node );
if ( nameable != 0 ) {
}
}
}
-void node_detach_name_changed_callback( scene::Node& node, const Callback& callback ){
+void node_detach_name_changed_callback( scene::Node& node, const Callback<void()>& callback ){
if ( node != 0 ) {
Nameable* nameable = Node_getNameable( node );
if ( nameable != 0 ) {
gtk_tree_store_append( GTK_TREE_STORE( model ), &child, parent_pointer );
gtk_tree_store_set( GTK_TREE_STORE( model ), &child, 0, node, 1, selectable, -1 );
- node_attach_name_changed_callback( instance.path().top(), ConstReferenceCaller<scene::Instance, graph_tree_model_row_changed>( instance ) );
+ node_attach_name_changed_callback( instance.path().top(), ConstReferenceCaller<scene::Instance, void(), graph_tree_model_row_changed>( instance ) );
}
void graph_tree_model_row_deleted( GraphTreeModel* model, const scene::Instance& instance ){
GtkTreeIter child;
ASSERT_MESSAGE( graph_tree_model_find_top( model, instance.path(), child ), "RUNTIME ERROR" );
- node_detach_name_changed_callback( instance.path().top(), ConstReferenceCaller<scene::Instance, graph_tree_model_row_changed>( instance ) );
+ node_detach_name_changed_callback( instance.path().top(), ConstReferenceCaller<scene::Instance, void(), graph_tree_model_row_changed>( instance ) );
gtk_tree_store_remove( GTK_TREE_STORE( model ), &child );
}
return GTK_TREE_MODEL_ITERS_PERSIST;
}
-static gint graph_tree_model_get_n_columns( GtkTreeModel* tree_model ){
+static gint graph_tree_model_get_n_columns( ui::TreeModel tree_model ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
GraphTreeModel* graph_tree_model = (GraphTreeModel*) tree_model;
ASSERT_MESSAGE( iter->user_data != 0, "tree model error" );
}
-static GType graph_tree_model_get_column_type( GtkTreeModel *tree_model, gint index ){
+static GType graph_tree_model_get_column_type( ui::TreeModel tree_model, gint index ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
GraphTreeModel *graph_tree_model = (GraphTreeModel *) tree_model;
return G_TYPE_POINTER;
}
-static gboolean graph_tree_model_get_iter( GtkTreeModel* tree_model, GtkTreeIter* iter, GtkTreePath* path ){
+static gboolean graph_tree_model_get_iter( ui::TreeModel tree_model, GtkTreeIter* iter, ui::TreePath path ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
gint* indices = gtk_tree_path_get_indices( path );
gint depth = gtk_tree_path_get_depth( path );
return TRUE;
}
-static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTreeIter* iter ){
+static ui::TreePath graph_tree_model_get_path( ui::TreeModel tree_model, GtkTreeIter* iter ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph;
graph_type::iterator i = graph_iterator_read_tree_iter( iter );
- GtkTreePath* path = gtk_tree_path_new();
+ auto path = ui::TreePath();
for ( std::size_t depth = ( *i ).first.get().size(); depth != 0; --depth )
{
}
-static void graph_tree_model_get_value( GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value ){
+static void graph_tree_model_get_value( ui::TreeModel tree_model, GtkTreeIter *iter, gint column, GValue *value ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
ASSERT_MESSAGE( column == 0 || column == 1, "tree model error" );
}
}
-static gboolean graph_tree_model_iter_next( GtkTreeModel *tree_model, GtkTreeIter *iter ){
+static gboolean graph_tree_model_iter_next( ui::TreeModel tree_model, GtkTreeIter *iter ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph;
graph_type::iterator i = graph_iterator_read_tree_iter( iter );
return TRUE;
}
-static gboolean graph_tree_model_iter_children( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent ){
+static gboolean graph_tree_model_iter_children( ui::TreeModel tree_model, GtkTreeIter *iter, GtkTreeIter *parent ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph;
graph_type::iterator i = ( parent == 0 ) ? graph.begin() : graph_iterator_read_tree_iter( parent );
return FALSE;
}
-static gboolean graph_tree_model_iter_has_child( GtkTreeModel *tree_model, GtkTreeIter *iter ){
+static gboolean graph_tree_model_iter_has_child( ui::TreeModel tree_model, GtkTreeIter *iter ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph;
graph_type::iterator i = graph_iterator_read_tree_iter( iter );
return ++i != graph.end() && ( *i ).first.get().size() == depth;
}
-static gint graph_tree_model_iter_n_children( GtkTreeModel *tree_model, GtkTreeIter *parent ){
+static gint graph_tree_model_iter_n_children( ui::TreeModel tree_model, GtkTreeIter *parent ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph;
graph_type::iterator i = ( parent == 0 ) ? graph.begin() : graph_iterator_read_tree_iter( parent );
return count;
}
-static gboolean graph_tree_model_iter_nth_child( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n ){
+static gboolean graph_tree_model_iter_nth_child( ui::TreeModel tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph;
graph_type::iterator i = ( parent == 0 ) ? graph.begin() : graph_iterator_read_tree_iter( parent );
return FALSE;
}
-static gboolean graph_tree_model_iter_parent( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child ){
+static gboolean graph_tree_model_iter_parent( ui::TreeModel tree_model, GtkTreeIter *iter, GtkTreeIter *child ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
graph_type& graph = *GRAPH_TREE_MODEL( tree_model )->graph;
graph_type::iterator i = graph_iterator_read_tree_iter( child );
iface->iter_parent = graph_tree_model_iter_parent;
}
-static gboolean graph_tree_model_row_draggable( GtkTreeDragSource *drag_source, GtkTreePath *path ){
-#ifdef _DEBUG
+static gboolean graph_tree_model_row_draggable( GtkTreeDragSource *drag_source, ui::TreePath path ){
+#if GDEF_DEBUG
gint depth = gtk_tree_path_get_depth( path );
#endif
return gtk_tree_path_get_depth( path ) > 1;
}
-static gboolean graph_tree_model_drag_data_delete( GtkTreeDragSource *drag_source, GtkTreePath *path ){
+static gboolean graph_tree_model_drag_data_delete( GtkTreeDragSource *drag_source, ui::TreePath path ){
GtkTreeIter iter;
- if ( gtk_tree_model_get_iter( GTK_TREE_MODEL( drag_source ), &iter, path ) ) {
+ if ( gtk_tree_model_get_iter( drag_source, &iter, path ) ) {
graph_type::iterator i = graph_iterator_read_tree_iter( &iter );
Path_deleteTop( ( *i ).first );
return TRUE;
}
}
-static gboolean graph_tree_model_drag_data_get( GtkTreeDragSource *drag_source, GtkTreePath *path, GtkSelectionData *selection_data ){
- if ( gtk_tree_set_row_drag_data( selection_data, GTK_TREE_MODEL( drag_source ), path ) ) {
+static gboolean graph_tree_model_drag_data_get( GtkTreeDragSource *drag_source, ui::TreePath path, GtkSelectionData *selection_data ){
+ if ( gtk_tree_set_row_drag_data( selection_data, drag_source, path ) ) {
return TRUE;
}
else
iface->drag_data_get = graph_tree_model_drag_data_get;
}
-static gboolean graph_tree_model_drag_data_received( GtkTreeDragDest *drag_dest, GtkTreePath *dest, GtkSelectionData *selection_data ){
- GtkTreeModel *tree_model = GTK_TREE_MODEL( drag_dest );
+static gboolean graph_tree_model_drag_data_received( GtkTreeDragDest *drag_dest, ui::TreePath dest, GtkSelectionData *selection_data ){
+ auto tree_model = drag_dest;
GtkTreeModel *src_model = 0;
GtkTreePath *src_path = 0;
return FALSE;
}
-static gboolean graph_tree_model_row_drop_possible( GtkTreeDragDest *drag_dest, GtkTreePath *dest_path, GtkSelectionData *selection_data ){
+static gboolean graph_tree_model_row_drop_possible( GtkTreeDragDest *drag_dest, ui::TreePath dest_path, GtkSelectionData *selection_data ){
gboolean retval = FALSE;
GtkTreeModel *src_model = 0;
GtkTreePath *src_path = 0;
if ( gtk_tree_get_row_drag_data( selection_data, &src_model, &src_path ) != FALSE ) {
/* can only drag to ourselves */
- if ( src_model == GTK_TREE_MODEL( drag_dest ) ) {
+ if ( src_model == drag_dest ) {
/* Can't drop into ourself. */
if ( !gtk_tree_path_is_ancestor( src_path, dest_path ) ) {
/* Can't drop if dest_path's parent doesn't exist */
if ( gtk_tree_path_get_depth( dest_path ) > 1 ) {
- GtkTreePath* tmp = gtk_tree_path_copy( dest_path );
+ auto tmp = gtk_tree_path_copy( dest_path );
gtk_tree_path_up( tmp );
GtkTreeIter iter;
- retval = gtk_tree_model_get_iter( GTK_TREE_MODEL( drag_dest ), &iter, tmp );
+ retval = gtk_tree_model_get_iter( drag_dest, &iter, tmp );
gtk_tree_path_free( tmp );
}
};
void node_attach_name_changed_callback( scene::Node& node, const NameCallback& callback ){
- // line 650: Reference cannot be bound to dereferenced null pointer in well-defined
+ // Reference cannot be bound to dereferenced null pointer in well-defined
// C++ code, and Clang will assume that comparison below always evaluates
// to true, resulting in a segmentation fault. Use a dirty hack to force
// Clang to check those "bad" references for null nonetheless.
GtkTreeIter iter;
graph_iterator_write_tree_iter( i, &iter );
- GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter );
+ auto tree_path = graph_tree_model_get_path( model, &iter );
gint depth = gtk_tree_path_get_depth( tree_path );
gint* indices = gtk_tree_path_get_indices( tree_path );
- gtk_tree_model_row_inserted( GTK_TREE_MODEL( model ), tree_path, &iter );
+ gtk_tree_model_row_inserted( model, tree_path, &iter );
gtk_tree_path_free( tree_path );
}
GtkTreeIter iter;
graph_iterator_write_tree_iter( i, &iter );
- GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter );
+ auto tree_path = graph_tree_model_get_path( model, &iter );
- gtk_tree_model_row_deleted( GTK_TREE_MODEL( model ), tree_path );
+ gtk_tree_model_row_deleted( model, tree_path );
gtk_tree_path_free( tree_path );
}
graph_tree_model_row_inserted( model, i );
- node_attach_name_changed_callback( instance.path().top(), ConstReferenceCaller1<scene::Instance, const char*, graph_tree_model_set_name>( instance ) );
+ node_attach_name_changed_callback( instance.path().top(), ConstReferenceCaller<scene::Instance, void(const char*), graph_tree_model_set_name>( instance ) );
}
void graph_tree_model_erase( GraphTreeModel* model, const scene::Instance& instance ){
- node_detach_name_changed_callback( instance.path().top(), ConstReferenceCaller1<scene::Instance, const char*, graph_tree_model_set_name>( instance ) );
+ node_detach_name_changed_callback( instance.path().top(), ConstReferenceCaller<scene::Instance, void(const char*), graph_tree_model_set_name>( instance ) );
graph_type::iterator i = model->graph->find( PathConstReference( instance.path() ) );
ASSERT_MESSAGE( i != model->graph->end(), "ERROR" );
m_instance.get().setChildSelectedChangedCallback( RowChangedCaller( *this ) );
}
~GraphTreeNode(){
- m_instance.get().setChildSelectedChangedCallback( Callback() );
+ m_instance.get().setChildSelectedChangedCallback( Callback<void()>() );
ASSERT_MESSAGE( empty(), "GraphTreeNode::~GraphTreeNode: memory leak" );
}
void rowChanged(){
graph_tree_model_row_changed( *this );
}
-typedef MemberCaller<GraphTreeNode, &GraphTreeNode::rowChanged> RowChangedCaller;
+typedef MemberCaller<GraphTreeNode, void(), &GraphTreeNode::rowChanged> RowChangedCaller;
};
struct GraphTreeModel
GObjectClass parent_class;
};
-#define GRAPH_TREE_MODEL( p ) ( reinterpret_cast<GraphTreeModel*>( p ) )
-
-static GtkTreeModelFlags graph_tree_model_get_flags( GtkTreeModel* tree_model ){
+static GtkTreeModelFlags graph_tree_model_get_flags( ui::TreeModel tree_model ){
return GTK_TREE_MODEL_ITERS_PERSIST;
}
-static gint graph_tree_model_get_n_columns( GtkTreeModel* tree_model ){
- ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
+static gint graph_tree_model_get_n_columns( ui::TreeModel tree_model ){
+ ASSERT_MESSAGE( tree_model, "RUNTIME ERROR" );
//GraphTreeModel* graph_tree_model = (GraphTreeModel*) tree_model;
return 2;
ASSERT_MESSAGE( iter->user_data != 0, "tree model error" );
}
-static GType graph_tree_model_get_column_type( GtkTreeModel *tree_model, gint index ){
- ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
+static GType graph_tree_model_get_column_type( ui::TreeModel tree_model, gint index ){
+ ASSERT_MESSAGE( tree_model, "RUNTIME ERROR" );
//GraphTreeModel *graph_tree_model = (GraphTreeModel *) tree_model;
return G_TYPE_POINTER;
}
-static gboolean graph_tree_model_get_iter( GtkTreeModel* tree_model, GtkTreeIter* iter, GtkTreePath* path ){
+static gboolean graph_tree_model_get_iter( GraphTreeModel* tree_model, GtkTreeIter* iter, ui::TreePath path ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
gint* indices = gtk_tree_path_get_indices( path );
gint depth = gtk_tree_path_get_depth( path );
g_return_val_if_fail( depth > 0, FALSE );
- GraphTreeNode* graph = GRAPH_TREE_MODEL( tree_model )->m_graph;
+ GraphTreeNode *graph = tree_model->m_graph;
if ( graph->empty() ) {
return FALSE;
for ( gint i = 0; i < depth; i++ )
{
- if ( !gtk_tree_model_iter_nth_child( tree_model, iter, parent, indices[i] ) ) {
+ if ( !gtk_tree_model_iter_nth_child( GTK_TREE_MODEL(tree_model), iter, parent, indices[i] ) ) {
return FALSE;
}
tmp = *iter;
return TRUE;
}
-static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTreeIter* iter ){
- ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
- GraphTreeNode* graph = GRAPH_TREE_MODEL( tree_model )->m_graph;
+static ui::TreePath graph_tree_model_get_path( GraphTreeModel *tree_model, GtkTreeIter* iter ){
+ ASSERT_MESSAGE( tree_model, "RUNTIME ERROR" );
+ GraphTreeNode* graph = tree_model->m_graph;
- GtkTreePath* path = gtk_tree_path_new();
+ auto path = ui::TreePath(ui::New);
for ( GraphTreeNode* node = ( *graph_iterator_read_tree_iter( iter ) ).second; node != graph; node = node->m_parent )
{
}
-static void graph_tree_model_get_value( GtkTreeModel *tree_model, GtkTreeIter *iter, gint column, GValue *value ){
- ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
+static void graph_tree_model_get_value( ui::TreeModel tree_model, GtkTreeIter *iter, gint column, GValue *value ){
+ ASSERT_MESSAGE( tree_model, "RUNTIME ERROR" );
ASSERT_MESSAGE( column == 0 || column == 1, "tree model error" );
GraphTreeNode::iterator i = graph_iterator_read_tree_iter( iter );
}
}
-static gboolean graph_tree_model_iter_next( GtkTreeModel *tree_model, GtkTreeIter *iter ){
- ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
+static gboolean graph_tree_model_iter_next( ui::TreeModel tree_model, GtkTreeIter *iter ){
+ ASSERT_MESSAGE( tree_model, "RUNTIME ERROR" );
GraphTreeNode::iterator i = graph_iterator_read_tree_iter( iter );
GraphTreeNode& parent = *( *i ).second->m_parent;
return TRUE;
}
-static gboolean graph_tree_model_iter_children( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent ){
+static gboolean graph_tree_model_iter_children( GraphTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
- GraphTreeNode& node = ( parent == 0 ) ? *GRAPH_TREE_MODEL( tree_model )->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second;
+ GraphTreeNode& node = ( parent == 0 ) ? *tree_model->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second;
if ( !node.empty() ) {
graph_iterator_write_tree_iter( node.begin(), iter );
return TRUE;
return FALSE;
}
-static gboolean graph_tree_model_iter_has_child( GtkTreeModel *tree_model, GtkTreeIter *iter ){
- ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
+static gboolean graph_tree_model_iter_has_child( ui::TreeModel tree_model, GtkTreeIter *iter ){
+ ASSERT_MESSAGE( tree_model, "RUNTIME ERROR" );
GraphTreeNode& node = *( *graph_iterator_read_tree_iter( iter ) ).second;
return !node.empty();
}
-static gint graph_tree_model_iter_n_children( GtkTreeModel *tree_model, GtkTreeIter *parent ){
+static gint graph_tree_model_iter_n_children( GraphTreeModel *tree_model, GtkTreeIter *parent ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
- GraphTreeNode& node = ( parent == 0 ) ? *GRAPH_TREE_MODEL( tree_model )->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second;
+ GraphTreeNode& node = ( parent == 0 ) ? *tree_model->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second;
return static_cast<gint>( node.size() );
}
-static gboolean graph_tree_model_iter_nth_child( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n ){
+static gboolean graph_tree_model_iter_nth_child( GraphTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
- GraphTreeNode& node = ( parent == 0 ) ? *GRAPH_TREE_MODEL( tree_model )->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second;
+ GraphTreeNode& node = ( parent == 0 ) ? *tree_model->m_graph : *( *graph_iterator_read_tree_iter( parent ) ).second;
if ( static_cast<std::size_t>( n ) < node.size() ) {
GraphTreeNode::iterator i = node.begin();
std::advance( i, n );
return FALSE;
}
-static gboolean graph_tree_model_iter_parent( GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child ){
+static gboolean graph_tree_model_iter_parent( GraphTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child ){
ASSERT_MESSAGE( tree_model != 0, "RUNTIME ERROR" );
GraphTreeNode& node = *( *graph_iterator_read_tree_iter( child ) ).second;
- if ( node.m_parent != GRAPH_TREE_MODEL( tree_model )->m_graph ) {
+ if ( node.m_parent != tree_model->m_graph ) {
GraphTreeNode& parentParent = *node.m_parent->m_parent;
for ( GraphTreeNode::iterator i = parentParent.begin(); i != parentParent.end(); ++i )
{
}
static void graph_tree_model_finalize( GObject* object ){
- GraphTreeModel* graph_tree_model = GRAPH_TREE_MODEL( object );
+ auto graph_tree_model = reinterpret_cast<GraphTreeModel*>(object);
delete graph_tree_model->m_graph;
}
static void graph_tree_model_tree_model_init( GtkTreeModelIface *iface ){
- iface->get_flags = graph_tree_model_get_flags;
- iface->get_n_columns = graph_tree_model_get_n_columns;
- iface->get_column_type = graph_tree_model_get_column_type;
- iface->get_iter = graph_tree_model_get_iter;
- iface->get_path = graph_tree_model_get_path;
- iface->get_value = graph_tree_model_get_value;
- iface->iter_next = graph_tree_model_iter_next;
- iface->iter_children = graph_tree_model_iter_children;
- iface->iter_has_child = graph_tree_model_iter_has_child;
- iface->iter_n_children = graph_tree_model_iter_n_children;
- iface->iter_nth_child = graph_tree_model_iter_nth_child;
- iface->iter_parent = graph_tree_model_iter_parent;
+ iface->get_flags = reinterpret_cast<GtkTreeModelFlags (*)(GtkTreeModel *)>(graph_tree_model_get_flags);
+ iface->get_n_columns = reinterpret_cast<gint (*)(GtkTreeModel *)>(graph_tree_model_get_n_columns);
+ iface->get_column_type = reinterpret_cast<GType (*)(GtkTreeModel *, gint)>(graph_tree_model_get_column_type);
+ iface->get_iter = reinterpret_cast<gboolean (*)(GtkTreeModel *, GtkTreeIter *, GtkTreePath *)>(graph_tree_model_get_iter);
+ iface->get_path = reinterpret_cast<GtkTreePath *(*)(GtkTreeModel *, GtkTreeIter *)>(graph_tree_model_get_path);
+ iface->get_value = reinterpret_cast<void (*)(GtkTreeModel *, GtkTreeIter *, gint, GValue *)>(graph_tree_model_get_value);
+ iface->iter_next = reinterpret_cast<gboolean (*)(GtkTreeModel *, GtkTreeIter *)>(graph_tree_model_iter_next);
+ iface->iter_children = reinterpret_cast<gboolean (*)(GtkTreeModel *, GtkTreeIter *, GtkTreeIter *)>(graph_tree_model_iter_children);
+ iface->iter_has_child = reinterpret_cast<gboolean (*)(GtkTreeModel *, GtkTreeIter *)>(graph_tree_model_iter_has_child);
+ iface->iter_n_children = reinterpret_cast<gint (*)(GtkTreeModel *, GtkTreeIter *)>(graph_tree_model_iter_n_children);
+ iface->iter_nth_child = reinterpret_cast<gboolean (*)(GtkTreeModel *, GtkTreeIter *, GtkTreeIter *, gint)>(graph_tree_model_iter_nth_child);
+ iface->iter_parent = reinterpret_cast<gboolean (*)(GtkTreeModel *, GtkTreeIter *, GtkTreeIter *)>(graph_tree_model_iter_parent);
}
GType graph_tree_model_get_type( void ){
}
GraphTreeModel* graph_tree_model_new(){
- GraphTreeModel* graph_tree_model = GRAPH_TREE_MODEL( g_object_new( graph_tree_model_get_type(), 0 ) );
+ auto graph_tree_model = reinterpret_cast<GraphTreeModel*>(g_object_new( graph_tree_model_get_type(), 0 ));
return graph_tree_model;
}
GtkTreeIter iter;
graph_iterator_write_tree_iter( i, &iter );
- GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter );
+ auto tree_path = graph_tree_model_get_path(model, &iter );
gtk_tree_model_row_changed( GTK_TREE_MODEL( model ), tree_path, &iter );
GtkTreeIter iter;
graph_iterator_write_tree_iter( i, &iter );
- GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter );
+ auto tree_path = graph_tree_model_get_path(model, &iter );
gtk_tree_model_row_inserted( GTK_TREE_MODEL( model ), tree_path, &iter );
GtkTreeIter iter;
graph_iterator_write_tree_iter( i, &iter );
- GtkTreePath* tree_path = graph_tree_model_get_path( GTK_TREE_MODEL( model ), &iter );
+ auto tree_path = graph_tree_model_get_path(model, &iter );
gtk_tree_model_row_deleted( GTK_TREE_MODEL( model ), tree_path );
GraphTreeModel* scene_graph_get_tree_model(); // temp hack
-void graph_tree_node_foreach_pre( GraphTreeNode::iterator root, const Callback1<GraphTreeNode::iterator>& callback ){
+void graph_tree_node_foreach_pre( GraphTreeNode::iterator root, const Callback<void(GraphTreeNode::iterator)>& callback ){
callback( root );
for ( GraphTreeNode::iterator i = ( *root ).second->begin(); i != ( *root ).second->end(); ++i )
{
}
}
-void graph_tree_node_foreach_post( GraphTreeNode::iterator root, const Callback1<GraphTreeNode::iterator>& callback ){
+void graph_tree_node_foreach_post( GraphTreeNode::iterator root, const Callback<void(GraphTreeNode::iterator)>& callback ){
for ( GraphTreeNode::iterator i = ( *root ).second->begin(); i != ( *root ).second->end(); ++i )
{
graph_tree_node_foreach_post( i, callback );
GraphTreeNode* parent = graph_tree_model_find_parent( model, instance.path() );
GraphTreeNode::iterator oldNode = parent->find( GraphTreeNode::key_type( node_get_name_safe( instance.path().top().get() ), instance.path().top().get_pointer() ) );
- graph_tree_node_foreach_post( oldNode, ReferenceCaller1<GraphTreeModel, GraphTreeNode::iterator, graph_tree_model_row_deleted>( *model ) );
+ graph_tree_node_foreach_post( oldNode, ReferenceCaller<GraphTreeModel, void(GraphTreeNode::iterator), graph_tree_model_row_deleted>( *model ) );
GraphTreeNode* node( ( *oldNode ).second );
parent->erase( oldNode );
GraphTreeNode::iterator newNode = parent->insert( GraphTreeNode::value_type( GraphTreeNode::key_type( name, &instance.path().top().get() ), node ) );
- graph_tree_node_foreach_pre( newNode, ReferenceCaller1<GraphTreeModel, GraphTreeNode::iterator, graph_tree_model_row_inserted>( *model ) );
+ graph_tree_node_foreach_pre( newNode, ReferenceCaller<GraphTreeModel, void(GraphTreeNode::iterator), graph_tree_model_row_inserted>( *model ) );
}
void graph_tree_model_insert( GraphTreeModel* model, const scene::Instance& instance ){
graph_tree_model_row_inserted( model, i );
- node_attach_name_changed_callback( instance.path().top(), ConstReferenceCaller1<scene::Instance, const char*, graph_tree_model_set_name>( instance ) );
+ node_attach_name_changed_callback( instance.path().top(), ConstReferenceCaller<scene::Instance, void(const char*), graph_tree_model_set_name>( instance ) );
}
void graph_tree_model_erase( GraphTreeModel* model, const scene::Instance& instance ){
- node_detach_name_changed_callback( instance.path().top(), ConstReferenceCaller1<scene::Instance, const char*, graph_tree_model_set_name>( instance ) );
+ node_detach_name_changed_callback( instance.path().top(), ConstReferenceCaller<scene::Instance, void(const char*), graph_tree_model_set_name>( instance ) );
GraphTreeNode* parent = graph_tree_model_find_parent( model, instance.path() );
rootpath.pop();
rootpath.pop();
- GtkTreeModel* model = GTK_TREE_MODEL( graph_tree_model_new( &graph ) );
+ auto model = graph_tree_model_new( &graph );
{
gint n_columns = gtk_tree_model_get_n_columns( model );
{
GtkTreeIter iter;
- GtkTreePath* path = gtk_tree_path_new_from_string( "0" );
+ auto path = ui::TreePath( "0" );
gtk_tree_model_get_iter( model, &iter, path );
gtk_tree_path_free( path );
{
GtkTreeIter iter;
- GtkTreePath* path = gtk_tree_path_new_from_string( "1" );
+ auto path = ui::TreePath( "1" );
gtk_tree_model_get_iter( model, &iter, path );
gtk_tree_path_free( path );
++i;
graph_iterator_write_tree_iter( i, &iter );
- GtkTreePath* path = gtk_tree_model_get_path( model, &iter );
+ auto path = gtk_tree_model_get_path( model, &iter );
gint depth = gtk_tree_path_get_depth( path );
gint* indices = gtk_tree_path_get_indices( path );
++i;
graph_iterator_write_tree_iter( i, &iter );
- GtkTreePath* path = gtk_tree_model_get_path( model, &iter );
+ auto path = gtk_tree_model_get_path( model, &iter );
gint depth = gtk_tree_path_get_depth( path );
gint* indices = gtk_tree_path_get_indices( path );
class RadiantUndoSystem : public UndoSystem
{
-INTEGER_CONSTANT( MAX_UNDO_LEVELS, 1024 );
+UINT_CONSTANT( MAX_UNDO_LEVELS, 1024 );
class Snapshot
{
void UndoLevels_importString( RadiantUndoSystem& undo, const char* value ){
int levels;
- Int_importString( levels, value );
+ PropertyImpl<int, const char *>::Import( levels, value );
undo.setLevels( levels );
}
-typedef ReferenceCaller1<RadiantUndoSystem, const char*, UndoLevels_importString> UndoLevelsImportStringCaller;
-void UndoLevels_exportString( const RadiantUndoSystem& undo, const StringImportCallback& importer ){
- Int_exportString( static_cast<int>( undo.getLevels() ), importer );
+typedef ReferenceCaller<RadiantUndoSystem, void(const char*), UndoLevels_importString> UndoLevelsImportStringCaller;
+void UndoLevels_exportString( const RadiantUndoSystem& undo, const Callback<void(const char *)> & importer ){
+ PropertyImpl<int, const char *>::Export( static_cast<int>( undo.getLevels() ), importer );
}
-typedef ConstReferenceCaller1<RadiantUndoSystem, const StringImportCallback&, UndoLevels_exportString> UndoLevelsExportStringCaller;
+typedef ConstReferenceCaller<RadiantUndoSystem, void(const Callback<void(const char *)> &), UndoLevels_exportString> UndoLevelsExportStringCaller;
#include "generic/callback.h"
-void UndoLevelsImport( RadiantUndoSystem& self, int value ){
- self.setLevels( value );
-}
-typedef ReferenceCaller1<RadiantUndoSystem, int, UndoLevelsImport> UndoLevelsImportCaller;
-void UndoLevelsExport( const RadiantUndoSystem& self, const IntImportCallback& importCallback ){
- importCallback( static_cast<int>( self.getLevels() ) );
-}
-typedef ConstReferenceCaller1<RadiantUndoSystem, const IntImportCallback&, UndoLevelsExport> UndoLevelsExportCaller;
+struct UndoLevels {
+ static void Export(const RadiantUndoSystem &self, const Callback<void(int)> &returnz) {
+ returnz(static_cast<int>(self.getLevels()));
+ }
+ static void Import(RadiantUndoSystem &self, int value) {
+ self.setLevels(value);
+ }
+};
void Undo_constructPreferences( RadiantUndoSystem& undo, PreferencesPage& page ){
- page.appendSpinner( "Undo Queue Size", 64, 0, 1024, IntImportCallback( UndoLevelsImportCaller( undo ) ), IntExportCallback( UndoLevelsExportCaller( undo ) ) );
+ page.appendSpinner("Undo Queue Size", 64, 0, 1024, make_property<UndoLevels>(undo));
}
void Undo_constructPage( RadiantUndoSystem& undo, PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Undo", "Undo Queue Settings" ) );
Undo_constructPreferences( undo, page );
}
void Undo_registerPreferencesPage( RadiantUndoSystem& undo ){
- PreferencesDialog_addSettingsPage( ReferenceCaller1<RadiantUndoSystem, PreferenceGroup&, Undo_constructPage>( undo ) );
+ PreferencesDialog_addSettingsPage( ReferenceCaller<RadiantUndoSystem, void(PreferenceGroup&), Undo_constructPage>( undo ) );
}
class UndoSystemDependencies : public GlobalPreferenceSystemModuleRef
STRING_CONSTANT( Name, "*" );
UndoSystemAPI(){
- GlobalPreferenceSystem().registerPreference( "UndoLevels", makeIntStringImportCallback( UndoLevelsImportCaller( m_undosystem ) ), makeIntStringExportCallback( UndoLevelsExportCaller( m_undosystem ) ) );
+ GlobalPreferenceSystem().registerPreference("UndoLevels", make_property_string<UndoLevels>(m_undosystem));
Undo_registerPreferencesPage( m_undosystem );
}
*/
#include "url.h"
+#include "globaldefs.h"
#include "mainframe.h"
#include "gtkutil/messagebox.h"
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
+#include <gtk/gtk.h>
#include <gdk/gdkwin32.h>
#include <shellapi.h>
bool open_url( const char* url ){
- return ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", url, 0, 0, SW_SHOW ) > (HINSTANCE)32;
+ return ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "open", url, 0, 0, SW_SHOW ) > (HINSTANCE)32;
}
#endif
-#if defined( __linux__ ) || defined( __FreeBSD__ )
+#if GDEF_OS_LINUX || GDEF_OS_BSD
#include <stdlib.h>
bool open_url( const char* url ){
- // \todo FIXME: the way we open URLs on *nix should be improved. A script is good (see how I do on RTCW)
char command[2 * PATH_MAX];
snprintf( command, sizeof( command ),
- "firefox -remote \"openURL(%s,new-window)\" || firefox \"%s\" &", url, url );
+ "xdg-open \"%s\" &", url );
return system( command ) == 0;
}
#endif
-#ifdef __APPLE__
+#if GDEF_OS_MACOS
#include <stdlib.h>
bool open_url( const char* url ){
char command[2 * PATH_MAX];
// let's put a little comment
globalOutputStream() << "OpenURL: " << url << "\n";
if ( !open_url( url ) ) {
- gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "Failed to launch browser!" );
+ ui::alert( MainFrame_getWindow(), "Failed to launch browser!" );
}
}
#if !defined( INCLUDED_VIEW_H )
#define INCLUDED_VIEW_H
+#include "globaldefs.h"
#include "cullable.h"
#include "math/frustum.h"
-#if defined( _DEBUG )
+#if GDEF_DEBUG
#define DEBUG_CULLING
#endif
// monitoring window for running BSP processes (and possibly various other stuff)
#include "watchbsp.h"
+#include "globaldefs.h"
#include <algorithm>
-#include <gtk/gtkmain.h>
#include "cmdlib.h"
#include "convert.h"
#include <glib.h>
+#include <uilib/uilib.h>
#include "xmlstuff.h"
class CWatchBSP
{
private:
-// a flag we have set to true when using an external BSP plugin
-// the resulting code with that is a bit dirty, cleaner solution would be to seperate the succession of commands from the listening loop
-// (in two seperate classes probably)
-bool m_bBSPPlugin;
-
-// EIdle: we are not listening
-// DoMonitoringLoop will change state to EBeginStep
-// EBeginStep: the socket is up for listening, we are expecting incoming connection
-// incoming connection will change state to EWatching
-// EWatching: we have a connection, monitor it
-// connection closed will see if we start a new step (EBeginStep) or launch Quake3 and end (EIdle)
-enum EWatchBSPState { EIdle, EBeginStep, EWatching } m_eState;
-socket_t *m_pListenSocket;
-socket_t *m_pInSocket;
-netmessage_t msg;
-GPtrArray *m_pCmd;
-// used to timeout EBeginStep
-GTimer *m_pTimer;
-std::size_t m_iCurrentStep;
-// name of the map so we can run the engine
-char *m_sBSPName;
-// buffer we use in push mode to receive data directly from the network
-xmlParserInputBufferPtr m_xmlInputBuffer;
-xmlParserInputPtr m_xmlInput;
-xmlParserCtxtPtr m_xmlParserCtxt;
-// call this to switch the set listening mode
-bool SetupListening();
-// start a new EBeginStep
-void DoEBeginStep();
-// the xml and sax parser state
-char m_xmlBuf[MAX_NETMESSAGE];
-bool m_bNeedCtxtInit;
-message_info_t m_message_info;
+ // a flag we have set to true when using an external BSP plugin
+ // the resulting code with that is a bit dirty, cleaner solution would be to seperate the succession of commands from the listening loop
+ // (in two seperate classes probably)
+ bool m_bBSPPlugin;
+
+ // EIdle: we are not listening
+ // DoMonitoringLoop will change state to EBeginStep
+ // EBeginStep: the socket is up for listening, we are expecting incoming connection
+ // incoming connection will change state to EWatching
+ // EWatching: we have a connection, monitor it
+ // connection closed will see if we start a new step (EBeginStep) or launch Quake3 and end (EIdle)
+ enum EWatchBSPState { EIdle, EBeginStep, EWatching } m_eState;
+ socket_t *m_pListenSocket;
+ socket_t *m_pInSocket;
+ netmessage_t msg;
+ GPtrArray *m_pCmd;
+ // used to timeout EBeginStep
+ GTimer *m_pTimer;
+ std::size_t m_iCurrentStep;
+ // name of the map so we can run the engine
+ char *m_sBSPName;
+ // buffer we use in push mode to receive data directly from the network
+ xmlParserInputBufferPtr m_xmlInputBuffer;
+ xmlParserInputPtr m_xmlInput;
+ xmlParserCtxtPtr m_xmlParserCtxt;
+ // call this to switch the set listening mode
+ bool SetupListening();
+ // start a new EBeginStep
+ void DoEBeginStep();
+ // the xml and sax parser state
+ char m_xmlBuf[MAX_NETMESSAGE];
+ bool m_bNeedCtxtInit;
+ message_info_t m_message_info;
public:
-CWatchBSP(){
- m_pCmd = 0;
- m_bBSPPlugin = false;
- m_pListenSocket = NULL;
- m_pInSocket = NULL;
- m_eState = EIdle;
- m_pTimer = g_timer_new();
- m_sBSPName = NULL;
- m_xmlInputBuffer = NULL;
- m_bNeedCtxtInit = true;
-}
-virtual ~CWatchBSP(){
- EndMonitoringLoop();
- Net_Shutdown();
-
- g_timer_destroy( m_pTimer );
-}
-
-bool HasBSPPlugin() const
-{ return m_bBSPPlugin; }
+ CWatchBSP(){
+ m_pCmd = 0;
+ m_bBSPPlugin = false;
+ m_pListenSocket = NULL;
+ m_pInSocket = NULL;
+ m_eState = EIdle;
+ m_pTimer = g_timer_new();
+ m_sBSPName = NULL;
+ m_xmlInputBuffer = NULL;
+ m_bNeedCtxtInit = true;
+ }
+ virtual ~CWatchBSP(){
+ EndMonitoringLoop();
+ Net_Shutdown();
-// called regularly to keep listening
-void RoutineProcessing();
-// start a monitoring loop with the following steps
-void DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName );
-void EndMonitoringLoop(){
- Reset();
- if ( m_sBSPName ) {
- string_release( m_sBSPName, string_length( m_sBSPName ) );
- m_sBSPName = 0;
+ g_timer_destroy( m_pTimer );
}
- if ( m_pCmd ) {
- g_ptr_array_free( m_pCmd, TRUE );
- m_pCmd = 0;
+
+ bool HasBSPPlugin() const
+ { return m_bBSPPlugin; }
+
+ // called regularly to keep listening
+ void RoutineProcessing();
+ // start a monitoring loop with the following steps
+ void DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName );
+ void EndMonitoringLoop(){
+ Reset();
+ if ( m_sBSPName ) {
+ string_release( m_sBSPName, string_length( m_sBSPName ) );
+ m_sBSPName = 0;
+ }
+ if ( m_pCmd ) {
+ g_ptr_array_free( m_pCmd, TRUE );
+ m_pCmd = 0;
+ }
}
-}
-// close everything - may be called from the outside to abort the process
-void Reset();
-// start a listening loop for an external process, possibly a BSP plugin
-void ExternalListen();
+ // close everything - may be called from the outside to abort the process
+ void Reset();
+ // start a listening loop for an external process, possibly a BSP plugin
+ void ExternalListen();
};
CWatchBSP* g_pWatchBSP;
void Build_constructPreferences( PreferencesPage& page ){
- GtkWidget* monitorbsp = page.appendCheckBox( "", "Enable Build Process Monitoring", g_WatchBSP_Enabled );
- GtkWidget* leakstop = page.appendCheckBox( "", "Stop Compilation on Leak", g_WatchBSP_LeakStop );
- GtkWidget* runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake );
- GtkWidget* sleep = page.appendCheckBox ( "", "Sleep When Running the Engine", g_WatchBSP_DoSleep );
+ ui::CheckButton monitorbsp = page.appendCheckBox( "", "Enable Build Process Monitoring", g_WatchBSP_Enabled );
+ ui::CheckButton leakstop = page.appendCheckBox( "", "Stop Compilation on Leak", g_WatchBSP_LeakStop );
+ ui::CheckButton runengine = page.appendCheckBox( "", "Run Engine After Compile", g_WatchBSP_RunQuake );
+ ui::CheckButton sleep = page.appendCheckBox ( "", "Sleep When Running the Engine", g_WatchBSP_DoSleep );
Widget_connectToggleDependency( leakstop, monitorbsp );
Widget_connectToggleDependency( runengine, monitorbsp );
Widget_connectToggleDependency( sleep, runengine );
Build_constructPreferences( page );
}
void Build_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Build_constructPage>() );
+ PreferencesDialog_addSettingsPage( makeCallbackF(Build_constructPage) );
}
#include "preferencesystem.h"
g_WatchBSP_Enabled = !string_equal( g_pGameDescription->getKeyValue( "no_bsp_monitor" ), "1" );
- GlobalPreferenceSystem().registerPreference( "WatchBSP", BoolImportStringCaller( g_WatchBSP_Enabled ), BoolExportStringCaller( g_WatchBSP_Enabled ) );
- GlobalPreferenceSystem().registerPreference( "RunQuake2Run", BoolImportStringCaller( g_WatchBSP_RunQuake ), BoolExportStringCaller( g_WatchBSP_RunQuake ) );
- GlobalPreferenceSystem().registerPreference( "LeakStop", BoolImportStringCaller( g_WatchBSP_LeakStop ), BoolExportStringCaller( g_WatchBSP_LeakStop ) );
- GlobalPreferenceSystem().registerPreference( "SleepMode", BoolImportStringCaller( g_WatchBSP_DoSleep ), BoolExportStringCaller( g_WatchBSP_DoSleep ) );
+ GlobalPreferenceSystem().registerPreference( "WatchBSP", make_property_string( g_WatchBSP_Enabled ) );
+ GlobalPreferenceSystem().registerPreference( "RunQuake2Run", make_property_string( g_WatchBSP_RunQuake ) );
+ GlobalPreferenceSystem().registerPreference( "LeakStop", make_property_string( g_WatchBSP_LeakStop ) );
+ GlobalPreferenceSystem().registerPreference( "SleepMode", make_property_string( g_WatchBSP_DoSleep ) );
Build_registerPreferencesPage();
}
}
if ( data->recurse == data->stop_depth ) {
message_flush( data );
-#ifdef _DEBUG
+#if GDEF_DEBUG
globalOutputStream() << "Received error msg .. shutting down..\n";
#endif
GetWatchBSP()->EndMonitoringLoop();
class MessageOutputStream : public TextOutputStream
{
-message_info_t* m_data;
+ message_info_t* m_data;
public:
-MessageOutputStream( message_info_t* data ) : m_data( data ){
-}
-std::size_t write( const char* buffer, std::size_t length ){
- if ( m_data->pGeometry != 0 ) {
- m_data->pGeometry->saxCharacters( m_data, reinterpret_cast<const xmlChar*>( buffer ), int(length) );
+ MessageOutputStream( message_info_t* data ) : m_data( data ){
}
- else
- {
- if ( m_data->ignore_depth == 0 ) {
- // output the message using the level
- message_print( m_data, buffer, length );
- // if this message has error level flag, we mark the depth to stop the compilation when we get out
- // we don't set the msg level if we don't stop on leak
- if ( m_data->msg_level == 3 ) {
- m_data->stop_depth = m_data->recurse - 1;
+
+ std::size_t write( const char* buffer, std::size_t length ){
+ if ( m_data->pGeometry != 0 ) {
+ m_data->pGeometry->saxCharacters( m_data, reinterpret_cast<const xmlChar*>( buffer ), int(length) );
+ }
+ else
+ {
+ if ( m_data->ignore_depth == 0 ) {
+ // output the message using the level
+ message_print( m_data, buffer, length );
+ // if this message has error level flag, we mark the depth to stop the compilation when we get out
+ // we don't set the msg level if we don't stop on leak
+ if ( m_data->msg_level == 3 ) {
+ m_data->stop_depth = m_data->recurse - 1;
+ }
}
}
- }
- return length;
-}
+ return length;
+ }
};
template<typename T>
}
m_eState = EIdle;
if ( s_routine_id != 0 ) {
- gtk_timeout_remove( s_routine_id );
+ g_source_remove( s_routine_id );
s_routine_id = 0;
}
}
bool CWatchBSP::SetupListening(){
-#ifdef _DEBUG
+#if GDEF_DEBUG
if ( m_pListenSocket ) {
globalOutputStream() << "ERROR: m_pListenSocket != NULL in CWatchBSP::SetupListening\n";
return false;
if ( SetupListening() == false ) {
const char* msg = "Failed to get a listening socket on port 39000.\nTry running with Build monitoring disabled if you can't fix this.\n";
globalOutputStream() << msg;
- gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg, "Build monitoring", eMB_OK, eMB_ICONERROR );
+ ui::alert( MainFrame_getWindow(), msg, "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
return;
}
// set the timer for timeouts and step cancellation
msg << reinterpret_cast<const char*>( g_ptr_array_index( m_pCmd, m_iCurrentStep ) );
msg << "\nCheck that the file exists and that you don't run out of system resources.\n";
globalOutputStream() << msg.c_str();
- gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg.c_str(), "Build monitoring", eMB_OK, eMB_ICONERROR );
+ ui::alert( MainFrame_getWindow(), msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
return;
}
// re-initialise the debug window
}
}
m_eState = EBeginStep;
- s_routine_id = gtk_timeout_add( 25, watchbsp_routine, this );
+ s_routine_id = g_timeout_add( 25, watchbsp_routine, this );
}
-#if defined( WIN32 )
-#define ENGINE_ATTRIBUTE "engine_win32"
-#define MP_ENGINE_ATTRIBUTE "mp_engine_win32"
-#elif defined( __linux__ ) || defined ( __FreeBSD__ )
-#define ENGINE_ATTRIBUTE "engine_linux"
-#define MP_ENGINE_ATTRIBUTE "mp_engine_linux"
-#elif defined( __APPLE__ )
-#define ENGINE_ATTRIBUTE "engine_macos"
-#define MP_ENGINE_ATTRIBUTE "mp_engine_macos"
+#if GDEF_OS_WINDOWS
+const char *ENGINE_ATTRIBUTE = "engine_win32";
+const char *MP_ENGINE_ATTRIBUTE = "mp_engine_win32";
+#elif GDEF_OS_LINUX || GDEF_OS_BSD
+const char *ENGINE_ATTRIBUTE = "engine_linux";
+const char *MP_ENGINE_ATTRIBUTE = "mp_engine_linux";
+#elif GDEF_OS_MACOS
+const char *ENGINE_ATTRIBUTE = "engine_macos";
+const char *MP_ENGINE_ATTRIBUTE = "mp_engine_macos";
#else
#error "unsupported platform"
#endif
class RunEngineConfiguration
{
public:
-const char* executable;
-const char* mp_executable;
-bool do_sp_mp;
-
-RunEngineConfiguration() :
- executable( g_pGameDescription->getRequiredKeyValue( ENGINE_ATTRIBUTE ) ),
- mp_executable( g_pGameDescription->getKeyValue( MP_ENGINE_ATTRIBUTE ) ){
- do_sp_mp = !string_empty( mp_executable );
-}
+ const char* executable;
+ const char* mp_executable;
+ bool do_sp_mp;
+
+ RunEngineConfiguration() :
+ executable( g_pGameDescription->getRequiredKeyValue( ENGINE_ATTRIBUTE ) ),
+ mp_executable( g_pGameDescription->getKeyValue( MP_ENGINE_ATTRIBUTE ) ){
+ do_sp_mp = !string_empty( mp_executable );
+ }
};
inline void GlobalGameDescription_string_write_mapparameter( StringOutputStream& string, const char* mapname ){
case EBeginStep:
// timeout: if we don't get an incoming connection fast enough, go back to idle
if ( g_timer_elapsed( m_pTimer, NULL ) > g_WatchBSP_Timeout ) {
- gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", eMB_OK );
+ ui::alert( MainFrame_getWindow(), "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", ui::alert_type::OK );
EndMonitoringLoop();
#if 0
if ( m_bBSPPlugin ) {
#endif
return;
}
-#ifdef _DEBUG
+#if GDEF_DEBUG
// some debug checks
if ( !m_pListenSocket ) {
globalErrorStream() << "ERROR: m_pListenSocket == NULL in CWatchBSP::RoutineProcessing EBeginStep state\n";
break;
case EWatching:
{
-#ifdef _DEBUG
+#if GDEF_DEBUG
// some debug checks
if ( !m_pInSocket ) {
globalErrorStream() << "ERROR: m_pInSocket == NULL in CWatchBSP::RoutineProcessing EWatching state\n";
StringOutputStream msg;
msg << "Failed to execute the following command: " << cmd.c_str() << cmdline.c_str();
globalOutputStream() << msg.c_str();
- gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), msg.c_str(), "Build monitoring", eMB_OK, eMB_ICONERROR );
+ ui::alert( MainFrame_getWindow(), msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
}
}
EndMonitoringLoop();
if ( m_eState != EIdle ) {
globalOutputStream() << "WatchBSP got a monitoring request while not idling...\n";
// prompt the user, should we cancel the current process and go ahead?
-// if ( gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?",
-// "Build process monitoring", eMB_YESNO ) == eIDYES ) {
+ if ( ui::alert( MainFrame_getWindow(), "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?",
+ "Build process monitoring", ui::alert_type::YESNO ) == ui::alert_response::YES ) {
// disconnect and set EIdle state
Reset();
-// }
+ }
}
m_pCmd = str_ptr_array_clone( pCmd );
m_iCurrentStep = 0;
#include "windowobservers.h"
#include <vector>
-#include <gdk/gdkevents.h>
+#include <gdk/gdk.h>
#include "generic/bitfield.h"
namespace
#include <gdk/gdkkeysyms.h>
-gboolean selection_modifier_key_press( GtkWidget* widget, GdkEventKey* event, WindowObservers& observers ){
+gboolean selection_modifier_key_press( ui::Widget widget, GdkEventKey* event, WindowObservers& observers ){
switch ( event->keyval )
{
- case GDK_Alt_L:
- case GDK_Alt_R:
+ case GDK_KEY_Alt_L:
+ case GDK_KEY_Alt_R:
//globalOutputStream() << "Alt PRESSED\n";
WindowObservers_OnModifierDown( observers, c_modifierAlt );
break;
- case GDK_Shift_L:
- case GDK_Shift_R:
+ case GDK_KEY_Shift_L:
+ case GDK_KEY_Shift_R:
//globalOutputStream() << "Shift PRESSED\n";
WindowObservers_OnModifierDown( observers, c_modifierShift );
break;
- case GDK_Control_L:
- case GDK_Control_R:
+ case GDK_KEY_Control_L:
+ case GDK_KEY_Control_R:
//globalOutputStream() << "Control PRESSED\n";
WindowObservers_OnModifierDown( observers, c_modifierControl );
break;
return FALSE;
}
-gboolean selection_modifier_key_release( GtkWidget* widget, GdkEventKey* event, WindowObservers& observers ){
+gboolean selection_modifier_key_release( ui::Widget widget, GdkEventKey* event, WindowObservers& observers ){
switch ( event->keyval )
{
- case GDK_Alt_L:
- case GDK_Alt_R:
+ case GDK_KEY_Alt_L:
+ case GDK_KEY_Alt_R:
//globalOutputStream() << "Alt RELEASED\n";
WindowObservers_OnModifierUp( observers, c_modifierAlt );
break;
- case GDK_Shift_L:
- case GDK_Shift_R:
+ case GDK_KEY_Shift_L:
+ case GDK_KEY_Shift_R:
//globalOutputStream() << "Shift RELEASED\n";
WindowObservers_OnModifierUp( observers, c_modifierShift );
break;
- case GDK_Control_L:
- case GDK_Control_R:
+ case GDK_KEY_Control_L:
+ case GDK_KEY_Control_R:
//globalOutputStream() << "Control RELEASED\n";
WindowObservers_OnModifierUp( observers, c_modifierControl );
break;
WindowObservers_UpdateModifier( observers, modifiers, c_modifierControl );
}
-gboolean modifiers_button_press( GtkWidget* widget, GdkEventButton* event, WindowObservers* observers ){
+gboolean modifiers_button_press( ui::Widget widget, GdkEventButton* event, WindowObservers* observers ){
if ( event->type == GDK_BUTTON_PRESS ) {
WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) );
}
return FALSE;
}
-gboolean modifiers_button_release( GtkWidget* widget, GdkEventButton* event, WindowObservers* observers ){
+gboolean modifiers_button_release( ui::Widget widget, GdkEventButton* event, WindowObservers* observers ){
if ( event->type == GDK_BUTTON_RELEASE ) {
WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) );
}
return FALSE;
}
-gboolean modifiers_motion( GtkWidget *widget, GdkEventMotion *event, WindowObservers* observers ){
+gboolean modifiers_motion( ui::Widget widget, GdkEventMotion *event, WindowObservers* observers ){
WindowObservers_UpdateModifiers( *observers, modifiers_for_state( event->state ) );
return FALSE;
}
g_window_observers.push_back( observer );
}
-void GlobalWindowObservers_connectTopLevel( GtkWindow* window ){
- g_signal_connect( G_OBJECT( window ), "key_press_event", G_CALLBACK( selection_modifier_key_press ), &g_window_observers );
- g_signal_connect( G_OBJECT( window ), "key_release_event", G_CALLBACK( selection_modifier_key_release ), &g_window_observers );
+void GlobalWindowObservers_connectTopLevel( ui::Window window ){
+ window.connect( "key_press_event", G_CALLBACK( selection_modifier_key_press ), &g_window_observers );
+ window.connect( "key_release_event", G_CALLBACK( selection_modifier_key_release ), &g_window_observers );
}
-void GlobalWindowObservers_connectWidget( GtkWidget* widget ){
- g_signal_connect( G_OBJECT( widget ), "button_press_event", G_CALLBACK( modifiers_button_press ), &g_window_observers );
- g_signal_connect( G_OBJECT( widget ), "button_release_event", G_CALLBACK( modifiers_button_release ), &g_window_observers );
- g_signal_connect( G_OBJECT( widget ), "motion_notify_event", G_CALLBACK( modifiers_motion ), &g_window_observers );
+void GlobalWindowObservers_connectWidget( ui::Widget widget ){
+ widget.connect( "button_press_event", G_CALLBACK( modifiers_button_press ), &g_window_observers );
+ widget.connect( "button_release_event", G_CALLBACK( modifiers_button_release ), &g_window_observers );
+ widget.connect( "motion_notify_event", G_CALLBACK( modifiers_motion ), &g_window_observers );
+}
+
+ModifierFlags modifiers_for_state(unsigned int state)
+{
+ ModifierFlags modifiers = c_modifierNone;
+ if ( state & GDK_SHIFT_MASK ) {
+ modifiers |= c_modifierShift;
+ }
+ if ( state & GDK_CONTROL_MASK ) {
+ modifiers |= c_modifierControl;
+ }
+ if ( state & GDK_MOD1_MASK ) {
+ modifiers |= c_modifierAlt;
+ }
+ return modifiers;
}
#include "windowobserver.h"
-#include <gdk/gdktypes.h>
+#include <uilib/uilib.h>
#include "math/vector.h"
class WindowObserver;
void GlobalWindowObservers_add( WindowObserver* observer );
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-void GlobalWindowObservers_connectWidget( GtkWidget* widget );
-void GlobalWindowObservers_connectTopLevel( GtkWindow* window );
+void GlobalWindowObservers_connectWidget( ui::Widget widget );
+void GlobalWindowObservers_connectTopLevel( ui::Window window );
inline ButtonIdentifier button_for_button( unsigned int button ){
switch ( button )
return c_buttonInvalid;
}
-inline ModifierFlags modifiers_for_state( unsigned int state ){
- ModifierFlags modifiers = c_modifierNone;
- if ( state & GDK_SHIFT_MASK ) {
- modifiers |= c_modifierShift;
- }
- if ( state & GDK_CONTROL_MASK ) {
- modifiers |= c_modifierControl;
- }
- if ( state & GDK_MOD1_MASK ) {
- modifiers |= c_modifierAlt;
- }
- return modifiers;
-}
+ModifierFlags modifiers_for_state( unsigned int state );
inline WindowVector WindowVector_forDouble( double x, double y ){
return WindowVector( static_cast<float>( x ), static_cast<float>( y ) );
class ISAXHandler
{
public:
-virtual void Release(){
-}
+virtual ~ISAXHandler() = default;
+virtual void Release(){}
virtual void saxStartElement( message_info_t* ctx, const xmlChar* name, const xmlChar** attrs ) = 0;
virtual void saxEndElement( message_info_t* ctx, const xmlChar* name ) = 0;
virtual void saxCharacters( message_info_t* ctx, const xmlChar* ch, int len ) = 0;
#include "xywindow.h"
+#include <gtk/gtk.h>
+
#include "debugging/debugging.h"
#include "ientity.h"
#include "image.h"
#include "gtkutil/messagebox.h"
-#include <gtk/gtklabel.h>
-#include <gtk/gtkmenuitem.h>
+#include <uilib/uilib.h>
+#include <gdk/gdkkeysyms.h>
#include "generic/callback.h"
#include "string/string.h"
bool m_bChaseMouse;
bool m_bSizePaint;
+ bool g_bCrossHairs;
+
xywindow_globals_private_t() :
d_showgrid( true ),
// m_bCamXYUpdate( true ),
m_bChaseMouse( true ),
- m_bSizePaint( true ){
+ m_bSizePaint( true ),
+
+ g_bCrossHairs( false ){
}
};
switch ( button.get() )
{
+ case ButtonEnumeration::INVALID: break;
case ButtonEnumeration::LEFT: buttons |= RAD_LBUTTON; break;
case ButtonEnumeration::MIDDLE: buttons |= RAD_MBUTTON; break;
case ButtonEnumeration::RIGHT: buttons |= RAD_RBUTTON; break;
// =============================================================================
// variables
-bool g_bCrossHairs = false;
-
-GtkMenu* XYWnd::m_mnuDrop = 0;
+ui::Menu XYWnd::m_mnuDrop(ui::null);
// this is disabled, and broken
// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394
unsigned char* img;
const char* filename;
- filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, "Save Image", 0, FILTER_BMP );
+ filename = ui::file_dialog( MainFrame_getWindow( ), FALSE, "Save Image", 0, FILTER_BMP );
if ( !filename ) {
return;
}
Shader* XYWnd::m_state_selected = 0;
void xy_update_xor_rectangle( XYWnd& self, rect_t area ){
- if ( GTK_WIDGET_VISIBLE( self.GetWidget() ) ) {
+ if ( self.GetWidget().visible() ) {
rectangle_t rect = rectangle_from_area( area.min, area.max, self.Width(), self.Height() );
// int nDim1 = ( self.GetViewType() == YZ ) ? 1 : 0;
// int nDim2 = ( self.GetViewType() == XY ) ? 1 : 2;
}
}
-gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){
+gboolean xywnd_button_press( ui::Widget widget, GdkEventButton* event, XYWnd* xywnd ){
if ( event->type == GDK_BUTTON_PRESS ) {
if( !xywnd->Active() ){
g_pParentWnd->SetActiveXY( xywnd );
return FALSE;
}
-gboolean xywnd_button_release( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){
+gboolean xywnd_button_release( ui::Widget widget, GdkEventButton* event, XYWnd* xywnd ){
if ( event->type == GDK_BUTTON_RELEASE ) {
xywnd->XY_MouseUp( static_cast<int>( event->x ), static_cast<int>( event->y ), buttons_for_event_button( event ) );
return FALSE;
}
-gboolean xywnd_focus_in( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){
+gboolean xywnd_focus_in( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){
if ( event->type == GDK_FOCUS_CHANGE ) {
if ( event->in ) {
if( !xywnd->Active() ){
reinterpret_cast<XYWnd*>( data )->XY_MouseMoved( static_cast<int>( x ), static_cast<int>( y ), buttons_for_state( state ) );
}
-gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xywnd ){
+gboolean xywnd_wheel_scroll( ui::Widget widget, GdkEventScroll* event, XYWnd* xywnd ){
if( !xywnd->Active() ){
g_pParentWnd->SetActiveXY( xywnd );
}
return FALSE;
}
-gboolean xywnd_size_allocate( GtkWidget* widget, GtkAllocation* allocation, XYWnd* xywnd ){
+gboolean xywnd_size_allocate( ui::Widget widget, GtkAllocation* allocation, XYWnd* xywnd ){
xywnd->m_nWidth = allocation->width;
xywnd->m_nHeight = allocation->height;
xywnd->updateProjection();
return FALSE;
}
-gboolean xywnd_expose( GtkWidget* widget, GdkEventExpose* event, XYWnd* xywnd ){
+gboolean xywnd_expose( ui::Widget widget, GdkEventExpose* event, XYWnd* xywnd ){
if ( glwidget_make_current( xywnd->GetWidget() ) != FALSE ) {
if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) {
GlobalOpenGL_debugAssertNoErrors();
XYWnd::XYWnd() :
m_gl_widget( glwidget_new( FALSE ) ),
- m_deferredDraw( WidgetQueueDrawCaller( *m_gl_widget ) ),
+ m_deferredDraw( WidgetQueueDrawCaller( m_gl_widget ) ),
m_deferred_motion( xywnd_motion, this ),
- m_parent( 0 ),
+ m_parent( ui::null ),
m_window_observer( NewWindowObserver() ),
m_XORRectangle( m_gl_widget ),
m_chasemouse_handler( 0 ){
m_entityCreate = false;
- m_mnuDrop = 0;
+ m_mnuDrop = ui::Menu(ui::null);
GlobalWindowObservers_add( m_window_observer );
GlobalWindowObservers_connectWidget( m_gl_widget );
- m_window_observer->setRectangleDrawCallback( ReferenceCaller1<XYWnd, rect_t, xy_update_xor_rectangle>( *this ) );
+ m_window_observer->setRectangleDrawCallback( ReferenceCaller<XYWnd, void(rect_t), xy_update_xor_rectangle>( *this ) );
m_window_observer->setView( m_view );
- gtk_widget_ref( m_gl_widget );
+ g_object_ref( m_gl_widget._handle );
gtk_widget_set_events( m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK );
- GTK_WIDGET_SET_FLAGS( m_gl_widget, GTK_CAN_FOCUS );
+ gtk_widget_set_can_focus( m_gl_widget, true );
- m_sizeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "size_allocate", G_CALLBACK( xywnd_size_allocate ), this );
- m_exposeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "expose_event", G_CALLBACK( xywnd_expose ), this );
+ m_sizeHandler = m_gl_widget.connect( "size_allocate", G_CALLBACK( xywnd_size_allocate ), this );
+ m_exposeHandler = m_gl_widget.on_render( G_CALLBACK( xywnd_expose ), this );
- g_signal_connect( G_OBJECT( m_gl_widget ), "button_press_event", G_CALLBACK( xywnd_button_press ), this );
- g_signal_connect( G_OBJECT( m_gl_widget ), "button_release_event", G_CALLBACK( xywnd_button_release ), this );
- g_signal_connect( G_OBJECT( m_gl_widget ), "focus_in_event", G_CALLBACK( xywnd_focus_in ), this ); //works only in floating views layout
- g_signal_connect( G_OBJECT( m_gl_widget ), "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &m_deferred_motion );
+ m_gl_widget.connect( "button_press_event", G_CALLBACK( xywnd_button_press ), this );
+ m_gl_widget.connect( "button_release_event", G_CALLBACK( xywnd_button_release ), this );
+ m_gl_widget.connect( "focus_in_event", G_CALLBACK( xywnd_focus_in ), this ); //works only in floating views layout
+ m_gl_widget.connect( "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &m_deferred_motion );
- g_signal_connect( G_OBJECT( m_gl_widget ), "scroll_event", G_CALLBACK( xywnd_wheel_scroll ), this );
+ m_gl_widget.connect( "scroll_event", G_CALLBACK( xywnd_wheel_scroll ), this );
Map_addValidCallback( g_map, DeferredDrawOnMapValidChangedCaller( m_deferredDraw ) );
updateProjection();
updateModelview();
- AddSceneChangeCallback( ReferenceCaller<XYWnd, &XYWnd_Update>( *this ) );
- AddCameraMovedCallback( ReferenceCaller<XYWnd, &XYWnd_CameraMoved>( *this ) );
+ AddSceneChangeCallback( ReferenceCaller<XYWnd, void(), &XYWnd_Update>( *this ) );
+ AddCameraMovedCallback( ReferenceCaller<XYWnd, void(), &XYWnd_CameraMoved>( *this ) );
PressedButtons_connect( g_pressedButtons, m_gl_widget );
XYWnd::~XYWnd(){
onDestroyed();
- if ( m_mnuDrop != 0 ) {
- gtk_widget_destroy( GTK_WIDGET( m_mnuDrop ) );
- m_mnuDrop = 0;
+ if ( m_mnuDrop ) {
+ m_mnuDrop.destroy();
+ m_mnuDrop = ui::Menu(ui::null);
}
g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_sizeHandler );
g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_exposeHandler );
- gtk_widget_unref( m_gl_widget );
+ m_gl_widget.unref();
m_window_observer->release();
}
if ( ClipMode() && GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ) {
GdkCursor *cursor;
cursor = gdk_cursor_new( GDK_CROSSHAIR );
- gdk_window_set_cursor( m_gl_widget->window, cursor );
+ gdk_window_set_cursor( gtk_widget_get_window(m_gl_widget), cursor );
gdk_cursor_unref( cursor );
}
else
{
- gdk_window_set_cursor( m_gl_widget->window, 0 );
+ gdk_window_set_cursor( gtk_widget_get_window(m_gl_widget), 0 );
}
}
"textures/common/caulk" : TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
}
-void entitycreate_activated( GtkWidget* item ){
+void entitycreate_activated( ui::Widget item ){
scene::Node* world_node = Map_FindWorldspawn( g_map );
- const char* entity_name = gtk_label_get_text( GTK_LABEL( GTK_BIN( item )->child ) );
+ const char* entity_name = gtk_label_get_text( GTK_LABEL( gtk_bin_get_child(GTK_BIN( item )) ) );
if ( !( world_node && string_equal( entity_name, "worldspawn" ) ) ) {
g_pParentWnd->ActiveXY()->OnEntityCreate( entity_name );
}
else {
- GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( MainFrame_getWindow() ), "There's already a worldspawn in your map!"
+ GlobalRadiant().m_pfnMessageBox( MainFrame_getWindow(), "There's already a worldspawn in your map!"
"",
"Info",
eMB_OK,
}
}
-void EntityClassMenu_addItem( GtkMenu* menu, const char* name ){
- GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_label( name ) );
- g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( entitycreate_activated ), item );
- gtk_widget_show( GTK_WIDGET( item ) );
+void EntityClassMenu_addItem( ui::Menu menu, const char* name ){
+ auto item = ui::MenuItem( name );
+ item.connect( "activate", G_CALLBACK( entitycreate_activated ), item );
+ item.show();
menu_add_item( menu, item );
}
class EntityClassMenuInserter : public EntityClassVisitor
{
-typedef std::pair<GtkMenu*, CopiedString> MenuPair;
+typedef std::pair<ui::Menu, CopiedString> MenuPair;
typedef std::vector<MenuPair> MenuStack;
MenuStack m_stack;
CopiedString m_previous;
public:
-EntityClassMenuInserter( GtkMenu* menu ){
+EntityClassMenuInserter( ui::Menu menu ){
m_stack.reserve( 2 );
m_stack.push_back( MenuPair( menu, "" ) );
}
m_previous = e->name();
}
void pushMenu( const CopiedString& name ){
- GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_label( name.c_str() ) );
- gtk_widget_show( GTK_WIDGET( item ) );
- container_add_widget( GTK_CONTAINER( m_stack.back().first ), GTK_WIDGET( item ) );
+ auto item = ui::MenuItem( name.c_str() );
+ item.show();
+ m_stack.back().first.add(item);
- GtkMenu* submenu = GTK_MENU( gtk_menu_new() );
- gtk_menu_item_set_submenu( item, GTK_WIDGET( submenu ) );
+ auto submenu = ui::Menu(ui::New);
+ gtk_menu_item_set_submenu( item, submenu );
m_stack.push_back( MenuPair( submenu, name ) );
}
// return;
// }
- if ( m_mnuDrop == 0 ) { // first time, load it up
- GtkMenu* menu = m_mnuDrop = GTK_MENU( gtk_menu_new() );
+ if ( !m_mnuDrop ) { // first time, load it up
+ auto menu = m_mnuDrop = ui::Menu(ui::New);
EntityClassMenuInserter inserter( menu );
GlobalEntityClassManager().forEach( inserter );
reinterpret_cast<XYWnd*>( data )->Scroll( -x, y );
}
-gboolean XYWnd_Move_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){
+gboolean XYWnd_Move_focusOut( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){
xywnd->Move_End();
return FALSE;
}
Move_End();
}
m_move_started = true;
- g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_moveDelta, this );
- m_move_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this );
+ g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_moveDelta, this );
+ m_move_focusOut = m_gl_widget.connect( "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this );
}
void XYWnd::Move_End(){
m_move_started = false;
- g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), false );
+ g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), false );
g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_move_focusOut );
}
}
}
-gboolean XYWnd_Zoom_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){
+gboolean XYWnd_Zoom_focusOut( ui::Widget widget, GdkEventFocus* event, XYWnd* xywnd ){
xywnd->Zoom_End();
return FALSE;
}
}
m_zoom_started = true;
g_dragZoom = 0;
- g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this );
- m_zoom_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this );
+ g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this );
+ m_zoom_focusOut = m_gl_widget.connect( "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this );
}
void XYWnd::Zoom_End(){
m_zoom_started = false;
- g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), false );
+ g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), false );
g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut );
}
m_viewType = viewType;
updateModelview();
- if ( m_parent != 0 ) {
+ if ( m_parent ) {
gtk_window_set_title( m_parent, ViewType_getTitle( m_viewType ) );
}
}
<< " z:: " << FloatFormat( m_mousePosition[2], 6, 1 );
g_pParentWnd->SetStatusText( g_pParentWnd->m_position_status, status.c_str() );
- if ( g_bCrossHairs ) {
+ if ( g_xywindow_globals_private.g_bCrossHairs ) {
XYWnd_Update( *this );
}
void WXY_BackgroundSelect( void ){
bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0;
if ( !brushesSelected ) {
- gtk_MessageBox( 0, "You have to select some brushes to get the bounding box for.\n",
- "No selection", eMB_OK, eMB_ICONERROR );
+ ui::alert( ui::root, "You have to select some brushes to get the bounding box for.\n",
+ "No selection", ui::alert_type::OK, ui::alert_icon::Error );
return;
}
- const char *filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, "Background Image", NULL, NULL );
+ const char *filename = MainFrame_getWindow().file_dialog( TRUE, "Background Image", NULL, NULL );
g_pParentWnd->ActiveXY()->XY_DisableBackground();
if ( filename ) {
g_pParentWnd->ActiveXY()->XY_LoadBackgroundImage( filename );
m_state_stack.back().m_state = state;
}
}
-const EStyle getStyle() const {
+EStyle getStyle() const {
return eWireframeOnly;
}
void PushState(){
PaintSizeInfo( nDim1, nDim2, min, max );
}
- if ( g_bCrossHairs ) {
+ if ( g_xywindow_globals_private.g_bCrossHairs ) {
glColor4f( 0.2f, 0.9f, 0.2f, 0.8f );
glBegin( GL_LINES );
if ( m_viewType == XY ) {
+void ToggleShowCrosshair(){
+ g_xywindow_globals_private.g_bCrossHairs ^= 1;
+ XY_UpdateAllWindows();
+}
+
+void ToggleShowSizeInfo(){
+ g_xywindow_globals_private.m_bSizePaint = !g_xywindow_globals_private.m_bSizePaint;
+ XY_UpdateAllWindows();
+}
+
+void ToggleShowGrid(){
+ g_xywindow_globals_private.d_showgrid = !g_xywindow_globals_private.d_showgrid;
+ XY_UpdateAllWindows();
+}
+
ToggleShown g_xy_top_shown( true );
-void XY_Top_Shown_Construct( GtkWindow* parent ){
- g_xy_top_shown.connect( GTK_WIDGET( parent ) );
+void XY_Top_Shown_Construct( ui::Window parent ){
+ g_xy_top_shown.connect( parent );
}
ToggleShown g_yz_side_shown( false );
-void YZ_Side_Shown_Construct( GtkWindow* parent ){
- g_yz_side_shown.connect( GTK_WIDGET( parent ) );
+void YZ_Side_Shown_Construct( ui::Window parent ){
+ g_yz_side_shown.connect( parent );
}
ToggleShown g_xz_front_shown( false );
-void XZ_Front_Shown_Construct( GtkWindow* parent ){
- g_xz_front_shown.connect( GTK_WIDGET( parent ) );
+void XZ_Front_Shown_Construct( ui::Window parent ){
+ g_xz_front_shown.connect( parent );
}
}
void unrealise(){
if ( ++m_unrealised == 1 ) {
- if ( XYWnd::m_mnuDrop != 0 ) {
- gtk_widget_destroy( GTK_WIDGET( XYWnd::m_mnuDrop ) );
- XYWnd::m_mnuDrop = 0;
+ if ( XYWnd::m_mnuDrop ) {
+ XYWnd::m_mnuDrop.destroy();
+ XYWnd::m_mnuDrop = ui::Menu(ui::null);
}
}
}
-
-void ShowNamesExport( const BoolImportCallback& importer ){
- importer( GlobalEntityCreator().getShowNames() );
-}
-typedef FreeCaller1<const BoolImportCallback&, ShowNamesExport> ShowNamesExportCaller;
-ShowNamesExportCaller g_show_names_caller;
-ToggleItem g_show_names( g_show_names_caller );
+// Names
void ShowNamesToggle(){
GlobalEntityCreator().setShowNames( !GlobalEntityCreator().getShowNames() );
- g_show_names.update();
XY_UpdateAllWindows();
}
-void ShowAnglesExport( const BoolImportCallback& importer ){
- importer( GlobalEntityCreator().getShowAngles() );
+typedef FreeCaller<void(), ShowNamesToggle> ShowNamesToggleCaller;
+
+void ShowNamesExport( const Callback<void(bool)> & importer ){
+ importer( GlobalEntityCreator().getShowNames() );
}
-typedef FreeCaller1<const BoolImportCallback&, ShowAnglesExport> ShowAnglesExportCaller;
-ShowAnglesExportCaller g_show_angles_caller;
-ToggleItem g_show_angles( g_show_angles_caller );
+
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowNamesExport> ShowNamesExportCaller;
+
+// Angles
void ShowAnglesToggle(){
GlobalEntityCreator().setShowAngles( !GlobalEntityCreator().getShowAngles() );
- g_show_angles.update();
XY_UpdateAllWindows();
}
-BoolExportCaller g_show_blocks_caller( g_xywindow_globals_private.show_blocks );
-ToggleItem g_show_blocks( g_show_blocks_caller );
+typedef FreeCaller<void(), ShowAnglesToggle> ShowAnglesToggleCaller;
+
+void ShowAnglesExport( const Callback<void(bool)> & importer ){
+ importer( GlobalEntityCreator().getShowAngles() );
+}
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowAnglesExport> ShowAnglesExportCaller;
+
+// Blocks
void ShowBlocksToggle(){
g_xywindow_globals_private.show_blocks ^= 1;
- g_show_blocks.update();
XY_UpdateAllWindows();
}
-BoolExportCaller g_show_coordinates_caller( g_xywindow_globals_private.show_coordinates );
-ToggleItem g_show_coordinates( g_show_coordinates_caller );
+typedef FreeCaller<void(), ShowBlocksToggle> ShowBlocksToggleCaller;
+
+void ShowBlocksExport( const Callback<void(bool)> & importer ){
+ importer( g_xywindow_globals_private.show_blocks );
+}
+
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowBlocksExport> ShowBlocksExportCaller;
+
+// Coordinates
void ShowCoordinatesToggle(){
g_xywindow_globals_private.show_coordinates ^= 1;
- g_show_coordinates.update();
XY_UpdateAllWindows();
}
-BoolExportCaller g_show_outline_caller( g_xywindow_globals_private.show_outline );
-ToggleItem g_show_outline( g_show_outline_caller );
+typedef FreeCaller<void(), ShowCoordinatesToggle> ShowCoordinatesToggleCaller;
+
+void ShowCoordinatesExport( const Callback<void(bool)> & importer ){
+ importer( g_xywindow_globals_private.show_coordinates );
+}
+
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowCoordinatesExport> ShowCoordinatesExportCaller;
+
+// Outlines
void ShowOutlineToggle(){
g_xywindow_globals_private.show_outline ^= 1;
- g_show_outline.update();
XY_UpdateAllWindows();
}
-BoolExportCaller g_show_axes_caller( g_xywindow_globals_private.show_axis );
-ToggleItem g_show_axes( g_show_axes_caller );
+typedef FreeCaller<void(), ShowOutlineToggle> ShowOutlineToggleCaller;
+
+void ShowOutlineExport( const Callback<void(bool)> & importer ){
+ importer( g_xywindow_globals_private.show_outline );
+}
+
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowOutlineExport> ShowOutlineExportCaller;
+
+// Axes
void ShowAxesToggle(){
g_xywindow_globals_private.show_axis ^= 1;
- g_show_axes.update();
XY_UpdateAllWindows();
}
+typedef FreeCaller<void(), ShowAxesToggle> ShowAxesToggleCaller;
+
+void ShowAxesExport( const Callback<void(bool)> & importer ){
+ importer( g_xywindow_globals_private.show_axis );
+}
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowAxesExport> ShowAxesExportCaller;
-BoolExportCaller g_show_workzone_caller( g_xywindow_globals_private.d_show_work );
-ToggleItem g_show_workzone( g_show_workzone_caller );
+// Workzone
void ShowWorkzoneToggle(){
g_xywindow_globals_private.d_show_work ^= 1;
- g_show_workzone.update();
XY_UpdateAllWindows();
}
+typedef FreeCaller<void(), ShowWorkzoneToggle> ShowWorkzoneToggleCaller;
-/*
-void ShowAxesToggle(){
- g_xywindow_globals_private.show_axis ^= 1;
- XY_UpdateAllWindows();
-}
-typedef FreeCaller<ShowAxesToggle> ShowAxesToggleCaller;
-void ShowAxesExport( const BoolImportCallback& importer ){
- importer( g_xywindow_globals_private.show_axis );
+void ShowWorkzoneExport( const Callback<void(bool)> & importer ){
+ importer( g_xywindow_globals_private.d_show_work );
}
-typedef FreeCaller1<const BoolImportCallback&, ShowAxesExport> ShowAxesExportCaller;
-ShowAxesExportCaller g_show_axes_caller;
-BoolExportCallback g_show_axes_callback( g_show_axes_caller );
-ToggleItem g_show_axes( g_show_axes_callback );
-*/
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowWorkzoneExport> ShowWorkzoneExportCaller;
/*
BoolExportCaller g_texdef_movelock_caller( g_brush_texturelock_enabled );
}
*/
-BoolExportCaller g_show_size_caller( g_xywindow_globals_private.m_bSizePaint );
-ToggleItem g_show_size_item( g_show_size_caller );
-void ToggleShowSizeInfo(){
+// Size
+void ShowSizeToggle(){
g_xywindow_globals_private.m_bSizePaint = !g_xywindow_globals_private.m_bSizePaint;
- g_show_size_item.update();
XY_UpdateAllWindows();
}
+typedef FreeCaller<void(), ShowSizeToggle> ShowSizeToggleCaller;
+void ShowSizeExport( const Callback<void(bool)> & importer ){
+ importer( g_xywindow_globals_private.m_bSizePaint );
+}
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowSizeExport> ShowSizeExportCaller;
-BoolExportCaller g_show_crosshair_caller( g_bCrossHairs );
-ToggleItem g_show_crosshair_item( g_show_crosshair_caller );
-void ToggleShowCrosshair(){
- g_bCrossHairs ^= 1;
- g_show_crosshair_item.update();
+// Crosshair
+void ShowCrosshairToggle(){
+ g_xywindow_globals_private.g_bCrossHairs ^= 1;
XY_UpdateAllWindows();
}
+typedef FreeCaller<void(), ShowCrosshairToggle> ShowCrosshairToggleCaller;
+void ShowCrosshairExport( const Callback<void(bool)> & importer ){
+ importer( g_xywindow_globals_private.g_bCrossHairs );
+}
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowCrosshairExport> ShowCrosshairExportCaller;
-BoolExportCaller g_show_grid_caller( g_xywindow_globals_private.d_showgrid );
-ToggleItem g_show_grid_item( g_show_grid_caller );
-void ToggleShowGrid(){
+// Grid
+void ShowGridToggle(){
g_xywindow_globals_private.d_showgrid = !g_xywindow_globals_private.d_showgrid;
- g_show_grid_item.update();
XY_UpdateAllWindows();
}
+typedef FreeCaller<void(), ShowGridToggle> ShowGridToggleCaller;
+void ShowGridTExport( const Callback<void(bool)> & importer ){
+ importer( g_xywindow_globals_private.d_showgrid );
+}
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowSizeExport> ShowGridExportCaller;
+
+
+ShowNamesExportCaller g_show_names_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_names_callback( g_show_names_caller );
+ToggleItem g_show_names( g_show_names_callback );
+
+ShowAnglesExportCaller g_show_angles_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_angles_callback( g_show_angles_caller );
+ToggleItem g_show_angles( g_show_angles_callback );
+
+ShowBlocksExportCaller g_show_blocks_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_blocks_callback( g_show_blocks_caller );
+ToggleItem g_show_blocks( g_show_blocks_callback );
+
+ShowCoordinatesExportCaller g_show_coordinates_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_coordinates_callback( g_show_coordinates_caller );
+ToggleItem g_show_coordinates( g_show_coordinates_callback );
+
+ShowOutlineExportCaller g_show_outline_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_outline_callback( g_show_outline_caller );
+ToggleItem g_show_outline( g_show_outline_callback );
+
+ShowAxesExportCaller g_show_axes_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_axes_callback( g_show_axes_caller );
+ToggleItem g_show_axes( g_show_axes_callback );
+
+ShowWorkzoneExportCaller g_show_workzone_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_workzone_callback( g_show_workzone_caller );
+ToggleItem g_show_workzone( g_show_workzone_callback );
+
+ShowSizeExportCaller g_show_size_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_size_callback( g_show_size_caller );
+ToggleItem g_show_size( g_show_size_callback );
+
+ShowCrosshairExportCaller g_show_crosshair_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_crosshair_callback( g_show_crosshair_caller );
+ToggleItem g_show_crosshair( g_show_crosshair_callback );
+
+ShowGridExportCaller g_show_grid_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_grid_callback( g_show_grid_caller );
+ToggleItem g_show_grid( g_show_grid_callback );
void XYShow_registerCommands(){
- GlobalToggles_insert( "ToggleSizePaint", FreeCaller<ToggleShowSizeInfo>(), ToggleItem::AddCallbackCaller( g_show_size_item ), Accelerator( 'J' ) );
- GlobalToggles_insert( "ToggleCrosshairs", FreeCaller<ToggleShowCrosshair>(), ToggleItem::AddCallbackCaller( g_show_crosshair_item ), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalToggles_insert( "ToggleGrid", FreeCaller<ToggleShowGrid>(), ToggleItem::AddCallbackCaller( g_show_grid_item ), Accelerator( '0' ) );
+ GlobalToggles_insert( "ToggleSizePaint", ShowSizeToggleCaller(), ToggleItem::AddCallbackCaller( g_show_size ), Accelerator( 'J' ) );
+ GlobalToggles_insert( "ToggleCrosshairs", ShowCrosshairToggleCaller(), ToggleItem::AddCallbackCaller( g_show_crosshair ), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalToggles_insert( "ToggleGrid", ShowGridToggleCaller(), ToggleItem::AddCallbackCaller( g_show_grid ), Accelerator( '0' ) );
- GlobalToggles_insert( "ShowAngles", FreeCaller<ShowAnglesToggle>(), ToggleItem::AddCallbackCaller( g_show_angles ) );
- GlobalToggles_insert( "ShowNames", FreeCaller<ShowNamesToggle>(), ToggleItem::AddCallbackCaller( g_show_names ) );
- GlobalToggles_insert( "ShowBlocks", FreeCaller<ShowBlocksToggle>(), ToggleItem::AddCallbackCaller( g_show_blocks ) );
- GlobalToggles_insert( "ShowCoordinates", FreeCaller<ShowCoordinatesToggle>(), ToggleItem::AddCallbackCaller( g_show_coordinates ) );
- GlobalToggles_insert( "ShowWindowOutline", FreeCaller<ShowOutlineToggle>(), ToggleItem::AddCallbackCaller( g_show_outline ) );
- GlobalToggles_insert( "ShowAxes", FreeCaller<ShowAxesToggle>(), ToggleItem::AddCallbackCaller( g_show_axes ) );
- GlobalToggles_insert( "ShowWorkzone", FreeCaller<ShowWorkzoneToggle>(), ToggleItem::AddCallbackCaller( g_show_workzone ) );
+ GlobalToggles_insert( "ShowAngles", ShowAnglesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_angles ) );
+ GlobalToggles_insert( "ShowNames", ShowNamesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_names ) );
+ GlobalToggles_insert( "ShowBlocks", ShowBlocksToggleCaller(), ToggleItem::AddCallbackCaller( g_show_blocks ) );
+ GlobalToggles_insert( "ShowCoordinates", ShowCoordinatesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_coordinates ) );
+ GlobalToggles_insert( "ShowWindowOutline", ShowOutlineToggleCaller(), ToggleItem::AddCallbackCaller( g_show_outline ) );
+ GlobalToggles_insert( "ShowAxes", ShowAxesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_axes ) );
+ GlobalToggles_insert( "ShowWorkzone", ShowWorkzoneToggleCaller(), ToggleItem::AddCallbackCaller( g_show_workzone ) );
}
void XYWnd_registerShortcuts(){
Orthographic_constructPreferences( page );
}
void Orthographic_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Orthographic_constructPage>() );
+ PreferencesDialog_addSettingsPage( makeCallbackF(Orthographic_constructPage) );
}
void Clipper_constructPreferences( PreferencesPage& page ){
Clipper_constructPreferences( page );
}
void Clipper_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Clipper_constructPage>() );
+ PreferencesDialog_addSettingsPage( makeCallbackF(Clipper_constructPage) );
}
#include "stringio.h"
+struct ToggleShown_Bool {
+ static void Export(const ToggleShown &self, const Callback<void(bool)> &returnz) {
+ returnz(self.active());
+ }
-
-void ToggleShown_importBool( ToggleShown& self, bool value ){
- self.set( value );
-}
-typedef ReferenceCaller1<ToggleShown, bool, ToggleShown_importBool> ToggleShownImportBoolCaller;
-void ToggleShown_exportBool( const ToggleShown& self, const BoolImportCallback& importer ){
- importer( self.active() );
-}
-typedef ConstReferenceCaller1<ToggleShown, const BoolImportCallback&, ToggleShown_exportBool> ToggleShownExportBoolCaller;
+ static void Import(ToggleShown &self, bool value) {
+ self.set(value);
+ }
+};
void XYWindow_Construct(){
-// GlobalCommands_insert( "ToggleCrosshairs", FreeCaller<ToggleShowCrosshair>(), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
-// GlobalCommands_insert( "ToggleSizePaint", FreeCaller<ToggleShowSizeInfo>(), Accelerator( 'J' ) );
-// GlobalCommands_insert( "ToggleGrid", FreeCaller<ToggleShowGrid>(), Accelerator( '0' ) );
+// GlobalCommands_insert( "ToggleCrosshairs", makeCallbackF(ToggleShowCrosshair), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
+// GlobalCommands_insert( "ToggleSizePaint", makeCallbackF(ToggleShowSizeInfo), Accelerator( 'J' ) );
+// GlobalCommands_insert( "ToggleGrid", makeCallbackF(ToggleShowGrid), Accelerator( '0' ) );
GlobalToggles_insert( "ToggleView", ToggleShown::ToggleCaller( g_xy_top_shown ), ToggleItem::AddCallbackCaller( g_xy_top_shown.m_item ), Accelerator( 'V', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalToggles_insert( "ToggleSideView", ToggleShown::ToggleCaller( g_yz_side_shown ), ToggleItem::AddCallbackCaller( g_yz_side_shown.m_item ) );
GlobalToggles_insert( "ToggleFrontView", ToggleShown::ToggleCaller( g_xz_front_shown ), ToggleItem::AddCallbackCaller( g_xz_front_shown.m_item ) );
- GlobalCommands_insert( "NextView", FreeCaller<XY_Next>(), Accelerator( GDK_Tab, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "ZoomIn", FreeCaller<XY_ZoomIn>(), Accelerator( GDK_Delete ) );
- GlobalCommands_insert( "ZoomOut", FreeCaller<XY_ZoomOut>(), Accelerator( GDK_Insert ) );
- GlobalCommands_insert( "ViewTop", FreeCaller<XY_Top>(), Accelerator( GDK_KP_Home ) );
- GlobalCommands_insert( "ViewSide", FreeCaller<XY_Side>(), Accelerator( GDK_KP_Page_Down ) );
- GlobalCommands_insert( "ViewFront", FreeCaller<XY_Front>(), Accelerator( GDK_KP_End ) );
- GlobalCommands_insert( "Zoom100", FreeCaller<XY_Zoom100>() );
- GlobalCommands_insert( "CenterXYView", FreeCaller<XY_Focus>(), Accelerator( GDK_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
-
- GlobalPreferenceSystem().registerPreference( "ClipCaulk", BoolImportStringCaller( g_clip_useCaulk ), BoolExportStringCaller( g_clip_useCaulk ) );
-
-// GlobalPreferenceSystem().registerPreference( "NewRightClick", BoolImportStringCaller( g_xywindow_globals.m_bRightClick ), BoolExportStringCaller( g_xywindow_globals.m_bRightClick ) );
- GlobalPreferenceSystem().registerPreference( "ImprovedWheelZoom", BoolImportStringCaller( g_xywindow_globals.m_bImprovedWheelZoom ), BoolExportStringCaller( g_xywindow_globals.m_bImprovedWheelZoom ) );
- GlobalPreferenceSystem().registerPreference( "ChaseMouse", BoolImportStringCaller( g_xywindow_globals_private.m_bChaseMouse ), BoolExportStringCaller( g_xywindow_globals_private.m_bChaseMouse ) );
- GlobalPreferenceSystem().registerPreference( "SizePainting", BoolImportStringCaller( g_xywindow_globals_private.m_bSizePaint ), BoolExportStringCaller( g_xywindow_globals_private.m_bSizePaint ) );
- GlobalPreferenceSystem().registerPreference( "ShowCrosshair", BoolImportStringCaller( g_bCrossHairs ), BoolExportStringCaller( g_bCrossHairs ) );
- GlobalPreferenceSystem().registerPreference( "NoStipple", BoolImportStringCaller( g_xywindow_globals.m_bNoStipple ), BoolExportStringCaller( g_xywindow_globals.m_bNoStipple ) );
- GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", BoolImportStringCaller( g_xywindow_globals_private.show_coordinates ), BoolExportStringCaller( g_xywindow_globals_private.show_coordinates ) );
- GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", BoolImportStringCaller( g_xywindow_globals_private.show_outline ), BoolExportStringCaller( g_xywindow_globals_private.show_outline ) );
- GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", BoolImportStringCaller( g_xywindow_globals_private.show_axis ), BoolExportStringCaller( g_xywindow_globals_private.show_axis ) );
-// GlobalPreferenceSystem().registerPreference( "CamXYUpdate", BoolImportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ), BoolExportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ) );
- GlobalPreferenceSystem().registerPreference( "ShowWorkzone", BoolImportStringCaller( g_xywindow_globals_private.d_show_work ), BoolExportStringCaller( g_xywindow_globals_private.d_show_work ) );
-
- GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", Vector3ImportStringCaller( g_xywindow_globals.AxisColorX ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorX ) );
- GlobalPreferenceSystem().registerPreference( "SI_AxisColors1", Vector3ImportStringCaller( g_xywindow_globals.AxisColorY ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorY ) );
- GlobalPreferenceSystem().registerPreference( "SI_AxisColors2", Vector3ImportStringCaller( g_xywindow_globals.AxisColorZ ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorZ ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors1", Vector3ImportStringCaller( g_xywindow_globals.color_gridback ), Vector3ExportStringCaller( g_xywindow_globals.color_gridback ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors2", Vector3ImportStringCaller( g_xywindow_globals.color_gridminor ), Vector3ExportStringCaller( g_xywindow_globals.color_gridminor ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors3", Vector3ImportStringCaller( g_xywindow_globals.color_gridmajor ), Vector3ExportStringCaller( g_xywindow_globals.color_gridmajor ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors6", Vector3ImportStringCaller( g_xywindow_globals.color_gridblock ), Vector3ExportStringCaller( g_xywindow_globals.color_gridblock ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors7", Vector3ImportStringCaller( g_xywindow_globals.color_gridtext ), Vector3ExportStringCaller( g_xywindow_globals.color_gridtext ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors8", Vector3ImportStringCaller( g_xywindow_globals.color_brushes ), Vector3ExportStringCaller( g_xywindow_globals.color_brushes ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors9", Vector3ImportStringCaller( g_xywindow_globals.color_viewname ), Vector3ExportStringCaller( g_xywindow_globals.color_viewname ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors10", Vector3ImportStringCaller( g_xywindow_globals.color_clipper ), Vector3ExportStringCaller( g_xywindow_globals.color_clipper ) );
- GlobalPreferenceSystem().registerPreference( "SI_Colors11", Vector3ImportStringCaller( g_xywindow_globals.color_selbrushes ), Vector3ExportStringCaller( g_xywindow_globals.color_selbrushes ) );
-
-
- GlobalPreferenceSystem().registerPreference( "XZVIS", makeBoolStringImportCallback( ToggleShownImportBoolCaller( g_xz_front_shown ) ), makeBoolStringExportCallback( ToggleShownExportBoolCaller( g_xz_front_shown ) ) );
- GlobalPreferenceSystem().registerPreference( "YZVIS", makeBoolStringImportCallback( ToggleShownImportBoolCaller( g_yz_side_shown ) ), makeBoolStringExportCallback( ToggleShownExportBoolCaller( g_yz_side_shown ) ) );
+ GlobalCommands_insert( "NextView", makeCallbackF(XY_Next), Accelerator( GDK_KEY_Tab, (GdkModifierType)GDK_CONTROL_MASK ) ); // fixme: doesn't show its shortcut
+ GlobalCommands_insert( "ZoomIn", makeCallbackF(XY_ZoomIn), Accelerator( GDK_KEY_Delete ) );
+ GlobalCommands_insert( "ZoomOut", makeCallbackF(XY_ZoomOut), Accelerator( GDK_KEY_Insert ) );
+ GlobalCommands_insert( "ViewTop", makeCallbackF(XY_Top), Accelerator( GDK_KEY_KP_Home ) );
+ GlobalCommands_insert( "ViewSide", makeCallbackF(XY_Side), Accelerator( GDK_KEY_KP_Page_Down ) );
+ GlobalCommands_insert( "ViewFront", makeCallbackF(XY_Front), Accelerator( GDK_KEY_KP_End ) );
+ GlobalCommands_insert( "Zoom100", makeCallbackF(XY_Zoom100) );
+ GlobalCommands_insert( "CenterXYView", makeCallbackF(XY_Focus), Accelerator( GDK_KEY_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+
+ GlobalPreferenceSystem().registerPreference( "ClipCaulk", make_property_string( g_clip_useCaulk ) );
+
+// GlobalPreferenceSystem().registerPreference( "NewRightClick", make_property_string( g_xywindow_globals.m_bRightClick ) );
+ GlobalPreferenceSystem().registerPreference( "ImprovedWheelZoom", make_property_string( g_xywindow_globals.m_bImprovedWheelZoom ) );
+ GlobalPreferenceSystem().registerPreference( "ChaseMouse", make_property_string( g_xywindow_globals_private.m_bChaseMouse ) );
+ GlobalPreferenceSystem().registerPreference( "SizePainting", make_property_string( g_xywindow_globals_private.m_bSizePaint ) );
+ GlobalPreferenceSystem().registerPreference( "ShowCrosshair", make_property_string( g_xywindow_globals_private.g_bCrossHairs ) );
+ GlobalPreferenceSystem().registerPreference( "NoStipple", make_property_string( g_xywindow_globals.m_bNoStipple ) );
+ GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", make_property_string( g_xywindow_globals_private.show_coordinates ) );
+ GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", make_property_string( g_xywindow_globals_private.show_outline ) );
+ GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", make_property_string( g_xywindow_globals_private.show_axis ) );
+// GlobalPreferenceSystem().registerPreference( "CamXYUpdate", make_property_string( g_xywindow_globals_private.m_bCamXYUpdate ) );
+ GlobalPreferenceSystem().registerPreference( "ShowWorkzone", make_property_string( g_xywindow_globals_private.d_show_work ) );
+
+ GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", make_property_string( g_xywindow_globals.AxisColorX ) );
+ GlobalPreferenceSystem().registerPreference( "SI_AxisColors1", make_property_string( g_xywindow_globals.AxisColorY ) );
+ GlobalPreferenceSystem().registerPreference( "SI_AxisColors2", make_property_string( g_xywindow_globals.AxisColorZ ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors1", make_property_string( g_xywindow_globals.color_gridback ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors2", make_property_string( g_xywindow_globals.color_gridminor ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors3", make_property_string( g_xywindow_globals.color_gridmajor ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors6", make_property_string( g_xywindow_globals.color_gridblock ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors7", make_property_string( g_xywindow_globals.color_gridtext ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors8", make_property_string( g_xywindow_globals.color_brushes ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors9", make_property_string( g_xywindow_globals.color_viewname ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors10", make_property_string( g_xywindow_globals.color_clipper ) );
+ GlobalPreferenceSystem().registerPreference( "SI_Colors11", make_property_string( g_xywindow_globals.color_selbrushes ) );
+
+
+
+
+ GlobalPreferenceSystem().registerPreference( "XZVIS", make_property_string<ToggleShown_Bool>( g_xz_front_shown ) );
+ GlobalPreferenceSystem().registerPreference( "YZVIS", make_property_string<ToggleShown_Bool>( g_yz_side_shown ) );
Orthographic_registerPreferencesPage();
Clipper_registerPreferencesPage();
{
class Node;
}
-typedef struct _GtkWindow GtkWindow;
-typedef struct _GtkMenu GtkMenu;
void FlipClip();
class XYWnd
{
-GtkWidget* m_gl_widget;
+ui::GLArea m_gl_widget;
guint m_sizeHandler;
guint m_exposeHandler;
DeferredDraw m_deferredDraw;
DeferredMotion m_deferred_motion;
public:
-GtkWindow* m_parent;
+ui::Window m_parent;
XYWnd();
~XYWnd();
void queueDraw(){
m_deferredDraw.draw();
}
-GtkWidget* GetWidget(){
+ui::GLArea GetWidget(){
return m_gl_widget;
}
void SetViewType( VIEWTYPE n );
bool m_bActive;
-static GtkMenu* m_mnuDrop;
+static ui::Menu m_mnuDrop;
int m_chasemouse_current_x, m_chasemouse_current_y;
int m_chasemouse_delta_x, m_chasemouse_delta_y;
Signal0 onDestroyed;
Signal3<const WindowVector&, ButtonIdentifier, ModifierFlags> onMouseDown;
void mouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers );
-typedef Member3<XYWnd, const WindowVector&, ButtonIdentifier, ModifierFlags, void, &XYWnd::mouseDown> MouseDownCaller;
+typedef Member<XYWnd, void(const WindowVector&, ButtonIdentifier, ModifierFlags), &XYWnd::mouseDown> MouseDownCaller;
};
inline void XYWnd_Update( XYWnd& xywnd ){
VIEWTYPE GlobalXYWnd_getCurrentViewType();
-typedef struct _GtkWindow GtkWindow;
-void XY_Top_Shown_Construct( GtkWindow* parent );
-void YZ_Side_Shown_Construct( GtkWindow* parent );
-void XZ_Front_Shown_Construct( GtkWindow* parent );
+void XY_Top_Shown_Construct( ui::Window parent );
+void YZ_Side_Shown_Construct( ui::Window parent );
+void XZ_Front_Shown_Construct( ui::Window parent );
void XYWindow_Construct();
void XYWindow_Destroy();
-*3DSMAX_ASCIIEXPORT 200\r
-*COMMENT "Generated by Q3Map2 (ydnar) -convert -format ase"\r
-*SCENE {\r
- *SCENE_FILENAME "wedge_45.bsp"\r
- *SCENE_FIRSTFRAME 0\r
- *SCENE_LASTFRAME 100\r
- *SCENE_FRAMESPEED 30\r
- *SCENE_TICKSPERFRAME 160\r
- *SCENE_BACKGROUND_STATIC 0.0000 0.0000 0.0000\r
- *SCENE_AMBIENT_STATIC 0.0000 0.0000 0.0000\r
-}\r
-*MATERIAL_LIST {\r
- *MATERIAL_COUNT 2\r
- *MATERIAL 0 {\r
- *MATERIAL_NAME "textures/radiant_regression_tests/tile_model"\r
- *MATERIAL_CLASS "Standard"\r
- *MATERIAL_DIFFUSE 1.000000 1.000000 0.833333\r
- *MATERIAL_SHADING Phong\r
- *MAP_DIFFUSE {\r
- *MAP_NAME "textures/radiant_regression_tests/tile_model"\r
- *MAP_CLASS "Bitmap"\r
- *MAP_SUBNO 1\r
- *MAP_AMOUNT 1.0\r
- *MAP_TYPE Screen\r
- *BITMAP "..\textures\radiant_regression_tests\tile_model.tga"\r
- *BITMAP_FILTER Pyramidal\r
- }\r
- }\r
- *MATERIAL 1 {\r
- *MATERIAL_NAME "noshader"\r
- *MATERIAL_CLASS "Standard"\r
- *MATERIAL_DIFFUSE 1.000000 1.000000 1.000000\r
- *MATERIAL_SHADING Phong\r
- *MAP_DIFFUSE {\r
- *MAP_NAME "noshader"\r
- *MAP_CLASS "Bitmap"\r
- *MAP_SUBNO 1\r
- *MAP_AMOUNT 1.0\r
- *MAP_TYPE Screen\r
- *BITMAP "..\noshader.tga"\r
- *BITMAP_FILTER Pyramidal\r
- }\r
- }\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf0"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf0"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 128.000000 0.000000 0.000000\r
- *MESH_VERTEX 1 64.000000 0.000000 64.000000\r
- *MESH_VERTEX 2 128.000000 128.000000 0.000000\r
- *MESH_VERTEX 3 64.000000 128.000000 64.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.707107 0.000000 0.707107\r
- *MESH_FACENORMAL 1 0.707107 0.000000 0.707107\r
- *MESH_VERTEXNORMAL 0 0.707107 0.000000 0.707107\r
- *MESH_VERTEXNORMAL 1 0.707107 0.000000 0.707107\r
- *MESH_VERTEXNORMAL 2 0.707107 0.000000 0.707107\r
- *MESH_VERTEXNORMAL 3 0.707107 0.000000 0.707107\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 1.000000 -1.000000 1.000000\r
- *MESH_TVERT 1 -1.000000 -1.000000 1.000000\r
- *MESH_TVERT 2 1.000000 3.000000 1.000000\r
- *MESH_TVERT 3 -1.000000 3.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf1"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf1"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 0.000000 128.000000 64.000000\r
- *MESH_VERTEX 1 0.000000 128.000000 0.000000\r
- *MESH_VERTEX 2 64.000000 128.000000 64.000000\r
- *MESH_VERTEX 3 128.000000 128.000000 0.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.707107 0.000000 0.707107\r
- *MESH_FACENORMAL 1 0.707107 0.000000 0.707107\r
- *MESH_VERTEXNORMAL 0 0.000000 1.000000 0.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 1.000000 0.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 1.000000 0.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 1.000000 0.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 -2.000000 2.000000 1.000000\r
- *MESH_TVERT 1 -2.000000 0.000000 1.000000\r
- *MESH_TVERT 2 0.000000 2.000000 1.000000\r
- *MESH_TVERT 3 2.000000 0.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf2"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf2"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 64.000000 0.000000 64.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 64.000000\r
- *MESH_VERTEX 2 64.000000 128.000000 64.000000\r
- *MESH_VERTEX 3 0.000000 128.000000 64.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.707107 0.000000 0.707107\r
- *MESH_FACENORMAL 1 0.707107 0.000000 0.707107\r
- *MESH_VERTEXNORMAL 0 0.000000 0.000000 1.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 0.000000 1.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 0.000000 1.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 0.000000 1.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 1.000000 -1.000000 1.000000\r
- *MESH_TVERT 1 -1.000000 -1.000000 1.000000\r
- *MESH_TVERT 2 1.000000 3.000000 1.000000\r
- *MESH_TVERT 3 -1.000000 3.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf3"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf3"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 0.000000 0.000000 64.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 0.000000\r
- *MESH_VERTEX 2 0.000000 128.000000 64.000000\r
- *MESH_VERTEX 3 0.000000 128.000000 0.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.707107 0.000000 0.707107\r
- *MESH_FACENORMAL 1 0.707107 0.000000 0.707107\r
- *MESH_VERTEXNORMAL 0 -1.000000 0.000000 0.000000\r
- *MESH_VERTEXNORMAL 1 -1.000000 0.000000 0.000000\r
- *MESH_VERTEXNORMAL 2 -1.000000 0.000000 0.000000\r
- *MESH_VERTEXNORMAL 3 -1.000000 0.000000 0.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 -2.000000 2.000000 1.000000\r
- *MESH_TVERT 1 -2.000000 0.000000 1.000000\r
- *MESH_TVERT 2 2.000000 2.000000 1.000000\r
- *MESH_TVERT 3 2.000000 0.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf4"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf4"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 128.000000 0.000000 0.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 0.000000\r
- *MESH_VERTEX 2 64.000000 0.000000 64.000000\r
- *MESH_VERTEX 3 0.000000 0.000000 64.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.707107 0.000000 0.707107\r
- *MESH_FACENORMAL 1 0.707107 0.000000 0.707107\r
- *MESH_VERTEXNORMAL 0 0.000000 -1.000000 0.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 -1.000000 0.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 -1.000000 0.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 -1.000000 0.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 2.000000 0.000000 1.000000\r
- *MESH_TVERT 1 -2.000000 0.000000 1.000000\r
- *MESH_TVERT 2 0.000000 2.000000 1.000000\r
- *MESH_TVERT 3 -2.000000 2.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf5"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf5"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 0.000000 128.000000 0.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 0.000000\r
- *MESH_VERTEX 2 128.000000 128.000000 0.000000\r
- *MESH_VERTEX 3 128.000000 0.000000 0.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.707107 0.000000 0.707107\r
- *MESH_FACENORMAL 1 0.707107 0.000000 0.707107\r
- *MESH_VERTEXNORMAL 0 0.000000 0.000000 -1.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 0.000000 -1.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 0.000000 -1.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 0.000000 -1.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 -2.000000 3.000000 1.000000\r
- *MESH_TVERT 1 -2.000000 -1.000000 1.000000\r
- *MESH_TVERT 2 2.000000 3.000000 1.000000\r
- *MESH_TVERT 3 2.000000 -1.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
+*3DSMAX_ASCIIEXPORT 200
+*COMMENT "Generated by Q3Map2 (ydnar) -convert -format ase"
+*SCENE {
+ *SCENE_FILENAME "wedge_45.bsp"
+ *SCENE_FIRSTFRAME 0
+ *SCENE_LASTFRAME 100
+ *SCENE_FRAMESPEED 30
+ *SCENE_TICKSPERFRAME 160
+ *SCENE_BACKGROUND_STATIC 0.0000 0.0000 0.0000
+ *SCENE_AMBIENT_STATIC 0.0000 0.0000 0.0000
+}
+*MATERIAL_LIST {
+ *MATERIAL_COUNT 2
+ *MATERIAL 0 {
+ *MATERIAL_NAME "textures/radiant_regression_tests/tile_model"
+ *MATERIAL_CLASS "Standard"
+ *MATERIAL_DIFFUSE 1.000000 1.000000 0.833333
+ *MATERIAL_SHADING Phong
+ *MAP_DIFFUSE {
+ *MAP_NAME "textures/radiant_regression_tests/tile_model"
+ *MAP_CLASS "Bitmap"
+ *MAP_SUBNO 1
+ *MAP_AMOUNT 1.0
+ *MAP_TYPE Screen
+ *BITMAP "..\textures\radiant_regression_tests\tile_model.tga"
+ *BITMAP_FILTER Pyramidal
+ }
+ }
+ *MATERIAL 1 {
+ *MATERIAL_NAME "noshader"
+ *MATERIAL_CLASS "Standard"
+ *MATERIAL_DIFFUSE 1.000000 1.000000 1.000000
+ *MATERIAL_SHADING Phong
+ *MAP_DIFFUSE {
+ *MAP_NAME "noshader"
+ *MAP_CLASS "Bitmap"
+ *MAP_SUBNO 1
+ *MAP_AMOUNT 1.0
+ *MAP_TYPE Screen
+ *BITMAP "..\noshader.tga"
+ *BITMAP_FILTER Pyramidal
+ }
+ }
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf0"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf0"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 128.000000 0.000000 0.000000
+ *MESH_VERTEX 1 64.000000 0.000000 64.000000
+ *MESH_VERTEX 2 128.000000 128.000000 0.000000
+ *MESH_VERTEX 3 64.000000 128.000000 64.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.707107 0.000000 0.707107
+ *MESH_FACENORMAL 1 0.707107 0.000000 0.707107
+ *MESH_VERTEXNORMAL 0 0.707107 0.000000 0.707107
+ *MESH_VERTEXNORMAL 1 0.707107 0.000000 0.707107
+ *MESH_VERTEXNORMAL 2 0.707107 0.000000 0.707107
+ *MESH_VERTEXNORMAL 3 0.707107 0.000000 0.707107
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 1.000000 -1.000000 1.000000
+ *MESH_TVERT 1 -1.000000 -1.000000 1.000000
+ *MESH_TVERT 2 1.000000 3.000000 1.000000
+ *MESH_TVERT 3 -1.000000 3.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf1"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf1"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 0.000000 128.000000 64.000000
+ *MESH_VERTEX 1 0.000000 128.000000 0.000000
+ *MESH_VERTEX 2 64.000000 128.000000 64.000000
+ *MESH_VERTEX 3 128.000000 128.000000 0.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.707107 0.000000 0.707107
+ *MESH_FACENORMAL 1 0.707107 0.000000 0.707107
+ *MESH_VERTEXNORMAL 0 0.000000 1.000000 0.000000
+ *MESH_VERTEXNORMAL 1 0.000000 1.000000 0.000000
+ *MESH_VERTEXNORMAL 2 0.000000 1.000000 0.000000
+ *MESH_VERTEXNORMAL 3 0.000000 1.000000 0.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 -2.000000 2.000000 1.000000
+ *MESH_TVERT 1 -2.000000 0.000000 1.000000
+ *MESH_TVERT 2 0.000000 2.000000 1.000000
+ *MESH_TVERT 3 2.000000 0.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf2"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf2"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 64.000000 0.000000 64.000000
+ *MESH_VERTEX 1 0.000000 0.000000 64.000000
+ *MESH_VERTEX 2 64.000000 128.000000 64.000000
+ *MESH_VERTEX 3 0.000000 128.000000 64.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.707107 0.000000 0.707107
+ *MESH_FACENORMAL 1 0.707107 0.000000 0.707107
+ *MESH_VERTEXNORMAL 0 0.000000 0.000000 1.000000
+ *MESH_VERTEXNORMAL 1 0.000000 0.000000 1.000000
+ *MESH_VERTEXNORMAL 2 0.000000 0.000000 1.000000
+ *MESH_VERTEXNORMAL 3 0.000000 0.000000 1.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 1.000000 -1.000000 1.000000
+ *MESH_TVERT 1 -1.000000 -1.000000 1.000000
+ *MESH_TVERT 2 1.000000 3.000000 1.000000
+ *MESH_TVERT 3 -1.000000 3.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf3"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf3"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 0.000000 0.000000 64.000000
+ *MESH_VERTEX 1 0.000000 0.000000 0.000000
+ *MESH_VERTEX 2 0.000000 128.000000 64.000000
+ *MESH_VERTEX 3 0.000000 128.000000 0.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.707107 0.000000 0.707107
+ *MESH_FACENORMAL 1 0.707107 0.000000 0.707107
+ *MESH_VERTEXNORMAL 0 -1.000000 0.000000 0.000000
+ *MESH_VERTEXNORMAL 1 -1.000000 0.000000 0.000000
+ *MESH_VERTEXNORMAL 2 -1.000000 0.000000 0.000000
+ *MESH_VERTEXNORMAL 3 -1.000000 0.000000 0.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 -2.000000 2.000000 1.000000
+ *MESH_TVERT 1 -2.000000 0.000000 1.000000
+ *MESH_TVERT 2 2.000000 2.000000 1.000000
+ *MESH_TVERT 3 2.000000 0.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf4"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf4"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 128.000000 0.000000 0.000000
+ *MESH_VERTEX 1 0.000000 0.000000 0.000000
+ *MESH_VERTEX 2 64.000000 0.000000 64.000000
+ *MESH_VERTEX 3 0.000000 0.000000 64.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.707107 0.000000 0.707107
+ *MESH_FACENORMAL 1 0.707107 0.000000 0.707107
+ *MESH_VERTEXNORMAL 0 0.000000 -1.000000 0.000000
+ *MESH_VERTEXNORMAL 1 0.000000 -1.000000 0.000000
+ *MESH_VERTEXNORMAL 2 0.000000 -1.000000 0.000000
+ *MESH_VERTEXNORMAL 3 0.000000 -1.000000 0.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 2.000000 0.000000 1.000000
+ *MESH_TVERT 1 -2.000000 0.000000 1.000000
+ *MESH_TVERT 2 0.000000 2.000000 1.000000
+ *MESH_TVERT 3 -2.000000 2.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf5"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf5"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 0.000000 128.000000 0.000000
+ *MESH_VERTEX 1 0.000000 0.000000 0.000000
+ *MESH_VERTEX 2 128.000000 128.000000 0.000000
+ *MESH_VERTEX 3 128.000000 0.000000 0.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.707107 0.000000 0.707107
+ *MESH_FACENORMAL 1 0.707107 0.000000 0.707107
+ *MESH_VERTEXNORMAL 0 0.000000 0.000000 -1.000000
+ *MESH_VERTEXNORMAL 1 0.000000 0.000000 -1.000000
+ *MESH_VERTEXNORMAL 2 0.000000 0.000000 -1.000000
+ *MESH_VERTEXNORMAL 3 0.000000 0.000000 -1.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 -2.000000 3.000000 1.000000
+ *MESH_TVERT 1 -2.000000 -1.000000 1.000000
+ *MESH_TVERT 2 2.000000 3.000000 1.000000
+ *MESH_TVERT 3 2.000000 -1.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
-*3DSMAX_ASCIIEXPORT 200\r
-*COMMENT "Generated by Q3Map2 (ydnar) -convert -format ase"\r
-*SCENE {\r
- *SCENE_FILENAME "wedge_shallow.bsp"\r
- *SCENE_FIRSTFRAME 0\r
- *SCENE_LASTFRAME 100\r
- *SCENE_FRAMESPEED 30\r
- *SCENE_TICKSPERFRAME 160\r
- *SCENE_BACKGROUND_STATIC 0.0000 0.0000 0.0000\r
- *SCENE_AMBIENT_STATIC 0.0000 0.0000 0.0000\r
-}\r
-*MATERIAL_LIST {\r
- *MATERIAL_COUNT 2\r
- *MATERIAL 0 {\r
- *MATERIAL_NAME "textures/radiant_regression_tests/tile_model"\r
- *MATERIAL_CLASS "Standard"\r
- *MATERIAL_DIFFUSE 1.000000 1.000000 0.833333\r
- *MATERIAL_SHADING Phong\r
- *MAP_DIFFUSE {\r
- *MAP_NAME "textures/radiant_regression_tests/tile_model"\r
- *MAP_CLASS "Bitmap"\r
- *MAP_SUBNO 1\r
- *MAP_AMOUNT 1.0\r
- *MAP_TYPE Screen\r
- *BITMAP "..\textures\radiant_regression_tests\tile_model.tga"\r
- *BITMAP_FILTER Pyramidal\r
- }\r
- }\r
- *MATERIAL 1 {\r
- *MATERIAL_NAME "noshader"\r
- *MATERIAL_CLASS "Standard"\r
- *MATERIAL_DIFFUSE 1.000000 1.000000 1.000000\r
- *MATERIAL_SHADING Phong\r
- *MAP_DIFFUSE {\r
- *MAP_NAME "noshader"\r
- *MAP_CLASS "Bitmap"\r
- *MAP_SUBNO 1\r
- *MAP_AMOUNT 1.0\r
- *MAP_TYPE Screen\r
- *BITMAP "..\noshader.tga"\r
- *BITMAP_FILTER Pyramidal\r
- }\r
- }\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf0"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf0"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 160.000000 0.000000 0.000000\r
- *MESH_VERTEX 1 64.000000 0.000000 64.000000\r
- *MESH_VERTEX 2 160.000000 128.000000 0.000000\r
- *MESH_VERTEX 3 64.000000 128.000000 64.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.554700 0.000000 0.832050\r
- *MESH_FACENORMAL 1 0.554700 0.000000 0.832050\r
- *MESH_VERTEXNORMAL 0 0.554700 0.000000 0.832050\r
- *MESH_VERTEXNORMAL 1 0.554700 0.000000 0.832050\r
- *MESH_VERTEXNORMAL 2 0.554700 0.000000 0.832050\r
- *MESH_VERTEXNORMAL 3 0.554700 0.000000 0.832050\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 2.000000 -1.000000 1.000000\r
- *MESH_TVERT 1 -1.000000 -1.000000 1.000000\r
- *MESH_TVERT 2 2.000000 3.000000 1.000000\r
- *MESH_TVERT 3 -1.000000 3.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf1"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf1"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 0.000000 128.000000 64.000000\r
- *MESH_VERTEX 1 0.000000 128.000000 0.000000\r
- *MESH_VERTEX 2 64.000000 128.000000 64.000000\r
- *MESH_VERTEX 3 160.000000 128.000000 0.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.554700 0.000000 0.832050\r
- *MESH_FACENORMAL 1 0.554700 0.000000 0.832050\r
- *MESH_VERTEXNORMAL 0 0.000000 1.000000 0.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 1.000000 0.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 1.000000 0.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 1.000000 0.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 -2.000000 2.000000 1.000000\r
- *MESH_TVERT 1 -2.000000 0.000000 1.000000\r
- *MESH_TVERT 2 0.000000 2.000000 1.000000\r
- *MESH_TVERT 3 3.000000 0.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf2"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf2"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 64.000000 0.000000 64.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 64.000000\r
- *MESH_VERTEX 2 64.000000 128.000000 64.000000\r
- *MESH_VERTEX 3 0.000000 128.000000 64.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.554700 0.000000 0.832050\r
- *MESH_FACENORMAL 1 0.554700 0.000000 0.832050\r
- *MESH_VERTEXNORMAL 0 0.000000 0.000000 1.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 0.000000 1.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 0.000000 1.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 0.000000 1.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 1.000000 -1.000000 1.000000\r
- *MESH_TVERT 1 -1.000000 -1.000000 1.000000\r
- *MESH_TVERT 2 1.000000 3.000000 1.000000\r
- *MESH_TVERT 3 -1.000000 3.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf3"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf3"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 0.000000 0.000000 64.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 0.000000\r
- *MESH_VERTEX 2 0.000000 128.000000 64.000000\r
- *MESH_VERTEX 3 0.000000 128.000000 0.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.554700 0.000000 0.832050\r
- *MESH_FACENORMAL 1 0.554700 0.000000 0.832050\r
- *MESH_VERTEXNORMAL 0 -1.000000 0.000000 0.000000\r
- *MESH_VERTEXNORMAL 1 -1.000000 0.000000 0.000000\r
- *MESH_VERTEXNORMAL 2 -1.000000 0.000000 0.000000\r
- *MESH_VERTEXNORMAL 3 -1.000000 0.000000 0.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 -2.000000 2.000000 1.000000\r
- *MESH_TVERT 1 -2.000000 0.000000 1.000000\r
- *MESH_TVERT 2 2.000000 2.000000 1.000000\r
- *MESH_TVERT 3 2.000000 0.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf4"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf4"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 160.000000 0.000000 0.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 0.000000\r
- *MESH_VERTEX 2 64.000000 0.000000 64.000000\r
- *MESH_VERTEX 3 0.000000 0.000000 64.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.554700 0.000000 0.832050\r
- *MESH_FACENORMAL 1 0.554700 0.000000 0.832050\r
- *MESH_VERTEXNORMAL 0 0.000000 -1.000000 0.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 -1.000000 0.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 -1.000000 0.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 -1.000000 0.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 3.000000 0.000000 1.000000\r
- *MESH_TVERT 1 -2.000000 0.000000 1.000000\r
- *MESH_TVERT 2 0.000000 2.000000 1.000000\r
- *MESH_TVERT 3 -2.000000 2.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf5"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf5"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 0.000000 128.000000 0.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 0.000000\r
- *MESH_VERTEX 2 160.000000 128.000000 0.000000\r
- *MESH_VERTEX 3 160.000000 0.000000 0.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.554700 0.000000 0.832050\r
- *MESH_FACENORMAL 1 0.554700 0.000000 0.832050\r
- *MESH_VERTEXNORMAL 0 0.000000 0.000000 -1.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 0.000000 -1.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 0.000000 -1.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 0.000000 -1.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 -2.000000 3.000000 1.000000\r
- *MESH_TVERT 1 -2.000000 -1.000000 1.000000\r
- *MESH_TVERT 2 3.000000 3.000000 1.000000\r
- *MESH_TVERT 3 3.000000 -1.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
+*3DSMAX_ASCIIEXPORT 200
+*COMMENT "Generated by Q3Map2 (ydnar) -convert -format ase"
+*SCENE {
+ *SCENE_FILENAME "wedge_shallow.bsp"
+ *SCENE_FIRSTFRAME 0
+ *SCENE_LASTFRAME 100
+ *SCENE_FRAMESPEED 30
+ *SCENE_TICKSPERFRAME 160
+ *SCENE_BACKGROUND_STATIC 0.0000 0.0000 0.0000
+ *SCENE_AMBIENT_STATIC 0.0000 0.0000 0.0000
+}
+*MATERIAL_LIST {
+ *MATERIAL_COUNT 2
+ *MATERIAL 0 {
+ *MATERIAL_NAME "textures/radiant_regression_tests/tile_model"
+ *MATERIAL_CLASS "Standard"
+ *MATERIAL_DIFFUSE 1.000000 1.000000 0.833333
+ *MATERIAL_SHADING Phong
+ *MAP_DIFFUSE {
+ *MAP_NAME "textures/radiant_regression_tests/tile_model"
+ *MAP_CLASS "Bitmap"
+ *MAP_SUBNO 1
+ *MAP_AMOUNT 1.0
+ *MAP_TYPE Screen
+ *BITMAP "..\textures\radiant_regression_tests\tile_model.tga"
+ *BITMAP_FILTER Pyramidal
+ }
+ }
+ *MATERIAL 1 {
+ *MATERIAL_NAME "noshader"
+ *MATERIAL_CLASS "Standard"
+ *MATERIAL_DIFFUSE 1.000000 1.000000 1.000000
+ *MATERIAL_SHADING Phong
+ *MAP_DIFFUSE {
+ *MAP_NAME "noshader"
+ *MAP_CLASS "Bitmap"
+ *MAP_SUBNO 1
+ *MAP_AMOUNT 1.0
+ *MAP_TYPE Screen
+ *BITMAP "..\noshader.tga"
+ *BITMAP_FILTER Pyramidal
+ }
+ }
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf0"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf0"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 160.000000 0.000000 0.000000
+ *MESH_VERTEX 1 64.000000 0.000000 64.000000
+ *MESH_VERTEX 2 160.000000 128.000000 0.000000
+ *MESH_VERTEX 3 64.000000 128.000000 64.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.554700 0.000000 0.832050
+ *MESH_FACENORMAL 1 0.554700 0.000000 0.832050
+ *MESH_VERTEXNORMAL 0 0.554700 0.000000 0.832050
+ *MESH_VERTEXNORMAL 1 0.554700 0.000000 0.832050
+ *MESH_VERTEXNORMAL 2 0.554700 0.000000 0.832050
+ *MESH_VERTEXNORMAL 3 0.554700 0.000000 0.832050
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 2.000000 -1.000000 1.000000
+ *MESH_TVERT 1 -1.000000 -1.000000 1.000000
+ *MESH_TVERT 2 2.000000 3.000000 1.000000
+ *MESH_TVERT 3 -1.000000 3.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf1"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf1"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 0.000000 128.000000 64.000000
+ *MESH_VERTEX 1 0.000000 128.000000 0.000000
+ *MESH_VERTEX 2 64.000000 128.000000 64.000000
+ *MESH_VERTEX 3 160.000000 128.000000 0.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.554700 0.000000 0.832050
+ *MESH_FACENORMAL 1 0.554700 0.000000 0.832050
+ *MESH_VERTEXNORMAL 0 0.000000 1.000000 0.000000
+ *MESH_VERTEXNORMAL 1 0.000000 1.000000 0.000000
+ *MESH_VERTEXNORMAL 2 0.000000 1.000000 0.000000
+ *MESH_VERTEXNORMAL 3 0.000000 1.000000 0.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 -2.000000 2.000000 1.000000
+ *MESH_TVERT 1 -2.000000 0.000000 1.000000
+ *MESH_TVERT 2 0.000000 2.000000 1.000000
+ *MESH_TVERT 3 3.000000 0.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf2"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf2"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 64.000000 0.000000 64.000000
+ *MESH_VERTEX 1 0.000000 0.000000 64.000000
+ *MESH_VERTEX 2 64.000000 128.000000 64.000000
+ *MESH_VERTEX 3 0.000000 128.000000 64.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.554700 0.000000 0.832050
+ *MESH_FACENORMAL 1 0.554700 0.000000 0.832050
+ *MESH_VERTEXNORMAL 0 0.000000 0.000000 1.000000
+ *MESH_VERTEXNORMAL 1 0.000000 0.000000 1.000000
+ *MESH_VERTEXNORMAL 2 0.000000 0.000000 1.000000
+ *MESH_VERTEXNORMAL 3 0.000000 0.000000 1.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 1.000000 -1.000000 1.000000
+ *MESH_TVERT 1 -1.000000 -1.000000 1.000000
+ *MESH_TVERT 2 1.000000 3.000000 1.000000
+ *MESH_TVERT 3 -1.000000 3.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf3"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf3"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 0.000000 0.000000 64.000000
+ *MESH_VERTEX 1 0.000000 0.000000 0.000000
+ *MESH_VERTEX 2 0.000000 128.000000 64.000000
+ *MESH_VERTEX 3 0.000000 128.000000 0.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.554700 0.000000 0.832050
+ *MESH_FACENORMAL 1 0.554700 0.000000 0.832050
+ *MESH_VERTEXNORMAL 0 -1.000000 0.000000 0.000000
+ *MESH_VERTEXNORMAL 1 -1.000000 0.000000 0.000000
+ *MESH_VERTEXNORMAL 2 -1.000000 0.000000 0.000000
+ *MESH_VERTEXNORMAL 3 -1.000000 0.000000 0.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 -2.000000 2.000000 1.000000
+ *MESH_TVERT 1 -2.000000 0.000000 1.000000
+ *MESH_TVERT 2 2.000000 2.000000 1.000000
+ *MESH_TVERT 3 2.000000 0.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf4"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf4"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 160.000000 0.000000 0.000000
+ *MESH_VERTEX 1 0.000000 0.000000 0.000000
+ *MESH_VERTEX 2 64.000000 0.000000 64.000000
+ *MESH_VERTEX 3 0.000000 0.000000 64.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.554700 0.000000 0.832050
+ *MESH_FACENORMAL 1 0.554700 0.000000 0.832050
+ *MESH_VERTEXNORMAL 0 0.000000 -1.000000 0.000000
+ *MESH_VERTEXNORMAL 1 0.000000 -1.000000 0.000000
+ *MESH_VERTEXNORMAL 2 0.000000 -1.000000 0.000000
+ *MESH_VERTEXNORMAL 3 0.000000 -1.000000 0.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 3.000000 0.000000 1.000000
+ *MESH_TVERT 1 -2.000000 0.000000 1.000000
+ *MESH_TVERT 2 0.000000 2.000000 1.000000
+ *MESH_TVERT 3 -2.000000 2.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf5"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf5"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 0.000000 128.000000 0.000000
+ *MESH_VERTEX 1 0.000000 0.000000 0.000000
+ *MESH_VERTEX 2 160.000000 128.000000 0.000000
+ *MESH_VERTEX 3 160.000000 0.000000 0.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.554700 0.000000 0.832050
+ *MESH_FACENORMAL 1 0.554700 0.000000 0.832050
+ *MESH_VERTEXNORMAL 0 0.000000 0.000000 -1.000000
+ *MESH_VERTEXNORMAL 1 0.000000 0.000000 -1.000000
+ *MESH_VERTEXNORMAL 2 0.000000 0.000000 -1.000000
+ *MESH_VERTEXNORMAL 3 0.000000 0.000000 -1.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 -2.000000 3.000000 1.000000
+ *MESH_TVERT 1 -2.000000 -1.000000 1.000000
+ *MESH_TVERT 2 3.000000 3.000000 1.000000
+ *MESH_TVERT 3 3.000000 -1.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
-*3DSMAX_ASCIIEXPORT 200\r
-*COMMENT "Generated by Q3Map2 (ydnar) -convert -format ase"\r
-*SCENE {\r
- *SCENE_FILENAME "wedge_steep.bsp"\r
- *SCENE_FIRSTFRAME 0\r
- *SCENE_LASTFRAME 100\r
- *SCENE_FRAMESPEED 30\r
- *SCENE_TICKSPERFRAME 160\r
- *SCENE_BACKGROUND_STATIC 0.0000 0.0000 0.0000\r
- *SCENE_AMBIENT_STATIC 0.0000 0.0000 0.0000\r
-}\r
-*MATERIAL_LIST {\r
- *MATERIAL_COUNT 2\r
- *MATERIAL 0 {\r
- *MATERIAL_NAME "textures/radiant_regression_tests/tile_model"\r
- *MATERIAL_CLASS "Standard"\r
- *MATERIAL_DIFFUSE 1.000000 1.000000 0.833333\r
- *MATERIAL_SHADING Phong\r
- *MAP_DIFFUSE {\r
- *MAP_NAME "textures/radiant_regression_tests/tile_model"\r
- *MAP_CLASS "Bitmap"\r
- *MAP_SUBNO 1\r
- *MAP_AMOUNT 1.0\r
- *MAP_TYPE Screen\r
- *BITMAP "..\textures\radiant_regression_tests\tile_model.tga"\r
- *BITMAP_FILTER Pyramidal\r
- }\r
- }\r
- *MATERIAL 1 {\r
- *MATERIAL_NAME "noshader"\r
- *MATERIAL_CLASS "Standard"\r
- *MATERIAL_DIFFUSE 1.000000 1.000000 1.000000\r
- *MATERIAL_SHADING Phong\r
- *MAP_DIFFUSE {\r
- *MAP_NAME "noshader"\r
- *MAP_CLASS "Bitmap"\r
- *MAP_SUBNO 1\r
- *MAP_AMOUNT 1.0\r
- *MAP_TYPE Screen\r
- *BITMAP "..\noshader.tga"\r
- *BITMAP_FILTER Pyramidal\r
- }\r
- }\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf0"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf0"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 112.000000 0.000000 0.000000\r
- *MESH_VERTEX 1 64.000000 0.000000 64.000000\r
- *MESH_VERTEX 2 112.000000 128.000000 0.000000\r
- *MESH_VERTEX 3 64.000000 128.000000 64.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.800000 0.000000 0.600000\r
- *MESH_FACENORMAL 1 0.800000 0.000000 0.600000\r
- *MESH_VERTEXNORMAL 0 0.800000 0.000000 0.600000\r
- *MESH_VERTEXNORMAL 1 0.800000 0.000000 0.600000\r
- *MESH_VERTEXNORMAL 2 0.800000 0.000000 0.600000\r
- *MESH_VERTEXNORMAL 3 0.800000 0.000000 0.600000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 -2.000000 0.000000 1.000000\r
- *MESH_TVERT 1 -2.000000 2.000000 1.000000\r
- *MESH_TVERT 2 2.000000 0.000000 1.000000\r
- *MESH_TVERT 3 2.000000 2.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf1"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf1"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 0.000000 128.000000 64.000000\r
- *MESH_VERTEX 1 0.000000 128.000000 0.000000\r
- *MESH_VERTEX 2 64.000000 128.000000 64.000000\r
- *MESH_VERTEX 3 112.000000 128.000000 0.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.800000 0.000000 0.600000\r
- *MESH_FACENORMAL 1 0.800000 0.000000 0.600000\r
- *MESH_VERTEXNORMAL 0 0.000000 1.000000 0.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 1.000000 0.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 1.000000 0.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 1.000000 0.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 -1.000000 2.000000 1.000000\r
- *MESH_TVERT 1 -1.000000 0.000000 1.000000\r
- *MESH_TVERT 2 1.000000 2.000000 1.000000\r
- *MESH_TVERT 3 2.500000 0.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf2"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf2"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 64.000000 0.000000 64.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 64.000000\r
- *MESH_VERTEX 2 64.000000 128.000000 64.000000\r
- *MESH_VERTEX 3 0.000000 128.000000 64.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.800000 0.000000 0.600000\r
- *MESH_FACENORMAL 1 0.800000 0.000000 0.600000\r
- *MESH_VERTEXNORMAL 0 0.000000 0.000000 1.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 0.000000 1.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 0.000000 1.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 0.000000 1.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 1.000000 -1.000000 1.000000\r
- *MESH_TVERT 1 -1.000000 -1.000000 1.000000\r
- *MESH_TVERT 2 1.000000 3.000000 1.000000\r
- *MESH_TVERT 3 -1.000000 3.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf3"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf3"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 0.000000 0.000000 64.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 0.000000\r
- *MESH_VERTEX 2 0.000000 128.000000 64.000000\r
- *MESH_VERTEX 3 0.000000 128.000000 0.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.800000 0.000000 0.600000\r
- *MESH_FACENORMAL 1 0.800000 0.000000 0.600000\r
- *MESH_VERTEXNORMAL 0 -1.000000 0.000000 0.000000\r
- *MESH_VERTEXNORMAL 1 -1.000000 0.000000 0.000000\r
- *MESH_VERTEXNORMAL 2 -1.000000 0.000000 0.000000\r
- *MESH_VERTEXNORMAL 3 -1.000000 0.000000 0.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 -2.000000 2.000000 1.000000\r
- *MESH_TVERT 1 -2.000000 0.000000 1.000000\r
- *MESH_TVERT 2 2.000000 2.000000 1.000000\r
- *MESH_TVERT 3 2.000000 0.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf4"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf4"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 112.000000 0.000000 0.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 0.000000\r
- *MESH_VERTEX 2 64.000000 0.000000 64.000000\r
- *MESH_VERTEX 3 0.000000 0.000000 64.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.800000 0.000000 0.600000\r
- *MESH_FACENORMAL 1 0.800000 0.000000 0.600000\r
- *MESH_VERTEXNORMAL 0 0.000000 -1.000000 0.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 -1.000000 0.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 -1.000000 0.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 -1.000000 0.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 2.500000 0.000000 1.000000\r
- *MESH_TVERT 1 -1.000000 0.000000 1.000000\r
- *MESH_TVERT 2 1.000000 2.000000 1.000000\r
- *MESH_TVERT 3 -1.000000 2.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
-*GEOMOBJECT {\r
- *NODE_NAME "mat0model0surf5"\r
- *NODE_TM {\r
- *NODE_NAME "mat0model0surf5"\r
- *INHERIT_POS 0 0 0\r
- *INHERIT_ROT 0 0 0\r
- *INHERIT_SCL 0 0 0\r
- *TM_ROW0 1.0 0 0\r
- *TM_ROW1 0 1.0 0\r
- *TM_ROW2 0 0 1.0\r
- *TM_ROW3 0 0 0\r
- *TM_POS 0.000000 0.000000 0.000000\r
- }\r
- *MESH {\r
- *TIMEVALUE 0\r
- *MESH_NUMVERTEX 4\r
- *MESH_NUMFACES 2\r
- *COMMENT "SURFACETYPE MST_PLANAR"\r
- *MESH_VERTEX_LIST {\r
- *MESH_VERTEX 0 0.000000 128.000000 0.000000\r
- *MESH_VERTEX 1 0.000000 0.000000 0.000000\r
- *MESH_VERTEX 2 112.000000 128.000000 0.000000\r
- *MESH_VERTEX 3 112.000000 0.000000 0.000000\r
- }\r
- *MESH_NORMALS {\r
- *MESH_FACENORMAL 0 0.800000 0.000000 0.600000\r
- *MESH_FACENORMAL 1 0.800000 0.000000 0.600000\r
- *MESH_VERTEXNORMAL 0 0.000000 0.000000 -1.000000\r
- *MESH_VERTEXNORMAL 1 0.000000 0.000000 -1.000000\r
- *MESH_VERTEXNORMAL 2 0.000000 0.000000 -1.000000\r
- *MESH_VERTEXNORMAL 3 0.000000 0.000000 -1.000000\r
- }\r
- *MESH_FACE_LIST {\r
- *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0\r
- }\r
- *MESH_NUMTVERTEX 4\r
- *MESH_TVERTLIST {\r
- *MESH_TVERT 0 -1.000000 3.000000 1.000000\r
- *MESH_TVERT 1 -1.000000 -1.000000 1.000000\r
- *MESH_TVERT 2 2.500000 3.000000 1.000000\r
- *MESH_TVERT 3 2.500000 -1.000000 1.000000\r
- }\r
- *MESH_NUMTVFACES 2\r
- *MESH_TFACELIST {\r
- *MESH_TFACE 0 0 2 1\r
- *MESH_TFACE 1 2 3 1\r
- }\r
- }\r
- *PROP_MOTIONBLUR 0\r
- *PROP_CASTSHADOW 1\r
- *PROP_RECVSHADOW 1\r
- *MATERIAL_REF 0\r
-}\r
+*3DSMAX_ASCIIEXPORT 200
+*COMMENT "Generated by Q3Map2 (ydnar) -convert -format ase"
+*SCENE {
+ *SCENE_FILENAME "wedge_steep.bsp"
+ *SCENE_FIRSTFRAME 0
+ *SCENE_LASTFRAME 100
+ *SCENE_FRAMESPEED 30
+ *SCENE_TICKSPERFRAME 160
+ *SCENE_BACKGROUND_STATIC 0.0000 0.0000 0.0000
+ *SCENE_AMBIENT_STATIC 0.0000 0.0000 0.0000
+}
+*MATERIAL_LIST {
+ *MATERIAL_COUNT 2
+ *MATERIAL 0 {
+ *MATERIAL_NAME "textures/radiant_regression_tests/tile_model"
+ *MATERIAL_CLASS "Standard"
+ *MATERIAL_DIFFUSE 1.000000 1.000000 0.833333
+ *MATERIAL_SHADING Phong
+ *MAP_DIFFUSE {
+ *MAP_NAME "textures/radiant_regression_tests/tile_model"
+ *MAP_CLASS "Bitmap"
+ *MAP_SUBNO 1
+ *MAP_AMOUNT 1.0
+ *MAP_TYPE Screen
+ *BITMAP "..\textures\radiant_regression_tests\tile_model.tga"
+ *BITMAP_FILTER Pyramidal
+ }
+ }
+ *MATERIAL 1 {
+ *MATERIAL_NAME "noshader"
+ *MATERIAL_CLASS "Standard"
+ *MATERIAL_DIFFUSE 1.000000 1.000000 1.000000
+ *MATERIAL_SHADING Phong
+ *MAP_DIFFUSE {
+ *MAP_NAME "noshader"
+ *MAP_CLASS "Bitmap"
+ *MAP_SUBNO 1
+ *MAP_AMOUNT 1.0
+ *MAP_TYPE Screen
+ *BITMAP "..\noshader.tga"
+ *BITMAP_FILTER Pyramidal
+ }
+ }
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf0"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf0"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 112.000000 0.000000 0.000000
+ *MESH_VERTEX 1 64.000000 0.000000 64.000000
+ *MESH_VERTEX 2 112.000000 128.000000 0.000000
+ *MESH_VERTEX 3 64.000000 128.000000 64.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.800000 0.000000 0.600000
+ *MESH_FACENORMAL 1 0.800000 0.000000 0.600000
+ *MESH_VERTEXNORMAL 0 0.800000 0.000000 0.600000
+ *MESH_VERTEXNORMAL 1 0.800000 0.000000 0.600000
+ *MESH_VERTEXNORMAL 2 0.800000 0.000000 0.600000
+ *MESH_VERTEXNORMAL 3 0.800000 0.000000 0.600000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 -2.000000 0.000000 1.000000
+ *MESH_TVERT 1 -2.000000 2.000000 1.000000
+ *MESH_TVERT 2 2.000000 0.000000 1.000000
+ *MESH_TVERT 3 2.000000 2.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf1"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf1"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 0.000000 128.000000 64.000000
+ *MESH_VERTEX 1 0.000000 128.000000 0.000000
+ *MESH_VERTEX 2 64.000000 128.000000 64.000000
+ *MESH_VERTEX 3 112.000000 128.000000 0.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.800000 0.000000 0.600000
+ *MESH_FACENORMAL 1 0.800000 0.000000 0.600000
+ *MESH_VERTEXNORMAL 0 0.000000 1.000000 0.000000
+ *MESH_VERTEXNORMAL 1 0.000000 1.000000 0.000000
+ *MESH_VERTEXNORMAL 2 0.000000 1.000000 0.000000
+ *MESH_VERTEXNORMAL 3 0.000000 1.000000 0.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 -1.000000 2.000000 1.000000
+ *MESH_TVERT 1 -1.000000 0.000000 1.000000
+ *MESH_TVERT 2 1.000000 2.000000 1.000000
+ *MESH_TVERT 3 2.500000 0.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf2"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf2"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 64.000000 0.000000 64.000000
+ *MESH_VERTEX 1 0.000000 0.000000 64.000000
+ *MESH_VERTEX 2 64.000000 128.000000 64.000000
+ *MESH_VERTEX 3 0.000000 128.000000 64.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.800000 0.000000 0.600000
+ *MESH_FACENORMAL 1 0.800000 0.000000 0.600000
+ *MESH_VERTEXNORMAL 0 0.000000 0.000000 1.000000
+ *MESH_VERTEXNORMAL 1 0.000000 0.000000 1.000000
+ *MESH_VERTEXNORMAL 2 0.000000 0.000000 1.000000
+ *MESH_VERTEXNORMAL 3 0.000000 0.000000 1.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 1.000000 -1.000000 1.000000
+ *MESH_TVERT 1 -1.000000 -1.000000 1.000000
+ *MESH_TVERT 2 1.000000 3.000000 1.000000
+ *MESH_TVERT 3 -1.000000 3.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf3"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf3"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 0.000000 0.000000 64.000000
+ *MESH_VERTEX 1 0.000000 0.000000 0.000000
+ *MESH_VERTEX 2 0.000000 128.000000 64.000000
+ *MESH_VERTEX 3 0.000000 128.000000 0.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.800000 0.000000 0.600000
+ *MESH_FACENORMAL 1 0.800000 0.000000 0.600000
+ *MESH_VERTEXNORMAL 0 -1.000000 0.000000 0.000000
+ *MESH_VERTEXNORMAL 1 -1.000000 0.000000 0.000000
+ *MESH_VERTEXNORMAL 2 -1.000000 0.000000 0.000000
+ *MESH_VERTEXNORMAL 3 -1.000000 0.000000 0.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 -2.000000 2.000000 1.000000
+ *MESH_TVERT 1 -2.000000 0.000000 1.000000
+ *MESH_TVERT 2 2.000000 2.000000 1.000000
+ *MESH_TVERT 3 2.000000 0.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf4"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf4"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 112.000000 0.000000 0.000000
+ *MESH_VERTEX 1 0.000000 0.000000 0.000000
+ *MESH_VERTEX 2 64.000000 0.000000 64.000000
+ *MESH_VERTEX 3 0.000000 0.000000 64.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.800000 0.000000 0.600000
+ *MESH_FACENORMAL 1 0.800000 0.000000 0.600000
+ *MESH_VERTEXNORMAL 0 0.000000 -1.000000 0.000000
+ *MESH_VERTEXNORMAL 1 0.000000 -1.000000 0.000000
+ *MESH_VERTEXNORMAL 2 0.000000 -1.000000 0.000000
+ *MESH_VERTEXNORMAL 3 0.000000 -1.000000 0.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 2.500000 0.000000 1.000000
+ *MESH_TVERT 1 -1.000000 0.000000 1.000000
+ *MESH_TVERT 2 1.000000 2.000000 1.000000
+ *MESH_TVERT 3 -1.000000 2.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
+*GEOMOBJECT {
+ *NODE_NAME "mat0model0surf5"
+ *NODE_TM {
+ *NODE_NAME "mat0model0surf5"
+ *INHERIT_POS 0 0 0
+ *INHERIT_ROT 0 0 0
+ *INHERIT_SCL 0 0 0
+ *TM_ROW0 1.0 0 0
+ *TM_ROW1 0 1.0 0
+ *TM_ROW2 0 0 1.0
+ *TM_ROW3 0 0 0
+ *TM_POS 0.000000 0.000000 0.000000
+ }
+ *MESH {
+ *TIMEVALUE 0
+ *MESH_NUMVERTEX 4
+ *MESH_NUMFACES 2
+ *COMMENT "SURFACETYPE MST_PLANAR"
+ *MESH_VERTEX_LIST {
+ *MESH_VERTEX 0 0.000000 128.000000 0.000000
+ *MESH_VERTEX 1 0.000000 0.000000 0.000000
+ *MESH_VERTEX 2 112.000000 128.000000 0.000000
+ *MESH_VERTEX 3 112.000000 0.000000 0.000000
+ }
+ *MESH_NORMALS {
+ *MESH_FACENORMAL 0 0.800000 0.000000 0.600000
+ *MESH_FACENORMAL 1 0.800000 0.000000 0.600000
+ *MESH_VERTEXNORMAL 0 0.000000 0.000000 -1.000000
+ *MESH_VERTEXNORMAL 1 0.000000 0.000000 -1.000000
+ *MESH_VERTEXNORMAL 2 0.000000 0.000000 -1.000000
+ *MESH_VERTEXNORMAL 3 0.000000 0.000000 -1.000000
+ }
+ *MESH_FACE_LIST {
+ *MESH_FACE 0 A: 0 B: 2 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ *MESH_FACE 1 A: 2 B: 3 C: 1 AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID 0
+ }
+ *MESH_NUMTVERTEX 4
+ *MESH_TVERTLIST {
+ *MESH_TVERT 0 -1.000000 3.000000 1.000000
+ *MESH_TVERT 1 -1.000000 -1.000000 1.000000
+ *MESH_TVERT 2 2.500000 3.000000 1.000000
+ *MESH_TVERT 3 2.500000 -1.000000 1.000000
+ }
+ *MESH_NUMTVFACES 2
+ *MESH_TFACELIST {
+ *MESH_TFACE 0 0 2 1
+ *MESH_TFACE 1 2 3 1
+ }
+ }
+ *PROP_MOTIONBLUR 0
+ *PROP_CASTSHADOW 1
+ *PROP_RECVSHADOW 1
+ *MATERIAL_REF 0
+}
--- /dev/null
+# Makefile for NetRadiant.app, requires http://macdylibbundler.sourceforge.net/
+
+INSTALL = ../../install
+TARGET = target
+RESOURCES = $(TARGET)/NetRadiant.app/Contents/Resources
+BINDIR = $(RESOURCES)/install
+CONFDIR = $(RESOURCES)/etc
+DATADIR = $(RESOURCES)/share
+LIBDIR = $(RESOURCES)/lib
+VERSION = 1.5.0
+DMG = $(TARGET)/NetRadiant-$(VERSION).dmg
+VOLUME_NAME = "NetRadiant $(VERSION)"
+
+# We must rewrite some Gtk configuration files, which vary from environment to
+# environment depending on where you've installed MacPorts. Fun!
+
+MACPORTS_PREFIX := $(shell which port | sed 's:/bin/port::')
+PREFIX_SED_EXPR = "s:$(MACPORTS_PREFIX):@executable_path/..:g"
+
+all: install bundle
+
+-pre-install:
+ install -d $(TARGET)
+ cp -r NetRadiant.app $(TARGET)
+ find $(TARGET) -name .turd -delete
+
+-gtk-runtime-gdk-pixbuf-2.0:
+ cp -r $(MACPORTS_PREFIX)/lib/gdk-pixbuf-2.0 $(LIBDIR)
+ find $(LIBDIR)/gdk-pixbuf-2.0 -type f ! -name "*.so" -delete
+
+ gdk-pixbuf-query-loaders | sed $(PREFIX_SED_EXPR) > \
+ $(CONFDIR)/gtk-2.0/gdk-pixbuf.loaders
+
+-gtk-runtime-pango:
+ cp -r $(MACPORTS_PREFIX)/lib/pango $(LIBDIR)
+ find $(LIBDIR)/pango -type f ! -name "*.so" -delete
+
+ pango-querymodules | sed $(PREFIX_SED_EXPR) > \
+ $(CONFDIR)/pango/pango.modules
+
+-gtk-runtime: -gtk-runtime-gdk-pixbuf-2.0 -gtk-runtime-pango
+ cp -r $(MACPORTS_PREFIX)/lib/gtk-2.0 $(LIBDIR)
+ find $(LIBDIR)/gtk-2.0 -type f ! -name "*.so" -delete
+
+ rm -rf $(LIBDIR)/gtk-2.0/{includes,modules}
+ rm -rf $(LIBDIR)/gtk-2.0/*/printbackends
+
+ cp -r $(MACPORTS_PREFIX)/share/themes/Default $(RESOURCES)/share
+
+ gtk-query-immodules-2.0 | sed $(PREFIX_SED_EXPR) > \
+ $(CONFDIR)/gtk-2.0/gtk.immodules
+
+install: -pre-install -gtk-runtime
+ cp -r $(INSTALL) $(RESOURCES)
+ #rm -rf `find $(INSTDIR)/installs -type d -name .svn`
+
+bundle:
+
+ # The Radiant plugins (modules) are a little funky
+ # Some of them are actually linked against the build directory
+
+ test -L install || ln -s $(INSTALL)
+
+ dylibbundler -b \
+ -x $(BINDIR)/radiant \
+ -x $(BINDIR)/q2map \
+ -x $(BINDIR)/q3data \
+ -x $(BINDIR)/q3map2 \
+ -x $(BINDIR)/qdata3 \
+ `find $(BINDIR)/modules -name "*.dylib" | xargs -I {} echo -x {}` \
+ `find $(LIBDIR) -name "*.dylib" | xargs -I {} echo -x {}` \
+ -d $(LIBDIR) -of -p @executable_path/../lib
+
+ rm -f install
+
+image:
+ find $(TARGET) -name .DS_Store -delete
+ ln -f -s /Applications $(TARGET)/Applications
+ hdiutil create -ov $(DMG) -srcfolder $(TARGET) -volname $(VOLUME_NAME)
+ rm $(TARGET)/Applications
+
+clean:
+ rm -rf $(TARGET)/*
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>NetRadiant</string>
+ <key>CFBundleExecutable</key>
+ <string>radiant</string>
+ <key>CFBundleIconFile</key>
+ <string>radiant.icns</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.xonotic.netradiant</string>
+ <key>CFBundleName</key>
+ <string>NetRadiant</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.5.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.5.0</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>10.7</string>
+</dict>
+</plist>
--- /dev/null
+#!/bin/bash
+
+RADIANT_HOME=$(dirname "$0")
+RADIANT_HOME=${RADIANT_HOME/NetRadiant.app*/NetRadiant.app}
+
+echo
+echo "Starting NetRadiant in ${RADIANT_HOME}"
+echo
+
+set -x
+
+resources="${RADIANT_HOME}/Contents/Resources"
+
+export FONTCONFIG_PATH="${resources}/etc/fonts"
+export FC_DEBUG=1024
+
+export GDK_GL_LIBGL_PATH="${resources}/lib/libGL.1.dylib"
+export GDK_GL_LIBGLU_PATH="${resources}/lib/libGLU.1.dylib"
+
+export GDK_PATH="${resources}"
+export GDK_PIXBUF_MODULE_FILE="${resources}/etc/gtk-2.0/gdk-pixbuf.loaders"
+
+export GOBJECT_PATH="${resources}"
+
+export GTK_DATA_PREFIX="${resources}"
+export GTK_EXE_PREFIX="${resources}"
+export GTK_PATH="${resources}"
+
+export PANGO_SYSCONFDIR="${resources}/etc"
+export PANGO_LIBDIR="${resources}/lib"
+
+cd "${resources}/install"
+./radiant &
+
+set +x
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+
+<!--
+ Adjusted FontConfig for GtkRadiant.app. Include only paths which Mac users
+ will more than likely have.
+-->
+
+<!--
+ Font directory list
+-->
+ <dir>/usr/X11/lib/X11/fonts</dir>
+ <dir>/Library/Fonts</dir>
+ <dir>/System/Library/Fonts</dir>
+ <dir prefix="xdg">fonts</dir>
+
+<!--
+ Accept deprecated 'mono' alias, replacing it with 'monospace'
+-->
+ <match target="pattern">
+ <test qual="any" name="family">
+ <string>mono</string>
+ </test>
+ <edit name="family" mode="assign" binding="same">
+ <string>monospace</string>
+ </edit>
+ </match>
+
+<!--
+ Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
+-->
+ <match target="pattern">
+ <test qual="any" name="family">
+ <string>sans serif</string>
+ </test>
+ <edit name="family" mode="assign" binding="same">
+ <string>sans-serif</string>
+ </edit>
+ </match>
+
+<!--
+ Accept deprecated 'sans' alias, replacing it with 'sans-serif'
+-->
+ <match target="pattern">
+ <test qual="any" name="family">
+ <string>sans</string>
+ </test>
+ <edit name="family" mode="assign" binding="same">
+ <string>sans-serif</string>
+ </edit>
+ </match>
+
+<!-- Font cache directory list -->
+ <cachedir prefix="xdg">fontconfig</cachedir>
+
+ <config>
+<!--
+ These are the default Unicode chars that are expected to be blank
+ in fonts. All other blank chars are assumed to be broken and
+ won't appear in the resulting charsets
+ -->
+ <blank>
+ <int>0x0020</int> <!-- SPACE -->
+ <int>0x00A0</int> <!-- NO-BREAK SPACE -->
+ <int>0x00AD</int> <!-- SOFT HYPHEN -->
+ <int>0x034F</int> <!-- COMBINING GRAPHEME JOINER -->
+ <int>0x0600</int> <!-- ARABIC NUMBER SIGN -->
+ <int>0x0601</int> <!-- ARABIC SIGN SANAH -->
+ <int>0x0602</int> <!-- ARABIC FOOTNOTE MARKER -->
+ <int>0x0603</int> <!-- ARABIC SIGN SAFHA -->
+ <int>0x06DD</int> <!-- ARABIC END OF AYAH -->
+ <int>0x070F</int> <!-- SYRIAC ABBREVIATION MARK -->
+ <int>0x115F</int> <!-- HANGUL CHOSEONG FILLER -->
+ <int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER -->
+ <int>0x1680</int> <!-- OGHAM SPACE MARK -->
+ <int>0x17B4</int> <!-- KHMER VOWEL INHERENT AQ -->
+ <int>0x17B5</int> <!-- KHMER VOWEL INHERENT AA -->
+ <int>0x180E</int> <!-- MONGOLIAN VOWEL SEPARATOR -->
+ <int>0x2000</int> <!-- EN QUAD -->
+ <int>0x2001</int> <!-- EM QUAD -->
+ <int>0x2002</int> <!-- EN SPACE -->
+ <int>0x2003</int> <!-- EM SPACE -->
+ <int>0x2004</int> <!-- THREE-PER-EM SPACE -->
+ <int>0x2005</int> <!-- FOUR-PER-EM SPACE -->
+ <int>0x2006</int> <!-- SIX-PER-EM SPACE -->
+ <int>0x2007</int> <!-- FIGURE SPACE -->
+ <int>0x2008</int> <!-- PUNCTUATION SPACE -->
+ <int>0x2009</int> <!-- THIN SPACE -->
+ <int>0x200A</int> <!-- HAIR SPACE -->
+ <int>0x200B</int> <!-- ZERO WIDTH SPACE -->
+ <int>0x200C</int> <!-- ZERO WIDTH NON-JOINER -->
+ <int>0x200D</int> <!-- ZERO WIDTH JOINER -->
+ <int>0x200E</int> <!-- LEFT-TO-RIGHT MARK -->
+ <int>0x200F</int> <!-- RIGHT-TO-LEFT MARK -->
+ <int>0x2028</int> <!-- LINE SEPARATOR -->
+ <int>0x2029</int> <!-- PARAGRAPH SEPARATOR -->
+ <int>0x202A</int> <!-- LEFT-TO-RIGHT EMBEDDING -->
+ <int>0x202B</int> <!-- RIGHT-TO-LEFT EMBEDDING -->
+ <int>0x202C</int> <!-- POP DIRECTIONAL FORMATTING -->
+ <int>0x202D</int> <!-- LEFT-TO-RIGHT OVERRIDE -->
+ <int>0x202E</int> <!-- RIGHT-TO-LEFT OVERRIDE -->
+ <int>0x202F</int> <!-- NARROW NO-BREAK SPACE -->
+ <int>0x205F</int> <!-- MEDIUM MATHEMATICAL SPACE -->
+ <int>0x2060</int> <!-- WORD JOINER -->
+ <int>0x2061</int> <!-- FUNCTION APPLICATION -->
+ <int>0x2062</int> <!-- INVISIBLE TIMES -->
+ <int>0x2063</int> <!-- INVISIBLE SEPARATOR -->
+ <int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING -->
+ <int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING -->
+ <int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING -->
+ <int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING -->
+ <int>0x206E</int> <!-- NATIONAL DIGIT SHAPES -->
+ <int>0x206F</int> <!-- NOMINAL DIGIT SHAPES -->
+ <int>0x2800</int> <!-- BRAILLE PATTERN BLANK -->
+ <int>0x3000</int> <!-- IDEOGRAPHIC SPACE -->
+ <int>0x3164</int> <!-- HANGUL FILLER -->
+ <int>0xFEFF</int> <!-- ZERO WIDTH NO-BREAK SPACE -->
+ <int>0xFFA0</int> <!-- HALFWIDTH HANGUL FILLER -->
+ <int>0xFFF9</int> <!-- INTERLINEAR ANNOTATION ANCHOR -->
+ <int>0xFFFA</int> <!-- INTERLINEAR ANNOTATION SEPARATOR -->
+ <int>0xFFFB</int> <!-- INTERLINEAR ANNOTATION TERMINATOR -->
+ </blank>
+<!--
+ Rescan configuration every 30 seconds when FcFontSetList is called
+ -->
+ <rescan>
+ <int>30</int>
+ </rescan>
+ </config>
+
+</fontconfig>
+
--- /dev/null
+[Pango]
\ No newline at end of file
--- /dev/null
+NetRadiant for Apple OS X
+========================
+
+This directory provides packaging steps for NetRadiant for OS X. This document describes compiling the application on OSX as well as generating distributable bundles using the framework provided in this directory.
+
+Dependencies & Compilation
+--------------------------
+
+Directions for OS X Yosemite 10.10 - your mileage may vary:
+
+- Install [MacPorts](http://macports.org).
+- Install [XQuartz](http://xquartz.macosforge.org/)
+
+- Install dependencies with MacPorts:
+
+```
+sudo port install dylibbundler pkgconfig gtkglext
+```
+
+- Get the NetRadiant code and compile:
+
+```
+git clone https://gitlab.com/xonotic/netradiant.git
+cd netradiant/
+make
+```
+
+- Run the build:
+
+(from the netradiant/ directory)
+```
+./install/radiant
+```
+
+XQuartz note: on my configuration XQuartz doesn't automatically start for some reason. I have to open another terminal, and run the following command: `/Applications/Utilities/XQuartz.app/Contents/MacOS/X11.bin`, then start radiant.
+
+Building NetRadiant.app
+-----------------------
+
+The `Makefile` in the 'setup/apple/' directory will produce a distributable .app bundle for NetRadiant using `dylibbundler`:
+
+```
+make
+make image
+```
+
+Getting help
+------------
+
+IRC: Quakenet #xonotic, or post something on the issue tracker..
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>netradiant.sh</string>
- <key>CFBundleIconFile</key>
- <string>NetRadiant</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>1.5.0</string>
-</dict>
-</plist>
+++ /dev/null
-<?xml version="1.0"?>
-<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
-<!-- /etc/fonts/fonts.conf file to configure system font access -->
-<fontconfig>
-
-<!--
- DO NOT EDIT THIS FILE.
- IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
- LOCAL CHANGES BELONG IN 'local.conf'.
-
- The intent of this standard configuration file is to be adequate for
- most environments. If you have a reasonably normal environment and
- have found problems with this configuration, they are probably
- things that others will also want fixed. Please submit any
- problems to the fontconfig bugzilla system located at fontconfig.org
-
- Note that the normal 'make install' procedure for fontconfig is to
- replace any existing fonts.conf file with the new version. Place
- any local customizations in local.conf which this file references.
-
- Keith Packard
--->
-
-<!-- Font directory list -->
-
- <dir>/usr/share/fonts</dir>
- <dir>/usr/X11/lib/X11/fonts</dir> <dir>/Library/Fonts</dir> <dir>/Network/Library/Fonts</dir> <dir>/System/Library/Fonts</dir> <dir>/opt/local/share/fonts</dir>
- <dir>~/.fonts</dir>
-
-<!--
- Accept deprecated 'mono' alias, replacing it with 'monospace'
--->
- <match target="pattern">
- <test qual="any" name="family">
- <string>mono</string>
- </test>
- <edit name="family" mode="assign">
- <string>monospace</string>
- </edit>
- </match>
-
-<!--
- Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
--->
- <match target="pattern">
- <test qual="any" name="family">
- <string>sans serif</string>
- </test>
- <edit name="family" mode="assign">
- <string>sans-serif</string>
- </edit>
- </match>
-
-<!--
- Accept deprecated 'sans' alias, replacing it with 'sans-serif'
--->
- <match target="pattern">
- <test qual="any" name="family">
- <string>sans</string>
- </test>
- <edit name="family" mode="assign">
- <string>sans-serif</string>
- </edit>
- </match>
-
-<!--
- Load local system customization file
--->
- <include ignore_missing="yes">conf.d</include>
-
-<!-- Font cache directory list -->
-
- <cachedir>~/.fontconfig</cachedir>
-
- <config>
-<!--
- These are the default Unicode chars that are expected to be blank
- in fonts. All other blank chars are assumed to be broken and
- won't appear in the resulting charsets
- -->
- <blank>
- <int>0x0020</int> <!-- SPACE -->
- <int>0x00A0</int> <!-- NO-BREAK SPACE -->
- <int>0x00AD</int> <!-- SOFT HYPHEN -->
- <int>0x034F</int> <!-- COMBINING GRAPHEME JOINER -->
- <int>0x0600</int> <!-- ARABIC NUMBER SIGN -->
- <int>0x0601</int> <!-- ARABIC SIGN SANAH -->
- <int>0x0602</int> <!-- ARABIC FOOTNOTE MARKER -->
- <int>0x0603</int> <!-- ARABIC SIGN SAFHA -->
- <int>0x06DD</int> <!-- ARABIC END OF AYAH -->
- <int>0x070F</int> <!-- SYRIAC ABBREVIATION MARK -->
- <int>0x115F</int> <!-- HANGUL CHOSEONG FILLER -->
- <int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER -->
- <int>0x1680</int> <!-- OGHAM SPACE MARK -->
- <int>0x17B4</int> <!-- KHMER VOWEL INHERENT AQ -->
- <int>0x17B5</int> <!-- KHMER VOWEL INHERENT AA -->
- <int>0x180E</int> <!-- MONGOLIAN VOWEL SEPARATOR -->
- <int>0x2000</int> <!-- EN QUAD -->
- <int>0x2001</int> <!-- EM QUAD -->
- <int>0x2002</int> <!-- EN SPACE -->
- <int>0x2003</int> <!-- EM SPACE -->
- <int>0x2004</int> <!-- THREE-PER-EM SPACE -->
- <int>0x2005</int> <!-- FOUR-PER-EM SPACE -->
- <int>0x2006</int> <!-- SIX-PER-EM SPACE -->
- <int>0x2007</int> <!-- FIGURE SPACE -->
- <int>0x2008</int> <!-- PUNCTUATION SPACE -->
- <int>0x2009</int> <!-- THIN SPACE -->
- <int>0x200A</int> <!-- HAIR SPACE -->
- <int>0x200B</int> <!-- ZERO WIDTH SPACE -->
- <int>0x200C</int> <!-- ZERO WIDTH NON-JOINER -->
- <int>0x200D</int> <!-- ZERO WIDTH JOINER -->
- <int>0x200E</int> <!-- LEFT-TO-RIGHT MARK -->
- <int>0x200F</int> <!-- RIGHT-TO-LEFT MARK -->
- <int>0x2028</int> <!-- LINE SEPARATOR -->
- <int>0x2029</int> <!-- PARAGRAPH SEPARATOR -->
- <int>0x202A</int> <!-- LEFT-TO-RIGHT EMBEDDING -->
- <int>0x202B</int> <!-- RIGHT-TO-LEFT EMBEDDING -->
- <int>0x202C</int> <!-- POP DIRECTIONAL FORMATTING -->
- <int>0x202D</int> <!-- LEFT-TO-RIGHT OVERRIDE -->
- <int>0x202E</int> <!-- RIGHT-TO-LEFT OVERRIDE -->
- <int>0x202F</int> <!-- NARROW NO-BREAK SPACE -->
- <int>0x205F</int> <!-- MEDIUM MATHEMATICAL SPACE -->
- <int>0x2060</int> <!-- WORD JOINER -->
- <int>0x2061</int> <!-- FUNCTION APPLICATION -->
- <int>0x2062</int> <!-- INVISIBLE TIMES -->
- <int>0x2063</int> <!-- INVISIBLE SEPARATOR -->
- <int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING -->
- <int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING -->
- <int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING -->
- <int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING -->
- <int>0x206E</int> <!-- NATIONAL DIGIT SHAPES -->
- <int>0x206F</int> <!-- NOMINAL DIGIT SHAPES -->
- <int>0x2800</int> <!-- BRAILLE PATTERN BLANK -->
- <int>0x3000</int> <!-- IDEOGRAPHIC SPACE -->
- <int>0x3164</int> <!-- HANGUL FILLER -->
- <int>0xFEFF</int> <!-- ZERO WIDTH NO-BREAK SPACE -->
- <int>0xFFA0</int> <!-- HALFWIDTH HANGUL FILLER -->
- <int>0xFFF9</int> <!-- INTERLINEAR ANNOTATION ANCHOR -->
- <int>0xFFFA</int> <!-- INTERLINEAR ANNOTATION SEPARATOR -->
- <int>0xFFFB</int> <!-- INTERLINEAR ANNOTATION TERMINATOR -->
- </blank>
-<!--
- Rescan configuration every 30 seconds when FcFontSetList is called
- -->
- <rescan>
- <int>30</int>
- </rescan>
- </config>
-
-</fontconfig>
+++ /dev/null
-<!-- This is the Document Type Definition for font configuration files -->
-<!ELEMENT fontconfig (dir |
- cache |
- cachedir |
- include |
- config |
- selectfont |
- match |
- alias)* >
-
-<!--
- Add a directory that provides fonts
--->
-<!ELEMENT dir (#PCDATA)>
-<!ATTLIST dir xml:space (default|preserve) 'preserve'>
-
-<!--
- Define the per-user file that holds cache font information.
-
- If the filename begins with '~', it is replaced with the users
- home directory path.
--->
-<!ELEMENT cache (#PCDATA)>
-<!ATTLIST cache xml:space (default|preserve) 'preserve'>
-
-<!--
- Add a directory that is searched for font cache files.
- These hold per-directory cache data and are searched in
- order for each directory. When writing cache files, the first
- directory which allows the cache file to be created is used.
-
- A leading '~' in a directory name is replaced with the users
- home directory path.
--->
-<!ELEMENT cachedir (#PCDATA)>
-<!ATTLIST cachedir xml:space (default|preserve) 'preserve'>
-
-<!--
- Reference another configuration file; note that this
- is another complete font configuration file and not
- just a file included by the XML parser.
-
- Set 'ignore_missing' to 'yes' if errors are to be ignored.
-
- If the filename begins with '~', it is replaced with the users
- home directory path.
--->
-<!ELEMENT include (#PCDATA)>
-<!ATTLIST include
- ignore_missing (no|yes) "no"
- xml:space (default|preserve) "preserve">
-
-<!--
- Global library configuration data
- -->
-<!ELEMENT config (blank|rescan)*>
-
-<!--
- Specify the set of Unicode encoding values which
- represent glyphs that are allowed to contain no
- data. With this list, fontconfig can examine
- fonts for broken glyphs and eliminate them from
- the set of valid Unicode chars. This idea
- was borrowed from Mozilla
- -->
-<!ELEMENT blank (int)*>
-
-<!--
- Aliases are just a special case for multiple match elements
-
- They are syntactically equivalent to:
-
- <match>
- <test name="family">
- <string value=[family]/>
- </test>
- <edit name="family" mode="prepend">
- <string value=[prefer]/>
- ...
- </edit>
- <edit name="family" mode="append">
- <string value=[accept]/>
- ...
- </edit>
- <edit name="family" mode="append_last">
- <string value=[default]/>
- ...
- </edit>
- </match>
--->
-<!--
- Periodically rescan the font configuration and
- directories to synch internal state with filesystem
- -->
-<!ELEMENT rescan (int)>
-
-<!--
- Edit list of available fonts at startup/reload time
- -->
-<!ELEMENT selectfont (rejectfont | acceptfont)* >
-
-<!ELEMENT rejectfont (glob | pattern)*>
-
-<!ELEMENT acceptfont (glob | pattern)*>
-
-<!ELEMENT glob (#PCDATA)>
-
-<!ELEMENT pattern (patelt)*>
-
-<!ENTITY % constant 'int|double|string|matrix|bool|charset|const'>
-
-<!ELEMENT patelt (%constant;)*>
-<!ATTLIST patelt
- name CDATA #REQUIRED>
-
-<!ELEMENT alias (family*, prefer?, accept?, default?)>
-<!ATTLIST alias
- binding (weak|strong|same) "weak">
-<!ELEMENT prefer (family)*>
-<!ELEMENT accept (family)*>
-<!ELEMENT default (family)*>
-<!ELEMENT family (#PCDATA)>
-<!ATTLIST family xml:space (default|preserve) 'preserve'>
-
-<!ENTITY % expr 'int|double|string|matrix|bool|charset
- |name|const
- |or|and|eq|not_eq|less|less_eq|more|more_eq|contains|not_contains
- |plus|minus|times|divide|not|if|floor|ceil|round|trunc'>
-
-<!--
- Match and edit patterns.
-
- If 'target' is 'pattern', execute the match before selecting a font.
- if 'target' is 'font', execute the match on the result of a font
- selection.
--->
-<!ELEMENT match (test*, edit*)>
-<!ATTLIST match
- target (pattern|font|scan) "pattern">
-
-<!--
- Match a field in a pattern
-
- if 'qual' is 'any', then the match succeeds if any value in the field matches.
- if 'qual' is 'all', then the match succeeds only if all values match.
- if 'qual' is 'first', then the match succeeds only if the first value matches.
- if 'qual' is 'not_first', then the match succeeds only if any value other than
- the first matches.
- For match elements with target=font, if test 'target' is 'pattern',
- then the test is applied to the pattern used in matching rather than
- to the resulting font.
-
- Match elements with target=scan are applied as fonts are scanned.
- They edit the pattern generated from the scanned font and affect
- what the fontconfig database contains.
--->
-<!ELEMENT test (%expr;)*>
-<!ATTLIST test
- qual (any|all|first|not_first) "any"
- name CDATA #REQUIRED
- target (pattern|font|default) "default"
- compare (eq|not_eq|less|less_eq|more|more_eq|contains|not_contains) "eq">
-
-<!--
- Edit a field in a pattern
-
- The enclosed values are used together to edit the list of values
- associated with 'name'.
-
- If 'name' matches one of those used in a test element for this match element:
- if 'mode' is 'assign', replace the matched value.
- if 'mode' is 'assign_replace', replace all of the values
- if 'mode' is 'prepend', insert before the matched value
- if 'mode' is 'append', insert after the matched value
- if 'mode' is 'prepend_first', insert before all of the values
- if 'mode' is 'append_last', insert after all of the values
- If 'name' doesn't match any of those used in a test element:
- if 'mode' is 'assign' or 'assign_replace, replace all of the values
- if 'mode' is 'prepend' or 'prepend_first', insert before all of the values
- if 'mode' is 'append' or 'append_last', insert after all of the values
--->
-<!ELEMENT edit (%expr;)*>
-<!ATTLIST edit
- name CDATA #REQUIRED
- mode (assign|assign_replace|prepend|append|prepend_first|append_last) "assign"
- binding (weak|strong|same) "weak">
-
-<!--
- Elements of expressions follow
--->
-<!ELEMENT int (#PCDATA)>
-<!ATTLIST int xml:space (default|preserve) 'preserve'>
-<!ELEMENT double (#PCDATA)>
-<!ATTLIST double xml:space (default|preserve) 'preserve'>
-<!ELEMENT string (#PCDATA)>
-<!ATTLIST string xml:space (default|preserve) 'preserve'>
-<!ELEMENT matrix (double,double,double,double)>
-<!ELEMENT bool (#PCDATA)>
-<!ELEMENT charset (#PCDATA)>
-<!ATTLIST charset xml:space (default|preserve) 'preserve'>
-<!ELEMENT name (#PCDATA)>
-<!ATTLIST name xml:space (default|preserve) 'preserve'>
-<!ELEMENT const (#PCDATA)>
-<!ATTLIST const xml:space (default|preserve) 'preserve'>
-<!ELEMENT or (%expr;)*>
-<!ELEMENT and (%expr;)*>
-<!ELEMENT eq ((%expr;), (%expr;))>
-<!ELEMENT not_eq ((%expr;), (%expr;))>
-<!ELEMENT less ((%expr;), (%expr;))>
-<!ELEMENT less_eq ((%expr;), (%expr;))>
-<!ELEMENT more ((%expr;), (%expr;))>
-<!ELEMENT more_eq ((%expr;), (%expr;))>
-<!ELEMENT contains ((%expr;), (%expr;))>
-<!ELEMENT not_contains ((%expr;), (%expr;))>
-<!ELEMENT plus (%expr;)*>
-<!ELEMENT minus (%expr;)*>
-<!ELEMENT times (%expr;)*>
-<!ELEMENT divide (%expr;)*>
-<!ELEMENT not (%expr;)>
-<!ELEMENT if ((%expr;), (%expr;), (%expr;))>
-<!ELEMENT floor (%expr;)>
-<!ELEMENT ceil (%expr;)>
-<!ELEMENT round (%expr;)>
-<!ELEMENT trunc (%expr;)>
+++ /dev/null
-# GdkPixbuf Image Loader Modules file
-# Automatically generated file, do not edit
-# Created by gdk-pixbuf-query-loaders from gtk+-2.6.10
-#
-# LoaderDir = /sw.haha/lib/gtk-2.0/2.4.0/loaders
-#
-"./libpixbufloader-bmp.so"
-"bmp" 5 "gtk20" "The BMP image format"
-"image/bmp" "image/x-bmp" "image/x-MS-bmp" ""
-"bmp" ""
-"BM" "" 100
-
+++ /dev/null
-# Pango Modules file
-# Automatically generated file, do not edit
-#
-# ModulesPath = /sw.haha/lib/pango/1.4.0/modules
-#
-./pango-basic-fc.so BasicScriptEngineFc PangoEngineShape PangoRenderFc armenian:* bopomofo:* cherokee:* coptic:* cyrillic:* deseret:* ethiopic:* georgian:* gothic:* greek:* han:* hiragana:* katakana:* latin:* ogham:* old-italic:* runic:* canadian-aboriginal:* yi:* braille:* cypriot:* limbu:* osmanya:* shavian:* linear-b:* ugaritic:* common:
-./pango-basic-x.so BasicScriptEngineX PangoEngineShape PangoRenderX common:
+++ /dev/null
-[Pango]
-ModuleFiles = ./pango.modules
-
-[PangoX]
-AliasFiles = ./pangox.aliases
+++ /dev/null
-# File defining aliases of PangoFontDescription to X font set
-#
-# family style variant weight stretch XLFD
-
-sans normal normal normal normal \
- "-*-helvetica-medium-r-normal--*-*-*-*-*-*-*-*,\
- -*-gulim-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-sans italic normal normal normal \
- "-*-helvetica-medium-o-normal--*-*-*-*-*-*-*-*,\
- -*-gulim-medium-o-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-sans normal normal bold normal \
- "-*-helvetica-bold-r-normal--*-*-*-*-*-*-*-*,\
- -*-gulim-bold-r-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-sans italic normal bold normal \
- "-*-helvetica-bold-o-normal--*-*-*-*-*-*-*-*,\
- -*-gulim-bold-o-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-
-serif normal normal normal normal \
- "-*-times-medium-r-normal--*-*-*-*-*-*-*-*,\
- -*-batang-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-serif italic normal normal normal \
- "-*-times-medium-i-normal--*-*-*-*-*-*-*-*,\
- -*-batang-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-serif normal normal bold normal \
- "-*-times-bold-r-normal--*-*-*-*-*-*-*-*,\
- -*-batang-bold-r-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-serif italic normal bold normal \
- "-*-times-bold-i-normal--*-*-*-*-*-*-*-*,\
- -*-batang-bold-r-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-monospace normal normal normal normal \
- "-*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -*-dotum-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-monospace italic normal normal normal \
- "-*-fixed-medium-i-normal--*-*-*-*-*-*-*-*,\
- -*-dotum-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-monospace normal normal bold normal \
- "-*-fixed-bold-r-normal--*-*-*-*-*-*-*-*,\
- -*-dotum-bold-r-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
-
-monospace italic normal bold normal \
- "-*-fixed-bold-i-normal--*-*-*-*-*-*-*-*,\
- -*-dotum-bold-r-normal--*-*-*-*-*-*-ksc5601.1987-0,\
- -*-clearlyu-medium-r-normal--*-*-*-*-*-*-iso10646-1,\
- -*-fixed-medium-r-normal--*-*-*-*-*-*-*-*,\
- -kaist-iyagi-bold-r-normal--*-*-*-*-*-*-johab-1,\
- -*-song ti-medium-r-normal--*-*-*-*-*-*-*-*,\
- -freetype-unitamil-medium-r-normal--*-*-*-*-*-*-iso10646-tam,\
- -*-devanagari-medium-r-normal--*-*-*-*-*-*-iso10646-dev,\
- -*-gujarati-medium-r-normal--*-*-*-*-*-*-iso10646-guj,\
- -*-gurmukhi-medium-r-normal--*-*-*-*-*-*-iso10646-gur,\
- -*-bengali-medium-r-normal--*-*-*-*-*-*-iso10646-bng,\
- -*-kannada-medium-r-normal--*-*-*-*-*-*-iso10646-kan,\
- -*-burmese-medium-r-normal--*-*-*-*-*-*-iso10646-brm,\
- -*-buginese-medium-r-normal--*-*-*-*-*-*-iso10646-bgn,\
- -*-oriya-medium-r-normal--*-*-*-*-*-*-iso10646-ori,\
- -daewoo-mincho-medium-r-normal--*-*-*-*-*-*-ksc5601.1987-0"
+++ /dev/null
-APPL????
\ No newline at end of file
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<!-- generated by Radiant setup, modify at your own risks -->
<links>
-<!--item name="NetRadiant website" url="http://www.icculus.org/netradiant/"/-->
-<item name="q3map2 handbook (web)" url="http://en.wikibooks.org/wiki/Category:Q3Map2"/>
-<item name="Shader Manual (web)" url="http://robotrenegade.com/q3map2/docs/shader_manual/contents.html"/>
-<item name="Shader Manual (offline+fixed)" url="docs/shaderManual/contents.html"/>
-<item name="Mouse Shortcuts" url="docs/Mouse Shortcuts.txt"/>
-<item name="Additional map compiler features" url="docs/Additional_map_compiler_features.htm"/>
-<item name="Additional map editor features" url="docs/Additional_map_editor_features.htm"/>
-<item name="Complete list of Q3map2 command line parameters" url="docs/Complete_list_of_command_line_parameters.htm"/>
-<item name="Complete list of entity keys" url="docs/Complete_list_of_entity_keys.htm"/>
-<item name="Complete list of shader keywords" url="docs/Complete_list_of_shader_keywords.htm"/>
-<item name="Q3Map2 - FS20 - R5 readme" url="docs/fsr_readme.txt"/>
-<item name="Blendmodes cheatsheet" url="docs/Blendmodes_cheatsheet.jpg"/>
-<!--item name="ETB documentation (web)" url="http://www.map-craft.com/modules.php?name=ETB"/-->
+<item name="NetRadiant website" url="https://gitlab.com/xonotic/netradiant"/>
+<item name="q3map2 handbook" url="http://q3map2.everyonelookbusy.net/shader_manual/"/>
+<item name="q3map2 wikibook" url="https://en.wikibooks.org/wiki/Q3Map2"/>
</links>
--- /dev/null
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+
+add_subdirectory(quake3)
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// Nurail: Swiped from quake3/common
#include "cmdlib.h"
+#include "globaldefs.h"
+
#include "mathlib.h"
#include "inout.h"
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <direct.h>
#include <windows.h>
#endif
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#include <unistd.h>
#endif
#define MAX_EX_ARGC 1024
int ex_argc;
char *ex_argv[MAX_EX_ARGC];
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include "io.h"
void ExpandWildcards( int *argc, char ***argv ){
struct _finddata_t fileinfo;
void Q_getwd( char *out ){
int i = 0;
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
_getcwd( out, 256 );
strcat( out, "\\" );
#else
void Q_mkdir( const char *path ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
if ( _mkdir( path ) != -1 ) {
return;
}
============================================================================
*/
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
short LittleShort( short l ){
byte b1,b2;
char c;
char dir[1024];
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
int olddrive = -1;
if ( path[1] == ':' ) {
}
}
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
if ( olddrive != -1 ) {
_chdrive( olddrive );
}
}
void Sys_Sleep( int n ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
Sleep( n );
#endif
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
usleep( n * 1000 );
#endif
}
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#ifndef __CMDLIB__
#define __CMDLIB__
+#include "globaldefs.h"
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#ifdef NDEBUG // Don't show in a Release build
#pragma warning(disable : 4305) // truncate from double to float
#pragma warning(disable : 4244) // conversion from double to float
#endif
#endif
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#pragma intrinsic( memset, memcpy )
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// deal with in/out tasks, for either stdin/stdout or network/XML stream
//
+#include "globaldefs.h"
#include "cmdlib.h"
#include "mathlib.h"
#include "polylib.h"
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <direct.h>
#include <windows.h>
#endif
#include "l_net/l_net.h"
#include "libxml/tree.h"
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
HWND hwndOut = NULL;
qboolean lookedForServer = false;
UINT wm_BroadcastCommand = -1;
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#ifndef __INOUT__
#define __INOUT__
+#include "globaldefs.h"
// inout is the only stuff relying on xml, include the headers there
#include "libxml/tree.h"
#include "mathlib.h"
void Sys_FPrintf( int flag, const char *text, ... );
void Error( const char *error, ... );
-#ifdef _DEBUG
+#if GDEF_DEBUG
#define DBG_XML 1
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/* -------------------------------------------------------------------------------
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
*/
+#include "globaldefs.h"
-
-/* marker */
-#define PATH_INIT_C
-
-#if defined( __linux__ ) || defined( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#define Q_UNIX
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
========================================================================
*/
-#ifdef WIN32
+#include "globaldefs.h"
+#if GDEF_COMPILER_MSVC
#ifdef NDEBUG // Don't show in a Release build
#pragma warning(disable : 4305) // truncate from double to float
#pragma warning(disable : 4244) // conversion from double to float
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef WIN32
+#include "globaldefs.h"
+
+#if !GDEF_OS_WINDOWS
// The below define is necessary to use
// pthreads extensions like pthread_mutexattr_settype
#define _GNU_SOURCE
===================================================================
*/
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#define USED
=======================================================================
*/
-#if defined( __linux__ ) || defined( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#define USED
// Setting default Threads to 1
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
===========================================================================
*/
+#include "globaldefs.h"
#include "cmdlib.h"
#include "mathlib.h"
#include "bspfile.h"
#include "threads.h"
#include "lbmlib.h"
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <windows.h>
#endif
// cmdlib.c
#include "cmdlib.h"
+#include "globaldefs.h"
+
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <direct.h>
#endif
#define MAX_EX_ARGC 1024
int ex_argc;
char *ex_argv[MAX_EX_ARGC];
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
#include "io.h"
void ExpandWildcards (int *argc, char ***argv)
{
void Q_getwd (char *out)
{
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
_getcwd (out, 256);
strcat (out, "\\");
#else
void Q_mkdir (char *path)
{
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
if (_mkdir (path) != -1)
return;
#else
============================================================================
*/
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
short LittleShort (short l)
{
#ifndef __CMDLIB__
#define __CMDLIB__
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4244) // MIPS
#pragma warning(disable : 4136) // X86
#pragma warning(disable : 4051) // ALPHA
#include "cmdlib.h"
#include "threads.h"
+#include "globaldefs.h"
#define MAX_THREADS 64
===================================================================
*/
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#define USED
===============
*/
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
#include "io.h"
void PackDirectory_r (char *dir)
{
// cmdlib.c
#include "cmdlib.h"
+#include "globaldefs.h"
#define PATHSEPERATOR '/'
============================================================================
*/
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
short LittleShort (short l)
{
//
//*************************************************************
+#include "globaldefs.h"
#include <windows.h>
#include <windowsx.h>
#include <string.h>
return TRUE;
}
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
BOOL IsWin395OrHigher(void)
{
#ifndef __MRU_H__
#define __MRU_H__
+#include "globaldefs.h"
+
#define NBMRUMENUSHOW 6 // Default number of MRU showed in the menu File
#define NBMRUMENU 9 // Default number of MRU stored
#define IDMRU 8000 // Default First ID of MRU
BOOL SaveMruInIni (LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile);
BOOL LoadMruInIni (LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile);
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
BOOL SaveMruInReg (LPMRUMENU lpMruMenu,LPSTR lpszKey);
BOOL LoadMruInReg (LPMRUMENU lpMruMenu,LPSTR lpszKey);
#define __QE3_H__
// disable data conversion warnings for gl
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4244) // MIPS
#pragma warning(disable : 4136) // X86
#pragma warning(disable : 4051) // ALPHA
+#endif
#include <windows.h>
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
volume = BrushVolume( b );
if ( volume < microvolume ) {
- Sys_Printf( "WARNING: entity %i, brush %i: microbrush\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: entity %i, brush %i: microbrush\n",
b->original->entitynum, b->original->brushnum );
}
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
}
#if 0
if ( v1 == edge->v[0] && v2 == edge->v[1] ) {
- Sys_Printf( "WARNING: multiple forward edge\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: multiple forward edge\n" );
return i;
}
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
if ( target[0] ) { // point towards target
e2 = FindTargetEntity( target );
if ( !e2 ) {
- Sys_Printf( "WARNING: light at (%i %i %i) has missing target\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: light at (%i %i %i) has missing target\n",
(int)dl->origin[0], (int)dl->origin[1], (int)dl->origin[2] );
}
else
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Sys_Printf( "Game: %s\n", game );
if ( !do_info && !do_bsp && !do_vis && !do_rad ) {
- Sys_Printf( "ERROR: -bsp, -vis, -light, nor -info specified.\nWhat to you want me to do?\n\n" );
+ Sys_FPrintf( SYS_ERR, "ERROR: -bsp, -vis, -light, nor -info specified.\nWhat to you want me to do?\n\n" );
}
else
{
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
CalcNodeBounds( node );
if ( node->mins[0] >= node->maxs[0] ) {
- Sys_Printf( "WARNING: node without a volume\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: node without a volume\n" );
}
for ( i = 0 ; i < 3 ; i++ )
{
if ( node->mins[i] < -8000 || node->maxs[i] > 8000 ) {
- Sys_Printf( "WARNING: node with unbounded volume\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: node with unbounded volume\n" );
break;
}
}
// note the current area as bounding the portal
if ( e->portalareas[1] ) {
- Sys_Printf( "WARNING: areaportal entity %i touches > 2 areas\n", b->original->entitynum );
+ Sys_FPrintf( SYS_WRN, "WARNING: areaportal entity %i touches > 2 areas\n", b->original->entitynum );
return;
}
if ( e->portalareas[0] ) {
e = &entities[b->original->entitynum];
node->area = e->portalareas[0];
if ( !e->portalareas[1] ) {
- Sys_Printf( "WARNING: areaportal entity %i doesn't touch two areas\n", b->original->entitynum );
+ Sys_FPrintf( SYS_WRN, "WARNING: areaportal entity %i doesn't touch two areas\n", b->original->entitynum );
return;
}
}
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
*/
// q2map.h
+#include "globaldefs.h"
+
/* platform-specific */
-#if defined( __linux__ ) || defined( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#define Q_UNIX
#endif
#include <limits.h>
#endif
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <windows.h>
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
*/
+#include "globaldefs.h"
#include "cmdlib.h"
#include "mathlib.h"
#include "scriplib.h"
#include "bspfile.h"
#include "inout.h"
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#ifdef NDEBUG // Don't show in a Release build
#pragma warning(disable : 4305) // truncate from double to float
#pragma warning(disable : 4244) // conversion from double to float
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
*/
-
+#include "globaldefs.h"
#include "cmdlib.h"
#include "mathlib.h"
#include "bspfile.h"
#include "lbmlib.h"
#include "inout.h"
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <windows.h>
#endif
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#ifdef NDEBUG // Don't show in a Release build
#pragma warning(disable : 4305) // truncate from double to float
#pragma warning(disable : 4244) // conversion from double to float
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
numvis = LeafVectorFromPortalVector( portalvector, uncompressed );
if ( uncompressed[leafnum >> 3] & ( 1 << ( leafnum & 7 ) ) ) {
- Sys_Printf( "WARNING: Leaf portals saw into leaf\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Leaf portals saw into leaf\n" );
}
uncompressed[leafnum >> 3] |= ( 1 << ( leafnum & 7 ) );
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
*/
+#include "globaldefs.h"
#include "cmdlib.h"
#include "mathlib.h"
#include "bspfile.h"
#include "inout.h"
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#ifdef NDEBUG // Don't show in a Release build
#pragma warning(disable : 4305) // truncate from double to float
#pragma warning(disable : 4244) // conversion from double to float
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
===============
*/
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
#include "io.h"
void PackDirectory_r( char *dir ){
struct _finddata_t fileinfo;
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "globaldefs.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "l3dslib.h"
#include "bspfile.h"
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
#ifdef NDEBUG // Don't show in a Release build
#pragma warning(disable : 4305) // truncate from double to float
#pragma warning(disable : 4244) // conversion from double to float
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// Nurail: Swiped from quake3/common
#include "cmdlib.h"
+#include "globaldefs.h"
#include "mathlib.h"
#include "inout.h"
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <direct.h>
#include <windows.h>
#endif
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#include <unistd.h>
#endif
return p;
}
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
void strlwr( char *conv_str ){
int i;
#define MAX_EX_ARGC 1024
int ex_argc;
char *ex_argv[MAX_EX_ARGC];
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
#include "io.h"
void ExpandWildcards( int *argc, char ***argv ){
struct _finddata_t fileinfo;
void Q_getwd( char *out ){
int i = 0;
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
_getcwd( out, 256 );
strcat( out, "\\" );
#else
void Q_mkdir( const char *path ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
if ( _mkdir( path ) != -1 ) {
return;
}
============================================================================
*/
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
short LittleShort( short l ){
byte b1,b2;
char c;
char dir[1024];
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
int olddrive = -1;
if ( path[1] == ':' ) {
}
}
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
if ( olddrive != -1 ) {
_chdrive( olddrive );
}
}
void Sys_Sleep( int n ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
Sleep( n );
#endif
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
usleep( n * 1000 );
#endif
}
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#ifndef __CMDLIB__
#define __CMDLIB__
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4244) // MIPS
#pragma warning(disable : 4136) // X86
#pragma warning(disable : 4051) // ALPHA
#include <time.h>
#include <stdarg.h>
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
#pragma intrinsic( memset, memcpy )
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// deal with in/out tasks, for either stdin/stdout or network/XML stream
//
+#include "globaldefs.h"
#include "cmdlib.h"
#include "mathlib.h"
#include "polylib.h"
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <direct.h>
#include <windows.h>
#endif
#include "l_net/l_net.h"
#include "libxml/tree.h"
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
HWND hwndOut = NULL;
qboolean lookedForServer = false;
UINT wm_BroadcastCommand = -1;
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#ifndef __INOUT__
#define __INOUT__
+#include "globaldefs.h"
// inout is the only stuff relying on xml, include the headers there
#include "libxml/tree.h"
#include "mathlib.h"
void Sys_FPrintf( int flag, const char *text, ... );
void Error( const char *error, ... );
-#ifdef _DEBUG
+#if GDEF_DEBUG
#define DBG_XML 1
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
out[2] = v[2] * scale;
}
+#if GDEF_COMPILER_MSVC
#pragma optimize("g", off) // went back to turning optimization off,
// the bug_fix thing stopped working
+#endif
vec_t VectorNormalize( vec3_t in, vec3_t out ){
vec_t length, ilength;
return max;
}
+#if GDEF_COMPILER_MSVC
#pragma optimize("", on)
+#endif
void VectorInverse( vec3_t v ){
v[0] = -v[0];
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/* -------------------------------------------------------------------------------
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Nurail: Swiped from Q3Map2
*/
+#include "globaldefs.h"
-
-/* marker */
-#define PATH_INIT_C
-
-#if defined( __linux__ ) || defined( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#define Q_UNIX
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef WIN32
+#include "globaldefs.h"
+
+#if !GDEF_OS_WINDOWS
// The below define is necessary to use
// pthreads extensions like pthread_mutexattr_settype
#define _GNU_SOURCE
===================================================================
*/
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#define USED
=======================================================================
*/
-#ifdef __linux__
+#if GDEF_OS_LINUX
#define USED
int numthreads = 4;
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
void ScaleTris( vec3_t min, vec3_t max, int Width, int Height, float* u, float* v, int verts );
void NewDrawLine( int x1, int y1, int x2, int y2, unsigned char* picture, int width, int height );
-#ifndef _WIN32
+#if !GDEF_OS_WINDOWS
void strupr( char *string ){
int i;
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#include "qdata.h"
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
#include <windows.h>
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#ifndef JOINTS_H
#define JOINTS_H
+#include "globaldefs.h"
+
#ifdef _HERETIC2_
#include "angles.h"
#endif
//typedef float vec3_t[3];
//typedef unsigned char byte;
-#ifndef _WIN32
+#if !GDEF_OS_WINDOWS
#define stricmp strcasecmp
#define strcmpi strcasecmp
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#define SHORT_TO_ANGLE ( 360.0 / 65536 )
-
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4305) // 'initializing' : truncation from 'const double ' to 'float '
+#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#define ARRAYEDLISTNODE_NULL -1
-static
-#ifdef _WIN32
-_inline
-#else
-inline
-#endif
-int GetFreeNode( ArrayedListNode_t *nodeArray, int max ){
+static GDEF_ATTRIBUTE_INLINE int GetFreeNode( ArrayedListNode_t *nodeArray, int max ){
int i;
for ( i = 0; i < max; ++i )
return -1;
}
-static
-#ifdef _WIN32
-_inline
-#else
-inline
-#endif
-void FreeNode( ArrayedListNode_t *nodeArray, int index ){
+static GDEF_ATTRIBUTE_INLINE void FreeNode( ArrayedListNode_t *nodeArray, int index ){
nodeArray[index].inUse = 0;
}
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
*/
#include "qdata.h"
+#include "globaldefs.h"
#include "md4.h"
void TK_Init();
===============
*/
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
#include "io.h"
void PackDirectory_r( char *dir ){
struct _finddata_t fileinfo;
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// qdata.h
-
+#include "globaldefs.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "l3dslib.h"
#include "bspfile.h"
-#ifndef _WIN32
+#if !GDEF_OS_WINDOWS
#define stricmp strcasecmp
#define strcmpi strcasecmp
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
--- /dev/null
+include_directories(BEFORE common)
+
+set(Q3MAP_VERSION 2.5.17n)
+find_package(Git REQUIRED)
+execute_process(
+ COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ OUTPUT_VARIABLE GIT_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+if (GIT_VERSION)
+ set(Q3MAP_VERSION "${Q3MAP_VERSION}-git-${GIT_VERSION}")
+endif ()
+add_definitions(-DQ3MAP_VERSION="${Q3MAP_VERSION}")
+
+find_package(GLIB REQUIRED)
+include_directories(${GLIB_INCLUDE_DIRS})
+
+find_package(JPEG REQUIRED)
+include_directories(${JPEG_INCLUDE_DIR})
+
+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})
+
+find_package(ZLIB REQUIRED)
+include_directories(${ZLIB_INCLUDE_DIRS})
+
+find_package(Minizip REQUIRED)
+include_directories(${Minizip_INCLUDE_DIRS})
+
+include_directories(${CMAKE_SOURCE_DIR}/libs/crnrgba)
+
+set(q3map2_games
+ q3map2/game_darkplaces.h
+ q3map2/game_dq.h
+ q3map2/game_ef.h
+ q3map2/game_etut.h
+ q3map2/game_ja.h
+ q3map2/game_jk2.h
+ q3map2/game_nexuiz.h
+ q3map2/game_prophecy.h
+ q3map2/game_qfusion.h
+ q3map2/game_quake3.h
+ q3map2/game_quakelive.h
+ q3map2/game_reaction.h
+ q3map2/game_sof2.h
+ q3map2/game_tenebrae.h
+ q3map2/game_tremulous.h
+ q3map2/game_unvanquished.h
+ q3map2/game_wolf.h
+ q3map2/game_wolfet.h
+ q3map2/game_xonotic.h
+ )
+
+radiant_tool(q3map2
+ common/cmdlib.c common/cmdlib.h
+ common/imagelib.c common/imagelib.h
+ common/inout.c common/inout.h
+ common/jpeg.c
+ common/md4.c common/md4.h
+ common/mutex.c common/mutex.h
+ common/polylib.c common/polylib.h
+ common/polyset.h
+ common/qfiles.h
+ common/qthreads.h
+ common/scriplib.c common/scriplib.h
+ common/surfaceflags.h
+ common/threads.c
+ common/vfs.c common/vfs.h
+
+ q3map2/brush.c
+ q3map2/brush_primit.c
+ q3map2/bsp.c
+ q3map2/bsp_analyze.c
+ q3map2/bsp_info.c
+ q3map2/bsp_scale.c
+ q3map2/bspfile_abstract.c
+ q3map2/bspfile_ibsp.c
+ q3map2/bspfile_rbsp.c
+ q3map2/convert_ase.c
+ q3map2/convert_bsp.c
+ q3map2/convert_map.c
+ q3map2/convert_obj.c
+ q3map2/decals.c
+ q3map2/exportents.c
+ q3map2/facebsp.c
+ q3map2/fixaas.c
+ q3map2/fog.c
+ ${q3map2_games} q3map2/game__null.h
+ q3map2/help.c
+ q3map2/image.c
+ q3map2/leakfile.c
+ q3map2/light.c
+ q3map2/light_bounce.c
+ q3map2/light_trace.c
+ q3map2/light_ydnar.c
+ q3map2/lightmaps_ydnar.c
+ q3map2/main.c
+ q3map2/map.c
+ q3map2/mesh.c
+ q3map2/minimap.c
+ q3map2/model.c
+ q3map2/patch.c
+ q3map2/path_init.c
+ q3map2/portals.c
+ q3map2/prtfile.c
+ q3map2/q3map2.h
+ q3map2/shaders.c
+ q3map2/surface.c
+ q3map2/surface_extra.c
+ q3map2/surface_foliage.c
+ q3map2/surface_fur.c
+ q3map2/surface_meta.c
+ q3map2/tjunction.c
+ q3map2/tree.c
+ q3map2/vis.c
+ q3map2/visflow.c
+ q3map2/writebsp.c
+ )
+
+if (BUILD_CRUNCH)
+ set(OPTIONAL_IMAGE_LIBRARIES crnrgba)
+ set(OPTIONAL_IMAGE_DEFINES BUILD_CRUNCH=1)
+endif ()
+
+target_compile_definitions(q3map2
+ PRIVATE
+ ${OPTIONAL_IMAGE_DEFINES}
+ )
+
+target_link_libraries(q3map2
+ ${GLIB_LIBRARIES}
+ ${JPEG_LIBRARIES}
+ ${PNG_LIBRARIES}
+ ${WEBP_LIBRARIES}
+ ${LIBXML2_LIBRARIES}
+ ${Minizip_LIBRARIES}
+ ${ZLIB_LIBRARIES}
+ ${OPTIONAL_IMAGE_LIBRARIES}
+ ddslib
+ etclib
+ filematch
+ l_net
+ mathlib
+ picomodel
+ )
+
+radiant_tool(q3data
+ common/aselib.c common/aselib.h
+ common/bspfile.c common/bspfile.h
+ common/cmdlib.c common/cmdlib.h
+ common/imagelib.c common/imagelib.h
+ common/inout.c common/inout.h
+ common/md4.c common/md4.h
+ common/scriplib.c common/scriplib.h
+ common/trilib.c common/trilib.h
+ common/vfs.c common/vfs.h
+
+ q3data/3dslib.c q3data/3dslib.h
+ q3data/compress.c
+ q3data/images.c
+ q3data/md3lib.c q3data/md3lib.h
+ q3data/models.c
+ q3data/p3dlib.c q3data/p3dlib.h
+ q3data/polyset.c
+ q3data/q3data.c q3data/q3data.h
+ q3data/stripper.c
+ q3data/video.c
+ )
+
+target_link_libraries(q3data
+ ${GLIB_LIBRARIES}
+ ${LIBXML2_LIBRARIES}
+ ${Minizip_LIBRARIES}
+ ${ZLIB_LIBRARIES}
+ filematch
+ etclib
+ l_net
+ mathlib
+ )
+
+add_custom_target(quake3)
+add_dependencies(quake3 q3map2 q3data)
+
+if (UNIX)
+ target_link_libraries(q3map2 pthread m)
+ target_link_libraries(q3data m)
+endif ()
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
#include "aselib.h"
+#include "globaldefs.h"
#include "inout.h"
#include <assert.h>
static void ASE_Process( void );
static void ASE_FreeGeomObject( int ndx );
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
static char* strlwr( char* string ){
char *cp;
{
numFramesInAnimation = pObject->anim.numFrames;
if ( maxFrames != -1 ) {
- Sys_Printf( "WARNING: ASE_GetSurfaceAnimation maxFrames > numFramesInAnimation\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: ASE_GetSurfaceAnimation maxFrames > numFramesInAnimation\n" );
}
}
}
static void ASE_KeyMAP_DIFFUSE( const char *token ){
- char fullpath[1024], bitmap[1024], modeldir[1024];
+ char bitmap[1024];
char filename[1024];
- int i = 0, count;
+ int i = 0;
strcpy( filename, gl_filename );
else
{
sprintf( ase.materials[ase.numMaterials].name, "(not converted: '%s')", bitmap );
- Sys_Printf( "WARNING: illegal material name '%s'\n", bitmap );
+ Sys_FPrintf( SYS_WRN, "WARNING: illegal material name '%s'\n", bitmap );
}
}
else
}
}
else if ( s_token[0] ) {
- Sys_Printf( "Unknown token '%s'\n", s_token );
+ Error( "Unknown token '%s'\n", s_token );
}
}
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
=============
*/
int GetLumpElements( dheader_t *header, int lump, int size ) {
- int length, ofs;
-
- length = header->lumps[lump].filelen;
- ofs = header->lumps[lump].fileofs;
+ int length = header->lumps[lump].filelen;
if ( length % size ) {
Error( "LoadBSPFile: odd lump size" );
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// replaced qprintf with Sys_Printf
#include "cmdlib.h"
+#include "globaldefs.h"
#include "mathlib.h"
#include "inout.h"
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <direct.h>
#include <windows.h>
#endif
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#include <unistd.h>
#endif
#define MAX_EX_ARGC 1024
int ex_argc;
char *ex_argv[MAX_EX_ARGC];
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
#include "io.h"
void ExpandWildcards( int *argc, char ***argv ){
struct _finddata_t fileinfo;
void Q_getwd( char *out ){
int i = 0;
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
_getcwd( out, 256 );
strcat( out, "\\" );
#else
int retry = 2;
while ( retry-- )
{
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
const char *q = NULL;
if ( _mkdir( path ) != -1 ) {
return;
============================================================================
*/
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
short LittleShort( short l ){
byte b1,b2;
char c;
char dir[1024];
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
int olddrive = -1;
if ( path[1] == ':' ) {
}
}
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
if ( olddrive != -1 ) {
_chdrive( olddrive );
}
}
void Sys_Sleep( int n ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
Sleep( n );
#endif
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
usleep( n * 1000 );
#endif
}
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#define __CMDLIB__
#include "bytebool.h"
+#include "globaldefs.h"
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
#pragma warning(disable : 4244) // MIPS
#pragma warning(disable : 4136) // X86
#pragma warning(disable : 4051) // ALPHA
#include <time.h>
#include <stdarg.h>
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
#pragma intrinsic( memset, memcpy )
double I_FloatTime( void );
-void Error( const char *error, ... )
-#ifdef __GNUC__
-__attribute__( ( noreturn ) )
-#endif
-;
+void Error( const char *error, ... ) GDEF_ATTRIBUTE_NORETURN;
int CheckParm( const char *check );
FILE *SafeOpenWrite( const char *filename );
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#include "inout.h"
#include "cmdlib.h"
+#include "etclib.h"
#include "imagelib.h"
#include "vfs.h"
void WriteTGAGray( const char *filename, byte *data, int width, int height ) {
byte buffer[18];
- FILE *f;
+ FILE *f;
memset( buffer, 0, 18 );
buffer[2] = 3; // uncompressed type
}
}
}
+
+
+/*
+ ============================================================================
+
+ KHRONOS TEXTURE
+
+ ============================================================================
+ */
+
+
+#define KTX_UINT32_LE( buf ) ( ( unsigned int )( (buf)[0] | ( (buf)[1] << 8 ) | ( (buf)[2] << 16 ) | ( (buf)[3] << 24 ) ) )
+#define KTX_UINT32_BE( buf ) ( ( unsigned int )( (buf)[3] | ( (buf)[2] << 8 ) | ( (buf)[1] << 16 ) | ( (buf)[0] << 24 ) ) )
+
+#define KTX_TYPE_UNSIGNED_BYTE 0x1401
+#define KTX_TYPE_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define KTX_TYPE_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define KTX_TYPE_UNSIGNED_SHORT_5_6_5 0x8363
+
+#define KTX_FORMAT_ALPHA 0x1906
+#define KTX_FORMAT_RGB 0x1907
+#define KTX_FORMAT_RGBA 0x1908
+#define KTX_FORMAT_LUMINANCE 0x1909
+#define KTX_FORMAT_LUMINANCE_ALPHA 0x190A
+#define KTX_FORMAT_BGR 0x80E0
+#define KTX_FORMAT_BGRA 0x80E1
+
+#define KTX_FORMAT_ETC1_RGB8 0x8D64
+
+static void KTX_DecodeA8( const byte *in, qboolean bigEndian, byte *out ){
+ out[0] = out[1] = out[2] = 0;
+ out[3] = in[0];
+}
+
+static void KTX_DecodeRGB8( const byte *in, qboolean bigEndian, byte *out ){
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = 255;
+}
+
+static void KTX_DecodeRGBA8( const byte *in, qboolean bigEndian, byte *out ){
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = in[3];
+}
+
+static void KTX_DecodeL8( const byte *in, qboolean bigEndian, byte *out ){
+ out[0] = out[1] = out[2] = in[0];
+ out[3] = 255;
+}
+
+static void KTX_DecodeLA8( const byte *in, qboolean bigEndian, byte *out ){
+ out[0] = out[1] = out[2] = in[0];
+ out[3] = in[1];
+}
+
+static void KTX_DecodeBGR8( const byte *in, qboolean bigEndian, byte *out ){
+ out[0] = in[2];
+ out[1] = in[1];
+ out[2] = in[0];
+ out[3] = 255;
+}
+
+static void KTX_DecodeBGRA8( const byte *in, qboolean bigEndian, byte *out ){
+ out[0] = in[2];
+ out[1] = in[1];
+ out[2] = in[0];
+ out[3] = in[3];
+}
+
+static void KTX_DecodeRGBA4( const byte *in, qboolean bigEndian, byte *out ){
+ unsigned short rgba;
+ int r, g, b, a;
+
+ if ( bigEndian ) {
+ rgba = ( in[0] << 8 ) | in[1];
+ }
+ else {
+ rgba = ( in[1] << 8 ) | in[0];
+ }
+
+ r = ( rgba >> 12 ) & 0xf;
+ g = ( rgba >> 8 ) & 0xf;
+ b = ( rgba >> 4 ) & 0xf;
+ a = rgba & 0xf;
+ out[0] = ( r << 4 ) | r;
+ out[1] = ( g << 4 ) | g;
+ out[2] = ( b << 4 ) | b;
+ out[3] = ( a << 4 ) | a;
+}
+
+static void KTX_DecodeRGBA5( const byte *in, qboolean bigEndian, byte *out ){
+ unsigned short rgba;
+ int r, g, b;
+
+ if ( bigEndian ) {
+ rgba = ( in[0] << 8 ) | in[1];
+ }
+ else {
+ rgba = ( in[1] << 8 ) | in[0];
+ }
+
+ r = ( rgba >> 11 ) & 0x1f;
+ g = ( rgba >> 6 ) & 0x1f;
+ b = ( rgba >> 1 ) & 0x1f;
+ out[0] = ( r << 3 ) | ( r >> 2 );
+ out[1] = ( g << 3 ) | ( g >> 2 );
+ out[2] = ( b << 3 ) | ( b >> 2 );
+ out[3] = ( rgba & 1 ) * 255;
+}
+
+static void KTX_DecodeRGB5( const byte *in, qboolean bigEndian, byte *out ){
+ unsigned short rgba;
+ int r, g, b;
+
+ if ( bigEndian ) {
+ rgba = ( in[0] << 8 ) | in[1];
+ }
+ else {
+ rgba = ( in[1] << 8 ) | in[0];
+ }
+
+ r = ( rgba >> 11 ) & 0x1f;
+ g = ( rgba >> 5 ) & 0x3f;
+ b = rgba & 0x1f;
+ out[0] = ( r << 3 ) | ( r >> 2 );
+ out[1] = ( g << 2 ) | ( g >> 4 );
+ out[2] = ( b << 3 ) | ( b >> 2 );
+ out[3] = 255;
+}
+
+typedef struct
+{
+ unsigned int type;
+ unsigned int format;
+ unsigned int pixelSize;
+ void ( *decode )( const byte *in, qboolean bigEndian, byte *out );
+} KTX_UncompressedFormat_t;
+
+static const KTX_UncompressedFormat_t KTX_UncompressedFormats[] =
+{
+ { KTX_TYPE_UNSIGNED_BYTE, KTX_FORMAT_ALPHA, 1, KTX_DecodeA8 },
+ { KTX_TYPE_UNSIGNED_BYTE, KTX_FORMAT_RGB, 3, KTX_DecodeRGB8 },
+ { KTX_TYPE_UNSIGNED_BYTE, KTX_FORMAT_RGBA, 4, KTX_DecodeRGBA8 },
+ { KTX_TYPE_UNSIGNED_BYTE, KTX_FORMAT_LUMINANCE, 1, KTX_DecodeL8 },
+ { KTX_TYPE_UNSIGNED_BYTE, KTX_FORMAT_LUMINANCE_ALPHA, 2, KTX_DecodeLA8 },
+ { KTX_TYPE_UNSIGNED_BYTE, KTX_FORMAT_BGR, 3, KTX_DecodeBGR8 },
+ { KTX_TYPE_UNSIGNED_BYTE, KTX_FORMAT_BGRA, 4, KTX_DecodeBGRA8 },
+ { KTX_TYPE_UNSIGNED_SHORT_4_4_4_4, KTX_FORMAT_RGBA, 2, KTX_DecodeRGBA4 },
+ { KTX_TYPE_UNSIGNED_SHORT_5_5_5_1, KTX_FORMAT_RGBA, 2, KTX_DecodeRGBA5 },
+ { KTX_TYPE_UNSIGNED_SHORT_5_6_5, KTX_FORMAT_RGB, 2, KTX_DecodeRGB5 },
+ { 0, 0, 0, NULL }
+};
+
+static qboolean KTX_DecodeETC1( const byte* in, size_t inSize, unsigned int width, unsigned int height, byte* out ){
+ unsigned int y, stride = width * 4;
+ byte rgba[64];
+
+ if ( inSize < ( ( ( ( width + 3 ) & ~3 ) * ( ( height + 3 ) & ~3 ) ) >> 1 ) ) {
+ return qfalse;
+ }
+
+ for ( y = 0; y < height; y += 4, out += stride * 4 )
+ {
+ byte *p;
+ unsigned int x, blockrows;
+
+ blockrows = height - y;
+ if ( blockrows > 4 ) {
+ blockrows = 4;
+ }
+
+ p = out;
+ for ( x = 0; x < width; x += 4, p += 16 )
+ {
+ unsigned int blockrowsize, blockrow;
+
+ ETC_DecodeETC1Block( in, rgba, qtrue );
+ in += 8;
+
+ blockrowsize = width - x;
+ if ( blockrowsize > 4 ) {
+ blockrowsize = 4;
+ }
+ blockrowsize *= 4;
+ for ( blockrow = 0; blockrow < blockrows; blockrow++ )
+ {
+ memcpy( p + blockrow * stride, rgba + blockrow * 16, blockrowsize );
+ }
+ }
+ }
+
+ return qtrue;
+}
+
+#define KTX_HEADER_UINT32( buf ) ( bigEndian ? KTX_UINT32_BE( buf ) : KTX_UINT32_LE( buf ) )
+
+void LoadKTXBufferFirstImage( const byte *buffer, size_t bufSize, byte **pic, int *picWidth, int *picHeight ){
+ unsigned int type, format, width, height, imageOffset;
+ byte *pixels;
+
+ if ( bufSize < 64 ) {
+ Error( "LoadKTX: Image doesn't have a header" );
+ }
+
+ if ( memcmp( buffer, "\xABKTX 11\xBB\r\n\x1A\n", 12 ) ) {
+ Error( "LoadKTX: Image has the wrong identifier" );
+ }
+
+ qboolean bigEndian = ( buffer[4] == 4 );
+
+ type = KTX_HEADER_UINT32( buffer + 16 );
+ if ( type ) {
+ format = KTX_HEADER_UINT32( buffer + 32 );
+ }
+ else {
+ format = KTX_HEADER_UINT32( buffer + 28 );
+ }
+
+ width = KTX_HEADER_UINT32( buffer + 36 );
+ height = KTX_HEADER_UINT32( buffer + 40 );
+ if ( !width ) {
+ Error( "LoadKTX: Image has zero width" );
+ }
+ if ( !height ) {
+ height = 1;
+ }
+ if ( picWidth ) {
+ *picWidth = width;
+ }
+ if ( picHeight ) {
+ *picHeight = height;
+ }
+
+ imageOffset = 64 + KTX_HEADER_UINT32( buffer + 60 ) + 4;
+ if ( bufSize < imageOffset ) {
+ Error( "LoadKTX: No image in the file" );
+ }
+ buffer += imageOffset;
+ bufSize -= imageOffset;
+
+ pixels = safe_malloc( width * height * 4 );
+ *pic = pixels;
+
+ if ( type ) {
+ const KTX_UncompressedFormat_t *ktxFormat = KTX_UncompressedFormats;
+ unsigned int pixelSize;
+ unsigned int inRowLength, inPadding;
+ unsigned int y;
+
+ while ( ktxFormat->type )
+ {
+ if ( ktxFormat->type == type && ktxFormat->format == format ) {
+ break;
+ }
+ ktxFormat++;
+ }
+ if ( !ktxFormat->type ) {
+ Error( "LoadKTX: Image has an unsupported pixel type 0x%X or format 0x%X", type, format );
+ }
+
+ pixelSize = ktxFormat->pixelSize;
+ inRowLength = width * pixelSize;
+ inPadding = ( ( inRowLength + 3 ) & ~3 ) - inRowLength;
+
+ if ( bufSize < height * ( inRowLength + inPadding ) ) {
+ Error( "LoadKTX: Image is truncated" );
+ }
+
+ for ( y = 0; y < height; y++ )
+ {
+ unsigned int x;
+ for ( x = 0; x < width; x++, buffer += pixelSize, pixels += 4 )
+ {
+ ktxFormat->decode( buffer, bigEndian, pixels );
+ }
+ buffer += inPadding;
+ }
+ }
+ else {
+ qboolean decoded = qfalse;
+
+ switch ( format )
+ {
+ case KTX_FORMAT_ETC1_RGB8:
+ decoded = KTX_DecodeETC1( buffer, bufSize, width, height, pixels );
+ break;
+ default:
+ Error( "LoadKTX: Image has an unsupported compressed format format 0x%X", format );
+ break;
+ }
+
+ if ( !decoded ) {
+ Error( "LoadKTX: Image is truncated" );
+ }
+ }
+}
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
int LoadJPGBuff( void *src_buffer, int src_size, unsigned char **pic, int *width, int *height );
void Load32BitImage( const char *name, unsigned **pixels, int *width, int *height );
+
+void LoadKTXBufferFirstImage( const byte *buffer, size_t bufSize, byte **pic, int *picWidth, int *picHeight );
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// deal with in/out tasks, for either stdin/stdout or network/XML stream
//
+#include "globaldefs.h"
#include "cmdlib.h"
#include "mathlib.h"
#include "polylib.h"
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <direct.h>
#include <windows.h>
#endif
// utf8 conversion
#include <glib.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
HWND hwndOut = NULL;
qboolean lookedForServer = qfalse;
UINT wm_BroadcastCommand = -1;
netmessage_t msg;
qboolean verbose = qfalse;
+qboolean werror = qfalse;
// our main document
// is streamed through the network to Radiant
xmlNodeAddContent( node, (xmlChar*)buf );
level[0] = (int)'0' + ( bError ? SYS_ERR : SYS_WRN ) ;
level[1] = 0;
- xmlSetProp( node, (xmlChar*)"level", (xmlChar *)&level );
+ xmlSetProp( node, (xmlChar*)"level", (xmlChar*)&level );
// a 'select' information
sprintf( buf, "%i %i", entitynum, brushnum );
select = xmlNewNode( NULL, (xmlChar*)"brush" );
vsprintf( out_buffer, format, argptr );
va_end( argptr );
+ if ( ( flag == SYS_WRN ) && ( werror == qtrue ) ) {
+ Error( out_buffer );
+ return;
+ }
+
FPrintf( flag, out_buffer );
}
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#ifndef __INOUT__
#define __INOUT__
+#include "globaldefs.h"
// inout is the only stuff relying on xml, include the headers there
#include "libxml/tree.h"
#include "mathlib.h"
#define SYS_NOXML 4 // don't send that down the XML stream
extern qboolean verbose;
+extern qboolean werror;
void Sys_Printf( const char *text, ... );
void Sys_FPrintf( int flag, const char *text, ... );
-#ifdef _DEBUG
+#if GDEF_DEBUG
#define DBG_XML 1
#endif
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
+#include "globaldefs.h"
#include "cmdlib.h"
#include "qthreads.h"
#include "mutex.h"
===================================================================
*/
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#define USED
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
#include "cmdlib.h"
#include "mathlib.h"
#include "inout.h"
=============
*/
void ClipWindingEpsilonStrict( winding_t *in, vec3_t normal, vec_t dist,
- vec_t epsilon, winding_t **front, winding_t **back ){
+ vec_t epsilon, winding_t **front, winding_t **back ){
vec_t dists[MAX_POINTS_ON_WINDING + 4];
int sides[MAX_POINTS_ON_WINDING + 4];
int counts[3];
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
*/
void AddScriptToStack( const char *filename, int index ){
int size;
+ void* buffer;
script++;
if ( script == &scriptstack[MAX_INCLUDES] ) {
}
strcpy( script->filename, ExpandPath( filename ) );
- size = vfsLoadFile( script->filename, (void **)&script->buffer, index );
+ size = vfsLoadFile( script->filename, &buffer, index );
if ( size == -1 ) {
Sys_Printf( "Script file %s was not found\n", script->filename );
+ script--;
}
else
{
else{
Sys_Printf( "entering %s\n", script->filename );
}
- }
- script->line = 1;
- script->script_p = script->buffer;
- script->end_p = script->buffer + size;
+ script->buffer = buffer;
+ script->line = 1;
+ script->script_p = script->buffer;
+ script->end_p = script->buffer + size;
+ }
}
}
if ( script->buffer == NULL ) {
- Sys_Printf( "WARNING: Attempt to free already freed script buffer\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Attempt to free already freed script buffer\n" );
}
else{
free( script->buffer );
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef WIN32
+#include "globaldefs.h"
+#include <stdint.h>
+#if !GDEF_OS_WINDOWS
// The below define is necessary to use
// pthreads extensions like pthread_mutexattr_settype
#define _GNU_SOURCE
f = 40 * dispatch / workcount;
if ( f < oldf ) {
- Sys_Printf( "warning: progress went backwards (should never happen)\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: progress went backwards (should never happen)\n" );
oldf = f;
}
while ( f > oldf )
===================================================================
*/
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#define USED
=======================================================================
*/
-#if defined( __linux__ ) || ( defined( __APPLE__ ) && !MAC_STATIC_HACK )
+#if GDEF_OS_LINUX || ( GDEF_OS_MACOS && !MAC_STATIC_HACK )
#define USED
#include <unistd.h>
for ( i = 0 ; i < numthreads ; i++ )
{
/* Default pthread attributes: joinable & non-realtime scheduling */
- if ( pthread_create( &work_threads[i], &attr, (void*)func, (void*)(size_t)i ) != 0 ) {
+ if ( pthread_create(&work_threads[i], &attr, (void *(*)(void *)) func, (void*)(uintptr_t)i ) != 0 ) {
Error( "pthread_create failed" );
}
}
=============
*/
void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
- int i;
int start, end;
dispatch = 0;
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// trilib.c: library for loading triangles from an Alias triangle file
//
+#include "globaldefs.h"
#include <stdio.h>
#include "cmdlib.h"
#include "mathlib.h"
//#define NOISY 1
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#define strlwr strlower
#endif
static void ByteSwapTri( tf_triangle *tri ){
- int i;
+ unsigned int i;
for ( i = 0 ; i < sizeof( tf_triangle ) / 4 ; i++ )
{
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
+++ /dev/null
-/*
-WARNING: DO NOT UNCRUSTIFY
-It will still compile after an uncrustify, but it will be *broken*
-See https://github.com/TTimo/GtkRadiant/issues/33
-*/
-
-/*
-Copyright (C) 1999-2007 id Software, Inc. and contributors.
-For a list of contributors, see the accompanying CONTRIBUTORS file.
-
-This file is part of GtkRadiant.
-
-GtkRadiant 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.
-
-GtkRadiant 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 GtkRadiant; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-/*****************************************************************************
- * name: unzip.c
- *
- * desc: IO on .zip files using portions of zlib
- *
- *
- *****************************************************************************/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "unzip.h"
-
-// TTimo added for safe_malloc wrapping
-#include "cmdlib.h"
-
-/* unzip.h -- IO for uncompress .zip files using zlib
- Version 0.15 beta, Mar 19th, 1998,
-
- Copyright (C) 1998 Gilles Vollant
-
- This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
- WinZip, InfoZip tools and compatible.
- Encryption and multi volume ZipFile (span) are not supported.
- Old compressions used by old PKZip 1.x are not supported
-
- THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
- CAN CHANGE IN FUTURE VERSION !!
- I WAIT FEEDBACK at mail info@winimage.com
- Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
-
- Condition of use and distribution are the same than zlib :
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
-
-*/
-/* for more info about .ZIP format, see
- ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
- PkWare has also a specification at :
- ftp://ftp.pkware.com/probdesc.zip */
-
-/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.1.3, July 9th, 1998
-
- Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-
- The data format used by the zlib library is described by RFCs (Request for
- Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
- (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
-*/
-
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-1998 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-
-#ifndef _ZCONF_H
-#define _ZCONF_H
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- (1 << (windowBits+2)) + (1 << (memLevel+9))
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-#define OF(args) args
-#endif
-
-typedef unsigned char Byte; /* 8 bits */
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-typedef Byte *voidp;
-
-#ifndef SEEK_SET
-# define SEEK_SET 0 /* Seek from beginning of file. */
-# define SEEK_CUR 1 /* Seek from current position. */
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
-#endif
-
-#endif /* _ZCONF_H */
-
-#define ZLIB_VERSION "1.1.3"
-
-/*
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed
- data. This version of the library supports only one compression method
- (deflation) but other algorithms will be added later and will have the same
- stream interface.
-
- Compression can be done in a single step if the buffers are large
- enough (for example if an input file is mmap'ed), or can be done by
- repeated calls of the compression function. In the latter case, the
- application must provide more input and/or consume the output
- (providing more output space) before each call.
-
- The library also supports reading and writing files in gzip (.gz) format
- with an interface similar to that of stdio.
-
- The library does not install any signal handler. The decoder checks
- the consistency of the compressed data, so the library should never
- crash even in case of corrupted input.
-*/
-
-/*
- The application must update next_in and avail_in when avail_in has
- dropped to zero. It must update next_out and avail_out when avail_out
- has dropped to zero. The application must initialize zalloc, zfree and
- opaque before calling the init function. All other fields are set by the
- compression library and must not be updated by the application.
-
- The opaque value provided by the application will be passed as the first
- parameter for calls of zalloc and zfree. This can be useful for custom
- memory management. The compression library attaches no meaning to the
- opaque value.
-
- zalloc must return Z_NULL if there is not enough memory for the object.
- If zlib is used in a multi-threaded application, zalloc and zfree must be
- thread safe.
-
- On 16-bit systems, the functions zalloc and zfree must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this
- if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
- pointers returned by zalloc for objects of exactly 65536 bytes *must*
- have their offset normalized to zero. The default allocation function
- provided by this library ensures this (see zutil.c). To reduce memory
- requirements and avoid any allocation of 64K objects, at the expense of
- compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
-
- The fields total_in and total_out can be used for statistics or
- progress reports. After compression, total_in holds the total size of
- the uncompressed data and may be saved for use in the decompressor
- (particularly if the decompressor wants to decompress everything in
- a single step).
-*/
-
- /* constants */
-
-#define Z_NO_FLUSH 0
-#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
-#define Z_SYNC_FLUSH 2
-#define Z_FULL_FLUSH 3
-#define Z_FINISH 4
-/* Allowed flush values; see deflate() below for details */
-
-#define Z_OK 0
-#define Z_STREAM_END 1
-#define Z_NEED_DICT 2
-#define Z_ERRNO (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR (-3)
-#define Z_MEM_ERROR (-4)
-#define Z_BUF_ERROR (-5)
-#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative
- * values are errors, positive values are used for special but normal events.
- */
-
-#define Z_NO_COMPRESSION 0
-#define Z_BEST_SPEED 1
-#define Z_BEST_COMPRESSION 9
-#define Z_DEFAULT_COMPRESSION (-1)
-/* compression levels */
-
-#define Z_FILTERED 1
-#define Z_HUFFMAN_ONLY 2
-#define Z_DEFAULT_STRATEGY 0
-/* compression strategy; see deflateInit2() below for details */
-
-#define Z_BINARY 0
-#define Z_ASCII 1
-#define Z_UNKNOWN 2
-/* Possible values of the data_type field */
-
-#define Z_DEFLATED 8
-/* The deflate compression method (the only one supported in this version) */
-
-#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
-
-#define zlib_version zlibVersion()
-/* for compatibility with versions < 1.0.2 */
-
- /* basic functions */
-
-const char * zlibVersion OF((void));
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is
- not compatible with the zlib.h header file used by the application.
- This check is automatically made by deflateInit and inflateInit.
- */
-
-/*
-int deflateInit OF((z_streamp strm, int level));
-
- Initializes the internal stream state for compression. The fields
- zalloc, zfree and opaque must be initialized before by the caller.
- If zalloc and zfree are set to Z_NULL, deflateInit updates them to
- use default allocation functions.
-
- The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
- 1 gives best speed, 9 gives best compression, 0 gives no compression at
- all (the input data is simply copied a block at a time).
- Z_DEFAULT_COMPRESSION requests a default compromise between speed and
- compression (currently equivalent to level 6).
-
- deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if level is not a valid compression level,
- Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
- with the version assumed by the caller (ZLIB_VERSION).
- msg is set to null if there is no error message. deflateInit does not
- perform any compression: this will be done by deflate().
-*/
-
-
-int deflate OF((z_streamp strm, int flush));
-/*
- deflate compresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce some
- output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. deflate performs one or both of the
- following actions:
-
- - Compress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in and avail_in are updated and
- processing will resume at this point for the next call of deflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. This action is forced if the parameter flush is non zero.
- Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications).
- Some output may be provided even if flush is not set.
-
- Before the call of deflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating avail_in or avail_out accordingly; avail_out
- should never be zero before the call. The application can consume the
- compressed output when it wants, for example when the output buffer is full
- (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
- and with zero avail_out, it must be called again after making room in the
- output buffer because there might be more output pending.
-
- If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
- flushed to the output buffer and the output is aligned on a byte boundary, so
- that the decompressor can get all input data available so far. (In particular
- avail_in is zero after the call if enough output space has been provided
- before the call.) Flushing may degrade compression for some compression
- algorithms and so it should be used only when necessary.
-
- If flush is set to Z_FULL_FLUSH, all output is flushed as with
- Z_SYNC_FLUSH, and the compression state is reset so that decompression can
- restart from this point if previous compressed data has been damaged or if
- random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
- the compression.
-
- If deflate returns with avail_out == 0, this function must be called again
- with the same value of the flush parameter and more output space (updated
- avail_out), until the flush is complete (deflate returns with non-zero
- avail_out).
-
- If the parameter flush is set to Z_FINISH, pending input is processed,
- pending output is flushed and deflate returns with Z_STREAM_END if there
- was enough output space; if deflate returns with Z_OK, this function must be
- called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the
- stream are deflateReset or deflateEnd.
-
- Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least
- 0.1% larger than avail_in plus 12 bytes. If deflate does not return
- Z_STREAM_END, then it must be called again as described above.
-
- deflate() sets strm->adler to the adler32 checksum of all input read
- so (that is, total_in bytes).
-
- deflate() may update data_type if it can make a good guess about
- the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect
- the compression algorithm in any manner.
-
- deflate() returns Z_OK if some progress has been made (more input
- processed or more output produced), Z_STREAM_END if all input has been
- consumed and all output has been produced (only when flush is set to
- Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero).
-*/
-
-
-int deflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
- stream state was inconsistent, Z_DATA_ERROR if the stream was freed
- prematurely (some input or output was discarded). In the error case,
- msg may be set but then points to a static string (which must not be
- deallocated).
-*/
-
-
-/*
-int inflateInit OF((z_streamp strm));
-
- Initializes the internal stream state for decompression. The fields
- next_in, avail_in, zalloc, zfree and opaque must be initialized before by
- the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
- value depends on the compression method), inflateInit determines the
- compression method from the zlib header and allocates all data structures
- accordingly; otherwise the allocation will be deferred to the first call of
- inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
- use default allocation functions.
-
- inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
- version assumed by the caller. msg is set to null if there is no error
- message. inflateInit does not perform any decompression apart from reading
- the zlib header if present: this will be done by inflate(). (So next_in and
- avail_in may be modified, but next_out and avail_out are unchanged.)
-*/
-
-
-int inflate OF((z_streamp strm, int flush));
-/*
- inflate decompresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may some
- introduce some output latency (reading input without producing any output)
- except when forced to flush.
-
- The detailed semantics are as follows. inflate performs one or both of the
- following actions:
-
- - Decompress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing
- will resume at this point for the next call of inflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. inflate() provides as much output as possible, until there
- is no more input data or no more space in the output buffer (see below
- about the flush parameter).
-
- Before the call of inflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating the next_* and avail_* values accordingly.
- The application can consume the uncompressed output when it wants, for
- example when the output buffer is full (avail_out == 0), or after each
- call of inflate(). If inflate returns Z_OK and with zero avail_out, it
- must be called again after making room in the output buffer because there
- might be more output pending.
-
- If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
- output as possible to the output buffer. The flushing behavior of inflate is
- not specified for values of the flush parameter other than Z_SYNC_FLUSH
- and Z_FINISH, but the current implementation actually flushes as much output
- as possible anyway.
-
- inflate() should normally be called until it returns Z_STREAM_END or an
- error. However if all decompression is to be performed in a single step
- (a single call of inflate), the parameter flush should be set to
- Z_FINISH. In this case all pending input is processed and all pending
- output is flushed; avail_out must be large enough to hold all the
- uncompressed data. (The size of the uncompressed data may have been saved
- by the compressor for this purpose.) The next operation on this stream must
- be inflateEnd to deallocate the decompression state. The use of Z_FINISH
- is never required, but can be used to inform inflate that a faster routine
- may be used for the single inflate() call.
-
- If a preset dictionary is needed at this point (see inflateSetDictionary
- below), inflate sets strm-adler to the adler32 checksum of the
- dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
- it sets strm->adler to the adler32 checksum of all output produced
- so (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
- an error code as described below. At the end of the stream, inflate()
- checks that its computed adler32 checksum is equal to that saved by the
- compressor and returns Z_STREAM_END only if the checksum is correct.
-
- inflate() returns Z_OK if some progress has been made (more input processed
- or more output produced), Z_STREAM_END if the end of the compressed data has
- been reached and all uncompressed output has been produced, Z_NEED_DICT if a
- preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
- corrupted (input stream not conforming to the zlib format or incorrect
- adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
- (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if no progress is possible or if there was not
- enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
- case, the application may then call inflateSync to look for a good
- compression block.
-*/
-
-
-int inflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
-*/
-
- /* Advanced functions */
-
-/*
- The following functions are needed only in some special applications.
-*/
-
-/*
-int deflateInit2 OF((z_streamp strm,
- int level,
- int method,
- int windowBits,
- int memLevel,
- int strategy));
-
- This is another version of deflateInit with more compression options. The
- fields next_in, zalloc, zfree and opaque must be initialized before by
- the caller.
-
- The method parameter is the compression method. It must be Z_DEFLATED in
- this version of the library.
-
- The windowBits parameter is the base two logarithm of the window size
- (the size of the history buffer). It should be in the range 8..15 for this
- version of the library. Larger values of this parameter result in better
- compression at the expense of memory usage. The default value is 15 if
- deflateInit is used instead.
-
- The memLevel parameter specifies how much memory should be allocated
- for the internal compression state. memLevel=1 uses minimum memory but
- is slow and reduces compression ratio; memLevel=9 uses maximum memory
- for optimal speed. The default value is 8. See zconf.h for total memory
- usage as a function of windowBits and memLevel.
-
- The strategy parameter is used to tune the compression algorithm. Use the
- value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
- filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
- string match). Filtered data consists mostly of small values with a
- somewhat random distribution. In this case, the compression algorithm is
- tuned to compress them better. The effect of Z_FILTERED is to force more
- Huffman coding and less string matching; it is somewhat intermediate
- between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
- the compression ratio but not the correctness of the compressed output even
- if it is not set appropriately.
-
- deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
- method). msg is set to null if there is no error message. deflateInit2 does
- not perform any compression: this will be done by deflate().
-*/
-
-int deflateSetDictionary OF((z_streamp strm,
- const Byte *dictionary,
- uInt dictLength));
-/*
- Initializes the compression dictionary from the given byte sequence
- without producing any compressed output. This function must be called
- immediately after deflateInit, deflateInit2 or deflateReset, before any
- call of deflate. The compressor and decompressor must use exactly the same
- dictionary (see inflateSetDictionary).
-
- The dictionary should consist of strings (byte sequences) that are likely
- to be encountered later in the data to be compressed, with the most commonly
- used strings preferably put towards the end of the dictionary. Using a
- dictionary is most useful when the data to be compressed is short and can be
- predicted with good accuracy; the data can then be compressed better than
- with the default empty dictionary.
-
- Depending on the size of the compression data structures selected by
- deflateInit or deflateInit2, a part of the dictionary may in effect be
- discarded, for example if the dictionary is larger than the window size in
- deflate or deflate2. Thus the strings most likely to be useful should be
- put at the end of the dictionary, not at the front.
-
- Upon return of this function, strm->adler is set to the Adler32 value
- of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The Adler32 value
- applies to the whole dictionary even if only a subset of the dictionary is
- actually used by the compressor.)
-
- deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent (for example if deflate has already been called for this stream
- or if the compression method is bsort). deflateSetDictionary does not
- perform any compression: this will be done by deflate().
-*/
-
-int deflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when several compression strategies will be
- tried, for example when there are several ways of pre-processing the input
- data with a filter. The streams that will be discarded should then be freed
- by calling deflateEnd. Note that deflateCopy duplicates the internal
- compression state which can be quite large, so this strategy is slow and
- can consume lots of memory.
-
- deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
- destination.
-*/
-
-int deflateReset OF((z_streamp strm));
-/*
- This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state.
- The stream will keep the same compression level and any other attributes
- that may have been set by deflateInit2.
-
- deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-int deflateParams OF((z_streamp strm,
- int level,
- int strategy));
-/*
- Dynamically update the compression level and compression strategy. The
- interpretation of level and strategy is as in deflateInit2. This can be
- used to switch between compression and straight copy of the input data, or
- to switch to a different kind of input data requiring a different
- strategy. If the compression level is changed, the input available so far
- is compressed with the old level (and may be flushed); the new level will
- take effect only at the next call of deflate().
-
- Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to
- be compressed and flushed. In particular, strm->avail_out must be non-zero.
-
- deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
- if strm->avail_out was zero.
-*/
-
-/*
-int inflateInit2 OF((z_streamp strm,
- int windowBits));
-
- This is another version of inflateInit with an extra parameter. The
- fields next_in, avail_in, zalloc, zfree and opaque must be initialized
- before by the caller.
-
- The windowBits parameter is the base two logarithm of the maximum window
- size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library. The default value is 15 if inflateInit is used
- instead. If a compressed stream with a larger window size is given as
- input, inflate() will return with the error code Z_DATA_ERROR instead of
- trying to allocate a larger window.
-
- inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
- memLevel). msg is set to null if there is no error message. inflateInit2
- does not perform any decompression apart from reading the zlib header if
- present: this will be done by inflate(). (So next_in and avail_in may be
- modified, but next_out and avail_out are unchanged.)
-*/
-
-int inflateSetDictionary OF((z_streamp strm,
- const Byte *dictionary,
- uInt dictLength));
-/*
- Initializes the decompression dictionary from the given uncompressed byte
- sequence. This function must be called immediately after a call of inflate
- if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
- can be determined from the Adler32 value returned by this call of
- inflate. The compressor and decompressor must use exactly the same
- dictionary (see deflateSetDictionary).
-
- inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect Adler32 value). inflateSetDictionary does not
- perform any decompression: this will be done by subsequent calls of
- inflate().
-*/
-
-int inflateSync OF((z_streamp strm));
-/*
- Skips invalid compressed data until a full flush point (see above the
- description of deflate with Z_FULL_FLUSH) can be found, or until all
- available input is skipped. No output is provided.
-
- inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
- if no more input was provided, Z_DATA_ERROR if no flush point has been found,
- or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
- case, the application may save the current current value of total_in which
- indicates where valid compressed data was found. In the error case, the
- application may repeatedly call inflateSync, providing more input each time,
- until success or end of the input data.
-*/
-
-int inflateReset OF((z_streamp strm));
-/*
- This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state.
- The stream will keep attributes that may have been set by inflateInit2.
-
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-
- /* utility functions */
-
-/*
- The following utility functions are implemented on top of the
- basic stream-oriented functions. To simplify the interface, some
- default options are assumed (compression level and memory usage,
- standard memory allocation functions). The source code of these
- utility functions can easily be modified if you need special options.
-*/
-
-int compress OF((Byte *dest, uLong *destLen,
- const Byte *source, uLong sourceLen));
-/*
- Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be at least 0.1% larger than
- sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
- compressed buffer.
- This function can be used to compress a whole file at once if the
- input file is mmap'ed.
- compress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer.
-*/
-
-int compress2 OF((Byte *dest, uLong *destLen,
- const Byte *source, uLong sourceLen,
- int level));
-/*
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least 0.1% larger than sourceLen plus
- 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-
-int uncompress OF((Byte *dest, uLong *destLen,
- const Byte *source, uLong sourceLen));
-/*
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted.
-*/
-
-
-typedef voidp gzFile;
-
-gzFile gzopen OF((const char *path, const char *mode));
-/*
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb") but can also include a compression level
- ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
- Huffman only compression as in "wb1h". (See the description
- of deflateInit2 for more information about the strategy parameter.)
-
- gzopen can be used to read a file which is not in gzip format; in this
- case gzread will directly read from the file without decompression.
-
- gzopen returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR). */
-
-gzFile gzdopen OF((int fd, const char *mode));
-/*
- gzdopen() associates a gzFile with the file descriptor fd. File
- descriptors are obtained from calls like open, dup, creat, pipe or
- fileno (in the file has been previously opened with fopen).
- The mode parameter is as in gzopen.
- The next call of gzclose on the returned gzFile will also close the
- file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
- descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
- gzdopen returns NULL if there was insufficient memory to allocate
- the (de)compression state.
-*/
-
-int gzsetparams OF((gzFile file, int level, int strategy));
-/*
- Dynamically update the compression level or strategy. See the description
- of deflateInit2 for the meaning of these parameters.
- gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
- opened for writing.
-*/
-
-int gzread OF((gzFile file, voidp buf, unsigned len));
-/*
- Reads the given number of uncompressed bytes from the compressed file.
- If the input file was not in gzip format, gzread copies the given number
- of bytes into the buffer.
- gzread returns the number of uncompressed bytes actually read (0 for
- end of file, -1 for error). */
-
-int gzwrite OF((gzFile file,
- const voidp buf, unsigned len));
-/*
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of uncompressed bytes actually written
- (0 in case of error).
-*/
-
-int gzprintf OF((gzFile file, const char *format, ...));
-/*
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written (0 in case of error).
-*/
-
-int gzputs OF((gzFile file, const char *s));
-/*
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-
-char * gzgets OF((gzFile file, char *buf, int len));
-/*
- Reads bytes from the compressed file until len-1 characters are read, or
- a newline character is read and transferred to buf, or an end-of-file
- condition is encountered. The string is then terminated with a null
- character.
- gzgets returns buf, or Z_NULL in case of error.
-*/
-
-int gzputc OF((gzFile file, int c));
-/*
- Writes c, converted to an unsigned char, into the compressed file.
- gzputc returns the value that was written, or -1 in case of error.
-*/
-
-int gzgetc OF((gzFile file));
-/*
- Reads one byte from the compressed file. gzgetc returns this byte
- or -1 in case of end of file or error.
-*/
-
-int gzflush OF((gzFile file, int flush));
-/*
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function. The return value is the zlib
- error number (see function gzerror below). gzflush returns Z_OK if
- the flush parameter is Z_FINISH and all output could be flushed.
- gzflush should be called only when strictly necessary because it can
- degrade compression.
-*/
-
-long gzseek OF((gzFile file,
- long offset, int whence));
-/*
- Sets the starting position for the next gzread or gzwrite on the
- given compressed file. The offset represents a number of bytes in the
- uncompressed data stream. The whence parameter is defined as in lseek(2);
- the value SEEK_END is not supported.
- If the file is opened for reading, this function is emulated but can be
- extremely slow. If the file is opened for writing, only forward seeks are
- supported; gzseek then compresses a sequence of zeroes up to the new
- starting position.
-
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error, in
- particular if the file is opened for writing and the new starting position
- would be before the current position.
-*/
-
-int gzrewind OF((gzFile file));
-/*
- Rewinds the given file. This function is supported only for reading.
-
- gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
-*/
-
-long gztell OF((gzFile file));
-/*
- Returns the starting position for the next gzread or gzwrite on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
-
- gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
-*/
-
-int gzeof OF((gzFile file));
-/*
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
-*/
-
-int gzclose OF((gzFile file));
-/*
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state. The return value is the zlib
- error number (see function gzerror below).
-*/
-
-const char * gzerror OF((gzFile file, int *errnum));
-/*
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
-*/
-
- /* checksum functions */
-
-/*
- These functions are not related to compression but are exported
- anyway because they might be useful in applications using the
- compression library.
-*/
-
-uLong adler32 OF((uLong adler, const Byte *buf, uInt len));
-
-/*
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is NULL, this function returns
- the required initial value for the checksum.
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster. Usage example:
-
- uLong adler = adler32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- adler = adler32(adler, buffer, length);
- }
- if (adler != original_adler) error();
-*/
-
-uLong crc32 OF((uLong crc, const Byte *buf, uInt len));
-/*
- Update a running crc with the bytes buf[0..len-1] and return the updated
- crc. If buf is NULL, this function returns the required initial value
- for the crc. Pre- and post-conditioning (one's complement) is performed
- within this function so it shouldn't be done by the application.
- Usage example:
-
- uLong crc = crc32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- crc = crc32(crc, buffer, length);
- }
- if (crc != original_crc) error();
-*/
-
-// private stuff to not include cmdlib.h
-/*
-============================================================================
-
- BYTE ORDER FUNCTIONS
-
-============================================================================
-*/
-
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
-
-short __LittleShort (short l)
-{
- byte b1,b2;
-
- b1 = l&255;
- b2 = (l>>8)&255;
-
- return (b1<<8) + b2;
-}
-
-short __BigShort (short l)
-{
- return l;
-}
-
-
-int __LittleLong (int l)
-{
- byte b1,b2,b3,b4;
-
- b1 = l&255;
- b2 = (l>>8)&255;
- b3 = (l>>16)&255;
- b4 = (l>>24)&255;
-
- return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
-}
-
-int __BigLong (int l)
-{
- return l;
-}
-
-
-float __LittleFloat (float l)
-{
- union {byte b[4]; float f;} in, out;
-
- in.f = l;
- out.b[0] = in.b[3];
- out.b[1] = in.b[2];
- out.b[2] = in.b[1];
- out.b[3] = in.b[0];
-
- return out.f;
-}
-
-float __BigFloat (float l)
-{
- return l;
-}
-
-
-#else
-
-
-short __BigShort (short l)
-{
- byte b1,b2;
-
- b1 = l&255;
- b2 = (l>>8)&255;
-
- return (b1<<8) + b2;
-}
-
-short __LittleShort (short l)
-{
- return l;
-}
-
-
-int __BigLong (int l)
-{
- byte b1,b2,b3,b4;
-
- b1 = l&255;
- b2 = (l>>8)&255;
- b3 = (l>>16)&255;
- b4 = (l>>24)&255;
-
- return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
-}
-
-int __LittleLong (int l)
-{
- return l;
-}
-
-float __BigFloat (float l)
-{
- union {byte b[4]; float f;} in, out;
-
- in.f = l;
- out.b[0] = in.b[3];
- out.b[1] = in.b[2];
- out.b[2] = in.b[1];
- out.b[3] = in.b[0];
-
- return out.f;
-}
-
-float __LittleFloat (float l)
-{
- return l;
-}
-
-
-
-#endif
-
-
-
-
- /* various hacks, don't look :) */
-
-/* deflateInit and inflateInit are macros to allow checking the zlib version
- * and the compiler's view of z_stream:
- */
-int deflateInit_ OF((z_streamp strm, int level,
- const char *version, int stream_size));
-int inflateInit_ OF((z_streamp strm,
- const char *version, int stream_size));
-int deflateInit2_ OF((z_streamp strm, int level, int method,
- int windowBits, int memLevel,
- int strategy, const char *version,
- int stream_size));
-int inflateInit2_ OF((z_streamp strm, int windowBits,
- const char *version, int stream_size));
-#define deflateInit(strm, level) \
- deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit(strm) \
- inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
- (strategy), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
-
-
-const char * zError OF((int err));
-int inflateSyncPoint OF((z_streamp z));
-const uLong * get_crc_table OF((void));
-
-typedef unsigned char uch;
-typedef unsigned short ush;
-typedef unsigned long ulg;
-
-extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
-/* (size given to avoid silly warnings with Visual C++) */
-
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
-
-#define ERR_RETURN(strm,err) \
- return (strm->msg = (char*)ERR_MSG(err), (err))
-/* To be used only when the state is known to be valid */
-
- /* common constants */
-
-#ifndef DEF_WBITS
-# define DEF_WBITS MAX_WBITS
-#endif
-/* default windowBits for decompression. MAX_WBITS is for compression only */
-
-#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-#endif
-/* default memLevel */
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES 2
-/* The three kinds of block type */
-
-#define MIN_MATCH 3
-#define MAX_MATCH 258
-/* The minimum and maximum match lengths */
-
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
-
- /* target dependencies */
-
- /* Common defaults */
-
-#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
-#endif
-
-#ifndef F_OPEN
-# define F_OPEN(name, mode) fopen((name), (mode))
-#endif
-
- /* functions */
-
-#ifdef HAVE_STRERROR
- extern char *strerror OF((int));
-# define zstrerror(errnum) strerror(errnum)
-#else
-# define zstrerror(errnum) ""
-#endif
-
-#define zmemcpy memcpy
-#define zmemcmp memcmp
-#define zmemzero(dest, len) memset(dest, 0, len)
-
-/* Diagnostic functions */
-#ifdef _ZIP_DEBUG_
- int z_verbose = 0;
-# define Assert(cond,msg) assert(cond);
- //{if(!(cond)) Sys_Error(msg);}
-# define Trace(x) {if (z_verbose>=0) Sys_Error x ;}
-# define Tracev(x) {if (z_verbose>0) Sys_Error x ;}
-# define Tracevv(x) {if (z_verbose>1) Sys_Error x ;}
-# define Tracec(c,x) {if (z_verbose>0 && (c)) Sys_Error x ;}
-# define Tracecv(c,x) {if (z_verbose>1 && (c)) Sys_Error x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-
-typedef uLong (*check_func) OF((uLong check, const Byte *buf, uInt len));
-voidp zcalloc OF((voidp opaque, unsigned items, unsigned size));
-void zcfree OF((voidp opaque, voidp ptr));
-
-#define ZALLOC(strm, items, size) \
- (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidp)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
-
-
-#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \
- !defined(CASESENSITIVITYDEFAULT_NO)
-#define CASESENSITIVITYDEFAULT_NO
-#endif
-
-
-#ifndef UNZ_BUFSIZE
-#define UNZ_BUFSIZE (65536)
-#endif
-
-#ifndef UNZ_MAXFILENAMEINZIP
-#define UNZ_MAXFILENAMEINZIP (256)
-#endif
-
-#ifndef ALLOC
-# define ALLOC(size) (safe_malloc(size))
-#endif
-#ifndef TRYFREE
-# define TRYFREE(p) {if (p) free(p);}
-#endif
-
-#define SIZECENTRALDIRITEM (0x2e)
-#define SIZEZIPLOCALHEADER (0x1e)
-
-
-
-/* ===========================================================================
- Read a byte from a gz_stream; update next_in and avail_in. Return EOF
- for end of file.
- IN assertion: the stream s has been sucessfully opened for reading.
-*/
-
-/*
-static int unzlocal_getByte(FILE *fin,int *pi)
-{
- unsigned char c;
- int err = fread(&c, 1, 1, fin);
- if (err==1)
- {
- *pi = (int)c;
- return UNZ_OK;
- }
- else
- {
- if (ferror(fin))
- return UNZ_ERRNO;
- else
- return UNZ_EOF;
- }
-}
-*/
-
-/* ===========================================================================
- Reads a long in LSB order from the given gz_stream. Sets
-*/
-static int unzlocal_getShort (FILE* fin, uLong *pX)
-{
- short v;
-
- if ( fread( &v, sizeof( v ), 1, fin ) != 1 ) {
- return UNZ_EOF;
- }
-
- *pX = __LittleShort( v);
- return UNZ_OK;
-
-/*
- uLong x ;
- int i;
- int err;
-
- err = unzlocal_getByte(fin,&i);
- x = (uLong)i;
-
- if (err==UNZ_OK)
- err = unzlocal_getByte(fin,&i);
- x += ((uLong)i)<<8;
-
- if (err==UNZ_OK)
- *pX = x;
- else
- *pX = 0;
- return err;
-*/
-}
-
-static int unzlocal_getLong (FILE *fin, uLong *pX)
-{
- int v;
-
- if ( fread( &v, sizeof( v ), 1, fin ) != 1 ) {
- return UNZ_EOF;
- }
-
- *pX = __LittleLong( v);
- return UNZ_OK;
-
-/*
- uLong x ;
- int i;
- int err;
-
- err = unzlocal_getByte(fin,&i);
- x = (uLong)i;
-
- if (err==UNZ_OK)
- err = unzlocal_getByte(fin,&i);
- x += ((uLong)i)<<8;
-
- if (err==UNZ_OK)
- err = unzlocal_getByte(fin,&i);
- x += ((uLong)i)<<16;
-
- if (err==UNZ_OK)
- err = unzlocal_getByte(fin,&i);
- x += ((uLong)i)<<24;
-
- if (err==UNZ_OK)
- *pX = x;
- else
- *pX = 0;
- return err;
-*/
-}
-
-
-/* My own strcmpi / strcasecmp */
-static int strcmpcasenosensitive_internal (const char* fileName1,const char* fileName2)
-{
- for (;;)
- {
- char c1=*(fileName1++);
- char c2=*(fileName2++);
- if ((c1>='a') && (c1<='z'))
- c1 -= 0x20;
- if ((c2>='a') && (c2<='z'))
- c2 -= 0x20;
- if (c1=='\0')
- return ((c2=='\0') ? 0 : -1);
- if (c2=='\0')
- return 1;
- if (c1<c2)
- return -1;
- if (c1>c2)
- return 1;
- }
-}
-
-
-#ifdef CASESENSITIVITYDEFAULT_NO
-#define CASESENSITIVITYDEFAULTVALUE 2
-#else
-#define CASESENSITIVITYDEFAULTVALUE 1
-#endif
-
-#ifndef STRCMPCASENOSENTIVEFUNCTION
-#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
-#endif
-
-/*
- Compare two filename (fileName1,fileName2).
- If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
- If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
- or strcasecmp)
- If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
- (like 1 on Unix, 2 on Windows)
-
-*/
-extern int unzStringFileNameCompare (const char* fileName1,const char* fileName2,int iCaseSensitivity)
-{
- if (iCaseSensitivity==0)
- iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
-
- if (iCaseSensitivity==1)
- return strcmp(fileName1,fileName2);
-
- return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
-}
-
-#define BUFREADCOMMENT (0x400)
-
-/*
- Locate the Central directory of a zipfile (at the end, just before
- the global comment)
-*/
-static uLong unzlocal_SearchCentralDir(FILE *fin)
-{
- unsigned char* buf;
- uLong uSizeFile;
- uLong uBackRead;
- uLong uMaxBack=0xffff; /* maximum size of global comment */
- uLong uPosFound=0;
-
- if (fseek(fin,0,SEEK_END) != 0)
- return 0;
-
-
- uSizeFile = ftell( fin );
-
- if (uMaxBack>uSizeFile)
- uMaxBack = uSizeFile;
-
- buf = (unsigned char*)safe_malloc(BUFREADCOMMENT+4);
- if (buf==NULL)
- return 0;
-
- uBackRead = 4;
- while (uBackRead<uMaxBack)
- {
- uLong uReadSize,uReadPos ;
- int i;
- if (uBackRead+BUFREADCOMMENT>uMaxBack)
- uBackRead = uMaxBack;
- else
- uBackRead+=BUFREADCOMMENT;
- uReadPos = uSizeFile-uBackRead ;
-
- uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
- (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
- if (fseek(fin,uReadPos,SEEK_SET)!=0)
- break;
-
- if (fread(buf,(uInt)uReadSize,1,fin)!=1)
- break;
-
- for (i=(int)uReadSize-3; (i--)>0;)
- if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
- ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
- {
- uPosFound = uReadPos+i;
- break;
- }
-
- if (uPosFound!=0)
- break;
- }
- free(buf);
- return uPosFound;
-}
-
-extern unzFile unzReOpen (const char* path, unzFile file)
-{
- unz_s *s;
- FILE * fin;
-
- fin=fopen(path,"rb");
- if (fin==NULL)
- return NULL;
-
- s=(unz_s*)safe_malloc(sizeof(unz_s));
- memcpy(s, (unz_s*)file, sizeof(unz_s));
-
- s->file = fin;
- return (unzFile)s;
-}
-
-/*
- Open a Zip file. path contain the full pathname (by example,
- on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer
- "zlib/zlib109.zip".
- If the zipfile cannot be opened (file don't exist or in not valid), the
- return value is NULL.
- Else, the return value is a unzFile Handle, usable with other function
- of this unzip package.
-*/
-extern unzFile unzOpen (const char* path)
-{
- unz_s us;
- unz_s *s;
- uLong central_pos,uL;
- FILE * fin ;
-
- uLong number_disk; /* number of the current dist, used for
- spaning ZIP, unsupported, always 0*/
- uLong number_disk_with_CD; /* number the the disk with central dir, used
- for spaning ZIP, unsupported, always 0*/
- uLong number_entry_CD; /* total number of entries in
- the central dir
- (same than number_entry on nospan) */
-
- int err=UNZ_OK;
-
- fin=fopen(path,"rb");
- if (fin==NULL)
- return NULL;
-
- central_pos = unzlocal_SearchCentralDir(fin);
- if (central_pos==0)
- err=UNZ_ERRNO;
-
- if (fseek(fin,central_pos,SEEK_SET)!=0)
- err=UNZ_ERRNO;
-
- /* the signature, already checked */
- if (unzlocal_getLong(fin,&uL)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* number of this disk */
- if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* number of the disk with the start of the central directory */
- if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* total number of entries in the central dir on this disk */
- if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* total number of entries in the central dir */
- if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- if ((number_entry_CD!=us.gi.number_entry) ||
- (number_disk_with_CD!=0) ||
- (number_disk!=0))
- err=UNZ_BADZIPFILE;
-
- /* size of the central directory */
- if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* offset of start of central directory with respect to the
- starting disk number */
- if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* zipfile comment length */
- if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
- (err==UNZ_OK))
- err=UNZ_BADZIPFILE;
-
- if (err!=UNZ_OK)
- {
- fclose(fin);
- return NULL;
- }
-
- us.file=fin;
- us.byte_before_the_zipfile = central_pos -
- (us.offset_central_dir+us.size_central_dir);
- us.central_pos = central_pos;
- us.pfile_in_zip_read = NULL;
-
-
- s=(unz_s*)safe_malloc(sizeof(unz_s));
- *s=us;
-// unzGoToFirstFile((unzFile)s);
- return (unzFile)s;
-}
-
-
-/*
- Close a ZipFile opened with unzipOpen.
- If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
- these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
- return UNZ_OK if there is no problem. */
-extern int unzClose (unzFile file)
-{
- unz_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
-
- if (s->pfile_in_zip_read!=NULL)
- unzCloseCurrentFile(file);
-
- fclose(s->file);
- free(s);
- return UNZ_OK;
-}
-
-
-/*
- Write info about the ZipFile in the *pglobal_info structure.
- No preparation of the structure is needed
- return UNZ_OK if there is no problem. */
-extern int unzGetGlobalInfo (unzFile file,unz_global_info *pglobal_info)
-{
- unz_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- *pglobal_info=s->gi;
- return UNZ_OK;
-}
-
-
-/*
- Translate date/time from Dos format to tm_unz (readable more easilty)
-*/
-static void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz* ptm)
-{
- uLong uDate;
- uDate = (uLong)(ulDosDate>>16);
- ptm->tm_mday = (uInt)(uDate&0x1f) ;
- ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
- ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
-
- ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
- ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
- ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
-}
-
-/*
- Get Info about the current file in the zipfile, with internal only info
-*/
-static int unzlocal_GetCurrentFileInfoInternal (unzFile file,
- unz_file_info *pfile_info,
- unz_file_info_internal
- *pfile_info_internal,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize)
-{
- unz_s* s;
- unz_file_info file_info;
- unz_file_info_internal file_info_internal;
- int err=UNZ_OK;
- uLong uMagic;
- long lSeek=0;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0)
- err=UNZ_ERRNO;
-
-
- /* we check the magic */
- if (err==UNZ_OK) {
- if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
- err=UNZ_ERRNO;
- else if (uMagic!=0x02014b50)
- err=UNZ_BADZIPFILE;
- }
-
- if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK)
- err=UNZ_ERRNO;
-
- unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
-
- if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK)
- err=UNZ_ERRNO;
-
- lSeek+=file_info.size_filename;
- if ((err==UNZ_OK) && (szFileName!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_filename<fileNameBufferSize)
- {
- *(szFileName+file_info.size_filename)='\0';
- uSizeRead = file_info.size_filename;
- }
- else
- uSizeRead = fileNameBufferSize;
-
- if ((file_info.size_filename>0) && (fileNameBufferSize>0))
- if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1)
- err=UNZ_ERRNO;
- lSeek -= uSizeRead;
- }
-
-
- if ((err==UNZ_OK) && (extraField!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_file_extra<extraFieldBufferSize)
- uSizeRead = file_info.size_file_extra;
- else
- uSizeRead = extraFieldBufferSize;
-
- if (lSeek!=0) {
- if (fseek(s->file,lSeek,SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
- }
- if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
- if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
- err=UNZ_ERRNO;
- lSeek += file_info.size_file_extra - uSizeRead;
- }
- else
- lSeek+=file_info.size_file_extra;
-
-
- if ((err==UNZ_OK) && (szComment!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_file_comment<commentBufferSize)
- {
- *(szComment+file_info.size_file_comment)='\0';
- uSizeRead = file_info.size_file_comment;
- }
- else
- uSizeRead = commentBufferSize;
-
- if (lSeek!=0) {
- if (fseek(s->file,lSeek,SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
- }
- if ((file_info.size_file_comment>0) && (commentBufferSize>0))
- if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
- err=UNZ_ERRNO;
- lSeek+=file_info.size_file_comment - uSizeRead;
- }
- else
- lSeek+=file_info.size_file_comment;
-
- if ((err==UNZ_OK) && (pfile_info!=NULL))
- *pfile_info=file_info;
-
- if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
- *pfile_info_internal=file_info_internal;
-
- return err;
-}
-
-
-
-/*
- Write info about the ZipFile in the *pglobal_info structure.
- No preparation of the structure is needed
- return UNZ_OK if there is no problem.
-*/
-extern int unzGetCurrentFileInfo ( unzFile file, unz_file_info *pfile_info,
- char *szFileName, uLong fileNameBufferSize,
- void *extraField, uLong extraFieldBufferSize,
- char *szComment, uLong commentBufferSize)
-{
- return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
- szFileName,fileNameBufferSize,
- extraField,extraFieldBufferSize,
- szComment,commentBufferSize);
-}
-
-/*
- Set the current file of the zipfile to the first file.
- return UNZ_OK if there is no problem
-*/
-extern int unzGoToFirstFile (unzFile file)
-{
- int err=UNZ_OK;
- unz_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- s->pos_in_central_dir=s->offset_central_dir;
- s->num_file=0;
- err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- NULL,0,NULL,0,NULL,0);
- s->current_file_ok = (err == UNZ_OK);
- return err;
-}
-
-
-/*
- Set the current file of the zipfile to the next file.
- return UNZ_OK if there is no problem
- return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-extern int unzGoToNextFile (unzFile file)
-{
- unz_s* s;
- int err;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return UNZ_END_OF_LIST_OF_FILE;
- if (s->num_file+1==s->gi.number_entry)
- return UNZ_END_OF_LIST_OF_FILE;
-
- s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
- s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
- s->num_file++;
- err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- NULL,0,NULL,0,NULL,0);
- s->current_file_ok = (err == UNZ_OK);
- return err;
-}
-
-
-/*
- Try locate the file szFileName in the zipfile.
- For the iCaseSensitivity signification, see unzipStringFileNameCompare
-
- return value :
- UNZ_OK if the file is found. It becomes the current file.
- UNZ_END_OF_LIST_OF_FILE if the file is not found
-*/
-extern int unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
-{
- unz_s* s;
- int err;
-
-
- uLong num_fileSaved;
- uLong pos_in_central_dirSaved;
-
-
- if (file==NULL)
- return UNZ_PARAMERROR;
-
- if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
- return UNZ_PARAMERROR;
-
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return UNZ_END_OF_LIST_OF_FILE;
-
- num_fileSaved = s->num_file;
- pos_in_central_dirSaved = s->pos_in_central_dir;
-
- err = unzGoToFirstFile(file);
-
- while (err == UNZ_OK)
- {
- char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
- unzGetCurrentFileInfo(file,NULL,
- szCurrentFileName,sizeof(szCurrentFileName)-1,
- NULL,0,NULL,0);
- if (unzStringFileNameCompare(szCurrentFileName,
- szFileName,iCaseSensitivity)==0)
- return UNZ_OK;
- err = unzGoToNextFile(file);
- }
-
- s->num_file = num_fileSaved ;
- s->pos_in_central_dir = pos_in_central_dirSaved ;
- return err;
-}
-
-
-/*
- Read the static header of the current zipfile
- Check the coherency of the static header and info in the end of central
- directory about this file
- store in *piSizeVar the size of extra info in static header
- (filename and size of extra field data)
-*/
-static int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,
- uLong *poffset_local_extrafield,
- uInt *psize_local_extrafield)
-{
- uLong uMagic,uData,uFlags;
- uLong size_filename;
- uLong size_extra_field;
- int err=UNZ_OK;
-
- *piSizeVar = 0;
- *poffset_local_extrafield = 0;
- *psize_local_extrafield = 0;
-
- if (fseek(s->file,s->cur_file_info_internal.offset_curfile +
- s->byte_before_the_zipfile,SEEK_SET)!=0)
- return UNZ_ERRNO;
-
-
- if (err==UNZ_OK) {
- if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
- err=UNZ_ERRNO;
- else if (uMagic!=0x04034b50)
- err=UNZ_BADZIPFILE;
- }
-
- if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
- err=UNZ_ERRNO;
-/*
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
- err=UNZ_BADZIPFILE;
-*/
- if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
- err=UNZ_BADZIPFILE;
-
- if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
- (s->cur_file_info.compression_method!=Z_DEFLATED))
- err=UNZ_BADZIPFILE;
-
- if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */
- err=UNZ_ERRNO;
-
- if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
- ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
-
- if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
- ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
-
- if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
- ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
-
-
- if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK)
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
- err=UNZ_BADZIPFILE;
-
- *piSizeVar += (uInt)size_filename;
-
- if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK)
- err=UNZ_ERRNO;
- *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
- SIZEZIPLOCALHEADER + size_filename;
- *psize_local_extrafield = (uInt)size_extra_field;
-
- *piSizeVar += (uInt)size_extra_field;
-
- return err;
-}
-
-/*
- Open for reading data the current file in the zipfile.
- If there is no error and the file is opened, the return value is UNZ_OK.
-*/
-extern int unzOpenCurrentFile (unzFile file)
-{
- int err=UNZ_OK;
- int Store;
- uInt iSizeVar;
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- uLong offset_local_extrafield; /* offset of the static extra field */
- uInt size_local_extrafield; /* size of the static extra field */
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- if (!s->current_file_ok)
- return UNZ_PARAMERROR;
-
- if (s->pfile_in_zip_read != NULL)
- unzCloseCurrentFile(file);
-
- if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
- &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
- return UNZ_BADZIPFILE;
-
- pfile_in_zip_read_info = (file_in_zip_read_info_s*)
- safe_malloc(sizeof(file_in_zip_read_info_s));
- if (pfile_in_zip_read_info==NULL)
- return UNZ_INTERNALERROR;
-
- pfile_in_zip_read_info->read_buffer=(char*)safe_malloc(UNZ_BUFSIZE);
- pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
- pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
- pfile_in_zip_read_info->pos_local_extrafield=0;
-
- if (pfile_in_zip_read_info->read_buffer==NULL)
- {
- free(pfile_in_zip_read_info);
- return UNZ_INTERNALERROR;
- }
-
- pfile_in_zip_read_info->stream_initialised=0;
-
- if ((s->cur_file_info.compression_method!=0) &&
- (s->cur_file_info.compression_method!=Z_DEFLATED))
- err=UNZ_BADZIPFILE;
- Store = s->cur_file_info.compression_method==0;
-
- pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
- pfile_in_zip_read_info->crc32=0;
- pfile_in_zip_read_info->compression_method =
- s->cur_file_info.compression_method;
- pfile_in_zip_read_info->file=s->file;
- pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
-
- pfile_in_zip_read_info->stream.total_out = 0;
-
- if (!Store)
- {
- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
- pfile_in_zip_read_info->stream.zfree = (free_func)0;
- pfile_in_zip_read_info->stream.opaque = (voidp)0;
-
- err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
- if (err == Z_OK)
- pfile_in_zip_read_info->stream_initialised=1;
- /* windowBits is passed < 0 to tell that there is no zlib header.
- * Note that in this case inflate *requires* an extra "dummy" byte
- * after the compressed stream in order to complete decompression and
- * return Z_STREAM_END.
- * In unzip, i don't wait absolutely Z_STREAM_END because I known the
- * size of both compressed and uncompressed data
- */
- }
- pfile_in_zip_read_info->rest_read_compressed =
- s->cur_file_info.compressed_size ;
- pfile_in_zip_read_info->rest_read_uncompressed =
- s->cur_file_info.uncompressed_size ;
-
-
- pfile_in_zip_read_info->pos_in_zipfile =
- s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
- iSizeVar;
-
- pfile_in_zip_read_info->stream.avail_in = (uInt)0;
-
-
- s->pfile_in_zip_read = pfile_in_zip_read_info;
- return UNZ_OK;
-}
-
-
-/*
- Read bytes from the current file.
- buf contain buffer where data must be copied
- len the size of buf.
-
- return the number of byte copied if somes bytes are copied
- return 0 if the end of file was reached
- return <0 with error code if there is an error
- (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-*/
-extern int unzReadCurrentFile (unzFile file, void *buf, unsigned len)
-{
- int err=UNZ_OK;
- uInt iRead = 0;
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
-
- if ((pfile_in_zip_read_info->read_buffer == NULL))
- return UNZ_END_OF_LIST_OF_FILE;
- if (len==0)
- return 0;
-
- pfile_in_zip_read_info->stream.next_out = (Byte*)buf;
-
- pfile_in_zip_read_info->stream.avail_out = (uInt)len;
-
- if (len>pfile_in_zip_read_info->rest_read_uncompressed)
- pfile_in_zip_read_info->stream.avail_out =
- (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
-
- while (pfile_in_zip_read_info->stream.avail_out>0)
- {
- if ((pfile_in_zip_read_info->stream.avail_in==0) &&
- (pfile_in_zip_read_info->rest_read_compressed>0))
- {
- uInt uReadThis = UNZ_BUFSIZE;
- if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
- uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
- if (uReadThis == 0)
- return UNZ_EOF;
- if (s->cur_file_info.compressed_size == pfile_in_zip_read_info->rest_read_compressed)
- if (fseek(pfile_in_zip_read_info->file,
- pfile_in_zip_read_info->pos_in_zipfile +
- pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)
- return UNZ_ERRNO;
- if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,
- pfile_in_zip_read_info->file)!=1)
- return UNZ_ERRNO;
- pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
-
- pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
-
- pfile_in_zip_read_info->stream.next_in =
- (Byte*)pfile_in_zip_read_info->read_buffer;
- pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
- }
-
- if (pfile_in_zip_read_info->compression_method==0)
- {
- uInt uDoCopy,i ;
- if (pfile_in_zip_read_info->stream.avail_out <
- pfile_in_zip_read_info->stream.avail_in)
- uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
- else
- uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
-
- for (i=0;i<uDoCopy;i++)
- *(pfile_in_zip_read_info->stream.next_out+i) =
- *(pfile_in_zip_read_info->stream.next_in+i);
-
- pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
- pfile_in_zip_read_info->stream.next_out,
- uDoCopy);
- pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
- pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
- pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
- pfile_in_zip_read_info->stream.next_out += uDoCopy;
- pfile_in_zip_read_info->stream.next_in += uDoCopy;
- pfile_in_zip_read_info->stream.total_out += uDoCopy;
- iRead += uDoCopy;
- }
- else
- {
- uLong uTotalOutBefore,uTotalOutAfter;
- const Byte *bufBefore;
- uLong uOutThis;
- int flush=Z_SYNC_FLUSH;
-
- uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
- bufBefore = pfile_in_zip_read_info->stream.next_out;
-
- /*
- if ((pfile_in_zip_read_info->rest_read_uncompressed ==
- pfile_in_zip_read_info->stream.avail_out) &&
- (pfile_in_zip_read_info->rest_read_compressed == 0))
- flush = Z_FINISH;
- */
- err=inflate(&pfile_in_zip_read_info->stream,flush);
-
- uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
- uOutThis = uTotalOutAfter-uTotalOutBefore;
-
- pfile_in_zip_read_info->crc32 =
- crc32(pfile_in_zip_read_info->crc32,bufBefore,
- (uInt)(uOutThis));
-
- pfile_in_zip_read_info->rest_read_uncompressed -=
- uOutThis;
-
- iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
- if (err==Z_STREAM_END)
- return (iRead==0) ? UNZ_EOF : iRead;
- if (err!=Z_OK)
- break;
- }
- }
-
- if (err==Z_OK)
- return iRead;
- return err;
-}
-
-
-/*
- Give the current position in uncompressed data
-*/
-extern long unztell (unzFile file)
-{
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- return (long)pfile_in_zip_read_info->stream.total_out;
-}
-
-
-/*
- return 1 if the end of file was reached, 0 elsewhere
-*/
-extern int unzeof (unzFile file)
-{
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
- return 1;
- else
- return 0;
-}
-
-
-
-/*
- Read extra field from the current file (opened by unzOpenCurrentFile)
- This is the static-header version of the extra field (sometimes, there is
- more info in the static-header version than in the central-header)
-
- if buf==NULL, it return the size of the static extra field that can be read
-
- if buf!=NULL, len is the size of the buffer, the extra header is copied in
- buf.
- the return value is the number of bytes copied in buf, or (if <0)
- the error code
-*/
-extern int unzGetLocalExtrafield (unzFile file,void *buf,unsigned len)
-{
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- uInt read_now;
- uLong size_to_read;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
- pfile_in_zip_read_info->pos_local_extrafield);
-
- if (buf==NULL)
- return (int)size_to_read;
-
- if (len>size_to_read)
- read_now = (uInt)size_to_read;
- else
- read_now = (uInt)len ;
-
- if (read_now==0)
- return 0;
-
- if (fseek(pfile_in_zip_read_info->file,
- pfile_in_zip_read_info->offset_local_extrafield +
- pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)
- return UNZ_ERRNO;
-
- if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1)
- return UNZ_ERRNO;
-
- return (int)read_now;
-}
-
-/*
- Close the file in zip opened with unzipOpenCurrentFile
- Return UNZ_CRCERROR if all the file was read but the CRC is not good
-*/
-extern int unzCloseCurrentFile (unzFile file)
-{
- int err=UNZ_OK;
-
- unz_s* s;
- file_in_zip_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
-
- if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
- {
- if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
- err=UNZ_CRCERROR;
- }
-
-
- free(pfile_in_zip_read_info->read_buffer);
- pfile_in_zip_read_info->read_buffer = NULL;
- if (pfile_in_zip_read_info->stream_initialised)
- inflateEnd(&pfile_in_zip_read_info->stream);
-
- pfile_in_zip_read_info->stream_initialised = 0;
- free(pfile_in_zip_read_info);
-
- s->pfile_in_zip_read=NULL;
-
- return err;
-}
-
-
-/*
- Get the global comment string of the ZipFile, in the szComment buffer.
- uSizeBuf is the size of the szComment buffer.
- return the number of byte copied or an error code <0
-*/
-extern int unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf)
-{
- unz_s* s;
- uLong uReadThis ;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz_s*)file;
-
- uReadThis = uSizeBuf;
- if (uReadThis>s->gi.size_comment)
- uReadThis = s->gi.size_comment;
-
- if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0)
- return UNZ_ERRNO;
-
- if (uReadThis>0)
- {
- *szComment='\0';
- if (fread(szComment,(uInt)uReadThis,1,s->file)!=1)
- return UNZ_ERRNO;
- }
-
- if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
- *(szComment+s->gi.size_comment)='\0';
- return (int)uReadThis;
-}
-
-/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-1998 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-
-#ifdef DYNAMIC_CRC_TABLE
-
-static int crc_table_empty = 1;
-static uLong crc_table[256];
-static void make_crc_table OF((void));
-
-/*
- Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
- x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
-
- Polynomials over GF(2) are represented in binary, one bit per coefficient,
- with the lowest powers in the most significant bit. Then adding polynomials
- is just exclusive-or, and multiplying a polynomial by x is a right shift by
- one. If we call the above polynomial p, and represent a byte as the
- polynomial q, also with the lowest power in the most significant bit (so the
- byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
- where a mod b means the remainder after dividing a by b.
-
- This calculation is done using the shift-register method of multiplying and
- taking the remainder. The register is initialized to zero, and for each
- incoming bit, x^32 is added mod p to the register if the bit is a one (where
- x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
- x (which is shifting right by one and adding x^32 mod p if the bit shifted
- out is a one). We start with the highest power (least significant bit) of
- q and repeat for all eight bits of q.
-
- The table is simply the CRC of all possible eight bit values. This is all
- the information needed to generate CRC's on data a byte at a time for all
- combinations of CRC register values and incoming bytes.
-*/
-static void make_crc_table()
-{
- uLong c;
- int n, k;
- uLong poly; /* polynomial exclusive-or pattern */
- /* terms of polynomial defining this crc (except x^32): */
- static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
-
- /* make exclusive-or pattern from polynomial (0xedb88320L) */
- poly = 0L;
- for (n = 0; n < sizeof(p)/sizeof(Byte); n++)
- poly |= 1L << (31 - p[n]);
-
- for (n = 0; n < 256; n++)
- {
- c = (uLong)n;
- for (k = 0; k < 8; k++)
- c = c & 1 ? poly ^ (c >> 1) : c >> 1;
- crc_table[n] = c;
- }
- crc_table_empty = 0;
-}
-#else
-/* ========================================================================
- * Table of CRC-32's of all single-byte values (made by make_crc_table)
- */
-static const uLong crc_table[256] = {
- 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
- 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
- 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
- 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
- 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
- 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
- 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
- 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
- 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
- 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
- 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
- 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
- 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
- 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
- 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
- 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
- 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
- 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
- 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
- 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
- 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
- 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
- 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
- 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
- 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
- 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
- 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
- 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
- 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
- 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
- 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
- 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
- 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
- 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
- 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
- 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
- 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
- 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
- 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
- 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
- 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
- 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
- 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
- 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
- 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
- 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
- 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
- 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
- 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
- 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
- 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
- 0x2d02ef8dL
-};
-#endif
-
-/* =========================================================================
- * This function can be used by asm versions of crc32()
- */
-#ifndef __APPLE__
-const uLong * get_crc_table()
-{
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty) make_crc_table();
-#endif
- return (const uLong *)crc_table;
-}
-#endif
-
-/* ========================================================================= */
-#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
-#define DO2(buf) DO1(buf); DO1(buf);
-#define DO4(buf) DO2(buf); DO2(buf);
-#define DO8(buf) DO4(buf); DO4(buf);
-
-/* ========================================================================= */
-#ifndef __APPLE__
-uLong crc32(uLong crc, const Byte *buf, uInt len)
-{
- if (buf == Z_NULL) return 0L;
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif
- crc = crc ^ 0xffffffffL;
- while (len >= 8)
- {
- DO8(buf);
- len -= 8;
- }
- if (len) do {
- DO1(buf);
- } while (--len);
- return crc ^ 0xffffffffL;
-}
-#endif
-
-/* infblock.h -- header to use infblock.c
- * Copyright (C) 1995-1998 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-struct inflate_blocks_state;
-typedef struct inflate_blocks_state inflate_blocks_statef;
-
-extern inflate_blocks_statef * inflate_blocks_new OF((
- z_streamp z,
- check_func c, /* check function */
- uInt w)); /* window size */
-
-extern int inflate_blocks OF((
- inflate_blocks_statef *,
- z_streamp ,
- int)); /* initial return code */
-
-extern void inflate_blocks_reset OF((
- inflate_blocks_statef *,
- z_streamp ,
- uLong *)); /* check value on output */
-
-extern int inflate_blocks_free OF((
- inflate_blocks_statef *,
- z_streamp));
-
-extern void inflate_set_dictionary OF((
- inflate_blocks_statef *s,
- const Byte *d, /* dictionary */
- uInt n)); /* dictionary length */
-
-extern int inflate_blocks_sync_point OF((
- inflate_blocks_statef *s));
-
-/* simplify the use of the inflate_huft type with some defines */
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-/* Table for deflate from PKZIP's appnote.txt. */
-static const uInt border[] = { /* Order of the bit length code lengths */
- 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
-/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-1998 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* Huffman code lookup table entry--this entry is four bytes for machines
- that have 16-bit pointers (e.g. PC's in the small or medium model). */
-
-typedef struct inflate_huft_s inflate_huft;
-
-struct inflate_huft_s {
- union {
- struct {
- Byte Exop; /* number of extra bits or operation */
- Byte Bits; /* number of bits in this code or subcode */
- } what;
- uInt pad; /* pad structure to a power of 2 (4 bytes for */
- } word; /* 16-bit, 8 bytes for 32-bit int's) */
- uInt base; /* literal, length base, distance base,
- or table offset */
-};
-
-/* Maximum size of dynamic tree. The maximum found in a long but non-
- exhaustive search was 1004 huft structures (850 for length/literals
- and 154 for distances, the latter actually the result of an
- exhaustive search). The actual maximum is not known, but the
- value below is more than safe. */
-#define MANY 1440
-
-extern int inflate_trees_bits OF((
- uInt *, /* 19 code lengths */
- uInt *, /* bits tree desired/actual depth */
- inflate_huft * *, /* bits tree result */
- inflate_huft *, /* space for trees */
- z_streamp)); /* for messages */
-
-extern int inflate_trees_dynamic OF((
- uInt, /* number of literal/length codes */
- uInt, /* number of distance codes */
- uInt *, /* that many (total) code lengths */
- uInt *, /* literal desired/actual bit depth */
- uInt *, /* distance desired/actual bit depth */
- inflate_huft * *, /* literal/length tree result */
- inflate_huft * *, /* distance tree result */
- inflate_huft *, /* space for trees */
- z_streamp)); /* for messages */
-
-extern int inflate_trees_fixed OF((
- uInt *, /* literal desired/actual bit depth */
- uInt *, /* distance desired/actual bit depth */
- inflate_huft * *, /* literal/length tree result */
- inflate_huft * *, /* distance tree result */
- z_streamp)); /* for memory allocation */
-
-
-/* infcodes.h -- header to use infcodes.c
- * Copyright (C) 1995-1998 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-struct inflate_codes_state;
-typedef struct inflate_codes_state inflate_codes_statef;
-
-extern inflate_codes_statef *inflate_codes_new OF((
- uInt, uInt,
- inflate_huft *, inflate_huft *,
- z_streamp ));
-
-extern int inflate_codes OF((
- inflate_blocks_statef *,
- z_streamp ,
- int));
-
-extern void inflate_codes_free OF((
- inflate_codes_statef *,
- z_streamp ));
-
-/* infutil.h -- types and macros common to blocks and codes
- * Copyright (C) 1995-1998 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-#ifndef _INFUTIL_H
-#define _INFUTIL_H
-
-typedef enum {
- TYPE, /* get type bits (3, including end bit) */
- LENS, /* get lengths for stored */
- STORED, /* processing stored block */
- TABLE, /* get table lengths */
- BTREE, /* get bit lengths tree for a dynamic block */
- DTREE, /* get length, distance trees for a dynamic block */
- CODES, /* processing fixed or dynamic block */
- DRY, /* output remaining window bytes */
- DONE, /* finished last block, done */
- BAD} /* got a data error--stuck here */
-inflate_block_mode;
-
-/* inflate blocks semi-private state */
-struct inflate_blocks_state {
-
- /* mode */
- inflate_block_mode mode; /* current inflate_block mode */
-
- /* mode dependent information */
- union {
- uInt left; /* if STORED, bytes left to copy */
- struct {
- uInt table; /* table lengths (14 bits) */
- uInt index; /* index into blens (or border) */
- uInt *blens; /* bit lengths of codes */
- uInt bb; /* bit length tree depth */
- inflate_huft *tb; /* bit length decoding tree */
- } trees; /* if DTREE, decoding info for trees */
- struct {
- inflate_codes_statef
- *codes;
- } decode; /* if CODES, current state */
- } sub; /* submode */
- uInt last; /* true if this block is the last block */
-
- /* mode independent information */
- uInt bitk; /* bits in bit buffer */
- uLong bitb; /* bit buffer */
- inflate_huft *hufts; /* single safe_malloc for tree space */
- Byte *window; /* sliding window */
- Byte *end; /* one byte after sliding window */
- Byte *read; /* window read pointer */
- Byte *write; /* window write pointer */
- check_func checkfn; /* check function */
- uLong check; /* check on output */
-
-};
-
-
-/* defines for inflate input/output */
-/* update pointers and return */
-#define UPDBITS {s->bitb=b;s->bitk=k;}
-#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
-#define UPDOUT {s->write=q;}
-#define UPDATE {UPDBITS UPDIN UPDOUT}
-#define LEAVE {UPDATE return inflate_flush(s,z,r);}
-/* get bytes and bits */
-#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
-#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
-#define NEXTBYTE (n--,*p++)
-#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
-#define DUMPBITS(j) {b>>=(j);k-=(j);}
-/* output bytes */
-#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
-#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
-#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
-#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
-#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
-#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
-/* load static pointers */
-#define LOAD {LOADIN LOADOUT}
-
-/* masks for lower bits (size given to avoid silly warnings with Visual C++) */
-extern uInt inflate_mask[17];
-
-/* copy as much as possible from the sliding window to the output area */
-extern int inflate_flush OF((
- inflate_blocks_statef *,
- z_streamp ,
- int));
-
-#endif
-
-
-/*
- Notes beyond the 1.93a appnote.txt:
-
- 1. Distance pointers never point before the beginning of the output
- stream.
- 2. Distance pointers can point back across blocks, up to 32k away.
- 3. There is an implied maximum of 7 bits for the bit length table and
- 15 bits for the actual data.
- 4. If only one code exists, then it is encoded using one bit. (Zero
- would be more efficient, but perhaps a little confusing.) If two
- codes exist, they are coded using one bit each (0 and 1).
- 5. There is no way of sending zero distance codes--a dummy must be
- sent if there are none. (History: a pre 2.0 version of PKZIP would
- store blocks with no distance codes, but this was discovered to be
- too harsh a criterion.) Valid only for 1.93a. 2.04c does allow
- zero distance codes, which is sent as one code of zero bits in
- length.
- 6. There are up to 286 literal/length codes. Code 256 represents the
- end-of-block. Note however that the static length tree defines
- 288 codes just to fill out the Huffman codes. Codes 286 and 287
- cannot be used though, since there is no length base or extra bits
- defined for them. Similarily, there are up to 30 distance codes.
- However, static trees define 32 codes (all 5 bits) to fill out the
- Huffman codes, but the last two had better not show up in the data.
- 7. Unzip can check dynamic Huffman blocks for complete code sets.
- The exception is that a single code would not be complete (see #4).
- 8. The five bits following the block type is really the number of
- literal codes sent minus 257.
- 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
- (1+6+6). Therefore, to output three times the length, you output
- three codes (1+1+1), whereas to output four times the same length,
- you only need two codes (1+3). Hmm.
- 10. In the tree reconstruction algorithm, Code = Code + Increment
- only if BitLength(i) is not zero. (Pretty obvious.)
- 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19)
- 12. Note: length code 284 can represent 227-258, but length code 285
- really is 258. The last length deserves its own, short code
- since it gets used a lot in very redundant files. The length
- 258 is special since 258 - 3 (the min match length) is 255.
- 13. The literal/length and distance code bit lengths are read as a
- single stream of lengths. It is possible (and advantageous) for
- a repeat code (16, 17, or 18) to go across the boundary between
- the two sets of lengths.
- */
-
-
-#ifndef __APPLE__
-void inflate_blocks_reset(inflate_blocks_statef *s, z_streamp z, uLong *c)
-{
- if (c != Z_NULL)
- *c = s->check;
- if (s->mode == BTREE || s->mode == DTREE)
- ZFREE(z, s->sub.trees.blens);
- if (s->mode == CODES)
- inflate_codes_free(s->sub.decode.codes, z);
- s->mode = TYPE;
- s->bitk = 0;
- s->bitb = 0;
- s->read = s->write = s->window;
- if (s->checkfn != Z_NULL)
- z->adler = s->check = (*s->checkfn)(0L, (const Byte *)Z_NULL, 0);
- Tracev(("inflate: blocks reset\n"));
-}
-#endif
-
-#ifndef __APPLE__
-inflate_blocks_statef *inflate_blocks_new(z_streamp z, check_func c, uInt w)
-{
- inflate_blocks_statef *s;
-
- if ((s = (inflate_blocks_statef *)ZALLOC
- (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
- return s;
- if ((s->hufts =
- (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)
- {
- ZFREE(z, s);
- return Z_NULL;
- }
- if ((s->window = (Byte *)ZALLOC(z, 1, w)) == Z_NULL)
- {
- ZFREE(z, s->hufts);
- ZFREE(z, s);
- return Z_NULL;
- }
- s->end = s->window + w;
- s->checkfn = c;
- s->mode = TYPE;
- Tracev(("inflate: blocks allocated\n"));
- inflate_blocks_reset(s, z, Z_NULL);
- return s;
-}
-#endif
-
-#ifndef __APPLE__
-int inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r)
-{
- uInt t; /* temporary storage */
- uLong b; /* bit buffer */
- uInt k; /* bits in bit buffer */
- Byte *p; /* input data pointer */
- uInt n; /* bytes available there */
- Byte *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
-
- /* copy input/output information to locals (UPDATE macro restores) */
- LOAD
-
- /* process input based on current state */
- while (1) switch (s->mode)
- {
- case TYPE:
- NEEDBITS(3)
- t = (uInt)b & 7;
- s->last = t & 1;
- switch (t >> 1)
- {
- case 0: /* stored */
- Tracev(("inflate: stored block%s\n",
- s->last ? " (last)" : ""));
- DUMPBITS(3)
- t = k & 7; /* go to byte boundary */
- DUMPBITS(t)
- s->mode = LENS; /* get length of stored block */
- break;
- case 1: /* fixed */
- Tracev(("inflate: fixed codes block%s\n",
- s->last ? " (last)" : ""));
- {
- uInt bl, bd;
- inflate_huft *tl, *td;
-
- inflate_trees_fixed(&bl, &bd, &tl, &td, z);
- s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
- if (s->sub.decode.codes == Z_NULL)
- {
- r = Z_MEM_ERROR;
- LEAVE
- }
- }
- DUMPBITS(3)
- s->mode = CODES;
- break;
- case 2: /* dynamic */
- Tracev(("inflate: dynamic codes block%s\n",
- s->last ? " (last)" : ""));
- DUMPBITS(3)
- s->mode = TABLE;
- break;
- case 3: /* illegal */
- DUMPBITS(3)
- s->mode = BAD;
- z->msg = (char*)"invalid block type";
- r = Z_DATA_ERROR;
- LEAVE
- }
- break;
- case LENS:
- NEEDBITS(32)
- if ((((~b) >> 16) & 0xffff) != (b & 0xffff))
- {
- s->mode = BAD;
- z->msg = (char*)"invalid stored block lengths";
- r = Z_DATA_ERROR;
- LEAVE
- }
- s->sub.left = (uInt)b & 0xffff;
- b = k = 0; /* dump bits */
- Tracev(("inflate: stored length %u\n", s->sub.left));
- s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE);
- break;
- case STORED:
- if (n == 0)
- LEAVE
- NEEDOUT
- t = s->sub.left;
- if (t > n) t = n;
- if (t > m) t = m;
- zmemcpy(q, p, t);
- p += t; n -= t;
- q += t; m -= t;
- if ((s->sub.left -= t) != 0)
- break;
- Tracev(("inflate: stored end, %lu total out\n",
- z->total_out + (q >= s->read ? q - s->read :
- (s->end - s->read) + (q - s->window))));
- s->mode = s->last ? DRY : TYPE;
- break;
- case TABLE:
- NEEDBITS(14)
- s->sub.trees.table = t = (uInt)b & 0x3fff;
-#ifndef PKZIP_BUG_WORKAROUND
- if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
- {
- s->mode = BAD;
- z->msg = (char*)"too many length or distance symbols";
- r = Z_DATA_ERROR;
- LEAVE
- }
-#endif
- t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
- if ((s->sub.trees.blens = (uInt*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
- {
- r = Z_MEM_ERROR;
- LEAVE
- }
- DUMPBITS(14)
- s->sub.trees.index = 0;
- Tracev(("inflate: table sizes ok\n"));
- s->mode = BTREE;
- case BTREE:
- while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
- {
- NEEDBITS(3)
- s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
- DUMPBITS(3)
- }
- while (s->sub.trees.index < 19)
- s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
- s->sub.trees.bb = 7;
- t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
- &s->sub.trees.tb, s->hufts, z);
- if (t != Z_OK)
- {
- ZFREE(z, s->sub.trees.blens);
- r = t;
- if (r == Z_DATA_ERROR)
- s->mode = BAD;
- LEAVE
- }
- s->sub.trees.index = 0;
- Tracev(("inflate: bits tree ok\n"));
- s->mode = DTREE;
- case DTREE:
- while (t = s->sub.trees.table,
- s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
- {
- inflate_huft *h;
- uInt i, j, c;
-
- t = s->sub.trees.bb;
- NEEDBITS(t)
- h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
- t = h->bits;
- c = h->base;
- if (c < 16)
- {
- DUMPBITS(t)
- s->sub.trees.blens[s->sub.trees.index++] = c;
- }
- else /* c == 16..18 */
- {
- i = c == 18 ? 7 : c - 14;
- j = c == 18 ? 11 : 3;
- NEEDBITS(t + i)
- DUMPBITS(t)
- j += (uInt)b & inflate_mask[i];
- DUMPBITS(i)
- i = s->sub.trees.index;
- t = s->sub.trees.table;
- if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
- (c == 16 && i < 1))
- {
- ZFREE(z, s->sub.trees.blens);
- s->mode = BAD;
- z->msg = (char*)"invalid bit length repeat";
- r = Z_DATA_ERROR;
- LEAVE
- }
- c = c == 16 ? s->sub.trees.blens[i - 1] : 0;
- do {
- s->sub.trees.blens[i++] = c;
- } while (--j);
- s->sub.trees.index = i;
- }
- }
- s->sub.trees.tb = Z_NULL;
- {
- uInt bl, bd;
- inflate_huft *tl, *td;
- inflate_codes_statef *c;
-
- bl = 9; /* must be <= 9 for lookahead assumptions */
- bd = 6; /* must be <= 9 for lookahead assumptions */
- t = s->sub.trees.table;
- t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
- s->sub.trees.blens, &bl, &bd, &tl, &td,
- s->hufts, z);
- ZFREE(z, s->sub.trees.blens);
- if (t != Z_OK)
- {
- if (t == (uInt)Z_DATA_ERROR)
- s->mode = BAD;
- r = t;
- LEAVE
- }
- Tracev(("inflate: trees ok\n"));
- if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
- {
- r = Z_MEM_ERROR;
- LEAVE
- }
- s->sub.decode.codes = c;
- }
- s->mode = CODES;
- case CODES:
- UPDATE
- if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
- return inflate_flush(s, z, r);
- r = Z_OK;
- inflate_codes_free(s->sub.decode.codes, z);
- LOAD
- Tracev(("inflate: codes end, %lu total out\n",
- z->total_out + (q >= s->read ? q - s->read :
- (s->end - s->read) + (q - s->window))));
- if (!s->last)
- {
- s->mode = TYPE;
- break;
- }
- s->mode = DRY;
- case DRY:
- FLUSH
- if (s->read != s->write)
- LEAVE
- s->mode = DONE;
- case DONE:
- r = Z_STREAM_END;
- LEAVE
- case BAD:
- r = Z_DATA_ERROR;
- LEAVE
- default:
- r = Z_STREAM_ERROR;
- LEAVE
- }
-}
-#endif
-
-#ifndef __APPLE__
-int inflate_blocks_free(inflate_blocks_statef *s, z_streamp z)
-{
- inflate_blocks_reset(s, z, Z_NULL);
- ZFREE(z, s->window);
- ZFREE(z, s->hufts);
- ZFREE(z, s);
- Tracev(("inflate: blocks freed\n"));
- return Z_OK;
-}
-#endif
-
-#ifndef __APPLE__
-void inflate_set_dictionary(inflate_blocks_statef *s, const Byte *d, uInt n)
-{
- zmemcpy(s->window, d, n);
- s->read = s->write = s->window + n;
-}
-#endif
-
-/* Returns true if inflate is currently at the end of a block generated
- * by Z_SYNC_FLUSH or Z_FULL_FLUSH.
- * IN assertion: s != Z_NULL
- */
-#ifndef __APPLE__
-int inflate_blocks_sync_point(inflate_blocks_statef *s)
-{
- return s->mode == LENS;
-}
-#endif
-
-/* And'ing with mask[n] masks the lower n bits */
-uInt inflate_mask[17] = {
- 0x0000,
- 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
- 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
-};
-
-/* copy as much as possible from the sliding window to the output area */
-#ifndef __APPLE__
-int inflate_flush(inflate_blocks_statef *s, z_streamp z, int r)
-{
- uInt n;
- Byte *p;
- Byte *q;
-
- /* static copies of source and destination pointers */
- p = z->next_out;
- q = s->read;
-
- /* compute number of bytes to copy as as end of window */
- n = (uInt)((q <= s->write ? s->write : s->end) - q);
- if (n > z->avail_out) n = z->avail_out;
- if (n && r == Z_BUF_ERROR) r = Z_OK;
-
- /* update counters */
- z->avail_out -= n;
- z->total_out += n;
-
- /* update check information */
- if (s->checkfn != Z_NULL)
- z->adler = s->check = (*s->checkfn)(s->check, q, n);
-
- /* copy as as end of window */
- zmemcpy(p, q, n);
- p += n;
- q += n;
-
- /* see if more to copy at beginning of window */
- if (q == s->end)
- {
- /* wrap pointers */
- q = s->window;
- if (s->write == s->end)
- s->write = s->window;
-
- /* compute bytes to copy */
- n = (uInt)(s->write - q);
- if (n > z->avail_out) n = z->avail_out;
- if (n && r == Z_BUF_ERROR) r = Z_OK;
-
- /* update counters */
- z->avail_out -= n;
- z->total_out += n;
-
- /* update check information */
- if (s->checkfn != Z_NULL)
- z->adler = s->check = (*s->checkfn)(s->check, q, n);
-
- /* copy */
- zmemcpy(p, q, n);
- p += n;
- q += n;
- }
-
- /* update pointers */
- z->next_out = p;
- s->read = q;
-
- /* done */
- return r;
-}
-#endif
-
-/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-1998 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#ifndef __APPLE__
-const char inflate_copyright[] =
- " inflate 1.1.3 Copyright 1995-1998 Mark Adler ";
-#endif
-
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/* simplify the use of the inflate_huft type with some defines */
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-
-static int huft_build OF((
- uInt *, /* code lengths in bits */
- uInt, /* number of codes */
- uInt, /* number of "simple" codes */
- const uInt *, /* list of base values for non-simple codes */
- const uInt *, /* list of extra bits for non-simple codes */
- inflate_huft **, /* result: starting table */
- uInt *, /* maximum lookup bits (returns actual) */
- inflate_huft *, /* space for trees */
- uInt *, /* hufts used in space */
- uInt * )); /* space for values */
-
-/* Tables for deflate from PKZIP's appnote.txt. */
-static const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
- /* see note #13 above about 258 */
-static const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
- 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */
-static const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
- 8193, 12289, 16385, 24577};
-static const uInt cpdext[30] = { /* Extra bits for distance codes */
- 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
- 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
- 12, 12, 13, 13};
-
-/*
- Huffman code decoding is performed using a multi-level table lookup.
- The fastest way to decode is to simply build a lookup table whose
- size is determined by the longest code. However, the time it takes
- to build this table can also be a factor if the data being decoded
- is not very long. The most common codes are necessarily the
- shortest codes, so those codes dominate the decoding time, and hence
- the speed. The idea is you can have a shorter table that decodes the
- shorter, more probable codes, and then point to subsidiary tables for
- the longer codes. The time it costs to decode the longer codes is
- then traded against the time it takes to make longer tables.
-
- This results of this trade are in the variables lbits and dbits
- below. lbits is the number of bits the first level table for literal/
- length codes can decode in one step, and dbits is the same thing for
- the distance codes. Subsequent tables are also less than or equal to
- those sizes. These values may be adjusted either when all of the
- codes are shorter than that, in which case the longest code length in
- bits is used, or when the shortest code is *longer* than the requested
- table size, in which case the length of the shortest code in bits is
- used.
-
- There are two different values for the two tables, since they code a
- different number of possibilities each. The literal/length table
- codes 286 possible values, or in a flat code, a little over eight
- bits. The distance table codes 30 possible values, or a little less
- than five bits, flat. The optimum values for speed end up being
- about one bit more than those, so lbits is 8+1 and dbits is 5+1.
- The optimum values may differ though from machine to machine, and
- possibly even between compilers. Your mileage may vary.
- */
-
-
-/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */
-#define BMAX 15 /* maximum bit length of any code */
-
-static int huft_build(uInt *b, uInt n, uInt s, const uInt *d, const uInt *e, inflate_huft ** t, uInt *m, inflate_huft *hp, uInt *hn, uInt *v)
-//uInt *b; /* code lengths in bits (all assumed <= BMAX) */
-//uInt n; /* number of codes (assumed <= 288) */
-//uInt s; /* number of simple-valued codes (0..s-1) */
-//const uInt *d; /* list of base values for non-simple codes */
-//const uInt *e; /* list of extra bits for non-simple codes */
-//inflate_huft ** t; /* result: starting table */
-//uInt *m; /* maximum lookup bits, returns actual */
-//inflate_huft *hp; /* space for trees */
-//uInt *hn; /* hufts used in space */
-//uInt *v; /* working area: values in order of bit length */
-/* Given a list of code lengths and a maximum table size, make a set of
- tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
- if the given code set is incomplete (the tables are still built in this
- case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
- lengths), or Z_MEM_ERROR if not enough memory. */
-{
-
- uInt a; /* counter for codes of length k */
- uInt c[BMAX+1]; /* bit length count table */
- uInt f; /* i repeats in table every f entries */
- int g; /* maximum code length */
- int h; /* table level */
- register uInt i; /* counter, current code */
- register uInt j; /* counter */
- register int k; /* number of bits in current code */
- int l; /* bits per table (returned in m) */
- uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */
- register uInt *p; /* pointer into c[], b[], or v[] */
- inflate_huft *q; /* points to current table */
- struct inflate_huft_s r; /* table entry for structure assignment */
- inflate_huft *u[BMAX]; /* table stack */
- register int w; /* bits before this table == (l * h) */
- uInt x[BMAX+1]; /* bit offsets, then code stack */
- uInt *xp; /* pointer into x */
- int y; /* number of dummy codes added */
- uInt z; /* number of entries in current table */
-
-
- /* Generate counts for each bit length */
- p = c;
-#define C0 *p++ = 0;
-#define C2 C0 C0 C0 C0
-#define C4 C2 C2 C2 C2
- C4 /* clear c[]--assume BMAX+1 is 16 */
- p = b; i = n;
- do {
- c[*p++]++; /* assume all entries <= BMAX */
- } while (--i);
- if (c[0] == n) /* null input--all zero length codes */
- {
- *t = (inflate_huft *)Z_NULL;
- *m = 0;
- return Z_OK;
- }
-
-
- /* Find minimum and maximum length, bound *m by those */
- l = *m;
- for (j = 1; j <= BMAX; j++)
- if (c[j])
- break;
- k = j; /* minimum code length */
- if ((uInt)l < j)
- l = j;
- for (i = BMAX; i; i--)
- if (c[i])
- break;
- g = i; /* maximum code length */
- if ((uInt)l > i)
- l = i;
- *m = l;
-
-
- /* Adjust last length count to fill out codes, if needed */
- for (y = 1 << j; j < i; j++, y <<= 1)
- if ((y -= c[j]) < 0)
- return Z_DATA_ERROR;
- if ((y -= c[i]) < 0)
- return Z_DATA_ERROR;
- c[i] += y;
-
-
- /* Generate starting offsets into the value table for each length */
- x[1] = j = 0;
- p = c + 1; xp = x + 2;
- while (--i) { /* note that i == g from above */
- *xp++ = (j += *p++);
- }
-
-
- /* Make a table of values in order of bit lengths */
- p = b; i = 0;
- do {
- if ((j = *p++) != 0)
- v[x[j]++] = i;
- } while (++i < n);
- n = x[g]; /* set n to length of v */
-
-
- /* Generate the Huffman codes and for each, make the table entries */
- x[0] = i = 0; /* first Huffman code is zero */
- p = v; /* grab values in bit order */
- h = -1; /* no tables yet--level -1 */
- w = -l; /* bits decoded == (l * h) */
- u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */
- q = (inflate_huft *)Z_NULL; /* ditto */
- z = 0; /* ditto */
-
- /* go through the bit lengths (k already is bits in shortest code) */
- for (; k <= g; k++)
- {
- a = c[k];
- while (a--)
- {
- /* here i is the Huffman code of length k bits for value *p */
- /* make tables up to required level */
- while (k > w + l)
- {
- h++;
- w += l; /* previous table always l bits */
-
- /* compute minimum size table less than or equal to l bits */
- z = g - w;
- z = z > (uInt)l ? (uInt)l : z; /* table size upper limit */
- if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
- { /* too few codes for k-w bit table */
- f -= a + 1; /* deduct codes from patterns left */
- xp = c + k;
- if (j < z)
- while (++j < z) /* try smaller tables up to z bits */
- {
- if ((f <<= 1) <= *++xp)
- break; /* enough codes to use up j bits */
- f -= *xp; /* else deduct codes from patterns */
- }
- }
- z = 1 << j; /* table entries for j-bit table */
-
- /* allocate new table */
- if (*hn + z > MANY) /* (note: doesn't matter for fixed) */
- return Z_MEM_ERROR; /* not enough memory */
- u[h] = q = hp + *hn;
- *hn += z;
-
- /* connect to last table, if there is one */
- if (h)
- {
- x[h] = i; /* save pattern for backing up */
- r.bits = (Byte)l; /* bits to dump before this table */
- r.exop = (Byte)j; /* bits in this table */
- j = i >> (w - l);
- r.base = (uInt)(q - u[h-1] - j); /* offset to this table */
- u[h-1][j] = r; /* connect to last table */
- }
- else
- *t = q; /* first table is returned result */
- }
-
- /* set up table entry in r */
- r.bits = (Byte)(k - w);
- if (p >= v + n)
- r.exop = 128 + 64; /* out of values--invalid code */
- else if (*p < s)
- {
- r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */
- r.base = *p++; /* simple code is just the value */
- }
- else
- {
- r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */
- r.base = d[*p++ - s];
- }
-
- /* fill code-like entries with r */
- f = 1 << (k - w);
- for (j = i >> w; j < z; j += f)
- q[j] = r;
-
- /* backwards increment the k-bit code i */
- for (j = 1 << (k - 1); i & j; j >>= 1)
- i ^= j;
- i ^= j;
-
- /* backup over finished tables */
- mask = (1 << w) - 1; /* needed on HP, cc -O bug */
- while ((i & mask) != x[h])
- {
- h--; /* don't need to update q */
- w -= l;
- mask = (1 << w) - 1;
- }
- }
- }
-
-
- /* Return Z_BUF_ERROR if we were given an incomplete table */
- return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
-}
-
-
-#ifndef __APPLE__
-int inflate_trees_bits(uInt *c, uInt *bb, inflate_huft * *tb, inflate_huft *hp, z_streamp z)
-//uInt *c; /* 19 code lengths */
-//uInt *bb; /* bits tree desired/actual depth */
-//inflate_huft * *tb; /* bits tree result */
-//inflate_huft *hp; /* space for trees */
-//z_streamp z; /* for messages */
-{
- int r;
- uInt hn = 0; /* hufts used in space */
- uInt *v; /* work area for huft_build */
-
- if ((v = (uInt*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL)
- return Z_MEM_ERROR;
- r = huft_build(c, 19, 19, (uInt*)Z_NULL, (uInt*)Z_NULL,
- tb, bb, hp, &hn, v);
- if (r == Z_DATA_ERROR)
- z->msg = (char*)"oversubscribed dynamic bit lengths tree";
- else if (r == Z_BUF_ERROR || *bb == 0)
- {
- z->msg = (char*)"incomplete dynamic bit lengths tree";
- r = Z_DATA_ERROR;
- }
- ZFREE(z, v);
- return r;
-}
-#endif
-
-#ifndef __APPLE__
-int inflate_trees_dynamic(uInt nl, uInt nd, uInt *c, uInt *bl, uInt *bd, inflate_huft * *tl, inflate_huft * *td, inflate_huft *hp, z_streamp z)
-//uInt nl; /* number of literal/length codes */
-//uInt nd; /* number of distance codes */
-//uInt *c; /* that many (total) code lengths */
-//uInt *bl; /* literal desired/actual bit depth */
-//uInt *bd; /* distance desired/actual bit depth */
-//inflate_huft * *tl; /* literal/length tree result */
-//inflate_huft * *td; /* distance tree result */
-//inflate_huft *hp; /* space for trees */
-//z_streamp z; /* for messages */
-{
- int r;
- uInt hn = 0; /* hufts used in space */
- uInt *v; /* work area for huft_build */
-
- /* allocate work area */
- if ((v = (uInt*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
- return Z_MEM_ERROR;
-
- /* build literal/length tree */
- r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);
- if (r != Z_OK || *bl == 0)
- {
- if (r == Z_DATA_ERROR)
- z->msg = (char*)"oversubscribed literal/length tree";
- else if (r != Z_MEM_ERROR)
- {
- z->msg = (char*)"incomplete literal/length tree";
- r = Z_DATA_ERROR;
- }
- ZFREE(z, v);
- return r;
- }
-
- /* build distance tree */
- r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);
- if (r != Z_OK || (*bd == 0 && nl > 257))
- {
- if (r == Z_DATA_ERROR)
- z->msg = (char*)"oversubscribed distance tree";
- else if (r == Z_BUF_ERROR) {
-#ifdef PKZIP_BUG_WORKAROUND
- r = Z_OK;
- }
-#else
- z->msg = (char*)"incomplete distance tree";
- r = Z_DATA_ERROR;
- }
- else if (r != Z_MEM_ERROR)
- {
- z->msg = (char*)"empty distance tree with lengths";
- r = Z_DATA_ERROR;
- }
- ZFREE(z, v);
- return r;
-#endif
- }
-
- /* done */
- ZFREE(z, v);
- return Z_OK;
-}
-#endif
-
-/* inffixed.h -- table for decoding fixed codes
- * Generated automatically by the maketree.c program
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-static uInt fixed_bl = 9;
-static uInt fixed_bd = 5;
-static inflate_huft fixed_tl[] = {
- {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
- {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},
- {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},
- {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},
- {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},
- {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},
- {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},
- {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},
- {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
- {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},
- {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},
- {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},
- {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},
- {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},
- {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},
- {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},
- {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
- {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},
- {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},
- {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},
- {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},
- {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},
- {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},
- {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},
- {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},
- {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},
- {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},
- {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},
- {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},
- {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},
- {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},
- {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
- {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},
- {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},
- {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},
- {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},
- {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},
- {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},
- {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},
- {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
- {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},
- {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},
- {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},
- {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},
- {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},
- {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},
- {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},
- {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
- {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},
- {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},
- {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},
- {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},
- {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},
- {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},
- {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},
- {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},
- {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},
- {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},
- {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},
- {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},
- {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},
- {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},
- {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
- {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},
- {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},
- {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},
- {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},
- {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},
- {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},
- {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},
- {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
- {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},
- {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},
- {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},
- {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},
- {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},
- {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},
- {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},
- {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
- {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},
- {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},
- {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},
- {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},
- {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},
- {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},
- {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},
- {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},
- {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},
- {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},
- {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},
- {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},
- {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},
- {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},
- {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
- {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},
- {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},
- {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},
- {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},
- {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},
- {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},
- {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},
- {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
- {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},
- {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},
- {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},
- {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},
- {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},
- {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},
- {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},
- {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
- {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},
- {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},
- {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},
- {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},
- {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},
- {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},
- {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},
- {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},
- {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},
- {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},
- {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},
- {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},
- {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
- {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
- };
-static inflate_huft fixed_td[] = {
- {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
- {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
- {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
- {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
- {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
- {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
- {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
- {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
- };
-
-#ifndef __APPLE__
-int inflate_trees_fixed(uInt *bl, uInt *bd, inflate_huft * *tl, inflate_huft * *td, z_streamp z)
-//uInt *bl; /* literal desired/actual bit depth */
-//uInt *bd; /* distance desired/actual bit depth */
-//inflate_huft * *tl; /* literal/length tree result */
-//inflate_huft * *td; /* distance tree result */
-//z_streamp z; /* for memory allocation */
-{
- *bl = fixed_bl;
- *bd = fixed_bd;
- *tl = fixed_tl;
- *td = fixed_td;
- return Z_OK;
-}
-#endif
-
-/* simplify the use of the inflate_huft type with some defines */
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-/* macros for bit input with no checking and for returning unused bytes */
-#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
-#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
-
-/* Called with number of bytes left to write in window at least 258
- (the maximum string length) and number of input bytes available
- at least ten. The ten bytes are six bytes for the longest length/
- distance pair plus four bytes for overloading the bit buffer. */
-
-#ifndef __APPLE__
-int inflate_fast(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, inflate_blocks_statef *s, z_streamp z)
-{
- inflate_huft *t; /* temporary pointer */
- uInt e; /* extra bits or operation */
- uLong b; /* bit buffer */
- uInt k; /* bits in bit buffer */
- Byte *p; /* input data pointer */
- uInt n; /* bytes available there */
- Byte *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
- uInt ml; /* mask for literal/length tree */
- uInt md; /* mask for distance tree */
- uInt c; /* bytes to copy */
- uInt d; /* distance back to copy from */
- Byte *r; /* copy source pointer */
-
- /* load input, output, bit values */
- LOAD
-
- /* initialize masks */
- ml = inflate_mask[bl];
- md = inflate_mask[bd];
-
- /* do until not enough input or output space for fast loop */
- do { /* assume called with m >= 258 && n >= 10 */
- /* get literal/length code */
- GRABBITS(20) /* max bits for literal/length code */
- if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
- {
- DUMPBITS(t->bits)
- Tracevv((t->base >= 0x20 && t->base < 0x7f ?
- "inflate: * literal '%c'\n" :
- "inflate: * literal 0x%02x\n", t->base));
- *q++ = (Byte)t->base;
- m--;
- continue;
- }
- do {
- DUMPBITS(t->bits)
- if (e & 16)
- {
- /* get extra bits for length */
- e &= 15;
- c = t->base + ((uInt)b & inflate_mask[e]);
- DUMPBITS(e)
- Tracevv(("inflate: * length %u\n", c));
-
- /* decode distance base of block to copy */
- GRABBITS(15); /* max bits for distance code */
- e = (t = td + ((uInt)b & md))->exop;
- do {
- DUMPBITS(t->bits)
- if (e & 16)
- {
- /* get extra bits to add to distance base */
- e &= 15;
- GRABBITS(e) /* get extra bits (up to 13) */
- d = t->base + ((uInt)b & inflate_mask[e]);
- DUMPBITS(e)
- Tracevv(("inflate: * distance %u\n", d));
-
- /* do the copy */
- m -= c;
- if ((uInt)(q - s->window) >= d) /* offset before dest */
- { /* just copy */
- r = q - d;
- *q++ = *r++; c--; /* minimum count is three, */
- *q++ = *r++; c--; /* so unroll loop a little */
- }
- else /* else offset after destination */
- {
- e = d - (uInt)(q - s->window); /* bytes from offset to end */
- r = s->end - e; /* pointer to offset */
- if (c > e) /* if source crosses, */
- {
- c -= e; /* copy to end of window */
- do {
- *q++ = *r++;
- } while (--e);
- r = s->window; /* copy rest from start of window */
- }
- }
- do { /* copy all or what's left */
- *q++ = *r++;
- } while (--c);
- break;
- }
- else if ((e & 64) == 0)
- {
- t += t->base;
- e = (t += ((uInt)b & inflate_mask[e]))->exop;
- }
- else
- {
- z->msg = (char*)"invalid distance code";
- UNGRAB
- UPDATE
- return Z_DATA_ERROR;
- }
- } while (1);
- break;
- }
- if ((e & 64) == 0)
- {
- t += t->base;
- if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
- {
- DUMPBITS(t->bits)
- Tracevv((t->base >= 0x20 && t->base < 0x7f ?
- "inflate: * literal '%c'\n" :
- "inflate: * literal 0x%02x\n", t->base));
- *q++ = (Byte)t->base;
- m--;
- break;
- }
- }
- else if (e & 32)
- {
- Tracevv(("inflate: * end of block\n"));
- UNGRAB
- UPDATE
- return Z_STREAM_END;
- }
- else
- {
- z->msg = (char*)"invalid literal/length code";
- UNGRAB
- UPDATE
- return Z_DATA_ERROR;
- }
- } while (1);
- } while (m >= 258 && n >= 10);
-
- /* not enough input or output--restore pointers and return */
- UNGRAB
- UPDATE
- return Z_OK;
-}
-#endif
-
-/* infcodes.c -- process literals and length/distance pairs
- * Copyright (C) 1995-1998 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* simplify the use of the inflate_huft type with some defines */
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
- START, /* x: set up for LEN */
- LEN, /* i: get length/literal/eob next */
- LENEXT, /* i: getting length extra (have base) */
- DIST, /* i: get distance next */
- DISTEXT, /* i: getting distance extra */
- COPY, /* o: copying bytes in window, waiting for space */
- LIT, /* o: got literal, waiting for output space */
- WASH, /* o: got eob, possibly still output waiting */
- END, /* x: got eob and all data flushed */
- BADCODE} /* x: got error */
-inflate_codes_mode;
-
-/* inflate codes private state */
-struct inflate_codes_state {
-
- /* mode */
- inflate_codes_mode mode; /* current inflate_codes mode */
-
- /* mode dependent information */
- uInt len;
- union {
- struct {
- inflate_huft *tree; /* pointer into tree */
- uInt need; /* bits needed */
- } code; /* if LEN or DIST, where in tree */
- uInt lit; /* if LIT, literal */
- struct {
- uInt get; /* bits to get for extra */
- uInt dist; /* distance back to copy from */
- } copy; /* if EXT or COPY, where and how much */
- } sub; /* submode */
-
- /* mode independent information */
- Byte lbits; /* ltree bits decoded per branch */
- Byte dbits; /* dtree bits decoder per branch */
- inflate_huft *ltree; /* literal/length/eob tree */
- inflate_huft *dtree; /* distance tree */
-
-};
-
-#ifndef __APPLE__
-inflate_codes_statef *inflate_codes_new(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, z_streamp z)
-{
- inflate_codes_statef *c;
-
- if ((c = (inflate_codes_statef *)
- ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
- {
- c->mode = START;
- c->lbits = (Byte)bl;
- c->dbits = (Byte)bd;
- c->ltree = tl;
- c->dtree = td;
- Tracev(("inflate: codes new\n"));
- }
- return c;
-}
-#endif
-
-#ifndef __APPLE__
-int inflate_codes(inflate_blocks_statef *s, z_streamp z, int r)
-{
- uInt j; /* temporary storage */
- inflate_huft *t; /* temporary pointer */
- uInt e; /* extra bits or operation */
- uLong b; /* bit buffer */
- uInt k; /* bits in bit buffer */
- Byte *p; /* input data pointer */
- uInt n; /* bytes available there */
- Byte *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
- Byte *f; /* pointer to copy strings from */
- inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
-
- /* copy input/output information to locals (UPDATE macro restores) */
- LOAD
-
- /* process input and output based on current state */
- while (1) switch (c->mode)
- { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
- case START: /* x: set up for LEN */
-#ifndef SLOW
- if (m >= 258 && n >= 10)
- {
- UPDATE
- r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
- LOAD
- if (r != Z_OK)
- {
- c->mode = r == Z_STREAM_END ? WASH : BADCODE;
- break;
- }
- }
-#endif /* !SLOW */
- c->sub.code.need = c->lbits;
- c->sub.code.tree = c->ltree;
- c->mode = LEN;
- case LEN: /* i: get length/literal/eob next */
- j = c->sub.code.need;
- NEEDBITS(j)
- t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
- DUMPBITS(t->bits)
- e = (uInt)(t->exop);
- if (e == 0) /* literal */
- {
- c->sub.lit = t->base;
- Tracevv((t->base >= 0x20 && t->base < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", t->base));
- c->mode = LIT;
- break;
- }
- if (e & 16) /* length */
- {
- c->sub.copy.get = e & 15;
- c->len = t->base;
- c->mode = LENEXT;
- break;
- }
- if ((e & 64) == 0) /* next table */
- {
- c->sub.code.need = e;
- c->sub.code.tree = t + t->base;
- break;
- }
- if (e & 32) /* end of block */
- {
- Tracevv(("inflate: end of block\n"));
- c->mode = WASH;
- break;
- }
- c->mode = BADCODE; /* invalid code */
- z->msg = (char*)"invalid literal/length code";
- r = Z_DATA_ERROR;
- LEAVE
- case LENEXT: /* i: getting length extra (have base) */
- j = c->sub.copy.get;
- NEEDBITS(j)
- c->len += (uInt)b & inflate_mask[j];
- DUMPBITS(j)
- c->sub.code.need = c->dbits;
- c->sub.code.tree = c->dtree;
- Tracevv(("inflate: length %u\n", c->len));
- c->mode = DIST;
- case DIST: /* i: get distance next */
- j = c->sub.code.need;
- NEEDBITS(j)
- t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
- DUMPBITS(t->bits)
- e = (uInt)(t->exop);
- if (e & 16) /* distance */
- {
- c->sub.copy.get = e & 15;
- c->sub.copy.dist = t->base;
- c->mode = DISTEXT;
- break;
- }
- if ((e & 64) == 0) /* next table */
- {
- c->sub.code.need = e;
- c->sub.code.tree = t + t->base;
- break;
- }
- c->mode = BADCODE; /* invalid code */
- z->msg = (char*)"invalid distance code";
- r = Z_DATA_ERROR;
- LEAVE
- case DISTEXT: /* i: getting distance extra */
- j = c->sub.copy.get;
- NEEDBITS(j)
- c->sub.copy.dist += (uInt)b & inflate_mask[j];
- DUMPBITS(j)
- Tracevv(("inflate: distance %u\n", c->sub.copy.dist));
- c->mode = COPY;
- case COPY: /* o: copying bytes in window, waiting for space */
-#ifndef __TURBOC__ /* Turbo C bug for following expression */
- f = (uInt)(q - s->window) < c->sub.copy.dist ?
- s->end - (c->sub.copy.dist - (q - s->window)) :
- q - c->sub.copy.dist;
-#else
- f = q - c->sub.copy.dist;
- if ((uInt)(q - s->window) < c->sub.copy.dist)
- f = s->end - (c->sub.copy.dist - (uInt)(q - s->window));
-#endif
- while (c->len)
- {
- NEEDOUT
- OUTBYTE(*f++)
- if (f == s->end)
- f = s->window;
- c->len--;
- }
- c->mode = START;
- break;
- case LIT: /* o: got literal, waiting for output space */
- NEEDOUT
- OUTBYTE(c->sub.lit)
- c->mode = START;
- break;
- case WASH: /* o: got eob, possibly more output */
- if (k > 7) /* return unused byte, if any */
- {
- Assert(k < 16, "inflate_codes grabbed too many bytes")
- k -= 8;
- n++;
- p--; /* can always return one */
- }
- FLUSH
- if (s->read != s->write)
- LEAVE
- c->mode = END;
- case END:
- r = Z_STREAM_END;
- LEAVE
- case BADCODE: /* x: got error */
- r = Z_DATA_ERROR;
- LEAVE
- default:
- r = Z_STREAM_ERROR;
- LEAVE
- }
-#ifdef NEED_DUMMY_RETURN
- return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
-#endif
-}
-#endif
-
-#ifndef __APPLE__
-void inflate_codes_free(inflate_codes_statef *c, z_streamp z)
-{
- ZFREE(z, c);
- Tracev(("inflate: codes free\n"));
-}
-#endif
-
-/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-1998 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#define BASE 65521L /* largest prime smaller than 65536 */
-#define NMAX 5552
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-
-#undef DO1
-#undef DO2
-#undef DO4
-#undef DO8
-
-#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
-#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
-#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
-#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
-#define DO16(buf) DO8(buf,0); DO8(buf,8);
-
-/* ========================================================================= */
-#ifndef __APPLE__
-uLong adler32(uLong adler, const Byte *buf, uInt len)
-{
- unsigned long s1 = adler & 0xffff;
- unsigned long s2 = (adler >> 16) & 0xffff;
- int k;
-
- if (buf == Z_NULL) return 1L;
-
- while (len > 0) {
- k = len < NMAX ? len : NMAX;
- len -= k;
- while (k >= 16) {
- DO16(buf);
- buf += 16;
- k -= 16;
- }
- if (k != 0) do {
- s1 += *buf++;
- s2 += s1;
- } while (--k);
- s1 %= BASE;
- s2 %= BASE;
- }
- return (s2 << 16) | s1;
-}
-#endif
-
-
-/* infblock.h -- header to use infblock.c
- * Copyright (C) 1995-1998 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-extern inflate_blocks_statef * inflate_blocks_new OF((
- z_streamp z,
- check_func c, /* check function */
- uInt w)); /* window size */
-
-extern int inflate_blocks OF((
- inflate_blocks_statef *,
- z_streamp ,
- int)); /* initial return code */
-
-extern void inflate_blocks_reset OF((
- inflate_blocks_statef *,
- z_streamp ,
- uLong *)); /* check value on output */
-
-extern int inflate_blocks_free OF((
- inflate_blocks_statef *,
- z_streamp));
-
-extern void inflate_set_dictionary OF((
- inflate_blocks_statef *s,
- const Byte *d, /* dictionary */
- uInt n)); /* dictionary length */
-
-extern int inflate_blocks_sync_point OF((
- inflate_blocks_statef *s));
-
-typedef enum {
- imMETHOD, /* waiting for method byte */
- imFLAG, /* waiting for flag byte */
- imDICT4, /* four dictionary check bytes to go */
- imDICT3, /* three dictionary check bytes to go */
- imDICT2, /* two dictionary check bytes to go */
- imDICT1, /* one dictionary check byte to go */
- imDICT0, /* waiting for inflateSetDictionary */
- imBLOCKS, /* decompressing blocks */
- imCHECK4, /* four check bytes to go */
- imCHECK3, /* three check bytes to go */
- imCHECK2, /* two check bytes to go */
- imCHECK1, /* one check byte to go */
- imDONE, /* finished check, done */
- imBAD} /* got an error--stay here */
-inflate_mode;
-
-/* inflate private state */
-struct internal_state {
-
- /* mode */
- inflate_mode mode; /* current inflate mode */
-
- /* mode dependent information */
- union {
- uInt method; /* if FLAGS, method byte */
- struct {
- uLong was; /* computed check value */
- uLong need; /* stream check value */
- } check; /* if CHECK, check values to compare */
- uInt marker; /* if BAD, inflateSync's marker bytes count */
- } sub; /* submode */
-
- /* mode independent information */
- int nowrap; /* flag for no wrapper */
- uInt wbits; /* log2(window size) (8..15, defaults to 15) */
- inflate_blocks_statef
- *blocks; /* current inflate_blocks state */
-
-};
-
-
-#ifndef __APPLE__
-int inflateReset(z_streamp z)
-{
- if (z == Z_NULL || z->state == Z_NULL)
- return Z_STREAM_ERROR;
- z->total_in = z->total_out = 0;
- z->msg = Z_NULL;
- z->state->mode = z->state->nowrap ? imBLOCKS : imMETHOD;
- inflate_blocks_reset(z->state->blocks, z, Z_NULL);
- Tracev(("inflate: reset\n"));
- return Z_OK;
-}
-#endif
-
-#ifndef __APPLE__
-int inflateEnd(z_streamp z)
-{
- if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
- return Z_STREAM_ERROR;
- if (z->state->blocks != Z_NULL)
- inflate_blocks_free(z->state->blocks, z);
- ZFREE(z, z->state);
- z->state = Z_NULL;
- Tracev(("inflate: end\n"));
- return Z_OK;
-}
-#endif
-
-#ifndef __APPLE__
-int inflateInit2_(z_streamp z, int w, const char *version, int stream_size)
-{
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != sizeof(z_stream))
- return Z_VERSION_ERROR;
-
- /* initialize state */
- if (z == Z_NULL)
- return Z_STREAM_ERROR;
- z->msg = Z_NULL;
- if (z->zalloc == Z_NULL)
- {
- z->zalloc = (void *(*)(void *, unsigned, unsigned))zcalloc;
- z->opaque = (voidp)0;
- }
- if (z->zfree == Z_NULL) z->zfree = (void (*)(void *, void *))zcfree;
- if ((z->state = (struct internal_state *)
- ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)
- return Z_MEM_ERROR;
- z->state->blocks = Z_NULL;
-
- /* handle undocumented nowrap option (no zlib header or check) */
- z->state->nowrap = 0;
- if (w < 0)
- {
- w = - w;
- z->state->nowrap = 1;
- }
-
- /* set window size */
- if (w < 8 || w > 15)
- {
- inflateEnd(z);
- return Z_STREAM_ERROR;
- }
- z->state->wbits = (uInt)w;
-
- /* create inflate_blocks state */
- if ((z->state->blocks =
- inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w))
- == Z_NULL)
- {
- inflateEnd(z);
- return Z_MEM_ERROR;
- }
- Tracev(("inflate: allocated\n"));
-
- /* reset state */
- inflateReset(z);
- return Z_OK;
-}
-#endif
-
-#ifndef __APPLE__
-int inflateInit_(z_streamp z, const char *version, int stream_size)
-{
- return inflateInit2_(z, DEF_WBITS, version, stream_size);
-}
-#endif
-
-#define iNEEDBYTE {if(z->avail_in==0)return r;r=f;}
-#define iNEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
-
-#ifndef __APPLE__
-int inflate(z_streamp z, int f)
-{
- int r;
- uInt b;
-
- if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL)
- return Z_STREAM_ERROR;
- f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
- r = Z_BUF_ERROR;
- while (1) switch (z->state->mode)
- {
- case imMETHOD:
- iNEEDBYTE
- if (((z->state->sub.method = iNEXTBYTE) & 0xf) != Z_DEFLATED)
- {
- z->state->mode = imBAD;
- z->msg = (char*)"unknown compression method";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
- {
- z->state->mode = imBAD;
- z->msg = (char*)"invalid window size";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- z->state->mode = imFLAG;
- case imFLAG:
- iNEEDBYTE
- b = iNEXTBYTE;
- if (((z->state->sub.method << 8) + b) % 31)
- {
- z->state->mode = imBAD;
- z->msg = (char*)"incorrect header check";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- Tracev(("inflate: zlib header ok\n"));
- if (!(b & PRESET_DICT))
- {
- z->state->mode = imBLOCKS;
- break;
- }
- z->state->mode = imDICT4;
- case imDICT4:
- iNEEDBYTE
- z->state->sub.check.need = (uLong)iNEXTBYTE << 24;
- z->state->mode = imDICT3;
- case imDICT3:
- iNEEDBYTE
- z->state->sub.check.need += (uLong)iNEXTBYTE << 16;
- z->state->mode = imDICT2;
- case imDICT2:
- iNEEDBYTE
- z->state->sub.check.need += (uLong)iNEXTBYTE << 8;
- z->state->mode = imDICT1;
- case imDICT1:
- iNEEDBYTE
- z->state->sub.check.need += (uLong)iNEXTBYTE;
- z->adler = z->state->sub.check.need;
- z->state->mode = imDICT0;
- return Z_NEED_DICT;
- case imDICT0:
- z->state->mode = imBAD;
- z->msg = (char*)"need dictionary";
- z->state->sub.marker = 0; /* can try inflateSync */
- return Z_STREAM_ERROR;
- case imBLOCKS:
- r = inflate_blocks(z->state->blocks, z, r);
- if (r == Z_DATA_ERROR)
- {
- z->state->mode = imBAD;
- z->state->sub.marker = 0; /* can try inflateSync */
- break;
- }
- if (r == Z_OK)
- r = f;
- if (r != Z_STREAM_END)
- return r;
- r = f;
- inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
- if (z->state->nowrap)
- {
- z->state->mode = imDONE;
- break;
- }
- z->state->mode = imCHECK4;
- case imCHECK4:
- iNEEDBYTE
- z->state->sub.check.need = (uLong)iNEXTBYTE << 24;
- z->state->mode = imCHECK3;
- case imCHECK3:
- iNEEDBYTE
- z->state->sub.check.need += (uLong)iNEXTBYTE << 16;
- z->state->mode = imCHECK2;
- case imCHECK2:
- iNEEDBYTE
- z->state->sub.check.need += (uLong)iNEXTBYTE << 8;
- z->state->mode = imCHECK1;
- case imCHECK1:
- iNEEDBYTE
- z->state->sub.check.need += (uLong)iNEXTBYTE;
-
- if (z->state->sub.check.was != z->state->sub.check.need)
- {
- z->state->mode = imBAD;
- z->msg = (char*)"incorrect data check";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- Tracev(("inflate: zlib check ok\n"));
- z->state->mode = imDONE;
- case imDONE:
- return Z_STREAM_END;
- case imBAD:
- return Z_DATA_ERROR;
- default:
- return Z_STREAM_ERROR;
- }
-#ifdef NEED_DUMMY_RETURN
- return Z_STREAM_ERROR; /* Some dumb compilers complain without this */
-#endif
-}
-#endif
-
-#ifndef __APPLE__
-int inflateSetDictionary(z_streamp z, const Byte *dictionary, uInt dictLength)
-{
- uInt length = dictLength;
-
- if (z == Z_NULL || z->state == Z_NULL || z->state->mode != imDICT0)
- return Z_STREAM_ERROR;
-
- if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;
- z->adler = 1L;
-
- if (length >= ((uInt)1<<z->state->wbits))
- {
- length = (1<<z->state->wbits)-1;
- dictionary += dictLength - length;
- }
- inflate_set_dictionary(z->state->blocks, dictionary, length);
- z->state->mode = imBLOCKS;
- return Z_OK;
-}
-#endif
-
-#ifndef __APPLE__
-int inflateSync(z_streamp z)
-{
- uInt n; /* number of bytes to look at */
- Byte *p; /* pointer to bytes */
- uInt m; /* number of marker bytes found in a row */
- uLong r, w; /* temporaries to save total_in and total_out */
-
- /* set up */
- if (z == Z_NULL || z->state == Z_NULL)
- return Z_STREAM_ERROR;
- if (z->state->mode != imBAD)
- {
- z->state->mode = imBAD;
- z->state->sub.marker = 0;
- }
- if ((n = z->avail_in) == 0)
- return Z_BUF_ERROR;
- p = z->next_in;
- m = z->state->sub.marker;
-
- /* search */
- while (n && m < 4)
- {
- static const Byte mark[4] = {0, 0, 0xff, 0xff};
- if (*p == mark[m])
- m++;
- else if (*p)
- m = 0;
- else
- m = 4 - m;
- p++, n--;
- }
-
- /* restore */
- z->total_in += p - z->next_in;
- z->next_in = p;
- z->avail_in = n;
- z->state->sub.marker = m;
-
- /* return no joy or set up to restart on a new block */
- if (m != 4)
- return Z_DATA_ERROR;
- r = z->total_in; w = z->total_out;
- inflateReset(z);
- z->total_in = r; z->total_out = w;
- z->state->mode = imBLOCKS;
- return Z_OK;
-}
-#endif
-
-/* Returns true if inflate is currently at the end of a block generated
- * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
- * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
- * but removes the length bytes of the resulting empty stored block. When
- * decompressing, PPP checks that at the end of input packet, inflate is
- * waiting for these length bytes.
- */
-#ifndef __APPLE__
-int inflateSyncPoint(z_streamp z)
-{
- if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)
- return Z_STREAM_ERROR;
- return inflate_blocks_sync_point(z->state->blocks);
-}
-#endif
-
-#ifndef __APPLE__
-voidp zcalloc (voidp opaque, unsigned items, unsigned size)
-{
- if (opaque) items += size - size; /* make compiler happy */
- return (voidp)safe_malloc(items*size);
-}
-
-void zcfree (voidp opaque, voidp ptr)
-{
- free(ptr);
- if (opaque) return; /* make compiler happy */
-}
-#endif
+++ /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 GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#if defined( STRICTUNZIP ) || defined( STRICTZIPUNZIP )
-/* like the STRICT of WIN32, we define a pointer that cannot be converted
- from (void*) without cast */
-typedef struct TagunzFile__ { int unused; } unzFile__;
-typedef unzFile__ *unzFile;
-#else
-typedef void* unzFile;
-#endif
-
-
-/* tm_unz contain date/time info */
-typedef struct tm_unz_s
-{
- unsigned int tm_sec; /* seconds after the minute - [0,59] */
- unsigned int tm_min; /* minutes after the hour - [0,59] */
- unsigned int tm_hour; /* hours since midnight - [0,23] */
- unsigned int tm_mday; /* day of the month - [1,31] */
- unsigned int tm_mon; /* months since January - [0,11] */
- unsigned int tm_year; /* years - [1980..2044] */
-} tm_unz;
-
-/* unz_global_info structure contain global data about the ZIPfile
- These data comes from the end of central dir */
-typedef struct unz_global_info_s
-{
- unsigned long number_entry; /* total number of entries in the central dir on this disk */
- unsigned long size_comment; /* size of the global comment of the zipfile */
-} unz_global_info;
-
-
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_info_s
-{
- unsigned long version; /* version made by 2 unsigned chars */
- unsigned long version_needed; /* version needed to extract 2 unsigned chars */
- unsigned long flag; /* general purpose bit flag 2 unsigned chars */
- unsigned long compression_method; /* compression method 2 unsigned chars */
- unsigned long dosDate; /* last mod file date in Dos fmt 4 unsigned chars */
- unsigned long crc; /* crc-32 4 unsigned chars */
- unsigned long compressed_size; /* compressed size 4 unsigned chars */
- unsigned long uncompressed_size; /* uncompressed size 4 unsigned chars */
- unsigned long size_filename; /* filename length 2 unsigned chars */
- unsigned long size_file_extra; /* extra field length 2 unsigned chars */
- unsigned long size_file_comment; /* file comment length 2 unsigned chars */
-
- unsigned long disk_num_start; /* disk number start 2 unsigned chars */
- unsigned long internal_fa; /* internal file attributes 2 unsigned chars */
- unsigned long external_fa; /* external file attributes 4 unsigned chars */
-
- tm_unz tmu_date;
-} unz_file_info;
-
-/* unz_file_info_interntal contain internal info about a file in zipfile*/
-typedef struct unz_file_info_internal_s
-{
- unsigned long offset_curfile; /* relative offset of static header 4 unsigned chars */
-} unz_file_info_internal;
-
-typedef void* ( *alloc_func )( void* opaque, unsigned int items, unsigned int size );
-typedef void ( *free_func )( void* opaque, void* address );
-
-struct internal_state;
-
-typedef struct z_stream_s {
- unsigned char *next_in; /* next input unsigned char */
- unsigned int avail_in; /* number of unsigned chars available at next_in */
- unsigned long total_in; /* total nb of input unsigned chars read so */
-
- unsigned char *next_out; /* next output unsigned char should be put there */
- unsigned int avail_out; /* remaining free space at next_out */
- unsigned long total_out; /* total nb of unsigned chars output so */
-
- char *msg; /* last error message, NULL if no error */
- struct internal_state *state; /* not visible by applications */
-
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- unsigned char* opaque; /* private data object passed to zalloc and zfree */
-
- int data_type; /* best guess about the data type: ascii or binary */
- unsigned long adler; /* adler32 value of the uncompressed data */
- unsigned long reserved; /* reserved for future use */
-} z_stream;
-
-typedef z_stream *z_streamp;
-
-
-/* file_in_zip_read_info_s contain internal information about a file in zipfile,
- when reading and decompress it */
-typedef struct
-{
- char *read_buffer; /* internal buffer for compressed data */
- z_stream stream; /* zLib stream structure for inflate */
-
- unsigned long pos_in_zipfile; /* position in unsigned char on the zipfile, for fseek*/
- unsigned long stream_initialised; /* flag set if stream structure is initialised*/
-
- unsigned long offset_local_extrafield; /* offset of the static extra field */
- unsigned int size_local_extrafield; /* size of the static extra field */
- unsigned long pos_local_extrafield; /* position in the static extra field in read*/
-
- unsigned long crc32; /* crc32 of all data uncompressed */
- unsigned long crc32_wait; /* crc32 we must obtain after decompress all */
- unsigned long rest_read_compressed; /* number of unsigned char to be decompressed */
- unsigned long rest_read_uncompressed; /*number of unsigned char to be obtained after decomp*/
- FILE* file; /* io structore of the zipfile */
- unsigned long compression_method; /* compression method (0==store) */
- unsigned long byte_before_the_zipfile; /* unsigned char before the zipfile, (>0 for sfx)*/
-} file_in_zip_read_info_s;
-
-
-/* unz_s contain internal information about the zipfile
- */
-typedef struct
-{
- FILE* file; /* io structore of the zipfile */
- unz_global_info gi; /* public global information */
- unsigned long byte_before_the_zipfile; /* unsigned char before the zipfile, (>0 for sfx)*/
- unsigned long num_file; /* number of the current file in the zipfile*/
- unsigned long pos_in_central_dir; /* pos of the current file in the central dir*/
- unsigned long current_file_ok; /* flag about the usability of the current file*/
- unsigned long central_pos; /* position of the beginning of the central dir*/
-
- unsigned long size_central_dir; /* size of the central directory */
- unsigned long offset_central_dir; /* offset of start of central directory with
- respect to the starting disk number */
-
- unz_file_info cur_file_info; /* public info about the current file in zip*/
- unz_file_info_internal cur_file_info_internal; /* private info about it*/
- file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
- file if we are decompressing it */
-} unz_s;
-
-#define UNZ_OK ( 0 )
-#define UNZ_END_OF_LIST_OF_FILE ( -100 )
-#define UNZ_ERRNO ( Z_ERRNO )
-#define UNZ_EOF ( 0 )
-#define UNZ_PARAMERROR ( -102 )
-#define UNZ_BADZIPFILE ( -103 )
-#define UNZ_INTERNALERROR ( -104 )
-#define UNZ_CRCERROR ( -105 )
-
-#define UNZ_CASESENSITIVE 1
-#define UNZ_NOTCASESENSITIVE 2
-#define UNZ_OSDEFAULTCASE 0
-
-extern int unzStringFileNameCompare( const char* fileName1, const char* fileName2, int iCaseSensitivity );
-
-/*
- Compare two filename (fileName1,fileName2).
- If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
- If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
- or strcasecmp)
- If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
- (like 1 on Unix, 2 on Windows)
- */
-
-extern unzFile unzOpen( const char *path );
-extern unzFile unzReOpen( const char* path, unzFile file );
-
-/*
- Open a Zip file. path contain the full pathname (by example,
- on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
- "zlib/zlib111.zip".
- If the zipfile cannot be opened (file don't exist or in not valid), the
- return value is NULL.
- Else, the return value is a unzFile Handle, usable with other function
- of this unzip package.
- */
-
-extern int unzClose( unzFile file );
-
-/*
- Close a ZipFile opened with unzipOpen.
- If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
- these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
- return UNZ_OK if there is no problem. */
-
-extern int unzGetGlobalInfo( unzFile file, unz_global_info *pglobal_info );
-
-/*
- Write info about the ZipFile in the *pglobal_info structure.
- No preparation of the structure is needed
- return UNZ_OK if there is no problem. */
-
-
-extern int unzGetGlobalComment( unzFile file, char *szComment, unsigned long uSizeBuf );
-
-/*
- Get the global comment string of the ZipFile, in the szComment buffer.
- uSizeBuf is the size of the szComment buffer.
- return the number of unsigned char copied or an error code <0
- */
-
-
-/***************************************************************************/
-/* Unzip package allow you browse the directory of the zipfile */
-
-extern int unzGoToFirstFile( unzFile file );
-
-/*
- Set the current file of the zipfile to the first file.
- return UNZ_OK if there is no problem
- */
-
-extern int unzGoToNextFile( unzFile file );
-
-/*
- Set the current file of the zipfile to the next file.
- return UNZ_OK if there is no problem
- return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
- */
-
-extern int unzLocateFile( unzFile file, const char *szFileName, int iCaseSensitivity );
-
-/*
- Try locate the file szFileName in the zipfile.
- For the iCaseSensitivity signification, see unzStringFileNameCompare
-
- return value :
- UNZ_OK if the file is found. It becomes the current file.
- UNZ_END_OF_LIST_OF_FILE if the file is not found
- */
-
-
-extern int unzGetCurrentFileInfo( unzFile file, unz_file_info *pfile_info, char *szFileName, unsigned long fileNameBufferSize, void *extraField, unsigned long extraFieldBufferSize, char *szComment, unsigned long commentBufferSize );
-
-/*
- Get Info about the current file
- if pfile_info!=NULL, the *pfile_info structure will contain somes info about
- the current file
- if szFileName!=NULL, the filemane string will be copied in szFileName
- (fileNameBufferSize is the size of the buffer)
- if extraField!=NULL, the extra field information will be copied in extraField
- (extraFieldBufferSize is the size of the buffer).
- This is the Central-header version of the extra field
- if szComment!=NULL, the comment string of the file will be copied in szComment
- (commentBufferSize is the size of the buffer)
- */
-
-/***************************************************************************/
-/* for reading the content of the current zipfile, you can open it, read data
- from it, and close it (you can close it before reading all the file)
- */
-
-extern int unzOpenCurrentFile( unzFile file );
-
-/*
- Open for reading data the current file in the zipfile.
- If there is no error, the return value is UNZ_OK.
- */
-
-extern int unzCloseCurrentFile( unzFile file );
-
-/*
- Close the file in zip opened with unzOpenCurrentFile
- Return UNZ_CRCERROR if all the file was read but the CRC is not good
- */
-
-
-extern int unzReadCurrentFile( unzFile file, void* buf, unsigned len );
-
-/*
- Read unsigned chars from the current file (opened by unzOpenCurrentFile)
- buf contain buffer where data must be copied
- len the size of buf.
-
- return the number of unsigned char copied if somes unsigned chars are copied
- return 0 if the end of file was reached
- return <0 with error code if there is an error
- (UNZ_ERRNO for IO error, or zLib error for uncompress error)
- */
-
-extern long unztell( unzFile file );
-
-/*
- Give the current position in uncompressed data
- */
-
-extern int unzeof( unzFile file );
-
-/*
- return 1 if the end of file was reached, 0 elsewhere
- */
-
-extern int unzGetLocalExtrafield( unzFile file, void* buf, unsigned len );
-
-/*
- Read extra field from the current file (opened by unzOpenCurrentFile)
- This is the local-header version of the extra field (sometimes, there is
- more info in the local-header version than in the central-header)
-
- if buf==NULL, it return the size of the local extra field
-
- if buf!=NULL, len is the size of the buffer, the extra header is copied in
- buf.
- the return value is the number of unsigned chars copied in buf, or (if <0)
- the error code
- */
#include "mathlib.h"
#include "inout.h"
#include "vfs.h"
-#include "unzip.h"
+#include <minizip/unzip.h>
+#include <glib.h>
+#define GARUX_DISABLE_BAD_MINIZ
+#ifndef GARUX_DISABLE_BAD_MINIZ
#include "miniz.h"
+#endif
typedef struct
{
char* unzFilePath;
char* name;
- unz_s zipinfo;
unzFile zipfile;
+ unz_file_pos zippos;
guint32 size;
} VFS_PAKFILE;
for ( i = 0; i < gi.number_entry; i++ )
{
char filename_inzip[NAME_MAX];
+ char *filename_lower;
unz_file_info file_info;
VFS_PAKFILE* file;
if ( err != UNZ_OK ) {
break;
}
+ unz_file_pos pos;
+ err = unzGetFilePos( uf, &pos );
+ if ( err != UNZ_OK ) {
+ break;
+ }
file = (VFS_PAKFILE*)safe_malloc( sizeof( VFS_PAKFILE ) );
g_pakFiles = g_slist_append( g_pakFiles, file );
vfsFixDOSName( filename_inzip );
- g_strdown( filename_inzip );
+ //-1 null terminated string
+ filename_lower = g_ascii_strdown( filename_inzip, -1 );
- file->name = strdup( filename_inzip );
+ file->name = strdup( filename_lower );
file->size = file_info.uncompressed_size;
file->zipfile = uf;
file->unzFilePath = unzFilePath;
- memcpy( &file->zipinfo, uf, sizeof( unz_s ) );
+ file->zippos = pos;
if ( ( i + 1 ) < gi.number_entry ) {
err = unzGoToNextFile( uf );
break;
}
}
+ g_free( filename_lower );
}
}
{
char *ext = strrchr( dirlist, '.' );
- if ( ext && !Q_stricmp( ext, ".pk3dir" ) ) {
+ if ( ext != NULL && ( !Q_stricmp( ext, ".pk3dir" ) || !Q_stricmp( ext, ".dpkdir" ) ) ) {
if ( g_numDirs == VFS_MAXDIRS ) {
continue;
}
snprintf( g_strDirs[g_numDirs], PATH_MAX, "%s/%s", path, name );
- g_strDirs[g_numDirs][PATH_MAX] = '\0';
+ g_strDirs[g_numDirs][PATH_MAX-1] = '\0';
vfsFixDOSName( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs] );
++g_numDirs;
}
- if ( ( ext == NULL ) || ( Q_stricmp( ext, ".pk3" ) != 0 ) ) {
+ if ( ext == NULL || ( Q_stricmp( ext, ".pk3" ) != 0 && Q_stricmp( ext, ".dpk" ) != 0 ) ) {
continue;
}
}
int vfsGetFileCount( const char *filename ){
int i, count = 0;
char fixed[NAME_MAX], tmp[NAME_MAX];
+ char *lower;
GSList *lst;
strcpy( fixed, filename );
vfsFixDOSName( fixed );
- g_strdown( fixed );
+ lower = g_ascii_strdown( fixed, -1 );
for ( lst = g_pakFiles; lst != NULL; lst = g_slist_next( lst ) )
{
VFS_PAKFILE* file = (VFS_PAKFILE*)lst->data;
- if ( strcmp( file->name, fixed ) == 0 ) {
+ if ( strcmp( file->name, lower ) == 0 ) {
count++;
}
}
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
- strcat( tmp, fixed );
+ strcat( tmp, lower );
if ( access( tmp, R_OK ) == 0 ) {
count++;
}
}
-
+ g_free( lower );
return count;
}
int vfsLoadFile( const char *filename, void **bufferptr, int index ){
int i, count = 0;
char tmp[NAME_MAX], fixed[NAME_MAX];
+ char *lower;
GSList *lst;
// filename is a full path
*bufferptr = NULL;
strcpy( fixed, filename );
vfsFixDOSName( fixed );
- g_strdown( fixed );
+ lower = g_ascii_strdown( fixed, -1 );
for ( i = 0; i < g_numDirs; i++ )
{
{
VFS_PAKFILE* file = (VFS_PAKFILE*)lst->data;
- if ( strcmp( file->name, fixed ) != 0 ) {
+ if ( strcmp( file->name, lower ) != 0 ) {
continue;
}
strcat( g_strLoadedFileLocation, " :: " );
strcat( g_strLoadedFileLocation, filename );
- memcpy( file->zipfile, &file->zipinfo, sizeof( unz_s ) );
+ if ( unzGoToFilePos( file->zipfile, &file->zippos ) != UNZ_OK ) {
+ return -1;
+ }
if ( unzOpenCurrentFile( file->zipfile ) != UNZ_OK ) {
return -1;
}
return -1;
}
else{
+ g_free( lower );
return file->size;
}
}
count++;
}
-
+ g_free( lower );
return -1;
}
-
-
qboolean vfsPackFile( const char *filename, const char *packname, const int compLevel ){
+#ifndef GARUX_DISABLE_BAD_MINIZ
int i;
char tmp[NAME_MAX], fixed[NAME_MAX];
GSList *lst;
}
return qfalse;
+#else
+ Error( "Disabled because of miniz issue" );
+#endif
}
qboolean vfsPackFile_Absolute_Path( const char *filepath, const char *filename, const char *packname, const int compLevel ){
+#ifndef GARUX_DISABLE_BAD_MINIZ
char tmp[NAME_MAX];
strcpy( tmp, filepath );
if ( access( tmp, R_OK ) == 0 ) {
}
return qfalse;
+#else
+ Error( "Disabled because of miniz issue" );
+#endif
}
#ifndef _VFS_H_
#define _VFS_H_
+#include "globaldefs.h"
+
// to get PATH_MAX
#include <stdio.h>
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#include <dirent.h>
#include <unistd.h>
#else
#define S_ISDIR( mode ) ( mode & _S_IFDIR )
#define PATH_MAX 260
#endif
-#include <glib.h>
#define VFS_MAXDIRS 64
+++ /dev/null
-*.dsp -m 'COPY' -k 'b'
-*.dsw -m 'COPY' -k 'b'
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
return bytesRead;
}
-static int ReadChunkAndLength( FILE *fp, short *chunk, long *len ){
+static int ReadChunkAndLength( FILE *fp, unsigned short *chunk, long *len ){
if ( fread( chunk, sizeof( short ), 1, fp ) != 1 ) {
return 0;
}
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
int pix;
int bestcolor;
byte *pal;
- int fullbright;
vis = 0;
r = g = b = 0;
- fullbright = 0;
for ( i = 0 ; i < count ; i++ )
{
pix = pixdata[i];
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "globaldefs.h"
#include <assert.h>
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <io.h>
#endif
#include "md3lib.h"
-#if defined ( __linux__ ) || defined ( __APPLE__ )
-#define filelength Q_filelength
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
+#define filelength(f) Q_filelength(f)
+#else
+#define filelength(f) filelength(fileno(f))
#endif
/*
** MD3_ComputeTagFromTri
*/
-void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] ){
+void MD3_ComputeTagFromTri( md3Tag_t *pTag, float pTri[3][3] ){
float len[3];
vec3_t axes[3], sides[3];
int longestSide, shortestSide, hypotSide;
Error( "Unable to open '%s'\n", filename );
}
- fileSize = filelength( fileno( fp ) );
- _buffer = malloc( filelength( fileno( fp ) ) );
+ fileSize = filelength( fp );
+ _buffer = malloc( fileSize );
fread( _buffer, fileSize, 1, fp );
fclose( fp );
printf( " num tags: %d\n", header.numTags );
printf( " num surfaces: %d\n", header.numSurfaces );
printf( " num skins: %d\n", header.numSkins );
- printf( " file size: %d\n", fileSize );
+ printf( " file size: %ld\n", fileSize );
printf( "--- TAGS ---\n" );
pTag = ( md3Tag_t * ) ( ( ( char * ) buffer ) + header.ofsTags );
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
#include "../common/qfiles.h"
void MD3_Dump( const char *filename );
-void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float tri[3][3] );
+void MD3_ComputeTagFromTri( md3Tag_t *pTag, float tri[3][3] );
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// float s_scale, t_scale;
// float scale;
// vec3_t mins, maxs;
- float *pbasevert;
/*
//
for ( j = 0 ; j < 3 ; j++ )
{
- pbasevert = ptri->verts[j];
-
VectorCopy( ptri->verts[j], bTri->v[j].xyz );
VectorCopy( ptri->normals[j], bTri->v[j].normal );
}
}
- if ( !tagWeapon ) {
- Error( "Missing tag_weapon!" );
+ if ( !tagHead ) {
+ // todo: was never being checked; should we error now that it is?
+ // Error( "Missing tag_head!" );
}
if ( !tagTorso ) {
Error( "Missing tag_torso!" );
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
*/
#include "p3dlib.h"
+#include "globaldefs.h"
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <io.h>
#endif
#include <stdlib.h>
#define MAX_POLYSETS 64
-#if defined ( __linux__ ) || defined ( __APPLE__ )
-#define _strcmpi Q_stricmp
-#define filelength Q_filelength
-#define strlwr strlower
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
+ #include "cmdlib.h"
+ #define _strcmpi Q_stricmp
+ #define strlwr strlower
+ #define filelength(f) Q_filelength(f)
+#else
+ #define filelength(f) filelength(fileno(f))
#endif
typedef struct
{
memset( &p3d, 0, sizeof( p3d ) );
- p3d.len = filelength( fileno( fp ) );
+ p3d.len = filelength( fp );
p3d.curpos = p3d.buffer = malloc( p3d.len );
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
}
else{
Error( "TRI files no longer supported" );
+ return NULL;
}
// TRI_LoadPolysets( file, &psets, numpolysets );
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifdef WIN32
+#include "globaldefs.h"
+#if GDEF_OS_WINDOWS
#include <io.h>
#endif
#include "q3data.h"
// some old defined that was in cmdlib lost during merge
char writedir[1024];
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#define strlwr strlower
#endif
===============
*/
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
#include "io.h"
void PackDirectory_r( char *dir ){
struct _finddata_t fileinfo;
#else
#include <sys/types.h>
-#ifndef WIN32
+#if !GDEF_OS_WINDOWS
#include <sys/dir.h>
#else
#include <sys/dirent.h>
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
/*
- Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
This file is part of GtkRadiant.
// Sys_Error ("FindNextChunk: %i length is past the 1 meg sanity limit", iff_chunk_len);
data_p -= 8;
last_chunk = data_p + 8 + ( ( iff_chunk_len + 1 ) & ~1 );
- if ( !strncmp( data_p, name, 4 ) ) {
+ if ( !strncmp((const char *) data_p, name, 4 ) ) {
return;
}
}
memcpy( str, data_p, 4 );
data_p += 4;
iff_chunk_len = GetLittleLong();
- printf( "0x%x : %s (%d)\n", (int)( data_p - 4 ), str, iff_chunk_len );
+ printf( "%p : %s (%d)\n", (void *) ( data_p - 4 ), str, iff_chunk_len );
data_p += ( iff_chunk_len + 1 ) & ~1;
} while ( data_p < iff_end );
}
// find "RIFF" chunk
FindChunk( "RIFF" );
- if ( !( data_p && !strncmp( data_p + 8, "WAVE", 4 ) ) ) {
+ if ( !( data_p && !strncmp((const char *) (data_p + 8), "WAVE", 4 ) ) ) {
printf( "Missing RIFF/WAVE chunks\n" );
return info;
}
// if the next chunk is a LIST chunk, look for a cue length marker
FindNextChunk( "LIST" );
if ( data_p ) {
- if ( !strncmp( data_p + 28, "mark", 4 ) ) { // this is not a proper parse, but it works with cooledit...
+ if ( !strncmp((const char *) (data_p + 28), "mark", 4 ) ) { // this is not a proper parse, but it works with cooledit...
data_p += 24;
i = GetLittleLong(); // samples in loop
info.samples = info.loopstart + i;
int i;
int btcQuantizedBlock[4][4]; // values should be [0..3]
unsigned long encodedEndPoints, encodedBitmap;
- unsigned int endPoints[2][2]; // endPoints[0] = color start, endPoints[1] = color end
+ unsigned long endPoints[2][2]; // endPoints[0] = color start, endPoints[1] = color end
int blockY, blockX;
float error = 0;
float bestError = 10000000000;
- unsigned int bestEndPoints[2][2];
+ unsigned long bestEndPoints[2][2];
#if 0
//
printf( "\n" );
- printf( "Total size: %i\n", ftell( output ) );
+ printf( "Total size: %ld\n", ftell( output ) );
printf( "Average error: %f\n", sumError / ( frame - startframe ) );
printf( "Max error: %f\n", maxError );
brush_t *bb;
size_t c;
-
/* allocate and clear */
/*if ( numSides <= 0 ) {
Error( "AllocBrush called with numsides = %d", numSides );
{
/* round to integer */
ai = Q_rint( a[ i ] );
- bi = Q_rint( a[ i ] );
+ bi = Q_rint( b[ i ] );
/* prefer exact integer */
if ( ai == a[ i ] ) {
}
/* use nearest */
- else if ( fabs( ai - a[ i ] ) < fabs( bi < b[ i ] ) ) {
+ else if ( fabs( ai - a[ i ] ) < fabs( bi - b[ i ] ) ) {
out[ i ] = a[ i ];
}
else{
}
}
+
+
/*
==================
SnapWeldVectorAccu
}
}
+
+
/*
FixWinding() - ydnar
removes degenerate edges from a winding
if ( !w ) {
continue;
}
+ /* strict, in parallel case we get the face back because it also is the midwinding */
ClipWindingEpsilonStrict( w, plane->normal, plane->dist,
- 0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1] ); /* strict, in parallel case we get the face back because it also is the midwinding */
+ 0 /*PLANESIDE_EPSILON*/, &cw[0], &cw[1] );
for ( j = 0 ; j < 2 ; j++ )
{
if ( !cw[j] ) {
/* get the model num */
value3 = ValueForKey( &entities[ j ], "model" );
if ( value3[ 0 ] == '\0' ) {
- Sys_Printf( "WARNING: Cloned entity %s referenced entity without model\n", value2 );
+ Sys_FPrintf( SYS_WRN, "WARNING: Cloned entity %s referenced entity without model\n", value2 );
continue;
}
- models = atoi( &value3[ 1 ] );
+ models = atoi( &value2[ 1 ] );
/* add the model key */
sprintf( modelValue, "*%d", models );
creates a full bsp + surfaces for the worldspawn entity
*/
-void ProcessWorldModel( void ){
+void ProcessWorldModel( const char *portalFilePath, const char *lineFilePath ){
int i, s;
entity_t *e;
tree_t *tree;
Sys_FPrintf( SYS_NOXML, "**********************\n" );
Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" );
Sys_FPrintf( SYS_NOXML, "**********************\n" );
- polyline = LeakFile( tree );
+ polyline = LeakFile( tree, lineFilePath );
leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
xmlNodeAddContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
xmlAddChild( leaknode, polyline );
/* save out information for visibility processing */
NumberClusters( tree );
if ( !leaked ) {
- WritePortalFile( tree );
+ WritePortalFile( tree, portalFilePath );
}
/* flood from entities */
process world + other models into the bsp
*/
-void ProcessModels( void ){
+void ProcessModels( const char *portalFilePath, const char *lineFilePath ){
qboolean oldVerbose;
entity_t *entity;
/* process the model */
Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
if ( mapEntityNum == 0 ) {
- ProcessWorldModel();
+ ProcessWorldModel(portalFilePath, lineFilePath);
}
else{
ProcessSubModel();
this is probably broken unless teamed with a radiant version that preserves entity order
*/
-void OnlyEnts( void ){
- char out[ 1024 ];
-
+void OnlyEnts( const char *BSPFilePath ){
char save_cmdline[1024], save_version[1024], save_gridsize[1024];
const char *p;
/* note it */
Sys_Printf( "--- OnlyEnts ---\n" );
- sprintf( out, "%s.bsp", source );
- LoadBSPFile( out );
+ LoadBSPFile( BSPFilePath );
ParseEntities();
p = ValueForKey( &entities[0], "_q3map2_cmdline" );
numBSPEntities = numEntities;
UnparseEntities();
- WriteBSPFile( out );
+ WriteBSPFile( BSPFilePath );
}
int i;
char path[ 1024 ], tempSource[ 1024 ];
qboolean onlyents = qfalse;
+ char BSPFilePath [ 1024 ];
+ char lineFilePath [ 1024 ];
+ char portalFilePath [ 1024 ];
+ char surfaceFilePath [ 1024 ];
+ BSPFilePath[0] = 0;
+ lineFilePath[0] = 0;
+ portalFilePath[0] = 0;
+ surfaceFilePath[0] = 0;
/* note it */
Sys_Printf( "Max Area face surface generation enabled\n" );
maxAreaFaceSurface = qtrue;
}
+ else if ( !strcmp( argv[ i ], "-bspfile" ) )
+ {
+ strcpy( BSPFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as bsp file\n", BSPFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-linfile" ) )
+ {
+ strcpy( lineFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as line file\n", lineFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-prtfile" ) )
+ {
+ strcpy( portalFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as portal file\n", portalFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-srffile" ) )
+ {
+ strcpy( surfaceFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as surface file\n", surfaceFilePath );
+ }
else if ( !strcmp( argv[ i ], "-bsp" ) ) {
Sys_Printf( "-bsp argument unnecessary\n" );
}
/* ydnar: set default sample size */
SetDefaultSampleSize( sampleSize );
+ if (!BSPFilePath[0]) {
+ sprintf( BSPFilePath, "%s.bsp", source );
+ }
+ if (!lineFilePath[0]) {
+ sprintf( lineFilePath, "%s.lin", source );
+ }
+ if (!portalFilePath[0]) {
+ sprintf( portalFilePath, "%s.prt", source );
+ }
+ if (!surfaceFilePath[0]) {
+ sprintf( surfaceFilePath, "%s.srf", source );
+ }
+
/* delete portal, line and surface files */
- sprintf( path, "%s.prt", source );
- remove( path );
- sprintf( path, "%s.lin", source );
- remove( path );
- //% sprintf( path, "%s.srf", source ); /* ydnar */
- //% remove( path );
+ remove( portalFilePath );
+ remove( lineFilePath );
+ //% remove( surfaceFilePath ) /* ydnar */
/* expand mapname */
strcpy( name, ExpandArg( argv[ i ] ) );
/* if onlyents, just grab the entites and resave */
if ( onlyents ) {
- OnlyEnts();
+ OnlyEnts( BSPFilePath );
return 0;
}
SetCloneModelNumbers();
/* process world and submodels */
- ProcessModels();
+ ProcessModels( portalFilePath, lineFilePath );
/* set light styles from targetted light entities */
SetLightStyles();
ProcessAdvertisements();
/* finish and write bsp */
- EndBSPFile( qtrue );
+ EndBSPFile( qtrue, BSPFilePath, surfaceFilePath );
/* remove temp map source file if appropriate */
if ( strlen( tempSource ) > 0 ) {
--- /dev/null
+/* -------------------------------------------------------------------------------
+
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ -------------------------------------------------------------------------------
+
+ This code has been altered significantly from its original form, to support
+ several games based on the Quake III Arena engine, in the form of "Q3Map2."
+
+ ------------------------------------------------------------------------------- */
+
+
+
+/* dependencies */
+#include "q3map2.h"
+
+
+
+/*
+ AnalyzeBSPMain() - ydnar
+ analyzes a Quake engine BSP file
+ */
+
+typedef struct abspHeader_s
+{
+ char ident[ 4 ];
+ int version;
+
+ bspLump_t lumps[ 1 ]; /* unknown size */
+}
+abspHeader_t;
+
+typedef struct abspLumpTest_s
+{
+ int radix, minCount;
+ char *name;
+}
+abspLumpTest_t;
+
+int AnalyzeBSPMain( int argc, char **argv ){
+ abspHeader_t *header;
+ int size, i, version, offset, length, lumpInt, count;
+ char ident[ 5 ];
+ void *lump;
+ float lumpFloat;
+ char lumpString[ 1024 ], source[ 1024 ];
+ qboolean lumpSwap = qfalse;
+ abspLumpTest_t *lumpTest;
+ static abspLumpTest_t lumpTests[] =
+ {
+ { sizeof( bspPlane_t ), 6, "IBSP LUMP_PLANES" },
+ { sizeof( bspBrush_t ), 1, "IBSP LUMP_BRUSHES" },
+ { 8, 6, "IBSP LUMP_BRUSHSIDES" },
+ { sizeof( bspBrushSide_t ), 6, "RBSP LUMP_BRUSHSIDES" },
+ { sizeof( bspModel_t ), 1, "IBSP LUMP_MODELS" },
+ { sizeof( bspNode_t ), 2, "IBSP LUMP_NODES" },
+ { sizeof( bspLeaf_t ), 1, "IBSP LUMP_LEAFS" },
+ { 104, 3, "IBSP LUMP_DRAWSURFS" },
+ { 44, 3, "IBSP LUMP_DRAWVERTS" },
+ { 4, 6, "IBSP LUMP_DRAWINDEXES" },
+ { 128 * 128 * 3, 1, "IBSP LUMP_LIGHTMAPS" },
+ { 256 * 256 * 3, 1, "IBSP LUMP_LIGHTMAPS (256 x 256)" },
+ { 512 * 512 * 3, 1, "IBSP LUMP_LIGHTMAPS (512 x 512)" },
+ { 0, 0, NULL }
+ };
+
+
+ /* arg checking */
+ if ( argc < 1 ) {
+ Sys_Printf( "Usage: q3map -analyze [-lumpswap] [-v] <mapname>\n" );
+ return 0;
+ }
+
+ /* process arguments */
+ for ( i = 1; i < ( argc - 1 ); i++ )
+ {
+ /* -format map|ase|... */
+ if ( !strcmp( argv[ i ], "-lumpswap" ) ) {
+ Sys_Printf( "Swapped lump structs enabled\n" );
+ lumpSwap = qtrue;
+ }
+ }
+
+ /* clean up map name */
+ strcpy( source, ExpandArg( argv[ i ] ) );
+ Sys_Printf( "Loading %s\n", source );
+
+ /* load the file */
+ size = LoadFile( source, (void**) &header );
+ if ( size == 0 || header == NULL ) {
+ Sys_Printf( "Unable to load %s.\n", source );
+ return -1;
+ }
+
+ /* analyze ident/version */
+ memcpy( ident, header->ident, 4 );
+ ident[ 4 ] = '\0';
+ version = LittleLong( header->version );
+
+ Sys_Printf( "Identity: %s\n", ident );
+ Sys_Printf( "Version: %d\n", version );
+ Sys_Printf( "---------------------------------------\n" );
+
+ /* analyze each lump */
+ for ( i = 0; i < 100; i++ )
+ {
+ /* call of duty swapped lump pairs */
+ if ( lumpSwap ) {
+ offset = LittleLong( header->lumps[ i ].length );
+ length = LittleLong( header->lumps[ i ].offset );
+ }
+
+ /* standard lump pairs */
+ else
+ {
+ offset = LittleLong( header->lumps[ i ].offset );
+ length = LittleLong( header->lumps[ i ].length );
+ }
+
+ /* extract data */
+ lump = (byte*) header + offset;
+ lumpInt = LittleLong( (int) *( (int*) lump ) );
+ lumpFloat = LittleFloat( (float) *( (float*) lump ) );
+ memcpy( lumpString, (char*) lump, ( (size_t)length < sizeof( lumpString ) ? (size_t)length : sizeof( lumpString ) - 1 ) );
+ lumpString[ sizeof( lumpString ) - 1 ] = '\0';
+
+ /* print basic lump info */
+ Sys_Printf( "Lump: %d\n", i );
+ Sys_Printf( "Offset: %d bytes\n", offset );
+ Sys_Printf( "Length: %d bytes\n", length );
+
+ /* only operate on valid lumps */
+ if ( length > 0 ) {
+ /* print data in 4 formats */
+ Sys_Printf( "As hex: %08X\n", lumpInt );
+ Sys_Printf( "As int: %d\n", lumpInt );
+ Sys_Printf( "As float: %f\n", lumpFloat );
+ Sys_Printf( "As string: %s\n", lumpString );
+
+ /* guess lump type */
+ if ( lumpString[ 0 ] == '{' && lumpString[ 2 ] == '"' ) {
+ Sys_Printf( "Type guess: IBSP LUMP_ENTITIES\n" );
+ }
+ else if ( strstr( lumpString, "textures/" ) ) {
+ Sys_Printf( "Type guess: IBSP LUMP_SHADERS\n" );
+ }
+ else
+ {
+ /* guess based on size/count */
+ for ( lumpTest = lumpTests; lumpTest->radix > 0; lumpTest++ )
+ {
+ if ( ( length % lumpTest->radix ) != 0 ) {
+ continue;
+ }
+ count = length / lumpTest->radix;
+ if ( count < lumpTest->minCount ) {
+ continue;
+ }
+ Sys_Printf( "Type guess: %s (%d x %d)\n", lumpTest->name, count, lumpTest->radix );
+ }
+ }
+ }
+
+ Sys_Printf( "---------------------------------------\n" );
+
+ /* end of file */
+ if ( offset + length >= size ) {
+ break;
+ }
+ }
+
+ /* last stats */
+ Sys_Printf( "Lump count: %d\n", i + 1 );
+ Sys_Printf( "File size: %d bytes\n", size );
+
+ /* return to caller */
+ return 0;
+}
--- /dev/null
+/* -------------------------------------------------------------------------------
+
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ -------------------------------------------------------------------------------
+
+ This code has been altered significantly from its original form, to support
+ several games based on the Quake III Arena engine, in the form of "Q3Map2."
+
+ ------------------------------------------------------------------------------- */
+
+
+
+/* dependencies */
+#include "q3map2.h"
+
+
+
+/*
+ BSPInfoMain()
+ emits statistics about the bsp file
+ */
+
+int BSPInfoMain( int count, char **fileNames ){
+ int i;
+ char source[ 1024 ], ext[ 64 ];
+ int size;
+ FILE *f;
+
+
+ /* dummy check */
+ if ( count < 1 ) {
+ Sys_Printf( "No files to dump info for.\n" );
+ return -1;
+ }
+
+ /* enable info mode */
+ infoMode = qtrue;
+
+ /* walk file list */
+ for ( i = 0; i < count; i++ )
+ {
+ Sys_Printf( "---------------------------------\n" );
+
+ /* mangle filename and get size */
+ strcpy( source, fileNames[ i ] );
+ ExtractFileExtension( source, ext );
+ if ( !Q_stricmp( ext, "map" ) ) {
+ StripExtension( source );
+ }
+ DefaultExtension( source, ".bsp" );
+ f = fopen( source, "rb" );
+ if ( f ) {
+ size = Q_filelength( f );
+ fclose( f );
+ }
+ else{
+ size = 0;
+ }
+
+ /* load the bsp file and print lump sizes */
+ Sys_Printf( "%s\n", source );
+ LoadBSPFile( source );
+ PrintBSPFileSizes();
+
+ /* print sizes */
+ Sys_Printf( "\n" );
+ Sys_Printf( " total %9d\n", size );
+ Sys_Printf( " %9d KB\n", size / 1024 );
+ Sys_Printf( " %9d MB\n", size / ( 1024 * 1024 ) );
+
+ Sys_Printf( "---------------------------------\n" );
+ }
+
+ /* return count */
+ return i;
+}
--- /dev/null
+/* -------------------------------------------------------------------------------
+
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ -------------------------------------------------------------------------------
+
+ This code has been altered significantly from its original form, to support
+ several games based on the Quake III Arena engine, in the form of "Q3Map2."
+
+ ------------------------------------------------------------------------------- */
+
+
+
+/* dependencies */
+#include "q3map2.h"
+
+
+
+static void ExtrapolateTexcoords( const float *axyz, const float *ast, const float *bxyz, const float *bst, const float *cxyz, const float *cst, const float *axyz_new, float *ast_out, const float *bxyz_new, float *bst_out, const float *cxyz_new, float *cst_out ){
+ vec4_t scoeffs, tcoeffs;
+ float md;
+ m4x4_t solvematrix;
+
+ vec3_t norm;
+ vec3_t dab, dac;
+ VectorSubtract( bxyz, axyz, dab );
+ VectorSubtract( cxyz, axyz, dac );
+ CrossProduct( dab, dac, norm );
+
+ // assume:
+ // s = f(x, y, z)
+ // s(v + norm) = s(v) when n ortho xyz
+
+ // s(v) = DotProduct(v, scoeffs) + scoeffs[3]
+
+ // solve:
+ // scoeffs * (axyz, 1) == ast[0]
+ // scoeffs * (bxyz, 1) == bst[0]
+ // scoeffs * (cxyz, 1) == cst[0]
+ // scoeffs * (norm, 0) == 0
+ // scoeffs * [axyz, 1 | bxyz, 1 | cxyz, 1 | norm, 0] = [ast[0], bst[0], cst[0], 0]
+ solvematrix[0] = axyz[0];
+ solvematrix[4] = axyz[1];
+ solvematrix[8] = axyz[2];
+ solvematrix[12] = 1;
+ solvematrix[1] = bxyz[0];
+ solvematrix[5] = bxyz[1];
+ solvematrix[9] = bxyz[2];
+ solvematrix[13] = 1;
+ solvematrix[2] = cxyz[0];
+ solvematrix[6] = cxyz[1];
+ solvematrix[10] = cxyz[2];
+ solvematrix[14] = 1;
+ solvematrix[3] = norm[0];
+ solvematrix[7] = norm[1];
+ solvematrix[11] = norm[2];
+ solvematrix[15] = 0;
+
+ md = m4_det( solvematrix );
+ if ( md * md < 1e-10 ) {
+ Sys_Printf( "Cannot invert some matrix, some texcoords aren't extrapolated!" );
+ return;
+ }
+
+ m4x4_invert( solvematrix );
+
+ scoeffs[0] = ast[0];
+ scoeffs[1] = bst[0];
+ scoeffs[2] = cst[0];
+ scoeffs[3] = 0;
+ m4x4_transform_vec4( solvematrix, scoeffs );
+ tcoeffs[0] = ast[1];
+ tcoeffs[1] = bst[1];
+ tcoeffs[2] = cst[1];
+ tcoeffs[3] = 0;
+ m4x4_transform_vec4( solvematrix, tcoeffs );
+
+ ast_out[0] = scoeffs[0] * axyz_new[0] + scoeffs[1] * axyz_new[1] + scoeffs[2] * axyz_new[2] + scoeffs[3];
+ ast_out[1] = tcoeffs[0] * axyz_new[0] + tcoeffs[1] * axyz_new[1] + tcoeffs[2] * axyz_new[2] + tcoeffs[3];
+ bst_out[0] = scoeffs[0] * bxyz_new[0] + scoeffs[1] * bxyz_new[1] + scoeffs[2] * bxyz_new[2] + scoeffs[3];
+ bst_out[1] = tcoeffs[0] * bxyz_new[0] + tcoeffs[1] * bxyz_new[1] + tcoeffs[2] * bxyz_new[2] + tcoeffs[3];
+ cst_out[0] = scoeffs[0] * cxyz_new[0] + scoeffs[1] * cxyz_new[1] + scoeffs[2] * cxyz_new[2] + scoeffs[3];
+ cst_out[1] = tcoeffs[0] * cxyz_new[0] + tcoeffs[1] * cxyz_new[1] + tcoeffs[2] * cxyz_new[2] + tcoeffs[3];
+}
+
+/*
+ ScaleBSPMain()
+ amaze and confuse your enemies with wierd scaled maps!
+ */
+
+int ScaleBSPMain( int argc, char **argv ){
+ int i, j;
+ float f, a;
+ vec3_t scale;
+ vec3_t vec;
+ char str[ 1024 ];
+ int uniform, axis;
+ qboolean texscale;
+ float *old_xyzst = NULL;
+ float spawn_ref = 0;
+
+
+ /* arg checking */
+ if ( argc < 3 ) {
+ Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
+ return 0;
+ }
+
+ texscale = qfalse;
+ for ( i = 1; i < argc - 2; ++i )
+ {
+ if ( !strcmp( argv[i], "-tex" ) ) {
+ texscale = qtrue;
+ }
+ else if ( !strcmp( argv[i], "-spawn_ref" ) ) {
+ spawn_ref = atof( argv[i + 1] );
+ ++i;
+ }
+ else{
+ break;
+ }
+ }
+
+ /* get scale */
+ // if(argc-2 >= i) // always true
+ scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
+ if ( argc - 3 >= i ) {
+ scale[1] = scale[0] = atof( argv[ argc - 3 ] );
+ }
+ if ( argc - 4 >= i ) {
+ scale[0] = atof( argv[ argc - 4 ] );
+ }
+
+ uniform = ( ( scale[0] == scale[1] ) && ( scale[1] == scale[2] ) );
+
+ if ( scale[0] == 0.0f || scale[1] == 0.0f || scale[2] == 0.0f ) {
+ Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
+ Sys_Printf( "Non-zero scale value required.\n" );
+ return 0;
+ }
+
+ /* do some path mangling */
+ strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
+ StripExtension( source );
+ DefaultExtension( source, ".bsp" );
+
+ /* load the bsp */
+ Sys_Printf( "Loading %s\n", source );
+ LoadBSPFile( source );
+ ParseEntities();
+
+ /* note it */
+ Sys_Printf( "--- ScaleBSP ---\n" );
+ Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities );
+
+ /* scale entity keys */
+ for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
+ {
+ /* scale origin */
+ GetVectorForKey( &entities[ i ], "origin", vec );
+ if ( ( vec[ 0 ] || vec[ 1 ] || vec[ 2 ] ) ) {
+ if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
+ vec[2] += spawn_ref;
+ }
+ vec[0] *= scale[0];
+ vec[1] *= scale[1];
+ vec[2] *= scale[2];
+ if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
+ vec[2] -= spawn_ref;
+ }
+ sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
+ SetKeyValue( &entities[ i ], "origin", str );
+ }
+
+ a = FloatForKey( &entities[ i ], "angle" );
+ if ( a == -1 || a == -2 ) { // z scale
+ axis = 2;
+ }
+ else if ( fabs( sin( DEG2RAD( a ) ) ) < 0.707 ) {
+ axis = 0;
+ }
+ else{
+ axis = 1;
+ }
+
+ /* scale door lip */
+ f = FloatForKey( &entities[ i ], "lip" );
+ if ( f ) {
+ f *= scale[axis];
+ sprintf( str, "%f", f );
+ SetKeyValue( &entities[ i ], "lip", str );
+ }
+
+ /* scale plat height */
+ f = FloatForKey( &entities[ i ], "height" );
+ if ( f ) {
+ f *= scale[2];
+ sprintf( str, "%f", f );
+ SetKeyValue( &entities[ i ], "height", str );
+ }
+
+ // TODO maybe allow a definition file for entities to specify which values are scaled how?
+ }
+
+ /* scale models */
+ for ( i = 0; i < numBSPModels; i++ )
+ {
+ bspModels[ i ].mins[0] *= scale[0];
+ bspModels[ i ].mins[1] *= scale[1];
+ bspModels[ i ].mins[2] *= scale[2];
+ bspModels[ i ].maxs[0] *= scale[0];
+ bspModels[ i ].maxs[1] *= scale[1];
+ bspModels[ i ].maxs[2] *= scale[2];
+ }
+
+ /* scale nodes */
+ for ( i = 0; i < numBSPNodes; i++ )
+ {
+ bspNodes[ i ].mins[0] *= scale[0];
+ bspNodes[ i ].mins[1] *= scale[1];
+ bspNodes[ i ].mins[2] *= scale[2];
+ bspNodes[ i ].maxs[0] *= scale[0];
+ bspNodes[ i ].maxs[1] *= scale[1];
+ bspNodes[ i ].maxs[2] *= scale[2];
+ }
+
+ /* scale leafs */
+ for ( i = 0; i < numBSPLeafs; i++ )
+ {
+ bspLeafs[ i ].mins[0] *= scale[0];
+ bspLeafs[ i ].mins[1] *= scale[1];
+ bspLeafs[ i ].mins[2] *= scale[2];
+ bspLeafs[ i ].maxs[0] *= scale[0];
+ bspLeafs[ i ].maxs[1] *= scale[1];
+ bspLeafs[ i ].maxs[2] *= scale[2];
+ }
+
+ if ( texscale ) {
+ Sys_Printf( "Using texture unlocking (and probably breaking texture alignment a lot)\n" );
+ old_xyzst = safe_malloc( sizeof( *old_xyzst ) * numBSPDrawVerts * 5 );
+ for ( i = 0; i < numBSPDrawVerts; i++ )
+ {
+ old_xyzst[5 * i + 0] = bspDrawVerts[i].xyz[0];
+ old_xyzst[5 * i + 1] = bspDrawVerts[i].xyz[1];
+ old_xyzst[5 * i + 2] = bspDrawVerts[i].xyz[2];
+ old_xyzst[5 * i + 3] = bspDrawVerts[i].st[0];
+ old_xyzst[5 * i + 4] = bspDrawVerts[i].st[1];
+ }
+ }
+
+ /* scale drawverts */
+ for ( i = 0; i < numBSPDrawVerts; i++ )
+ {
+ bspDrawVerts[i].xyz[0] *= scale[0];
+ bspDrawVerts[i].xyz[1] *= scale[1];
+ bspDrawVerts[i].xyz[2] *= scale[2];
+ bspDrawVerts[i].normal[0] /= scale[0];
+ bspDrawVerts[i].normal[1] /= scale[1];
+ bspDrawVerts[i].normal[2] /= scale[2];
+ VectorNormalize( bspDrawVerts[i].normal, bspDrawVerts[i].normal );
+ }
+
+ if ( texscale ) {
+ for ( i = 0; i < numBSPDrawSurfaces; i++ )
+ {
+ switch ( bspDrawSurfaces[i].surfaceType )
+ {
+ case SURFACE_FACE:
+ case SURFACE_META:
+ if ( bspDrawSurfaces[i].numIndexes % 3 ) {
+ Error( "Not a triangulation!" );
+ }
+ for ( j = bspDrawSurfaces[i].firstIndex; j < bspDrawSurfaces[i].firstIndex + bspDrawSurfaces[i].numIndexes; j += 3 )
+ {
+ int ia = bspDrawIndexes[j] + bspDrawSurfaces[i].firstVert, ib = bspDrawIndexes[j + 1] + bspDrawSurfaces[i].firstVert, ic = bspDrawIndexes[j + 2] + bspDrawSurfaces[i].firstVert;
+ bspDrawVert_t *a = &bspDrawVerts[ia], *b = &bspDrawVerts[ib], *c = &bspDrawVerts[ic];
+ float *oa = &old_xyzst[ia * 5], *ob = &old_xyzst[ib * 5], *oc = &old_xyzst[ic * 5];
+ // extrapolate:
+ // a->xyz -> oa
+ // b->xyz -> ob
+ // c->xyz -> oc
+ ExtrapolateTexcoords(
+ &oa[0], &oa[3],
+ &ob[0], &ob[3],
+ &oc[0], &oc[3],
+ a->xyz, a->st,
+ b->xyz, b->st,
+ c->xyz, c->st );
+ }
+ break;
+ }
+ }
+ }
+
+ /* scale planes */
+ if ( uniform ) {
+ for ( i = 0; i < numBSPPlanes; i++ )
+ {
+ bspPlanes[ i ].dist *= scale[0];
+ }
+ }
+ else
+ {
+ for ( i = 0; i < numBSPPlanes; i++ )
+ {
+ bspPlanes[ i ].normal[0] /= scale[0];
+ bspPlanes[ i ].normal[1] /= scale[1];
+ bspPlanes[ i ].normal[2] /= scale[2];
+ f = 1 / VectorLength( bspPlanes[i].normal );
+ VectorScale( bspPlanes[i].normal, f, bspPlanes[i].normal );
+ bspPlanes[ i ].dist *= f;
+ }
+ }
+
+ /* scale gridsize */
+ GetVectorForKey( &entities[ 0 ], "gridsize", vec );
+ if ( ( vec[ 0 ] + vec[ 1 ] + vec[ 2 ] ) == 0.0f ) {
+ VectorCopy( gridSize, vec );
+ }
+ vec[0] *= scale[0];
+ vec[1] *= scale[1];
+ vec[2] *= scale[2];
+ sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
+ SetKeyValue( &entities[ 0 ], "gridsize", str );
+
+ /* inject command line parameters */
+ InjectCommandLine( argv, 0, argc - 1 );
+
+ /* write the bsp */
+ UnparseEntities();
+ StripExtension( source );
+ DefaultExtension( source, "_s.bsp" );
+ Sys_Printf( "Writing %s\n", source );
+ WriteBSPFile( source );
+
+ /* return to sender */
+ return 0;
+}
bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
- memset( bspDrawSurfaces, 0, MAX_MAP_DRAW_SURFS * sizeof( bspDrawVert_t ) );
+ memset( bspDrawSurfaces, 0, MAX_MAP_DRAW_SURFS * sizeof( bspDrawSurface_t ) );
}
void SetDrawSurfaces( int n ){
bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
- memset( bspDrawSurfaces, 0, n * sizeof( bspDrawVert_t ) );
+ memset( bspDrawSurfaces, 0, n * sizeof( bspDrawSurface_t ) );
}
void BSPFilesCleanup(){
/* check for odd size */
if ( header->lumps[ lump ].length % size ) {
if ( force ) {
- Sys_Printf( "WARNING: GetLumpElements: odd lump size (%d) in lump %d\n", header->lumps[ lump ].length, lump );
+ Sys_FPrintf( SYS_WRN, "WARNING: GetLumpElements: odd lump size (%d) in lump %d\n", header->lumps[ lump ].length, lump );
return 0;
}
else{
}
if ( length % size ) {
if ( force ) {
- Sys_Printf( "WARNING: CopyLump: odd lump size (%d) in lump %d\n", length, lump );
+ Sys_FPrintf( SYS_WRN, "WARNING: CopyLump: odd lump size (%d) in lump %d\n", length, lump );
return 0;
}
else{
numBSPEntities = numEntities;
}
+
+
/*
* must be called before UnparseEntities
*/
SetKeyValue( &entities[0], "_q3map2_version", Q3MAP_VERSION );
}
+
+
/*
UnparseEntities()
generates the dentdata string from all the entities.
ep->value = copystring( value );
}
+
+
/*
KeyExists()
returns true if entity has this key
return qfalse;
}
+
+
/*
ValueForKey()
gets the value for an entity key
gets a 3-element vector value for an entity key
*/
-void GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec ){
+qboolean GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec ){
const char *k;
double v1, v2, v3;
vec[ 0 ] = v1;
vec[ 1 ] = v2;
vec[ 2 ] = v3;
+
+ /* true if the key is found, false otherwise */
+ return strlen( k );
}
fprintf( f, "\t*MATERIAL_REF\t%d\r\n", ds->lightmapNum[0] + deluxemap );
}
else{
- Sys_Printf( "WARNING: lightmap %d out of range, not exporting\n", ds->lightmapNum[0] + deluxemap );
+ Sys_FPrintf( SYS_WRN, "WARNING: lightmap %d out of range, not exporting\n", ds->lightmapNum[0] + deluxemap );
}
}
else{
/* get shader */
si = ShaderInfoForShader( shader->shader );
if ( si == NULL ) {
- Sys_Printf( "WARNING: NULL shader in BSP\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: NULL shader in BSP\n" );
return;
}
--- /dev/null
+/* -------------------------------------------------------------------------------
+
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ -------------------------------------------------------------------------------
+
+ This code has been altered significantly from its original form, to support
+ several games based on the Quake III Arena engine, in the form of "Q3Map2."
+
+ ------------------------------------------------------------------------------- */
+
+
+
+/* dependencies */
+#include "q3map2.h"
+
+
+
+/*
+ PseudoCompileBSP()
+ a stripped down ProcessModels
+ */
+void PseudoCompileBSP( qboolean need_tree, const char *BSPFilePath, const char *surfaceFilePath ){
+ int models;
+ char modelValue[10];
+ entity_t *entity;
+ face_t *faces;
+ tree_t *tree;
+ node_t *node;
+ brush_t *brush;
+ side_t *side;
+ int i;
+
+ SetDrawSurfacesBuffer();
+ mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
+ memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
+ numMapDrawSurfs = 0;
+
+ BeginBSPFile();
+ models = 1;
+ for ( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ )
+ {
+ /* get entity */
+ entity = &entities[ mapEntityNum ];
+ if ( entity->brushes == NULL && entity->patches == NULL ) {
+ continue;
+ }
+
+ if ( mapEntityNum != 0 ) {
+ sprintf( modelValue, "*%d", models++ );
+ SetKeyValue( entity, "model", modelValue );
+ }
+
+ /* process the model */
+ Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
+ BeginModel();
+
+ entity->firstDrawSurf = numMapDrawSurfs;
+
+ ClearMetaTriangles();
+ PatchMapDrawSurfs( entity );
+
+ if ( mapEntityNum == 0 && need_tree ) {
+ faces = MakeStructuralBSPFaceList( entities[0].brushes );
+ tree = FaceBSP( faces );
+ node = tree->headnode;
+ }
+ else
+ {
+ node = AllocNode();
+ node->planenum = PLANENUM_LEAF;
+ tree = AllocTree();
+ tree->headnode = node;
+ }
+
+ /* a minimized ClipSidesIntoTree */
+ for ( brush = entity->brushes; brush; brush = brush->next )
+ {
+ /* walk the brush sides */
+ for ( i = 0; i < brush->numsides; i++ )
+ {
+ /* get side */
+ side = &brush->sides[ i ];
+ if ( side->winding == NULL ) {
+ continue;
+ }
+ /* shader? */
+ if ( side->shaderInfo == NULL ) {
+ continue;
+ }
+ /* save this winding as a visible surface */
+ DrawSurfaceForSide( entity, brush, side, side->winding );
+ }
+ }
+
+ if ( meta ) {
+ ClassifyEntitySurfaces( entity );
+ MakeEntityDecals( entity );
+ MakeEntityMetaTriangles( entity );
+ SmoothMetaTriangles();
+ MergeMetaTriangles();
+ }
+ FilterDrawsurfsIntoTree( entity, tree );
+
+ FilterStructuralBrushesIntoTree( entity, tree );
+ FilterDetailBrushesIntoTree( entity, tree );
+
+ EmitBrushes( entity->brushes, &entity->firstBrush, &entity->numBrushes );
+ EndModel( entity, node );
+ }
+ EndBSPFile( qfalse, BSPFilePath, surfaceFilePath );
+}
+
+/*
+ ConvertBSPMain()
+ main argument processing function for bsp conversion
+ */
+
+int ConvertBSPMain( int argc, char **argv ){
+ int i;
+ int ( *convertFunc )( char * );
+ game_t *convertGame;
+ char ext[1024];
+ char BSPFilePath [ 1024 ];
+ char surfaceFilePath [ 1024 ];
+ qboolean map_allowed, force_bsp, force_map;
+
+
+ /* set default */
+ convertFunc = ConvertBSPToASE;
+ convertGame = NULL;
+ map_allowed = qfalse;
+ force_bsp = qfalse;
+ force_map = qfalse;
+
+ /* arg checking */
+ if ( argc < 1 ) {
+ Sys_Printf( "Usage: q3map -convert [-format <ase|obj|map_bp|map>] [-shadersasbitmap|-lightmapsastexcoord|-deluxemapsastexcoord] [-readbsp|-readmap [-meta|-patchmeta]] [-v] <mapname>\n" );
+ return 0;
+ }
+
+ /* process arguments */
+ for ( i = 1; i < ( argc - 1 ); i++ )
+ {
+ /* -format map|ase|... */
+ if ( !strcmp( argv[ i ], "-format" ) ) {
+ i++;
+ if ( !Q_stricmp( argv[ i ], "ase" ) ) {
+ convertFunc = ConvertBSPToASE;
+ map_allowed = qfalse;
+ }
+ else if ( !Q_stricmp( argv[ i ], "obj" ) ) {
+ convertFunc = ConvertBSPToOBJ;
+ map_allowed = qfalse;
+ }
+ else if ( !Q_stricmp( argv[ i ], "map_bp" ) ) {
+ convertFunc = ConvertBSPToMap_BP;
+ map_allowed = qtrue;
+ }
+ else if ( !Q_stricmp( argv[ i ], "map" ) ) {
+ convertFunc = ConvertBSPToMap;
+ map_allowed = qtrue;
+ }
+ else
+ {
+ convertGame = GetGame( argv[ i ] );
+ map_allowed = qfalse;
+ if ( convertGame == NULL ) {
+ Sys_FPrintf( SYS_WRN, "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] );
+ }
+ }
+ }
+ else if ( !strcmp( argv[ i ], "-ne" ) ) {
+ normalEpsilon = atof( argv[ i + 1 ] );
+ i++;
+ Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon );
+ }
+ else if ( !strcmp( argv[ i ], "-de" ) ) {
+ distanceEpsilon = atof( argv[ i + 1 ] );
+ i++;
+ Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon );
+ }
+ else if ( !strcmp( argv[ i ], "-shaderasbitmap" ) || !strcmp( argv[ i ], "-shadersasbitmap" ) ) {
+ shadersAsBitmap = qtrue;
+ }
+ else if ( !strcmp( argv[ i ], "-lightmapastexcoord" ) || !strcmp( argv[ i ], "-lightmapsastexcoord" ) ) {
+ lightmapsAsTexcoord = qtrue;
+ }
+ else if ( !strcmp( argv[ i ], "-deluxemapastexcoord" ) || !strcmp( argv[ i ], "-deluxemapsastexcoord" ) ) {
+ lightmapsAsTexcoord = qtrue;
+ deluxemap = qtrue;
+ }
+ else if ( !strcmp( argv[ i ], "-readbsp" ) ) {
+ force_bsp = qtrue;
+ }
+ else if ( !strcmp( argv[ i ], "-readmap" ) ) {
+ force_map = qtrue;
+ }
+ else if ( !strcmp( argv[ i ], "-meta" ) ) {
+ meta = qtrue;
+ }
+ else if ( !strcmp( argv[ i ], "-patchmeta" ) ) {
+ meta = qtrue;
+ patchMeta = qtrue;
+ }
+ }
+
+ LoadShaderInfo();
+
+ /* clean up map name */
+ strcpy( source, ExpandArg( argv[i] ) );
+ ExtractFileExtension( source, ext );
+
+ if ( !map_allowed && !force_map ) {
+ force_bsp = qtrue;
+ }
+
+ if ( force_map || ( !force_bsp && !Q_stricmp( ext, "map" ) && map_allowed ) ) {
+ if ( !map_allowed ) {
+ Sys_FPrintf( SYS_WRN, "WARNING: the requested conversion should not be done from .map files. Compile a .bsp first.\n" );
+ }
+ StripExtension( source );
+ DefaultExtension( source, ".map" );
+ Sys_Printf( "Loading %s\n", source );
+ LoadMapFile( source, qfalse, convertGame == NULL );
+ sprintf( BSPFilePath, "%s.bsp", source );
+ sprintf( surfaceFilePath, "%s.srf", source );
+ PseudoCompileBSP( convertGame != NULL, BSPFilePath, surfaceFilePath );
+ }
+ else
+ {
+ StripExtension( source );
+ DefaultExtension( source, ".bsp" );
+ Sys_Printf( "Loading %s\n", source );
+ LoadBSPFile( source );
+ ParseEntities();
+ }
+
+ /* bsp format convert? */
+ if ( convertGame != NULL ) {
+ /* set global game */
+ game = convertGame;
+
+ /* write bsp */
+ StripExtension( source );
+ DefaultExtension( source, "_c.bsp" );
+ Sys_Printf( "Writing %s\n", source );
+ WriteBSPFile( source );
+
+ /* return to sender */
+ return 0;
+ }
+
+ /* normal convert */
+ return convertFunc( source );
+}
objLastShaderNum = ds->lightmapNum[0] + deluxemap;
}
if ( ds->lightmapNum[0] + (int)deluxemap < firstLightmap ) {
- Sys_Printf( "WARNING: lightmap %d out of range (exporting anyway)\n", ds->lightmapNum[0] + deluxemap );
+ Sys_FPrintf( SYS_WRN, "WARNING: lightmap %d out of range (exporting anyway)\n", ds->lightmapNum[0] + deluxemap );
firstLightmap = ds->lightmapNum[0] + deluxemap;
}
if ( ds->lightmapNum[0] > lastLightmap ) {
- Sys_Printf( "WARNING: lightmap %d out of range (exporting anyway)\n", ds->lightmapNum[0] + deluxemap );
+ Sys_FPrintf( SYS_WRN, "WARNING: lightmap %d out of range (exporting anyway)\n", ds->lightmapNum[0] + deluxemap );
lastLightmap = ds->lightmapNum[0] + deluxemap;
}
}
/* get shader */
si = ShaderInfoForShader( shader->shader );
if ( si == NULL ) {
- Sys_Printf( "WARNING: NULL shader in BSP\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: NULL shader in BSP\n" );
return;
}
/* limit check */
if ( numProjectors >= MAX_PROJECTORS ) {
- Sys_Printf( "WARNING: MAX_PROJECTORS (%d) exceeded, no more decal projectors available.\n", MAX_PROJECTORS );
+ Sys_FPrintf( SYS_WRN, "WARNING: MAX_PROJECTORS (%d) exceeded, no more decal projectors available.\n", MAX_PROJECTORS );
return -2;
}
/* any patches? */
if ( e->patches == NULL ) {
- Sys_Printf( "WARNING: Decal entity without any patch meshes, ignoring.\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Decal entity without any patch meshes, ignoring.\n" );
e->epairs = NULL; /* fixme: leak! */
continue;
}
/* no target? */
if ( e2 == NULL ) {
- Sys_Printf( "WARNING: Decal entity without a valid target, ignoring.\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Decal entity without a valid target, ignoring.\n" );
continue;
}
/* sanity check */
if ( bspEntData == NULL || bspEntDataSize == 0 ) {
- Sys_Printf( "WARNING: No BSP entity data. aborting...\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: No BSP entity data. aborting...\n" );
return;
}
/* return to sender */
return 0;
-}
\ No newline at end of file
+}
*/
static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum, int *compileFlags ){
- face_t *split;
- face_t *check;
- face_t *bestSplit;
+ face_t *split;
+ face_t *check;
+ face_t *bestSplit;
int splits, facing, front, back;
int side;
- plane_t *plane;
+ plane_t *plane;
int value, bestValue;
int i;
vec3_t normal;
int planenum;
float sizeBias;
- //int frontC,backC,splitsC,facingC;
-
-
/* ydnar: set some defaults */
*splitPlaneNum = -1; /* leaf */
*compileFlags = 0;
if ( value > bestValue ) {
bestValue = value;
bestSplit = split;
- //frontC=front;
- //backC=back;
- //splitsC=splits;
- //facingC=facing;
}
}
return;
}
- //Sys_FPrintf (SYS_VRB, "F: %d B:%d S:%d FA:%ds\n",frontC,backC,splitsC,facingC );
-
/* set best split data */
*splitPlaneNum = bestSplit->planenum;
*compileFlags = bestSplit->compileFlags;
-#if 0
- if ( bestSplit->compileFlags & C_DETAIL ) {
- for ( split = list; split; split = split->next )
- if ( !( split->compileFlags & C_DETAIL ) ) {
- Sys_FPrintf( SYS_ERR, "DON'T DO SUCH SPLITS (1)\n" );
- }
- }
- if ( ( node->compileFlags & C_DETAIL ) && !( bestSplit->compileFlags & C_DETAIL ) ) {
- Sys_FPrintf( SYS_ERR, "DON'T DO SUCH SPLITS (2)\n" );
- }
-#endif
-
if ( *splitPlaneNum > -1 ) {
mapplanes[ *splitPlaneNum ].counter++;
}
winding_t *frontWinding, *backWinding;
int i;
int splitPlaneNum, compileFlags;
-#if 0
- qboolean isstruct = qfalse;
-#endif
/* count faces left */
continue;
}
-#if 0
- if ( !( split->compileFlags & C_DETAIL ) ) {
- isstruct = 1;
- }
-#endif
-
/* determine which side the face falls on */
side = WindingOnPlaneSide( split->w, plane->normal, plane->dist );
/* switch on side */
if ( side == SIDE_CROSS ) {
+ /* strict; if no winding is left, we have a "virtually identical" plane and don't want to split by it */
ClipWindingEpsilonStrict( split->w, plane->normal, plane->dist, CLIP_EPSILON * 2,
- &frontWinding, &backWinding ); /* strict; if no winding is left, we have a "virtually identical" plane and don't want to split by it */
+ &frontWinding, &backWinding );
if ( frontWinding ) {
newFace = AllocBspFace();
newFace->w = frontWinding;
}
}
-#if 0
- if ( ( node->compileFlags & C_DETAIL ) && isstruct ) {
- Sys_FPrintf( SYS_ERR, "I am detail, my child is structural, this is a wtf1\n", node->has_structural_children );
- }
-#endif
-
for ( i = 0 ; i < 2 ; i++ ) {
BuildFaceTree_r( node->children[i], childLists[i] );
node->has_structural_children |= node->children[i]->has_structural_children;
}
-
-#if 0
- if ( ( node->compileFlags & C_DETAIL ) && !( node->children[0]->compileFlags & C_DETAIL ) && node->children[0]->planenum != PLANENUM_LEAF ) {
- Sys_FPrintf( SYS_ERR, "I am detail, my child is structural\n", node->has_structural_children );
- }
- if ( ( node->compileFlags & C_DETAIL ) && isstruct ) {
- Sys_FPrintf( SYS_ERR, "I am detail, my child is structural, this is a wtf2\n", node->has_structural_children );
- }
-#endif
}
--- /dev/null
+/* -------------------------------------------------------------------------------
+
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ -------------------------------------------------------------------------------
+
+ This code has been altered significantly from its original form, to support
+ several games based on the Quake III Arena engine, in the form of "Q3Map2."
+
+ ------------------------------------------------------------------------------- */
+
+
+
+/* dependencies */
+#include "q3map2.h"
+
+
+
+/*
+ MD4BlockChecksum()
+ calculates an md4 checksum for a block of data
+ */
+
+static int MD4BlockChecksum( void *buffer, int length ){
+ return Com_BlockChecksum( buffer, length );
+}
+
+/*
+ FixAASMain()
+ resets an aas checksum to match the given BSP
+ */
+
+int FixAASMain( int argc, char **argv ){
+ int length, checksum;
+ void *buffer;
+ FILE *file;
+ char aas[ 1024 ], **ext;
+ char *exts[] =
+ {
+ ".aas",
+ "_b0.aas",
+ "_b1.aas",
+ NULL
+ };
+
+
+ /* arg checking */
+ if ( argc < 2 ) {
+ Sys_Printf( "Usage: q3map -fixaas [-v] <mapname>\n" );
+ return 0;
+ }
+
+ /* do some path mangling */
+ strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
+ StripExtension( source );
+ DefaultExtension( source, ".bsp" );
+
+ /* note it */
+ Sys_Printf( "--- FixAAS ---\n" );
+
+ /* load the bsp */
+ Sys_Printf( "Loading %s\n", source );
+ length = LoadFile( source, &buffer );
+
+ /* create bsp checksum */
+ Sys_Printf( "Creating checksum...\n" );
+ checksum = LittleLong( MD4BlockChecksum( buffer, length ) );
+
+ /* write checksum to aas */
+ ext = exts;
+ while ( *ext )
+ {
+ /* mangle name */
+ strcpy( aas, source );
+ StripExtension( aas );
+ strcat( aas, *ext );
+ Sys_Printf( "Trying %s\n", aas );
+ ext++;
+
+ /* fix it */
+ file = fopen( aas, "r+b" );
+ if ( !file ) {
+ continue;
+ }
+ if ( fwrite( &checksum, 4, 1, file ) != 1 ) {
+ Error( "Error writing checksum to %s", aas );
+ }
+ fclose( file );
+ }
+
+ /* return to sender */
+ return 0;
+}
NULL, /* unix home sub-dir */
NULL, /* magic path word */
NULL, /* shader directory */
- 0, /* max lightmapped surface verts */
- 0, /* max surface verts */
- 0, /* max surface indexes */
+ 0, /* max lightmapped surface verts */
+ 0, /* max surface verts */
+ 0, /* max surface indexes */
qfalse, /* flares */
NULL, /* default flare shader */
qfalse, /* wolf lighting model? */
- 0, /* lightmap width/height */
- 0, /* lightmap gamma */
+ 0, /* lightmap width/height */
+ 0, /* lightmap gamma */
qfalse, /* lightmap sRGB */
qfalse, /* texture sRGB */
qfalse, /* color sRGB */
- 0, /* lightmap exposure */
- 0, /* lightmap compensate */
- 0, /* lightgrid scale */
- 0, /* lightgrid ambient scale */
+ 0, /* lightmap exposure */
+ 0, /* lightmap compensate */
+ 0, /* lightgrid scale */
+ 0, /* lightgrid ambient scale */
qfalse, /* light angle attenuation uses half-lambert curve */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
- 0, /* default patchMeta subdivisions tolerance */
+ 0, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
- 0, /* deluxemaps default mode */
- 0, /* minimap size */
- 0, /* minimap sharpener */
- 0, /* minimap border */
+ 0, /* deluxemaps default mode */
+ 0, /* minimap size */
+ 0, /* minimap sharpener */
+ 0, /* minimap border */
qfalse, /* minimap keep aspect */
MINIMAP_MODE_GRAY, /* minimap mode */
NULL, /* minimap name format */
NULL, /* bsp file prefix */
- 0, /* bsp file version */
+ 0, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */
NULL, /* bsp load function */
NULL, /* bsp write function */
"flareshader", /* default flare shader */
qfalse, /* wolf lighting model? */
128, /* lightmap width/height */
- 1.0f, /* lightmap gamma */
+ 2.2f, /* lightmap gamma */
qtrue, /* lightmap sRGB */
qfalse, /* texture sRGB (yes, this is incorrect, but we better match ET:UT) */
qfalse, /* color sRGB */
------------------------------------------------------------------------------- */
+ /* -------------------------------------------------------------------------------
+
+ Additional surface flags for Quake Live
+
+ ------------------------------------------------------------------------------- */
+
+#define Q_SURF_SNOWSTEPS 0x80000 // snow footsteps
+#define Q_SURF_WOODSTEPS 0x100000 // wood footsteps
+#define Q_SURF_DMGTHROUGH 0x200000 // Missile dmg through surface(?)
+ // (This is not in use atm, will
+ // probably be re-purposed some day.)
+
/* -------------------------------------------------------------------------------
{
"quakelive", /* -game x */
- "baseq3", /* default base game data dir (FIXME what does quake live really use?) */
- ".q3a", /* unix home sub-dir (FIXME what does quake live really use?) */
- "quake", /* magic path word (FIXME where does quake live install to?) */
+ "baseq3", /* default base game data dir */
+ ".quakelive/quakelive/home", /* unix home sub-dir */
+ "quake", /* magic path word */
"scripts", /* shader directory */
64, /* max lightmapped surface verts */
999, /* max surface verts */
{ "ladder", 0, 0, Q_SURF_LADDER, 0, 0, 0 },
{ "nodamage", 0, 0, Q_SURF_NODAMAGE, 0, 0, 0 },
{ "metalsteps", 0, 0, Q_SURF_METALSTEPS, 0, 0, 0 },
+ { "snowsteps", 0, 0, Q_SURF_SNOWSTEPS, 0, 0, 0 },
+ { "woodsteps", 0, 0, Q_SURF_WOODSTEPS, 0, 0, 0 },
+ { "dmgthrough", 0, 0, Q_SURF_DMGTHROUGH, 0, 0, 0 },
{ "flesh", 0, 0, Q_SURF_FLESH, 0, 0, 0 },
{ "nosteps", 0, 0, Q_SURF_NOSTEPS, 0, 0, 0 },
{ "nodlight", 0, 0, Q_SURF_NODLIGHT, 0, 0, 0 },
+++ /dev/null
-
-/*
- Copyright (C) 1999-2007 id Software, Inc. and contributors.
- For a list of contributors, see the accompanying CONTRIBUTORS file.
-
- This file is part of GtkRadiant.
-
- GtkRadiant 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.
-
- GtkRadiant 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 GtkRadiant; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* ydnar: for -game support */
-typedef struct game_s
-{
- char *arg; /* -game matches this */
- char *gamePath; /* main game data dir */
- char *homeBasePath; /* home sub-dir on unix */
- char *magic; /* magic word for figuring out base path */
- qboolean wolfLight; /* when true, lights work like wolf q3map */
- int bspVersion; /* BSP version to use */
-}
-game_t;
------------------------------------------------------------------------------- */
/* Derived from Tremulous support by LinuxManMikeC */
+/* Updated to Unvanquished support by Neumond */
/* marker */
{
"unvanquished", /* -game x */
"pkg", /* default base game data dir */
- ".unvanquished", /* unix home sub-dir */
+ ".local/share/unvanquished", /* unix home sub-dir */
"unvanquished", /* magic path word */
"scripts", /* shader directory */
1048575, /* max lightmapped surface verts */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
- 1, /* deluxemaps default mode */
+ 0, /* deluxemaps default mode */
512, /* minimap size */
1.0f, /* minimap sharpener */
0.0f, /* minimap border */
qtrue, /* minimap keep aspect */
- MINIMAP_MODE_BLACK, /* minimap mode */
+ MINIMAP_MODE_WHITE, /* minimap mode */
"../minimaps/%s.tga", /* minimap name format */
"IBSP", /* bsp file prefix */
46, /* bsp file version */
{ "clusterportal", W_CONT_CLUSTERPORTAL, W_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID },
{ "donotenter", W_CONT_DONOTENTER, W_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID },
{ "nonotenterlarge",W_CONT_DONOTENTER_LARGE, W_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID },
+ { "donotenterlarge",W_CONT_DONOTENTER_LARGE, W_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID },
{ "fog", W_CONT_FOG, W_CONT_SOLID, 0, 0, C_FOG, C_SOLID },
{ "sky", 0, 0, W_SURF_SKY, 0, C_SKY, 0 },
{ "clusterportal", W_CONT_CLUSTERPORTAL, W_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID },
{ "donotenter", W_CONT_DONOTENTER, W_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID },
{ "nonotenterlarge",W_CONT_DONOTENTER_LARGE, W_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID },
+ { "donotenterlarge",W_CONT_DONOTENTER_LARGE, W_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID },
{ "fog", W_CONT_FOG, W_CONT_SOLID, 0, 0, C_FOG, C_SOLID },
{ "sky", 0, 0, W_SURF_SKY, 0, C_SKY, 0 },
{"-flat", "Enable flat shading (good for combining with -celshader)"},
{"-fulldetail", "Treat detail brushes as structural ones"},
{"-leaktest", "Abort if a leak was found"},
- {"-linefile <filename.lin>", "Line file to write"},
+ {"-linfile <filename.lin>", "Line file to write"},
{"-meta", "Combine adjacent triangles of the same texture to surfaces (ALWAYS USE THIS)"},
{"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"},
{"-mi <N>", "Sets the maximum number of indexes per surface"},
struct HelpOption vis[] = {
{"-vis <filename.map>", "Switch that enters this stage"},
{"-fast", "Very fast and crude vis calculation"},
+ {"-hint", "Merge all but hint portals"},
{"-mergeportals", "The less crude half of `-merge`, makes vis sometimes much faster but doesn't hurt fps usually"},
{"-merge", "Faster but still okay vis calculation"},
{"-nopassage", "Just use PortalFlow vis (usually less fps)"},
{"-gridscale <F>", "Scaling factor for the light grid only"},
{"-keeplights", "Keep light entities in the BSP file after compile"},
{"-lightmapdir <directory>", "Directory to store external lightmaps (default: same as map name without extension)"},
+ {"-lightmapsearchblocksize <N>", "Restrict lightmap search to block size <N>"},
+ {"-lightmapsearchpower <N>", "Optimize for lightmap merge power <N>"},
{"-lightmapsize <N>", "Size of lightmaps to generate (must be a power of two)"},
+ {"-lightsubdiv <N>", "Size of light emitting shader subdivision"},
{"-lomem", "Low memory but slower lighting mode"},
{"-lowquality", "Low quality floodlight (appears to currently break floodlight)"},
{"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"},
{"-fs_basepath <path>", "Sets the given path as main directory of the game (can be used more than once to look in multiple paths)"},
{"-fs_game <gamename>", "Sets a different game directory name (default for Q3A: baseq3, can be used more than once)"},
{"-fs_homebase <dir>", "Specifies where the user home directory name is on Linux (default for Q3A: .q3a)"},
- {"-fs_pakpath <dir>", "Specify a package directory (can be used more than once to look in multiple paths)"},
+ {"-fs_homepath <path>", "Sets the given path as home directory name"},
+ {"-fs_nobasepath", "Do not load base paths in VFS, imply -fs_nomagicpath"},
+ {"-fs_nomagicpath", "Do not try to guess base path magically"},
+ {"-fs_nohomepath", "Do not load home path in VFS"},
+ {"-fs_pakpath <path>", "Specify a package directory (can be used more than once to look in multiple paths)"},
{"-game <gamename>", "Load settings for the given game (default: quake3)"},
{"-subdivisions <F>", "multiplier for patch subdivisions quality"},
{"-threads <N>", "number of threads to use"},
- {"-v", "Verbose mode"}
+ {"-v", "Verbose mode"},
+ {"-werror", "Make all warnings into errors"}
};
HelpOptions("Common Options", 0, 80, common, sizeof(common)/sizeof(struct HelpOption));
/* dependencies */
#include "q3map2.h"
-
+#include "webp/decode.h"
/* -------------------------------------------------------------------------------
/* get dds info */
if ( DDSGetInfo( (ddsBuffer_t*) buffer, &w, &h, &pf ) ) {
- Sys_Printf( "WARNING: Invalid DDS texture\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Invalid DDS texture\n" );
return;
}
/* only certain types of dds textures are supported */
if ( pf != DDS_PF_ARGB8888 && pf != DDS_PF_DXT1 && pf != DDS_PF_DXT3 && pf != DDS_PF_DXT5 ) {
- Sys_Printf( "WARNING: Only DDS texture formats ARGB8888, DXT1, DXT3, and DXT5 are supported (%d)\n", pf );
+ Sys_FPrintf( SYS_WRN, "WARNING: Only DDS texture formats ARGB8888, DXT1, DXT3, and DXT5 are supported (%d)\n", pf );
return;
}
DDSDecompress( (ddsBuffer_t*) buffer, *pixels );
}
+#ifdef BUILD_CRUNCH
+/*
+ LoadCRNBuffer
+ loads a crn image into a valid rgba image
+*/
+void LoadCRNBuffer( byte *buffer, int size, byte **pixels, int *width, int *height) {
+ /* dummy check */
+ if ( buffer == NULL || size <= 0 || pixels == NULL || width == NULL || height == NULL ) {
+ return;
+ }
+ if ( !GetCRNImageSize( buffer, size, width, height ) ) {
+ Sys_FPrintf( SYS_WRN, "WARNING: Error getting crn imag dimensions.\n");;
+ return;
+ }
+ int outBufSize = *width * *height * 4;
+ *pixels = safe_malloc( outBufSize );
+ if ( !ConvertCRNtoRGBA( buffer, size, outBufSize, *pixels) ) {
+ Sys_FPrintf( SYS_WRN, "WARNING: Error decoding crn image.\n", 0 );
+ return;
+ }
+}
+#endif // BUILD_CRUNCH
/*
png_struct *png;
png_info *info, *end;
pngBuffer_t pb;
- //pngBuffer_t *pb = (pngBuffer_t*) png_get_io_ptr( png );
int bitDepth, colorType;
png_uint_32 w, h, i;
byte **rowPointers;
/* determine if this is a png file */
if ( png_sig_cmp( buffer, 0, 8 ) != 0 ) {
- Sys_Printf( "WARNING: Invalid PNG file\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Invalid PNG file\n" );
return;
}
/* create png structs */
png = png_create_read_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL );
if ( png == NULL ) {
- Sys_Printf( "WARNING: Unable to create PNG read struct\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unable to create PNG read struct\n" );
return;
}
info = png_create_info_struct( png );
if ( info == NULL ) {
- Sys_Printf( "WARNING: Unable to create PNG info struct\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unable to create PNG info struct\n" );
png_destroy_read_struct( &png, NULL, NULL );
return;
}
end = png_create_info_struct( png );
if ( end == NULL ) {
- Sys_Printf( "WARNING: Unable to create PNG end info struct\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unable to create PNG end info struct\n" );
png_destroy_read_struct( &png, &info, NULL );
return;
}
pb.size = size;
pb.offset = 0;
png_set_read_fn( png, &pb, PNGReadData );
- //png->io_ptr = &pb; /* hack! */
/* set error longjmp */
if ( setjmp( png_jmpbuf(png) ) ) {
- Sys_Printf( "WARNING: An error occurred reading PNG image\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: An error occurred reading PNG image\n" );
png_destroy_read_struct( &png, &info, &end );
return;
}
+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_FPrintf( SYS_WRN, "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_Printf( "WARNING: LoadJPGBuff %s %s\n", name, (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
- }
- }
+
+ /* 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 );
if ( LoadJPGBuff( buffer, size, &pixels, &width, &height ) == -1 ) {
if (pixels) {
// On error, LoadJPGBuff might store a pointer to the error message in pixels
- Sys_Printf( "WARNING: LoadJPGBuff %s %s\n", name, (unsigned char*) pixels );
- }
+ Sys_FPrintf( SYS_WRN, "WARNING: LoadJPGBuff %s %s\n", name, (unsigned char*) pixels );
+ }
} else {
if ( width == image->width && height == image->height ) {
int i;
LEAK FILE GENERATION
- Save out name.line for qe3 to read
+ Save out name.lin for qe3 to read
==============================================================================
*/
TTimo: builds a polyline xml node
=============
*/
-xmlNodePtr LeakFile( tree_t *tree ){
+xmlNodePtr LeakFile( tree_t *tree, const char *filename ){
vec3_t mid;
FILE *linefile;
- char filename[1024];
node_t *node;
int count;
xmlNodePtr xml_node, point;
//
// write the points to the file
//
- sprintf( filename, "%s.lin", source );
linefile = fopen( filename, "w" );
if ( !linefile ) {
Error( "Couldn't open %s\n", filename );
/* get target */
e2 = FindTargetEntity( target );
if ( e2 == NULL ) {
- Sys_Printf( "WARNING: light at (%i %i %i) has missing target\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: light at (%i %i %i) has missing target\n",
(int) light->origin[ 0 ], (int) light->origin[ 1 ], (int) light->origin[ 2 ] );
light->photons *= pointScale;
}
/* return to sender */
return 1;
}
- else{
+ else {
Error( "Light of undefined type!" );
}
does what it says...
*/
-void LightWorld( void ){
+void LightWorld( const char *BSPFilePath, qboolean fastAllocate ){
vec3_t color;
float f;
int b, bt;
/* find the optional minimum lighting values */
GetVectorForKey( &entities[ 0 ], "_color", color );
+ if ( VectorLength( color ) == 0.0f ) {
+ VectorSet( color, 1.0, 1.0, 1.0 );
+ }
+
if ( colorsRGB ) {
color[0] = Image_LinearFloatFromsRGBFloat( color[0] );
color[1] = Image_LinearFloatFromsRGBFloat( color[1] );
color[2] = Image_LinearFloatFromsRGBFloat( color[2] );
}
- if ( VectorLength( color ) == 0.0f ) {
- VectorSet( color, 1.0, 1.0, 1.0 );
- }
/* ambient */
f = FloatForKey( &entities[ 0 ], "_ambient" );
while ( bounce > 0 )
{
/* store off the bsp between bounces */
- StoreSurfaceLightmaps();
+ StoreSurfaceLightmaps( fastAllocate );
UnparseEntities();
- Sys_Printf( "Writing %s\n", source );
- WriteBSPFile( source );
+ Sys_Printf( "Writing %s\n", BSPFilePath );
+ WriteBSPFile( BSPFilePath );
/* note it */
Sys_Printf( "\n--- Radiosity (bounce %d of %d) ---\n", b, bt );
SetupEnvelopes( qfalse, fastbounce );
if ( numLights == 0 ) {
Sys_Printf( "No diffuse light to calculate, ending radiosity.\n" );
- break;
+ return;
}
/* add to lightgrid */
bounce--;
b++;
}
+ /* ydnar: store off lightmaps */
+ StoreSurfaceLightmaps( fastAllocate );
}
int LightMain( int argc, char **argv ){
int i;
float f;
- char mapSource[ 1024 ];
+ char BSPFilePath[ 1024 ];
+ char surfaceFilePath[ 1024 ];
+ BSPFilePath[0] = 0;
+ surfaceFilePath[0] = 0;
const char *value;
int lightmapMergeSize = 0;
qboolean lightSamplesInsist = qfalse;
-
+ qboolean fastAllocate = qfalse;
/* note it */
Sys_Printf( "--- Light ---\n" );
}
i++;
}
+
else if ( !strcmp( argv[ i ], "-deluxe" ) || !strcmp( argv[ i ], "-deluxemap" ) ) {
deluxemap = qtrue;
Sys_Printf( "Generating deluxemaps for average light direction\n" );
/* must be a power of 2 and greater than 2 */
if ( ( ( lmCustomSize - 1 ) & lmCustomSize ) || lmCustomSize < 2 ) {
- Sys_Printf( "WARNING: Lightmap size must be a power of 2, greater or equal to 2 pixels.\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Lightmap size must be a power of 2, greater or equal to 2 pixels.\n" );
lmCustomSize = game->lightmapSize;
}
i++;
Sys_Printf( "Faster mode enabled\n" );
}
+ else if ( !strcmp( argv[ i ], "-fastallocate" ) ) {
+ fastAllocate = qtrue;
+ Sys_Printf( "Fast allocation mode enabled\n" );
+ }
+
else if ( !strcmp( argv[ i ], "-fastgrid" ) ) {
fastgrid = qtrue;
Sys_Printf( "Fast grid lighting enabled\n" );
loMem = qtrue;
Sys_Printf( "Enabling low-memory (potentially slower) lighting mode\n" );
}
+ else if ( !strcmp( argv[ i ], "-lightsubdiv" ) ) {
+ defaultLightSubdivide = atoi( argv[ i + 1 ] );
+ if ( defaultLightSubdivide < 1 ) {
+ defaultLightSubdivide = 1;
+ }
+ i++;
+ Sys_Printf( "Default light subdivision set to %d\n", defaultLightSubdivide );
+ }
else if ( !strcmp( argv[ i ], "-lightanglehl" ) ) {
if ( ( atoi( argv[ i + 1 ] ) != 0 ) != lightAngleHL ) {
lightAngleHL = ( atoi( argv[ i + 1 ] ) != 0 );
lightmapFill = qtrue;
Sys_Printf( "Filling lightmap colors from surrounding pixels to improve JPEG compression\n" );
}
+ else if ( !strcmp( argv[ i ], "-bspfile" ) )
+ {
+ strcpy( BSPFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as bsp file\n", BSPFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-srffile" ) )
+ {
+ strcpy( surfaceFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as surface file\n", surfaceFilePath );
+ }
/* unhandled args */
else
{
- Sys_Printf( "WARNING: Unknown argument \"%s\"\n", argv[ i ] );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unknown argument \"%s\"\n", argv[ i ] );
}
}
Sys_Printf( "Restricted lightmap searching enabled - block size adjusted to %d\n", lightmapSearchBlockSize );
}
- /* clean up map name */
strcpy( source, ExpandArg( argv[ i ] ) );
StripExtension( source );
- DefaultExtension( source, ".bsp" );
- strcpy( mapSource, ExpandArg( argv[ i ] ) );
- StripExtension( mapSource );
- DefaultExtension( mapSource, ".map" );
+ DefaultExtension( source, ".map" );
+
+ if (!BSPFilePath[0]) {
+ strcpy( BSPFilePath, ExpandArg( argv[ i ] ) );
+ StripExtension( BSPFilePath );
+ DefaultExtension( BSPFilePath, ".bsp" );
+ }
+
+ if (!surfaceFilePath[0]) {
+ strcpy( surfaceFilePath, ExpandArg( argv[ i ] ) );
+ StripExtension( surfaceFilePath );
+ DefaultExtension( surfaceFilePath, ".srf" );
+ }
/* ydnar: set default sample size */
SetDefaultSampleSize( sampleSize );
/* ydnar: handle shaders */
- BeginMapShaderFile( source );
+ BeginMapShaderFile( BSPFilePath );
LoadShaderInfo();
/* note loading */
Sys_Printf( "Loading %s\n", source );
/* ydnar: load surface file */
- LoadSurfaceExtraFile( source );
+ LoadSurfaceExtraFile( surfaceFilePath );
/* load bsp file */
- LoadBSPFile( source );
+ LoadBSPFile( BSPFilePath );
/* parse bsp entities */
ParseEntities();
/* load map file */
value = ValueForKey( &entities[ 0 ], "_keepLights" );
if ( value[ 0 ] != '1' ) {
- LoadMapFile( mapSource, qtrue, qfalse );
+ LoadMapFile( source, qtrue, qfalse );
}
/* set the entity/model origins and init yDrawVerts */
SetupTraceNodes();
/* light the world */
- LightWorld();
-
- /* ydnar: store off lightmaps */
- StoreSurfaceLightmaps();
+ LightWorld( BSPFilePath, fastAllocate );
/* write out the bsp */
UnparseEntities();
- Sys_Printf( "Writing %s\n", source );
- WriteBSPFile( source );
+ Sys_Printf( "Writing %s\n", BSPFilePath );
+ WriteBSPFile( BSPFilePath );
/* ydnar: export lightmaps */
if ( exportLightmaps && !externalLightmaps ) {
light->falloffTolerance = falloffTolerance;
/* bouncing light? */
- if ( !bouncing ) {
+ if ( bouncing == qfalse ) {
/* This is weird. This actually handles surfacelight and not
* bounces. */
#define GROW_TRACE_NODES 16384 //% 16384
#define GROW_NODE_ITEMS 16 //% 256
-#define MAX_TW_VERTS 24 // vortex: increased from 12 to 24 for ability co compile some insane maps with large curve count
+// vortex: increased from 12 to 24 for ability co compile some insane maps with large curve count
+#define MAX_TW_VERTS 24
#define TRACE_ON_EPSILON 0.1f
memset( &traceNodes[ numTraceNodes ], 0, sizeof( traceNode_t ) );
traceNodes[ numTraceNodes ].type = TRACE_LEAF;
ClearBounds( traceNodes[ numTraceNodes ].mins, traceNodes[ numTraceNodes ].maxs );
-
- /* Sys_Printf("alloc node %d\n", numTraceNodes); */
-
numTraceNodes++;
/* return the count */
}
}
- /* Sys_Printf("node %d children: %d %d\n", nodeNum, traceNodes[ nodeNum ].children[0], traceNodes[ nodeNum ].children[1]); */
-
/* return node number */
return nodeNum;
}
origin2 = SUPER_ORIGIN( x, y );
//% normal2 = SUPER_NORMAL( x, y );
}
- else
- {
- Error( "Spurious lightmap S vector\n" );
+ else {
+ Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap S vector\n" );
}
VectorSubtract( origin2, origin, originVecs[ 0 ] );
//% normal2 = SUPER_NORMAL( x, y );
}
else{
- Sys_Printf( "WARNING: Spurious lightmap T vector\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap T vector\n" );
}
VectorSubtract( origin2, origin, originVecs[ 1 ] );
- //% VectorSubtract( normal2, normal, normalVecs[ 1 ] );
/* calculate new origin */
- //% VectorMA( origin, bx, originVecs[ 0 ], sampleOrigin );
- //% VectorMA( sampleOrigin, by, originVecs[ 1 ], sampleOrigin );
for ( i = 0; i < 3; i++ )
sampleOrigin[ i ] = sampleOrigin[ i ] + ( bx * originVecs[ 0 ][ i ] ) + ( by * originVecs[ 1 ][ i ] );
}
/* calculate new normal */
- //% VectorMA( normal, bx, normalVecs[ 0 ], sampleNormal );
- //% VectorMA( sampleNormal, by, normalVecs[ 1 ], sampleNormal );
- //% if( VectorNormalize( sampleNormal, sampleNormal ) <= 0.0f )
- //% return qfalse;
normal = SUPER_NORMAL( x, y );
VectorCopy( normal, sampleNormal );
/* max of MAX_LIGHTMAPS (4) styles allowed to hit a surface/lightmap */
if ( lightmapNum >= MAX_LIGHTMAPS ) {
- Sys_Printf( "WARNING: Hit per-surface style limit (%d)\n", MAX_LIGHTMAPS );
+ Sys_FPrintf( SYS_WRN, "WARNING: Hit per-surface style limit (%d)\n", MAX_LIGHTMAPS );
continue;
}
normal = SUPER_NORMAL( x, y );
flag = SUPER_FLAG( x, y );
-#if 0
- ////////// 27's temp hack for testing edge clipping ////
- if ( origin[0] == 0 && origin[1] == 0 && origin[2] == 0 ) {
- lightLuxel[ 1 ] = 255;
- lightLuxel[ 3 ] = 1.0f;
- totalLighted++;
- }
- else
-#endif
- {
- /* set contribution count */
- lightLuxel[ 3 ] = 1.0f;
+ /* set contribution count */
+ lightLuxel[ 3 ] = 1.0f;
- /* setup trace */
- trace.cluster = *cluster;
- VectorCopy( origin, trace.origin );
- VectorCopy( normal, trace.normal );
+ /* setup trace */
+ trace.cluster = *cluster;
+ VectorCopy( origin, trace.origin );
+ VectorCopy( normal, trace.normal );
- /* get light for this sample */
- LightContributionToSample( &trace );
- VectorCopy( trace.color, lightLuxel );
+ /* get light for this sample */
+ LightContributionToSample( &trace );
+ VectorCopy( trace.color, lightLuxel );
- /* add the contribution to the deluxemap */
- if ( deluxemap ) {
- VectorCopy( trace.directionContribution, lightDeluxel );
- }
+ /* add the contribution to the deluxemap */
+ if ( deluxemap ) {
+ VectorCopy( trace.directionContribution, lightDeluxel );
+ }
- /* check for evilness */
- if ( trace.forceSubsampling > 1.0f && ( lightSamples > 1 || lightRandomSamples ) ) {
- totalLighted++;
- *flag |= FLAG_FORCE_SUBSAMPLING; /* force */
- }
- /* add to count */
- else if ( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] ) {
- totalLighted++;
- }
+ /* check for evilness */
+ if ( trace.forceSubsampling > 1.0f && ( lightSamples > 1 || lightRandomSamples ) ) {
+ totalLighted++;
+ *flag |= FLAG_FORCE_SUBSAMPLING; /* force */
+ }
+ /* add to count */
+ else if ( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] ) {
+ totalLighted++;
}
}
}
{
/* get cluster */
cluster = SUPER_CLUSTER( x, y );
- //% if( *cluster < 0 ) // TODO why not do this check? These pixels should be zero anyway
- //% continue;
/* get particulars */
luxel = SUPER_LUXEL( lightmapNum, x, y );
}
}
}
-
-
-#if 0
- // audit pass
- for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
- {
- /* early out */
- if ( lm->superLuxels[ lightmapNum ] == NULL ) {
- continue;
- }
- for ( y = 0; y < lm->sh; y++ )
- for ( x = 0; x < lm->sw; x++ )
- {
- /* get cluster */
- cluster = SUPER_CLUSTER( x, y );
- luxel = SUPER_LUXEL( lightmapNum, x, y );
- deluxel = SUPER_DELUXEL( x, y );
- if ( !luxel || !deluxel || !cluster ) {
- Sys_FPrintf( SYS_VRB, "WARNING: I got NULL'd.\n" );
- continue;
- }
- else if ( *cluster < 0 ) {
- // unmapped pixel
- // should have neither deluxemap nor lightmap
- if ( deluxel[3] ) {
- Sys_FPrintf( SYS_VRB, "WARNING: I have written deluxe to an unmapped luxel. Sorry.\n" );
- }
- }
- else
- {
- // mapped pixel
- // should have both deluxemap and lightmap
- if ( deluxel[3] ) {
- Sys_FPrintf( SYS_VRB, "WARNING: I forgot to write deluxe to a mapped luxel. Sorry.\n" );
- }
- }
- }
- }
-#endif
}
determines opaque brushes in the world and find sky shaders for sunlight calculations
*/
-void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ){
+void SetupBrushesFlags( unsigned int mask_any, unsigned int test_any, unsigned int mask_all, unsigned int test_all ){
int i, j, b;
unsigned int compileFlags, allCompileFlags;
bspBrush_t *brush;
else{
light->flags &= ~LIGHT_FAST_TEMP;
}
- if ( fastpoint && ( light->flags != EMIT_AREA ) ) {
+ if ( fastpoint && ( light->type != EMIT_AREA ) ) {
light->flags |= LIGHT_FAST_TEMP;
}
if ( light->si && light->si->noFast ) {
for ( i = 0; i < 3; i++ )
{
if ( mins[ i ] > light->origin[ i ] || maxs[ i ] < light->origin[ i ] ) {
- //% Sys_Printf( "WARNING: Light PVS bounds (%.0f, %.0f, %.0f) -> (%.0f, %.0f, %.0f)\ndo not encompass light %d (%f, %f, %f)\n",
+ //% Sys_FPrintf( SYS_WRN, "WARNING: Light PVS bounds (%.0f, %.0f, %.0f) -> (%.0f, %.0f, %.0f)\ndo not encompass light %d (%f, %f, %f)\n",
//% mins[ 0 ], mins[ 1 ], mins[ 2 ],
//% maxs[ 0 ], maxs[ 1 ], maxs[ 2 ],
//% numLights, light->origin[ 0 ], light->origin[ 1 ], light->origin[ 2 ] );
/* dependencies */
#include "q3map2.h"
-
+#include <glib.h>
/* sanity check */
if ( bspLightBytes == NULL ) {
- Sys_Printf( "WARNING: No BSP lightmap data\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: No BSP lightmap data\n" );
return;
}
buffer = NULL;
len = vfsLoadFile( filename, (void*) &buffer, -1 );
if ( len < 0 ) {
- Sys_Printf( "WARNING: Unable to load image %s\n", filename );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unable to load image %s\n", filename );
continue;
}
/* sanity check it */
if ( pixels == NULL ) {
- Sys_Printf( "WARNING: Unable to load image %s\n", filename );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unable to load image %s\n", filename );
continue;
}
if ( width != game->lightmapSize || height != game->lightmapSize ) {
- Sys_Printf( "WARNING: Image %s is not the right size (%d, %d) != (%d, %d)\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: Image %s is not the right size (%d, %d) != (%d, %d)\n",
filename, width, height, game->lightmapSize, game->lightmapSize );
}
length = 0;
for ( x = 0; x < ( mesh->width - 1 ); x++ )
length += widthTable[ x ];
- lm->w = ceil( length / lm->sampleSize ) + 1;
+ lm->w = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0;
if ( lm->w < ds->patchWidth ) {
lm->w = ds->patchWidth;
}
length = 0;
for ( y = 0; y < ( mesh->height - 1 ); y++ )
length += heightTable[ y ];
- lm->h = ceil( length / lm->sampleSize ) + 1;
+ lm->h = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0;
if ( lm->h < ds->patchHeight ) {
lm->h = ds->patchHeight;
}
/* check for bogus axis */
if ( faxis[ axisNum ] == 0.0f ) {
- Sys_Printf( "WARNING: ProjectSurfaceLightmap: Chose a 0 valued axis\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: ProjectSurfaceLightmap: Chose a 0 valued axis\n" );
lm->w = lm->h = 0;
return qfalse;
}
return -1;
}
-
/* then lightmap sample size */
if ( aInfo->sampleSize < bInfo->sampleSize ) {
return 1;
superSample = 1;
}
else if ( superSample > 8 ) {
- Sys_Printf( "WARNING: Insane supersampling amount (%d) detected.\n", superSample );
+ Sys_FPrintf( SYS_WRN, "WARNING: Insane supersampling amount (%d) detected.\n", superSample );
superSample = 8;
}
*/
#define LIGHTMAP_RESERVE_COUNT 1
-static void FindOutLightmaps( rawLightmap_t *lm ){
+static void FindOutLightmaps( rawLightmap_t *lm, qboolean fastAllocate ){
int i, j, k, lightmapNum, xMax, yMax, x = -1, y = -1, sx, sy, ox, oy, offset;
outLightmap_t *olm;
surfaceInfo_t *info;
vec3_t color, direction;
byte *pixel;
qboolean ok;
+ int xIncrement, yIncrement;
/* set default lightmap number (-3 = LIGHTMAP_BY_VERTEX) */
continue;
}
+ /* if fast allocation, skip lightmap files that are more than 90% complete */
+ if ( fastAllocate == qtrue ) {
+ if (olm->freeLuxels < (olm->customWidth * olm->customHeight) / 10) {
+ continue;
+ }
+ }
+
/* don't store non-custom raw lightmaps on custom bsp lightmaps */
if ( olm->customWidth != lm->customWidth ||
olm->customHeight != lm->customHeight ) {
yMax = ( olm->customHeight - lm->h ) + 1;
}
+ /* if fast allocation, do not test allocation on every pixels, especially for large lightmaps */
+ if ( fastAllocate == qtrue ) {
+ xIncrement = MAX(1, lm->w / 15);
+ yIncrement = MAX(1, lm->h / 15);
+ }
+ else {
+ xIncrement = 1;
+ yIncrement = 1;
+ }
+
/* walk the origin around the lightmap */
- for ( y = 0; y < yMax; y++ )
+ for ( y = 0; y < yMax; y += yIncrement )
{
- for ( x = 0; x < xMax; x++ )
+ for ( x = 0; x < xMax; x += xIncrement )
{
/* find a fine tract of lauhnd */
ok = TestOutLightmapStamp( lm, lightmapNum, olm, x, y );
return 0;
}
+
+
void FillOutLightmap( outLightmap_t *olm ){
int x, y;
int ofs;
}
}
+
+
/*
StoreSurfaceLightmaps()
stores the surface lightmaps into the bsp as byte rgb triplets
*/
-void StoreSurfaceLightmaps( void ){
+void StoreSurfaceLightmaps( qboolean fastAllocate ){
int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples;
int style, size, lightmapNum, lightmapNum2;
float *normal, *luxel, *bspLuxel, *bspLuxel2, *radLuxel, samples, occludedSamples;
char dirname[ 1024 ], filename[ 1024 ];
shaderInfo_t *csi;
char lightmapName[ 128 ];
- const char *rgbGenValues[ 256 ];
- const char *alphaGenValues[ 256 ];
+ const char *rgbGenValues[ 256 ];
+ const char *alphaGenValues[ 256 ];
/* note it */
----------------------------------------------------------------- */
/* note it */
- Sys_Printf( "Subsampling..." );
+ Sys_FPrintf( SYS_VRB, "Subsampling..." );
/* walk the list of raw lightmaps */
numUsed = 0;
if ( noCollapse == qfalse && deluxemap == qfalse ) {
/* note it */
- Sys_Printf( "collapsing..." );
+ Sys_FPrintf( SYS_VRB, "collapsing..." );
/* set all twin refs to null */
for ( i = 0; i < numRawLightmaps; i++ )
----------------------------------------------------------------- */
/* note it */
- Sys_Printf( "sorting..." );
+ Sys_FPrintf( SYS_VRB, "sorting..." );
/* allocate a new sorted list */
if ( sortLightmaps == NULL ) {
----------------------------------------------------------------- */
/* note it */
- Sys_Printf( "allocating..." );
+ Sys_FPrintf( SYS_VRB, "allocating..." );
/* kill all existing output lightmaps */
if ( outLightmaps != NULL ) {
for ( i = 0; i < numRawLightmaps; i++ )
{
lm = &rawLightmaps[ sortLightmaps[ i ] ];
- FindOutLightmaps( lm );
+ FindOutLightmaps( lm, fastAllocate );
}
/* set output numbers in twinned lightmaps */
----------------------------------------------------------------- */
/* note it */
- Sys_Printf( "storing..." );
+ Sys_FPrintf( SYS_VRB, "storing..." );
/* count the bsp lightmaps and allocate space */
if ( bspLightBytes != NULL ) {
}
if ( numExtLightmaps > 0 ) {
- Sys_Printf( "\n" );
+ Sys_FPrintf( SYS_VRB, "\n" );
}
/* delete unused external lightmaps */
----------------------------------------------------------------- */
/* note it */
- Sys_Printf( "projecting..." );
+ Sys_FPrintf( SYS_VRB, "projecting..." );
/* walk the list of surfaces */
for ( i = 0; i < numBSPDrawSurfaces; i++ )
}
/* finish */
- Sys_Printf( "done.\n" );
+ Sys_FPrintf( SYS_VRB, "done.\n" );
/* calc num stored */
numStored = numBSPLightBytes / 3;
-/* -------------------------------------------------------------------------------;
+/* -------------------------------------------------------------------------------
Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
/* dependencies */
#include "q3map2.h"
-
-
-
-/*
- Random()
- returns a pseudorandom number between 0 and 1
- */
-
-vec_t Random( void ){
- return (vec_t) rand() / RAND_MAX;
-}
-
-
-char *Q_strncpyz( char *dst, const char *src, size_t len ) {
- if ( len == 0 ) {
- abort();
- }
-
- strncpy( dst, src, len );
- dst[ len - 1 ] = '\0';
- return dst;
-}
-
-
-char *Q_strcat( char *dst, size_t dlen, const char *src ) {
- size_t n = strlen( dst );
-
- if ( n > dlen ) {
- abort(); /* buffer overflow */
- }
-
- return Q_strncpyz( dst + n, src, dlen - n );
-}
-
-
-char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen ) {
- size_t n = strlen( dst );
-
- if ( n > dlen ) {
- abort(); /* buffer overflow */
- }
-
- return Q_strncpyz( dst + n, src, MIN( slen, dlen - n ) );
-}
-
-
-/*
- ExitQ3Map()
- cleanup routine
- */
-
-static void ExitQ3Map( void ){
- BSPFilesCleanup();
- if ( mapDrawSurfs != NULL ) {
- free( mapDrawSurfs );
- }
-}
-
-
-
-/* minimap stuff */
-
-typedef struct minimap_s
-{
- bspModel_t *model;
- int width;
- int height;
- int samples;
- float *sample_offsets;
- float sharpen_boxmult;
- float sharpen_centermult;
- float boost, brightness, contrast;
- float *data1f;
- float *sharpendata1f;
- vec3_t mins, size;
-}
-minimap_t;
-static minimap_t minimap;
-
-qboolean BrushIntersectionWithLine( bspBrush_t *brush, vec3_t start, vec3_t dir, float *t_in, float *t_out ){
- int i;
- qboolean in = qfalse, out = qfalse;
- bspBrushSide_t *sides = &bspBrushSides[brush->firstSide];
-
- for ( i = 0; i < brush->numSides; ++i )
- {
- bspPlane_t *p = &bspPlanes[sides[i].planeNum];
- float sn = DotProduct( start, p->normal );
- float dn = DotProduct( dir, p->normal );
- if ( dn == 0 ) {
- if ( sn > p->dist ) {
- return qfalse; // outside!
- }
- }
- else
- {
- float t = ( p->dist - sn ) / dn;
- if ( dn < 0 ) {
- if ( !in || t > *t_in ) {
- *t_in = t;
- in = qtrue;
- // as t_in can only increase, and t_out can only decrease, early out
- if ( out && *t_in >= *t_out ) {
- return qfalse;
- }
- }
- }
- else
- {
- if ( !out || t < *t_out ) {
- *t_out = t;
- out = qtrue;
- // as t_in can only increase, and t_out can only decrease, early out
- if ( in && *t_in >= *t_out ) {
- return qfalse;
- }
- }
- }
- }
- }
- return in && out;
-}
-
-static float MiniMapSample( float x, float y ){
- vec3_t org, dir;
- int i, bi;
- float t0, t1;
- float samp;
- bspBrush_t *b;
- bspBrushSide_t *s;
- int cnt;
-
- org[0] = x;
- org[1] = y;
- org[2] = 0;
- dir[0] = 0;
- dir[1] = 0;
- dir[2] = 1;
-
- cnt = 0;
- samp = 0;
- for ( i = 0; i < minimap.model->numBSPBrushes; ++i )
- {
- bi = minimap.model->firstBSPBrush + i;
- if ( opaqueBrushes[bi >> 3] & ( 1 << ( bi & 7 ) ) ) {
- b = &bspBrushes[bi];
-
- // sort out mins/maxs of the brush
- s = &bspBrushSides[b->firstSide];
- if ( x < -bspPlanes[s[0].planeNum].dist ) {
- continue;
- }
- if ( x > +bspPlanes[s[1].planeNum].dist ) {
- continue;
- }
- if ( y < -bspPlanes[s[2].planeNum].dist ) {
- continue;
- }
- if ( y > +bspPlanes[s[3].planeNum].dist ) {
- continue;
- }
-
- if ( BrushIntersectionWithLine( b, org, dir, &t0, &t1 ) ) {
- samp += t1 - t0;
- ++cnt;
- }
- }
- }
-
- return samp;
-}
-
-void RandomVector2f( float v[2] ){
- do
- {
- v[0] = 2 * Random() - 1;
- v[1] = 2 * Random() - 1;
- }
- while ( v[0] * v[0] + v[1] * v[1] > 1 );
-}
-
-static void MiniMapRandomlySupersampled( int y ){
- int x, i;
- float *p = &minimap.data1f[y * minimap.width];
- float ymin = minimap.mins[1] + minimap.size[1] * ( y / (float) minimap.height );
- float dx = minimap.size[0] / (float) minimap.width;
- float dy = minimap.size[1] / (float) minimap.height;
- float uv[2];
- float thisval;
-
- for ( x = 0; x < minimap.width; ++x )
- {
- float xmin = minimap.mins[0] + minimap.size[0] * ( x / (float) minimap.width );
- float val = 0;
-
- for ( i = 0; i < minimap.samples; ++i )
- {
- RandomVector2f( uv );
- thisval = MiniMapSample(
- xmin + ( uv[0] + 0.5 ) * dx, /* exaggerated random pattern for better results */
- ymin + ( uv[1] + 0.5 ) * dy /* exaggerated random pattern for better results */
- );
- val += thisval;
- }
- val /= minimap.samples * minimap.size[2];
- *p++ = val;
- }
-}
-
-static void MiniMapSupersampled( int y ){
- int x, i;
- float *p = &minimap.data1f[y * minimap.width];
- float ymin = minimap.mins[1] + minimap.size[1] * ( y / (float) minimap.height );
- float dx = minimap.size[0] / (float) minimap.width;
- float dy = minimap.size[1] / (float) minimap.height;
-
- for ( x = 0; x < minimap.width; ++x )
- {
- float xmin = minimap.mins[0] + minimap.size[0] * ( x / (float) minimap.width );
- float val = 0;
-
- for ( i = 0; i < minimap.samples; ++i )
- {
- float thisval = MiniMapSample(
- xmin + minimap.sample_offsets[2 * i + 0] * dx,
- ymin + minimap.sample_offsets[2 * i + 1] * dy
- );
- val += thisval;
- }
- val /= minimap.samples * minimap.size[2];
- *p++ = val;
- }
-}
-
-static void MiniMapNoSupersampling( int y ){
- int x;
- float *p = &minimap.data1f[y * minimap.width];
- float ymin = minimap.mins[1] + minimap.size[1] * ( ( y + 0.5 ) / (float) minimap.height );
-
- for ( x = 0; x < minimap.width; ++x )
- {
- float xmin = minimap.mins[0] + minimap.size[0] * ( ( x + 0.5 ) / (float) minimap.width );
- *p++ = MiniMapSample( xmin, ymin ) / minimap.size[2];
- }
-}
-
-static void MiniMapSharpen( int y ){
- int x;
- qboolean up = ( y > 0 );
- qboolean down = ( y < minimap.height - 1 );
- float *p = &minimap.data1f[y * minimap.width];
- float *q = &minimap.sharpendata1f[y * minimap.width];
-
- for ( x = 0; x < minimap.width; ++x )
- {
- qboolean left = ( x > 0 );
- qboolean right = ( x < minimap.width - 1 );
- float val = p[0] * minimap.sharpen_centermult;
-
- if ( left && up ) {
- val += p[-1 - minimap.width] * minimap.sharpen_boxmult;
- }
- if ( left && down ) {
- val += p[-1 + minimap.width] * minimap.sharpen_boxmult;
- }
- if ( right && up ) {
- val += p[+1 - minimap.width] * minimap.sharpen_boxmult;
- }
- if ( right && down ) {
- val += p[+1 + minimap.width] * minimap.sharpen_boxmult;
- }
-
- if ( left ) {
- val += p[-1] * minimap.sharpen_boxmult;
- }
- if ( right ) {
- val += p[+1] * minimap.sharpen_boxmult;
- }
- if ( up ) {
- val += p[-minimap.width] * minimap.sharpen_boxmult;
- }
- if ( down ) {
- val += p[+minimap.width] * minimap.sharpen_boxmult;
- }
-
- ++p;
- *q++ = val;
- }
-}
-
-static void MiniMapContrastBoost( int y ){
- int x;
- float *q = &minimap.data1f[y * minimap.width];
- for ( x = 0; x < minimap.width; ++x )
- {
- *q = *q * minimap.boost / ( ( minimap.boost - 1 ) * *q + 1 );
- ++q;
- }
-}
-
-static void MiniMapBrightnessContrast( int y ){
- int x;
- float *q = &minimap.data1f[y * minimap.width];
- for ( x = 0; x < minimap.width; ++x )
- {
- *q = *q * minimap.contrast + minimap.brightness;
- ++q;
- }
-}
-
-void MiniMapMakeMinsMaxs( vec3_t mins_in, vec3_t maxs_in, float border, qboolean keepaspect ){
- vec3_t mins, maxs, extend;
- VectorCopy( mins_in, mins );
- VectorCopy( maxs_in, maxs );
-
- // line compatible to nexuiz mapinfo
- Sys_Printf( "size %f %f %f %f %f %f\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2] );
-
- if ( keepaspect ) {
- VectorSubtract( maxs, mins, extend );
- if ( extend[1] > extend[0] ) {
- mins[0] -= ( extend[1] - extend[0] ) * 0.5;
- maxs[0] += ( extend[1] - extend[0] ) * 0.5;
- }
- else
- {
- mins[1] -= ( extend[0] - extend[1] ) * 0.5;
- maxs[1] += ( extend[0] - extend[1] ) * 0.5;
- }
- }
-
- /* border: amount of black area around the image */
- /* input: border, 1-2*border, border but we need border/(1-2*border) */
-
- VectorSubtract( maxs, mins, extend );
- VectorScale( extend, border / ( 1 - 2 * border ), extend );
-
- VectorSubtract( mins, extend, mins );
- VectorAdd( maxs, extend, maxs );
-
- VectorCopy( mins, minimap.mins );
- VectorSubtract( maxs, mins, minimap.size );
-
- // line compatible to nexuiz mapinfo
- Sys_Printf( "size_texcoords %f %f %f %f %f %f\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2] );
-}
-
-/*
- MiniMapSetupBrushes()
- determines solid non-sky brushes in the world
- */
-
-void MiniMapSetupBrushes( void ){
- SetupBrushesFlags( C_SOLID | C_SKY, C_SOLID, 0, 0 );
- // at least one must be solid
- // none may be sky
- // not all may be nodraw
-}
-
-qboolean MiniMapEvaluateSampleOffsets( int *bestj, int *bestk, float *bestval ){
- float val, dx, dy;
- int j, k;
-
- *bestj = *bestk = -1;
- *bestval = 3; /* max possible val is 2 */
-
- for ( j = 0; j < minimap.samples; ++j )
- for ( k = j + 1; k < minimap.samples; ++k )
- {
- dx = minimap.sample_offsets[2 * j + 0] - minimap.sample_offsets[2 * k + 0];
- dy = minimap.sample_offsets[2 * j + 1] - minimap.sample_offsets[2 * k + 1];
- if ( dx > +0.5 ) {
- dx -= 1;
- }
- if ( dx < -0.5 ) {
- dx += 1;
- }
- if ( dy > +0.5 ) {
- dy -= 1;
- }
- if ( dy < -0.5 ) {
- dy += 1;
- }
- val = dx * dx + dy * dy;
- if ( val < *bestval ) {
- *bestj = j;
- *bestk = k;
- *bestval = val;
- }
- }
-
- return *bestval < 3;
-}
-
-void MiniMapMakeSampleOffsets(){
- int i, j, k, jj, kk;
- float val, valj, valk, sx, sy, rx, ry;
-
- Sys_Printf( "Generating good sample offsets (this may take a while)...\n" );
-
- /* start with entirely random samples */
- for ( i = 0; i < minimap.samples; ++i )
- {
- minimap.sample_offsets[2 * i + 0] = Random();
- minimap.sample_offsets[2 * i + 1] = Random();
- }
-
- for ( i = 0; i < 1000; ++i )
- {
- if ( MiniMapEvaluateSampleOffsets( &j, &k, &val ) ) {
- sx = minimap.sample_offsets[2 * j + 0];
- sy = minimap.sample_offsets[2 * j + 1];
- minimap.sample_offsets[2 * j + 0] = rx = Random();
- minimap.sample_offsets[2 * j + 1] = ry = Random();
- if ( !MiniMapEvaluateSampleOffsets( &jj, &kk, &valj ) ) {
- valj = -1;
- }
- minimap.sample_offsets[2 * j + 0] = sx;
- minimap.sample_offsets[2 * j + 1] = sy;
-
- sx = minimap.sample_offsets[2 * k + 0];
- sy = minimap.sample_offsets[2 * k + 1];
- minimap.sample_offsets[2 * k + 0] = rx;
- minimap.sample_offsets[2 * k + 1] = ry;
- if ( !MiniMapEvaluateSampleOffsets( &jj, &kk, &valk ) ) {
- valk = -1;
- }
- minimap.sample_offsets[2 * k + 0] = sx;
- minimap.sample_offsets[2 * k + 1] = sy;
-
- if ( valj > valk ) {
- if ( valj > val ) {
- /* valj is the greatest */
- minimap.sample_offsets[2 * j + 0] = rx;
- minimap.sample_offsets[2 * j + 1] = ry;
- i = -1;
- }
- else
- {
- /* valj is the greater and it is useless - forget it */
- }
- }
- else
- {
- if ( valk > val ) {
- /* valk is the greatest */
- minimap.sample_offsets[2 * k + 0] = rx;
- minimap.sample_offsets[2 * k + 1] = ry;
- i = -1;
- }
- else
- {
- /* valk is the greater and it is useless - forget it */
- }
- }
- }
- else{
- break;
- }
- }
-}
-
-void MergeRelativePath( char *out, const char *absolute, const char *relative ){
- const char *endpos = absolute + strlen( absolute );
- while ( endpos != absolute && ( endpos[-1] == '/' || endpos[-1] == '\\' ) )
- --endpos;
- while ( relative[0] == '.' && relative[1] == '.' && ( relative[2] == '/' || relative[2] == '\\' ) )
- {
- relative += 3;
- while ( endpos != absolute )
- {
- --endpos;
- if ( *endpos == '/' || *endpos == '\\' ) {
- break;
- }
- }
- while ( endpos != absolute && ( endpos[-1] == '/' || endpos[-1] == '\\' ) )
- --endpos;
- }
- memcpy( out, absolute, endpos - absolute );
- out[endpos - absolute] = '/';
- strcpy( out + ( endpos - absolute + 1 ), relative );
-}
-
-int MiniMapBSPMain( int argc, char **argv ){
- char minimapFilename[1024];
- char basename[1024];
- char path[1024];
- char relativeMinimapFilename[1024];
- qboolean autolevel;
- float minimapSharpen;
- float border;
- byte *data4b, *p;
- float *q;
- int x, y;
- int i;
- miniMapMode_t mode;
- vec3_t mins, maxs;
- qboolean keepaspect;
-
- /* arg checking */
- if ( argc < 2 ) {
- Sys_Printf( "Usage: q3map [-v] -minimap [-size n] [-sharpen f] [-samples n | -random n] [-o filename.tga] [-minmax Xmin Ymin Zmin Xmax Ymax Zmax] <mapname>\n" );
- return 0;
- }
-
- /* load the BSP first */
- strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
- StripExtension( source );
- DefaultExtension( source, ".bsp" );
- Sys_Printf( "Loading %s\n", source );
- //BeginMapShaderFile( source ); //do not delete q3map2_*.shader on minimap generation
- LoadShaderInfo();
- LoadBSPFile( source );
-
- minimap.model = &bspModels[0];
- VectorCopy( minimap.model->mins, mins );
- VectorCopy( minimap.model->maxs, maxs );
-
- *minimapFilename = 0;
- minimapSharpen = game->miniMapSharpen;
- minimap.width = minimap.height = game->miniMapSize;
- border = game->miniMapBorder;
- keepaspect = game->miniMapKeepAspect;
- mode = game->miniMapMode;
-
- autolevel = qfalse;
- minimap.samples = 1;
- minimap.sample_offsets = NULL;
- minimap.boost = 1.0;
- minimap.brightness = 0.0;
- minimap.contrast = 1.0;
-
- /* process arguments */
- for ( i = 1; i < ( argc - 1 ); i++ )
- {
- if ( !strcmp( argv[ i ], "-size" ) ) {
- minimap.width = minimap.height = atoi( argv[i + 1] );
- i++;
- Sys_Printf( "Image size set to %i\n", minimap.width );
- }
- else if ( !strcmp( argv[ i ], "-sharpen" ) ) {
- minimapSharpen = atof( argv[i + 1] );
- i++;
- Sys_Printf( "Sharpening coefficient set to %f\n", minimapSharpen );
- }
- else if ( !strcmp( argv[ i ], "-samples" ) ) {
- minimap.samples = atoi( argv[i + 1] );
- i++;
- Sys_Printf( "Samples set to %i\n", minimap.samples );
- if ( minimap.sample_offsets ) {
- free( minimap.sample_offsets );
- }
- minimap.sample_offsets = malloc( 2 * sizeof( *minimap.sample_offsets ) * minimap.samples );
- MiniMapMakeSampleOffsets();
- }
- else if ( !strcmp( argv[ i ], "-random" ) ) {
- minimap.samples = atoi( argv[i + 1] );
- i++;
- Sys_Printf( "Random samples set to %i\n", minimap.samples );
- if ( minimap.sample_offsets ) {
- free( minimap.sample_offsets );
- }
- minimap.sample_offsets = NULL;
- }
- else if ( !strcmp( argv[ i ], "-border" ) ) {
- border = atof( argv[i + 1] );
- i++;
- Sys_Printf( "Border set to %f\n", border );
- }
- else if ( !strcmp( argv[ i ], "-keepaspect" ) ) {
- keepaspect = qtrue;
- Sys_Printf( "Keeping aspect ratio by letterboxing\n", border );
- }
- else if ( !strcmp( argv[ i ], "-nokeepaspect" ) ) {
- keepaspect = qfalse;
- Sys_Printf( "Not keeping aspect ratio\n", border );
- }
- else if ( !strcmp( argv[ i ], "-o" ) ) {
- strcpy( minimapFilename, argv[i + 1] );
- i++;
- Sys_Printf( "Output file name set to %s\n", minimapFilename );
- }
- else if ( !strcmp( argv[ i ], "-minmax" ) && i < ( argc - 7 ) ) {
- mins[0] = atof( argv[i + 1] );
- mins[1] = atof( argv[i + 2] );
- mins[2] = atof( argv[i + 3] );
- maxs[0] = atof( argv[i + 4] );
- maxs[1] = atof( argv[i + 5] );
- maxs[2] = atof( argv[i + 6] );
- i += 6;
- Sys_Printf( "Map mins/maxs overridden\n" );
- }
- else if ( !strcmp( argv[ i ], "-gray" ) ) {
- mode = MINIMAP_MODE_GRAY;
- Sys_Printf( "Writing as white-on-black image\n" );
- }
- else if ( !strcmp( argv[ i ], "-black" ) ) {
- mode = MINIMAP_MODE_BLACK;
- Sys_Printf( "Writing as black alpha image\n" );
- }
- else if ( !strcmp( argv[ i ], "-white" ) ) {
- mode = MINIMAP_MODE_WHITE;
- Sys_Printf( "Writing as white alpha image\n" );
- }
- else if ( !strcmp( argv[ i ], "-boost" ) && i < ( argc - 2 ) ) {
- minimap.boost = atof( argv[i + 1] );
- i++;
- Sys_Printf( "Contrast boost set to %f\n", minimap.boost );
- }
- else if ( !strcmp( argv[ i ], "-brightness" ) && i < ( argc - 2 ) ) {
- minimap.brightness = atof( argv[i + 1] );
- i++;
- Sys_Printf( "Brightness set to %f\n", minimap.brightness );
- }
- else if ( !strcmp( argv[ i ], "-contrast" ) && i < ( argc - 2 ) ) {
- minimap.contrast = atof( argv[i + 1] );
- i++;
- Sys_Printf( "Contrast set to %f\n", minimap.contrast );
- }
- else if ( !strcmp( argv[ i ], "-autolevel" ) ) {
- autolevel = qtrue;
- Sys_Printf( "Auto level enabled\n", border );
- }
- else if ( !strcmp( argv[ i ], "-noautolevel" ) ) {
- autolevel = qfalse;
- Sys_Printf( "Auto level disabled\n", border );
- }
- }
-
- MiniMapMakeMinsMaxs( mins, maxs, border, keepaspect );
-
- if ( !*minimapFilename ) {
- ExtractFileBase( source, basename );
- ExtractFilePath( source, path );
- sprintf( relativeMinimapFilename, game->miniMapNameFormat, basename );
- MergeRelativePath( minimapFilename, path, relativeMinimapFilename );
- Sys_Printf( "Output file name automatically set to %s\n", minimapFilename );
- }
- ExtractFilePath( minimapFilename, path );
- Q_mkdir( path );
-
- if ( minimapSharpen >= 0 ) {
- minimap.sharpen_centermult = 8 * minimapSharpen + 1;
- minimap.sharpen_boxmult = -minimapSharpen;
- }
-
- minimap.data1f = safe_malloc( minimap.width * minimap.height * sizeof( *minimap.data1f ) );
- data4b = safe_malloc( minimap.width * minimap.height * 4 );
- if ( minimapSharpen >= 0 ) {
- minimap.sharpendata1f = safe_malloc( minimap.width * minimap.height * sizeof( *minimap.data1f ) );
- }
-
- MiniMapSetupBrushes();
-
- if ( minimap.samples <= 1 ) {
- Sys_Printf( "\n--- MiniMapNoSupersampling (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapNoSupersampling );
- }
- else
- {
- if ( minimap.sample_offsets ) {
- Sys_Printf( "\n--- MiniMapSupersampled (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapSupersampled );
- }
- else
- {
- Sys_Printf( "\n--- MiniMapRandomlySupersampled (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapRandomlySupersampled );
- }
- }
-
- if ( minimap.boost != 1.0 ) {
- Sys_Printf( "\n--- MiniMapContrastBoost (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapContrastBoost );
- }
-
- if ( autolevel ) {
- Sys_Printf( "\n--- MiniMapAutoLevel (%d) ---\n", minimap.height );
- float mi = 1, ma = 0;
- float s, o;
-
- // TODO threads!
- q = minimap.data1f;
- for ( y = 0; y < minimap.height; ++y )
- for ( x = 0; x < minimap.width; ++x )
- {
- float v = *q++;
- if ( v < mi ) {
- mi = v;
- }
- if ( v > ma ) {
- ma = v;
- }
- }
- if ( ma > mi ) {
- s = 1 / ( ma - mi );
- o = mi / ( ma - mi );
-
- // equations:
- // brightness + contrast * v
- // after autolevel:
- // brightness + contrast * (v * s - o)
- // =
- // (brightness - contrast * o) + (contrast * s) * v
- minimap.brightness = minimap.brightness - minimap.contrast * o;
- minimap.contrast *= s;
-
- Sys_Printf( "Auto level: Brightness changed to %f\n", minimap.brightness );
- Sys_Printf( "Auto level: Contrast changed to %f\n", minimap.contrast );
- }
- else{
- Sys_Printf( "Auto level: failed because all pixels are the same value\n" );
- }
- }
-
- if ( minimap.brightness != 0 || minimap.contrast != 1 ) {
- Sys_Printf( "\n--- MiniMapBrightnessContrast (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapBrightnessContrast );
- }
-
- if ( minimap.sharpendata1f ) {
- Sys_Printf( "\n--- MiniMapSharpen (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapSharpen );
- q = minimap.sharpendata1f;
- }
- else
- {
- q = minimap.data1f;
- }
-
- Sys_Printf( "\nConverting..." );
-
- switch ( mode )
- {
- case MINIMAP_MODE_GRAY:
- p = data4b;
- for ( y = 0; y < minimap.height; ++y )
- for ( x = 0; x < minimap.width; ++x )
- {
- byte b;
- float v = *q++;
- if ( v < 0 ) {
- v = 0;
- }
- if ( v > 255.0 / 256.0 ) {
- v = 255.0 / 256.0;
- }
- b = v * 256;
- *p++ = b;
- }
- Sys_Printf( " writing to %s...", minimapFilename );
- WriteTGAGray( minimapFilename, data4b, minimap.width, minimap.height );
- break;
- case MINIMAP_MODE_BLACK:
- p = data4b;
- for ( y = 0; y < minimap.height; ++y )
- for ( x = 0; x < minimap.width; ++x )
- {
- byte b;
- float v = *q++;
- if ( v < 0 ) {
- v = 0;
- }
- if ( v > 255.0 / 256.0 ) {
- v = 255.0 / 256.0;
- }
- b = v * 256;
- *p++ = 0;
- *p++ = 0;
- *p++ = 0;
- *p++ = b;
- }
- Sys_Printf( " writing to %s...", minimapFilename );
- WriteTGA( minimapFilename, data4b, minimap.width, minimap.height );
- break;
- case MINIMAP_MODE_WHITE:
- p = data4b;
- for ( y = 0; y < minimap.height; ++y )
- for ( x = 0; x < minimap.width; ++x )
- {
- byte b;
- float v = *q++;
- if ( v < 0 ) {
- v = 0;
- }
- if ( v > 255.0 / 256.0 ) {
- v = 255.0 / 256.0;
- }
- b = v * 256;
- *p++ = 255;
- *p++ = 255;
- *p++ = 255;
- *p++ = b;
- }
- Sys_Printf( " writing to %s...", minimapFilename );
- WriteTGA( minimapFilename, data4b, minimap.width, minimap.height );
- break;
- }
-
- Sys_Printf( " done.\n" );
-
- /* return to sender */
- return 0;
-}
-
-
-
-
-
-/*
- MD4BlockChecksum()
- calculates an md4 checksum for a block of data
- */
-
-static int MD4BlockChecksum( void *buffer, int length ){
- return Com_BlockChecksum( buffer, length );
-}
-
-/*
- FixAAS()
- resets an aas checksum to match the given BSP
- */
-
-int FixAAS( int argc, char **argv ){
- int length, checksum;
- void *buffer;
- FILE *file;
- char aas[ 1024 ], **ext;
- char *exts[] =
- {
- ".aas",
- "_b0.aas",
- "_b1.aas",
- NULL
- };
-
-
- /* arg checking */
- if ( argc < 2 ) {
- Sys_Printf( "Usage: q3map -fixaas [-v] <mapname>\n" );
- return 0;
- }
-
- /* do some path mangling */
- strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
- StripExtension( source );
- DefaultExtension( source, ".bsp" );
-
- /* note it */
- Sys_Printf( "--- FixAAS ---\n" );
-
- /* load the bsp */
- Sys_Printf( "Loading %s\n", source );
- length = LoadFile( source, &buffer );
-
- /* create bsp checksum */
- Sys_Printf( "Creating checksum...\n" );
- checksum = LittleLong( MD4BlockChecksum( buffer, length ) );
-
- /* write checksum to aas */
- ext = exts;
- while ( *ext )
- {
- /* mangle name */
- strcpy( aas, source );
- StripExtension( aas );
- strcat( aas, *ext );
- Sys_Printf( "Trying %s\n", aas );
- ext++;
-
- /* fix it */
- file = fopen( aas, "r+b" );
- if ( !file ) {
- continue;
- }
- if ( fwrite( &checksum, 4, 1, file ) != 1 ) {
- Error( "Error writing checksum to %s", aas );
- }
- fclose( file );
- }
-
- /* return to sender */
- return 0;
-}
-
-
-
-/*
- AnalyzeBSP() - ydnar
- analyzes a Quake engine BSP file
- */
-
-typedef struct abspHeader_s
-{
- char ident[ 4 ];
- int version;
-
- bspLump_t lumps[ 1 ]; /* unknown size */
-}
-abspHeader_t;
-
-typedef struct abspLumpTest_s
-{
- int radix, minCount;
- char *name;
-}
-abspLumpTest_t;
-
-int AnalyzeBSP( int argc, char **argv ){
- abspHeader_t *header;
- int size, i, version, offset, length, lumpInt, count;
- char ident[ 5 ];
- void *lump;
- float lumpFloat;
- char lumpString[ 1024 ], source[ 1024 ];
- qboolean lumpSwap = qfalse;
- abspLumpTest_t *lumpTest;
- static abspLumpTest_t lumpTests[] =
- {
- { sizeof( bspPlane_t ), 6, "IBSP LUMP_PLANES" },
- { sizeof( bspBrush_t ), 1, "IBSP LUMP_BRUSHES" },
- { 8, 6, "IBSP LUMP_BRUSHSIDES" },
- { sizeof( bspBrushSide_t ), 6, "RBSP LUMP_BRUSHSIDES" },
- { sizeof( bspModel_t ), 1, "IBSP LUMP_MODELS" },
- { sizeof( bspNode_t ), 2, "IBSP LUMP_NODES" },
- { sizeof( bspLeaf_t ), 1, "IBSP LUMP_LEAFS" },
- { 104, 3, "IBSP LUMP_DRAWSURFS" },
- { 44, 3, "IBSP LUMP_DRAWVERTS" },
- { 4, 6, "IBSP LUMP_DRAWINDEXES" },
- { 128 * 128 * 3, 1, "IBSP LUMP_LIGHTMAPS" },
- { 256 * 256 * 3, 1, "IBSP LUMP_LIGHTMAPS (256 x 256)" },
- { 512 * 512 * 3, 1, "IBSP LUMP_LIGHTMAPS (512 x 512)" },
- { 0, 0, NULL }
- };
-
-
- /* arg checking */
- if ( argc < 1 ) {
- Sys_Printf( "Usage: q3map -analyze [-lumpswap] [-v] <mapname>\n" );
- return 0;
- }
-
- /* process arguments */
- for ( i = 1; i < ( argc - 1 ); i++ )
- {
- /* -format map|ase|... */
- if ( !strcmp( argv[ i ], "-lumpswap" ) ) {
- Sys_Printf( "Swapped lump structs enabled\n" );
- lumpSwap = qtrue;
- }
- }
-
- /* clean up map name */
- strcpy( source, ExpandArg( argv[ i ] ) );
- Sys_Printf( "Loading %s\n", source );
-
- /* load the file */
- size = LoadFile( source, (void**) &header );
- if ( size == 0 || header == NULL ) {
- Sys_Printf( "Unable to load %s.\n", source );
- return -1;
- }
-
- /* analyze ident/version */
- memcpy( ident, header->ident, 4 );
- ident[ 4 ] = '\0';
- version = LittleLong( header->version );
-
- Sys_Printf( "Identity: %s\n", ident );
- Sys_Printf( "Version: %d\n", version );
- Sys_Printf( "---------------------------------------\n" );
-
- /* analyze each lump */
- for ( i = 0; i < 100; i++ )
- {
- /* call of duty swapped lump pairs */
- if ( lumpSwap ) {
- offset = LittleLong( header->lumps[ i ].length );
- length = LittleLong( header->lumps[ i ].offset );
- }
-
- /* standard lump pairs */
- else
- {
- offset = LittleLong( header->lumps[ i ].offset );
- length = LittleLong( header->lumps[ i ].length );
- }
-
- /* extract data */
- lump = (byte*) header + offset;
- lumpInt = LittleLong( (int) *( (int*) lump ) );
- lumpFloat = LittleFloat( (float) *( (float*) lump ) );
- memcpy( lumpString, (char*) lump, ( (size_t)length < sizeof( lumpString ) ? (size_t)length : sizeof( lumpString ) - 1 ) );
- lumpString[ sizeof( lumpString ) - 1 ] = '\0';
-
- /* print basic lump info */
- Sys_Printf( "Lump: %d\n", i );
- Sys_Printf( "Offset: %d bytes\n", offset );
- Sys_Printf( "Length: %d bytes\n", length );
-
- /* only operate on valid lumps */
- if ( length > 0 ) {
- /* print data in 4 formats */
- Sys_Printf( "As hex: %08X\n", lumpInt );
- Sys_Printf( "As int: %d\n", lumpInt );
- Sys_Printf( "As float: %f\n", lumpFloat );
- Sys_Printf( "As string: %s\n", lumpString );
-
- /* guess lump type */
- if ( lumpString[ 0 ] == '{' && lumpString[ 2 ] == '"' ) {
- Sys_Printf( "Type guess: IBSP LUMP_ENTITIES\n" );
- }
- else if ( strstr( lumpString, "textures/" ) ) {
- Sys_Printf( "Type guess: IBSP LUMP_SHADERS\n" );
- }
- else
- {
- /* guess based on size/count */
- for ( lumpTest = lumpTests; lumpTest->radix > 0; lumpTest++ )
- {
- if ( ( length % lumpTest->radix ) != 0 ) {
- continue;
- }
- count = length / lumpTest->radix;
- if ( count < lumpTest->minCount ) {
- continue;
- }
- Sys_Printf( "Type guess: %s (%d x %d)\n", lumpTest->name, count, lumpTest->radix );
- }
- }
- }
-
- Sys_Printf( "---------------------------------------\n" );
-
- /* end of file */
- if ( offset + length >= size ) {
- break;
- }
- }
-
- /* last stats */
- Sys_Printf( "Lump count: %d\n", i + 1 );
- Sys_Printf( "File size: %d bytes\n", size );
-
- /* return to caller */
- return 0;
-}
-
-
-
-/*
- BSPInfo()
- emits statistics about the bsp file
- */
-
-int BSPInfo( int count, char **fileNames ){
- int i;
- char source[ 1024 ], ext[ 64 ];
- int size;
- FILE *f;
-
-
- /* dummy check */
- if ( count < 1 ) {
- Sys_Printf( "No files to dump info for.\n" );
- return -1;
- }
-
- /* enable info mode */
- infoMode = qtrue;
-
- /* walk file list */
- for ( i = 0; i < count; i++ )
- {
- Sys_Printf( "---------------------------------\n" );
-
- /* mangle filename and get size */
- strcpy( source, fileNames[ i ] );
- ExtractFileExtension( source, ext );
- if ( !Q_stricmp( ext, "map" ) ) {
- StripExtension( source );
- }
- DefaultExtension( source, ".bsp" );
- f = fopen( source, "rb" );
- if ( f ) {
- size = Q_filelength( f );
- fclose( f );
- }
- else{
- size = 0;
- }
-
- /* load the bsp file and print lump sizes */
- Sys_Printf( "%s\n", source );
- LoadBSPFile( source );
- PrintBSPFileSizes();
-
- /* print sizes */
- Sys_Printf( "\n" );
- Sys_Printf( " total %9d\n", size );
- Sys_Printf( " %9d KB\n", size / 1024 );
- Sys_Printf( " %9d MB\n", size / ( 1024 * 1024 ) );
-
- Sys_Printf( "---------------------------------\n" );
- }
-
- /* return count */
- return i;
-}
-
-
-static void ExtrapolateTexcoords( const float *axyz, const float *ast, const float *bxyz, const float *bst, const float *cxyz, const float *cst, const float *axyz_new, float *ast_out, const float *bxyz_new, float *bst_out, const float *cxyz_new, float *cst_out ){
- vec4_t scoeffs, tcoeffs;
- float md;
- m4x4_t solvematrix;
-
- vec3_t norm;
- vec3_t dab, dac;
- VectorSubtract( bxyz, axyz, dab );
- VectorSubtract( cxyz, axyz, dac );
- CrossProduct( dab, dac, norm );
-
- // assume:
- // s = f(x, y, z)
- // s(v + norm) = s(v) when n ortho xyz
-
- // s(v) = DotProduct(v, scoeffs) + scoeffs[3]
-
- // solve:
- // scoeffs * (axyz, 1) == ast[0]
- // scoeffs * (bxyz, 1) == bst[0]
- // scoeffs * (cxyz, 1) == cst[0]
- // scoeffs * (norm, 0) == 0
- // scoeffs * [axyz, 1 | bxyz, 1 | cxyz, 1 | norm, 0] = [ast[0], bst[0], cst[0], 0]
- solvematrix[0] = axyz[0];
- solvematrix[4] = axyz[1];
- solvematrix[8] = axyz[2];
- solvematrix[12] = 1;
- solvematrix[1] = bxyz[0];
- solvematrix[5] = bxyz[1];
- solvematrix[9] = bxyz[2];
- solvematrix[13] = 1;
- solvematrix[2] = cxyz[0];
- solvematrix[6] = cxyz[1];
- solvematrix[10] = cxyz[2];
- solvematrix[14] = 1;
- solvematrix[3] = norm[0];
- solvematrix[7] = norm[1];
- solvematrix[11] = norm[2];
- solvematrix[15] = 0;
-
- md = m4_det( solvematrix );
- if ( md * md < 1e-10 ) {
- Sys_Printf( "Cannot invert some matrix, some texcoords aren't extrapolated!" );
- return;
- }
-
- m4x4_invert( solvematrix );
-
- scoeffs[0] = ast[0];
- scoeffs[1] = bst[0];
- scoeffs[2] = cst[0];
- scoeffs[3] = 0;
- m4x4_transform_vec4( solvematrix, scoeffs );
- tcoeffs[0] = ast[1];
- tcoeffs[1] = bst[1];
- tcoeffs[2] = cst[1];
- tcoeffs[3] = 0;
- m4x4_transform_vec4( solvematrix, tcoeffs );
-
- ast_out[0] = scoeffs[0] * axyz_new[0] + scoeffs[1] * axyz_new[1] + scoeffs[2] * axyz_new[2] + scoeffs[3];
- ast_out[1] = tcoeffs[0] * axyz_new[0] + tcoeffs[1] * axyz_new[1] + tcoeffs[2] * axyz_new[2] + tcoeffs[3];
- bst_out[0] = scoeffs[0] * bxyz_new[0] + scoeffs[1] * bxyz_new[1] + scoeffs[2] * bxyz_new[2] + scoeffs[3];
- bst_out[1] = tcoeffs[0] * bxyz_new[0] + tcoeffs[1] * bxyz_new[1] + tcoeffs[2] * bxyz_new[2] + tcoeffs[3];
- cst_out[0] = scoeffs[0] * cxyz_new[0] + scoeffs[1] * cxyz_new[1] + scoeffs[2] * cxyz_new[2] + scoeffs[3];
- cst_out[1] = tcoeffs[0] * cxyz_new[0] + tcoeffs[1] * cxyz_new[1] + tcoeffs[2] * cxyz_new[2] + tcoeffs[3];
-}
+#include <glib.h>
/*
- ScaleBSPMain()
- amaze and confuse your enemies with wierd scaled maps!
+ Random()
+ returns a pseudorandom number between 0 and 1
*/
-int ScaleBSPMain( int argc, char **argv ){
- int i, j;
- float f, a;
- vec3_t scale;
- vec3_t vec;
- char str[ 1024 ];
- int uniform, axis;
- qboolean texscale;
- float *old_xyzst = NULL;
- float spawn_ref = 0;
+vec_t Random( void ){
+ return (vec_t) rand() / RAND_MAX;
+}
- /* arg checking */
- if ( argc < 3 ) {
- Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
- return 0;
+char *Q_strncpyz( char *dst, const char *src, size_t len ) {
+ if ( len == 0 ) {
+ abort();
}
- texscale = qfalse;
- for ( i = 1; i < argc - 2; ++i )
- {
- if ( !strcmp( argv[i], "-tex" ) ) {
- texscale = qtrue;
- }
- else if ( !strcmp( argv[i], "-spawn_ref" ) ) {
- spawn_ref = atof( argv[i + 1] );
- ++i;
- }
- else{
- break;
- }
- }
+ strncpy( dst, src, len );
+ dst[ len - 1 ] = '\0';
+ return dst;
+}
- /* get scale */
- // if(argc-2 >= i) // always true
- scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
- if ( argc - 3 >= i ) {
- scale[1] = scale[0] = atof( argv[ argc - 3 ] );
- }
- if ( argc - 4 >= i ) {
- scale[0] = atof( argv[ argc - 4 ] );
- }
- uniform = ( ( scale[0] == scale[1] ) && ( scale[1] == scale[2] ) );
+char *Q_strcat( char *dst, size_t dlen, const char *src ) {
+ size_t n = strlen( dst );
- if ( scale[0] == 0.0f || scale[1] == 0.0f || scale[2] == 0.0f ) {
- Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
- Sys_Printf( "Non-zero scale value required.\n" );
- return 0;
+ if ( n > dlen ) {
+ abort(); /* buffer overflow */
}
- /* do some path mangling */
- strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
- StripExtension( source );
- DefaultExtension( source, ".bsp" );
-
- /* load the bsp */
- Sys_Printf( "Loading %s\n", source );
- LoadBSPFile( source );
- ParseEntities();
-
- /* note it */
- Sys_Printf( "--- ScaleBSP ---\n" );
- Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities );
-
- /* scale entity keys */
- for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
- {
- /* scale origin */
- GetVectorForKey( &entities[ i ], "origin", vec );
- if ( ( vec[ 0 ] || vec[ 1 ] || vec[ 2 ] ) ) {
- if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
- vec[2] += spawn_ref;
- }
- vec[0] *= scale[0];
- vec[1] *= scale[1];
- vec[2] *= scale[2];
- if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
- vec[2] -= spawn_ref;
- }
- sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
- SetKeyValue( &entities[ i ], "origin", str );
- }
-
- a = FloatForKey( &entities[ i ], "angle" );
- if ( a == -1 || a == -2 ) { // z scale
- axis = 2;
- }
- else if ( fabs( sin( DEG2RAD( a ) ) ) < 0.707 ) {
- axis = 0;
- }
- else{
- axis = 1;
- }
-
- /* scale door lip */
- f = FloatForKey( &entities[ i ], "lip" );
- if ( f ) {
- f *= scale[axis];
- sprintf( str, "%f", f );
- SetKeyValue( &entities[ i ], "lip", str );
- }
-
- /* scale plat height */
- f = FloatForKey( &entities[ i ], "height" );
- if ( f ) {
- f *= scale[2];
- sprintf( str, "%f", f );
- SetKeyValue( &entities[ i ], "height", str );
- }
-
- // TODO maybe allow a definition file for entities to specify which values are scaled how?
- }
+ return Q_strncpyz( dst + n, src, dlen - n );
+}
- /* scale models */
- for ( i = 0; i < numBSPModels; i++ )
- {
- bspModels[ i ].mins[0] *= scale[0];
- bspModels[ i ].mins[1] *= scale[1];
- bspModels[ i ].mins[2] *= scale[2];
- bspModels[ i ].maxs[0] *= scale[0];
- bspModels[ i ].maxs[1] *= scale[1];
- bspModels[ i ].maxs[2] *= scale[2];
- }
- /* scale nodes */
- for ( i = 0; i < numBSPNodes; i++ )
- {
- bspNodes[ i ].mins[0] *= scale[0];
- bspNodes[ i ].mins[1] *= scale[1];
- bspNodes[ i ].mins[2] *= scale[2];
- bspNodes[ i ].maxs[0] *= scale[0];
- bspNodes[ i ].maxs[1] *= scale[1];
- bspNodes[ i ].maxs[2] *= scale[2];
- }
+char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen ) {
+ size_t n = strlen( dst );
- /* scale leafs */
- for ( i = 0; i < numBSPLeafs; i++ )
- {
- bspLeafs[ i ].mins[0] *= scale[0];
- bspLeafs[ i ].mins[1] *= scale[1];
- bspLeafs[ i ].mins[2] *= scale[2];
- bspLeafs[ i ].maxs[0] *= scale[0];
- bspLeafs[ i ].maxs[1] *= scale[1];
- bspLeafs[ i ].maxs[2] *= scale[2];
- }
-
- if ( texscale ) {
- Sys_Printf( "Using texture unlocking (and probably breaking texture alignment a lot)\n" );
- old_xyzst = safe_malloc( sizeof( *old_xyzst ) * numBSPDrawVerts * 5 );
- for ( i = 0; i < numBSPDrawVerts; i++ )
- {
- old_xyzst[5 * i + 0] = bspDrawVerts[i].xyz[0];
- old_xyzst[5 * i + 1] = bspDrawVerts[i].xyz[1];
- old_xyzst[5 * i + 2] = bspDrawVerts[i].xyz[2];
- old_xyzst[5 * i + 3] = bspDrawVerts[i].st[0];
- old_xyzst[5 * i + 4] = bspDrawVerts[i].st[1];
- }
+ if ( n > dlen ) {
+ abort(); /* buffer overflow */
}
- /* scale drawverts */
- for ( i = 0; i < numBSPDrawVerts; i++ )
- {
- bspDrawVerts[i].xyz[0] *= scale[0];
- bspDrawVerts[i].xyz[1] *= scale[1];
- bspDrawVerts[i].xyz[2] *= scale[2];
- bspDrawVerts[i].normal[0] /= scale[0];
- bspDrawVerts[i].normal[1] /= scale[1];
- bspDrawVerts[i].normal[2] /= scale[2];
- VectorNormalize( bspDrawVerts[i].normal, bspDrawVerts[i].normal );
- }
+ return Q_strncpyz( dst + n, src, MIN( slen, dlen - n ) );
+}
- if ( texscale ) {
- for ( i = 0; i < numBSPDrawSurfaces; i++ )
- {
- switch ( bspDrawSurfaces[i].surfaceType )
- {
- case SURFACE_FACE:
- case SURFACE_META:
- if ( bspDrawSurfaces[i].numIndexes % 3 ) {
- Error( "Not a triangulation!" );
- }
- for ( j = bspDrawSurfaces[i].firstIndex; j < bspDrawSurfaces[i].firstIndex + bspDrawSurfaces[i].numIndexes; j += 3 )
- {
- int ia = bspDrawIndexes[j] + bspDrawSurfaces[i].firstVert, ib = bspDrawIndexes[j + 1] + bspDrawSurfaces[i].firstVert, ic = bspDrawIndexes[j + 2] + bspDrawSurfaces[i].firstVert;
- bspDrawVert_t *a = &bspDrawVerts[ia], *b = &bspDrawVerts[ib], *c = &bspDrawVerts[ic];
- float *oa = &old_xyzst[ia * 5], *ob = &old_xyzst[ib * 5], *oc = &old_xyzst[ic * 5];
- // extrapolate:
- // a->xyz -> oa
- // b->xyz -> ob
- // c->xyz -> oc
- ExtrapolateTexcoords(
- &oa[0], &oa[3],
- &ob[0], &ob[3],
- &oc[0], &oc[3],
- a->xyz, a->st,
- b->xyz, b->st,
- c->xyz, c->st );
- }
- break;
- }
- }
- }
- /* scale planes */
- if ( uniform ) {
- for ( i = 0; i < numBSPPlanes; i++ )
- {
- bspPlanes[ i ].dist *= scale[0];
- }
- }
- else
- {
- for ( i = 0; i < numBSPPlanes; i++ )
- {
- bspPlanes[ i ].normal[0] /= scale[0];
- bspPlanes[ i ].normal[1] /= scale[1];
- bspPlanes[ i ].normal[2] /= scale[2];
- f = 1 / VectorLength( bspPlanes[i].normal );
- VectorScale( bspPlanes[i].normal, f, bspPlanes[i].normal );
- bspPlanes[ i ].dist *= f;
- }
- }
+/*
+ ExitQ3Map()
+ cleanup routine
+ */
- /* scale gridsize */
- GetVectorForKey( &entities[ 0 ], "gridsize", vec );
- if ( ( vec[ 0 ] + vec[ 1 ] + vec[ 2 ] ) == 0.0f ) {
- VectorCopy( gridSize, vec );
+static void ExitQ3Map( void ){
+ BSPFilesCleanup();
+ if ( mapDrawSurfs != NULL ) {
+ free( mapDrawSurfs );
}
- vec[0] *= scale[0];
- vec[1] *= scale[1];
- vec[2] *= scale[2];
- sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
- SetKeyValue( &entities[ 0 ], "gridsize", str );
-
- /* inject command line parameters */
- InjectCommandLine( argv, 0, argc - 1 );
-
- /* write the bsp */
- UnparseEntities();
- StripExtension( source );
- DefaultExtension( source, "_s.bsp" );
- Sys_Printf( "Writing %s\n", source );
- WriteBSPFile( source );
-
- /* return to sender */
- return 0;
}
/* shift origin */
GetVectorForKey( &entities[ i ], "origin", vec );
if ( ( vec[ 0 ] || vec[ 1 ] || vec[ 2 ] ) ) {
- if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
+ if ( !!strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
vec[2] += spawn_ref;
}
vec[0] += scale[0];
vec[1] += scale[1];
vec[2] += scale[2];
- if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
+ if ( !!strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
vec[2] -= spawn_ref;
}
sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
-/*
- PseudoCompileBSP()
- a stripped down ProcessModels
- */
-void PseudoCompileBSP( qboolean need_tree ){
- int models;
- char modelValue[10];
- entity_t *entity;
- face_t *faces;
- tree_t *tree;
- node_t *node;
- brush_t *brush;
- side_t *side;
- int i;
-
- SetDrawSurfacesBuffer();
- mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
- memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
- numMapDrawSurfs = 0;
-
- BeginBSPFile();
- models = 1;
- for ( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ )
- {
- /* get entity */
- entity = &entities[ mapEntityNum ];
- if ( entity->brushes == NULL && entity->patches == NULL ) {
- continue;
- }
-
- if ( mapEntityNum != 0 ) {
- sprintf( modelValue, "*%d", models++ );
- SetKeyValue( entity, "model", modelValue );
- }
-
- /* process the model */
- Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
- BeginModel();
-
- entity->firstDrawSurf = numMapDrawSurfs;
-
- ClearMetaTriangles();
- PatchMapDrawSurfs( entity );
-
- if ( mapEntityNum == 0 && need_tree ) {
- faces = MakeStructuralBSPFaceList( entities[0].brushes );
- tree = FaceBSP( faces );
- node = tree->headnode;
- }
- else
- {
- node = AllocNode();
- node->planenum = PLANENUM_LEAF;
- tree = AllocTree();
- tree->headnode = node;
- }
-
- /* a minimized ClipSidesIntoTree */
- for ( brush = entity->brushes; brush; brush = brush->next )
- {
- /* walk the brush sides */
- for ( i = 0; i < brush->numsides; i++ )
- {
- /* get side */
- side = &brush->sides[ i ];
- if ( side->winding == NULL ) {
- continue;
- }
- /* shader? */
- if ( side->shaderInfo == NULL ) {
- continue;
- }
- /* save this winding as a visible surface */
- DrawSurfaceForSide( entity, brush, side, side->winding );
- }
- }
-
- if ( meta ) {
- ClassifyEntitySurfaces( entity );
- MakeEntityDecals( entity );
- MakeEntityMetaTriangles( entity );
- SmoothMetaTriangles();
- MergeMetaTriangles();
- }
- FilterDrawsurfsIntoTree( entity, tree );
-
- FilterStructuralBrushesIntoTree( entity, tree );
- FilterDetailBrushesIntoTree( entity, tree );
-
- EmitBrushes( entity->brushes, &entity->firstBrush, &entity->numBrushes );
- EndModel( entity, node );
- }
- EndBSPFile( qfalse );
-}
-
-/*
- ConvertBSPMain()
- main argument processing function for bsp conversion
- */
-
-int ConvertBSPMain( int argc, char **argv ){
- int i;
- int ( *convertFunc )( char * );
- game_t *convertGame;
- char ext[1024];
- qboolean map_allowed, force_bsp, force_map;
-
-
- /* set default */
- convertFunc = ConvertBSPToASE;
- convertGame = NULL;
- map_allowed = qfalse;
- force_bsp = qfalse;
- force_map = qfalse;
-
- /* arg checking */
- if ( argc < 1 ) {
- Sys_Printf( "Usage: q3map -convert [-format <ase|obj|map_bp|map>] [-shadersasbitmap|-lightmapsastexcoord|-deluxemapsastexcoord] [-readbsp|-readmap [-meta|-patchmeta]] [-v] <mapname>\n" );
- return 0;
- }
-
- /* process arguments */
- for ( i = 1; i < ( argc - 1 ); i++ )
- {
- /* -format map|ase|... */
- if ( !strcmp( argv[ i ], "-format" ) ) {
- i++;
- if ( !Q_stricmp( argv[ i ], "ase" ) ) {
- convertFunc = ConvertBSPToASE;
- map_allowed = qfalse;
- }
- else if ( !Q_stricmp( argv[ i ], "obj" ) ) {
- convertFunc = ConvertBSPToOBJ;
- map_allowed = qfalse;
- }
- else if ( !Q_stricmp( argv[ i ], "map_bp" ) ) {
- convertFunc = ConvertBSPToMap_BP;
- map_allowed = qtrue;
- }
- else if ( !Q_stricmp( argv[ i ], "map" ) ) {
- convertFunc = ConvertBSPToMap;
- map_allowed = qtrue;
- }
- else
- {
- convertGame = GetGame( argv[ i ] );
- map_allowed = qfalse;
- if ( convertGame == NULL ) {
- Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] );
- }
- }
- }
- else if ( !strcmp( argv[ i ], "-ne" ) ) {
- normalEpsilon = atof( argv[ i + 1 ] );
- i++;
- Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon );
- }
- else if ( !strcmp( argv[ i ], "-de" ) ) {
- distanceEpsilon = atof( argv[ i + 1 ] );
- i++;
- Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon );
- }
- else if ( !strcmp( argv[ i ], "-shaderasbitmap" ) || !strcmp( argv[ i ], "-shadersasbitmap" ) ) {
- shadersAsBitmap = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-lightmapastexcoord" ) || !strcmp( argv[ i ], "-lightmapsastexcoord" ) ) {
- lightmapsAsTexcoord = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-deluxemapastexcoord" ) || !strcmp( argv[ i ], "-deluxemapsastexcoord" ) ) {
- lightmapsAsTexcoord = qtrue;
- deluxemap = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-readbsp" ) ) {
- force_bsp = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-readmap" ) ) {
- force_map = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-meta" ) ) {
- meta = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-patchmeta" ) ) {
- meta = qtrue;
- patchMeta = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-fast" ) ) {
- fast = qtrue;
- }
- }
-
- LoadShaderInfo();
-
- /* clean up map name */
- strcpy( source, ExpandArg( argv[i] ) );
- ExtractFileExtension( source, ext );
-
- if ( !map_allowed && !force_map ) {
- force_bsp = qtrue;
- }
-
- if ( force_map || ( !force_bsp && !Q_stricmp( ext, "map" ) && map_allowed ) ) {
- if ( !map_allowed ) {
- Sys_Printf( "WARNING: the requested conversion should not be done from .map files. Compile a .bsp first.\n" );
- }
- StripExtension( source );
- DefaultExtension( source, ".map" );
- Sys_Printf( "Loading %s\n", source );
- LoadMapFile( source, qfalse, convertGame == NULL );
- PseudoCompileBSP( convertGame != NULL );
- }
- else
- {
- StripExtension( source );
- DefaultExtension( source, ".bsp" );
- Sys_Printf( "Loading %s\n", source );
- LoadBSPFile( source );
- ParseEntities();
- }
-
- /* bsp format convert? */
- if ( convertGame != NULL ) {
- /* set global game */
- game = convertGame;
-
- /* write bsp */
- StripExtension( source );
- DefaultExtension( source, "_c.bsp" );
- Sys_Printf( "Writing %s\n", source );
- WriteBSPFile( source );
-
- /* return to sender */
- return 0;
- }
-
- /* normal convert */
- return convertFunc( source );
-}
-
-
-
/*
main()
q3map mojo...
int main( int argc, char **argv ){
int i, r;
double start, end;
+ extern qboolean werror;
#ifdef WIN32
_setmaxstdio(2048);
argv[ i ] = NULL;
}
+ /* make all warnings into errors */
+ else if ( !strcmp( argv[ i ], "-werror" ) ) {
+ werror = qtrue;
+ argv[ i ] = NULL;
+ }
+
/* patch subdivisions */
else if ( !strcmp( argv[ i ], "-subdivisions" ) ) {
argv[ i ] = NULL;
/* fixaas */
if ( !strcmp( argv[ 1 ], "-fixaas" ) ) {
- r = FixAAS( argc - 1, argv + 1 );
+ r = FixAASMain( argc - 1, argv + 1 );
}
/* analyze */
else if ( !strcmp( argv[ 1 ], "-analyze" ) ) {
- r = AnalyzeBSP( argc - 1, argv + 1 );
+ r = AnalyzeBSPMain( argc - 1, argv + 1 );
}
/* info */
else if ( !strcmp( argv[ 1 ], "-info" ) ) {
- r = BSPInfo( argc - 2, argv + 2 );
+ r = BSPInfoMain( argc - 2, argv + 2 );
}
/* vis */
/* vlight */
else if ( !strcmp( argv[ 1 ], "-vlight" ) ) {
- Sys_Printf( "WARNING: VLight is no longer supported, defaulting to -light -fast instead\n\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: VLight is no longer supported, defaulting to -light -fast instead\n\n" );
argv[ 1 ] = "-fast"; /* eek a hack */
r = LightMain( argc, argv );
}
value = ValueForKey( e, "layers" );
}
if ( value[ 0 ] == '\0' ) {
- Sys_Printf( "WARNING: Entity with index/alpha map \"%s\" has missing \"_layers\" or \"layers\" key\n", indexMapFilename );
+ Sys_FPrintf( SYS_WRN, "WARNING: Entity with index/alpha map \"%s\" has missing \"_layers\" or \"layers\" key\n", indexMapFilename );
Sys_Printf( "Entity will not be textured properly. Check your keys/values.\n" );
return;
}
numLayers = atoi( value );
if ( numLayers < 1 ) {
- Sys_Printf( "WARNING: Entity with index/alpha map \"%s\" has < 1 layer (%d)\n", indexMapFilename, numLayers );
+ Sys_FPrintf( SYS_WRN, "WARNING: Entity with index/alpha map \"%s\" has < 1 layer (%d)\n", indexMapFilename, numLayers );
Sys_Printf( "Entity will not be textured properly. Check your keys/values.\n" );
return;
}
value = ValueForKey( e, "shader" );
}
if ( value[ 0 ] == '\0' ) {
- Sys_Printf( "WARNING: Entity with index/alpha map \"%s\" has missing \"_shader\" or \"shader\" key\n", indexMapFilename );
+ Sys_FPrintf( SYS_WRN, "WARNING: Entity with index/alpha map \"%s\" has missing \"_shader\" or \"shader\" key\n", indexMapFilename );
Sys_Printf( "Entity will not be textured properly. Check your keys/values.\n" );
return;
}
/* the index map must be at least 2x2 pixels */
if ( w < 2 || h < 2 ) {
- Sys_Printf( "WARNING: Entity with index/alpha map \"%s\" is smaller than 2x2 pixels\n", indexMapFilename );
+ Sys_FPrintf( SYS_WRN, "WARNING: Entity with index/alpha map \"%s\" is smaller than 2x2 pixels\n", indexMapFilename );
Sys_Printf( "Entity will not be textured properly. Check your keys/values.\n" );
free( pixels );
return;
/* conformance check */
if ( strcmp( token, "{" ) ) {
- Sys_Printf( "WARNING: ParseEntity: { not found, found %s on line %d - last entity was at: <%4.2f, %4.2f, %4.2f>...\n"
+ Sys_FPrintf( SYS_WRN, "WARNING: ParseEntity: { not found, found %s on line %d - last entity was at: <%4.2f, %4.2f, %4.2f>...\n"
"Continuing to process map, but resulting BSP may be invalid.\n",
token, scriptline, entities[ numEntities ].origin[ 0 ], entities[ numEntities ].origin[ 1 ], entities[ numEntities ].origin[ 2 ] );
return qfalse;
{
/* get initial token */
if ( !GetToken( qtrue ) ) {
- Sys_Printf( "WARNING: ParseEntity: EOF without closing brace\n"
+ Sys_FPrintf( SYS_WRN, "WARNING: ParseEntity: EOF without closing brace\n"
"Continuing to process map, but resulting BSP may be invalid.\n" );
return qfalse;
}
}
else if ( !strcmp( token, "terrainDef" ) ) {
//% ParseTerrain();
- Sys_Printf( "WARNING: Terrain entity parsing not supported in this build.\n" ); /* ydnar */
+ Sys_FPrintf( SYS_WRN, "WARNING: Terrain entity parsing not supported in this build.\n" ); /* ydnar */
}
else if ( !strcmp( token, "brushDef" ) ) {
if ( g_bBrushPrimit == BPRIMIT_OLDBRUSHES ) {
/* get brush counts */
numMapBrushes = CountBrushList( entities[ 0 ].brushes );
if ( (float) c_detail / (float) numMapBrushes < 0.10f && numMapBrushes > 500 ) {
- Sys_Printf( "WARNING: Over 90 percent structural map detected. Compile time may be adversely affected.\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Over 90 percent structural map detected. Compile time may be adversely affected.\n" );
}
/* emit some statistics */
--- /dev/null
+/* -------------------------------------------------------------------------------
+
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant 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.
+
+ GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ -------------------------------------------------------------------------------
+
+ This code has been altered significantly from its original form, to support
+ several games based on the Quake III Arena engine, in the form of "Q3Map2."
+
+ ------------------------------------------------------------------------------- */
+
+
+
+/* dependencies */
+#include "q3map2.h"
+
+/* minimap stuff */
+
+typedef struct minimap_s
+{
+ bspModel_t *model;
+ int width;
+ int height;
+ int samples;
+ float *sample_offsets;
+ float sharpen_boxmult;
+ float sharpen_centermult;
+ float boost, brightness, contrast;
+ float *data1f;
+ float *sharpendata1f;
+ vec3_t mins, size;
+}
+minimap_t;
+
+static minimap_t minimap;
+
+qboolean BrushIntersectionWithLine( bspBrush_t *brush, vec3_t start, vec3_t dir, float *t_in, float *t_out ){
+ int i;
+ qboolean in = qfalse, out = qfalse;
+ bspBrushSide_t *sides = &bspBrushSides[brush->firstSide];
+
+ for ( i = 0; i < brush->numSides; ++i )
+ {
+ bspPlane_t *p = &bspPlanes[sides[i].planeNum];
+ float sn = DotProduct( start, p->normal );
+ float dn = DotProduct( dir, p->normal );
+ if ( dn == 0 ) {
+ if ( sn > p->dist ) {
+ return qfalse; // outside!
+ }
+ }
+ else
+ {
+ float t = ( p->dist - sn ) / dn;
+ if ( dn < 0 ) {
+ if ( !in || t > *t_in ) {
+ *t_in = t;
+ in = qtrue;
+ // as t_in can only increase, and t_out can only decrease, early out
+ if ( out && *t_in >= *t_out ) {
+ return qfalse;
+ }
+ }
+ }
+ else
+ {
+ if ( !out || t < *t_out ) {
+ *t_out = t;
+ out = qtrue;
+ // as t_in can only increase, and t_out can only decrease, early out
+ if ( in && *t_in >= *t_out ) {
+ return qfalse;
+ }
+ }
+ }
+ }
+ }
+ return in && out;
+}
+
+static float MiniMapSample( float x, float y ){
+ vec3_t org, dir;
+ int i, bi;
+ float t0, t1;
+ float samp;
+ bspBrush_t *b;
+ bspBrushSide_t *s;
+ int cnt;
+
+ org[0] = x;
+ org[1] = y;
+ org[2] = 0;
+ dir[0] = 0;
+ dir[1] = 0;
+ dir[2] = 1;
+
+ cnt = 0;
+ samp = 0;
+ for ( i = 0; i < minimap.model->numBSPBrushes; ++i )
+ {
+ bi = minimap.model->firstBSPBrush + i;
+ if ( opaqueBrushes[bi >> 3] & ( 1 << ( bi & 7 ) ) ) {
+ b = &bspBrushes[bi];
+
+ // sort out mins/maxs of the brush
+ s = &bspBrushSides[b->firstSide];
+ if ( x < -bspPlanes[s[0].planeNum].dist ) {
+ continue;
+ }
+ if ( x > +bspPlanes[s[1].planeNum].dist ) {
+ continue;
+ }
+ if ( y < -bspPlanes[s[2].planeNum].dist ) {
+ continue;
+ }
+ if ( y > +bspPlanes[s[3].planeNum].dist ) {
+ continue;
+ }
+
+ if ( BrushIntersectionWithLine( b, org, dir, &t0, &t1 ) ) {
+ samp += t1 - t0;
+ ++cnt;
+ }
+ }
+ }
+
+ return samp;
+}
+
+void RandomVector2f( float v[2] ){
+ do
+ {
+ v[0] = 2 * Random() - 1;
+ v[1] = 2 * Random() - 1;
+ }
+ while ( v[0] * v[0] + v[1] * v[1] > 1 );
+}
+
+static void MiniMapRandomlySupersampled( int y ){
+ int x, i;
+ float *p = &minimap.data1f[y * minimap.width];
+ float ymin = minimap.mins[1] + minimap.size[1] * ( y / (float) minimap.height );
+ float dx = minimap.size[0] / (float) minimap.width;
+ float dy = minimap.size[1] / (float) minimap.height;
+ float uv[2];
+ float thisval;
+
+ for ( x = 0; x < minimap.width; ++x )
+ {
+ float xmin = minimap.mins[0] + minimap.size[0] * ( x / (float) minimap.width );
+ float val = 0;
+
+ for ( i = 0; i < minimap.samples; ++i )
+ {
+ RandomVector2f( uv );
+ thisval = MiniMapSample(
+ xmin + ( uv[0] + 0.5 ) * dx, /* exaggerated random pattern for better results */
+ ymin + ( uv[1] + 0.5 ) * dy /* exaggerated random pattern for better results */
+ );
+ val += thisval;
+ }
+ val /= minimap.samples * minimap.size[2];
+ *p++ = val;
+ }
+}
+
+static void MiniMapSupersampled( int y ){
+ int x, i;
+ float *p = &minimap.data1f[y * minimap.width];
+ float ymin = minimap.mins[1] + minimap.size[1] * ( y / (float) minimap.height );
+ float dx = minimap.size[0] / (float) minimap.width;
+ float dy = minimap.size[1] / (float) minimap.height;
+
+ for ( x = 0; x < minimap.width; ++x )
+ {
+ float xmin = minimap.mins[0] + minimap.size[0] * ( x / (float) minimap.width );
+ float val = 0;
+
+ for ( i = 0; i < minimap.samples; ++i )
+ {
+ float thisval = MiniMapSample(
+ xmin + minimap.sample_offsets[2 * i + 0] * dx,
+ ymin + minimap.sample_offsets[2 * i + 1] * dy
+ );
+ val += thisval;
+ }
+ val /= minimap.samples * minimap.size[2];
+ *p++ = val;
+ }
+}
+
+static void MiniMapNoSupersampling( int y ){
+ int x;
+ float *p = &minimap.data1f[y * minimap.width];
+ float ymin = minimap.mins[1] + minimap.size[1] * ( ( y + 0.5 ) / (float) minimap.height );
+
+ for ( x = 0; x < minimap.width; ++x )
+ {
+ float xmin = minimap.mins[0] + minimap.size[0] * ( ( x + 0.5 ) / (float) minimap.width );
+ *p++ = MiniMapSample( xmin, ymin ) / minimap.size[2];
+ }
+}
+
+static void MiniMapSharpen( int y ){
+ int x;
+ qboolean up = ( y > 0 );
+ qboolean down = ( y < minimap.height - 1 );
+ float *p = &minimap.data1f[y * minimap.width];
+ float *q = &minimap.sharpendata1f[y * minimap.width];
+
+ for ( x = 0; x < minimap.width; ++x )
+ {
+ qboolean left = ( x > 0 );
+ qboolean right = ( x < minimap.width - 1 );
+ float val = p[0] * minimap.sharpen_centermult;
+
+ if ( left && up ) {
+ val += p[-1 - minimap.width] * minimap.sharpen_boxmult;
+ }
+ if ( left && down ) {
+ val += p[-1 + minimap.width] * minimap.sharpen_boxmult;
+ }
+ if ( right && up ) {
+ val += p[+1 - minimap.width] * minimap.sharpen_boxmult;
+ }
+ if ( right && down ) {
+ val += p[+1 + minimap.width] * minimap.sharpen_boxmult;
+ }
+
+ if ( left ) {
+ val += p[-1] * minimap.sharpen_boxmult;
+ }
+ if ( right ) {
+ val += p[+1] * minimap.sharpen_boxmult;
+ }
+ if ( up ) {
+ val += p[-minimap.width] * minimap.sharpen_boxmult;
+ }
+ if ( down ) {
+ val += p[+minimap.width] * minimap.sharpen_boxmult;
+ }
+
+ ++p;
+ *q++ = val;
+ }
+}
+
+static void MiniMapContrastBoost( int y ){
+ int x;
+ float *q = &minimap.data1f[y * minimap.width];
+ for ( x = 0; x < minimap.width; ++x )
+ {
+ *q = *q * minimap.boost / ( ( minimap.boost - 1 ) * *q + 1 );
+ ++q;
+ }
+}
+
+static void MiniMapBrightnessContrast( int y ){
+ int x;
+ float *q = &minimap.data1f[y * minimap.width];
+ for ( x = 0; x < minimap.width; ++x )
+ {
+ *q = *q * minimap.contrast + minimap.brightness;
+ ++q;
+ }
+}
+
+void MiniMapMakeMinsMaxs( vec3_t mins_in, vec3_t maxs_in, float border, qboolean keepaspect ){
+ vec3_t mins, maxs, extend;
+ VectorCopy( mins_in, mins );
+ VectorCopy( maxs_in, maxs );
+
+ // line compatible to nexuiz mapinfo
+ Sys_Printf( "size %f %f %f %f %f %f\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2] );
+
+ if ( keepaspect ) {
+ VectorSubtract( maxs, mins, extend );
+ if ( extend[1] > extend[0] ) {
+ mins[0] -= ( extend[1] - extend[0] ) * 0.5;
+ maxs[0] += ( extend[1] - extend[0] ) * 0.5;
+ }
+ else
+ {
+ mins[1] -= ( extend[0] - extend[1] ) * 0.5;
+ maxs[1] += ( extend[0] - extend[1] ) * 0.5;
+ }
+ }
+
+ /* border: amount of black area around the image */
+ /* input: border, 1-2*border, border but we need border/(1-2*border) */
+
+ VectorSubtract( maxs, mins, extend );
+ VectorScale( extend, border / ( 1 - 2 * border ), extend );
+
+ VectorSubtract( mins, extend, mins );
+ VectorAdd( maxs, extend, maxs );
+
+ VectorCopy( mins, minimap.mins );
+ VectorSubtract( maxs, mins, minimap.size );
+
+ // line compatible to nexuiz mapinfo
+ Sys_Printf( "size_texcoords %f %f %f %f %f %f\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2] );
+}
+
+/*
+ MiniMapSetupBrushes()
+ determines solid non-sky brushes in the world
+ */
+
+void MiniMapSetupBrushes( void ){
+ SetupBrushesFlags( C_SOLID | C_SKY, C_SOLID, 0, 0 );
+ // at least one must be solid
+ // none may be sky
+ // not all may be nodraw
+}
+
+qboolean MiniMapEvaluateSampleOffsets( int *bestj, int *bestk, float *bestval ){
+ float val, dx, dy;
+ int j, k;
+
+ *bestj = *bestk = -1;
+ *bestval = 3; /* max possible val is 2 */
+
+ for ( j = 0; j < minimap.samples; ++j )
+ for ( k = j + 1; k < minimap.samples; ++k )
+ {
+ dx = minimap.sample_offsets[2 * j + 0] - minimap.sample_offsets[2 * k + 0];
+ dy = minimap.sample_offsets[2 * j + 1] - minimap.sample_offsets[2 * k + 1];
+ if ( dx > +0.5 ) {
+ dx -= 1;
+ }
+ if ( dx < -0.5 ) {
+ dx += 1;
+ }
+ if ( dy > +0.5 ) {
+ dy -= 1;
+ }
+ if ( dy < -0.5 ) {
+ dy += 1;
+ }
+ val = dx * dx + dy * dy;
+ if ( val < *bestval ) {
+ *bestj = j;
+ *bestk = k;
+ *bestval = val;
+ }
+ }
+
+ return *bestval < 3;
+}
+
+void MiniMapMakeSampleOffsets(){
+ int i, j, k, jj, kk;
+ float val, valj, valk, sx, sy, rx, ry;
+
+ Sys_Printf( "Generating good sample offsets (this may take a while)...\n" );
+
+ /* start with entirely random samples */
+ for ( i = 0; i < minimap.samples; ++i )
+ {
+ minimap.sample_offsets[2 * i + 0] = Random();
+ minimap.sample_offsets[2 * i + 1] = Random();
+ }
+
+ for ( i = 0; i < 1000; ++i )
+ {
+ if ( MiniMapEvaluateSampleOffsets( &j, &k, &val ) ) {
+ sx = minimap.sample_offsets[2 * j + 0];
+ sy = minimap.sample_offsets[2 * j + 1];
+ minimap.sample_offsets[2 * j + 0] = rx = Random();
+ minimap.sample_offsets[2 * j + 1] = ry = Random();
+ if ( !MiniMapEvaluateSampleOffsets( &jj, &kk, &valj ) ) {
+ valj = -1;
+ }
+ minimap.sample_offsets[2 * j + 0] = sx;
+ minimap.sample_offsets[2 * j + 1] = sy;
+
+ sx = minimap.sample_offsets[2 * k + 0];
+ sy = minimap.sample_offsets[2 * k + 1];
+ minimap.sample_offsets[2 * k + 0] = rx;
+ minimap.sample_offsets[2 * k + 1] = ry;
+ if ( !MiniMapEvaluateSampleOffsets( &jj, &kk, &valk ) ) {
+ valk = -1;
+ }
+ minimap.sample_offsets[2 * k + 0] = sx;
+ minimap.sample_offsets[2 * k + 1] = sy;
+
+ if ( valj > valk ) {
+ if ( valj > val ) {
+ /* valj is the greatest */
+ minimap.sample_offsets[2 * j + 0] = rx;
+ minimap.sample_offsets[2 * j + 1] = ry;
+ i = -1;
+ }
+ else
+ {
+ /* valj is the greater and it is useless - forget it */
+ }
+ }
+ else
+ {
+ if ( valk > val ) {
+ /* valk is the greatest */
+ minimap.sample_offsets[2 * k + 0] = rx;
+ minimap.sample_offsets[2 * k + 1] = ry;
+ i = -1;
+ }
+ else
+ {
+ /* valk is the greater and it is useless - forget it */
+ }
+ }
+ }
+ else{
+ break;
+ }
+ }
+}
+
+void MergeRelativePath( char *out, const char *absolute, const char *relative ){
+ const char *endpos = absolute + strlen( absolute );
+ while ( endpos != absolute && ( endpos[-1] == '/' || endpos[-1] == '\\' ) )
+ --endpos;
+ while ( relative[0] == '.' && relative[1] == '.' && ( relative[2] == '/' || relative[2] == '\\' ) )
+ {
+ relative += 3;
+ while ( endpos != absolute )
+ {
+ --endpos;
+ if ( *endpos == '/' || *endpos == '\\' ) {
+ break;
+ }
+ }
+ while ( endpos != absolute && ( endpos[-1] == '/' || endpos[-1] == '\\' ) )
+ --endpos;
+ }
+ memcpy( out, absolute, endpos - absolute );
+ out[endpos - absolute] = '/';
+ strcpy( out + ( endpos - absolute + 1 ), relative );
+}
+
+int MiniMapBSPMain( int argc, char **argv ){
+ char minimapFilename[1024];
+ char basename[1024];
+ char path[1024];
+ char relativeMinimapFilename[1024];
+ qboolean autolevel;
+ float minimapSharpen;
+ float border;
+ byte *data4b, *p;
+ float *q;
+ int x, y;
+ int i;
+ miniMapMode_t mode;
+ vec3_t mins, maxs;
+ qboolean keepaspect;
+
+ /* arg checking */
+ if ( argc < 2 ) {
+ Sys_Printf( "Usage: q3map [-v] -minimap [-size n] [-sharpen f] [-samples n | -random n] [-o filename.tga] [-minmax Xmin Ymin Zmin Xmax Ymax Zmax] <mapname>\n" );
+ return 0;
+ }
+
+ /* load the BSP first */
+ strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
+ StripExtension( source );
+ DefaultExtension( source, ".bsp" );
+ Sys_Printf( "Loading %s\n", source );
+ LoadShaderInfo();
+ LoadBSPFile( source );
+
+ minimap.model = &bspModels[0];
+ VectorCopy( minimap.model->mins, mins );
+ VectorCopy( minimap.model->maxs, maxs );
+
+ *minimapFilename = 0;
+ minimapSharpen = game->miniMapSharpen;
+ minimap.width = minimap.height = game->miniMapSize;
+ border = game->miniMapBorder;
+ keepaspect = game->miniMapKeepAspect;
+ mode = game->miniMapMode;
+
+ autolevel = qfalse;
+ minimap.samples = 1;
+ minimap.sample_offsets = NULL;
+ minimap.boost = 1.0;
+ minimap.brightness = 0.0;
+ minimap.contrast = 1.0;
+
+ /* process arguments */
+ for ( i = 1; i < ( argc - 1 ); i++ )
+ {
+ if ( !strcmp( argv[ i ], "-size" ) ) {
+ minimap.width = minimap.height = atoi( argv[i + 1] );
+ i++;
+ Sys_Printf( "Image size set to %i\n", minimap.width );
+ }
+ else if ( !strcmp( argv[ i ], "-sharpen" ) ) {
+ minimapSharpen = atof( argv[i + 1] );
+ i++;
+ Sys_Printf( "Sharpening coefficient set to %f\n", minimapSharpen );
+ }
+ else if ( !strcmp( argv[ i ], "-samples" ) ) {
+ minimap.samples = atoi( argv[i + 1] );
+ i++;
+ Sys_Printf( "Samples set to %i\n", minimap.samples );
+ if ( minimap.sample_offsets ) {
+ free( minimap.sample_offsets );
+ }
+ minimap.sample_offsets = malloc( 2 * sizeof( *minimap.sample_offsets ) * minimap.samples );
+ MiniMapMakeSampleOffsets();
+ }
+ else if ( !strcmp( argv[ i ], "-random" ) ) {
+ minimap.samples = atoi( argv[i + 1] );
+ i++;
+ Sys_Printf( "Random samples set to %i\n", minimap.samples );
+ if ( minimap.sample_offsets ) {
+ free( minimap.sample_offsets );
+ }
+ minimap.sample_offsets = NULL;
+ }
+ else if ( !strcmp( argv[ i ], "-border" ) ) {
+ border = atof( argv[i + 1] );
+ i++;
+ Sys_Printf( "Border set to %f\n", border );
+ }
+ else if ( !strcmp( argv[ i ], "-keepaspect" ) ) {
+ keepaspect = qtrue;
+ Sys_Printf( "Keeping aspect ratio by letterboxing\n", border );
+ }
+ else if ( !strcmp( argv[ i ], "-nokeepaspect" ) ) {
+ keepaspect = qfalse;
+ Sys_Printf( "Not keeping aspect ratio\n", border );
+ }
+ else if ( !strcmp( argv[ i ], "-o" ) ) {
+ strcpy( minimapFilename, argv[i + 1] );
+ i++;
+ Sys_Printf( "Output file name set to %s\n", minimapFilename );
+ }
+ else if ( !strcmp( argv[ i ], "-minmax" ) && i < ( argc - 7 ) ) {
+ mins[0] = atof( argv[i + 1] );
+ mins[1] = atof( argv[i + 2] );
+ mins[2] = atof( argv[i + 3] );
+ maxs[0] = atof( argv[i + 4] );
+ maxs[1] = atof( argv[i + 5] );
+ maxs[2] = atof( argv[i + 6] );
+ i += 6;
+ Sys_Printf( "Map mins/maxs overridden\n" );
+ }
+ else if ( !strcmp( argv[ i ], "-gray" ) ) {
+ mode = MINIMAP_MODE_GRAY;
+ Sys_Printf( "Writing as white-on-black image\n" );
+ }
+ else if ( !strcmp( argv[ i ], "-black" ) ) {
+ mode = MINIMAP_MODE_BLACK;
+ Sys_Printf( "Writing as black alpha image\n" );
+ }
+ else if ( !strcmp( argv[ i ], "-white" ) ) {
+ mode = MINIMAP_MODE_WHITE;
+ Sys_Printf( "Writing as white alpha image\n" );
+ }
+ else if ( !strcmp( argv[ i ], "-boost" ) && i < ( argc - 2 ) ) {
+ minimap.boost = atof( argv[i + 1] );
+ i++;
+ Sys_Printf( "Contrast boost set to %f\n", minimap.boost );
+ }
+ else if ( !strcmp( argv[ i ], "-brightness" ) && i < ( argc - 2 ) ) {
+ minimap.brightness = atof( argv[i + 1] );
+ i++;
+ Sys_Printf( "Brightness set to %f\n", minimap.brightness );
+ }
+ else if ( !strcmp( argv[ i ], "-contrast" ) && i < ( argc - 2 ) ) {
+ minimap.contrast = atof( argv[i + 1] );
+ i++;
+ Sys_Printf( "Contrast set to %f\n", minimap.contrast );
+ }
+ else if ( !strcmp( argv[ i ], "-autolevel" ) ) {
+ autolevel = qtrue;
+ Sys_Printf( "Auto level enabled\n", border );
+ }
+ else if ( !strcmp( argv[ i ], "-noautolevel" ) ) {
+ autolevel = qfalse;
+ Sys_Printf( "Auto level disabled\n", border );
+ }
+ }
+
+ MiniMapMakeMinsMaxs( mins, maxs, border, keepaspect );
+
+ if ( !*minimapFilename ) {
+ ExtractFileBase( source, basename );
+ ExtractFilePath( source, path );
+ sprintf( relativeMinimapFilename, game->miniMapNameFormat, basename );
+ MergeRelativePath( minimapFilename, path, relativeMinimapFilename );
+ Sys_Printf( "Output file name automatically set to %s\n", minimapFilename );
+ }
+ ExtractFilePath( minimapFilename, path );
+ Q_mkdir( path );
+
+ if ( minimapSharpen >= 0 ) {
+ minimap.sharpen_centermult = 8 * minimapSharpen + 1;
+ minimap.sharpen_boxmult = -minimapSharpen;
+ }
+
+ minimap.data1f = safe_malloc( minimap.width * minimap.height * sizeof( *minimap.data1f ) );
+ data4b = safe_malloc( minimap.width * minimap.height * 4 );
+ if ( minimapSharpen >= 0 ) {
+ minimap.sharpendata1f = safe_malloc( minimap.width * minimap.height * sizeof( *minimap.data1f ) );
+ }
+
+ MiniMapSetupBrushes();
+
+ if ( minimap.samples <= 1 ) {
+ Sys_Printf( "\n--- MiniMapNoSupersampling (%d) ---\n", minimap.height );
+ RunThreadsOnIndividual( minimap.height, qtrue, MiniMapNoSupersampling );
+ }
+ else
+ {
+ if ( minimap.sample_offsets ) {
+ Sys_Printf( "\n--- MiniMapSupersampled (%d) ---\n", minimap.height );
+ RunThreadsOnIndividual( minimap.height, qtrue, MiniMapSupersampled );
+ }
+ else
+ {
+ Sys_Printf( "\n--- MiniMapRandomlySupersampled (%d) ---\n", minimap.height );
+ RunThreadsOnIndividual( minimap.height, qtrue, MiniMapRandomlySupersampled );
+ }
+ }
+
+ if ( minimap.boost != 1.0 ) {
+ Sys_Printf( "\n--- MiniMapContrastBoost (%d) ---\n", minimap.height );
+ RunThreadsOnIndividual( minimap.height, qtrue, MiniMapContrastBoost );
+ }
+
+ if ( autolevel ) {
+ Sys_Printf( "\n--- MiniMapAutoLevel (%d) ---\n", minimap.height );
+ float mi = 1, ma = 0;
+ float s, o;
+
+ // TODO threads!
+ q = minimap.data1f;
+ for ( y = 0; y < minimap.height; ++y )
+ for ( x = 0; x < minimap.width; ++x )
+ {
+ float v = *q++;
+ if ( v < mi ) {
+ mi = v;
+ }
+ if ( v > ma ) {
+ ma = v;
+ }
+ }
+ if ( ma > mi ) {
+ s = 1 / ( ma - mi );
+ o = mi / ( ma - mi );
+
+ // equations:
+ // brightness + contrast * v
+ // after autolevel:
+ // brightness + contrast * (v * s - o)
+ // =
+ // (brightness - contrast * o) + (contrast * s) * v
+ minimap.brightness = minimap.brightness - minimap.contrast * o;
+ minimap.contrast *= s;
+
+ Sys_Printf( "Auto level: Brightness changed to %f\n", minimap.brightness );
+ Sys_Printf( "Auto level: Contrast changed to %f\n", minimap.contrast );
+ }
+ else{
+ Sys_Printf( "Auto level: failed because all pixels are the same value\n" );
+ }
+ }
+
+ if ( minimap.brightness != 0 || minimap.contrast != 1 ) {
+ Sys_Printf( "\n--- MiniMapBrightnessContrast (%d) ---\n", minimap.height );
+ RunThreadsOnIndividual( minimap.height, qtrue, MiniMapBrightnessContrast );
+ }
+
+ if ( minimap.sharpendata1f ) {
+ Sys_Printf( "\n--- MiniMapSharpen (%d) ---\n", minimap.height );
+ RunThreadsOnIndividual( minimap.height, qtrue, MiniMapSharpen );
+ q = minimap.sharpendata1f;
+ }
+ else
+ {
+ q = minimap.data1f;
+ }
+
+ Sys_Printf( "\nConverting..." );
+
+ switch ( mode )
+ {
+ case MINIMAP_MODE_GRAY:
+ p = data4b;
+ for ( y = 0; y < minimap.height; ++y )
+ for ( x = 0; x < minimap.width; ++x )
+ {
+ byte b;
+ float v = *q++;
+ if ( v < 0 ) {
+ v = 0;
+ }
+ if ( v > 255.0 / 256.0 ) {
+ v = 255.0 / 256.0;
+ }
+ b = v * 256;
+ *p++ = b;
+ }
+ Sys_Printf( " writing to %s...", minimapFilename );
+ WriteTGAGray( minimapFilename, data4b, minimap.width, minimap.height );
+ break;
+ case MINIMAP_MODE_BLACK:
+ p = data4b;
+ for ( y = 0; y < minimap.height; ++y )
+ for ( x = 0; x < minimap.width; ++x )
+ {
+ byte b;
+ float v = *q++;
+ if ( v < 0 ) {
+ v = 0;
+ }
+ if ( v > 255.0 / 256.0 ) {
+ v = 255.0 / 256.0;
+ }
+ b = v * 256;
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = b;
+ }
+ Sys_Printf( " writing to %s...", minimapFilename );
+ WriteTGA( minimapFilename, data4b, minimap.width, minimap.height );
+ break;
+ case MINIMAP_MODE_WHITE:
+ p = data4b;
+ for ( y = 0; y < minimap.height; ++y )
+ for ( x = 0; x < minimap.width; ++x )
+ {
+ byte b;
+ float v = *q++;
+ if ( v < 0 ) {
+ v = 0;
+ }
+ if ( v > 255.0 / 256.0 ) {
+ v = 255.0 / 256.0;
+ }
+ b = v * 256;
+ *p++ = 255;
+ *p++ = 255;
+ *p++ = 255;
+ *p++ = b;
+ }
+ Sys_Printf( " writing to %s...", minimapFilename );
+ WriteTGA( minimapFilename, data4b, minimap.width, minimap.height );
+ break;
+ }
+
+ Sys_Printf( " done.\n" );
+
+ /* return to sender */
+ return 0;
+}
break;
case PICO_WARNING:
- Sys_Printf( "WARNING: %s\n", str );
+ Sys_FPrintf( SYS_WRN, "WARNING: %s\n", str );
break;
case PICO_ERROR:
- Sys_Printf( "ERROR: %s\n", str );
+ Sys_FPrintf( SYS_ERR, "ERROR: %s\n", str );
break;
case PICO_FATAL:
}
}
-
/* walk the entity list */
for ( num = 1; num < numEntities; num++ )
{
/* get model name */
model = ValueForKey( e2, "model" );
if ( model[ 0 ] == '\0' ) {
- Sys_Printf( "WARNING: misc_model at %i %i %i without a model key\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: misc_model at %i %i %i without a model key\n",
(int) origin[ 0 ], (int) origin[ 1 ], (int) origin[ 2 ] );
continue;
}
/* split the string */
split = strchr( remap->from, ';' );
if ( split == NULL ) {
- Sys_Printf( "WARNING: Shader _remap key found in misc_model without a ; character\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Shader _remap key found in misc_model without a ; character\n" );
free( remap );
remap = remap2;
continue;
*/
void LokiInitPaths( char *argv0 ){
- char *home;
+ char *home;
if ( !homePath ) {
/* get home dir */
/* this is kinda crap, but hey */
strcpy( installPath, "../" );
#else
+
char temp[ MAX_OS_PATH ];
- char *path;
- char *last;
+ char *path;
+ char *last;
qboolean found;
int i, j, k, len, len2;
char temp[ MAX_OS_PATH ];
+ int noBasePath = 0;
+ int noHomePath = 0;
+ int noMagicPath = 0;
/* note it */
Sys_FPrintf( SYS_VRB, "--- InitPaths ---\n" );
argv[ i ] = NULL;
}
+ /* -fs_nobasepath */
+ else if ( strcmp( argv[ i ], "-fs_nobasepath" ) == 0 ) {
+ noBasePath = 1;
+ // we don't want any basepath, neither guessed ones
+ noMagicPath = 1;
+ argv[ i ] = NULL;
+ }
+
+ /* -fs_nomagicpath */
+ else if ( strcmp( argv[ i ], "-fs_nomagicpath") == 0) {
+ noMagicPath = 1;
+ argv[ i ] = NULL;
+ }
+
/* -fs_basepath */
else if ( strcmp( argv[ i ], "-fs_basepath" ) == 0 ) {
if ( ++i >= *argc ) {
argv[ i ] = NULL;
}
+ /* -fs_nohomepath */
+ else if ( strcmp( argv[ i ], "-fs_nohomepath" ) == 0 ) {
+ noHomePath = 1;
+ argv[ i ] = NULL;
+ }
+
/* -fs_homebase */
else if ( strcmp( argv[ i ], "-fs_homebase" ) == 0 ) {
if ( ++i >= *argc ) {
homeBasePath = ".";
argv[ i ] = NULL;
}
-
- /* -fs_pakpath */
- else if ( strcmp( argv[ i ], "-fs_pakpath" ) == 0 ) {
- if ( ++i >= *argc ) {
- Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
- }
- argv[ i - 1 ] = NULL;
- AddPakPath( argv[ i ] );
- argv[ i ] = NULL;
- }
-
}
/* remove processed arguments */
/* add standard game path */
AddGamePath( game->gamePath );
- /* if there is no base path set, figure it out */
- if ( numBasePaths == 0 ) {
+ /* if there is no base path set, figure it out unless fs_nomagicpath is set */
+ if ( numBasePaths == 0 && noBasePath == 0 && noMagicPath == 0 ) {
/* this is another crappy replacement for SetQdirFromPath() */
len2 = strlen( game->magic );
for ( i = 0; i < *argc && numBasePaths == 0; i++ )
}
}
- /* this only affects unix */
- if ( homeBasePath ) {
- AddHomeBasePath( homeBasePath );
+ if ( noBasePath == 1 ) {
+ numBasePaths = 0;
}
- else{
- AddHomeBasePath( game->homeBasePath );
+
+ if ( noHomePath == 0 ) {
+ /* this only affects unix */
+ if ( homeBasePath ) {
+ AddHomeBasePath( homeBasePath );
+ }
+ else{
+ AddHomeBasePath( game->homeBasePath );
+ }
}
/* initialize vfs paths */
//
// cut the portal into two portals, one on each side of the cut plane
//
+ /* not strict, we want to always keep one of them even if coplanar */
ClipWindingEpsilon( p->winding, plane->normal, plane->dist,
- SPLIT_WINDING_EPSILON, &frontwinding, &backwinding ); /* not strict, we want to always keep one of them even if coplanar */
+ SPLIT_WINDING_EPSILON, &frontwinding, &backwinding );
if ( frontwinding && WindingIsTiny( frontwinding ) ) {
if ( !f->tinyportals ) {
CalcNodeBounds( node );
if ( node->mins[0] >= node->maxs[0] ) {
- Sys_Printf( "WARNING: node without a volume\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: node without a volume\n" );
Sys_Printf( "node has %d tiny portals\n", node->tinyportals );
Sys_Printf( "node reference point %1.2f %1.2f %1.2f\n", node->referencepoint[0],
node->referencepoint[1],
int FloodEntities( tree_t *tree ){
int i, s;
vec3_t origin, offset, scale, angles;
- qboolean r, inside, skybox;
+ qboolean r, inside, skybox, found;
node_t *headnode;
entity_t *e, *tripped;
const char *value;
e = &entities[ i ];
/* get origin */
- GetVectorForKey( e, "origin", origin );
+ found = GetVectorForKey( e, "origin", origin );
/* as a special case, allow origin-less entities */
- if ( VectorCompare( origin, vec3_origin ) ) {
+ if ( !found ) {
continue;
}
// note the current area as bounding the portal
if ( b->portalareas[ 1 ] != -1 ) {
- Sys_Printf( "WARNING: areaportal brush %i touches > 2 areas\n", b->brushNum );
+ Sys_FPrintf( SYS_WRN, "WARNING: areaportal brush %i touches > 2 areas\n", b->brushNum );
return;
}
if ( b->portalareas[ 0 ] != -1 ) {
if ( node->cluster != -1 ) {
if ( node->area == -1 ) {
- Sys_Printf( "WARNING: cluster %d has area set to -1\n", node->cluster );
+ Sys_FPrintf( SYS_WRN, "WARNING: cluster %d has area set to -1\n", node->cluster );
}
}
if ( node->areaportal ) {
// check if the areaportal touches two areas
if ( b->portalareas[0] == -1 || b->portalareas[1] == -1 ) {
- Sys_Printf( "WARNING: areaportal brush %i doesn't touch two areas\n", b->brushNum );
+ Sys_FPrintf( SYS_WRN, "WARNING: areaportal brush %i doesn't touch two areas\n", b->brushNum );
}
}
}
WritePortalFile
================
*/
-void WritePortalFile( tree_t *tree ){
- char filename[1024];
+void WritePortalFile( tree_t *tree, const char *portalFilePath ){
Sys_FPrintf( SYS_VRB,"--- WritePortalFile ---\n" );
// write the file
- sprintf( filename, "%s.prt", source );
- Sys_Printf( "writing %s\n", filename );
- pf = fopen( filename, "w" );
+ Sys_Printf( "writing %s\n", portalFilePath );
+ pf = fopen( portalFilePath, "w" );
if ( !pf ) {
- Error( "Error opening %s", filename );
+ Error( "Error opening %s", portalFilePath );
}
fprintf( pf, "%s\n", PORTALFILE );
#ifndef Q3MAP2_H
#define Q3MAP2_H
-
+#include "globaldefs.h"
/* version */
#ifndef Q3MAP_VERSION
------------------------------------------------------------------------------- */
/* platform-specific */
-#if defined( __linux__ ) || defined( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#define Q_UNIX
#endif
#include <limits.h>
#endif
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <windows.h>
#endif
#include "mathlib.h"
#include "md5lib.h"
#include "ddslib.h"
+#ifdef BUILD_CRUNCH
+#include "crn_rgba.h"
+#endif // BUILD_CRUNCH
#include "picomodel.h"
------------------------------------------------------------------------------- */
#define MAC_STATIC_HACK 0
-#if defined( __APPLE__ ) && MAC_STATIC_HACK
+#if GDEF_OS_MACOS && MAC_STATIC_HACK
#define MAC_STATIC static
#else
#define MAC_STATIC
#endif
#if 1
- #ifdef WIN32
+ #if GDEF_OS_WINDOWS
#define Q_stricmp stricmp
#define Q_strncasecmp strnicmp
#else
/* ok to increase these at the expense of more memory */
#define MAX_MAP_AREAS 0x100 /* MAX_MAP_AREA_BYTES in q_shared must match! */
-#define MAX_MAP_FOGS 0x100 //& 0x100 /* RBSP (32 - world fog - goggles) */
+#define MAX_MAP_FOGS 30 //& 0x100 /* RBSP (32 - world fog - goggles) */
#define MAX_MAP_LEAFS 0x20000
#define MAX_MAP_PORTALS 0x20000
#define MAX_MAP_LIGHTING 0x800000
#define MAX_MAP_VISCLUSTERS 0x4000 // <= MAX_MAP_LEAFS
#define MAX_MAP_VISIBILITY ( VIS_HEADER_SIZE + MAX_MAP_VISCLUSTERS * ( ( ( MAX_MAP_VISCLUSTERS + 63 ) & ~63 ) >> 3 ) )
-#define MAX_MAP_DRAW_SURFS 0x20000
+#define MAX_MAP_DRAW_SURFS 0x20000
#define MAX_MAP_ADVERTISEMENTS 30
shaderInfo_t *shaderInfo;
shaderInfo_t *celShader; /* :) */
+ /* jal : entity based _lightmapsamplesize */
+ int lightmapSampleSize;
/* ydnar: gs mods */
- int lightmapSampleSize; /* jal : entity based _lightmapsamplesize */
float lightmapScale;
vec3_t eMins, eMaxs;
indexMap_t *im;
char *Q_strncpyz( char *dst, const char *src, size_t len );
char *Q_strcat( char *dst, size_t dlen, const char *src );
char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen );
-int BSPInfo( int count, char **fileNames );
-int ScaleBSPMain( int argc, char **argv );
int ShiftBSPMain( int argc, char **argv );
-int ConvertMain( int argc, char **argv );
/* help.c */
void HelpMain(const char* arg);
void InitPaths( int *argc, char **argv );
+/* fixaas.c */
+int FixAASMain( int argc, char **argv );
+
+
/* bsp.c */
int BSPMain( int argc, char **argv );
+/* bsp_analyze.c */
+int AnalyzeBSPMain( int argc, char **argv );
+
+
+/* bsp_info.c */
+int BSPInfoMain( int count, char **fileNames );
+
+/* bsp_scale.c */
+int ScaleBSPMain( int argc, char **argv );
+
+/* minimap.c */
+int MiniMapBSPMain( int argc, char **argv );
+
+/* convert_bsp.c */
+int ConvertBSPMain( int argc, char **argv );
+
+
/* convert_map.c */
int ConvertBSPToMap( char *bspName );
int ConvertBSPToMap_BP( char *bspName );
-
/* convert_ase.c */
int ConvertBSPToASE( char *bspName );
/* convert_obj.c */
int ConvertBSPToOBJ( char *bspName );
-
/* brush.c */
sideRef_t *AllocSideRef( side_t *side, sideRef_t *next );
int CountBrushList( brush_t *brushes );
/* leakfile.c */
-xmlNodePtr LeakFile( tree_t *tree );
+xmlNodePtr LeakFile( tree_t *tree, const char *lineFilePath );
/* prtfile.c */
void NumberClusters( tree_t *tree );
-void WritePortalFile( tree_t *tree );
+void WritePortalFile( tree_t *tree, const char *portalFilePath );
/* writebsp.c */
int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags );
void BeginBSPFile( void );
-void EndBSPFile( qboolean do_write );
+void EndBSPFile( qboolean do_write, const char *BSPFilePath, const char *surfaceFilePath );
void EmitBrushes( brush_t *brushes, int *firstBrush, int *numBrushes );
void EmitFogs( void );
float GetSurfaceExtraLongestCurve( int num );
void GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis );
-void WriteSurfaceExtraFile( const char *path );
-void LoadSurfaceExtraFile( const char *path );
+void WriteSurfaceExtraFile( const char *surfaceFilePath );
+void LoadSurfaceExtraFile( const char *surfaceFilePath );
/* decals.c */
void IlluminateRawLightmap( int num );
void IlluminateVertexes( int num );
-void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all );
+void SetupBrushesFlags( unsigned int mask_any, unsigned int test_any, unsigned int mask_all, unsigned int test_all );
void SetupBrushes( void );
void SetupClusters( void );
qboolean ClusterVisible( int a, int b );
void SetupSurfaceLightmaps( void );
void StitchSurfaceLightmaps( void );
-void StoreSurfaceLightmaps( void );
+void StoreSurfaceLightmaps( qboolean fastAllocate );
+
+
+/* exportents.c */
+void ExportEntities( void );
+int ExportEntitiesMain( int argc, char **argv );
/* exportents.c */
const char *ValueForKey( const entity_t *ent, const char *key );
int IntForKey( const entity_t *ent, const char *key );
vec_t FloatForKey( const entity_t *ent, const char *key );
-void GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec );
+qboolean GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec );
entity_t *FindTargetEntity( const char *target );
void GetEntityShadowFlags( const entity_t *ent, const entity_t *ent2, int *castShadows, int *recvShadows );
void InjectCommandLine( char **argv, int beginArgs, int endArgs );
{
#include "game_quake3.h"
,
- #include "game_quakelive.h" /* most be after game_quake3.h as they share defines! */
+ #include "game_quakelive.h" /* must be after game_quake3.h as they share defines! */
,
- #include "game_nexuiz.h" /* most be after game_quake3.h as they share defines! */
+ #include "game_nexuiz.h" /* must be after game_quake3.h as they share defines! */
,
- #include "game_xonotic.h" /* most be after game_quake3.h as they share defines! */
+ #include "game_xonotic.h" /* must be after game_quake3.h as they share defines! */
,
#include "game_tremulous.h" /*LinuxManMikeC: must be after game_quake3.h, depends on #define's set in it */
,
- #include "game_unvanquished.h"
+ #include "game_unvanquished.h" /* must be after game_tremulous.h as they share defines! */
,
#include "game_tenebrae.h"
,
#include "game_wolf.h"
,
- #include "game_wolfet.h" /* most be after game_wolf.h as they share defines! */
+ #include "game_wolfet.h" /* must be after game_wolf.h as they share defines! */
,
#include "game_etut.h"
,
,
#include "game_sof2.h"
,
- #include "game_jk2.h" /* most be after game_sof2.h as they share defines! */
+ #include "game_jk2.h" /* must be after game_sof2.h as they share defines! */
,
- #include "game_ja.h" /* most be after game_jk2.h as they share defines! */
+ #include "game_ja.h" /* must be after game_jk2.h as they share defines! */
,
#include "game_qfusion.h" /* qfusion game */
,
Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE );
Q_EXTERN int minSampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE );
-Q_EXTERN float noVertexLighting Q_ASSIGN( 0.0f );
+Q_EXTERN qboolean noVertexLighting Q_ASSIGN( qfalse );
Q_EXTERN qboolean nolm Q_ASSIGN( qfalse );
Q_EXTERN qboolean noGridLighting Q_ASSIGN( qfalse );
/* open shader file */
file = fopen( mapShaderFile, "w" );
if ( file == NULL ) {
- Sys_Printf( "WARNING: Unable to open map shader file %s for writing\n", mapShaderFile );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unable to open map shader file %s for writing\n", mapShaderFile );
return;
}
if ( si->shaderImage == NULL ) {
si->shaderImage = ImageLoad( DEFAULT_IMAGE );
if ( warnImage && strcmp( si->shader, "noshader" ) ) {
- Sys_Printf( "WARNING: Couldn't find image for shader %s\n", si->shader );
+ Sys_FPrintf( SYS_WRN, "WARNING: Couldn't find image for shader %s\n", si->shader );
}
}
/* dummy check */
if ( shaderName == NULL || shaderName[ 0 ] == '\0' ) {
- Sys_Printf( "WARNING: Null or empty shader name\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Null or empty shader name\n" );
shaderName = "missing";
}
/* increase deprecation depth */
deprecationDepth++;
if ( deprecationDepth == MAX_SHADER_DEPRECATION_DEPTH ) {
- Sys_Printf( "WARNING: Max deprecation depth of %i is reached on shader '%s'\n", MAX_SHADER_DEPRECATION_DEPTH, shader );
+ Sys_FPrintf( SYS_WRN, "WARNING: Max deprecation depth of %i is reached on shader '%s'\n", MAX_SHADER_DEPRECATION_DEPTH, shader );
}
/* search again from beginning */
i = -1;
else if ( !Q_stricmp( token, "surfaceparm" ) ) {
GetTokenAppend( shaderText, qfalse );
if ( ApplySurfaceParm( token, &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) {
- Sys_Printf( "WARNING: Unknown surfaceparm: \"%s\"\n", token );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unknown surfaceparm: \"%s\"\n", token );
}
}
}
else
{
- Sys_Printf( "WARNING: Unknown value for lightmap axis: %s\n", token );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unknown value for lightmap axis: %s\n", token );
VectorClear( si->lightmapAxis );
}
}
/* must be a power of 2 */
if ( ( ( si->lmCustomWidth - 1 ) & si->lmCustomWidth ) ||
( ( si->lmCustomHeight - 1 ) & si->lmCustomHeight ) ) {
- Sys_Printf( "WARNING: Non power-of-two lightmap size specified (%d, %d)\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: Non power-of-two lightmap size specified (%d, %d)\n",
si->lmCustomWidth, si->lmCustomHeight );
si->lmCustomWidth = lmCustomSize;
si->lmCustomHeight = lmCustomSize;
}
else
{
- Sys_Printf( "WARNING: Unknown q3map_tcGen method: %s\n", token );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unknown q3map_tcGen method: %s\n", token );
VectorClear( si->vecs[ 0 ] );
VectorClear( si->vecs[ 1 ] );
}
/* unknown */
else{
- Sys_Printf( "WARNING: Unknown colorMod method: %s\n", token );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unknown colorMod method: %s\n", token );
}
}
TCModRotate( si->mod, a );
}
else{
- Sys_Printf( "WARNING: Unknown q3map_tcMod method: %s\n", token );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unknown q3map_tcMod method: %s\n", token );
}
}
GetTokenAppend( shaderText, qfalse );
sprintf( temp, "*mat_%s", token );
if ( ApplySurfaceParm( temp, &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) {
- Sys_Printf( "WARNING: Unknown material \"%s\"\n", token );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unknown material \"%s\"\n", token );
}
}
{
Sys_FPrintf( SYS_VRB, "Attempting to match %s with a known surfaceparm\n", token );
if ( ApplySurfaceParm( &token[ 6 ], &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) {
- Sys_Printf( "WARNING: Unknown q3map_* directive \"%s\"\n", token );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unknown q3map_* directive \"%s\"\n", token );
}
}
#endif
custSurfaceParms[ numCustSurfaceParms ].name = safe_malloc( MAX_OS_PATH );
strcpy( custSurfaceParms[ numCustSurfaceParms ].name, token );
GetToken( qfalse );
- sscanf( token, "%x", &custSurfaceParms[ numCustSurfaceParms ].contentFlags );
+ sscanf( token, "%x", (unsigned int *) &custSurfaceParms[ numCustSurfaceParms ].contentFlags );
numCustSurfaceParms++;
}
/* any content? */
if ( !parsedContent ) {
- Sys_Printf( "WARNING: Couldn't find valid custom contentsflag section\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Couldn't find valid custom contentsflag section\n" );
return;
}
custSurfaceParms[ numCustSurfaceParms ].name = safe_malloc( MAX_OS_PATH );
strcpy( custSurfaceParms[ numCustSurfaceParms ].name, token );
GetToken( qfalse );
- sscanf( token, "%x", &custSurfaceParms[ numCustSurfaceParms ].surfaceFlags );
+ sscanf( token, "%x", (unsigned int *) &custSurfaceParms[ numCustSurfaceParms ].surfaceFlags );
numCustSurfaceParms++;
}
/* any content? */
if ( !parsedContent ) {
- Sys_Printf( "WARNING: Couldn't find valid custom surfaceflag section\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Couldn't find valid custom surfaceflag section\n" );
}
}
if ( fabs( dist ) > PLANAR_EPSILON ) {
//% if( ds->planeNum >= 0 )
//% {
- //% Sys_Printf( "WARNING: Planar surface marked unplanar (%f > %f)\n", fabs( dist ), PLANAR_EPSILON );
+ //% Sys_FPrintf( SYS_WRN, "WARNING: Planar surface marked unplanar (%f > %f)\n", fabs( dist ), PLANAR_EPSILON );
//% ds->verts[ i ].color[ 0 ][ 0 ] = ds->verts[ i ].color[ 0 ][ 2 ] = 0;
//% }
ds->planar = qfalse;
ds->planeNum = -1;
VectorClear( ds->lightmapVecs[ 2 ] );
//% if( ds->type == SURF_META || ds->type == SURF_FACE )
- //% Sys_Printf( "WARNING: Non-planar face (%d): %s\n", ds->planeNum, ds->shaderInfo->shader );
+ //% Sys_FPrintf( SYS_WRN, "WARNING: Non-planar face (%d): %s\n", ds->planeNum, ds->shaderInfo->shader );
}
/* -----------------------------------------------------------------
}
+#define snprintf_ignore(s, n, format, ...) do { \
+ size_t __n = snprintf(s, n, format, __VA_ARGS__); \
+ if (n >= n) {} /* truncated, ignore */ \
+} while (0)
/*
GetIndexedShader() - ydnar
/* make a shader name */
if ( minShaderIndex == maxShaderIndex ) {
- sprintf( shader, "textures/%s_%d", im->shader, maxShaderIndex );
+ snprintf_ignore( shader, sizeof shader, "textures/%s_%d", im->shader, maxShaderIndex );
}
else{
- sprintf( shader, "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex );
+ snprintf_ignore( shader, sizeof shader, "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex );
}
/* get the shader */
/* ydnar: sky hack/fix for GL_CLAMP borders on ati cards */
if ( skyFixHack && si->skyParmsImageBase[ 0 ] != '\0' ) {
//% Sys_FPrintf( SYS_VRB, "Enabling sky hack for shader %s using env %s\n", si->shader, si->skyParmsImageBase );
- sprintf( tempShader, "%s_lf", si->skyParmsImageBase );
+ snprintf_ignore( tempShader, sizeof tempShader, "%s_lf", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader );
- sprintf( tempShader, "%s_rt", si->skyParmsImageBase );
+ snprintf_ignore( tempShader, sizeof tempShader, "%s_rt", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader );
- sprintf( tempShader, "%s_ft", si->skyParmsImageBase );
+ snprintf_ignore( tempShader, sizeof tempShader, "%s_ft", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader );
- sprintf( tempShader, "%s_bk", si->skyParmsImageBase );
+ snprintf_ignore( tempShader, sizeof tempShader, "%s_bk", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader );
- sprintf( tempShader, "%s_up", si->skyParmsImageBase );
+ snprintf_ignore( tempShader, sizeof tempShader, "%s_up", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader );
- sprintf( tempShader, "%s_dn", si->skyParmsImageBase );
+ snprintf_ignore( tempShader, sizeof tempShader, "%s_dn", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader );
}
return AddReferenceToLeaf( ds, node );
}
+
+
/*
FilterPointConvexHullIntoTree_r() - ydnar
filters the convex hull of multiple points from a surface into the tree
}
+
/*
FilterWindingIntoTree_r() - ydnar
filters a winding from a drawsurface into the tree
si->mins[ 2 ] != 0.0f || si->maxs[ 2 ] != 0.0f ) ) {
static qboolean warned = qfalse;
if ( !warned ) {
- Sys_Printf( "WARNING: this map uses the deformVertexes move hack\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: this map uses the deformVertexes move hack\n" );
warned = qtrue;
}
return FilterWindingIntoTree_r( w, ds, node->children[ 1 ] );
}
#else
+ (void) plane2;
/* div0: this is the cholera (doesn't hit enough) */
/* the drawsurf might have an associated plane, if so, force a filter here */
/* validate the index */
if ( ds->type != SURFACE_PATCH ) {
if ( bspDrawIndexes[ numBSPDrawIndexes ] < 0 || bspDrawIndexes[ numBSPDrawIndexes ] >= ds->numVerts ) {
- Sys_Printf( "WARNING: %d %s has invalid index %d (%d)\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: %d %s has invalid index %d (%d)\n",
numBSPDrawSurfaces,
ds->shaderInfo->shader,
bspDrawIndexes[ numBSPDrawIndexes ],
numSurfacesByType[ ds->type ]++;
}
+
+
/*
EmitPatchSurface()
emits a bsp patch drawsurface
numSurfacesByType[ ds->type ]++;
}
+
+
/*
OptimizeTriangleSurface() - ydnar
optimizes the vertex/index data in a triangle surface
}
+
/*
MakeDebugPortalSurfs_r() - ydnar
generates drawsurfaces for passable portals in the bsp
bspDrawSurface_t *out;
out = &bspDrawSurfaces[ numBSPDrawSurfaces - 1 ];
if ( out->numVerts == 3 && out->numIndexes > 3 ) {
- Sys_Printf( "\nWARNING: Potentially bad %s surface (%d: %d, %d)\n %s\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: Potentially bad %s surface (%d: %d, %d)\n %s\n",
surfaceTypes[ ds->type ],
numBSPDrawSurfaces - 1, out->numVerts, out->numIndexes, si->shader );
}
writes out a surface info file (<map>.srf)
*/
-void WriteSurfaceExtraFile( const char *path ){
- char srfPath[ 1024 ];
+void WriteSurfaceExtraFile( const char *surfaceFilePath ){
FILE *sf;
surfaceExtra_t *se;
int i;
/* dummy check */
- if ( path == NULL || path[ 0 ] == '\0' ) {
+ if ( surfaceFilePath == NULL || surfaceFilePath[ 0 ] == '\0' ) {
return;
}
Sys_Printf( "--- WriteSurfaceExtraFile ---\n" );
/* open the file */
- strcpy( srfPath, path );
- StripExtension( srfPath );
- strcat( srfPath, ".srf" );
- Sys_Printf( "Writing %s\n", srfPath );
- sf = fopen( srfPath, "w" );
+ Sys_Printf( "Writing %s\n", surfaceFilePath );
+ sf = fopen( surfaceFilePath, "w" );
if ( sf == NULL ) {
- Error( "Error opening %s for writing", srfPath );
+ Error( "Error opening %s for writing", surfaceFilePath );
}
/* lap through the extras list */
reads a surface info file (<map>.srf)
*/
-void LoadSurfaceExtraFile( const char *path ){
- char srfPath[ 1024 ];
+void LoadSurfaceExtraFile( const char *surfaceFilePath ){
surfaceExtra_t *se;
int surfaceNum, size;
byte *buffer;
/* dummy check */
- if ( path == NULL || path[ 0 ] == '\0' ) {
+ if ( surfaceFilePath == NULL || surfaceFilePath[ 0 ] == '\0' ) {
return;
}
/* load the file */
- strcpy( srfPath, path );
- StripExtension( srfPath );
- strcat( srfPath, ".srf" );
- Sys_Printf( "Loading %s\n", srfPath );
- size = LoadFile( srfPath, (void**) &buffer );
+ Sys_Printf( "Loading %s\n", surfaceFilePath );
+ size = LoadFile( surfaceFilePath, (void**) &buffer );
if ( size <= 0 ) {
- Sys_Printf( "WARNING: Unable to find surface file %s, using defaults.\n", srfPath );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unable to find surface file %s, using defaults.\n", surfaceFilePath );
return;
}
/* parse the file */
- ParseFromMemory( (char *) buffer, size );
+ ParseFromMemory( (char*) buffer, size );
/* tokenize it */
while ( 1 )
{
surfaceNum = atoi( token );
if ( surfaceNum < 0 || surfaceNum > MAX_MAP_DRAW_SURFS ) {
- Error( "ReadSurfaceExtraFile(): %s, line %d: bogus surface num %d", srfPath, scriptline, surfaceNum );
+ Error( "ReadSurfaceExtraFile(): %s, line %d: bogus surface num %d", surfaceFilePath, scriptline, surfaceNum );
}
while ( surfaceNum >= numSurfaceExtras )
se = AllocSurfaceExtra();
/* handle { } section */
if ( !GetToken( qtrue ) || strcmp( token, "{" ) ) {
- Error( "ReadSurfaceExtraFile(): %s, line %d: { not found", srfPath, scriptline );
+ Error( "ReadSurfaceExtraFile(): %s, line %d: { not found", surfaceFilePath, scriptline );
}
while ( 1 )
{
if ( ds->numVerts == 0 || ds->type != SURFACE_PATCH || ( patchMeta == qfalse && !forcePatchMeta ) ) {
return;
}
+
/* make a mesh from the drawsurf */
src.width = ds->patchWidth;
src.height = ds->patchHeight;
ClassifySurfaces( 1, ds );
}
+
+
#define TINY_AREA 1.0f
#define MAXAREA_MAXTRIES 8
int MaxAreaIndexes( bspDrawVert_t *vert, int cnt, int *indexes ){
return -1;
}
+
+
/*
MaxAreaFaceSurface() - divVerent
creates a triangle list using max area indexes
}
+
/*
FanFaceSurface() - ydnar
creates a tri-fan from a brush face winding
}
+
/*
EmitMetaStatictics
vortex: prints meta statistics in general output
Sys_Printf( "%9d meta triangles\n", numMetaTriangles );
}
+
+
/*
MakeEntityMetaTriangles()
builds meta triangles from brush faces (tristrips and fans)
}
}
-
-
if ( metaMaxBBoxDistance >= 0 ) {
if ( ds->numIndexes > 0 ) {
VectorCopy( ds->mins, mins );
( bi == ds->indexes[ i ] && ci == ds->indexes[ i + 2 ] && ai == ds->indexes[ i + 1 ] ) ||
( ci == ds->indexes[ i ] && ai == ds->indexes[ i + 2 ] && bi == ds->indexes[ i + 1 ] ) ) {
/* warn about it */
- Sys_Printf( "WARNING: Flipped triangle: (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f)\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: Flipped triangle: (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f)\n",
ds->verts[ ai ].xyz[ 0 ], ds->verts[ ai ].xyz[ 1 ], ds->verts[ ai ].xyz[ 2 ],
ds->verts[ bi ].xyz[ 0 ], ds->verts[ bi ].xyz[ 1 ], ds->verts[ bi ].xyz[ 2 ],
ds->verts[ ci ].xyz[ 0 ], ds->verts[ ci ].xyz[ 1 ], ds->verts[ ci ].xyz[ 2 ] );
memset( verts, 0, sizeof( *verts ) * maxSurfaceVerts );
memset( indexes, 0, sizeof( *indexes ) * maxSurfaceIndexes );
-
/* add the first triangle */
if ( AddMetaTriangleToSurface( ds, seed, qfalse ) ) {
( *numAdded )++;
vec3_t origin;
vec3_t dir;
- edgePoint_t *chain; // unused element of doubly linked list
+ // unused element of doubly linked list
+ edgePoint_t *chain;
} edgeLine_t;
typedef struct {
int numOriginalEdges;
int allocatedOriginalEdges = 0;
-
-edgeLine_t *edgeLines = NULL;
+edgeLine_t *edgeLines = NULL;
int numEdgeLines;
int allocatedEdgeLines = 0;
p = e->chain->prev;
}
- for ( ; p != e->chain ; ) {
+ for ( ; p != e->chain ; ) {
if ( start < end ) {
if ( p->intercept > end - ON_EPSILON ) {
break;
Merges the portal visibility for a leaf
===============
*/
+
static int clustersizehistogram[MAX_MAP_LEAFS] = {0};
+
void ClusterMerge( int leafnum ){
leaf_t *leaf;
byte portalvector[MAX_PORTALS / 8];
numvis = LeafVectorFromPortalVector( portalvector, uncompressed );
// if (uncompressed[leafnum>>3] & (1<<(leafnum&7)))
-// Sys_Printf ("WARNING: Leaf portals saw into leaf\n");
+// Sys_FPrintf (SYS_WRN, "WARNING: Leaf portals saw into leaf\n");
// uncompressed[leafnum>>3] |= (1<<(leafnum&7));
numvis++; // count the leaf itself
- //Sys_FPrintf (SYS_VRB,"cluster %4i : %4i visible\n", leafnum, numvis);
+ //Sys_FPrintf( SYS_VRB,"cluster %4i : %4i visible\n", leafnum, numvis );
++clustersizehistogram[numvis];
memcpy( bspVisBytes + VIS_HEADER_SIZE + leafnum * leafbytes, uncompressed, leafbytes );
*/
void WriteFloat( FILE *f, vec_t v );
-void WritePortals( char *filename ){
+void WritePortals( char *portalpathfile ){
int i, j, num;
FILE *pf;
vportal_t *p;
fixedWinding_t *w;
// write the file
- pf = fopen( filename, "w" );
+ pf = fopen( portalpathfile, "w" );
if ( !pf ) {
- Error( "Error opening %s", filename );
+ Error( "Error opening %s", portalpathfile );
}
num = 0;
===========
*/
int VisMain( int argc, char **argv ){
- char portalfile[1024];
int i;
+ char portalFilePath[ 1024 ];
+ portalFilePath[0] = 0;
/* note it */
strcpy( outbase, "/tmp" );
}
-
/* ydnar: -hint to merge all but hint portals */
else if ( !strcmp( argv[ i ], "-hint" ) ) {
Sys_Printf( "hint = true\n" );
hint = qtrue;
mergevis = qtrue;
}
-
- else
+ else if ( !strcmp( argv[ i ], "-prtfile" ) )
{
- Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] );
+ strcpy( portalFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as portal file\n", portalFilePath );
+ }
+
+ else{
+ Sys_FPrintf( SYS_WRN, "WARNING: Unknown option \"%s\"\n", argv[ i ] );
}
}
if ( i != argc - 1 ) {
- Error( "usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile" );
+ Error( "usage: vis [-threads #] [-fast] [-v] BSPFilePath" );
}
LoadBSPFile( source );
/* load the portal file */
- sprintf( portalfile, "%s%s", inbase, ExpandArg( argv[ i ] ) );
- StripExtension( portalfile );
- strcat( portalfile, ".prt" );
- Sys_Printf( "Loading %s\n", portalfile );
- LoadPortals( portalfile );
+ if (!portalFilePath[0]) {
+ sprintf( portalFilePath, "%s%s", inbase, ExpandArg( argv[ i ] ) );
+ StripExtension( portalFilePath );
+ strcat( portalFilePath, ".prt" );
+ }
+ Sys_Printf( "Loading %s\n", portalFilePath );
+ LoadPortals( portalFilePath );
/* ydnar: exit if no portals, hence no vis */
if ( numportals == 0 ) {
/* delete the prt file */
if ( !saveprt ) {
- remove( portalfile );
+ remove( portalFilePath );
}
/* write the bsp file */
}
}
- // i == numBSPShaders
-
/* get shaderinfo */
si = ShaderInfoForShader( shader );
{
/* something is corrupting brushes */
if ( (size_t) b < 256 ) {
- Sys_Printf( "WARNING: Node brush list corrupted (0x%08X)\n", b );
+ Sys_FPrintf( SYS_WRN, "WARNING: Node brush list corrupted (0x%08X)\n", b );
break;
}
//% if( b->guard != 0xDEADBEEF )
finishes a new bsp and writes to disk
*/
-void EndBSPFile( qboolean do_write ){
- char path[ 1024 ];
-
+void EndBSPFile( qboolean do_write, const char *BSPFilePath, const char *surfaceFilePath ){
Sys_FPrintf( SYS_VRB, "--- EndBSPFile ---\n" );
if ( do_write ) {
/* write the surface extra file */
- WriteSurfaceExtraFile( source );
+ WriteSurfaceExtraFile( surfaceFilePath );
/* write the bsp */
- sprintf( path, "%s.bsp", source );
- Sys_Printf( "Writing %s\n", path );
- WriteBSPFile( path );
+ Sys_Printf( "Writing %s\n", BSPFilePath );
+ WriteBSPFile( BSPFilePath );
}
}