]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge commit '4645e19ce9e8f8034233ac965a4103a13b75714c' into garux-merge
authorThomas Debesse <dev@illwieckz.net>
Mon, 25 May 2020 11:27:17 +0000 (13:27 +0200)
committerThomas Debesse <dev@illwieckz.net>
Mon, 25 May 2020 11:27:17 +0000 (13:27 +0200)
932 files changed:
.cproject [new file with mode: 0644]
.drone.yml [new file with mode: 0644]
.gitignore
.gitmodules [new file with mode: 0644]
.project [new file with mode: 0644]
.travis.yml [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
COMPILING
Makefile
README.md [new file with mode: 0644]
TODO [deleted file]
TODO-Garux [new file with mode: 0644]
appveyor.yml [new file with mode: 0644]
cmake/FindGLIB.cmake [new file with mode: 0644]
cmake/FindGTK2.cmake [new file with mode: 0644]
cmake/FindGTK3.cmake [new file with mode: 0644]
cmake/FindGtkGLExt.cmake [new file with mode: 0644]
cmake/FindMinizip.cmake [new file with mode: 0644]
cmake/FindPango.cmake [new file with mode: 0644]
cmake/FindWebP.cmake [new file with mode: 0644]
cmake/scripts/package.cmake [new file with mode: 0644]
contrib/CMakeLists.txt [new file with mode: 0644]
contrib/bkgrnd2d/dialog.cpp
contrib/bobtoolz/CMakeLists.txt [new file with mode: 0644]
contrib/bobtoolz/DBobView.cpp
contrib/bobtoolz/DBobView.h
contrib/bobtoolz/DBrush.cpp
contrib/bobtoolz/DBrush.h
contrib/bobtoolz/DEntity.cpp
contrib/bobtoolz/DMap.cpp
contrib/bobtoolz/DMap.h
contrib/bobtoolz/DPatch.cpp
contrib/bobtoolz/DPatch.h
contrib/bobtoolz/DPlane.h
contrib/bobtoolz/DShape.h
contrib/bobtoolz/DTreePlanter.h
contrib/bobtoolz/DWinding.cpp
contrib/bobtoolz/DWinding.h
contrib/bobtoolz/ScriptParser.cpp
contrib/bobtoolz/ScriptParser.h
contrib/bobtoolz/StdAfx.cpp [deleted file]
contrib/bobtoolz/StdAfx.h [deleted file]
contrib/bobtoolz/bobToolz-GTK.cpp
contrib/bobtoolz/bsploader.cpp
contrib/bobtoolz/bsploader.h
contrib/bobtoolz/cportals.cpp
contrib/bobtoolz/dialogs/AboutDialog.cpp
contrib/bobtoolz/dialogs/AutoCaulkDialog.cpp
contrib/bobtoolz/dialogs/AutoCaulkStartDialog.cpp
contrib/bobtoolz/dialogs/AutoCaulkStartDialog.h
contrib/bobtoolz/dialogs/DoorDialog.cpp
contrib/bobtoolz/dialogs/IntersectDialog.cpp
contrib/bobtoolz/dialogs/IntersectDialog.h
contrib/bobtoolz/dialogs/IntersectInfoDialog.cpp
contrib/bobtoolz/dialogs/PolygonDialog.cpp
contrib/bobtoolz/dialogs/StairDialog.cpp
contrib/bobtoolz/dialogs/TextureResetDialog.cpp
contrib/bobtoolz/dialogs/brushcheckdialog.cpp
contrib/bobtoolz/dialogs/dialogs-gtk.cpp
contrib/bobtoolz/dialogs/dialogs-gtk.h
contrib/bobtoolz/dialogs/pathplotterdialog.cpp
contrib/bobtoolz/funchandlers-GTK.cpp
contrib/bobtoolz/funchandlers.h
contrib/bobtoolz/lists.cpp
contrib/bobtoolz/lists.h
contrib/bobtoolz/misc.cpp
contrib/bobtoolz/misc.h
contrib/bobtoolz/shapes.cpp
contrib/brushexport/CMakeLists.txt [new file with mode: 0644]
contrib/brushexport/callbacks.cpp
contrib/brushexport/callbacks.h
contrib/brushexport/export.cpp
contrib/brushexport/interface.cpp
contrib/brushexport/plugin.cpp
contrib/brushexport/support.cpp
contrib/brushexport/support.h
contrib/camera/camera.cpp
contrib/camera/camera.h
contrib/camera/dialogs.cpp
contrib/camera/dialogs_common.cpp
contrib/camera/funchandlers.cpp
contrib/camera/misc.cpp
contrib/camera/misc.h
contrib/gtkgensurf/bitmap.cpp
contrib/gtkgensurf/gendlgs.cpp
contrib/gtkgensurf/gensurf.cpp
contrib/gtkgensurf/gensurf.h
contrib/gtkgensurf/plugin.cpp
contrib/gtkgensurf/view.cpp
contrib/hydratoolz/plugin.cpp
contrib/hydratoolz/plugin.h
contrib/prtview/AboutDialog.cpp
contrib/prtview/CMakeLists.txt [new file with mode: 0644]
contrib/prtview/ConfigDialog.cpp
contrib/prtview/LoadPortalFileDialog.cpp
contrib/prtview/portals.cpp
contrib/prtview/portals.h
contrib/prtview/prtview.cpp
contrib/prtview/prtview.h
contrib/shaderplug/CMakeLists.txt [new file with mode: 0644]
contrib/shaderplug/shaderplug.cpp
contrib/sunplug/CMakeLists.txt [new file with mode: 0644]
contrib/sunplug/sunplug.cpp
contrib/ufoaiplug/CMakeLists.txt [new file with mode: 0644]
contrib/ufoaiplug/ufoai.cpp
contrib/ufoaiplug/ufoai_filters.cpp
contrib/ufoaiplug/ufoai_filters.h
contrib/ufoaiplug/ufoai_gtk.cpp
contrib/ufoaiplug/ufoai_gtk.h
contrib/ufoaiplug/ufoai_level.cpp
contrib/ufoaiplug/ufoai_level.h
docs/index.html
download-gamepacks.sh [deleted file]
gamepack-manager [new file with mode: 0755]
include/CMakeLists.txt [new file with mode: 0644]
include/cullable.cpp [deleted file]
include/defaults.h [new file with mode: 0644]
include/dpkdeps.h [new file with mode: 0644]
include/editable.cpp [deleted file]
include/iarchive.cpp [deleted file]
include/iarchive.h
include/ibrush.cpp [deleted file]
include/ibrush.h
include/icamera.cpp [deleted file]
include/icamera.h
include/idatastream.cpp [deleted file]
include/ieclass.cpp [deleted file]
include/ientity.cpp [deleted file]
include/ientity.h
include/ifilesystem.cpp [deleted file]
include/ifilesystem.h
include/ifiletypes.cpp [deleted file]
include/ifilter.cpp [deleted file]
include/igl.cpp [deleted file]
include/igl.h
include/iglrender.cpp [deleted file]
include/igtkgl.cpp [deleted file]
include/igtkgl.h
include/iimage.cpp [deleted file]
include/iimage.h
include/imap.cpp [deleted file]
include/imap.h
include/imodel.cpp [deleted file]
include/ipatch.cpp [deleted file]
include/ipatch.h
include/iplugin.cpp [deleted file]
include/ireference.cpp [deleted file]
include/irender.cpp [deleted file]
include/irender.h
include/iscenegraph.cpp [deleted file]
include/iscenegraph.h
include/iscriplib.cpp [deleted file]
include/iscriplib.h
include/iselection.cpp [deleted file]
include/iselection.h
include/ishaders.cpp [deleted file]
include/ishaders.h
include/itexdef.cpp [deleted file]
include/itextstream.cpp [deleted file]
include/itextures.cpp [deleted file]
include/itextures.h
include/itoolbar.cpp [deleted file]
include/itoolbar.h
include/iundo.cpp [deleted file]
include/iundo.h
include/mapfile.cpp [deleted file]
include/mapfile.h
include/modelskin.cpp [deleted file]
include/modelskin.h
include/moduleobserver.cpp [deleted file]
include/moduleobserver.h
include/modulesystem.cpp [deleted file]
include/modulesystem.h
include/nameable.cpp [deleted file]
include/nameable.h
include/namespace.cpp [deleted file]
include/namespace.h
include/preferencesystem.cpp
include/preferencesystem.h
include/qerplugin.cpp [deleted file]
include/qerplugin.h
include/renderable.cpp [deleted file]
include/renderable.h
include/selectable.cpp [deleted file]
include/selectable.h
include/version.h
include/warnings.h
include/windowobserver.cpp [deleted file]
include/windowobserver.h
install-gamepack.sh [deleted file]
install-gamepacks.sh [deleted file]
libs/CMakeLists.txt [new file with mode: 0644]
libs/_.cpp [new file with mode: 0644]
libs/archivelib.cpp [deleted file]
libs/bytebool.cpp [deleted file]
libs/bytestreamutils.cpp [deleted file]
libs/bytestreamutils.h
libs/character.cpp [deleted file]
libs/cmdlib.h
libs/cmdlib/.cvswrappers [deleted file]
libs/cmdlib/CMakeLists.txt [new file with mode: 0644]
libs/cmdlib/cmdlib.cpp
libs/container/CMakeLists.txt [new file with mode: 0644]
libs/container/array.h
libs/container/cache.cpp [deleted file]
libs/container/cache.h
libs/container/container.cpp [deleted file]
libs/container/container.h
libs/container/hashfunc.cpp [deleted file]
libs/container/hashfunc.h
libs/container/hashtable.cpp
libs/container/hashtable.h
libs/container/stack.cpp [deleted file]
libs/convert.cpp [deleted file]
libs/crnrgba/CMakeLists.txt [new file with mode: 0644]
libs/crnrgba/crn_rgba.cpp [new file with mode: 0644]
libs/crnrgba/crn_rgba.h [new file with mode: 0644]
libs/crunch [new submodule]
libs/ddslib/CMakeLists.txt [new file with mode: 0644]
libs/ddslib/ddslib.c
libs/debugging/CMakeLists.txt [new file with mode: 0644]
libs/debugging/debugging.h
libs/dragplanes.cpp [deleted file]
libs/eclasslib.cpp [deleted file]
libs/eclasslib.h
libs/entitylib.cpp [deleted file]
libs/entitylib.h
libs/entityxml.cpp [deleted file]
libs/etclib.c [new file with mode: 0644]
libs/etclib.h [new file with mode: 0644]
libs/etclib/CMakeLists.txt [new file with mode: 0644]
libs/filematch/CMakeLists.txt [new file with mode: 0644]
libs/fs_filesystem.cpp [deleted file]
libs/fs_path.cpp [deleted file]
libs/generic/CMakeLists.txt [new file with mode: 0644]
libs/generic/arrayrange.cpp [deleted file]
libs/generic/bitfield.cpp [deleted file]
libs/generic/callback.cpp
libs/generic/callback.h
libs/generic/callbackfwd.cpp [deleted file]
libs/generic/callbackfwd.h [deleted file]
libs/generic/constant.cpp
libs/generic/constant.h
libs/generic/enumeration.cpp [deleted file]
libs/generic/functional.cpp [deleted file]
libs/generic/functional.h
libs/generic/object.h
libs/generic/reference.cpp [deleted file]
libs/generic/referencecounted.cpp [deleted file]
libs/generic/static.cpp
libs/generic/vector.cpp [deleted file]
libs/globaldefs.h [new file with mode: 0644]
libs/gtkutil/CMakeLists.txt [new file with mode: 0644]
libs/gtkutil/accelerator.cpp
libs/gtkutil/accelerator.h
libs/gtkutil/button.cpp
libs/gtkutil/button.h
libs/gtkutil/clipboard.cpp
libs/gtkutil/closure.cpp [deleted file]
libs/gtkutil/closure.h
libs/gtkutil/container.cpp [deleted file]
libs/gtkutil/container.h
libs/gtkutil/cursor.cpp
libs/gtkutil/cursor.h
libs/gtkutil/dialog.cpp
libs/gtkutil/dialog.h
libs/gtkutil/entry.cpp
libs/gtkutil/entry.h
libs/gtkutil/filechooser.cpp
libs/gtkutil/filechooser.h
libs/gtkutil/frame.cpp
libs/gtkutil/frame.h
libs/gtkutil/glfont.cpp
libs/gtkutil/glwidget.cpp
libs/gtkutil/glwidget.h
libs/gtkutil/idledraw.cpp [deleted file]
libs/gtkutil/idledraw.h
libs/gtkutil/image.cpp
libs/gtkutil/image.h
libs/gtkutil/menu.cpp
libs/gtkutil/menu.h
libs/gtkutil/messagebox.cpp
libs/gtkutil/messagebox.h
libs/gtkutil/nonmodal.cpp
libs/gtkutil/nonmodal.h
libs/gtkutil/paned.cpp
libs/gtkutil/paned.h
libs/gtkutil/pointer.cpp [deleted file]
libs/gtkutil/toolbar.cpp
libs/gtkutil/toolbar.h
libs/gtkutil/widget.cpp
libs/gtkutil/widget.h
libs/gtkutil/window.cpp
libs/gtkutil/window.h
libs/gtkutil/xorrectangle.cpp
libs/gtkutil/xorrectangle.h
libs/imagelib.cpp [deleted file]
libs/instancelib.cpp [deleted file]
libs/instancelib.h
libs/l_net/CMakeLists.txt [new file with mode: 0644]
libs/l_net/l_net.c
libs/l_net/l_net.h
libs/l_net/l_net_berkley.c
libs/l_net/l_net_wins.c
libs/l_net/l_net_wins.h
libs/maplib.cpp [deleted file]
libs/maplib.h
libs/math/CMakeLists.txt [new file with mode: 0644]
libs/math/_.cpp [new file with mode: 0644]
libs/math/aabb.cpp [deleted file]
libs/math/aabb.h
libs/math/curve.cpp [deleted file]
libs/math/frustum.cpp [deleted file]
libs/math/line.cpp [deleted file]
libs/math/matrix.cpp [deleted file]
libs/math/pi.cpp [deleted file]
libs/math/plane.cpp [deleted file]
libs/math/quaternion.cpp [deleted file]
libs/math/vector.cpp [deleted file]
libs/math/vector.h
libs/mathlib/CMakeLists.txt [new file with mode: 0644]
libs/mathlib/bbox.c
libs/mathlib/m4x4.c
libs/mathlib/mathlib.c
libs/mathlib/ray.c
libs/md5lib.h
libs/md5lib/md5lib.c
libs/memory/CMakeLists.txt [new file with mode: 0644]
libs/memory/allocator.h
libs/moduleobservers.cpp [deleted file]
libs/modulesystem/CMakeLists.txt [new file with mode: 0644]
libs/modulesystem/moduleregistry.cpp [deleted file]
libs/modulesystem/moduleregistry.h
libs/modulesystem/modulesmap.cpp [deleted file]
libs/modulesystem/modulesmap.h
libs/modulesystem/singletonmodule.h
libs/os/CMakeLists.txt [new file with mode: 0644]
libs/os/_.cpp [new file with mode: 0644]
libs/os/dir.cpp [deleted file]
libs/os/file.cpp [deleted file]
libs/os/file.h
libs/os/path.cpp [deleted file]
libs/os/path.h
libs/picomodel/CMakeLists.txt [new file with mode: 0644]
libs/picomodel/lwo/clip.c
libs/picomodel/lwo/envelope.c
libs/picomodel/lwo/lwio.c
libs/picomodel/lwo/lwo2.c
libs/picomodel/lwo/lwo2.h
libs/picomodel/lwo/lwob.c
libs/picomodel/lwo/surface.c
libs/picomodel/picointernal.c
libs/picomodel/picointernal.h
libs/picomodel/picomodel.c
libs/picomodel/picomodules.c
libs/picomodel/pm_3ds.c
libs/picomodel/pm_ase.c
libs/picomodel/pm_fm.c
libs/picomodel/pm_lwo.c
libs/picomodel/pm_md2.c
libs/picomodel/pm_md3.c
libs/picomodel/pm_mdc.c
libs/picomodel/pm_ms3d.c
libs/picomodel/pm_obj.c
libs/picomodel/pm_terrain.c
libs/pivot.cpp [deleted file]
libs/profile/CMakeLists.txt [new file with mode: 0644]
libs/profile/file.cpp
libs/profile/profile.cpp
libs/property.h [new file with mode: 0644]
libs/render.cpp [deleted file]
libs/render.h
libs/scenelib.cpp [deleted file]
libs/scenelib.h
libs/script/CMakeLists.txt [new file with mode: 0644]
libs/script/_.cpp [new file with mode: 0644]
libs/script/scripttokeniser.cpp [deleted file]
libs/script/scripttokenwriter.cpp [deleted file]
libs/script/scripttokenwriter.h
libs/selectionlib.cpp [deleted file]
libs/selectionlib.h
libs/shaderlib.cpp [deleted file]
libs/shaderlib.h
libs/signal/CMakeLists.txt [new file with mode: 0644]
libs/signal/isignal.cpp [deleted file]
libs/signal/isignal.h
libs/signal/signal.cpp
libs/signal/signal.h
libs/signal/signalfwd.cpp [deleted file]
libs/splines/CMakeLists.txt [new file with mode: 0644]
libs/splines/math_matrix.h
libs/splines/math_quaternion.h
libs/splines/math_vector.h
libs/splines/q_parse.cpp
libs/splines/q_shared.cpp
libs/splines/q_shared.h
libs/splines/splines.cpp
libs/splines/util_str.cpp
libs/splines/util_str.h
libs/str.cpp [deleted file]
libs/str.h
libs/stream/CMakeLists.txt [new file with mode: 0644]
libs/stream/_.cpp [new file with mode: 0644]
libs/stream/filestream.cpp [deleted file]
libs/stream/memstream.cpp [deleted file]
libs/stream/stringstream.cpp [deleted file]
libs/stream/stringstream.h
libs/stream/textfilestream.cpp [deleted file]
libs/stream/textstream.cpp [deleted file]
libs/stream/textstream.h
libs/string/CMakeLists.txt [new file with mode: 0644]
libs/string/pooledstring.cpp
libs/string/string.cpp [deleted file]
libs/string/string.h
libs/string/stringfwd.cpp [deleted file]
libs/stringio.cpp [deleted file]
libs/stringio.h
libs/texturelib.cpp [deleted file]
libs/transformlib.cpp [deleted file]
libs/transformlib.h
libs/traverselib.cpp [deleted file]
libs/traverselib.h
libs/typesystem.cpp [deleted file]
libs/typesystem.h
libs/uilib/CMakeLists.txt [new file with mode: 0644]
libs/uilib/uilib.cpp [new file with mode: 0644]
libs/uilib/uilib.h [new file with mode: 0644]
libs/undolib.cpp [deleted file]
libs/undolib.h
libs/uniquenames.cpp [deleted file]
libs/versionlib.cpp [deleted file]
libs/xml/CMakeLists.txt [new file with mode: 0644]
libs/xml/ixml.cpp [deleted file]
libs/xml/xmlelement.cpp [deleted file]
libs/xml/xmlparser.cpp [deleted file]
libs/xml/xmlparser.h
libs/xml/xmltextags.cpp
libs/xml/xmlwriter.cpp [deleted file]
plugins/CMakeLists.txt [new file with mode: 0644]
plugins/archivepak/CMakeLists.txt [new file with mode: 0644]
plugins/archivepak/archive.cpp
plugins/archivepak/pak.cpp [deleted file]
plugins/archivepak/plugin.cpp
plugins/archivepak/plugin.h [deleted file]
plugins/archivewad/CMakeLists.txt [new file with mode: 0644]
plugins/archivewad/archive.cpp
plugins/archivewad/plugin.cpp
plugins/archivewad/plugin.h [deleted file]
plugins/archivewad/wad.cpp [deleted file]
plugins/archivezip/CMakeLists.txt [new file with mode: 0644]
plugins/archivezip/pkzip.cpp [deleted file]
plugins/archivezip/pkzip.h
plugins/archivezip/plugin.cpp
plugins/archivezip/plugin.h [deleted file]
plugins/archivezip/zlibstream.cpp [deleted file]
plugins/entity/CMakeLists.txt [new file with mode: 0644]
plugins/entity/angle.cpp [deleted file]
plugins/entity/angle.h
plugins/entity/angles.cpp [deleted file]
plugins/entity/angles.h
plugins/entity/colour.cpp [deleted file]
plugins/entity/colour.h
plugins/entity/curve.cpp [deleted file]
plugins/entity/curve.h
plugins/entity/doom3group.cpp
plugins/entity/eclassmodel.cpp
plugins/entity/eclassmodel.h
plugins/entity/entity.cpp
plugins/entity/filters.h
plugins/entity/generic.cpp
plugins/entity/group.cpp
plugins/entity/keyobservers.cpp [deleted file]
plugins/entity/light.cpp
plugins/entity/light.h
plugins/entity/miscmodel.cpp
plugins/entity/model.cpp [deleted file]
plugins/entity/model.h
plugins/entity/modelskinkey.cpp [deleted file]
plugins/entity/modelskinkey.h
plugins/entity/namedentity.cpp [deleted file]
plugins/entity/namedentity.h
plugins/entity/namekeys.cpp [deleted file]
plugins/entity/namekeys.h
plugins/entity/origin.cpp [deleted file]
plugins/entity/origin.h
plugins/entity/plugin.cpp
plugins/entity/plugin.h [deleted file]
plugins/entity/rotation.cpp [deleted file]
plugins/entity/rotation.h
plugins/entity/scale.cpp [deleted file]
plugins/entity/scale.h
plugins/entity/skincache.cpp
plugins/entity/targetable.h
plugins/image/CMakeLists.txt [new file with mode: 0644]
plugins/image/image.cpp
plugins/image/image.h [deleted file]
plugins/image/jpeg.cpp
plugins/image/ktx.cpp [new file with mode: 0644]
plugins/image/ktx.h [new file with mode: 0644]
plugins/image/tga.cpp
plugins/imagecrn/CMakeLists.txt [new file with mode: 0644]
plugins/imagecrn/crn.cpp [new file with mode: 0644]
plugins/imagecrn/crn.h [new file with mode: 0644]
plugins/imagecrn/imagecrn.cpp [new file with mode: 0644]
plugins/imagecrn/imagecrn.def [new file with mode: 0644]
plugins/imagehl/CMakeLists.txt [new file with mode: 0644]
plugins/imagehl/hlw.cpp
plugins/imagehl/imagehl.cpp
plugins/imagehl/imagehl.h [deleted file]
plugins/imagehl/mip.cpp
plugins/imagehl/sprite.cpp
plugins/imagepng/CMakeLists.txt [new file with mode: 0644]
plugins/imagepng/plugin.cpp
plugins/imagepng/plugin.h [deleted file]
plugins/imageq2/CMakeLists.txt [new file with mode: 0644]
plugins/imageq2/imageq2.cpp
plugins/imageq2/imageq2.h [deleted file]
plugins/imageq2/wal.cpp
plugins/imagewebp/CMakeLists.txt [new file with mode: 0644]
plugins/imagewebp/imagewebp.def [new file with mode: 0644]
plugins/imagewebp/plugin.cpp [new file with mode: 0644]
plugins/imagewebp/plugin.h [new file with mode: 0644]
plugins/iqmmodel/CMakeLists.txt [new file with mode: 0644]
plugins/iqmmodel/iqm.cpp [new file with mode: 0644]
plugins/iqmmodel/iqm.h [new file with mode: 0644]
plugins/iqmmodel/modeliqm.def [new file with mode: 0644]
plugins/iqmmodel/plugin.cpp [new file with mode: 0644]
plugins/iqmmodel/plugin.h [new file with mode: 0644]
plugins/mapq3/CMakeLists.txt [new file with mode: 0644]
plugins/mapq3/plugin.cpp
plugins/mapq3/plugin.h [deleted file]
plugins/mapq3/write.cpp
plugins/mapq3/write.h
plugins/mapxml/CMakeLists.txt [new file with mode: 0644]
plugins/mapxml/plugin.cpp
plugins/mapxml/plugin.h [deleted file]
plugins/mapxml/xmlparse.cpp
plugins/md3model/CMakeLists.txt [new file with mode: 0644]
plugins/md3model/md2.cpp
plugins/md3model/md3.cpp
plugins/md3model/md3normals.cpp [deleted file]
plugins/md3model/md5.cpp
plugins/md3model/mdc.cpp
plugins/md3model/mdlformat.cpp [deleted file]
plugins/md3model/mdlnormals.cpp [deleted file]
plugins/md3model/model.cpp [deleted file]
plugins/md3model/model.h
plugins/md3model/plugin.cpp
plugins/md3model/plugin.h [deleted file]
plugins/model/CMakeLists.txt [new file with mode: 0644]
plugins/model/model.cpp
plugins/model/plugin.cpp
plugins/model/plugin.h [deleted file]
plugins/sample/CMakeLists.txt [new file with mode: 0644]
plugins/sample/sample.h [deleted file]
plugins/shaders/CMakeLists.txt [new file with mode: 0644]
plugins/shaders/plugin.cpp
plugins/shaders/plugin.h [deleted file]
plugins/shaders/shaders.cpp
plugins/textool/.cvswrappers [deleted file]
plugins/textool/2DView.cpp
plugins/textool/Doc/.cvswrappers [deleted file]
plugins/textool/StdAfx.cpp [deleted file]
plugins/textool/StdAfx.h
plugins/textool/TexTool.cpp
plugins/vfspk3/CMakeLists.txt [new file with mode: 0644]
plugins/vfspk3/archive.cpp
plugins/vfspk3/vfs.cpp
plugins/vfspk3/vfspk3.cpp
plugins/vfspk3/vfspk3.h [deleted file]
radiant/CMakeLists.txt [new file with mode: 0644]
radiant/autosave.cpp
radiant/brush.h
radiant/brush_primit.cpp
radiant/brushmanip.cpp
radiant/brushmanip.h
radiant/brushmodule.cpp
radiant/build.cpp
radiant/build.h
radiant/camwindow.cpp
radiant/camwindow.h
radiant/commands.cpp
radiant/commands.h
radiant/console.cpp
radiant/console.h
radiant/csg.cpp
radiant/csg.h
radiant/dialog.cpp
radiant/dialog.h
radiant/eclass.cpp
radiant/eclass_doom3.cpp
radiant/eclass_fgd.cpp
radiant/entity.cpp
radiant/entity.h
radiant/entityinspector.cpp
radiant/entityinspector.h
radiant/entitylist.cpp
radiant/entitylist.h
radiant/environment.cpp
radiant/environment.h
radiant/error.cpp
radiant/feedback.cpp
radiant/feedback.h
radiant/filetypes.cpp
radiant/filterbar.cpp
radiant/filterbar.h
radiant/filters.cpp
radiant/filters.h
radiant/findtexturedialog.cpp
radiant/findtexturedialog.h
radiant/grid.cpp
radiant/grid.h
radiant/groupdialog.cpp
radiant/groupdialog.h
radiant/gtkdlgs.cpp
radiant/gtkdlgs.h
radiant/gtkmisc.cpp
radiant/gtkmisc.h
radiant/gtktheme.cpp
radiant/gtktheme.h
radiant/help.cpp
radiant/help.h
radiant/main.cpp
radiant/mainframe.cpp
radiant/mainframe.h
radiant/map.cpp
radiant/map.h
radiant/mru.cpp
radiant/mru.h
radiant/multimon.cpp
radiant/multimon.h
radiant/patch.cpp
radiant/patch.h
radiant/patchdialog.cpp
radiant/patchdialog.h
radiant/patchmanip.cpp
radiant/patchmanip.h
radiant/plugin.cpp
radiant/pluginapi.cpp
radiant/pluginmanager.cpp
radiant/pluginmanager.h
radiant/pluginmenu.cpp
radiant/pluginmenu.h
radiant/plugintoolbar.cpp
radiant/plugintoolbar.h
radiant/points.cpp
radiant/preferencedictionary.h
radiant/preferences.cpp
radiant/preferences.h
radiant/qe3.cpp
radiant/qgl.cpp
radiant/referencecache.cpp
radiant/renderer.h
radiant/renderstate.cpp
radiant/scenegraph.cpp
radiant/select.cpp
radiant/selection.cpp
radiant/selection.h
radiant/server.cpp
radiant/sockets.cpp
radiant/stacktrace.cpp
radiant/surfacedialog.cpp
radiant/surfacedialog.h
radiant/textureentry.cpp
radiant/textureentry.h
radiant/textures.cpp
radiant/textures.h
radiant/texwindow.cpp
radiant/texwindow.h
radiant/timer.cpp
radiant/treemodel.cpp
radiant/undo.cpp
radiant/url.cpp
radiant/view.h
radiant/watchbsp.cpp
radiant/windowobservers.cpp
radiant/windowobservers.h
radiant/xmlstuff.h
radiant/xywindow.cpp
radiant/xywindow.h
regression_tests/q3map2/model_clipping_45_degrees/models/mapobjects/wedges/wedge_45.ase
regression_tests/q3map2/model_clipping_45_degrees/models/mapobjects/wedges/wedge_shallow.ase
regression_tests/q3map2/model_clipping_45_degrees/models/mapobjects/wedges/wedge_steep.ase
setup/apple/.gitignore [new file with mode: 0644]
setup/apple/Makefile [new file with mode: 0644]
setup/apple/NetRadiant.app/Contents/Info.plist [new file with mode: 0644]
setup/apple/NetRadiant.app/Contents/MacOS/radiant [new file with mode: 0755]
setup/apple/NetRadiant.app/Contents/Resources/etc/fonts/fonts.conf [new file with mode: 0644]
setup/apple/NetRadiant.app/Contents/Resources/etc/gtk-2.0/gtkrc [new file with mode: 0644]
setup/apple/NetRadiant.app/Contents/Resources/etc/pango/pangorc [new file with mode: 0644]
setup/apple/NetRadiant.app/Contents/Resources/lib/.turd [new file with mode: 0644]
setup/apple/NetRadiant.app/Contents/Resources/radiant.icns [new file with mode: 0644]
setup/apple/NetRadiant.app/Contents/Resources/share/gtk-2.0/icons/.turd [new file with mode: 0644]
setup/apple/NetRadiant.app/Contents/Resources/share/gtk-2.0/themes/.turd [new file with mode: 0644]
setup/apple/README.md [new file with mode: 0644]
setup/data/osx/NetRadiant.app/Contents/Info.plist [deleted file]
setup/data/osx/NetRadiant.app/Contents/MacOS/install/fonts.conf [deleted file]
setup/data/osx/NetRadiant.app/Contents/MacOS/install/fonts.dtd [deleted file]
setup/data/osx/NetRadiant.app/Contents/MacOS/install/gdk-pixbuf.loaders [deleted file]
setup/data/osx/NetRadiant.app/Contents/MacOS/install/pango.modules [deleted file]
setup/data/osx/NetRadiant.app/Contents/MacOS/install/pangorc [deleted file]
setup/data/osx/NetRadiant.app/Contents/MacOS/install/pangox.aliases [deleted file]
setup/data/osx/NetRadiant.app/Contents/PkgInfo [deleted file]
setup/data/osx/NetRadiant.app/Contents/Resources/English.lproj/InfoPlist.strings [deleted file]
setup/data/osx/NetRadiant.app/Contents/Resources/NetRadiant.icns [deleted file]
setup/data/tools-src/notex.xcf [new file with mode: 0644]
setup/data/tools-src/shadernotex.xcf [new file with mode: 0644]
setup/data/tools-src/texbro_tags.xcf [new file with mode: 0644]
setup/data/tools/base/textures/radiant/notex.png [new file with mode: 0644]
setup/data/tools/base/textures/radiant/shadernotex.png [new file with mode: 0644]
setup/data/tools/bitmaps/cap_curve.png [new file with mode: 0644]
setup/data/tools/bitmaps/curve_cap.png [deleted file]
setup/data/tools/bitmaps/notex.png [deleted file]
setup/data/tools/bitmaps/selection_makeroom.png
setup/data/tools/bitmaps/shadernotex.png [deleted file]
setup/data/tools/bitmaps/texbro_tags.png [new file with mode: 0644]
setup/data/tools/global.xlink
tools/CMakeLists.txt [new file with mode: 0644]
tools/quake2/common/bspfile.c
tools/quake2/common/bspfile.h
tools/quake2/common/cmdlib.c
tools/quake2/common/cmdlib.h
tools/quake2/common/inout.c
tools/quake2/common/inout.h
tools/quake2/common/l3dslib.c
tools/quake2/common/l3dslib.h
tools/quake2/common/lbmlib.c
tools/quake2/common/lbmlib.h
tools/quake2/common/mathlib.c
tools/quake2/common/mathlib.h
tools/quake2/common/path_init.c
tools/quake2/common/polylib.c
tools/quake2/common/polylib.h
tools/quake2/common/q2_threads.h
tools/quake2/common/qfiles.h
tools/quake2/common/scriplib.c
tools/quake2/common/scriplib.h
tools/quake2/common/threads.c
tools/quake2/common/trilib.c
tools/quake2/common/trilib.h
tools/quake2/extra/bsp/qrad3/qrad.h
tools/quake2/extra/common/cmdlib.c
tools/quake2/extra/common/cmdlib.h
tools/quake2/extra/common/threads.c
tools/quake2/extra/qdata/qdata.c
tools/quake2/extra/qe4/cmdlib.c
tools/quake2/extra/qe4/mru.c
tools/quake2/extra/qe4/mru.h
tools/quake2/extra/qe4/qe3.h
tools/quake2/q2map/brushbsp.c
tools/quake2/q2map/csg.c
tools/quake2/q2map/faces.c
tools/quake2/q2map/flow.c
tools/quake2/q2map/gldraw.c
tools/quake2/q2map/glfile.c
tools/quake2/q2map/leakfile.c
tools/quake2/q2map/lightmap.c
tools/quake2/q2map/main.c
tools/quake2/q2map/map.c
tools/quake2/q2map/nodraw.c
tools/quake2/q2map/patches.c
tools/quake2/q2map/portals.c
tools/quake2/q2map/prtfile.c
tools/quake2/q2map/q2map.h
tools/quake2/q2map/qbsp.c
tools/quake2/q2map/qbsp.h
tools/quake2/q2map/qrad.c
tools/quake2/q2map/qrad.h
tools/quake2/q2map/qvis.c
tools/quake2/q2map/qvis.h
tools/quake2/q2map/textures.c
tools/quake2/q2map/trace.c
tools/quake2/q2map/tree.c
tools/quake2/q2map/writebsp.c
tools/quake2/qdata/images.c
tools/quake2/qdata/models.c
tools/quake2/qdata/qdata.c
tools/quake2/qdata/qdata.h
tools/quake2/qdata/sprites.c
tools/quake2/qdata/tables.c
tools/quake2/qdata/video.c
tools/quake2/qdata_heretic2/adpcm.h
tools/quake2/qdata_heretic2/animcomp.c
tools/quake2/qdata_heretic2/animcomp.h
tools/quake2/qdata_heretic2/anorms.h
tools/quake2/qdata_heretic2/book.c
tools/quake2/qdata_heretic2/common/bspfile.c
tools/quake2/qdata_heretic2/common/bspfile.h
tools/quake2/qdata_heretic2/common/cmdlib.c
tools/quake2/qdata_heretic2/common/cmdlib.h
tools/quake2/qdata_heretic2/common/her2_threads.h
tools/quake2/qdata_heretic2/common/inout.c
tools/quake2/qdata_heretic2/common/inout.h
tools/quake2/qdata_heretic2/common/l3dslib.c
tools/quake2/qdata_heretic2/common/l3dslib.h
tools/quake2/qdata_heretic2/common/lbmlib.c
tools/quake2/qdata_heretic2/common/lbmlib.h
tools/quake2/qdata_heretic2/common/mathlib.c
tools/quake2/qdata_heretic2/common/mathlib.h
tools/quake2/qdata_heretic2/common/path_init.c
tools/quake2/qdata_heretic2/common/polylib.c
tools/quake2/qdata_heretic2/common/polylib.h
tools/quake2/qdata_heretic2/common/qfiles.c
tools/quake2/qdata_heretic2/common/qfiles.h
tools/quake2/qdata_heretic2/common/scriplib.c
tools/quake2/qdata_heretic2/common/scriplib.h
tools/quake2/qdata_heretic2/common/threads.c
tools/quake2/qdata_heretic2/common/token.c
tools/quake2/qdata_heretic2/common/token.h
tools/quake2/qdata_heretic2/common/trilib.c
tools/quake2/qdata_heretic2/common/trilib.h
tools/quake2/qdata_heretic2/fmodels.c
tools/quake2/qdata_heretic2/images.c
tools/quake2/qdata_heretic2/jointed.c
tools/quake2/qdata_heretic2/jointed.h
tools/quake2/qdata_heretic2/joints.h
tools/quake2/qdata_heretic2/models.c
tools/quake2/qdata_heretic2/pics.c
tools/quake2/qdata_heretic2/qcommon/angles.h
tools/quake2/qdata_heretic2/qcommon/arrayedlist.h
tools/quake2/qdata_heretic2/qcommon/flex.h
tools/quake2/qdata_heretic2/qcommon/fmodel.h
tools/quake2/qdata_heretic2/qcommon/h2common.h
tools/quake2/qdata_heretic2/qcommon/placement.h
tools/quake2/qdata_heretic2/qcommon/q_typedef.h
tools/quake2/qdata_heretic2/qcommon/qfiles.h
tools/quake2/qdata_heretic2/qcommon/reference.c
tools/quake2/qdata_heretic2/qcommon/reference.h
tools/quake2/qdata_heretic2/qcommon/resourcemanager.c
tools/quake2/qdata_heretic2/qcommon/resourcemanager.h
tools/quake2/qdata_heretic2/qcommon/skeletons.c
tools/quake2/qdata_heretic2/qcommon/skeletons.h
tools/quake2/qdata_heretic2/qd_fmodel.h
tools/quake2/qdata_heretic2/qd_skeletons.c
tools/quake2/qdata_heretic2/qd_skeletons.h
tools/quake2/qdata_heretic2/qdata.c
tools/quake2/qdata_heretic2/qdata.h
tools/quake2/qdata_heretic2/sprites.c
tools/quake2/qdata_heretic2/svdcmp.c
tools/quake2/qdata_heretic2/tables.c
tools/quake2/qdata_heretic2/tmix.c
tools/quake2/qdata_heretic2/video.c
tools/quake3/CMakeLists.txt [new file with mode: 0644]
tools/quake3/common/aselib.c
tools/quake3/common/aselib.h
tools/quake3/common/bspfile.c
tools/quake3/common/bspfile.h
tools/quake3/common/cmdlib.c
tools/quake3/common/cmdlib.h
tools/quake3/common/imagelib.c
tools/quake3/common/imagelib.h
tools/quake3/common/inout.c
tools/quake3/common/inout.h
tools/quake3/common/l3dslib.c
tools/quake3/common/l3dslib.h
tools/quake3/common/mutex.c
tools/quake3/common/mutex.h
tools/quake3/common/polylib.c
tools/quake3/common/polylib.h
tools/quake3/common/polyset.h
tools/quake3/common/qfiles.h
tools/quake3/common/qthreads.h
tools/quake3/common/scriplib.c
tools/quake3/common/scriplib.h
tools/quake3/common/surfaceflags.h
tools/quake3/common/threads.c
tools/quake3/common/trilib.c
tools/quake3/common/trilib.h
tools/quake3/common/unzip.c [deleted file]
tools/quake3/common/unzip.h [deleted file]
tools/quake3/common/vfs.c
tools/quake3/common/vfs.h
tools/quake3/q3data/.cvswrappers [deleted file]
tools/quake3/q3data/3dslib.c
tools/quake3/q3data/3dslib.h
tools/quake3/q3data/compress.c
tools/quake3/q3data/images.c
tools/quake3/q3data/md3lib.c
tools/quake3/q3data/md3lib.h
tools/quake3/q3data/models.c
tools/quake3/q3data/oldstuff.c
tools/quake3/q3data/p3dlib.c
tools/quake3/q3data/p3dlib.h
tools/quake3/q3data/polyset.c
tools/quake3/q3data/q3data.c
tools/quake3/q3data/q3data.h
tools/quake3/q3data/stripper.c
tools/quake3/q3data/video.c
tools/quake3/q3map2/brush.c
tools/quake3/q3map2/bsp.c
tools/quake3/q3map2/bsp_analyze.c [new file with mode: 0644]
tools/quake3/q3map2/bsp_info.c [new file with mode: 0644]
tools/quake3/q3map2/bsp_scale.c [new file with mode: 0644]
tools/quake3/q3map2/bspfile_abstract.c
tools/quake3/q3map2/convert_ase.c
tools/quake3/q3map2/convert_bsp.c [new file with mode: 0644]
tools/quake3/q3map2/convert_obj.c
tools/quake3/q3map2/decals.c
tools/quake3/q3map2/exportents.c [new file with mode: 0644]
tools/quake3/q3map2/facebsp.c
tools/quake3/q3map2/fixaas.c [new file with mode: 0644]
tools/quake3/q3map2/game__null.h
tools/quake3/q3map2/game_etut.h
tools/quake3/q3map2/game_qfusion.h
tools/quake3/q3map2/game_quakelive.h
tools/quake3/q3map2/game_t.h [deleted file]
tools/quake3/q3map2/game_unvanquished.h [new file with mode: 0644]
tools/quake3/q3map2/game_wolf.h
tools/quake3/q3map2/game_wolfet.h
tools/quake3/q3map2/help.c [new file with mode: 0644]
tools/quake3/q3map2/image.c
tools/quake3/q3map2/leakfile.c
tools/quake3/q3map2/light.c
tools/quake3/q3map2/light_bounce.c
tools/quake3/q3map2/light_trace.c
tools/quake3/q3map2/light_ydnar.c
tools/quake3/q3map2/lightmaps_ydnar.c
tools/quake3/q3map2/main.c
tools/quake3/q3map2/map.c
tools/quake3/q3map2/minimap.c [new file with mode: 0644]
tools/quake3/q3map2/model.c
tools/quake3/q3map2/path_init.c
tools/quake3/q3map2/portals.c
tools/quake3/q3map2/prtfile.c
tools/quake3/q3map2/q3map2.h
tools/quake3/q3map2/shaders.c
tools/quake3/q3map2/surface.c
tools/quake3/q3map2/surface_extra.c
tools/quake3/q3map2/surface_meta.c
tools/quake3/q3map2/tjunction.c
tools/quake3/q3map2/vis.c
tools/quake3/q3map2/writebsp.c

diff --git a/.cproject b/.cproject
new file mode 100644 (file)
index 0000000..4a2a398
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,70 @@
+<?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="&quot;${workspace_loc:/NetRadiant/plugins}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/NetRadiant/include}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/NetRadiant/radiant}&quot;"/>
+                                                               </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>
diff --git a/.drone.yml b/.drone.yml
new file mode 100644 (file)
index 0000000..d40dd2e
--- /dev/null
@@ -0,0 +1,8 @@
+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
index b1c030fcafa5f5152f74f2366e176d76f7d64af9..32e1dbf1abeee8264c8cb909379ff6d506405ccb 100644 (file)
@@ -1,2 +1,6 @@
 *.[oda]
-install
+.idea/
+.settings
+build/
+games/
+install/
diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..d20f6e3
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "libs/crunch"]
+       path = libs/crunch
+       url = https://github.com/DaemonEngine/crunch.git
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..daa477f
--- /dev/null
+++ b/.project
@@ -0,0 +1,27 @@
+<?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>
diff --git a/.travis.yml b/.travis.yml
new file mode 100644 (file)
index 0000000..956213f
--- /dev/null
@@ -0,0 +1,32 @@
+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
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e920fd6
--- /dev/null
@@ -0,0 +1,288 @@
+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)
index 3c847ee13da6189d09f378d8a7e4fd1c2e0a053d..29a707c5917ef3dbdc40fce5dfbb2bbc92cc425e 100644 (file)
--- a/COMPILING
+++ b/COMPILING
@@ -48,16 +48,22 @@ environment:
 - 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
 
index 661aec24bfb1f98197235eb718a49dd54bc9b1bd..266e2f8c244ad61ffeb90f628b3a3851adbd60a5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,7 @@ RADIANT_ABOUTMSG   ?= Custom build
 # 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++
@@ -36,7 +37,7 @@ ECHO_NOLF          ?= echo -n
 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
@@ -67,6 +68,9 @@ LIBS_XML           ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) li
 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))
@@ -81,7 +85,7 @@ LIBS_GL            ?= -lGL # -lopengl32 on Win32
 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
@@ -113,7 +117,7 @@ CFLAGS_COMMON = -MMD -W -Wall -Wcast-align -Wcast-qual -Wno-unused-parameter -fn
 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),)
@@ -165,7 +169,7 @@ ifeq ($(findstring $(CFLAGS),-O),)
        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
@@ -233,8 +237,6 @@ ifeq ($(OS),Darwin)
        # 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))
@@ -243,10 +245,11 @@ endif
 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
@@ -258,7 +261,8 @@ ifneq ($(GIT_VERSION),)
        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: \
@@ -351,6 +355,7 @@ dependencies-check:
        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)"; \
@@ -381,6 +386,7 @@ binaries-radiant-modules: \
        $(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) \
@@ -449,6 +455,7 @@ binaries-q3map2: \
 .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
 
@@ -484,8 +491,8 @@ endif
        $(CC) $< $(CFLAGS) $(CFLAGS_COMMON) $(CPPFLAGS_EXTRA) $(CPPFLAGS_COMMON) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@
 
 $(INSTALLDIR)/q3map2.$(EXE): LDFLAGS_EXTRA := -Wl,--large-address-aware
-$(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 \
@@ -496,7 +503,6 @@ $(INSTALLDIR)/q3map2.$(EXE): \
        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 \
@@ -505,12 +511,19 @@ $(INSTALLDIR)/q3map2.$(EXE): \
        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/leakfile.o \
        tools/quake3/q3map2/light_bounce.o \
@@ -520,6 +533,7 @@ $(INSTALLDIR)/q3map2.$(EXE): \
        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 \
@@ -538,6 +552,7 @@ $(INSTALLDIR)/q3map2.$(EXE): \
        tools/quake3/q3map2/vis.o \
        tools/quake3/q3map2/writebsp.o \
        libddslib.$(A) \
+       libetclib.$(A) \
        libfilematch.$(A) \
        libl_net.$(A) \
        libmathlib.$(A) \
@@ -587,6 +602,10 @@ libddslib.$(A): CPPFLAGS_EXTRA := -Ilibs
 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): \
@@ -598,7 +617,6 @@ $(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 \
@@ -612,6 +630,7 @@ $(INSTALLDIR)/q3data.$(EXE): \
        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,) \
@@ -691,6 +710,7 @@ $(INSTALLDIR)/radiant.$(EXE): \
        radiant/stacktrace.o \
        radiant/surfacedialog.o \
        radiant/texmanip.o \
+       radiant/textureentry.o \
        radiant/textures.o \
        radiant/texwindow.o \
        radiant/timer.o \
@@ -705,6 +725,7 @@ $(INSTALLDIR)/radiant.$(EXE): \
        radiant/xywindow.o \
        libcmdlib.$(A) \
        libgtkutil.$(A) \
+       libuilib.$(A) \
        libl_net.$(A) \
        libmathlib.$(A) \
        libprofile.$(A) \
@@ -729,8 +750,6 @@ libgtkutil.$(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 \
@@ -738,51 +757,42 @@ libgtkutil.$(A): \
        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 \
@@ -791,13 +801,7 @@ $(INSTALLDIR)/modules/entity.$(DLL): \
        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 \
 
@@ -808,9 +812,11 @@ $(INSTALLDIR)/modules/image.$(DLL): \
        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): \
@@ -830,7 +836,12 @@ $(INSTALLDIR)/modules/imagepng.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_PNG) -Ilibs
 $(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 \
@@ -1066,29 +1077,22 @@ $(INSTALLDIR)/heretic2/h2data.$(EXE): \
 .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
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..25c6ad5
--- /dev/null
+++ b/README.md
@@ -0,0 +1,112 @@
+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.
diff --git a/TODO b/TODO
deleted file mode 100644 (file)
index 60573df..0000000
--- a/TODO
+++ /dev/null
@@ -1,149 +0,0 @@
-[-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?
diff --git a/TODO-Garux b/TODO-Garux
new file mode 100644 (file)
index 0000000..60573df
--- /dev/null
@@ -0,0 +1,149 @@
+[-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?
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644 (file)
index 0000000..d98cc73
--- /dev/null
@@ -0,0 +1,27 @@
+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
+      "@
diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake
new file mode 100644 (file)
index 0000000..4b1b265
--- /dev/null
@@ -0,0 +1,21 @@
+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)
diff --git a/cmake/FindGTK2.cmake b/cmake/FindGTK2.cmake
new file mode 100644 (file)
index 0000000..ff20526
--- /dev/null
@@ -0,0 +1,21 @@
+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)
diff --git a/cmake/FindGTK3.cmake b/cmake/FindGTK3.cmake
new file mode 100644 (file)
index 0000000..7bef3b0
--- /dev/null
@@ -0,0 +1,21 @@
+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)
diff --git a/cmake/FindGtkGLExt.cmake b/cmake/FindGtkGLExt.cmake
new file mode 100644 (file)
index 0000000..b30a1e1
--- /dev/null
@@ -0,0 +1,27 @@
+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)
diff --git a/cmake/FindMinizip.cmake b/cmake/FindMinizip.cmake
new file mode 100644 (file)
index 0000000..0de098f
--- /dev/null
@@ -0,0 +1,21 @@
+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)
diff --git a/cmake/FindPango.cmake b/cmake/FindPango.cmake
new file mode 100644 (file)
index 0000000..67359ef
--- /dev/null
@@ -0,0 +1,23 @@
+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)
diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake
new file mode 100644 (file)
index 0000000..0868255
--- /dev/null
@@ -0,0 +1,73 @@
+# - 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()
diff --git a/cmake/scripts/package.cmake b/cmake/scripts/package.cmake
new file mode 100644 (file)
index 0000000..be530ec
--- /dev/null
@@ -0,0 +1,16 @@
+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)
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8233ea1
--- /dev/null
@@ -0,0 +1,20 @@
+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)
index 6d63bc3fd80e8cba0bb60ddd484088da45f470bb..01a1b985b9b3e091bbcce460f1b22671cdfe12ae 100644 (file)
@@ -34,7 +34,7 @@
 // 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;
 
@@ -43,7 +43,7 @@ class CBackgroundDialogPage
 private:
 GtkWidget *m_pWidget;
 GtkWidget *m_pTabLabel;
-GtkWidget *m_pFileLabel;
+ui::Label m_pFileLabel;
 GtkWidget *m_pPosLabel;
 VIEWTYPE m_vt;
 bool m_bValidFile;
@@ -159,7 +159,7 @@ void CBackgroundDialogPage::Browse(){
 
        if ( m_pImage->Load( newfile ) ) {
                m_bValidFile = true;
-               gtk_label_set_text( GTK_LABEL( m_pFileLabel ),newfile );
+               m_pFileLabel.text(newfile);
        }
 }
 
@@ -168,12 +168,10 @@ void CBackgroundDialogPage::SetPosLabel(){
        // 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;
@@ -183,108 +181,103 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE 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 ){
@@ -314,17 +307,15 @@ void InitBackgroundDialog(){
        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();
 
@@ -338,13 +329,13 @@ void InitBackgroundDialog(){
 
        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 ){
diff --git a/contrib/bobtoolz/CMakeLists.txt b/contrib/bobtoolz/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c9b83cb
--- /dev/null
@@ -0,0 +1,36 @@
+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)
index 55dd8e4dd58d083435c2e79be5fd901c77fbbcaa..decfe7790664dbd3dd4654d2907177aac1323205 100644 (file)
@@ -143,7 +143,7 @@ void DBobView::SetPath( vec3_t *pPath ){
        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] ) {
@@ -264,4 +264,4 @@ void DBobView_setEntity( Entity& entity, float multiplier, int points, float var
                globalErrorStream() << "bobToolz PathPlotter: Entity must have a targetname.\n";
        }
        return;
-}
\ No newline at end of file
+}
index 05c8ad29a90fe4386ba6551fe61d120403299da0..b20ef141417d3c6e4dbcca32f9f5f4c8d3279974 100644 (file)
@@ -32,8 +32,8 @@
 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
@@ -78,7 +78,7 @@ void destroyShaders();
 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 ) );
 }
index 4a2b9c097969c4fa9766ab0ffd3cda41d5b211b5..a0d97699c3411818f17ecf69c4cc0d822a78a263 100644 (file)
@@ -22,8 +22,9 @@
 //////////////////////////////////////////////////////////////////////
 
 #include "DBrush.h"
+#include "globaldefs.h"
 
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
 #pragma warning(disable : 4786)
 #endif
 
@@ -68,7 +69,7 @@ DBrush::~DBrush(){
 //////////////////////////////////////////////////////////////////////
 
 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;
@@ -117,7 +118,7 @@ int DBrush::BuildPoints(){
                }
        }
 
-#ifdef _DEBUG
+#if GDEF_DEBUG
 //     Sys_Printf("%i points on brush\n", pointList.size());
 #endif
 
@@ -127,12 +128,12 @@ int DBrush::BuildPoints(){
 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();
index b5e343eb822a9945df1cd299860dc60d4724b759..7b3e8d6035ca47b69e0f1eb1b5b36452e4cf2989 100644 (file)
@@ -44,9 +44,9 @@ class Node;
 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
 {
index 38ab47f43c240269785cb019b46b3898b98df803..5a4d8e57501c8b7461eb6fdf8830f0579f432467 100644 (file)
@@ -22,8 +22,9 @@
 //////////////////////////////////////////////////////////////////////
 
 #include "DEntity.h"
+#include "globaldefs.h"
 
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
 #pragma warning(disable : 4786)
 #endif
 
@@ -161,7 +162,7 @@ bool DEntity::LoadFromPrt( char *filename ){
                {
                        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 );
@@ -243,7 +244,8 @@ void DEntity_loadBrush( DEntity& entity, scene::Instance& brush ){
        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();
@@ -276,7 +278,8 @@ void DEntity_loadPatch( DEntity& entity, scene::Instance& patch ){
        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();
@@ -385,6 +388,7 @@ public:
                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 ) );
@@ -489,8 +493,6 @@ void DEntity::BuildInRadiant( bool allowDestruction ){
        }
 }
 
-
-
 int DEntity::GetIDMax( void ) {
        int max = -1;
        for ( std::list<DBrush *>::const_iterator cntBrush = brushList.begin(); cntBrush != brushList.end(); cntBrush++ ) {
index 72356946ca81b68e425171883dce4cad0da7ec58..18edc3b1fee51870082c1336f6a43ab908b23d08 100644 (file)
@@ -58,7 +58,7 @@ DMap::~DMap(){
        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++ );
index b4a3f79bff33e6a716f4d4ec75f9f6b3f0c9e13f..f527d04d85411299d50564f3de5ac9309c15369c 100644 (file)
@@ -45,7 +45,7 @@ DEntity* GetWorldSpawn();
 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;
 
index 2228b23bc54f36c478d08ddefbf199be8ead2ca2..be49df4ef4ab9aa06f539161164e9bfce751be70 100644 (file)
@@ -302,7 +302,7 @@ DPatch* DPatch::MergePatches( patch_merge_t merge_info, DPatch *p1, DPatch *p2 )
 
        int newHeight = p1->height + p2->height - 1;
        if ( newHeight > MAX_PATCH_HEIGHT ) {
-               return false;
+               return NULL;
        }
 
        DPatch* newPatch = new DPatch();
index 8808daeb695768a30cd8e6decfc6b1447f1908fa..4d0c26c5718acdad9708811fe1ca654e4dce3a34 100644 (file)
@@ -47,10 +47,10 @@ class Node;
 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
 {
index 6e840cdb71ba81b77b51065149d220d72eb0eeec..88a33584622747152ebee554a882ebc10f36f4b7 100644 (file)
@@ -54,7 +54,7 @@ bool operator !=( DPlane& other );
 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 );
 
index 1f6c91fcaece093f3afb36c4e2c4aacb3126988a..31c66e13034dbe2292fa2451bbdd4a37d929914c 100644 (file)
@@ -35,7 +35,7 @@ class DBrush;
 class DEntity;
 
 // defines for polygon stuff
-#define MAX_POLYGON_FACES   128
+const int MAX_POLYGON_FACES = 128;
 
 extern bool bFacesAll[];
 
index 1d198ae63dddfed5b3f27278a01609c70ba526eb..102976d8d416d85f0d2d8f0970e4eff389b8ff44 100644 (file)
 #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;
index c3d811802fd4c83629c2c20e98cb103237c571da..e4dc026dddf867a42a14ff66870dbd759b4ea0de 100644 (file)
@@ -47,7 +47,7 @@ DWinding::~DWinding(){
 // Implementation
 //////////////////////////////////////////////////////////////////////
 
-#define BOGUS_RANGE 4096
+const int BOGUS_RANGE = 4096;
 
 void DWinding::AllocWinding( int points ){
        numpoints = points;
index 94a28096f457ee09ae2a5feb9620865bb4536ab1..cb8ddda759197504eb5eeef5dd2970aae9b87172 100644 (file)
@@ -63,8 +63,8 @@ vec3_t* p;
 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_)
index d53c7fe8dc4801994e6b092e5a0e7c8729471c63..3c801b26719f80f22ae255c9cfa320d7a6310c3e 100644 (file)
@@ -65,7 +65,7 @@ const char* CScriptParser::MakeToken( const char* pToken ) {
        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;
index b9ec823d3a9977899ed4a4543eb0a83a6276e520..2729dcaeb873ce3cbce996126677d17ed2567fff 100644 (file)
@@ -23,7 +23,7 @@
 
 //#include "interfaces/IScriptParser.h"
 
-#define SP_MAX_BREAKCHARS 16
+const int SP_MAX_BREAKCHARS = 16;
 
 class CScriptParser //: public IScriptParser
 {
diff --git a/contrib/bobtoolz/StdAfx.cpp b/contrib/bobtoolz/StdAfx.cpp
deleted file mode 100644 (file)
index 5c7495f..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-   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"
diff --git a/contrib/bobtoolz/StdAfx.h b/contrib/bobtoolz/StdAfx.h
deleted file mode 100644 (file)
index cfce5a4..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
index 4eecfd92d5b210538188b3e91190826babe90f39..bbc3979c56332e3ea3ad9abaf954451ea5655fd5 100644 (file)
@@ -57,13 +57,13 @@ void BobToolz_destroy(){
 }
 
 // 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";
+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";
 
 // globals
-GtkWidget *g_pRadiantWnd = NULL;
+ui::Window g_pRadiantWnd{ui::null};
 
 static const char *PLUGIN_ABOUT =   "bobToolz for SDRadiant\n"
                                                                        "by digibob (digibob@splashdamage.com)\n"
@@ -72,7 +72,7 @@ static const char *PLUGIN_ABOUT =   "bobToolz for SDRadiant\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";
 }
@@ -155,7 +155,7 @@ const char* QERPlug_GetCommandTitleList(){
 }
 
 
-#define NUM_TOOLBARBUTTONS 14
+const int NUM_TOOLBARBUTTONS = 14;
 
 std::size_t ToolbarButtonCount( void ) {
        return NUM_TOOLBARBUTTONS;
@@ -284,10 +284,10 @@ class BobToolzPluginDependencies :
 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" ) ){
 }
 };
 
index 6c8b09e90f185431e78c748a932e51eaf6e23527..0c442e16ce0f2258abac3775b662a62e1c235027 100644 (file)
@@ -1,3 +1,4 @@
+#include <globaldefs.h>
 #include "bsploader.h"
 #include "dialogs/dialogs-gtk.h"
 #include "cmdlib.h"
@@ -24,9 +25,9 @@ dbrush_t          *dbrushes =             NULL;
 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;
 
 /*
    ================
@@ -71,16 +72,16 @@ bool    LoadFile( const char *filename, byte **bufferptr ){
 }
 
 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;
 }
 
index 7bee8fd02ce801e5bbc551de4e660f2f6a56f5c1..47e9f5a32b17bbf860f3d4aa9cdaab7263f26cc9 100644 (file)
@@ -1,24 +1,24 @@
 
 #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;
@@ -106,10 +106,10 @@ typedef enum {
        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;
index 073c979de5b69e1be5462958b1808acdf4974cdb..d8ec2a6086b8cb073d23ea557aef23608f3af35c 100644 (file)
@@ -24,8 +24,8 @@
 
 #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
@@ -118,7 +118,7 @@ void CPortals::Load(){
 
        Purge();
 
-       globalOutputStream() << MSG_PREFIX "Loading portal file " << fn << ".\n";
+       globalOutputStream() << MSG_PREFIX << "Loading portal file " << fn << ".\n";
 
        FILE *in;
 
index 6ba6df1426a3b0d87fe2ba896b27a48ad33f01b8..0f5ef44fd190bc7ff7630d61410fc540d6e9fbee 100644 (file)
 #include "../StdAfx.h"
 #include "AboutDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-//static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CAboutDialog dialog
 
index bcbb495717eea89adbeed543ce6b27090ee36b86..a04c604c5eff7c75ba8e5b584258823d3dd38056 100644 (file)
 #include "../bobtoolz.h"
 #include "AutoCaulkDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CAutoCaulkDialog dialog
 
index f59dfd338291dbdc9a07279ecc8849238a97f19a..f112f02b0cb1891ddd659e30d7ff39274797245e 100644 (file)
 #include "../bobtoolz.h"
 #include "AutoCaulkStartDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CAutoCaulkStartDialog dialog
 
index 5c2f4297840e2e57a30b72fccddd8bcaa03b8930..73e265f44d8f45068d432039f4d7258056d7d0cb 100644 (file)
@@ -26,9 +26,9 @@
 // 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
index ce0d621325c32e1b693618d3c7ace0db0eb965dd..50e7ef7644572bb89cc5d09f5aec46d1eaebaff8 100644 (file)
 #include "../StdAfx.h"
 #include "DoorDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CDoorDialog dialog
 
index 4bcc8373fb769b22b840e70a28dd8de5057b15fd..8b2a0c7249fe467316bafe429f81c0d1319162fb 100644 (file)
 #include "../StdAfx.h"
 #include "IntersectDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CIntersectDialog dialog
 
index d8d64c3e088748236d685126d6230986ff4e6f87..b9c342b4ef42160f4b8c6193e3fd88fdbcb421dc 100644 (file)
@@ -26,8 +26,8 @@
 // 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
index c74a635e942812520d7da6f4310931a8192f0751..6d61f6ce991a92e37dbc714b03009a34439e9ded 100644 (file)
 #include "../bobtoolz.h"
 #include "IntersectInfoDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CIntersectInfoDialog dialog
 
index 652d9cb07875e3c865148dec6a868d7a2f60c528..ec7ee2cd57696aaa76b42cc196b3f21106634b98 100644 (file)
 #include "PolygonDialog.h"
 #include "../shapes.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CPolygonDialog dialog
 
index 8b94092f68fddc6bb9b268cb1c41187bbbcea429..e0cd2f142db15dcd542760ba54ecd6b7abc80bcb 100644 (file)
 #include "../StdAfx.h"
 #include "StairDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CStairDialog dialog
 
index 0913f51bb7a3c710fba32846e275cc4ba8e994c6..4b9991a082bc3cffc0c49bd4571d94f8a9eeb2d8 100644 (file)
 #include "../bobtoolz.h"
 #include "TextureResetDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CTextureResetDialog dialog
 
index 3b3ac60716d13857a96e545fac493527938d05fb..0b36f21f4a74ab6671ef1abd411ee17d3cd225c3 100644 (file)
 #include "../bobtoolz.h"
 #include "BrushCheckDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CBrushCheckDialog dialog
 
index b596f0591a846ec8c50575818221155fcbdb6fbf..9329f306a2817e7823d6e95fb456ee9e310861b3 100644 (file)
    ---------------------------------*/
 
 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();
 }
 
@@ -59,31 +59,30 @@ void 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" );
 
@@ -91,23 +90,20 @@ static void dialog_button_callback( GtkWidget *widget, gpointer data ){
        *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 );
 }
 
@@ -115,7 +111,7 @@ static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){
     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 );
 
@@ -134,7 +130,7 @@ bool ValidateTextFloat( const char* pData, char* error_title, float* value ){
        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 );
 
@@ -156,7 +152,7 @@ bool ValidateTextFloatRange( const char* pData, float min, float max, char* erro
        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 );
 
@@ -178,7 +174,7 @@ bool ValidateTextIntRange( const char* pData, int min, int max, char* error_titl
        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 );
 
@@ -209,131 +205,118 @@ bool ValidateTextInt( const char* pData, char* error_title, int* value ){
  */
 
 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 );
-       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 );
+       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 );
-       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 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 );
@@ -342,96 +325,91 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
 
 
 
-       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_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 );
@@ -440,58 +418,58 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
 
 
 
-       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 ----
 
@@ -499,56 +477,56 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
 
 
 
-       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 ----
 
        // ---- /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 );
 
        bool dialogError = TRUE;
@@ -561,16 +539,16 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
                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;
                                }
                        }
@@ -578,7 +556,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 }
@@ -587,26 +565,20 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
 // 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 );
@@ -614,53 +586,53 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
        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
@@ -668,59 +640,59 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
        // 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 :)
@@ -729,65 +701,65 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
        // 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;
@@ -800,42 +772,42 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
                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
@@ -844,25 +816,19 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
 }
 
 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 );
@@ -870,170 +836,168 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
        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 )
@@ -1055,28 +1019,25 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
        }
 
        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 );
@@ -1085,122 +1046,122 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
 
 
 
-       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;
@@ -1231,23 +1192,23 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
        }
 
        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 );
@@ -1256,50 +1217,50 @@ EMessageBoxReturn DoCTFColourChangeBox(){
 
 
 
-       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;
 }
@@ -1307,271 +1268,231 @@ EMessageBoxReturn DoCTFColourChangeBox(){
 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_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 );
-       gtk_widget_show( window );
+       gtk_window_set_position( window, GTK_WIN_POS_CENTER );
+       window.show();
        gtk_grab_add( window );
 
        Update_TextureReseter();
@@ -1630,7 +1551,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 }
@@ -1638,222 +1559,194 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
 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;
@@ -1897,28 +1790,28 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
        }
 
        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 );
@@ -1926,69 +1819,69 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
        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;
@@ -2001,15 +1894,15 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
                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;
-}
\ No newline at end of file
+}
index ae35490431b48cfcd43779ecb82c292c77e21322..a8490459fac9e7922c7386a48a2a3186bac84c0e 100644 (file)
@@ -90,11 +90,9 @@ struct MakeChainRS {
        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 );
index ea64f26e64b595a4a60de60925864aa591ffae56..65e4f5061252ca7377135faf45e6a34176362df0 100644 (file)
 #include "../bobtoolz.h"
 #include "PathPlotterDialog.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CPathPlotterDialog dialog
 
index aa8e64786a1eeba47bc8acc455514b706e1acfc4..b07bf328f7642c0d5776bc70a340d9801d506d1b 100644 (file)
@@ -18,8 +18,9 @@
  */
 
 #include "funchandlers.h"
+#include "globaldefs.h"
 
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
 #pragma warning(disable : 4786)
 #endif
 
index b25cc6d8a75cf52770d3f450484e0c4aa97b2299..6062ea6e453328557984b6b154b5aa96770246b6 100644 (file)
@@ -28,22 +28,22 @@ extern DTrainDrawer* g_TrainView;
 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();
index 810798397d6b7cfac63542f60d41c17a8fb612a3..74e31bc89a2a00f07d2fcc206f1076ff8f92220b 100644 (file)
  */
 
 #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 ){
@@ -54,7 +53,7 @@ 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];
@@ -67,7 +66,7 @@ bool LoadGList( char* filename, GList** loadlist ){
                        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++;
index 827c9cbc1638b2a97221b7a8d5a181be4ea96717..7a8ecc1802dabb503b8c33ccc6f86d7a67ed56cf 100644 (file)
@@ -18,8 +18,9 @@
  */
 
 #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 );
index 977879f59e4b0fe4f239356eddef76aa623e87f3..f73c9787a0267a0fe49236bac473542e91f1c986 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include "misc.h"
+#include "globaldefs.h"
 
 #include <list>
 #include "str.h"
@@ -31,7 +32,7 @@
 
 #include "funchandlers.h"
 
-#if defined ( POSIX )
+#if GDEF_OS_POSIX
 #include <sys/types.h>
 #include <unistd.h>
 #endif
@@ -129,7 +130,7 @@ char* TranslateString( char *buf ){
 
        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';
@@ -146,7 +147,7 @@ char* TranslateString( char *buf ){
 
 
 char* UnixToDosPath( char* path ){
-#ifndef WIN32
+#if !GDEF_OS_WINDOWS
        return path;
 #else
        for ( char* p = path; *p; p++ )
@@ -182,7 +183,7 @@ extern char* PLUGIN_NAME;
     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() )
@@ -192,7 +193,7 @@ bool Q_Exec( const char *pCmd, bool bCreateConsole ){
 //      Error ("CreateProcess failed");
                break;
        case 0:
-#ifdef _DEBUG
+#if GDEF_DEBUG
                printf( "Running system...\n" );
                printf( "Command: %s\n", pCmd );
 #endif
@@ -208,7 +209,7 @@ bool Q_Exec( const char *pCmd, bool bCreateConsole ){
 }
 #endif
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 
 #include <windows.h>
 
index 02ca174b19b7699b4e161fa24b6054fb1b57a0ba..4383935630ce910e15ab51943f5639e1d9435a0e 100644 (file)
@@ -25,7 +25,7 @@
 #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 );
 
index f466c5153558315b3a223d3419558b87982ee6f7..2e47035d75b5e0630c611bc8395369198edc32b4 100644 (file)
@@ -58,9 +58,9 @@
        / |   / |
       /  |  /  |
     4 ----- 6  |
- |  2|_|___|8
- |  /  |   /
- | /   |  /       ----> WEST, definitely
    |  2|_|___|8
    |  /  |   /
    | /   |  /       ----> WEST, definitely
  ||/    | /
     1|_____|/3
 
diff --git a/contrib/brushexport/CMakeLists.txt b/contrib/brushexport/CMakeLists.txt
new file mode 100644 (file)
index 0000000..578588d
--- /dev/null
@@ -0,0 +1,10 @@
+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)
index 6a346f3a07a6ce7997c25f3f9e9a087651fe0f97..1e7dbb2a8d53d0799ed7724f1f4f2875e6e1f0f4 100644 (file)
@@ -13,13 +13,13 @@ void DestroyWindow();
 
 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;
@@ -30,19 +30,19 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){
        // 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 )
@@ -51,31 +51,31 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){
        // 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;
 
@@ -84,8 +84,8 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){
        }
 
        // 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;
 
@@ -94,8 +94,8 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){
        }
 
        // 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;
 
@@ -107,24 +107,22 @@ void OnExportClicked( GtkButton* button, gpointer user_data ){
        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 ) ) {
@@ -132,17 +130,17 @@ void OnRemoveMaterial( GtkButton* button, gpointer user_data ){
        }
 }
 
-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 );
        }
 }
 
index eea5aa8b334ff720267e3b54f0403d531a27ffd7..ca4b9a1440f9ccd5da306e7a5d0c46eba1abd1af 100644 (file)
@@ -1,12 +1,12 @@
-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
index 4a1e2d4c2d2566796aeebc2033c5b9eefd511c89..cbc4abf608fc26dae7fbb56e20c5b3df6bee9829 100644 (file)
@@ -1,4 +1,5 @@
 #include "export.h"
+#include "globaldefs.h"
 #include "debugging/debugging.h"
 #include "ibrush.h"
 #include "iscenegraph.h"
@@ -12,7 +13,7 @@
 #include "../../radiant/brush.h"
 
 // for limNames
-#define MAX_MATERIAL_NAME 20
+const int MAX_MATERIAL_NAME = 20;
 
 /*
     Abstract baseclass for modelexporters
@@ -126,7 +127,7 @@ void ExportData::AddBrushFace( Face& f ){
        // 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
 }
@@ -143,7 +144,7 @@ void ExportData::GetShaderNameFromShaderPath( const char* path, std::string& nam
                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
 }
index 76279ab043eb6dff5be61d5873cd8783b681a796..d464a02a810e96c89520c0ad2276b8252be99c42 100644 (file)
 
 #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_position( GTK_WINDOW( w_plugplug2 ), GTK_WIN_POS_CENTER );
-       gtk_window_set_destroy_with_parent( GTK_WINDOW( w_plugplug2 ), TRUE );
+       gtk_window_set_title( w_plugplug2, "BrushExport-Plugin 3.0 by namespace" );
+       gtk_window_set_position( w_plugplug2, GTK_WIN_POS_CENTER );
+       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" );
@@ -202,36 +177,37 @@ create_w_plugplug2( void ){
 }
 
 // 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;
 }
index 274c840ee70f1947e408e6b360693ff148c78d9b..2a221c7143d201067edc57c3e97c198f8b0d5afb 100644 (file)
@@ -24,7 +24,6 @@
 #include "qerplugin.h"
 
 #include <gtk/gtk.h>
-#include <gtk/gtktreeview.h>
 
 #include "debugging/debugging.h"
 #include "string/string.h"
@@ -50,11 +49,11 @@ bool IsWindowOpen( void );
 
 namespace BrushExport
 {
-GtkWindow* g_mainwnd;
+ui::Window g_mainwnd{ui::null};
 
 const char* init( void* hApp, void* pMainWidget ){
-       g_mainwnd = (GtkWindow*)pMainWidget;
-       ASSERT_NOTNULL( g_mainwnd );
+       g_mainwnd = ui::Window::from(pMainWidget);
+       ASSERT_TRUE( g_mainwnd );
        return "";
 }
 const char* getName(){
@@ -69,7 +68,7 @@ const char* getCommandTitleList(){
 
 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 );
index 79c5e145b6939eb4ef6aa1f0a32b1fecc11e5679..b2586177d969bf0bbbc97f160dab52052d4954d6 100644 (file)
@@ -1,22 +1,23 @@
 #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;
@@ -24,8 +25,7 @@ lookup_widget( GtkWidget       *widget,
                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 );
        }
index e8f4cb045d5d75ba3d0fc308242c86cd49bae524..20116a1341a83af38806447a1ea48f81a7dd0b71 100644 (file)
@@ -3,10 +3,10 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#  include <config.h>
+#include <config.h>
 #endif
 
-#include <gtk/gtk.h>
+#include <uilib/uilib.h>
 
 /*
  * Public Functions.
@@ -18,5 +18,5 @@
  * 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 );
index 0ee788d06c6f0d0688296400260b261da778c40a..60996afc67b373563e26c1d94013145058a97bf1 100644 (file)
@@ -39,8 +39,8 @@ static const char *PLUGIN_NAME = "Camera";
 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
index 896ca1be704687b94a6aee7453471df4ef530927..ba008a2cc0e2c342137034c54061894848b9c55c 100644 (file)
@@ -48,7 +48,6 @@ extern _QERQglTable __QGLTABLENAME;
 #include "bytebool.h"
 
 class CCamera;
-#include <gtk/gtk.h>
 
 #include "str.h"
 
@@ -157,8 +156,8 @@ void SetCurrentCam( CCamera *cam );
 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;
index acd2fbd4fbda8cb08936ffc582d27a99669833c5..5bcd984d179cd6a77e8dfb2dd8fcad6cf78703c1 100644 (file)
@@ -61,7 +61,7 @@ static gint ci_editmode_add( GtkWidget *widget, gpointer data ){
    }*/
 
 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;
@@ -69,11 +69,11 @@ static gint ci_new( GtkWidget *widget, gpointer data ){
 //     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 );
@@ -81,72 +81,72 @@ static gint ci_new( GtkWidget *widget, gpointer data ){
        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;
@@ -171,7 +171,7 @@ static gint ci_new( GtkWidget *widget, gpointer data ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return TRUE;
 }
@@ -314,7 +314,7 @@ static gint ci_pathlist_changed( GtkWidget *widget, gpointer data ){
        }
 
        // start edit mode
-       if ( g_pCameraInspectorWnd && GTK_WIDGET_VISIBLE( g_pCameraInspectorWnd ) ) {
+       if ( g_pCameraInspectorWnd && gtk_widget_get_visible( g_pCameraInspectorWnd ) ) {
                DoStartEdit( GetCurrentCam() );
        }
 
@@ -353,7 +353,7 @@ static void RefreshEventList( void ){
 }
 
 static gint ci_rename( GtkWidget *widget, gpointer data ){
-       GtkWidget *window, *w, *vbox, *hbox, *name;
+       GtkWidget *w, *hbox, *name;
        EMessageBoxReturn ret;
        int loop = 1;
 
@@ -362,11 +362,11 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){
        }
 
        // 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 );
@@ -374,23 +374,23 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){
        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() );
@@ -402,33 +402,33 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){
        // -------------------------- //
 
        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;
@@ -463,13 +463,13 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){
        }
 
        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;
@@ -481,11 +481,11 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){
        }
 
        // 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 );
@@ -493,89 +493,89 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){
        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;
@@ -611,7 +611,7 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){
 
                                // 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 ) {
@@ -629,7 +629,7 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return TRUE;
 }
@@ -675,7 +675,7 @@ void RefreshCamListCombo( void ){
                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;
@@ -756,7 +756,7 @@ static gint ci_camlist_changed( GtkWidget *widget, gpointer data ){
 
        // 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() );
        }
 
@@ -817,7 +817,7 @@ const char *camEventStr[] = {
 };
 
 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;
@@ -829,11 +829,11 @@ static gint ci_add( GtkWidget *widget, gpointer data ){
        }
 
        // 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 );
@@ -841,32 +841,32 @@ static gint ci_add( GtkWidget *widget, gpointer data ){
        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 );
                }
@@ -874,48 +874,48 @@ static gint ci_add( GtkWidget *widget, gpointer data ){
 
        // -------------------------- //
 
-       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;
@@ -952,7 +952,7 @@ static gint ci_add( GtkWidget *widget, gpointer data ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return TRUE;
 }
@@ -992,15 +992,15 @@ static gint ci_timeline_changed( GtkAdjustment *adjustment ){
 }
 
 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 );
@@ -1010,115 +1010,111 @@ GtkWidget *CreateCameraInspectorDialog( void ){
        // 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 ) {
@@ -1126,161 +1122,159 @@ GtkWidget *CreateCameraInspectorDialog( void ){
                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();
 
        // -------------------------- //
 
@@ -1294,71 +1288,65 @@ GtkWidget *CreateCameraInspectorDialog( void ){
        // -------------------------- //
 
        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();
 
        // -------------------------- //
 
index f53da8d0dd87643c020629c0100fd79db3668492..805071cabe0cefcaabacd23ae98796c0201531b4 100644 (file)
 
 #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" );
 
index 4134a889eda465366e89e360b87173420e267b3a..5d72242b5eb48654cd2e96b6d990632feb75c5be 100644 (file)
  */
 
 #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"
@@ -84,7 +85,7 @@ void DoNewSplineCamera(){
 }
 
 void DoCameraInspector(){
-       gtk_widget_show( g_pCameraInspectorWnd );
+       g_pCameraInspectorWnd.show();
 }
 
 void DoPreviewCamera(){
index 372dc7bc5e8ae54f6d4e64fc17075e8571537460..88207af7de5022bd66b355dc866a48fc730bcefb 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include "camera.h"
+#include "globaldefs.h"
 
 void Sys_ERROR( char* text, ... ){
        va_list argptr;
@@ -38,7 +39,7 @@ void Sys_ERROR( char* text, ... ){
 }
 
 char* UnixToDosPath( char* path ){
-#ifndef WIN32
+#if !GDEF_OS_WINDOWS
        return path;
 #else
        for ( char* p = path; *p; p++ )
@@ -132,7 +133,7 @@ void CDECL Com_Printf( const char* msg, ... ){
 }
 
 void CDECL Com_DPrintf( const char* msg, ... ){
-#ifdef _DEBUG
+#if GDEF_DEBUG
        va_list argptr;
        char buf[32768];
 
@@ -156,7 +157,7 @@ void Com_Dealloc( void *ptr ) {
 // Filesystem
 //
 
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
        #pragma warning(disable : 4311)
        #pragma warning(disable : 4312)
 #endif
index 6e226d33f5e4a1a8e5e42366139aff8b51091ea6..9b3f71b7d67e8b51a19a87b9a1bbb5bfb54b718b 100644 (file)
@@ -24,6 +24,8 @@
    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 );
@@ -40,7 +42,7 @@ void Cbuf_Execute( void );
 
 // common
 #ifndef CDECL
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        #define CDECL __cdecl
 #else
        #define CDECL
index 2ca7e6b4b6f02d6b33193a037a2fff30eb3b267c..68eea5c2c43ee611a0bec432075a855bf2dc8cf6 100644 (file)
@@ -438,7 +438,7 @@ bool OpenBitmap(){
 
        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 );
index bfaf98490eb3f7fe3649502775c07f4d52775bb3..e64a6598b5fc68c5bc63cb8dd8d8d9019dd82a22 100644 (file)
@@ -32,7 +32,7 @@
 //#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 )
 
@@ -111,12 +111,12 @@ static void SetupControls(){
 
        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 );
                }
 
@@ -316,7 +316,7 @@ static void SetDlgValues( int tab ){
                                                                  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++;
@@ -363,7 +363,7 @@ static void SetDlgValues( int tab ){
                }
                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 ) );
@@ -718,7 +718,7 @@ static void main_about( GtkWidget *widget, gpointer data ){
 }
 
 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 );
@@ -934,7 +934,7 @@ static gint fix_value_entryfocusout( GtkWidget* widget, GdkEventFocus *event, gp
                                                                         "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++ )
@@ -1100,19 +1100,19 @@ void create_tooltips(){
 
        // 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 "
@@ -1120,105 +1120,105 @@ void create_tooltips(){
                                                  "" );
 
        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 "
@@ -1226,7 +1226,7 @@ void create_tooltips(){
                                                  "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 "
@@ -1234,71 +1234,71 @@ void create_tooltips(){
                                                  "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 "
@@ -1306,32 +1306,32 @@ void create_tooltips(){
                                                  "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 "
@@ -1344,9 +1344,9 @@ void create_tooltips(){
 // 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" };
@@ -1355,835 +1355,711 @@ GtkWidget* create_main_dialog(){
        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 );
index b28416e29bb485fceda4f2177c90dfc1dd2370b7..1be8b135fa7aaf0dbb68a00b54a6d7b0988f266d 100644 (file)
@@ -71,7 +71,7 @@ int Antialiasing;             // ^Fishman - Antializing for the preview window.
 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;
@@ -409,7 +409,7 @@ void WriteIniFile( const char *file ){
 }
 
 void UpdatePreview( bool DataChange ){
-       if ( g_pWndPreview && GTK_WIDGET_VISIBLE( g_pWndPreview ) ) {
+       if ( g_pWndPreview && gtk_widget_get_visible( g_pWndPreview ) ) {
                if ( DataChange ) {
                        GenerateXYZ();
                }
index 99e4a46b74252e85f8f5b2df61ab1325827396be..84a78cd6d0b4c448bafe329f81e9bc1f5bb0a95f 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef _GENSURF_H_
 #define _GENSURF_H_
 
+#include "globaldefs.h"
 #include <string.h>
 #include "qertypes.h"
 #include <stdio.h>
@@ -48,8 +49,6 @@ extern _QERBrushTable __BRUSHTABLENAME;
 #include "igl.h"
 #include "ientity.h"
 
-#include <gtk/gtk.h>
-
 #include "iui_gtk.h"
 
 #include "gendlgs.h"
@@ -58,7 +57,7 @@ extern _QERBrushTable __BRUSHTABLENAME;
 #define PLUGIN
 #define Q3RADIANT
 
-//#if defined(__linux__) || defined(__APPLE__)
+//#if GDEF_OS_LINUX || GDEF_OS_MACOS
 #if 1
 #include <algorithm>
 #else
@@ -413,8 +412,8 @@ extern int SP;       // ^Fishman - Snap to grid.
    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;
index 38a730da77c133f3f2830898fed1cc2b825421a0..6acaa4b9bf41a378cd420078e0a9c40c18b26582 100644 (file)
@@ -140,7 +140,7 @@ void QERPlug_Dispatch( const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrus
                        UseFaceBounds();
                }
 
-               gtk_widget_show( g_pWnd );
+               g_pWnd.show();
        }
 }
 
index ba0c43d5251c1ce7bf32a310582afc4b39e5d608..975c5cae366a53ff7ef65a680a3f7a3ec98d6fbe 100644 (file)
@@ -91,7 +91,7 @@ void ShowPreview(){
                if ( g_pWndPreview == NULL ) {
                        CreateViewWindow();
                }
-               gtk_widget_show( g_pWndPreview );
+               g_pWndPreview.show();
 
                UpdatePreview( true );
        }
@@ -363,75 +363,74 @@ static void preview_spin( GtkAdjustment *adj, double *data ){
 }
 
 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 );
index 44393ea14f3fa0bd2d3199c0dbaccf821450f766..14f2c4b8b09d561325db145b34a60797fc16edcd 100644 (file)
@@ -58,11 +58,10 @@ void *g_pMainWnd;
 // =============================================================================
 // 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" );
 
@@ -81,111 +80,111 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer
 }
 
 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;
 }
index 7e9e97712d59a78ce507185e71a3aa66dcb93858..055cf9912f657600efe3e83c4980e5b3ae29d9f6 100644 (file)
 #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
index 1baec68defd0b56e6c23fc38a293052c29591263..f320de22e74b9771c2dd3ac697ebbacb9a51bb21 100644 (file)
 #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" );
 
@@ -38,63 +38,56 @@ static void dialog_button_callback( GtkWidget *widget, gpointer data ){
        *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 );
-       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 )
+       auto dlg = ui::Window(ui::window_type::TOP);
+       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();
 }
 
 
diff --git a/contrib/prtview/CMakeLists.txt b/contrib/prtview/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f08707f
--- /dev/null
@@ -0,0 +1,13 @@
+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)
index a91a6a2b8e4b618ccdebc5f267e33c6ffe09a98e..1d7f2743499b4a31460baa1b26376d230d39bb14 100644 (file)
@@ -20,6 +20,7 @@
 #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" );
 
@@ -39,13 +39,10 @@ static void dialog_button_callback( GtkWidget *widget, gpointer data ){
        *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;
 }
 
@@ -53,46 +50,45 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer
 // 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;
-
-       dlg = gtk_color_selection_dialog_new( "Choose Color" );
-       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 ) );
+       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" ));
+       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 );
@@ -100,7 +96,7 @@ static void Set2DText( GtkWidget* label ){
        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 );
@@ -108,7 +104,7 @@ static void Set3DText( GtkWidget* label ){
        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 );
@@ -116,7 +112,7 @@ static void Set3DTransText( GtkWidget* label ){
        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 );
@@ -124,36 +120,36 @@ static void SetClipText( GtkWidget* label ){
        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();
@@ -161,13 +157,13 @@ static void OnAntiAlias2d( GtkWidget *widget, gpointer data ){
        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();
 
@@ -175,21 +171,21 @@ static void OnColor2d( GtkWidget *widget, gpointer data ){
        }
 }
 
-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();
 
@@ -197,7 +193,7 @@ static void OnColor3d( GtkWidget *widget, gpointer data ){
        }
 }
 
-static void OnColorFog( GtkWidget *widget, gpointer data ){
+static void OnColorFog(ui::Widget widget, gpointer data ){
        if ( DoColor( &portals.color_fog ) == IDOK ) {
                Portals_shadersChanged();
 
@@ -205,269 +201,229 @@ static void OnColorFog( GtkWidget *widget, gpointer data ){
        }
 }
 
-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 );
-       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 );
+
+       auto dlg = ui::Window( ui::window_type::TOP );
+       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 );
@@ -479,7 +435,7 @@ void DoConfigDialog(){
        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 );
@@ -487,11 +443,11 @@ void DoConfigDialog(){
        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();
 }
index f3d4df8d06a0104867dd8d1b259e9d9b168a1016..9ebcd69b916ddba8f24a5eeb35684d4930c3c67a 100644 (file)
 #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" );
 
@@ -45,57 +44,28 @@ static void dialog_button_callback( GtkWidget *widget, gpointer data ){
        *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" );
-       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 ) );
+       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));
 
-       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_file_chooser_set_filename( GTK_FILE_CHOOSER(file_sel), portals.fn );
 
-       gtk_grab_add( file_sel );
-       gtk_widget_show( file_sel );
-
-       while ( loop )
-               gtk_main_iteration();
-
-       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 );
@@ -105,63 +75,62 @@ static void change_clicked( GtkWidget *widget, gpointer data ){
 }
 
 int DoLoadPortalFileDialog(){
-       GtkWidget *dlg, *vbox, *hbox, *button, *entry, *check2d, *check3d;
        int loop = 1, ret = IDCANCEL;
 
-       dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
-       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 );
+       auto dlg = ui::Window( ui::window_type::TOP );
+       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, '.' );
@@ -176,7 +145,7 @@ int DoLoadPortalFileDialog(){
        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();
@@ -189,7 +158,7 @@ int DoLoadPortalFileDialog(){
        }
 
        gtk_grab_remove( dlg );
-       gtk_widget_destroy( dlg );
+       dlg.destroy();
 
        return ret;
 }
index a896fcd4276e48ae18eee8d08ea66acea1655109..7a2d99d15ee76bea40ca854201e4a147d2d1a66c 100644 (file)
  */
 
 #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>
@@ -30,7 +31,7 @@
 
 #include "prtview.h"
 
-#define LINE_BUF 1000
+const int LINE_BUF = 1000;
 
 CPortals portals;
 CPortalsRender render;
@@ -271,7 +272,7 @@ void CPortals::Load(){
                }
 
                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;
@@ -603,7 +604,7 @@ void CPortalsDrawSolid::render( RenderStateFlags state ) const {
 }
 
 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;
@@ -613,26 +614,26 @@ void CPortalsDrawSolidOutline::render( RenderStateFlags state ) const {
                        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();
index 1fd2f0375fc04c2f9b8a740bfc96c40b8238ec79..4865108855fd835a0cdef9322c8c409ef98d093f 100644 (file)
@@ -53,9 +53,9 @@ bool Build( char *def );
 };
 
 #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 ) ) )
index 301ac9ea154a8835682c9b22a6a89d3a285ea359..080af13a3c8ba35a8b1e087a4cc7a7865c95b3a5 100644 (file)
@@ -48,23 +48,23 @@ CopiedString INIfn;
 /////////////////////////////////////////////////////////////////////////////
 // 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(){
@@ -160,9 +160,9 @@ void SaveConfig(){
 }
 
 
-#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 ) ) {
@@ -173,7 +173,7 @@ int INIGetInt( char *key, int def ){
        }
 }
 
-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 ) {
index e149ae80c99f9460a30bd5e46eec3398051f6945..6b0487826aff3b6b7834b80e9c5488c3e3c21d23 100644 (file)
 void InitInstance();
 void SaveConfig();
 
-int INIGetInt( char *key, int def );
-void INISetInt( char *key, int val, char *comment = 0 );
+int INIGetInt( const char *key, int def );
+void INISetInt( const char *key, int val, const char *comment = 0 );
 
-#define IDOK                1
-#define IDCANCEL            2
+const int IDOK                = 1;
+const int IDCANCEL            = 2;
 
 
 #endif
diff --git a/contrib/shaderplug/CMakeLists.txt b/contrib/shaderplug/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5e2ff0a
--- /dev/null
@@ -0,0 +1,9 @@
+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)
index 62e9abe6aa1df261f9bc64515f7783d31690bb05..9d7bc4c52c78eca92c1e9d80095534675e5dc5d0 100644 (file)
@@ -57,7 +57,7 @@ ShaderPlugPluginDependencies() :
 
 namespace Shaderplug
 {
-GtkWindow* g_window;
+ui::Window g_window{ui::null};
 
 std::vector<const char*> archives;
 std::set<std::string> shaders;
@@ -67,7 +67,7 @@ XmlTagBuilder TagBuilder;
 void CreateTagFile();
 
 const char* init( void* hApp, void* pMainWidget ){
-       g_window = GTK_WINDOW( pMainWidget );
+       g_window = ui::Window::from(pMainWidget);
        return "";
 }
 const char* getName(){
@@ -81,7 +81,7 @@ const char* getCommandTitleList(){
 }
 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,
@@ -96,8 +96,6 @@ void loadArchiveFile( const char* filename ){
        archives.push_back( filename );
 }
 
-typedef FreeCaller1<const char*, loadArchiveFile> LoadArchiveFileCaller;
-
 void LoadTextureFile( const char* filename ){
        std::string s_filename = filename;
 
@@ -116,10 +114,8 @@ void LoadTextureFile( const char* 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 ){
@@ -128,14 +124,12 @@ 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";
 }
 
@@ -181,23 +175,23 @@ void CreateTagFile(){
                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",
diff --git a/contrib/sunplug/CMakeLists.txt b/contrib/sunplug/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9def181
--- /dev/null
@@ -0,0 +1,6 @@
+radiant_plugin(sunplug
+        sunplug.cpp sunplug.h
+        )
+
+target_include_directories(sunplug PRIVATE uilib)
+target_link_libraries(sunplug PRIVATE uilib)
index 50fb2cd8ee681f8abd93d02f2b3596c13251d966..ac8233d1fd87f29d2986fd21d8134c1fece223fa 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include "sunplug.h"
+#include "globaldefs.h"
 
 #include "debugging/debugging.h"
 
@@ -39,7 +40,7 @@
 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
@@ -72,7 +73,7 @@ char* itoa( int value, char* result, int base ){
 #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;
 
@@ -113,7 +114,7 @@ Entity* Scene_FindEntityByClass( const char* name ){
 // ** 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.
@@ -124,17 +125,17 @@ static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data
 }
 
 // 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 );
@@ -142,12 +143,12 @@ static void input_optimal( GtkWidget *widget, gpointer data ){
 }
 
 // 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];
 
@@ -184,11 +185,11 @@ SunPlugPluginDependencies() :
 //  *************************
 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(){
@@ -253,29 +254,27 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server
 
 // 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
 }
@@ -314,24 +313,22 @@ void GetOptimalCoordinates( AABB *levelBoundingBox ){
 
 // 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
@@ -366,77 +363,77 @@ void MapCoordinator(){
                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
 }
diff --git a/contrib/ufoaiplug/CMakeLists.txt b/contrib/ufoaiplug/CMakeLists.txt
new file mode 100644 (file)
index 0000000..88389cb
--- /dev/null
@@ -0,0 +1,9 @@
+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)
index bb11866430e1068f9012759f8703c4aa1eefd881..99815ab013b670aec626b4f3c0993d7f8e2bf62b 100644 (file)
@@ -59,10 +59,10 @@ UFOAIPluginDependencies( void ) :
 
 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(){
@@ -76,10 +76,14 @@ const char* getCommandTitleList(){
        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" ) ) {
@@ -129,7 +133,7 @@ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush
        }
 
        if ( message != NULL ) {
-               GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ),
+               GlobalRadiant().m_pfnMessageBox( g_mainwnd,
                                                                                 message, "Note",
                                                                                 eMB_OK, eMB_ICONDEFAULT );
        }
index 84a9665252d0245df6ff6d8ed781e694f9d96542..c40de733bb4385e09282d02dd5618f34eea177e6 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include "ufoai_filters.h"
+#include "globaldefs.h"
 
 #include "ibrush.h"
 #include "ientity.h"
@@ -100,7 +101,7 @@ ForEachFace( Brush& brush )
 }
 
 void visit( Face& face ) const {
-#if _DEBUG
+#if GDEF_DEBUG
        if ( m_surfaceFlagsVis < 0 ) {
                m_surfaceFlagsVis = face.getShader().m_flags.m_surfaceFlags;
        }
@@ -215,7 +216,7 @@ void filter_level( int flag ){
        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";
        }
@@ -264,7 +265,7 @@ void filter_nodraw( void ){
        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";
        }
@@ -285,7 +286,7 @@ void filter_actorclip( void ){
        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";
        }
@@ -306,7 +307,7 @@ void filter_weaponclip( void ){
        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";
        }
index 840c45bc0dd2d328c6af70cc9c43ac1f39490120..99289922a3c29069d31ae17944ad485062515107 100644 (file)
@@ -25,18 +25,18 @@ void filter_actorclip( void );
 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
index c547047431968301491b59ff066da872e697ab80..39a983b645f31f0b24b1ba1526f345af6a76e8cc 100644 (file)
 #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,
@@ -43,27 +32,27 @@ UFOAIGtk( void* gtk_window ) : m_gtk_window( ( GtkWindow* )gtk_window ){
  * 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
index 0254f7d6de5dc14407e325a279f0ad6864457ec7..939c1f6f56cc8a1650ad25eba929a014d3b6ac7d 100644 (file)
@@ -20,7 +20,6 @@
 #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 );
index c7554e4d2c4771858e3b438cd16cd1afa468ca03..41a4c62bd371eb9332219c24bffa7dafb0a4d4ae 100644 (file)
@@ -130,7 +130,7 @@ void get_team_count( const char *classname, int *count, int *team ){
 /**
  * @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;
@@ -190,7 +190,7 @@ int check_entity_flags( const char *classname, const char *flag ){
  * @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;
index e9d5e176d583fb70ba9753ae08ecf73b687947c8..714f05fc076ad7d44f2e0b392a0e8e529cc2ef50 100644 (file)
@@ -19,8 +19,8 @@
 #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
index 68811708f1101fb3ab436ebd50eebd988f263885..de757e082ddf9ee4360fd4bce4be492b86724c35 100644 (file)
@@ -11,6 +11,6 @@
   </style>
 </head>
 <body>
-<p class="p1"><a href="http://dev.xonotic.org/projects/xonotic/wiki/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>
diff --git a/download-gamepacks.sh b/download-gamepacks.sh
deleted file mode 100755 (executable)
index 7717cd2..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/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
diff --git a/gamepack-manager b/gamepack-manager
new file mode 100755 (executable)
index 0000000..6f280f6
--- /dev/null
@@ -0,0 +1,689 @@
+#! /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
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
new file mode 100644 (file)
index 0000000..40ab793
--- /dev/null
@@ -0,0 +1,48 @@
+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
+        )
diff --git a/include/cullable.cpp b/include/cullable.cpp
deleted file mode 100644 (file)
index 395d3e1..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/defaults.h b/include/defaults.h
new file mode 100644 (file)
index 0000000..96cb241
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+   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
diff --git a/include/dpkdeps.h b/include/dpkdeps.h
new file mode 100644 (file)
index 0000000..424fbdc
--- /dev/null
@@ -0,0 +1,91 @@
+#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
diff --git a/include/editable.cpp b/include/editable.cpp
deleted file mode 100644 (file)
index 63314dc..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/iarchive.cpp b/include/iarchive.cpp
deleted file mode 100644 (file)
index 1cf0005..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index dddf5579853e5dac3ec916e15638efa7276b6710..b6cfda19d465f34b42b6bceef2c949226058ff1a 100644 (file)
@@ -31,6 +31,7 @@ class InputStream;
 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.
@@ -50,6 +51,7 @@ class TextInputStream;
 class ArchiveTextFile
 {
 public:
+virtual ~ArchiveTextFile() = default;
 /// \brief Destroys the file object.
 virtual void release() = 0;
 /// \brief Returns the stream associated with this file.
@@ -75,6 +77,7 @@ class CustomArchiveVisitor;
 class Archive
 {
 public:
+virtual ~Archive() = default;
 
 class Visitor
 {
diff --git a/include/ibrush.cpp b/include/ibrush.cpp
deleted file mode 100644 (file)
index f075783..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 1171f8a7199980cada591c7fbe0a1597737465b5..93dc17e7bef4abe48427f8e3f9ed4aaafda0068f 100644 (file)
@@ -95,7 +95,7 @@ int flags;
 int value;
 };
 
-typedef Callback1<const _QERFaceData&> BrushFaceDataCallback;
+typedef Callback<void(const _QERFaceData&)> BrushFaceDataCallback;
 
 class BrushCreator
 {
diff --git a/include/icamera.cpp b/include/icamera.cpp
deleted file mode 100644 (file)
index bad7cac..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index e9becbae6f82748b4771d811e276275d7931e004..1ba28e2ae67972cf0960a91a3bdfc19fbeb51438 100644 (file)
@@ -29,7 +29,7 @@
 #define INCLUDED_ICAMERA_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 class Matrix4;
 
@@ -44,7 +44,7 @@ class CameraModel
 {
 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;
diff --git a/include/idatastream.cpp b/include/idatastream.cpp
deleted file mode 100644 (file)
index e6ef881..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/ieclass.cpp b/include/ieclass.cpp
deleted file mode 100644 (file)
index 5fd59c3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/ientity.cpp b/include/ientity.cpp
deleted file mode 100644 (file)
index 88dd59e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index c315b3abb2708a527c355ee7759efe44ef5d5363..dd3f253c8082be09116f28f25c213f776adae627 100644 (file)
 
 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;
@@ -123,7 +124,7 @@ virtual void setCounter( Counter* counter ) = 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;
diff --git a/include/ifilesystem.cpp b/include/ifilesystem.cpp
deleted file mode 100644 (file)
index 154f906..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 6bbc0db21789718a137d99528c49d77da01a374e..d7e128e6e1791a83f40dcc81102a01acbfb26fc3 100644 (file)
 
 #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;
@@ -50,6 +50,10 @@ virtual void initDirectory( const char *path ) = 0;
 /// \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;
 
@@ -120,7 +124,7 @@ inline VirtualFileSystem& GlobalFileSystem(){
 /// \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 ){
diff --git a/include/ifiletypes.cpp b/include/ifiletypes.cpp
deleted file mode 100644 (file)
index b4e5566..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/ifilter.cpp b/include/ifilter.cpp
deleted file mode 100644 (file)
index a5e732f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/igl.cpp b/include/igl.cpp
deleted file mode 100644 (file)
index 41781a4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index eca09ae74d653e6c7e19ad1a6223adf8992d76b0..cb7b66d17ac07171dae5fc67dfa56ca8ab1da736 100644 (file)
 #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
@@ -2805,7 +2806,7 @@ inline OpenGLBinding& GlobalOpenGL(){
        return GlobalOpenGLModule::getTable();
 }
 
-#if defined( _DEBUG )
+#if GDEF_DEBUG
 #define GlobalOpenGL_debugAssertNoErrors() GlobalOpenGL().assertNoErrors( __FILE__, __LINE__ )
 #else
 #define GlobalOpenGL_debugAssertNoErrors()
diff --git a/include/iglrender.cpp b/include/iglrender.cpp
deleted file mode 100644 (file)
index 6a9d9a7..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-
-#include "iglrender.h"
diff --git a/include/igtkgl.cpp b/include/igtkgl.cpp
deleted file mode 100644 (file)
index d0084a8..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index e6e852545f11c585d2ccf64585a37ebb1f3997d3..b4454564d12e8e1665704a36e45d94c717294943 100644 (file)
 #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
diff --git a/include/iimage.cpp b/include/iimage.cpp
deleted file mode 100644 (file)
index f438be7..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index c159e657152af1ba8ede594a4c3d53ffb99e234e..7f355f2ce17b8337f2219bf02ff5f3e51612dac8 100644 (file)
@@ -29,6 +29,7 @@ typedef unsigned char byte;
 class Image
 {
 public:
+virtual ~Image() = default;
 virtual void release() = 0;
 virtual byte* getRGBAPixels() const = 0;
 virtual unsigned int getWidth() const = 0;
diff --git a/include/imap.cpp b/include/imap.cpp
deleted file mode 100644 (file)
index a91f14d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 7af4c4721335f9bb016b1f2ba2b8b58c9e7ab037..4661a794768fb349f2bf3247aee9567dfbedfec9 100644 (file)
@@ -59,6 +59,7 @@ typedef void ( *GraphTraversalFunc )( scene::Node& root, const scene::Traversabl
 class MapFormat
 {
 public:
+virtual ~MapFormat() = default;
 INTEGER_CONSTANT( Version, 2 );
 STRING_CONSTANT( Name, "map" );
 mutable bool wrongFormat;
@@ -66,7 +67,7 @@ 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;
 };
 
 
diff --git a/include/imodel.cpp b/include/imodel.cpp
deleted file mode 100644 (file)
index 0b932e2..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/ipatch.cpp b/include/ipatch.cpp
deleted file mode 100644 (file)
index e29029c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index e9bee3d79bbc0bcf7d42bfefa84c07647f364bf2..bf26e8b45e5507b3d82177f54def97ecf8734d64 100644 (file)
@@ -22,6 +22,8 @@
 #if !defined( INCLUDED_IPATCH_H )
 #define INCLUDED_IPATCH_H
 
+#include "globaldefs.h"
+#include "debugging/debugging.h"
 #include "generic/constant.h"
 #include "generic/vector.h"
 
@@ -61,13 +63,13 @@ const_iterator end() const {
 }
 
 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];
@@ -166,25 +168,25 @@ const_iterator end() const {
 }
 
 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];
diff --git a/include/iplugin.cpp b/include/iplugin.cpp
deleted file mode 100644 (file)
index 2a7dab9..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/ireference.cpp b/include/ireference.cpp
deleted file mode 100644 (file)
index d2f56c4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/irender.cpp b/include/irender.cpp
deleted file mode 100644 (file)
index 9726b6d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 5199454287cb9081797c61cfddc7a96461df0baf..169d881a9c59e0c1cadcc8f85d291edb64e5fc16 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_IRENDER_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 
 // Rendering states to sort by.
@@ -88,9 +88,9 @@ virtual void clearLights(){
 };
 
 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
 {
@@ -107,6 +107,7 @@ const int c_attr_Binormal = 4;
 class OpenGLRenderable
 {
 public:
+virtual ~OpenGLRenderable() = default;
 virtual void render( RenderStateFlags state ) const = 0;
 };
 
@@ -119,6 +120,7 @@ class ModuleObserver;
 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;
diff --git a/include/iscenegraph.cpp b/include/iscenegraph.cpp
deleted file mode 100644 (file)
index 48cbcf2..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 6b28b0fc9a7122c3f5cf6184ebbd3263f120e987..569cf864c08a4e951ac8ef1b97a39e920637d731 100644 (file)
@@ -70,6 +70,7 @@ typedef Stack<NodeReference> Path;
 class Graph
 {
 public:
+virtual ~Graph() = default;
 INTEGER_CONSTANT( Version, 1 );
 STRING_CONSTANT( Name, "scenegraph" );
 
diff --git a/include/iscriplib.cpp b/include/iscriplib.cpp
deleted file mode 100644 (file)
index 3c4ba18..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 8f64503355b4ded1267a926dfd20a2dc4f3f42ab..e070406fc3fd6437697b4ca0f1c290bfb74eaa3f 100644 (file)
@@ -33,6 +33,7 @@
 class Tokeniser
 {
 public:
+virtual ~Tokeniser() = default;
 virtual void release() = 0;
 virtual void nextLine() = 0;
 virtual const char* getToken() = 0;
@@ -46,6 +47,7 @@ class TextInputStream;
 class TokenWriter
 {
 public:
+virtual ~TokenWriter() = default;
 virtual void release() = 0;
 virtual void nextLine() = 0;
 virtual void writeToken( const char* token ) = 0;
diff --git a/include/iselection.cpp b/include/iselection.cpp
deleted file mode 100644 (file)
index c0686cf..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index f5c76310b1cc4e17196ebebb33157c1779f839e0..9207271e1c4c52a6bc8f8557ab03cb7bb2ef3c96 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <cstddef>
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 #include "signal/signalfwd.h"
 
 class Renderer;
@@ -42,7 +42,7 @@ virtual bool isSelected() const = 0;
 namespace scene
 {
 class Instance;
-};
+}
 
 class InstanceSelectionObserver
 {
@@ -57,12 +57,13 @@ typedef BasicVector4<float> Vector4;
 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" );
 
diff --git a/include/ishaders.cpp b/include/ishaders.cpp
deleted file mode 100644 (file)
index 4a7affd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index ac447090cbd99fb9cde9aeade1cf8d833113e375..f588c287440e2e1c91355920729e98ca86ae76a9 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_ISHADERS_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 enum
 {
@@ -78,8 +78,7 @@ virtual bool clampToBorder() const = 0;
 virtual float alphaTest() const = 0;
 };
 
-typedef Callback1<const ShaderLayer&> ShaderLayerCallback;
-
+typedef Callback<void(const ShaderLayer&)> ShaderLayerCallback;
 
 class IShader
 {
@@ -132,7 +131,7 @@ virtual qtexture_t* lightFalloffImage() const = 0;
 };
 
 typedef struct _GSList GSList;
-typedef Callback1<const char*> ShaderNameCallback;
+typedef Callback<void(const char*)> ShaderNameCallback;
 
 class ModuleObserver;
 
@@ -159,7 +158,7 @@ virtual bool endActiveShadersIterator() = 0;
 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;
@@ -183,7 +182,6 @@ inline ShaderSystem& GlobalShaderSystem(){
        return GlobalShadersModule::getTable();
 }
 
-
 #define QERApp_Shader_ForName GlobalShaderSystem().getShaderForName
 #define QERApp_ActiveShaders_IteratorBegin GlobalShaderSystem().beginActiveShadersIterator
 #define QERApp_ActiveShaders_IteratorAtEnd GlobalShaderSystem().endActiveShadersIterator
diff --git a/include/itexdef.cpp b/include/itexdef.cpp
deleted file mode 100644 (file)
index 462a7a2..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/itextstream.cpp b/include/itextstream.cpp
deleted file mode 100644 (file)
index 3ce3df7..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/include/itextures.cpp b/include/itextures.cpp
deleted file mode 100644 (file)
index ae75c63..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index cc91399d2c452115b233e660ad5ab9d5fe139e43..6fa4b02ca51e6c9d7200483cd87248a1c411b33c 100644 (file)
@@ -59,6 +59,7 @@ virtual void realise() = 0;
 class TexturesCache
 {
 public:
+virtual ~TexturesCache() = default;
 INTEGER_CONSTANT( Version, 1 );
 STRING_CONSTANT( Name, "textures" );
 virtual LoadImageCallback defaultLoader() const = 0;
diff --git a/include/itoolbar.cpp b/include/itoolbar.cpp
deleted file mode 100644 (file)
index 146f755..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 62d82b6ec889e83f5b1641bd92b821067525dc22..7e5daad302a0eae0761d0c51f13a7797bff35819 100644 (file)
@@ -33,7 +33,6 @@ enum EType
        eSpace,
        eButton,
        eToggleButton,
-       eRadioButton,
 };
 
 virtual const char* getImage() const = 0;
diff --git a/include/iundo.cpp b/include/iundo.cpp
deleted file mode 100644 (file)
index 8dfd9e2..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index eb1e8681c9c16a7882d240306dc20bff43daafb0..25fa14899672b3a115f6c74ebeb72b4f3cb5da1d 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <cstddef>
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 class UndoMemento
 {
diff --git a/include/mapfile.cpp b/include/mapfile.cpp
deleted file mode 100644 (file)
index 5a6332e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index df1ab36fd7f44388a2d73447bc89bfc105a01495..02cd360e8bd0dee938a79415389eea9f1ba9130d 100644 (file)
@@ -25,7 +25,7 @@
 #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();
 
@@ -37,7 +37,7 @@ STRING_CONSTANT( Name, "MapFile" );
 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;
 };
 
diff --git a/include/modelskin.cpp b/include/modelskin.cpp
deleted file mode 100644 (file)
index fcdda39..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index bb5922ee7704b89c48ee666a8c5d353dd9e1b1b2..b070cc778255c021d716d2b6114cde9e624cf691 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_MODELSKIN_H
 
 #include "generic/constant.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 class SkinRemap
 {
@@ -34,12 +34,13 @@ SkinRemap( const char* from, const char* to ) : m_from( from ), m_to( to ){
 }
 };
 
-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;
@@ -64,6 +65,7 @@ virtual void skinChanged() = 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'.
diff --git a/include/moduleobserver.cpp b/include/moduleobserver.cpp
deleted file mode 100644 (file)
index f9d40b1..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 496d6f2e930d402eb9fdb2f7470e7d31e479672e..0559b850bdd308ffd602b8b0bf35a72105ac6637 100644 (file)
@@ -25,6 +25,7 @@
 class ModuleObserver
 {
 public:
+virtual ~ModuleObserver() = default;
 virtual void unrealise() = 0;
 virtual void realise() = 0;
 };
diff --git a/include/modulesystem.cpp b/include/modulesystem.cpp
deleted file mode 100644 (file)
index 907e8f7..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 8b1913fb850d26fce2b6162be5abf56ec2117f5c..f7d4656440a1f71c0a54d0474e33225a420ff1af 100644 (file)
 #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
 
@@ -150,7 +146,7 @@ ModuleRef( const char* name ) : m_table( 0 ){
        }
 }
 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;
@@ -181,7 +177,7 @@ void initialise( const char* name ){
 }
 
 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;
diff --git a/include/nameable.cpp b/include/nameable.cpp
deleted file mode 100644 (file)
index 8722c47..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index bbc6f899250891667cda4361fc0d56189d536df5..ceb7aabb450a999c995f3fc591c89e3bee8b8a22 100644 (file)
@@ -23,9 +23,9 @@
 #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
 {
diff --git a/include/namespace.cpp b/include/namespace.cpp
deleted file mode 100644 (file)
index f9b22f5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 9a00793c07a99350d9cabd2317130f63c90a78b0..0b24059f879f8859ffc73f992ccaa87d60de38ea 100644 (file)
 #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
 {
index 6152cb14865140d173ff2daf6df1eb9daaf34436..5796d76f0fbd44db47b0ddc1004010818c9eda2e 100644 (file)
@@ -75,14 +75,14 @@ void importString( const char* value ){
        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 );
@@ -113,11 +113,11 @@ void importString( const char* value ){
        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
index 45678024ffd8ec0a6df23e509a7d708fc8ed5369..6479ec91d32e7adabafc1d654d5b85611717754c 100644 (file)
 #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>
diff --git a/include/qerplugin.cpp b/include/qerplugin.cpp
deleted file mode 100644 (file)
index 5476001..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 3c1db04679701ce62c878c4e530599930e515b6e..b6a8865f2bcc6c9b42c147f6469c3704cdb834e8 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef __QERPLUGIN_H__
 #define __QERPLUGIN_H__
 
+#include "uilib/uilib.h"
 #include "generic/constant.h"
 
 
@@ -35,7 +36,6 @@
 // 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
 {
@@ -65,28 +65,27 @@ enum EMessageBoxReturn
 
 // 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 );
 
 // ========================================
 
@@ -124,6 +123,7 @@ struct _QERFuncTable_1
        const char* ( *getSettingsPath )( );
        const char* ( *getMapsPath )( );
 
+       const char* ( *getGameFile )( );
        const char* ( *getGameName )( );
        const char* ( *getGameMode )( );
 
@@ -134,15 +134,6 @@ struct _QERFuncTable_1
        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 );
diff --git a/include/renderable.cpp b/include/renderable.cpp
deleted file mode 100644 (file)
index dfc186f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 8b972170ed7c723c786956a966e6f72cc21dffea..d50ca7a8f57c87e4616f4cd6e5c14b5335d53c23 100644 (file)
@@ -48,7 +48,7 @@ enum EStyle
 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 ){
 }
@@ -60,6 +60,7 @@ class VolumeTest;
 class Renderable
 {
 public:
+virtual ~Renderable() = default;
 STRING_CONSTANT( Name, "Renderable" );
 
 virtual void renderSolid( Renderer& renderer, const VolumeTest& volume ) const = 0;
diff --git a/include/selectable.cpp b/include/selectable.cpp
deleted file mode 100644 (file)
index 38a2d1a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 2b8eab073c24de63358749f01081885c7e7efbe1..cb6f04c4522c254384e1c63ab4b4f88bdbab3935 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "generic/vector.h"
 #include "scenelib.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 class SelectionIntersection
 {
@@ -250,7 +250,7 @@ inline SelectionTestable* Instance_getSelectionTestable( scene::Instance& instan
 
 
 class Plane3;
-typedef Callback1<const Plane3&> PlaneCallback;
+typedef Callback<void(const Plane3&)> PlaneCallback;
 
 class SelectedPlanes
 {
index 47134512ca426de70d7955ac5c7745a2a02afe5a..3df8773e90359c41d4f7eca588c4c66d5db2ec21 100644 (file)
@@ -8,3 +8,6 @@
 #ifndef RADIANT_MINOR_VERSION
 #error no RADIANT_MINOR_VERSION defined
 #endif
+#ifndef RADIANT_PATCH_VERSION
+#error no RADIANT_PATCH_VERSION defined
+#endif
index e067fd11eb53c3086d6380dc984f968a13447d64..ebbd4f88c8d39b623120600938f53af675b7683e 100644 (file)
@@ -22,7 +22,9 @@
 #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
diff --git a/include/windowobserver.cpp b/include/windowobserver.cpp
deleted file mode 100644 (file)
index 16b4a00..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index b72d0820682b4d458e1290e20f985b1e4914632d..24948634ca1d05e2c7d3f72b1bd689cf25ac6e0d 100644 (file)
@@ -79,6 +79,7 @@ typedef Vector2 WindowVector;
 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;
diff --git a/install-gamepack.sh b/install-gamepack.sh
deleted file mode 100755 (executable)
index 3a36c20..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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
diff --git a/install-gamepacks.sh b/install-gamepacks.sh
deleted file mode 100755 (executable)
index f4ae842..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/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
diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt
new file mode 100644 (file)
index 0000000..633b965
--- /dev/null
@@ -0,0 +1,67 @@
+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})
diff --git a/libs/_.cpp b/libs/_.cpp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/libs/archivelib.cpp b/libs/archivelib.cpp
deleted file mode 100644 (file)
index a66f130..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/bytebool.cpp b/libs/bytebool.cpp
deleted file mode 100644 (file)
index d636f55..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/bytestreamutils.cpp b/libs/bytestreamutils.cpp
deleted file mode 100644 (file)
index 87917d2..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 156333a17cd6d599f7eff919250005977da8d6dd..69ec3755f9c0ca1da77eecc976f53f2d0f7d55d4 100644 (file)
@@ -22,7 +22,9 @@
 #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
@@ -55,18 +57,20 @@ typedef unsigned int uint32_t;
 
 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>
@@ -82,6 +86,13 @@ inline int16_t istream_read_int16_le( InputStreamType& istream ){
        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;
@@ -89,6 +100,13 @@ inline uint16_t istream_read_uint16_le( InputStreamType& istream ){
        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;
@@ -96,6 +114,13 @@ inline int32_t istream_read_int32_le( InputStreamType& istream ){
        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;
@@ -103,6 +128,13 @@ inline uint32_t istream_read_uint32_le( InputStreamType& istream ){
        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;
@@ -110,6 +142,13 @@ inline float istream_read_float32_le( InputStreamType& istream ){
        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;
diff --git a/libs/character.cpp b/libs/character.cpp
deleted file mode 100644 (file)
index cd36bc7..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 843dee76368813bf469914e77d7c5d7f8ef2c2d7..abdc15a6fd3cfd6d4d2da873c2f65d58d0c54713 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef __CMDLIB__
 #define __CMDLIB__
 
+#include "globaldefs.h"
 #include <time.h>
 
 
@@ -78,7 +79,7 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *execdir, bool bCreateCo
 
 // 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;
diff --git a/libs/cmdlib/.cvswrappers b/libs/cmdlib/.cvswrappers
deleted file mode 100644 (file)
index ed97d40..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-*.dsp  -m 'COPY' -k 'b'
-*.dsw  -m 'COPY' -k 'b'
-*.scc  -m 'COPY' -k 'b'
diff --git a/libs/cmdlib/CMakeLists.txt b/libs/cmdlib/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5d25ce8
--- /dev/null
@@ -0,0 +1,3 @@
+add_library(cmdlib
+        cmdlib.cpp ../cmdlib.h
+        )
index 2a9ab55a35182430f3a94c202fb2d7d700ceaa7f..9bfd24364dc4bff37e09a5354b10f3070cf7d364 100644 (file)
@@ -24,6 +24,7 @@
 //
 
 #include "cmdlib.h"
+#include "globaldefs.h"
 
 #include <string.h>
 #include <stdio.h>
@@ -33,7 +34,7 @@
 #include "container/array.h"
 
 
-#if defined ( POSIX )
+#if GDEF_OS_POSIX
 
 #include <unistd.h>
 #include <sys/types.h>
@@ -43,7 +44,7 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){
        char fullcmd[2048];
        char *pCmd;
        pid_t pid;
-#ifdef _DEBUG
+#if GDEF_DEBUG
        printf( "Q_Exec damnit\n" );
 #endif
        switch ( ( pid = fork() ) )
@@ -71,12 +72,12 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){
                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 );
@@ -85,7 +86,7 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){
        return true;
 }
 
-#elif defined( WIN32 )
+#elif GDEF_OS_WINDOWS
 
 #include <windows.h>
 
diff --git a/libs/container/CMakeLists.txt b/libs/container/CMakeLists.txt
new file mode 100644 (file)
index 0000000..00bfbb4
--- /dev/null
@@ -0,0 +1,8 @@
+add_library(container
+        array.cpp array.h
+        cache.h
+        container.h
+        hashfunc.h
+        hashtable.cpp hashtable.h
+        stack.h
+        )
index c359df15f2dea4392cf273ab1ea7dc32662e71b7..5de4fe824852ffbe6059eaf899070ed77bc40232 100644 (file)
@@ -22,6 +22,7 @@
 #if !defined( INCLUDED_CONTAINER_ARRAY_H )
 #define INCLUDED_CONTAINER_ARRAY_H
 
+#include "globaldefs.h"
 #include <cstddef>
 #include <algorithm>
 
@@ -119,13 +120,13 @@ const_iterator end() const {
 }
 
 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];
@@ -166,5 +167,4 @@ inline void swap( Array<Element, Allocator>& self, Array<Element, Allocator>& ot
        self.swap( other );
 }
 }
-
 #endif
diff --git a/libs/container/cache.cpp b/libs/container/cache.cpp
deleted file mode 100644 (file)
index 5cbdb00..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 880a7a7a57604dd7f90727a124db3c9b488f1197..047e4ea8f94c77a6e7060bab9584282e60f02e38 100644 (file)
@@ -95,83 +95,83 @@ pointer operator->() const {
 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();
+       }
 };
 
 
diff --git a/libs/container/container.cpp b/libs/container/container.cpp
deleted file mode 100644 (file)
index 8790307..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 47f823e67314b18d539ea02ac30c2b1ce780a8c4..a2d1fec91bd17437da9024e32599ce852cba97e6 100644 (file)
@@ -22,6 +22,7 @@
 #if !defined( INCLUDED_CONTAINER_CONTAINER_H )
 #define INCLUDED_CONTAINER_CONTAINER_H
 
+#include <algorithm>
 #include <list>
 #include <set>
 
diff --git a/libs/container/hashfunc.cpp b/libs/container/hashfunc.cpp
deleted file mode 100644 (file)
index 4c3d2e0..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 6d2166971488b65e7601395d47a533c8aefe9d4e..305202d0c9f00435bdcdab0c0798363abf5a8ef2 100644 (file)
@@ -203,17 +203,17 @@ inline ub4 hash(
        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 */
        }
index edcaff637bdca4b646ea8f21d5e6b65ef35f7d0d..f2e66022385e2988aaef24eaaba2e2cc6b4af1d5 100644 (file)
@@ -20,8 +20,9 @@
  */
 
 #include "hashtable.h"
+#include "globaldefs.h"
 
-#if defined( _DEBUG ) || defined( DOXYGEN )
+#if GDEF_DEBUG || defined( DOXYGEN )
 
 #include "hashfunc.h"
 
index 2c5677ce6d67f657e9d3b03268e921c4dbdef90c..7fa7907ee6cefd6de693a75d6c10f0e65ab00e03 100644 (file)
@@ -25,9 +25,9 @@
 #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 ){
diff --git a/libs/container/stack.cpp b/libs/container/stack.cpp
deleted file mode 100644 (file)
index 81d79b2..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/convert.cpp b/libs/convert.cpp
deleted file mode 100644 (file)
index c87038f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/crnrgba/CMakeLists.txt b/libs/crnrgba/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6e8463d
--- /dev/null
@@ -0,0 +1,10 @@
+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)
diff --git a/libs/crnrgba/crn_rgba.cpp b/libs/crnrgba/crn_rgba.cpp
new file mode 100644 (file)
index 0000000..8dec126
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+   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;
+}
diff --git a/libs/crnrgba/crn_rgba.h b/libs/crnrgba/crn_rgba.h
new file mode 100644 (file)
index 0000000..b674957
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+   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
diff --git a/libs/crunch b/libs/crunch
new file mode 160000 (submodule)
index 0000000..85bab3d
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 85bab3d798a54abe32a22d5275e625ec06df6917
diff --git a/libs/ddslib/CMakeLists.txt b/libs/ddslib/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d4de1a7
--- /dev/null
@@ -0,0 +1,3 @@
+add_library(ddslib
+        ddslib.c ../ddslib.h
+        )
index b60e506bed180d56b25c3e37df43d56455af3bd2..15dbef80a25172fe9d28b5dfae800dc1fb128dd8 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-
-/* marker */
-#define DDSLIB_C
-
-
-
 /* dependencies */
 #include "ddslib.h"
-
-
+#include "globaldefs.h"
 
 /* endian tomfoolery */
 typedef union
@@ -55,15 +47,7 @@ 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; }
diff --git a/libs/debugging/CMakeLists.txt b/libs/debugging/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e5880de
--- /dev/null
@@ -0,0 +1,3 @@
+add_library(debugging
+        debugging.cpp debugging.h
+        )
index c549a2f2072a9f3e72a62a6ebf5c2e49a94cc348..405131d24433703cffaf095d5ee5fde618c888bc 100644 (file)
 /// \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
 {
@@ -72,7 +71,7 @@ virtual TextOutputStream& getOutputStream(){
        return globalErrorStream();
 }
 virtual bool handleMessage(){
-#if defined( _DEBUG )
+#if GDEF_DEBUG
        return false; // send debug-break
 #else
        return true;
@@ -116,7 +115,8 @@ inline DebugMessageHandler& globalDebugMessageHandler(){
                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
 
diff --git a/libs/dragplanes.cpp b/libs/dragplanes.cpp
deleted file mode 100644 (file)
index 89da666..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/eclasslib.cpp b/libs/eclasslib.cpp
deleted file mode 100644 (file)
index 04d0d69..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index d2730d62beb07e3b732ad14e8648ec4dc02101f6..2a92fcdb738fcdd2fb14cf5a5027b5d9663c6c8e 100644 (file)
@@ -38,8 +38,8 @@ typedef Vector3 Colour3;
 
 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:
 
diff --git a/libs/entitylib.cpp b/libs/entitylib.cpp
deleted file mode 100644 (file)
index 48f3138..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 7f1bb0c1c355163e625124aeaaa04ee458b880fe..83f35f02ea959b758f4f9afbfa0cc587aee44fa2 100644 (file)
@@ -366,7 +366,7 @@ void importState( const CopiedString& string ){
 
        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.
@@ -524,7 +524,7 @@ public:
 
                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" );
diff --git a/libs/entityxml.cpp b/libs/entityxml.cpp
deleted file mode 100644 (file)
index 13b7408..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/etclib.c b/libs/etclib.c
new file mode 100644 (file)
index 0000000..09a149e
--- /dev/null
@@ -0,0 +1,114 @@
+// 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 );
+}
diff --git a/libs/etclib.h b/libs/etclib.h
new file mode 100644 (file)
index 0000000..7d24074
--- /dev/null
@@ -0,0 +1,33 @@
+// 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
diff --git a/libs/etclib/CMakeLists.txt b/libs/etclib/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8d8fb23
--- /dev/null
@@ -0,0 +1,3 @@
+add_library(etclib
+        ../etclib.c ../etclib.h
+        )
diff --git a/libs/filematch/CMakeLists.txt b/libs/filematch/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c7d8a9e
--- /dev/null
@@ -0,0 +1,3 @@
+add_library(filematch
+        ../filematch.c ../filematch.h
+        )
diff --git a/libs/fs_filesystem.cpp b/libs/fs_filesystem.cpp
deleted file mode 100644 (file)
index 9b781a3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/fs_path.cpp b/libs/fs_path.cpp
deleted file mode 100644 (file)
index f38bf1c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/generic/CMakeLists.txt b/libs/generic/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d89f574
--- /dev/null
@@ -0,0 +1,13 @@
+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
+        )
diff --git a/libs/generic/arrayrange.cpp b/libs/generic/arrayrange.cpp
deleted file mode 100644 (file)
index 0ee018b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/generic/bitfield.cpp b/libs/generic/bitfield.cpp
deleted file mode 100644 (file)
index 7e46a34..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index db04d53e3c1a96d2a40c065ea073f06f4048d846..7022e8cf65900a89e11917cbefd46561e27a08bf 100644 (file)
@@ -20,8 +20,9 @@
  */
 
 #include "callback.h"
+#include "globaldefs.h"
 
-#if defined( _DEBUG ) || defined( DOXYGEN )
+#if GDEF_DEBUG || defined( DOXYGEN )
 
 namespace ExampleMemberCaller
 {
@@ -39,14 +40,14 @@ void setValue(){
        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()
@@ -55,7 +56,7 @@ void example(){
 
        {
                // use the typedef to improve readability
-               Callback bar = Integer::SetValueCaller( foo );
+               Callback<void()> bar = Integer::SetValueCaller( foo );
 
                // invoke the callback
                bar(); // foo.setValue()
@@ -76,13 +77,13 @@ void Int_setValue( int& value ){
 }
 
 // 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)
@@ -91,7 +92,7 @@ void example(){
 
        {
                // use the typedef to improve readability
-               Callback bar = IntSetValueCaller( foo );
+               Callback<void()> bar = IntSetValueCaller( foo );
 
                // invoke the callback
                bar(); // Int_setValue(foo)
@@ -122,133 +123,131 @@ class Test
 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;
        }
index 2ce007fcb2780fbedfdb4b2adee11567f509786d..577dd9d958bd337082f9c2479c5c1803e664c1a3 100644 (file)
 
 #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
diff --git a/libs/generic/callbackfwd.cpp b/libs/generic/callbackfwd.cpp
deleted file mode 100644 (file)
index af15774..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-
-#include "callbackfwd.h"
diff --git a/libs/generic/callbackfwd.h b/libs/generic/callbackfwd.h
deleted file mode 100644 (file)
index 48c01d3..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#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
index 7c3c2fa65911bc04e6e1353cfece470a5b5f19a9..bcf9b4e5527a824e25877832604fce4010ed6d29 100644 (file)
@@ -20,8 +20,9 @@
  */
 
 #include "constant.h"
+#include "globaldefs.h"
 
-#if defined( _DEBUG ) || defined( DOXYGEN )
+#if GDEF_DEBUG || defined( DOXYGEN )
 
 namespace ExampleConstant
 {
index 83817947faf57d6add630748556ff968fb321079..e7e7ba04c47d35c79726b3208b83e62f7eff7358 100644 (file)
@@ -40,9 +40,10 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const
        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, "" );
 
diff --git a/libs/generic/enumeration.cpp b/libs/generic/enumeration.cpp
deleted file mode 100644 (file)
index c6071cd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/generic/functional.cpp b/libs/generic/functional.cpp
deleted file mode 100644 (file)
index e6cc857..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-
-#include "functional.h"
index 940d4e7fd0af09b448faa099f07ebd8c8e6a904b..2b4fe1b2e61ce2cd2ff64116b93b144951e56799 100644 (file)
-
 #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
index 5677a0e3428253338a1cae403f3598808458eb2b..084f760c7e465ce12f18382abc3f45e9437a7958 100644 (file)
 #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
 
diff --git a/libs/generic/reference.cpp b/libs/generic/reference.cpp
deleted file mode 100644 (file)
index fd64f28..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/generic/referencecounted.cpp b/libs/generic/referencecounted.cpp
deleted file mode 100644 (file)
index 0c531bd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index b32972de84231eb0f72bc6042440331d7a9b0306..a92246bb4100eb8d560a1ca7e86814a0faf1aff4 100644 (file)
@@ -20,8 +20,9 @@
  */
 
 #include "static.h"
+#include "globaldefs.h"
 
-#if defined( _DEBUG ) || defined( DOXYGEN )
+#if GDEF_DEBUG || defined( DOXYGEN )
 
 namespace ExampleStatic
 {
diff --git a/libs/generic/vector.cpp b/libs/generic/vector.cpp
deleted file mode 100644 (file)
index fbafd53..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-
-#include "vector.h"
diff --git a/libs/globaldefs.h b/libs/globaldefs.h
new file mode 100644 (file)
index 0000000..146dd78
--- /dev/null
@@ -0,0 +1,125 @@
+#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
diff --git a/libs/gtkutil/CMakeLists.txt b/libs/gtkutil/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b62098c
--- /dev/null
@@ -0,0 +1,37 @@
+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 ()
index c49c2c703605621157ae252bb7361584f180bf3e..00380d452f8eb6c66fcac93a0439693c0b2f0cee 100644 (file)
@@ -25,8 +25,7 @@
 
 #include <map>
 #include <set>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkaccelgroup.h>
+#include <gtk/gtk.h>
 
 #include "generic/callback.h"
 #include "generic/bitfield.h"
@@ -57,7 +56,7 @@ unsigned int global_keys_find( const char* name ){
                return 0;
        }
        k = gdk_keyval_from_name( name );
-       if ( k == GDK_VoidSymbol ) {
+       if ( k == GDK_KEY_VoidSymbol ) {
                return 0;
        }
        return k;
@@ -87,10 +86,10 @@ void accelerator_write( const Accelerator& accelerator, TextOutputStream& ostrea
        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;
        }
@@ -110,8 +109,8 @@ bool accelerator_map_erase( AcceleratorMap& acceleratorMap, Accelerator accelera
 
 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() ) );
 }
@@ -126,7 +125,7 @@ bool AcceleratorMap_activate( const AcceleratorMap& acceleratorMap, const Accele
        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 ) );
 }
 
@@ -173,7 +172,7 @@ ButtonMask ButtonMask_for_event_button( guint button ){
        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;
 }
 
@@ -187,13 +186,13 @@ bool global_accel_enabled(){
 }
 
 
-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";
        }
@@ -222,14 +221,7 @@ void globalQueuedAccelerators_commit(){
        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 ){
@@ -238,15 +230,12 @@ 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
                }
        }
@@ -264,15 +253,12 @@ bool Buttons_release( ButtonMask& buttons, guint button, guint state ){
                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();
@@ -298,35 +284,36 @@ struct PressedButtons
        }
 };
 
-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
 {
@@ -363,24 +350,24 @@ void Keys_releaseAll( PressedKeys::Keys& keys, guint state ){
        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 );
        }
@@ -393,18 +380,18 @@ void GlobalPressedKeys_releaseAll(){
        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" ) ) );
@@ -413,7 +400,7 @@ void GlobalPressedKeys_disconnect( GtkWindow* window ){
 
 
 
-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";
@@ -426,7 +413,7 @@ void special_accelerators_remove( Accelerator accelerator ){
        }
 }
 
-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";
@@ -439,7 +426,7 @@ 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 ){
        //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";
@@ -453,12 +440,12 @@ void keyup_accelerators_remove( Accelerator accelerator ){
 }
 
 
-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 );
@@ -472,7 +459,7 @@ GClosure* accel_group_add_accelerator( GtkAccelGroup* group, Accelerator acceler
        }
 }
 
-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 );
@@ -483,17 +470,9 @@ void accel_group_remove_accelerator( GtkAccelGroup* group, Accelerator accelerat
        }
 }
 
-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";
@@ -512,30 +491,30 @@ void global_accel_group_remove_accelerator( Accelerator accelerator ){
 }
 
 /// \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 );
 
@@ -565,13 +544,13 @@ GClosure* global_accel_group_find( Accelerator accelerator ){
        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 );
        }
index d1cd344e5e130c53cbc664a5d470d8f804cc2fd0..528dd6bb9269ac18d6c8f44f06117c1b4c2638c8 100644 (file)
 #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 ) )
@@ -81,35 +81,30 @@ TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const Accele
        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 ){
 }
 };
 
@@ -117,8 +112,8 @@ class Toggle
 {
 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 ){
 }
 };
 
@@ -126,17 +121,16 @@ class KeyEvent
 {
 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;
 
index fc1e58d7bb955b4d06d9789a90b21b1a336275bf..9f40f9e9600fae70f465782742c7b8675e23cf65 100644 (file)
@@ -21,7 +21,7 @@
 
 #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
@@ -42,7 +42,15 @@ void button_connect_callback( GtkButton* button, const Callback& callback ){
 #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
@@ -52,13 +60,23 @@ guint toggle_button_connect_callback( GtkToggleButton* button, const Callback& c
        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));
@@ -70,28 +88,35 @@ void toggle_button_set_active_no_signal( GtkToggleButton* button, gboolean activ
        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 ) )
                {
@@ -107,9 +132,9 @@ void radio_button_set_active_no_signal( GtkRadioButton* radio, int index ){
        }
 }
 
-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 ) )
        {
index 15a9f2e8cd4513d10894710d12a92ccf6f8e5a9e..238b207c7a98e821ffdc336b449355612506fb3f 100644 (file)
 #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
index c8073aba478bf6922a77be881b769c4461544de9..fd36f39e547b951336a61036bc3b778936135366 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "clipboard.h"
 
+#include "globaldefs.h"
 #include "stream/memstream.h"
 #include "stream/textstream.h"
 
@@ -28,7 +29,7 @@
 /// \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";
 
@@ -83,15 +84,17 @@ void clipboard_paste( ClipboardPasteFunc paste ){
 
 #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 ){
@@ -111,11 +114,11 @@ static void clipboard_clear( GtkClipboard *clipboard, 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 );
        }
 }
diff --git a/libs/gtkutil/closure.cpp b/libs/gtkutil/closure.cpp
deleted file mode 100644 (file)
index 09e2fab..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 9696464a649ae6d3fce5230693a9ebe3911afc3a..39945827b78c8fa4a33c6fe3f5c5b9ef2aae58b0 100644 (file)
 #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(){
diff --git a/libs/gtkutil/container.cpp b/libs/gtkutil/container.cpp
deleted file mode 100644 (file)
index 8790307..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index b6b6afa4f43e1199e1e269ffd3bf7797bc272d86..12d0ca99706020b5b6910f03c595df1c72158bfa 100644 (file)
 #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
index f0538a5089963bad6a1c7f5279b2bce7c73c4daa..999621f12ecdb4f633076aace99cd2579bbee9be 100644 (file)
 #include "stream/textstream.h"
 
 #include <string.h>
-#include <gdk/gdkcursor.h>
-#include <gdk/gdkpixmap.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
 
 
 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 );
 }
 
 
-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, &current_x, &current_y );
+       int dx = current_x - self->last_x;
+       int dy = current_y - self->last_y;
+       int ddx = current_x - self->recorded_x;
+       int ddy = current_y - self->recorded_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->recorded_x, self->recorded_y );
+                       self->last_x = self->recorded_x;
+                       self->last_y = self->recorded_y;
+               }
+               self->m_function( dx, dy, event->state, self->m_data );
+       }
+       return FALSE;
+}
+
+void FreezePointer::freeze_pointer(ui::Window window, 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();
+       //GdkGrabStatus status =
+       gdk_pointer_grab( gtk_widget_get_window(window), TRUE, mask, 0, cursor, GDK_CURRENT_TIME );
+       gdk_cursor_unref( cursor );
+
+       Sys_GetCursorPos( window, &recorded_x, &recorded_y );
+
+       Sys_SetCursorPos( window, recorded_x, recorded_y );
+
+       last_x = recorded_x;
+       last_y = recorded_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)
+{
+       g_signal_handler_disconnect( G_OBJECT( window ), handle_motion );
+
+       m_function = 0;
+       m_data = 0;
+
+       Sys_SetCursorPos( window, recorded_x, recorded_y );
+
+       gdk_pointer_ungrab( GDK_CURRENT_TIME );
+}
index dfcc962c1d1d8ff1a02b3a9500c921b2023222d3..2d16142eb9f71134c1bb93ae384632024c837565 100644 (file)
 #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 <uilib/uilib.h>
 
 #include "debugging/debugging.h"
 
 typedef struct _GdkCursor GdkCursor;
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
+typedef struct _GdkEventMotion GdkEventMotion;
 
 GdkCursor* create_blank_cursor();
-void blank_cursor( GtkWidget* widget );
-void default_cursor( GtkWidget* widget );
-void Sys_GetCursorPos( GtkWindow* window, int *x, int *y );
-void Sys_SetCursorPos( GtkWindow* window, int x, int y );
+void blank_cursor( ui::Widget widget );
+void default_cursor( ui::Widget widget );
+void Sys_GetCursorPos( ui::Window window, int *x, int *y );
+void Sys_SetCursorPos( ui::Window window, int x, int y );
 
 
 
@@ -67,10 +63,7 @@ void motion( gdouble x, gdouble y, guint state ){
                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
@@ -121,68 +114,11 @@ 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 ), &current_x, &current_y );
-       int dx = current_x - self->last_x;
-       int dy = current_y - self->last_y;
-       int ddx = current_x - self->recorded_x;
-       int ddy = current_y - self->recorded_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->recorded_x, self->recorded_y );
-                       self->last_x = self->recorded_x;
-                       self->last_y = self->recorded_y;
-               }
-               self->m_function( dx, dy, event->state, self->m_data );
-       }
-       return FALSE;
-}
-
-void freeze_pointer( GtkWindow* window, 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();
-       //GdkGrabStatus status =
-       gdk_pointer_grab( GTK_WIDGET( window )->window, TRUE, mask, 0, cursor, GDK_CURRENT_TIME );
-       gdk_cursor_unref( cursor );
-
-       Sys_GetCursorPos( window, &recorded_x, &recorded_y );
+static gboolean motion_delta( ui::Window widget, GdkEventMotion *event, FreezePointer* self );
 
-       Sys_SetCursorPos( window, recorded_x, recorded_y );
+void freeze_pointer( ui::Window window, MotionDeltaFunction function, void* data );
 
-       last_x = recorded_x;
-       last_y = recorded_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 ){
-       g_signal_handler_disconnect( G_OBJECT( window ), handle_motion );
-
-       m_function = 0;
-       m_data = 0;
-
-       Sys_SetCursorPos( window, recorded_x, recorded_y );
-
-       gdk_pointer_ungrab( GDK_CURRENT_TIME );
-}
+void unfreeze_pointer( ui::Window window );
 };
 
 #endif
index fb513e97d5d0e1982c09bd7d487220a6a2df364e..aa8aad47d0a873046151804c55d918f01c5ee973 100644 (file)
 
 #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 )
@@ -104,22 +95,22 @@ EMessageBoxReturn modal_dialog_show( GtkWindow* window, ModalDialog& dialog ){
                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 );
@@ -127,74 +118,74 @@ GtkWindow* create_fixedsize_modal_dialog_window( GtkWindow* parent, const char*
 
        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 );
        }
@@ -204,26 +195,26 @@ RadioHBox RadioHBox_new( StringArrayRange names ){
 
 
 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 );
 }
@@ -231,46 +222,42 @@ PathEntry PathEntry_new(){
 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 );
 }
index 5a87731e1819ba0c2bd53fdb3770b6e8865c9319..79330143679b85a05e49fdfb3574294c3a1a9990 100644 (file)
 #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
@@ -61,42 +51,36 @@ struct ModalDialogButton
 
 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 ){
 }
@@ -108,10 +92,10 @@ RadioHBox RadioHBox_new( StringArrayRange names );
 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 ){
@@ -123,8 +107,8 @@ PathEntry PathEntry_new();
 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;
@@ -132,10 +116,9 @@ 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
index 2640da0fb2df74243a6672c759503a6f05b2d55b..acb74db887baa751a4cafa6c3dcd3a9c7bb2e0c2 100644 (file)
@@ -1,22 +1,37 @@
-/*
-   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));
+}
index 814be152bfd901791839b3224ce51acd91223b53..067157af64847b2bbb97c7e23bb23f5dda0dbc7b 100644 (file)
    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
index 82ba697b78b963cff3c1ccd3f210f147b43fcb03..f375e53a91e2cef067eb20ed828b51f640d6f1fc 100644 (file)
 
 #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"
@@ -127,7 +124,7 @@ filetype_pair_t GetTypeForGTKMask( const char *mask ) const {
 
 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 ) {
@@ -143,28 +140,28 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c
                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 ) ) {
@@ -242,7 +239,7 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c
                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' ) {
@@ -252,16 +249,16 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c
        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 );
@@ -272,20 +269,20 @@ char* dir_dialog( GtkWidget* parent, const char* title, const char* 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;
                }
        }
index f4610bea33b2661a03f89166781f901395b86b80..cdad28b72158ec49616809d4552bec1c8f152529 100644 (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
index 8914fb707937980da8fa4984771c969ef0d02cdc..6baab763b50307c6b7a5788a272824f2a08af219 100644 (file)
 
 #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;
 }
index ebeccc28d2f3d60588487dbab05c00a76c429cd8..ecdd7fcc78b5ec90e88be08acc68a30f61076341 100644 (file)
    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
index 09211a05450d3bd103dfb691ff8e6bfb9b04dde2..afe8546e7c8dd00305c8b0b43935c875fedf7687 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "glfont.h"
+#include "globaldefs.h"
 #include "igl.h"
 
 // generic string printing with call lists
@@ -50,7 +51,7 @@ virtual int getPixelHeight() const {
 }
 };
 
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
        #include <windows.h>
 #endif
 #include "debugging/debugging.h"
@@ -174,6 +175,7 @@ GLFont *glfont_create( const char* font_string ){
 // new font code ripped from ZeroRadiant
 
 #include <pango/pangoft2.h>
+#include <pango/pango-features.h>
 #include <pango/pango-utils.h>
 
 class GLFontInternal : public GLFont
index 746b8f0f9202d34b92a8a0c079ff98591a0ff4e4..52cec49cf2a58d329001a7ad12a2e1ad7dfc4926 100644 (file)
 
 #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_tconfigs_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
index 43e26dc7d4dddd689025fc5e83d6a50e792b9a5f..6a43da88ca3eb2379a10737d7e71661ea62bbd08 100644 (file)
    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
diff --git a/libs/gtkutil/idledraw.cpp b/libs/gtkutil/idledraw.cpp
deleted file mode 100644 (file)
index b50d41f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 6267951d755b34a1219c3c17906c0d9bdadbfa0c..97791023c2ba181cdc4269cbf4dae444f1e3b9f5 100644 (file)
@@ -28,7 +28,7 @@
 
 class IdleDraw
 {
-Callback m_draw;
+Callback<void()> m_draw;
 unsigned int m_handler;
 static gboolean draw( gpointer data ){
        reinterpret_cast<IdleDraw*>( data )->m_draw();
@@ -36,7 +36,7 @@ static gboolean draw( gpointer data ){
        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 ) {
@@ -48,7 +48,7 @@ void queueDraw(){
                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 ) {
index 2791fd47393a09a921458c8b31839e6392af8273..a79b5b144b1d77bc86e296c1045ce886d531eabd 100644 (file)
@@ -21,8 +21,7 @@
 
 #include "image.h"
 
-#include <gtk/gtkimage.h>
-#include <gtk/gtkstock.h>
+#include <gtk/gtk.h>
 
 #include "string/string.h"
 #include "stream/stringstream.h"
@@ -46,41 +45,37 @@ GdkPixbuf* pixbuf_new_from_file_with_mask( const char* filename ){
        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
-               gdk_pixbuf_unref( rgb );
+               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 ) );
-               gdk_pixbuf_unref( 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() );
index cf452559b1938e1d9533789c32fd91689bc828f4..6a8d419b2087f3dcdf5b9a353360008aa19436ba 100644 (file)
    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
index cbb07df8fef5518fbee2238258c9c05cb9b1d451..2a8c55fb8592d75f07dcb6bf7a54d3a021db879e 100644 (file)
 #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
@@ -91,7 +89,7 @@ guint menu_item_connect_callback( GtkMenuItem* item, const Callback& callback ){
 #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
@@ -101,50 +99,50 @@ guint check_menu_item_connect_callback( GtkCheckMenuItem* item, const Callback&
        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 );
@@ -153,7 +151,7 @@ void check_menu_item_set_active_no_signal( GtkCheckMenuItem* item, gboolean acti
 
 
 
-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 ) )
                {
@@ -170,7 +168,7 @@ void radio_menu_item_set_active_no_signal( GtkRadioMenuItem* item, gboolean acti
 }
 
 
-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 );
 }
@@ -226,55 +224,28 @@ void accelerator_name( const Accelerator& accelerator, GString* gstring ){
        }
 }
 
-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;
 }
index a64291d4bf1d288263bb09923f144c4f4cadf05b..2ff78f89e58a4384f74b649e5a523db7e11bc5a1 100644 (file)
 #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
index 8f9fb7fa02a812442f398b4927b0e70b6e8f6275..82d6dfe4b02ad2ddc49327f7cd4bc91e4911771c 100644 (file)
 #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;
 }
 
@@ -59,122 +51,120 @@ const char* messagebox_stock_icon( EMessageBoxIcon type ){
        }
 }
 
-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;
@@ -182,23 +172,23 @@ EMessageBoxReturn gtk_MessageBox( GtkWidget *parent, const char* text, const cha
        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;
 }
index 8bdc0ba2e6fb63848262e96b5d6b5448ceb2b727..4ae8a3f8a52c5b7fc44c6004de32847e4f538c18 100644 (file)
@@ -24,8 +24,7 @@
 
 #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
index edca0b73d62ad8a1228a36df3b8223cba32e303e..f9da2dbf40b98738d6c50a89114b1c346b7efd7f 100644 (file)
-/*
-   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);
+    }
+}
index 864779bd1603e8a6912723dacffb426a9ca15a23..53318679a4ca51150994da1e08587d7b603bca03 100644 (file)
 #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);
 };
 
 
index c5adc09cd7ce71b1e28932d1790fb007af0bf740..4f724eef96bd6c247bd11044f0911278a5de39d4 100644 (file)
@@ -21,8 +21,8 @@
 
 #include "paned.h"
 
-#include <gtk/gtkhpaned.h>
-#include <gtk/gtkvpaned.h>
+#include <gtk/gtk.h>
+#include <uilib/uilib.h>
 
 #include "frame.h"
 
@@ -34,7 +34,7 @@ float position;
 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 ) );
@@ -42,7 +42,7 @@ gboolean hpaned_allocate( GtkWidget* widget, GtkAllocation* allocation, PanedSta
        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 ) );
@@ -50,7 +50,7 @@ gboolean vpaned_allocate( GtkWidget* widget, GtkAllocation* allocation, PanedSta
        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 );
        }
@@ -61,34 +61,34 @@ PanedState g_hpaned = { 0.5f, -1, };
 PanedState g_vpaned1 = { 0.5f, -1, };
 PanedState g_vpaned2 = { 0.5f, -1, };
 
-GtkHPaned* create_split_views( GtkWidget* topleft, GtkWidget* topright, GtkWidget* botleft, GtkWidget* botright ){
-       GtkHPaned* hsplit = GTK_HPANED( gtk_hpaned_new() );
-       gtk_widget_show( GTK_WIDGET( hsplit ) );
+ui::HPaned create_split_views( ui::Widget topleft, ui::Widget topright, ui::Widget botleft, ui::Widget botright ){
+       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() );
-               gtk_paned_add1( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) );
-               gtk_widget_show( GTK_WIDGET( vsplit ) );
+               auto vsplit = ui::VPaned(ui::New);
+               gtk_paned_add1( GTK_PANED( hsplit ), vsplit  );
+               vsplit.show();
 
-               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( topright ) ) );
+               gtk_paned_add1( GTK_PANED( vsplit ), create_framed_widget( topleft  ) );
+               gtk_paned_add2( GTK_PANED( vsplit ), create_framed_widget( topright  ) );
        }
        {
-               GtkVPaned* vsplit = GTK_VPANED( gtk_vpaned_new() );
-               gtk_paned_add2( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) );
-               gtk_widget_show( GTK_WIDGET( vsplit ) );
+               auto vsplit = ui::VPaned(ui::New);
+               gtk_paned_add2( GTK_PANED( hsplit ), vsplit  );
+               vsplit.show();
 
-               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( botleft ) ) );
-               gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( botright ) ) );
+               gtk_paned_add1( GTK_PANED( vsplit ), create_framed_widget( botleft  ) );
+               gtk_paned_add2( GTK_PANED( vsplit ), create_framed_widget( botright  ) );
        }
        return hsplit;
 }
index 8b79f931ff62ab28d2c7dc5eda433cd620a1f28c..842996efb5e3db6097b3cfa1899766e50c99cecd 100644 (file)
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <uilib/uilib.h>
+
 #if !defined( INCLUDED_GTKUTIL_PANED_H )
 #define INCLUDED_GTKUTIL_PANED_H
 
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkHPaned GtkHPaned;
-GtkHPaned* create_split_views( GtkWidget* topleft, GtkWidget* topright, GtkWidget* botleft, GtkWidget* botright );
+ui::HPaned create_split_views( ui::Widget topleft, ui::Widget topright, ui::Widget botleft, ui::Widget botright );
 
 #endif
diff --git a/libs/gtkutil/pointer.cpp b/libs/gtkutil/pointer.cpp
deleted file mode 100644 (file)
index 503845a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 3ac74f610451be6cd95ddb7795059774f42c7f7d..8df8802d27d1b250d8c16d2c1ed8909b63d3ec41 100644 (file)
 
 #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;
 }
index 6b9e32fb71f118c377bf5393a72e7db32646fcee..c995e1be4a3879dfe5d013ffe73d9f2f66034cb2 100644 (file)
 #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
index e212fdf644350e3d53be45dbb328041e8e7b9676..9d9c1a8d33e2e4f87e7c5182b813d36267269790 100644 (file)
@@ -1,22 +1,86 @@
-/*
-   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);
+}
index f4bc32671b80efce8375799b0a910c5bd565fd33..ff93211dc632e46e85983530be09c7f13b4d98ba 100644 (file)
 #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;
 }
@@ -49,127 +53,90 @@ inline void widget_set_visible( GtkWidget* widget, bool show ){
                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
index 74b724fddf613ba805bc37da9484f86cb61f4846..c1613500d12298de8664e83fe286787ab21de039 100644 (file)
 
 #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);
@@ -118,52 +121,143 @@ GtkWindow* create_floating_window( const char* title, GtkWindow* parent ){
        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;
+}
index 1a7161e6dfd34d1b32c63889d86002995b7ac4c6..69135f833f897bae273569133d746b325047449d 100644 (file)
 #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
index e4f46c6b8b171a838841c651b4ce216b125e89b9..e7012328d104a9df2c68916465cfbed088f85496 100644 (file)
@@ -1,22 +1,99 @@
-/*
-   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 );
+                               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();
+
+                               glDrawBuffer( GL_BACK );
+                               GlobalOpenGL_debugAssertNoErrors();
+                               //glwidget_swap_buffers( m_widget );
+                               glwidget_make_current( m_widget );
+                       }
+               }
+               m_rectangle = rectangle;
+    }
+}
index 73f1387f218daf7a6a8367466d63038d239ad259..2341f1f0c5005165fef67275264a065ed4f6494a 100644 (file)
 #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:
@@ -69,64 +61,20 @@ inline rectangle_t rectangle_from_area( const float min[2], const float max[2],
 
 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 );
-                               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();
-
-                               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 );
 };
 
 
diff --git a/libs/imagelib.cpp b/libs/imagelib.cpp
deleted file mode 100644 (file)
index 08e2d27..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/instancelib.cpp b/libs/instancelib.cpp
deleted file mode 100644 (file)
index 52dfc8d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 913288b6a9b127b90566412d78f96f3f13ad5c70..af9dd2bba31a181f3eb6b4e7c24f7e4c93cf8ed1 100644 (file)
@@ -135,14 +135,14 @@ void transformChanged(){
                ( *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>
@@ -153,23 +153,16 @@ inline void InstanceSet_forEach( InstanceSet& instances, const Functor& 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
diff --git a/libs/l_net/CMakeLists.txt b/libs/l_net/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a0a19a8
--- /dev/null
@@ -0,0 +1,14 @@
+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 ()
index caf6c4228d9aff64d892d2d21779ca61b1f2516c..1872722444a868e2f57afe9271b8bf97d05ce4a1 100644 (file)
@@ -29,6 +29,7 @@
 // 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];
@@ -51,7 +46,7 @@ void WinPrint( const char *str, ... ){
        vsprintf( text, str, argptr );
        va_end( argptr );
 
-       printf( text );
+       printf( "%s", text );
 }
 #else
 void WinPrint( const char *str, ... ){
@@ -78,7 +73,7 @@ void Net_SetAddressPort( address_t *address, int port ){
 // 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 );
@@ -169,7 +164,7 @@ int Net_Receive( socket_t *sock, netmessage_t *msg ){
                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;
@@ -183,7 +178,7 @@ int Net_Receive( socket_t *sock, netmessage_t *msg ){
 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
@@ -194,7 +189,7 @@ socket_t *Net_AllocSocket( void ){
 // Changes Globals:            -
 //===========================================================================
 void Net_FreeSocket( socket_t *sock ){
-       FreeMemory( sock );
+       free( sock );
 } //end of the function Net_FreeSocket
 //===========================================================================
 //
index 120201b3629fa620ab988b519340d621e3cbf1ac..c807091880170f16f0d5374f746945c617e23932 100644 (file)
 extern "C" {
 #endif
 
-#ifndef __BYTEBOOL__
-#define __BYTEBOOL__
-typedef enum { qfalse, qtrue } qboolean;
-typedef unsigned char byte;
-#endif
+#include "bytebool.h"
 
 typedef struct address_s
 {
index ac618dd684002a966923c18f3780fc01ab3333ef..f53f37e82bcd30c05c2c17ea31abb5f361c0dbc6 100644 (file)
 #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
 
@@ -80,9 +77,9 @@ typedef struct tag_error_struct
 
 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;
index 30ef9ac035d23cc39deb7cd5b8a547a8feafe3a0..a4a337868c938d4479130baf7b3ea5d4785cfb97 100644 (file)
 
 #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;
index ebe754723dc463f8fb1c4ff7e6696213b318967f..4ee5803ea04af60b9372e4674bd85d46e660684c 100644 (file)
@@ -29,6 +29,8 @@
 // Notes:
 //===========================================================================
 
+#include "bytebool.h"
+
 int  WINS_Init( void );
 void WINS_Shutdown( void );
 char *WINS_MyAddress( void );
diff --git a/libs/maplib.cpp b/libs/maplib.cpp
deleted file mode 100644 (file)
index 7487a68..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 07da39dcf7466e8c402df287ed48479ee46d5720..474ce4b4fb667835051cf2eed9eb0a9305a46928 100644 (file)
@@ -58,7 +58,7 @@ std::size_t m_size;
 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 ){
@@ -114,7 +114,7 @@ bool saved() const {
        return m_saved == m_size;
 }
 
-void setChangedCallback( const Callback& changed ){
+void setChangedCallback( const Callback<void()>& changed ){
        m_changed = changed;
        m_changed();
 }
diff --git a/libs/math/CMakeLists.txt b/libs/math/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6cfedbe
--- /dev/null
@@ -0,0 +1,12 @@
+add_library(math
+        _.cpp
+        aabb.h
+        curve.h
+        frustum.h
+        line.h
+        matrix.h
+        pi.h
+        plane.h
+        quaternion.h
+        vector.h
+        )
diff --git a/libs/math/_.cpp b/libs/math/_.cpp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/libs/math/aabb.cpp b/libs/math/aabb.cpp
deleted file mode 100644 (file)
index ad4ae00..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 29e3a38ebd13545565d9ba5dae4cc9913147379c..917850f5b5b3d6e2d326e3b5e1b1e114aced4d7c 100644 (file)
@@ -112,17 +112,6 @@ inline void aabb_extend_by_point_safe( AABB& aabb, const Vector3& point ){
        }
 }
 
-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 );
diff --git a/libs/math/curve.cpp b/libs/math/curve.cpp
deleted file mode 100644 (file)
index e38d2a1..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/math/frustum.cpp b/libs/math/frustum.cpp
deleted file mode 100644 (file)
index b977549..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/math/line.cpp b/libs/math/line.cpp
deleted file mode 100644 (file)
index 0f4eb81..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/math/matrix.cpp b/libs/math/matrix.cpp
deleted file mode 100644 (file)
index 6ed9a7e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/math/pi.cpp b/libs/math/pi.cpp
deleted file mode 100644 (file)
index dd54653..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/math/plane.cpp b/libs/math/plane.cpp
deleted file mode 100644 (file)
index 7b90b5e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/math/quaternion.cpp b/libs/math/quaternion.cpp
deleted file mode 100644 (file)
index 5cef646..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/math/vector.cpp b/libs/math/vector.cpp
deleted file mode 100644 (file)
index 4893324..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 9ec5159ff905ed2328e66245e93d6b523e7e5a8e..9bb3ef5111a0bdbb712f7453f13b26b4896784a1 100644 (file)
@@ -26,8 +26,9 @@
 /// \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;
@@ -45,7 +46,7 @@ inline __int64 llrint( double f ){
        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 );
@@ -55,7 +56,7 @@ inline long long llrint( double f ){
        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
diff --git a/libs/mathlib/CMakeLists.txt b/libs/mathlib/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5682a5e
--- /dev/null
@@ -0,0 +1,7 @@
+add_library(mathlib
+        bbox.c
+        line.c
+        m4x4.c
+        mathlib.c ../mathlib.h
+        ray.c
+        )
index fc9c1e33a9d22ad20c64a89a1ac10a0062f4f77f..fe5646d9327e683c2285d0e9f2541a6b436b68dc 100644 (file)
@@ -166,10 +166,10 @@ int aabb_test_plane( const aabb_t *aabb, const float *plane ){
    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;
index cb1ad87eb6f4d85367aaaba091b50a91d4f5726e..45e421f4d60eb5cc8748fc956f0cb4620eb8739b 100644 (file)
@@ -1737,9 +1737,8 @@ void m4x4_solve_ge( m4x4_t matrix, vec4_t x ){
 }
 #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;
index 642f9842e78ce94ad72d53950873fb79a8d67dd5..9b530e2d487c557b8be48c84b7f4c1484a003c08 100644 (file)
@@ -327,7 +327,7 @@ void _Vector53Copy( vec5_t in, vec3_t out ){
 }
 
 // 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;
index f08a884284901e53eb788c6ffc8c972d60e1e367..36a26168d8ee61f1e380d8f5d19b8e5a345ed676 100644 (file)
@@ -58,7 +58,7 @@ vec_t ray_intersect_point( const ray_t *ray, const vec3_t point, vec_t epsilon,
 
 // 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];
index db9fd3336dbb924cd2cfaab0013e5b0a3bcef015..c54f2605501ede7a579ef14e8d1ac50ed844d339 100644 (file)
@@ -48,7 +48,7 @@
  */
 
 #ifndef md5_INCLUDED
-#  define md5_INCLUDED
+#define md5_INCLUDED
 
 /*
  * This package supports both compile-time and run-time determination of CPU
index f30d0958b48aef14a59628a87ba5603eaedca4db..897e524f75ca27a291a28ab1f1700ef1983e9edd 100644 (file)
  */
 
 #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 )
@@ -197,11 +189,11 @@ md5_process( md5_state_t *pms, const md5_byte_t *data /*[64]*/ ){
                        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 );
                }
diff --git a/libs/memory/CMakeLists.txt b/libs/memory/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1c34573
--- /dev/null
@@ -0,0 +1,3 @@
+add_library(memory
+        allocator.cpp allocator.h
+        )
index bef7d7cb4c2a3eb02c0c30d3c9ab776cabb21d3d..845ce1400e716464b7022679d7abc421083e10ef 100644 (file)
@@ -118,11 +118,11 @@ struct rebind
        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(){
 }
diff --git a/libs/moduleobservers.cpp b/libs/moduleobservers.cpp
deleted file mode 100644 (file)
index 56150f9..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/modulesystem/CMakeLists.txt b/libs/modulesystem/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d27aa63
--- /dev/null
@@ -0,0 +1,5 @@
+add_library(modulesystem
+        moduleregistry.h
+        modulesmap.h
+        singletonmodule.cpp singletonmodule.h
+        )
diff --git a/libs/modulesystem/moduleregistry.cpp b/libs/modulesystem/moduleregistry.cpp
deleted file mode 100644 (file)
index 1e5bba6..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index abea5a055daba31330d14efed3e0d28dab2bb808..7cd84f975d9153807ac9cf9ef2a258f45842f28d 100644 (file)
 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;
@@ -53,9 +53,9 @@ typedef SmartStatic<ModuleRegistryList> StaticModuleRegistryList;
 class StaticRegisterModule : public StaticModuleRegistryList
 {
 public:
-StaticRegisterModule( ModuleRegisterable& module ){
-       StaticModuleRegistryList::instance().addModule( module );
-}
+       StaticRegisterModule( ModuleRegisterable& module ){
+               StaticModuleRegistryList::instance().addModule( module );
+       }
 };
 
 
diff --git a/libs/modulesystem/modulesmap.cpp b/libs/modulesystem/modulesmap.cpp
deleted file mode 100644 (file)
index a80f213..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index a48a083b9798702bc89ee5f86c76af9c4347a9c3..fae4c2a67f5fa8f9bd52b713937a0219ec59aa43 100644 (file)
@@ -99,6 +99,7 @@ class ModulesRef
 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 );
@@ -115,8 +116,14 @@ ModulesRef( const char* names ){
                                }
                                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
index 6dd9c52a62c2cfdf8e2b32cd14393bf6bd90665e..8dcd88de17c708c82161abbd78052e0c1f68874b 100644 (file)
@@ -88,7 +88,7 @@ explicit SingletonModule( const APIConstructor& constructor )
 
 void selfRegister(){
        globalModuleServer().registerModule( typename Type::Name(), typename Type::Version(), APIConstructor::getName(), *this );
-}
+       }
 
 Dependencies& getDependencies(){
        return *m_dependencies;
diff --git a/libs/os/CMakeLists.txt b/libs/os/CMakeLists.txt
new file mode 100644 (file)
index 0000000..437b506
--- /dev/null
@@ -0,0 +1,10 @@
+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})
diff --git a/libs/os/_.cpp b/libs/os/_.cpp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/libs/os/dir.cpp b/libs/os/dir.cpp
deleted file mode 100644 (file)
index 8ab8129..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/os/file.cpp b/libs/os/file.cpp
deleted file mode 100644 (file)
index 1855b5d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 43381c63ab9ef9b14935e5e0c362c436345c8929..144627e65a9dcea34a7ad9adf8a03aef9a613d9d 100644 (file)
 #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()
-#define F_OK 0x00
-#define W_OK 0x02
-#define R_OK 0x04
 #define access( path, mode ) _access( path, mode )
 #else
 #include <unistd.h> // access()
diff --git a/libs/os/path.cpp b/libs/os/path.cpp
deleted file mode 100644 (file)
index b62c219..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index e3329a758c76ec79291659a0af7cc2807ccbc0bb..a3db167cb484ad84abbff192fc9289ae3408fcc1 100644 (file)
@@ -22,6 +22,8 @@
 #if !defined ( INCLUDED_OS_PATH_H )
 #define INCLUDED_OS_PATH_H
 
+#include "globaldefs.h"
+
 /// \file
 /// \brief OS file-system path comparison, decomposition and manipulation.
 ///
@@ -33,7 +35,7 @@
 
 #include "string/string.h"
 
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
 #define OS_CASE_INSENSITIVE
 #endif
 
@@ -85,10 +87,10 @@ inline bool path_equal_n( const char* path, const char* other, std::size_t n ){
 /// \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
 }
diff --git a/libs/picomodel/CMakeLists.txt b/libs/picomodel/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0f1286d
--- /dev/null
@@ -0,0 +1,26 @@
+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
+        )
index 1e68cc1c12e03b23e7f1c28c3778016be1fe88ce..6a347f585a8cddea2f47a84dab0bf128306fd9fd 100644 (file)
@@ -20,8 +20,8 @@
 
 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:
index 8c5bb8fa78b389bf030c6b8bcda22d9bf3a86ba2..27992d49143b43d29905d692f8aa3708deab93f2 100644 (file)
@@ -23,7 +23,7 @@ void lwFreeEnvelope( lwEnvelope *env ){
                        _pico_free( env->name );
                }
                lwListFree( env->key, _pico_free );
-               lwListFree( env->cfilter, (void *) lwFreePlugin );
+               lwListFree(env->cfilter, (void (*)(void *)) lwFreePlugin);
                _pico_free( env );
        }
 }
@@ -105,7 +105,7 @@ lwEnvelope *lwGetEnvelope( picoMemStream_t *fp, int cksize ){
                        }
                        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;
 
index 0964273e747f926c3b8087a80eb66380f1e9f0f9..e825a3403e97d0b5b6f458cbefed03ae2513eea7 100644 (file)
@@ -9,6 +9,8 @@
 
 #include "../picointernal.h"
 #include "lwo2.h"
+#include <limits.h>
+#include "globaldefs.h"
 
 
 /*
@@ -22,8 +24,7 @@
    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;
 
@@ -32,7 +33,7 @@ void set_flen( int i ) { flen = i; }
 int get_flen( void ) { return flen; }
 
 
-#ifndef __BIG_ENDIAN__
+#if !GDEF_ARCH_ENDIAN_BIG
 /*
    =====================================================================
    revbytes()
index 1bbc7a36919f87dfb1fce617cf0e60b9c77c2a3e..fd367e4fea2139dd4e896d99f47725b06188bd24 100644 (file)
@@ -9,9 +9,10 @@
 
 #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
 
@@ -30,7 +31,7 @@ void lwFreeLayer( lwLayer *layer ){
                }
                lwFreePoints( &layer->point );
                lwFreePolygons( &layer->polygon );
-               lwListFree( layer->vmap, (void *) lwFreeVMap );
+               lwListFree(layer->vmap, (void (*)(void *)) lwFreeVMap);
                _pico_free( layer );
        }
 }
@@ -45,10 +46,10 @@ void lwFreeLayer( lwLayer *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 );
        }
index d055c13e50b3003a26614afb19056c319ae75f99..b1dc7470ba5fc228419680f534493979a3489e73 100644 (file)
@@ -10,6 +10,8 @@
 #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 ) )
@@ -642,7 +644,7 @@ int   sgetVX( unsigned char **bp );
 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 )
index e0256c091f42c21ec41341b8d5ce0aec01d7e9b3..cae5357dbd9a4a44172390e1c6e8bcc0e8a25165 100644 (file)
 
 #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
 
@@ -71,7 +72,7 @@ static int add_clip( char *s, lwClip **clist, int *nclips ){
        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;
@@ -380,12 +381,15 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
                        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;
                        }
index 4b3500242aea9bd1ec1d5eee4056cc64097dd437..1b2c1fcd2c7936bca785c49ac406c818dfcf98f5 100644 (file)
@@ -93,18 +93,19 @@ void lwFreeSurface( lwSurface *surf ){
                        _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 );
        }
@@ -817,7 +818,7 @@ static int add_texture( lwSurface *surf, lwTexture *tex ){
        default:  return 0;
        }
 
-       lwListInsert( (void **) list, tex, ( void *) compare_textures );
+       lwListInsert((void **) list, tex, (int (*)(void *, void *)) compare_textures);
        return 1;
 }
 
@@ -1057,7 +1058,7 @@ lwSurface *lwGetSurface( picoMemStream_t *fp, int cksize ){
                                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;
index e1bf9d1bb98e02aed6e0d040220e62b8c60c9010..018ee3a130295869d9294409545e6ca6a7792cb6 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-
-/* marker */
-#define PICOINTERNAL_C
-
-
-
 /* todo:
  * - fix p->curLine for parser routines. increased twice
  */
@@ -46,6 +39,7 @@
 /* dependencies */
 #include <string.h>
 #include "picointernal.h"
+#include "globaldefs.h"
 
 
 
@@ -483,7 +477,7 @@ void _pico_copy_color( picoColor_t src, picoColor_t dest ){
        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; }
@@ -763,7 +757,7 @@ picoParser_t *_pico_new_parser( const picoByte_t *buffer, int bufSize ){
        }
        /* 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 */
index 07c24cb570c39b2a5b2d102ee253f4addf158a2c..4bcbd4c281ae026efd4ad87ea7375f17ee4adb45 100644 (file)
@@ -38,6 +38,8 @@
 #ifndef PICOINTERNAL_H
 #define PICOINTERNAL_H
 
+#include "globaldefs.h"
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -56,7 +58,7 @@ extern "C"
 
 
 /* os dependent replacements */
-#if WIN32 || _WIN32
+#if GDEF_OS_WINDOWS
        #define _pico_stricmp stricmp
        #define _pico_strnicmp strnicmp
 #else
@@ -78,22 +80,22 @@ extern "C"
 /* 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;
index 4526745c290b6a0d83acaeb8885b82599d988f83..311f6de760c7791bb9e94f717d481a192c46dfdc 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-
-/* marker */
-#define PICOMODEL_C
-
-
-
 /* dependencies */
 #include "picointernal.h"
 
@@ -1426,7 +1419,7 @@ int PicoGetSurfaceSpecial( picoSurface_t *surface, int num ){
 
 /* 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;
index 9a973724e20457a3accd3f3176c1dfdfde2fbb56..77bb4918b22af6a9385cc71af558c912dc347d56 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-
-/* marker */
-#define PICOMODULES_C
-
-
-
 /* dependencies */
 #include "picointernal.h"
 
index 83a1446e0961fa2b474f8511279fa4d063d8354e..e72454a170a6d851599d15ac2f4c38f3d2863e5f 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-
-/* marker */
-#define PM_3DS_C
-
 /* dependencies */
 #include "picointernal.h"
 
@@ -124,7 +119,7 @@ debugChunkNames[] =
        { 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] );
 
@@ -523,7 +518,6 @@ static int DoNextEditorDataChunk( T3dsLoaderPers *pers, long endofs ){
                        /* read in surface name */
                        if ( !GetASCIIZ( pers,surfaceName,sizeof( surfaceName ) ) ) {
                                return 0; /* this is bad */
-
                        }
 //PicoGetSurfaceName
                        /* ignore NULL name surfaces */
index 001cca4f35d09897e12934d251ae8efcde2cef64..d73187c6ec706c2131b8282f89ec28a5f1f35eca 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-/* marker */
-#define PM_ASE_C
-
 /* uncomment when debugging this module */
 //#define DEBUG_PM_ASE
 //#define DEBUG_PM_ASE_EX
index eefee2e7d64f38377d3b714fbe7afbfc2809c8d4..c4086184c317cf15547c4f42637dff9f9d32b85b 100644 (file)
@@ -36,9 +36,6 @@
    Nurail: Used pm_md3.c (Randy Reddig) as a template.
  */
 
-/* marker */
-#define PM_FM_C
-
 /* dependencies */
 #include "pm_fm.h"
 
index 812496ae40fe8c43382367c090771f986cc665dc..6cbf0f4c162d50916f4fec5674d42ef87011e423 100644 (file)
@@ -32,9 +32,6 @@
 
    ----------------------------------------------------------------------------- */
 
-/* marker */
-#define PM_LWO_C
-
 /* dependencies */
 #include "picointernal.h"
 #include "lwo/lwo2.h"
index 28cf384e965c918366e0e749fe0f25d3e97cad66..37b5466c56f712e3c36c39dd6d72aaf4dc10d667 100644 (file)
    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
 {
index f014c4370857e002604e2f1b47fbf681558c5f1c..d31806b7e85fb6c67e09af1c11feeb75b0db2bba 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-
-/* 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
index 7e898ff1e3887f2c6d980831959c1d3c313268e1..235dcecf9467c0ca90d1508e0fef403e1adf285e 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-
-/* 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 ] =
index 535b7e22ceba57adac95157e8c6d9ff82a422825..378265f30a5504d59206c95b08d6f43fb103bce7 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-
-/* 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)
index 49d0fe84ed264e253f01b41abfcc961163c3fc22..6e11a1cdbaca6875bce3d01f474b0212a690f375 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-
-/* 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
 
@@ -135,7 +131,7 @@ static int _obj_canload( PM_PARAMS_CANLOAD ){
  *   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,
@@ -295,7 +291,7 @@ static int _obj_mtl_load( picoModel_t *model ){
 
                        /* 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 */
@@ -325,7 +321,7 @@ static int _obj_mtl_load( picoModel_t *model ){
 
                        /* 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 */
@@ -528,8 +524,9 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){
                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 ); } \
@@ -544,7 +541,7 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){
        /* 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 ); \
@@ -710,7 +707,7 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){
                        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 );
                        }
@@ -893,20 +890,20 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){
                        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 );
index 93b79840f7b0722ae17705e74871b92b0baf86d9..a82e4b122277916d9a3c4910ab3ce22017446e1e 100644 (file)
 
    ----------------------------------------------------------------------------- */
 
-
-
-/* marker */
-#define PM_TERRAIN_C
-
-
-
 /* dependencies */
 #include "picointernal.h"
 
@@ -62,7 +55,7 @@ tga_t;
    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;
@@ -298,7 +291,7 @@ breakOut:;
    validates a picoterrain file
  */
 
-static int _terrain_canload( PM_PARAMS_CANLOAD ){
+static int _terrain_canload( PM_PARAMS_CANLOAD ) {
        picoParser_t    *p;
 
 
@@ -333,7 +326,7 @@ static int _terrain_canload( PM_PARAMS_CANLOAD ){
    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;
 
diff --git a/libs/pivot.cpp b/libs/pivot.cpp
deleted file mode 100644 (file)
index adc9ef2..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/profile/CMakeLists.txt b/libs/profile/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e3822f4
--- /dev/null
@@ -0,0 +1,4 @@
+add_library(profile
+        file.cpp file.h
+        profile.cpp profile.h
+        )
index ec230964e3b8e31177186c21fb627cabc2d92549..9f83393d7ea6df5068f13caf70a36cdd98728239 100644 (file)
@@ -271,7 +271,7 @@ int MemStream::Seek( offset_type lOff, int nFrom ){
                lNewPos = m_nFileSize + lOff;
        }
        else{
-               return ( position_type ) - 1;
+               return -1;
        }
 
        m_nPosition = lNewPos;
index 71d2ae1b9c18b250cae0e987d042764a7c1f8d11..c1505e073b15ac1c2b68fbf58a5fd92568dbe11e 100644 (file)
@@ -252,7 +252,7 @@ bool profile_load_buffer( const char * rc_path, const char *name, void *buffer,
                fclose( f );
        }
 
-       return true;
+       return ret;
 }
 
 int profile_load_int( const char *filename, const char *section, const char *key, int default_value ){
diff --git a/libs/property.h b/libs/property.h
new file mode 100644 (file)
index 0000000..abdb32f
--- /dev/null
@@ -0,0 +1,167 @@
+#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
diff --git a/libs/render.cpp b/libs/render.cpp
deleted file mode 100644 (file)
index be1c49a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index b53612bf11621d78f6fe28f8d14c1eba244ccdf9..d568edb386216a826a823d6d6799cf24ce45ec83 100644 (file)
@@ -171,7 +171,7 @@ RenderIndex m_prev0;
 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 )
diff --git a/libs/scenelib.cpp b/libs/scenelib.cpp
deleted file mode 100644 (file)
index a1754d0..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 29402065252cf7c8f2cb4d040d244e48d2e67427..e1c05d464d8ba5ee096c55f6f08c2a122db47e9e 100644 (file)
@@ -22,6 +22,7 @@
 #if !defined ( INCLUDED_SCENELIB_H )
 #define INCLUDED_SCENELIB_H
 
+#include "globaldefs.h"
 #include "iscenegraph.h"
 #include "iselection.h"
 
@@ -106,9 +107,9 @@ NodeType() : m_typeId( NODETYPEID_NONE ){
 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;
@@ -441,9 +442,9 @@ InstanceType() : m_typeId( INSTANCETYPEID_NONE ){
 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;
@@ -574,8 +575,8 @@ mutable bool m_childSelected;
 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 {
@@ -673,7 +674,7 @@ void transformChanged(){
        GlobalSceneGraph().traverse_subgraph( TransformChangedWalker(), m_path );
        boundsChanged();
 }
-void setTransformChangedCallback( const Callback& callback ){
+void setTransformChangedCallback( const Callback<void()>& callback ){
        m_transformChangedCallback = callback;
 }
 
@@ -710,7 +711,7 @@ bool childSelected() const {
        return m_childSelected;
 }
 
-void setChildSelectedChangedCallback( const Callback& callback ){
+void setChildSelectedChangedCallback( const Callback<void()>& callback ){
        m_childSelectedChangedCallback = callback;
 }
 void selectedChanged(){
@@ -933,10 +934,10 @@ virtual void decrement() = 0;
 
 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(){
diff --git a/libs/script/CMakeLists.txt b/libs/script/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6e49527
--- /dev/null
@@ -0,0 +1,5 @@
+add_library(script
+        _.cpp
+        scripttokeniser.h
+        scripttokenwriter.h
+        )
diff --git a/libs/script/_.cpp b/libs/script/_.cpp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/libs/script/scripttokeniser.cpp b/libs/script/scripttokeniser.cpp
deleted file mode 100644 (file)
index 1b4ee4c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/script/scripttokenwriter.cpp b/libs/script/scripttokenwriter.cpp
deleted file mode 100644 (file)
index 753aab7..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 49ee57af7903393ac95cad481b75b11dc0a1ae3c..f1c5fc3147f46aa4c78f8de2cc631e18f48e0b76 100644 (file)
@@ -28,7 +28,8 @@ class SimpleTokenWriter : public TokenWriter
 {
 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();
@@ -63,7 +64,10 @@ void writeFloat( double f ){
 
 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;
diff --git a/libs/selectionlib.cpp b/libs/selectionlib.cpp
deleted file mode 100644 (file)
index cc85fe6..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index cb0e43e5171cd1135b91840d0195ad1aba420a71..06a905c74a2440c071e4eaf2da00e79010e5e19f 100644 (file)
@@ -114,7 +114,7 @@ void selectedChanged( const Selectable& selectable ){
 
        Instance::selectedChanged();
 }
-typedef MemberCaller1<SelectableInstance, const Selectable&, &SelectableInstance::selectedChanged> SelectedChangedCaller;
+typedef MemberCaller<SelectableInstance, void(const Selectable&), &SelectableInstance::selectedChanged> SelectedChangedCaller;
 };
 
 
diff --git a/libs/shaderlib.cpp b/libs/shaderlib.cpp
deleted file mode 100644 (file)
index 454bd4f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index ee972437befeb934fbfb06c11862af6873d6329b..b73d5963406a2d7d56a8181d814c68c61bbabd11 100644 (file)
@@ -22,6 +22,7 @@
 #if !defined ( INCLUDED_SHADERLIB_H )
 #define INCLUDED_SHADERLIB_H
 
+#include "defaults.h"
 #include "string/string.h"
 #include "character.h"
 #include "ishaders.h"
@@ -77,8 +78,8 @@ inline bool texdef_name_valid( const char* name ){
 }
 
 inline const char* texdef_name_default(){
-       return GlobalTexturePrefix_get();
+       const char* notex = DEFAULT_NOTEX_NAME;
+       return notex;
 }
 
-
 #endif
diff --git a/libs/signal/CMakeLists.txt b/libs/signal/CMakeLists.txt
new file mode 100644 (file)
index 0000000..499a483
--- /dev/null
@@ -0,0 +1,5 @@
+add_library(signal
+        isignal.h
+        signal.cpp signal.h
+        signalfwd.h
+        )
diff --git a/libs/signal/isignal.cpp b/libs/signal/isignal.cpp
deleted file mode 100644 (file)
index 5eafd5e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-
-#include "isignal.h"
index b6342190bd2ccb505b34ca0f486c571102c362bf..a8dcdfc9711bf5bf60b0a63c94a185f7cdd683c3 100644 (file)
@@ -22,72 +22,63 @@ bool operator!=( SignalHandlerResult other ) const {
 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>
@@ -95,111 +86,81 @@ inline SignalHandler makeSignalHandler( const BindFirstOpaque<Caller>& 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
index 6c64cf8856afc7271caa6151b288c35e84ffab55..caade86b928ecdce01e397357f2f947688ffb9f6 100644 (file)
@@ -21,39 +21,39 @@ class A3
 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;
index f435f027557d86b94cfab3220a3fb771aa25c75d..3d4c039701b684065ea5b301026c9460890cda9f 100644 (file)
@@ -315,7 +315,7 @@ class Signal1 : public SignalBase< SignalHandler1<FirstArgument> >
 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 ) );
 }
 };
 
@@ -325,7 +325,7 @@ class Signal2 : public SignalBase< SignalHandler2<FirstArgument, SecondArgument>
 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 ) );
 }
 };
 
@@ -335,7 +335,7 @@ class Signal3 : public SignalBase< SignalHandler3<FirstArgument, SecondArgument,
 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 ) );
 }
 };
 
diff --git a/libs/signal/signalfwd.cpp b/libs/signal/signalfwd.cpp
deleted file mode 100644 (file)
index fedf515..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-
-#include "signalfwd.h"
diff --git a/libs/splines/CMakeLists.txt b/libs/splines/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3a6b603
--- /dev/null
@@ -0,0 +1,11 @@
+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
+        )
index 597f1d029085e9c828c330d82275f8970e8139f9..b4427dcde922c6159953971174c4b2b595140c6c 100644 (file)
 #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;
 
@@ -83,8 +75,8 @@ friend mat3_t   SkewSymmetric( idVec3 const &src );
 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 ) {
index 8632661df914fbfb622b63ce134ee416ddb1eef9..b33f4425d28c2b6b660df07058c1ff1d56cd480b 100644 (file)
@@ -157,7 +157,7 @@ inline int operator==( quat_t a, quat_t b ) {
 }
 
 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 ) {
index dde072578cc470a2b805c13052205c3de0398f15..4fbe8d9dc5820f8071af22b13308e98aaad0288b 100644 (file)
@@ -22,7 +22,9 @@
 #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
@@ -98,7 +96,7 @@ static inline float idSqrt( float x ) {
        }
        B = x;
 
-#ifdef __GNUC__
+#if GDEF_COMPILER_GNU
        asm ( "frsqrte %0,%1" : "=f" ( y0 ) : "f" ( B ) );
 #else
        y0 = __frsqrte( B );
index 528b1f773c70602002a04e123850828258beb0b4..b856d59e3116902c10dbe8a6fc4a1ab793244c0a 100644 (file)
@@ -45,7 +45,7 @@ typedef struct {
        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];
index 033a6ee3120d4e725a727c498e5c08bc452b1cdd..1df4dfcd2c5de67676a444b0ddd2c2b9528f0d84 100644 (file)
@@ -546,7 +546,7 @@ char* Q_strrchr( const char* string, int c ){
    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" );
        }
@@ -633,10 +633,8 @@ char *Q_strupr( char *s1 ) {
 
 
 // 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" );
        }
@@ -689,14 +687,17 @@ char *Q_CleanStr( char *string ) {
 }
 
 
-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" );
        }
@@ -716,7 +717,7 @@ void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... ) {
    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;
@@ -750,7 +751,7 @@ char    * QDECL va( char *format, ... ) {
    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
index 6cad80bc97eec9ac4f5e2b8cbaa6e7a1e57874d9..10a75625cb8cc8405c1d34324b60d98ca4e565f0 100644 (file)
@@ -22,6 +22,8 @@
 #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
@@ -35,7 +37,7 @@
 #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 )
 
@@ -76,7 +80,7 @@
 
 
 // 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
@@ -88,7 +92,7 @@
 
 //======================= 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" {
@@ -188,11 +192,11 @@ void Sys_PumpEvents( void );
 
 // 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"
@@ -228,7 +232,7 @@ typedef enum {
 #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
@@ -591,7 +595,7 @@ void Com_Parse3DMatrix( const char *( *buf_p ), int z, int y, int x, float *m );
 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
@@ -624,8 +628,8 @@ char    *Q_strupr( char *s1 );
 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 );
@@ -646,7 +650,7 @@ float   BigFloat( float l );
 float   LittleFloat( float l );
 
 void    Swap_Init( void );
-char    * QDECL va( char *format, ... );
+char    *QDECL va( const char *format, ... );
 
 #ifdef __cplusplus
 }
@@ -776,7 +780,7 @@ int         Com_IndexForGrowListElement( const growList_t *list, const void *ele
 //
 // 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 );
index 05cb3bf972c09d5b6723be51710b0c088f9fac5a..e35d82b7e8b80d3b1ad4665203a93999a7645497 100644 (file)
@@ -43,7 +43,7 @@ float Q_fabs( float f ) {
 //             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];
 
@@ -638,8 +638,8 @@ bool idCameraDef::waitEvent( int index ) {
 }
 
 
-#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;
@@ -653,6 +653,7 @@ void idCameraDef::buildCamera() {
        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;
@@ -1166,7 +1167,7 @@ void idFixedPosition::parse( const char *( *text )  ) {
                        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 );
@@ -1175,7 +1176,7 @@ void idFixedPosition::parse( const char *( *text )  ) {
                                Com_UngetToken();
                                idCameraPosition::parseToken( key.c_str(), text );
                        }
-                       token = Com_Parse( text );
+                       Com_Parse( text );
 
                } while ( 1 );
 
@@ -1212,7 +1213,7 @@ void idInterpolatedPosition::parse( const char *( *text )  ) {
                        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 );
@@ -1225,7 +1226,7 @@ void idInterpolatedPosition::parse( const char *( *text )  ) {
                                Com_UngetToken();
                                idCameraPosition::parseToken( key.c_str(), text );
                        }
-                       token = Com_Parse( text );
+                       Com_Parse( text );
 
                } while ( 1 );
 
@@ -1263,7 +1264,7 @@ void idSplinePosition::parse( const char *( *text )  ) {
                        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 );
                        }
@@ -1271,7 +1272,7 @@ void idSplinePosition::parse( const char *( *text )  ) {
                                Com_UngetToken();
                                idCameraPosition::parseToken( key.c_str(), text );
                        }
-                       token = Com_Parse( text );
+                       Com_Parse( text );
 
                } while ( 1 );
 
index 62fdaedc50f6f5905beb1b22977841568ab7d0bb..c64ca73b7f52acac1edbb1bbb07c2ee3e36efafb 100644 (file)
@@ -27,7 +27,7 @@
 #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
@@ -455,7 +455,7 @@ void idStr::snprintf
        strncpy( dst, buffer, size - 1 );
 }
 
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
 #pragma warning(disable : 4189)     // local variable is initialized but not referenced
 #endif
 
@@ -475,14 +475,16 @@ void TestStringClass
        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
@@ -499,14 +501,14 @@ void TestStringClass
        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"
@@ -569,7 +571,7 @@ void TestStringClass
        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
index 57f05b5a000b3fe09dce30652e9aa1e15d62b219..02240ced728fba4ebf9f8cd589838ec11f73b0f6 100644 (file)
@@ -28,7 +28,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
 #pragma warning(disable : 4710)     // function 'blah' not inlined
 #endif
 
diff --git a/libs/str.cpp b/libs/str.cpp
deleted file mode 100644 (file)
index c63ef94..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-   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"
index 9090bf2d6e4587b797c1fbfa7a87d8a0fc63e1b3..e7ef600efada9c9d23cbeca5ae5d94154f1d979b 100644 (file)
@@ -31,6 +31,8 @@
 #ifndef __STR__
 #define __STR__
 
+#include "globaldefs.h"
+
 //
 // class Str
 // loose replacement for CString from MFC
@@ -44,7 +46,7 @@
 
 #include <cstdio>
 
-#ifdef _MSC_VER
+#if GDEF_COMPILER_MSVC
 #define strcasecmp strcmpi
 #if _MSC_VER < 1400
 #define vsnprintf std::vsnprintf
@@ -67,7 +69,7 @@ inline char* Q_StrDup( const char* pStr ){
        return strcpy( new char[strlen( pStr ) + 1], pStr );
 }
 
-#if !defined( WIN32 )
+#if !GDEF_OS_WINDOWS
 #define strcmpi strcasecmp
 #define stricmp strcasecmp
 #define strnicmp strncasecmp
@@ -254,7 +256,6 @@ const char* Left( std::size_t n ){
        }
        else
        {
-               g_pStrWork = "";
                g_pStrWork = new char[1];
                g_pStrWork[0] = '\0';
        }
@@ -290,7 +291,6 @@ const char* Mid( std::size_t first, std::size_t n ) const {
        }
        else
        {
-               g_pStrWork = "";
                g_pStrWork = new char[1];
                g_pStrWork[0] = '\0';
        }
@@ -429,7 +429,7 @@ bool operator >( char* pStr ) const { return ( m_bIgnoreCase ) ? stricmp( m_pStr
 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]; }
 };
 
 
diff --git a/libs/stream/CMakeLists.txt b/libs/stream/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6ce7939
--- /dev/null
@@ -0,0 +1,8 @@
+add_library(stream
+        _.cpp
+        filestream.h
+        memstream.h
+        stringstream.h
+        textfilestream.h
+        textstream.h
+        )
diff --git a/libs/stream/_.cpp b/libs/stream/_.cpp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/libs/stream/filestream.cpp b/libs/stream/filestream.cpp
deleted file mode 100644 (file)
index 33f1206..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/stream/memstream.cpp b/libs/stream/memstream.cpp
deleted file mode 100644 (file)
index c7c8d1b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/stream/stringstream.cpp b/libs/stream/stringstream.cpp
deleted file mode 100644 (file)
index 8e9da6e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 386093fe4a149b040adeca6de904978c84fcd233..8511bd4fa411bec02d93e3eb295db8e07a1503da 100644 (file)
@@ -105,7 +105,7 @@ typedef StringBuffer::const_iterator const_iterator;
 
 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 );
diff --git a/libs/stream/textfilestream.cpp b/libs/stream/textfilestream.cpp
deleted file mode 100644 (file)
index e1024e4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/stream/textstream.cpp b/libs/stream/textstream.cpp
deleted file mode 100644 (file)
index cfbdedd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index e8de1391075c9c96337a91a1de0902d6ff9cb553..25f3d1ad42d90b12db37b2cb395f8011da5e1aa0 100644 (file)
 #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>
@@ -33,6 +36,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <algorithm>
+#include <string>
 
 #include "generic/arrayrange.h"
 
@@ -46,7 +50,7 @@ inline char* write_unsigned_nonzero_decimal_backward( char* ptr, unsigned int de
        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 )
        {
@@ -76,7 +80,7 @@ inline char* write_unsigned_nonzero_decimal_backward( char* ptr, unsigned int de
        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 ) {
@@ -108,7 +112,7 @@ inline char* write_unsigned_decimal_backward( char* ptr, unsigned int decimal, b
        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';
@@ -123,7 +127,7 @@ inline char* write_size_t_decimal_backward( char* ptr, size_t decimal, bool show
 }
 
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 #define snprintf _snprintf
 #endif
 
@@ -184,7 +188,7 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const
        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>
@@ -396,6 +400,48 @@ std::size_t write( const char* buffer, std::size_t length ){
 }
 };
 
+
+/// \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
diff --git a/libs/string/CMakeLists.txt b/libs/string/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4b0720a
--- /dev/null
@@ -0,0 +1,5 @@
+add_library(string
+        pooledstring.cpp pooledstring.h
+        string.h
+        stringfwd.h
+        )
index 96cb298d56cd94c7feb34c724cc4208d338ea39c..d43863311374c07261402b225ab85a5d35508535 100644 (file)
@@ -1,8 +1,9 @@
 
 #include "pooledstring.h"
+#include "globaldefs.h"
 #include "generic/static.h"
 
-#if defined( _DEBUG )
+#if GDEF_DEBUG
 
 namespace ExamplePooledString
 {
@@ -21,4 +22,4 @@ struct Always
 } always;
 }
 
-#endif
\ No newline at end of file
+#endif
diff --git a/libs/string/string.cpp b/libs/string/string.cpp
deleted file mode 100644 (file)
index 5904301..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-   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
index a6de0673913009b899cead876a192372223128b6..ff7dc4536c9245ce116e612534f0d1ff826a49a6 100644 (file)
@@ -22,6 +22,8 @@
 #if !defined( INCLUDED_STRING_STRING_H )
 #define INCLUDED_STRING_STRING_H
 
+#include "globaldefs.h"
+
 /// \file
 /// C-style null-terminated-character-array string library.
 
@@ -81,7 +83,7 @@ inline bool string_greater( const char* string, const char* other ){
 /// 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 );
@@ -94,7 +96,7 @@ inline int string_compare_nocase( const char* string, const char* 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 );
@@ -141,6 +143,13 @@ inline bool string_equal_prefix( const char* string, const char* prefix ){
        return string_equal_n( string, prefix, string_length( prefix ) );
 }
 
+/// \brief Returns true if the ending of \p string is equal to \p suffix.
+/// O(n)
+inline bool string_equal_suffix( const char* string, const char* suffix){
+       const char *s = string + string_length( string ) - string_length( suffix );
+       return string_equal_n( s , suffix, string_length( suffix ) );
+}
+
 /// \brief Copies \p other into \p string and returns \p string.
 /// Assumes that the space allocated for \p string is at least string_length(other) + 1.
 /// O(n)
@@ -187,6 +196,14 @@ inline char* string_new( std::size_t length ){
        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;
diff --git a/libs/string/stringfwd.cpp b/libs/string/stringfwd.cpp
deleted file mode 100644 (file)
index add6eee..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/stringio.cpp b/libs/stringio.cpp
deleted file mode 100644 (file)
index a6e741f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 82d0e2584160a2793fb9c696fdd4c90daa11db0f..9003bca8dc030b6477201f8cfd0450fe83858945 100644 (file)
@@ -29,6 +29,7 @@
 #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 ) );
@@ -219,7 +220,7 @@ inline bool string_parse_size( const char* string, std::size_t& i ){
 }
 
 
-#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";
@@ -234,7 +235,10 @@ inline bool Tokeniser_getFloat( Tokeniser& tokeniser, float& f ){
        //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" );
@@ -293,183 +297,78 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& outputStream,
 }
 
 
-
-
-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
diff --git a/libs/texturelib.cpp b/libs/texturelib.cpp
deleted file mode 100644 (file)
index 00bde65..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/transformlib.cpp b/libs/transformlib.cpp
deleted file mode 100644 (file)
index ec82140..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 91c8cb25b4652ce9d341f87eb06f0e9c3e488910..2974979729fc10921025249fbd1acf6eaa2f78df 100644 (file)
@@ -116,12 +116,12 @@ class TransformModifier : public Transformable
 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 ),
diff --git a/libs/traverselib.cpp b/libs/traverselib.cpp
deleted file mode 100644 (file)
index 57e1dfb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index c90d01b59c8d8829408442c3cba9f625e32d125a..64df12124948a4eec5fa2f8468612e3ffe0f7f33 100644 (file)
@@ -166,7 +166,6 @@ void detach( Observer* observer ){
 }
 /// \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" );
@@ -179,7 +178,6 @@ void insert( scene::Node& node ){
 }
 /// \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" );
diff --git a/libs/typesystem.cpp b/libs/typesystem.cpp
deleted file mode 100644 (file)
index 755f05e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index b789c5c48877dd3436f390758e3f0fb221613427..4ceca552e23a936ea11cd8ea40cd2ab01539b9cc 100644 (file)
 
 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 {
diff --git a/libs/uilib/CMakeLists.txt b/libs/uilib/CMakeLists.txt
new file mode 100644 (file)
index 0000000..080376b
--- /dev/null
@@ -0,0 +1,18 @@
+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)
diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp
new file mode 100644 (file)
index 0000000..1f4acb1
--- /dev/null
@@ -0,0 +1,473 @@
+#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;
+    }
+
+}
diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h
new file mode 100644 (file)
index 0000000..d795b75
--- /dev/null
@@ -0,0 +1,643 @@
+#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
diff --git a/libs/undolib.cpp b/libs/undolib.cpp
deleted file mode 100644 (file)
index 8ebe6aa..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 4fc441193975a9fb47428021882354df94a0cd53..06d474bf56b13fcaa5d546d3acaa6f1ba72cb0a2 100644 (file)
@@ -49,7 +49,7 @@ const Copyable& get() const {
 template<typename Copyable>
 class ObservedUndoableObject : public Undoable
 {
-typedef Callback1<const Copyable&> ImportCallback;
+typedef Callback<void(const Copyable&)> ImportCallback;
 
 Copyable& m_object;
 ImportCallback m_importCallback;
diff --git a/libs/uniquenames.cpp b/libs/uniquenames.cpp
deleted file mode 100644 (file)
index 0515b68..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/versionlib.cpp b/libs/versionlib.cpp
deleted file mode 100644 (file)
index 74799ac..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/xml/CMakeLists.txt b/libs/xml/CMakeLists.txt
new file mode 100644 (file)
index 0000000..96e1e21
--- /dev/null
@@ -0,0 +1,15 @@
+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})
diff --git a/libs/xml/ixml.cpp b/libs/xml/ixml.cpp
deleted file mode 100644 (file)
index d4caeb5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/xml/xmlelement.cpp b/libs/xml/xmlelement.cpp
deleted file mode 100644 (file)
index 2ba3943..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/libs/xml/xmlparser.cpp b/libs/xml/xmlparser.cpp
deleted file mode 100644 (file)
index 8ef5d0b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index b11d355bce45c1a42df4f4df3644b1071747c13a..cdfdd8fbaffb4882128595f9fea1e66ea31e3690 100644 (file)
@@ -208,6 +208,7 @@ virtual void exportXML( XMLImporter& importer ){
                xmlFreeParserCtxt( ctxt );
        }
 
+       (void) wellFormed;
        //return wellFormed;
 }
 private:
index c9d2b06b6087c455c88426c8ab089baf67b971f1..00f57a057ac2337eec22fa81e6e8bd247793fbf3 100644 (file)
@@ -476,7 +476,7 @@ void XmlTagBuilder::GetShaderTags( const char* shader, std::vector<CopiedString>
           returns a vector containing the tags
         */
 
-       charexpression;
+       char const *expression;
 
        if ( shader == NULL ) { // get all tags from all shaders
                expression = "/root/*/*/tag";
@@ -510,7 +510,7 @@ void XmlTagBuilder::GetUntagged( std::set<CopiedString>& shaders ){
           returns a set containing the shaders (with path)
         */
 
-       charexpression = "/root/*/*[not(child::tag)]";
+       char const *expression = "/root/*/*[not(child::tag)]";
 
        xmlXPathObjectPtr xpathPtr = XpathEval( expression );
        xmlNodeSetPtr nodePtr;
@@ -540,7 +540,7 @@ void XmlTagBuilder::GetAllTags( std::set<CopiedString>& tags ){
           returns a set containing all used tags
         */
 
-       charexpression = "/root/*/*/tag";
+       char const *expression = "/root/*/*/tag";
 
        xmlXPathObjectPtr xpathPtr = XpathEval( expression );
        xmlNodeSetPtr nodePtr;
diff --git a/libs/xml/xmlwriter.cpp b/libs/xml/xmlwriter.cpp
deleted file mode 100644 (file)
index 8766897..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
new file mode 100644 (file)
index 0000000..80f45f1
--- /dev/null
@@ -0,0 +1,35 @@
+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)
diff --git a/plugins/archivepak/CMakeLists.txt b/plugins/archivepak/CMakeLists.txt
new file mode 100644 (file)
index 0000000..817cc03
--- /dev/null
@@ -0,0 +1,5 @@
+radiant_plugin(archivepak
+        archive.cpp archive.h
+        pak.h
+        plugin.cpp
+        )
index 785c2dda2aeda4b8ecc43c88326f72b89091b897..ee193339e663580517f71494a64c12a1cd273645 100644 (file)
@@ -32,8 +32,6 @@
 #include "archivelib.h"
 
 
-#include "plugin.h"
-
 #include <map>
 #include "string/string.h"
 #include "fs_filesystem.h"
diff --git a/plugins/archivepak/pak.cpp b/plugins/archivepak/pak.cpp
deleted file mode 100644 (file)
index f0b9c48..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index e334248eb020808ed887c366ff07ae7156c6c290..489af0b3559f4fd67ea4e8cb9d68be1c9661e478 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "plugin.h"
-
 #include "iarchive.h"
 
 #include "debugging/debugging.h"
diff --git a/plugins/archivepak/plugin.h b/plugins/archivepak/plugin.h
deleted file mode 100644 (file)
index 443a80e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
diff --git a/plugins/archivewad/CMakeLists.txt b/plugins/archivewad/CMakeLists.txt
new file mode 100644 (file)
index 0000000..acafeee
--- /dev/null
@@ -0,0 +1,5 @@
+radiant_plugin(archivewad
+        archive.cpp archive.h
+        plugin.cpp
+        wad.h
+        )
index 793cb0e7091942d8575b4b010f8906d113df9400..e67d19e8db263b74cdbec3f376d163c65cbbb277 100644 (file)
@@ -31,8 +31,6 @@
 
 #include "archivelib.h"
 
-#include "plugin.h"
-
 #include <map>
 #include "string/string.h"
 
index 2ade32ab1e63dd9facc80aaf3c57e6b997f9d8a3..9581357295e3759b08078bb8c36929cba4f22a52 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "plugin.h"
-
 #include "iarchive.h"
 
 #include "debugging/debugging.h"
diff --git a/plugins/archivewad/plugin.h b/plugins/archivewad/plugin.h
deleted file mode 100644 (file)
index 443a80e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
diff --git a/plugins/archivewad/wad.cpp b/plugins/archivewad/wad.cpp
deleted file mode 100644 (file)
index 778d0c6..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/plugins/archivezip/CMakeLists.txt b/plugins/archivezip/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7ed025d
--- /dev/null
@@ -0,0 +1,10 @@
+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})
diff --git a/plugins/archivezip/pkzip.cpp b/plugins/archivezip/pkzip.cpp
deleted file mode 100644 (file)
index 80c73d4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 146c40752c5053a485821950492bd4b7b4db606e..01d4b5f297f3629c1d976cbbe48f78e3fc7cd5d9 100644 (file)
@@ -98,7 +98,7 @@ inline void istream_read_zip_file_header( SeekableInputStream& istream, zip_file
        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
@@ -120,7 +120,7 @@ inline void istream_read_zip_file_trailer( InputStream& istream, zip_file_traile
        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:
index 8375eafa2114eaf5592c2e2a88dd04921472c165..69a344b9a142421482373cb223c2cb7985711c83 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "plugin.h"
-
 #include "iarchive.h"
 
 #include "debugging/debugging.h"
@@ -69,9 +67,30 @@ typedef SingletonModule<ArchivePK4API> ArchivePK4Module;
 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();
 }
diff --git a/plugins/archivezip/plugin.h b/plugins/archivezip/plugin.h
deleted file mode 100644 (file)
index 443a80e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
diff --git a/plugins/archivezip/zlibstream.cpp b/plugins/archivezip/zlibstream.cpp
deleted file mode 100644 (file)
index c47fa2a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/plugins/entity/CMakeLists.txt b/plugins/entity/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8e35991
--- /dev/null
@@ -0,0 +1,29 @@
+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>
+)
diff --git a/plugins/entity/angle.cpp b/plugins/entity/angle.cpp
deleted file mode 100644 (file)
index 7dcbd36..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 3e2da58b3d3bc64bebf774e541da56b04581a16a..a73c5332c779bd93ede5ecd2f4d5539e97ef8ae5 100644 (file)
@@ -59,12 +59,12 @@ inline void write_angle( float angle, Entity* entity ){
 
 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 ){
 }
 
@@ -72,7 +72,7 @@ void angleChanged( const char* value ){
        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 );
diff --git a/plugins/entity/angles.cpp b/plugins/entity/angles.cpp
deleted file mode 100644 (file)
index c114916..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 1ace81ea605cf18417f2af48ffbea7022f75017a..e44c6fcfc14ed006308f7f0e0f833f17ecab58f0 100644 (file)
@@ -97,12 +97,12 @@ inline Vector3 angles_rotated( const Vector3& angles, const Quaternion& rotation
 
 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 ){
 }
 
@@ -110,13 +110,13 @@ void angleChanged( const char* value ){
        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 );
diff --git a/plugins/entity/colour.cpp b/plugins/entity/colour.cpp
deleted file mode 100644 (file)
index 8c95988..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index e0b42ad7e7b6a8cfb3ad51dab05a39ad5d5102e3..86e0deb60037900f6e2c863a239dc3c1946135d9 100644 (file)
@@ -47,7 +47,7 @@ inline void write_colour( const Vector3& colour, Entity* entity ){
 
 class Colour
 {
-Callback m_colourChanged;
+Callback<void()> m_colourChanged;
 Shader* m_state;
 
 void capture_state(){
@@ -60,7 +60,7 @@ void release_state(){
 public:
 Vector3 m_colour;
 
-Colour( const Callback& colourChanged )
+Colour( const Callback<void()>& colourChanged )
        : m_colourChanged( colourChanged ){
        default_colour( m_colour );
        capture_state();
@@ -76,7 +76,7 @@ void colourChanged( const char* value ){
 
        m_colourChanged();
 }
-typedef MemberCaller1<Colour, const char*, &Colour::colourChanged> ColourChangedCaller;
+typedef MemberCaller<Colour, void(const char*), &Colour::colourChanged> ColourChangedCaller;
 
 
 void write( Entity* entity ) const {
diff --git a/plugins/entity/curve.cpp b/plugins/entity/curve.cpp
deleted file mode 100644 (file)
index e38d2a1..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index de610de35f05d6409b78b09d2278d9256c1141af..c22a51aa899cb043602b3405c82cddfda6049057 100644 (file)
@@ -111,50 +111,6 @@ inline void ControlPoint_testSelect( const Vector3& point, ObservedSelectable& s
        }
 }
 
-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:
@@ -253,15 +209,21 @@ void write( const char* key, Entity& entity ){
 }
 
 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 {
@@ -285,11 +247,13 @@ void curveChanged(){
 
        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;
 };
 
 
@@ -299,7 +263,7 @@ const int NURBS_degree = 3;
 class NURBSCurve
 {
 Signal0 m_curveChanged;
-Callback m_boundsChanged;
+Callback<void()> m_boundsChanged;
 public:
 ControlPoints m_controlPoints;
 ControlPoints m_controlPointsTransformed;
@@ -308,7 +272,7 @@ Knots m_knots;
 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 ){
@@ -379,20 +343,20 @@ void curveChanged( const char* value ){
        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 ){
@@ -447,7 +411,7 @@ void curveChanged( const char* value ){
        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";
index b53017c55d59b05c734714305da1d11b113ab9a1..ceb19b0b876055350f306b2989fcf0efe567bcac 100644 (file)
@@ -103,8 +103,8 @@ SignalHandlerId m_curveCatmullRomChanged;
 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;
@@ -199,7 +199,7 @@ void nameChanged( const char* value ){
        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;
@@ -212,7 +212,7 @@ void modelChanged( const char* 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;
@@ -225,19 +225,19 @@ void updateTransform(){
                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() ) {
@@ -247,10 +247,10 @@ void skinChanged(){
                }
        }
 }
-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 ),
@@ -269,7 +269,7 @@ Doom3Group( EntityClass* eclass, scene::Node& node, const Callback& transformCha
        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 ),
@@ -420,18 +420,7 @@ void transformChanged(){
        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 :
@@ -555,8 +544,12 @@ void transformComponents( const Matrix4& matrix ){
 
 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;
 }
 
@@ -586,13 +579,13 @@ void applyTransform(){
        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 :
index 855fc9230467e7a394d225f48646d719ccaa86a5..3b91eeb0d33ca0d4699a4f70aaad3823d9b6e528 100644 (file)
@@ -76,8 +76,8 @@ RenderablePivot m_renderOrigin;
 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 );
@@ -114,23 +114,23 @@ void updateTransform(){
 
        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();
@@ -138,11 +138,11 @@ void skinChanged(){
                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 ),
@@ -158,7 +158,7 @@ EclassModel( EntityClass* eclass, scene::Node& node, const Callback& transformCh
        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 ),
@@ -283,7 +283,7 @@ void transformChanged(){
        m_evaluateTransform();
        updateTransform();
 }
-typedef MemberCaller<EclassModel, &EclassModel::transformChanged> TransformChangedCaller;
+typedef MemberCaller<EclassModel, void(), &EclassModel::transformChanged> TransformChangedCaller;
 };
 
 class EclassModelInstance : public TargetableInstance, public TransformModifier, public Renderable
@@ -340,7 +340,7 @@ void applyTransform(){
        evaluateTransform();
        m_contained.freezeTransform();
 }
-typedef MemberCaller<EclassModelInstance, &EclassModelInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<EclassModelInstance, void(), &EclassModelInstance::applyTransform> ApplyTransformCaller;
 };
 
 class EclassModelNode :
index bdfd51e3ab0d3183b9bf1acdf578634a4ecac8a6..5dfe2fe92552671cca84367804f7b624e51dc21a 100644 (file)
@@ -25,7 +25,7 @@
 namespace scene
 {
 class Node;
-};
+}
 class EntityClass;
 
 scene::Node& New_EclassModel( EntityClass* eclass );
index db0e16b47f316d75871296b88626109c9a2492a4..181f9412082ed9c74434b7dbf4701957454e7765 100644 (file)
@@ -78,7 +78,7 @@ inline scene::Node& entity_for_eclass( 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 );
@@ -138,7 +138,7 @@ void connect( const char* name ){
        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 ){
@@ -255,7 +255,7 @@ void connectEntities( const scene::Path& path, const scene::Path& targetPath, in
 void setLightRadii( bool lightRadii ){
        g_lightRadii = lightRadii;
 }
-bool getLightRadii(){
+bool getLightRadii() const {
        return g_lightRadii;
 }
 void setShowNames( bool showNames ){
@@ -356,10 +356,10 @@ void Entity_Construct( EGameType gameType ){
                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;
index d903e28c0d1ce32e026b5b15c2c852de654cd34d..219d6de93c2cdc8b79cd680f340320e3886789c7 100644 (file)
@@ -69,7 +69,7 @@ void updateFiltered(){
 void classnameChanged( const char* value ){
        updateFiltered();
 }
-typedef MemberCaller1<ClassnameFilter, const char*, &ClassnameFilter::classnameChanged> ClassnameChangedCaller;
+typedef MemberCaller<ClassnameFilter, void(const char*), &ClassnameFilter::classnameChanged> ClassnameChangedCaller;
 };
 
 #endif
index bfdd22e89e158a595bd4f721ee78d8cb6da0c3ea..b80ae8300a1bb14cabb0fd0af830dee6b30afd93 100644 (file)
@@ -97,8 +97,8 @@ RenderableSolidAABB m_aabb_solid;
 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() );
@@ -120,20 +120,20 @@ void updateTransform(){
        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 ),
@@ -150,7 +150,7 @@ GenericEntity( EntityClass* eclass, scene::Node& node, const Callback& transform
        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 ),
@@ -264,7 +264,7 @@ void transformChanged(){
        m_evaluateTransform();
        updateTransform();
 }
-typedef MemberCaller<GenericEntity, &GenericEntity::transformChanged> TransformChangedCaller;
+typedef MemberCaller<GenericEntity, void(), &GenericEntity::transformChanged> TransformChangedCaller;
 };
 
 class GenericEntityInstance :
@@ -342,7 +342,7 @@ void applyTransform(){
        evaluateTransform();
        m_contained.freezeTransform();
 }
-typedef MemberCaller<GenericEntityInstance, &GenericEntityInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<GenericEntityInstance, void(), &GenericEntityInstance::applyTransform> ApplyTransformCaller;
 };
 
 class GenericEntityNode :
index 8e308c4c37ab8184508597e4539974fa4c6a70c5..bad7fc54e793b102a8bcd2caae1f6bd896497b9d 100644 (file)
@@ -66,8 +66,8 @@ Vector3 m_origin;
 RenderableNamedEntity m_renderName;
 mutable Vector3 m_name_origin;
 
-Callback m_transformChanged;
-Callback m_evaluateTransform;
+Callback<void()> m_transformChanged;
+Callback<void()> m_evaluateTransform;
 
 void construct(){
        m_keyObservers.insert( "classname", ClassnameFilter::ClassnameChangedCaller( m_filter ) );
@@ -76,7 +76,7 @@ void construct(){
 }
 
 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 ),
@@ -89,7 +89,7 @@ Group( EntityClass* eclass, scene::Node& node, const Callback& transformChanged,
        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 ),
@@ -172,12 +172,12 @@ void updateTransform(){
        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 );
@@ -195,7 +195,7 @@ void transformChanged(){
        m_evaluateTransform();
        updateTransform();
 }
-typedef MemberCaller<Group, &Group::transformChanged> TransformChangedCaller;
+typedef MemberCaller<Group, void(), &Group::transformChanged> TransformChangedCaller;
 };
 
 #if 0
@@ -337,7 +337,7 @@ void applyTransform(){
        evaluateTransform();
        m_contained.freezeTransform();
 }
-typedef MemberCaller<GroupInstance, &GroupInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<GroupInstance, void(), &GroupInstance::applyTransform> ApplyTransformCaller;
 };
 
 class GroupNode :
diff --git a/plugins/entity/keyobservers.cpp b/plugins/entity/keyobservers.cpp
deleted file mode 100644 (file)
index 210b138..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 2d0bf78ef9063e80db255adb24202b3a54bb25fc..018a4cf82db21e711825c0be6ab10f202d6e8086 100644 (file)
@@ -491,12 +491,12 @@ void primaryIntensityChanged( const char* value ){
        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 ) {
@@ -504,7 +504,7 @@ void scaleChanged( const char* value ){
        }
        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 ) {
@@ -512,12 +512,12 @@ void fadeChanged( const char* value ){
        }
        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
@@ -527,7 +527,7 @@ Vector3 m_defaultRadius;
 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 ){
@@ -547,7 +547,7 @@ void lightRadiusChanged( const char* value ){
        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 );
@@ -556,7 +556,7 @@ void lightCenterChanged( const char* value ){
        }
        SceneChangeNotify();
 }
-typedef MemberCaller1<Doom3LightRadius, const char*, &Doom3LightRadius::lightCenterChanged> LightCenterChangedCaller;
+typedef MemberCaller<Doom3LightRadius, void(const char*), &Doom3LightRadius::lightCenterChanged> LightCenterChangedCaller;
 };
 
 class RenderLightRadiiWire : public OpenGLRenderable
@@ -650,8 +650,8 @@ void render( RenderStateFlags state ) const {
        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 );
 }
 };
@@ -709,7 +709,7 @@ void valueChanged( const char* value ){
        }
        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();
@@ -807,9 +807,9 @@ LightShader m_shader;
 
 AABB m_aabb_light;
 
-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 );
@@ -878,7 +878,7 @@ void originChanged(){
        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 );
@@ -887,7 +887,7 @@ void lightOriginChanged( const char* 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 );
@@ -896,7 +896,7 @@ void lightTargetChanged( const char* 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 ) {
@@ -904,7 +904,7 @@ void lightUpChanged( const char* value ){
        }
        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 ) {
@@ -912,7 +912,7 @@ void lightRightChanged( const char* value ){
        }
        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 ) {
@@ -920,7 +920,7 @@ void lightStartChanged( const char* value ){
        }
        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 ) {
@@ -928,7 +928,7 @@ void lightEndChanged( const char* value ){
        }
        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" );
@@ -959,7 +959,7 @@ void rotationChanged(){
        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 );
@@ -968,15 +968,15 @@ void lightRotationChanged( const char* 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 ),
@@ -995,11 +995,11 @@ Light( EntityClass* eclass, scene::Node& node, const Callback& transformChanged,
        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 ),
@@ -1231,7 +1231,7 @@ void transformChanged(){
        m_evaluateTransform();
        updateOrigin();
 }
-typedef MemberCaller<Light, &Light::transformChanged> TransformChangedCaller;
+typedef MemberCaller<Light, void(), &Light::transformChanged> TransformChangedCaller;
 
 mutable Matrix4 m_localPivot;
 const Matrix4& getLocalPivot() const {
@@ -1240,7 +1240,7 @@ const Matrix4& getLocalPivot() const {
        return m_localPivot;
 }
 
-void setLightChangedCallback( const Callback& callback ){
+void setLightChangedCallback( const Callback<void()>& callback ){
        m_doom3Radius.m_changed = callback;
 }
 
@@ -1488,7 +1488,7 @@ LightInstance( const scene::Path& path, scene::Instance* parent, Light& containe
        StaticRenderableConnectionLines::instance().detach( *this );
 
        if ( g_lightType == LIGHTTYPE_DOOM3 ) {
-               m_contained.setLightChangedCallback( Callback() );
+               m_contained.setLightChangedCallback( Callback<void()>() );
                GlobalShaderCache().detach( *this );
        }
 
@@ -1527,7 +1527,7 @@ void selectedChangedComponent( const Selectable& selectable ){
        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 ) {
@@ -1547,12 +1547,12 @@ void applyTransform(){
        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();
index 4eaf7d8a36c90c228a250230ff19fa1d63ab9585..5c807ab270342cb9e58695bb05841c614d35b50d 100644 (file)
@@ -25,7 +25,7 @@
 namespace scene
 {
 class Node;
-};
+}
 class EntityClass;
 
 scene::Node& New_Light( EntityClass* eclass );
index e6197d099e43e323fecc08594e6b3bc4cac4d927..ac541a6f34f270ca6ab3e1d2ef6056712802e188 100644 (file)
@@ -72,8 +72,8 @@ NameKeys m_nameKeys;
 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 ) );
@@ -101,20 +101,20 @@ void originChanged(){
        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 ),
@@ -130,7 +130,7 @@ MiscModel( EntityClass* eclass, scene::Node& node, const Callback& transformChan
        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 ),
@@ -235,7 +235,7 @@ void transformChanged(){
        m_evaluateTransform();
        updateTransform();
 }
-typedef MemberCaller<MiscModel, &MiscModel::transformChanged> TransformChangedCaller;
+typedef MemberCaller<MiscModel, void(), &MiscModel::transformChanged> TransformChangedCaller;
 };
 
 class MiscModelInstance : public TargetableInstance, public TransformModifier, public Renderable
@@ -290,7 +290,7 @@ void applyTransform(){
        evaluateTransform();
        m_contained.freezeTransform();
 }
-typedef MemberCaller<MiscModelInstance, &MiscModelInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<MiscModelInstance, void(), &MiscModelInstance::applyTransform> ApplyTransformCaller;
 };
 
 class MiscModelNode :
diff --git a/plugins/entity/model.cpp b/plugins/entity/model.cpp
deleted file mode 100644 (file)
index 74717a5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index a7b395ff21def1d2e25aaa5cac8524e115404344..75e442f1af068ff97241e9b27d59980ab3c44f5e 100644 (file)
@@ -34,10 +34,10 @@ class EModel : public ModuleObserver
 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 );
 }
@@ -66,7 +66,7 @@ void modelChanged( const char* value ){
        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();
@@ -82,7 +82,7 @@ TraversableNode m_traverse;
 EModel m_model;
 public:
 SingletonModel()
-       : m_model( m_traverse, Callback() ){
+       : m_model( m_traverse, Callback<void()>() ){
 }
 
 void attach( scene::Traversable::Observer* observer ){
@@ -99,7 +99,7 @@ scene::Traversable& getTraversable(){
 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();
diff --git a/plugins/entity/modelskinkey.cpp b/plugins/entity/modelskinkey.cpp
deleted file mode 100644 (file)
index 4567578..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 34d9111201a79cc2c1f5aa554d50cf0985cf87d2..963640158ade832546e4b4bdfdc03460a54fa9b4 100644 (file)
@@ -40,7 +40,7 @@ class ModelSkinKey : public ModuleObserver
 {
 CopiedString m_name;
 ModelSkin* m_skin;
-Callback m_skinChangedCallback;
+Callback<void()> m_skinChangedCallback;
 
 ModelSkinKey( const ModelSkinKey& );
 ModelSkinKey operator=( const ModelSkinKey& );
@@ -55,7 +55,7 @@ void destroy(){
 }
 
 public:
-ModelSkinKey( const Callback& skinChangedCallback ) : m_skinChangedCallback( skinChangedCallback ){
+ModelSkinKey( const Callback<void()>& skinChangedCallback ) : m_skinChangedCallback( skinChangedCallback ){
        construct();
 }
 ~ModelSkinKey(){
@@ -69,7 +69,7 @@ void skinChanged( const char* value ){
        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();
diff --git a/plugins/entity/namedentity.cpp b/plugins/entity/namedentity.cpp
deleted file mode 100644 (file)
index 5edbf1c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 29170d9e795bd112c78e4bc6d461191f6f90c8b5..857b10b44a5e41a0066da12e01fc5fc8feb0a08a 100644 (file)
@@ -79,7 +79,7 @@ void identifierChanged( const char* value ){
        }
        m_name = value;
 }
-typedef MemberCaller1<NamedEntity, const char*, &NamedEntity::identifierChanged> IdentifierChangedCaller;
+typedef MemberCaller<NamedEntity, void(const char*), &NamedEntity::identifierChanged> IdentifierChangedCaller;
 };
 
 class RenderableNamedEntity : public OpenGLRenderable
diff --git a/plugins/entity/namekeys.cpp b/plugins/entity/namekeys.cpp
deleted file mode 100644 (file)
index 7351c57..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 0e2d88b3b48bdedf96a69f101ac2d81656a76432..45943f1f336c66f0d247ba2c18c9c5048728c42b 100644 (file)
@@ -46,9 +46,9 @@ KeyIsName(){
 };
 
 
-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
 {
diff --git a/plugins/entity/origin.cpp b/plugins/entity/origin.cpp
deleted file mode 100644 (file)
index c0c9b11..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 8628c3cf6e5316e1fc2192d3fdc737498f4e7707..84bb74621fd5cf2dde3b1d959e7cfe8dbbdff4be 100644 (file)
@@ -59,12 +59,12 @@ inline Vector3 origin_snapped( const Vector3& origin, float snap ){
 
 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 ){
 }
 
@@ -72,7 +72,7 @@ void originChanged( const char* value ){
        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 {
index e8131e0b3d77cb3c4befda98a63ef7c5660a0745..58b6fb37ee5a854d981f7b81b0ca0487d78c2567 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "plugin.h"
-
 #include "debugging/debugging.h"
 
 #include "iscenegraph.h"
diff --git a/plugins/entity/plugin.h b/plugins/entity/plugin.h
deleted file mode 100644 (file)
index 443a80e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
diff --git a/plugins/entity/rotation.cpp b/plugins/entity/rotation.cpp
deleted file mode 100644 (file)
index 30d5b94..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index fc2c9fbe4434d82011d7e967bec1a83446b48efc..4c566d96f420dd5264a6f509b3920160543c791f 100644 (file)
@@ -144,12 +144,12 @@ inline void read_angle( Float9 rotation, const char* value ){
 
 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 );
 }
@@ -158,13 +158,13 @@ void angleChanged( const char* value ){
        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 ) );
diff --git a/plugins/entity/scale.cpp b/plugins/entity/scale.cpp
deleted file mode 100644 (file)
index 3d5b989..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index f4cb726cff85fd7f3a7fa539221049985f93b610..dfb2884a3c1ae7a72183c71945c661093bd632c7 100644 (file)
@@ -87,12 +87,12 @@ inline Vector3 scale_scaled( const Vector3& scale, const Vector3& scaling ){
 
 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 ){
 }
 
@@ -100,13 +100,13 @@ void uniformScaleChanged( const char* value ){
        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 );
index fce3c1a14f4547ea29df520d0e278ae2d54ae34b..645e8a2875ff0cf65f6bb9ab2aa36f1f8e2cf12f 100644 (file)
@@ -156,7 +156,7 @@ void parseFile( const char* name ){
        }
 }
 
-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 ) );
index 6de382cfabd63b90558e1ffea7016a30d676f233..99046a508f2af58aa491ce95f59d2ba70437ccd9 100644 (file)
@@ -113,7 +113,7 @@ void targetnameChanged( const char* name ){
        m_targets = getTargetables( name );
        construct();
 }
-typedef MemberCaller1<TargetedEntity, const char*, &TargetedEntity::targetnameChanged> TargetnameChangedCaller;
+typedef MemberCaller<TargetedEntity, void(const char*), &TargetedEntity::targetnameChanged> TargetnameChangedCaller;
 };
 
 
@@ -127,7 +127,7 @@ TargetingEntity() :
 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;
 
@@ -194,7 +194,7 @@ void operator()( const Vector3& worldPosition ) const {
 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 ) ) {
@@ -210,7 +210,7 @@ bool readTargetKey( const char* key, std::size_t& index ){
        return false;
 }
 public:
-void setTargetsChanged( const Callback& targetsChanged ){
+void setTargetsChanged( const Callback<void()>& targetsChanged ){
        m_targetsChanged = targetsChanged;
 }
 void targetsChanged(){
@@ -323,7 +323,7 @@ TargetableInstance(
        m_entity.detach( *this );
 }
 
-void setTargetsChanged( const Callback& targetsChanged ){
+void setTargetsChanged( const Callback<void()>& targetsChanged ){
        m_targeting.setTargetsChanged( targetsChanged );
 }
 void targetsChanged(){
diff --git a/plugins/image/CMakeLists.txt b/plugins/image/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bea548e
--- /dev/null
@@ -0,0 +1,14 @@
+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)
index fcfdd01875510561f8db08617b2cb2aec269d05a..7d767f228426db79a3fb0db5a9b68c819af87433 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "image.h"
-
 #include "ifilesystem.h"
 #include "iimage.h"
 
@@ -29,6 +27,7 @@
 #include "bmp.h"
 #include "pcx.h"
 #include "dds.h"
+#include "ktx.h"
 
 
 #include "modulesystem/singletonmodule.h"
@@ -137,6 +136,26 @@ typedef SingletonModule<ImageDDSAPI, ImageDependencies> ImageDDSModule;
 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 );
 
@@ -145,4 +164,5 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server
        g_ImageBMPModule.selfRegister();
        g_ImagePCXModule.selfRegister();
        g_ImageDDSModule.selfRegister();
+       g_ImageKTXModule.selfRegister();
 }
diff --git a/plugins/image/image.h b/plugins/image/image.h
deleted file mode 100644 (file)
index c61bcc2..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
index 138151a2f62c81de5270f9188ff211d53c59a745..91fdf18e39cc54641170c71d9e8b7090b90555ef 100644 (file)
@@ -66,7 +66,7 @@ typedef struct {
 
 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 */
 
 
 /*
@@ -316,6 +316,7 @@ static void j_putRGBAScanline( unsigned char* jpegline, int widthPix, unsigned c
 
                //!\todo fix jpeglib, it leaves alpha channel uninitialised
 #if 1
+               (void) iAlp;
                *oAlp = 255;
 #else
                *oAlp = iAlp;
diff --git a/plugins/image/ktx.cpp b/plugins/image/ktx.cpp
new file mode 100644 (file)
index 0000000..696ede5
--- /dev/null
@@ -0,0 +1,416 @@
+/*
+   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 );
+}
diff --git a/plugins/image/ktx.h b/plugins/image/ktx.h
new file mode 100644 (file)
index 0000000..6070077
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+   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
index bc498a8fff6972afae3c6e4597492d68fb617c49..4fa8731f5a3b7600ead4d9e16982b0002567bb58 100644 (file)
@@ -165,6 +165,42 @@ inline TargaPacketSize targa_packet_size( const TargaPacket& packet ){
 }
 
 
+class TargaDecodeGrayPixelRLE
+{
+TargaPacketSize m_packetSize;
+RGBAPixel m_pixel;
+TargaPacket m_packet;
+public:
+TargaDecodeGrayPixelRLE() : m_packetSize( 0 ){
+}
+void operator()( PointerInputStream& istream, RGBAPixel& pixel ){
+       if ( m_packetSize == 0 ) {
+               targa_packet_read_istream( m_packet, istream );
+               m_packetSize = targa_packet_size( m_packet );
+
+               if ( targa_packet_is_rle( m_packet ) ) {
+                       istream_read_gray( istream, m_pixel );
+               }
+       }
+
+       if ( targa_packet_is_rle( m_packet ) ) {
+               pixel = m_pixel;
+       }
+       else
+       {
+               istream_read_gray( istream, pixel );
+       }
+
+       --m_packetSize;
+}
+};
+
+template<typename Flip>
+void targa_decode_rle_grayscale( PointerInputStream& istream, RGBAImage& image, const Flip& flip ){
+       TargaDecodeGrayPixelRLE decode;
+       image_decode( istream, decode, image, flip );
+}
+
 class TargaDecodeRGBPixelRLE
 {
 TargaPacketSize m_packetSize;
@@ -305,9 +341,12 @@ Image* Targa_decodeImageData( const TargaHeader& targa_header, PointerInputStrea
                        return 0;
                }
        }
-       else if ( targa_header.image_type == 10 ) {
+       else if ( targa_header.image_type == 10 || targa_header.image_type == 11 ) {
                switch ( targa_header.pixel_size )
                {
+               case 8:
+                       targa_decode_rle_grayscale( istream, *image, flip );
+                       break;
                case 24:
                        targa_decode_rle_rgb( istream, *image, flip );
                        break;
@@ -333,9 +372,9 @@ Image* LoadTGABuff( const byte* buffer ){
 
        targa_header_read_istream( targa_header, istream );
 
-       if ( targa_header.image_type != 2 && targa_header.image_type != 10 && targa_header.image_type != 3 ) {
+       if ( targa_header.image_type != 2 && targa_header.image_type != 10 && targa_header.image_type != 3 && targa_header.image_type != 11 ) {
                globalErrorStream() << "LoadTGA: TGA type " << targa_header.image_type << " not supported\n";
-               globalErrorStream() << "LoadTGA: Only type 2 (RGB), 3 (gray), and 10 (RGB) TGA images supported\n";
+               globalErrorStream() << "LoadTGA: Only type 2 (RGB), 3 (gray), 10 (RGB), and 11 (gray) TGA images supported\n";
                return 0;
        }
 
@@ -344,9 +383,9 @@ Image* LoadTGABuff( const byte* buffer ){
                return 0;
        }
 
-       if ( ( targa_header.pixel_size != 32 && targa_header.pixel_size != 24 )
-                && targa_header.image_type != 3 ) {
-               globalErrorStream() << "LoadTGA: Only 32 or 24 bit images supported\n";
+       if ( ( ( targa_header.image_type == 2 || targa_header.image_type == 10 ) && targa_header.pixel_size != 32 && targa_header.pixel_size != 24 ) ||
+            ( ( targa_header.image_type == 3 || targa_header.image_type == 11 ) && targa_header.pixel_size != 8 ) ) {
+               globalErrorStream() << "LoadTGA: Only 32, 24 or 8 bit images supported\n";
                return 0;
        }
 
diff --git a/plugins/imagecrn/CMakeLists.txt b/plugins/imagecrn/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fd45552
--- /dev/null
@@ -0,0 +1,7 @@
+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)
diff --git a/plugins/imagecrn/crn.cpp b/plugins/imagecrn/crn.cpp
new file mode 100644 (file)
index 0000000..85e1e5c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+   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);
+}
diff --git a/plugins/imagecrn/crn.h b/plugins/imagecrn/crn.h
new file mode 100644 (file)
index 0000000..4e97556
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+   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
+
diff --git a/plugins/imagecrn/imagecrn.cpp b/plugins/imagecrn/imagecrn.cpp
new file mode 100644 (file)
index 0000000..4516f06
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+   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();
+}
diff --git a/plugins/imagecrn/imagecrn.def b/plugins/imagecrn/imagecrn.def
new file mode 100644 (file)
index 0000000..df815fa
--- /dev/null
@@ -0,0 +1,7 @@
+; imagepng.def : Declares the module parameters for the DLL.
+
+LIBRARY      "IMAGECRN"
+
+EXPORTS
+    ; Explicit exports can go here
+       Radiant_RegisterModules @1
diff --git a/plugins/imagehl/CMakeLists.txt b/plugins/imagehl/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2e36ca1
--- /dev/null
@@ -0,0 +1,6 @@
+radiant_plugin(imagehl
+        hlw.cpp hlw.h
+        imagehl.cpp
+        mip.cpp mip.h
+        sprite.cpp sprite.h
+        )
index 2731e15ad2003a4462331e2b5488ca55c5d0a8b0..732755476a5245bf40084d90b9b44b502c8bd4a4 100644 (file)
@@ -91,7 +91,7 @@ typedef struct
 Image* LoadHLWBuff( byte* buffer ){
        byte *buf_p;
        unsigned long mipdatasize;
-       int columns, rows, numPixels;
+       int columns, rows;
        byte *pixbuf;
        int row, column;
        byte *palette;
@@ -108,7 +108,6 @@ Image* LoadHLWBuff( byte* buffer ){
 
        columns = lpMip->width;
        rows = lpMip->height;
-       numPixels = columns * rows;
 
        RGBAImage* image = new RGBAImage( columns, rows );
 
index 479a0d99960ff9e5bebb782d1d91551a55eb69cc..dfdf98b98c136fd28bd2b34a0e6363bf4ddfa811 100644 (file)
@@ -19,8 +19,6 @@
    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"
diff --git a/plugins/imagehl/imagehl.h b/plugins/imagehl/imagehl.h
deleted file mode 100644 (file)
index 6d0b776..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
index 51dbfd7e916409764e448fc21e1f169bd2873534..a9d5a71bf1ad79d32d7850a0e8addd0a5877a3fa 100644 (file)
@@ -138,7 +138,6 @@ static const byte quakepalette[768] =
 Image* LoadMIPBuff( byte* buffer ){
        byte *buf_p;
        int palettelength;
-       unsigned long mipdatasize;
        int columns, rows, numPixels;
        byte *pixbuf;
        int i;
@@ -158,7 +157,7 @@ Image* LoadMIPBuff( byte* buffer ){
                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 ) {
index b6347ec480f9444f95f84977d56e3aad372c552c..195d952832793552ea8afc27c37e04aba792daf5 100644 (file)
@@ -91,7 +91,7 @@ typedef struct {
    } dpalette_t;
  */
 
-#define IDSPRITEHEADER  ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' )
+const int IDSPRITEHEADER = ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' );
 // little-endian "IDSP"
 
 /*
@@ -102,7 +102,7 @@ typedef struct {
 
 Image* LoadIDSPBuff( byte *buffer ){
        byte *buf_p;
-       int columns, rows, numPixels;
+       int columns, rows;
        byte *pixbuf;
 
        int row, column;
@@ -159,8 +159,6 @@ Image* LoadIDSPBuff( byte *buffer ){
        // palette = buffer+mipdatasize+2;
        // buf_p = buffer+lpMip->offsets[0];
 
-       numPixels = columns * rows;
-
        RGBAImage* image = new RGBAImage( columns, rows );
 
 #ifdef DEBUG
diff --git a/plugins/imagepng/CMakeLists.txt b/plugins/imagepng/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a9c6993
--- /dev/null
@@ -0,0 +1,7 @@
+radiant_plugin(imagepng
+        plugin.cpp
+        )
+
+find_package(PNG REQUIRED)
+target_include_directories(imagepng PRIVATE ${PNG_INCLUDE_DIR})
+target_link_libraries(imagepng PRIVATE ${PNG_LIBRARIES})
index bf0874165c71dbbbfd8294970d2589063ac77826..281193fd63afd1208a1d37128912da151b687f77 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "plugin.h"
-
 #include "debugging/debugging.h"
 
 #include "ifilesystem.h"
@@ -182,11 +180,13 @@ class ImagePNGAPI
 _QERPlugImageTable m_imagepng;
 public:
 typedef _QERPlugImageTable Type;
+
 STRING_CONSTANT( Name, "png" );
 
 ImagePNGAPI(){
        m_imagepng.loadImage = LoadPNG;
 }
+
 _QERPlugImageTable* getTable(){
        return &m_imagepng;
 }
diff --git a/plugins/imagepng/plugin.h b/plugins/imagepng/plugin.h
deleted file mode 100644 (file)
index 271a2ad..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
diff --git a/plugins/imageq2/CMakeLists.txt b/plugins/imageq2/CMakeLists.txt
new file mode 100644 (file)
index 0000000..942c7e0
--- /dev/null
@@ -0,0 +1,5 @@
+radiant_plugin(imageq2
+        imageq2.cpp
+        wal.cpp wal.h
+        wal32.cpp wal32.h
+        )
index 6210166750b04c1984d2328206100ed3f234fa7e..9ea5c635ff178fb6b80b92dbe2a06e179287790a 100644 (file)
@@ -19,8 +19,6 @@
    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"
diff --git a/plugins/imageq2/imageq2.h b/plugins/imageq2/imageq2.h
deleted file mode 100644 (file)
index 3837437..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
index 6160887b7dc27546ee3ca37fa500891aa9f07f1d..5994e5088c6663334c78680ffb8e4fef431676d8 100644 (file)
@@ -28,8 +28,8 @@
 #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;
 
diff --git a/plugins/imagewebp/CMakeLists.txt b/plugins/imagewebp/CMakeLists.txt
new file mode 100644 (file)
index 0000000..baac0ca
--- /dev/null
@@ -0,0 +1,7 @@
+radiant_plugin(imagewebp
+        plugin.cpp
+        )
+
+find_package(WebP REQUIRED)
+target_include_directories(imagewebp PRIVATE ${WEBP_INCLUDE_DIR})
+target_link_libraries(imagewebp PRIVATE ${WEBP_LIBRARIES})
diff --git a/plugins/imagewebp/imagewebp.def b/plugins/imagewebp/imagewebp.def
new file mode 100644 (file)
index 0000000..d04effc
--- /dev/null
@@ -0,0 +1,7 @@
+; imagewebp.def : Declares the module parameters for the DLL.
+
+LIBRARY      "IMAGEWEBP"
+
+EXPORTS
+    ; Explicit exports can go here
+       Radiant_RegisterModules @1
diff --git a/plugins/imagewebp/plugin.cpp b/plugins/imagewebp/plugin.cpp
new file mode 100644 (file)
index 0000000..0dcd7ed
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+   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();
+}
diff --git a/plugins/imagewebp/plugin.h b/plugins/imagewebp/plugin.h
new file mode 100644 (file)
index 0000000..28a2933
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+   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
diff --git a/plugins/iqmmodel/CMakeLists.txt b/plugins/iqmmodel/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e371ae7
--- /dev/null
@@ -0,0 +1,4 @@
+radiant_plugin(iqmmodel
+        iqm.cpp iqm.h
+        plugin.cpp plugin.h
+        )
diff --git a/plugins/iqmmodel/iqm.cpp b/plugins/iqmmodel/iqm.cpp
new file mode 100644 (file)
index 0000000..466effc
--- /dev/null
@@ -0,0 +1,313 @@
+/*
+   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 );
+}
diff --git a/plugins/iqmmodel/iqm.h b/plugins/iqmmodel/iqm.h
new file mode 100644 (file)
index 0000000..5e6a014
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+   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
diff --git a/plugins/iqmmodel/modeliqm.def b/plugins/iqmmodel/modeliqm.def
new file mode 100644 (file)
index 0000000..5791cd7
--- /dev/null
@@ -0,0 +1,7 @@
+; modeliqm.def : Declares the module parameters for the DLL.
+
+LIBRARY      "MODELIQM"
+
+EXPORTS
+    ; Explicit exports can go here
+       Radiant_RegisterModules @1
diff --git a/plugins/iqmmodel/plugin.cpp b/plugins/iqmmodel/plugin.cpp
new file mode 100644 (file)
index 0000000..b6d896e
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+   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();
+}
diff --git a/plugins/iqmmodel/plugin.h b/plugins/iqmmodel/plugin.h
new file mode 100644 (file)
index 0000000..c94ee67
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+   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
diff --git a/plugins/mapq3/CMakeLists.txt b/plugins/mapq3/CMakeLists.txt
new file mode 100644 (file)
index 0000000..880b653
--- /dev/null
@@ -0,0 +1,9 @@
+radiant_plugin(mapq3
+        parse.cpp parse.h
+        plugin.cpp
+        write.cpp write.h
+        )
+
+target_include_directories(mapq3
+    PRIVATE $<TARGET_PROPERTY:uilib,INTERFACE_INCLUDE_DIRECTORIES>
+)
index 2c3d99c519b550838dbd503a563a9fde75aa3c9e..8b427d42801bf1f6eba1ce1b0df73b303eb9156b 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "plugin.h"
-
 #include "iscriplib.h"
 #include "ibrush.h"
 #include "ipatch.h"
@@ -56,12 +54,15 @@ MapDoom3Dependencies() :
        m_patchDef2Doom3Module( "def2doom3" ),
        m_patchDoom3Module( "doom3" ){
 }
+
 BrushCreator& getBrushDoom3(){
        return GlobalBrushModule::getTable();
 }
+
 PatchCreator& getPatchDoom3(){
        return *m_patchDoom3Module.getTable();
 }
+
 PatchCreator& getPatchDef2Doom3(){
        return *m_patchDef2Doom3Module.getTable();
 }
@@ -72,13 +73,16 @@ class MapDoom3API : public TypeSystemRef, public MapFormat, public PrimitivePars
 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;
 }
@@ -118,12 +122,13 @@ void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator&
        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();
 }
 };
@@ -143,13 +148,16 @@ class MapQuake4API : public TypeSystemRef, public MapFormat, public PrimitivePar
 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;
 }
@@ -189,12 +197,13 @@ void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator&
        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();
 }
 };
@@ -231,6 +240,7 @@ class MapQ3API : public TypeSystemRef, public MapFormat, public PrimitiveParser
 mutable bool detectedFormat;
 public:
 typedef MapFormat Type;
+
 STRING_CONSTANT( Name, "mapq3" );
 
 MapQ3API(){
@@ -238,6 +248,7 @@ 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;
 }
@@ -283,13 +294,14 @@ scene::Node& parsePrimitive( Tokeniser& tokeniser ) const {
 void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const {
        detectedFormat = false;
        wrongFormat = false;
-       Tokenisertokeniser = 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();
 }
 };
@@ -303,12 +315,14 @@ class MapQ1API : public TypeSystemRef, public MapFormat, public PrimitiveParser
 {
 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;
 }
@@ -330,9 +344,10 @@ void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator&
        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();
 }
 };
@@ -346,12 +361,14 @@ class MapHalfLifeAPI : public TypeSystemRef, public MapFormat, public PrimitiveP
 {
 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;
 }
@@ -368,14 +385,16 @@ scene::Node& parsePrimitive( Tokeniser& tokeniser ) const {
        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();
 }
 };
@@ -389,12 +408,14 @@ class MapQ2API : public TypeSystemRef, public MapFormat, public PrimitiveParser
 {
 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;
 }
@@ -415,9 +436,10 @@ void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator&
        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();
 }
 };
@@ -427,8 +449,7 @@ typedef SingletonModule<MapQ2API, MapDependencies> MapQ2Module;
 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 ) );
@@ -437,6 +458,7 @@ inline void parseToken( Tokeniser& tokeniser, const char* token ){
 #include "generic/arrayrange.h"
 
 class VMFBlock;
+
 typedef ArrayConstRange<VMFBlock> VMFBlockArrayRange;
 
 
@@ -453,9 +475,11 @@ const char* name() const {
        return m_name;
 }
 typedef Value* const_iterator;
+
 const_iterator begin() const {
        return m_children.first;
 }
+
 const_iterator end() const {
        return m_children.last;
 }
@@ -559,12 +583,14 @@ class MapVMFAPI : public TypeSystemRef, public MapFormat
 {
 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;
 }
@@ -574,7 +600,8 @@ void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator&
        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 {
 }
 };
 
@@ -583,7 +610,6 @@ typedef SingletonModule<MapVMFAPI, MapDependencies> MapVMFModule;
 MapVMFModule g_MapVMFModule;
 
 
-
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
        initialiseModule( server );
 
diff --git a/plugins/mapq3/plugin.h b/plugins/mapq3/plugin.h
deleted file mode 100644 (file)
index 443a80e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
index 7a95458644ce22909f52518521b484ce60f064ef..4bfbbe78da0097a8d8974a4c658ac32b7eb0767f 100644 (file)
@@ -61,19 +61,23 @@ class WriteTokensWalker : public scene::Traversable::Walker
 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();
@@ -85,11 +89,13 @@ bool pre( scene::Node& node ) const {
        {
                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 );
                }
@@ -97,6 +103,7 @@ bool pre( scene::Node& node ) const {
 
        return true;
 }
+
 void post( scene::Node& node ) const {
        if ( m_stack.top() ) {
                m_writer.writeToken( "}" );
@@ -106,7 +113,7 @@ void post( scene::Node& node ) const {
 }
 };
 
-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 ) );
 }
index e934ef641b5cc02a73a3f6412ad909383e9075a3..ae07784d16b006e5af75755b539695d89e563178 100644 (file)
@@ -24,6 +24,6 @@
 
 #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
diff --git a/plugins/mapxml/CMakeLists.txt b/plugins/mapxml/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a6aae15
--- /dev/null
@@ -0,0 +1,8 @@
+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)
index ff776381e21bbacb46ad57c00022221625046578..516e06be7d2b04828d86dab5a6960548d7cb9e3f 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "plugin.h"
-
 #include "ibrush.h"
 #include "ipatch.h"
 #include "ifiletypes.h"
@@ -50,12 +48,15 @@ MapXMLDependencies() :
        m_patchDef2Doom3Module( "def2doom3" ),
        m_patchDoom3Module( "doom3" ){
 }
+
 BrushCreator& getBrushDoom3(){
        return GlobalBrushModule::getTable();
 }
+
 PatchCreator& getPatchDoom3(){
        return *m_patchDoom3Module.getTable();
 }
+
 PatchCreator& getPatchDef2Doom3(){
        return *m_patchDef2Doom3Module.getTable();
 }
@@ -65,11 +66,13 @@ class MapXMLAPI : public TypeSystemRef, public MapFormat
 {
 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;
 }
@@ -77,7 +80,8 @@ MapFormat* getTable(){
 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 );
 }
 };
@@ -87,7 +91,6 @@ typedef SingletonModule<MapXMLAPI, MapXMLDependencies> MapXMLModule;
 MapXMLModule g_MapXMLModule;
 
 
-
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
        GlobalErrorStream::instance().setOutputStream( server.getErrorStream() );
        GlobalOutputStream::instance().setOutputStream( server.getOutputStream() );
diff --git a/plugins/mapxml/plugin.h b/plugins/mapxml/plugin.h
deleted file mode 100644 (file)
index 443a80e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
index 044adb66ead780b0ea7a3d6e921c969cbf7dabf2..ab2eb1bf7c21ec3c263ca13be9b7f3c3c638845f 100644 (file)
@@ -39,7 +39,7 @@
 #include "generic/object.h"
 
 
-#define PARSE_ERROR "XML PARSE ERROR"
+const char *PARSE_ERROR = "XML PARSE ERROR";
 
 
 inline XMLImporter* Node_getXMLImporter( scene::Node& node ){
diff --git a/plugins/md3model/CMakeLists.txt b/plugins/md3model/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1966759
--- /dev/null
@@ -0,0 +1,14 @@
+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
+        )
index 56a18ddc254e5e435221805a89adfd1563882c9b..e18ef2f6ca68016edf5dccd31f2fda6eb57caaef 100644 (file)
@@ -40,17 +40,16 @@ typedef unsigned char byte;
 
    ========================================================================
  */
-#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
 {
@@ -89,11 +88,11 @@ void istream_read_md2XyzNormal( PointerInputStream& inputStream, md2XyzNormal_t&
        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
 {
index e3db3ae7575ee58b96ec555a170b03fe60cc6143..0b459827144b16da77cb380eba25c97a43426d71 100644 (file)
@@ -32,7 +32,7 @@
 #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];
 
diff --git a/plugins/md3model/md3normals.cpp b/plugins/md3model/md3normals.cpp
deleted file mode 100644 (file)
index 94de3ea..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index 69719051c588e568cbafad6b86edebc8dc41eed1..e1c5de56d23f0ea0e4ec149a6c62115d9a0992b8 100644 (file)
@@ -29,7 +29,7 @@
 
 #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();
index 2f39483902f31af86508e3ac78735f780442d348..db333189d32da66c07d859ef0a01932d4ec0920e 100644 (file)
@@ -34,7 +34,7 @@
 
 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];
 
diff --git a/plugins/md3model/mdlformat.cpp b/plugins/md3model/mdlformat.cpp
deleted file mode 100644 (file)
index 36a64b1..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/plugins/md3model/mdlnormals.cpp b/plugins/md3model/mdlnormals.cpp
deleted file mode 100644 (file)
index cea533d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
diff --git a/plugins/md3model/model.cpp b/plugins/md3model/model.cpp
deleted file mode 100644 (file)
index 74717a5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-   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"
index ee76006494978a9b94b6d24376619ba0820fe527..5f03d73495b83dd278527ca4fa5cf45f77089d4b 100644 (file)
@@ -22,6 +22,7 @@
 #if !defined( INCLUDED_MODEL_H )
 #define INCLUDED_MODEL_H
 
+#include "globaldefs.h"
 #include "cullable.h"
 #include "renderable.h"
 #include "selectable.h"
@@ -180,7 +181,7 @@ void render( RenderStateFlags state ) const {
        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 )
@@ -235,7 +236,7 @@ surfaces_t m_surfaces;
 
 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 )
@@ -345,7 +346,7 @@ Cullable& get( NullType<Cullable>){
 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() );
@@ -396,9 +397,9 @@ ModelInstance( const scene::Path& path, scene::Instance* parent, Model& model )
 ~ModelInstance(){
        destroyRemaps();
 
-       Instance::setTransformChangedCallback( Callback() );
+       Instance::setTransformChangedCallback( Callback<void()>() );
 
-       m_model.m_lightsChanged = Callback();
+       m_model.m_lightsChanged = Callback<void()>();
        GlobalShaderCache().detach( *this );
 }
 
index 95fb54771e561e4003f5a90e74896f9de949610b..58c97677867f3940544cdf122e7ad02acf217a5b 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "plugin.h"
-
 #include "iscenegraph.h"
 #include "irender.h"
 #include "iselection.h"
diff --git a/plugins/md3model/plugin.h b/plugins/md3model/plugin.h
deleted file mode 100644 (file)
index 443a80e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
diff --git a/plugins/model/CMakeLists.txt b/plugins/model/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4a23e28
--- /dev/null
@@ -0,0 +1,7 @@
+radiant_plugin(model
+        model.cpp model.h
+        plugin.cpp
+        )
+
+target_include_directories(model PRIVATE picomodel)
+target_link_libraries(model PRIVATE picomodel)
index defa472aa0fd56503aea26bb1216fab8044062be..5811af6fe1ab30c731b3ff2962c1d41360c33e64 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "model.h"
+#include "globaldefs.h"
 
 #include "picomodel.h"
 
@@ -113,7 +114,7 @@ void render( RenderStateFlags state ) const {
        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(
@@ -322,7 +323,7 @@ surfaces_t m_surfaces;
 
 AABB m_aabb_local;
 public:
-Callback m_lightsChanged;
+Callback<void()> m_lightsChanged;
 
 PicoModel(){
        constructNull();
@@ -471,7 +472,7 @@ Cullable& get( NullType<Cullable>){
 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" );
@@ -523,9 +524,9 @@ PicoModelInstance( const scene::Path& path, scene::Instance* parent, PicoModel&
 ~PicoModelInstance(){
        destroyRemaps();
 
-       Instance::setTransformChangedCallback( Callback() );
+       Instance::setTransformChangedCallback( Callback<void()>() );
 
-       m_picomodel.m_lightsChanged = Callback();
+       m_picomodel.m_lightsChanged = Callback<void()>();
        GlobalShaderCache().detach( *this );
 }
 
index 61e77628530ff65e8118ff2d1836b868d2d64914..d23809a6571a2514675542229a66bb4f78e55af4 100644 (file)
@@ -19,8 +19,6 @@
    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;
diff --git a/plugins/model/plugin.h b/plugins/model/plugin.h
deleted file mode 100644 (file)
index 443a80e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
diff --git a/plugins/sample/CMakeLists.txt b/plugins/sample/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8eeb07b
--- /dev/null
@@ -0,0 +1,3 @@
+radiant_plugin(sample
+        sample.cpp sample.h
+        )
diff --git a/plugins/sample/sample.h b/plugins/sample/sample.h
deleted file mode 100644 (file)
index c6bfe6c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
diff --git a/plugins/shaders/CMakeLists.txt b/plugins/shaders/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b565c0a
--- /dev/null
@@ -0,0 +1,8 @@
+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})
index f7c74fb3fc2168bb5f9374f1f2946325733bb9bc..6a24236dfecf5511742ae5e4ffc093bc9d480ae4 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "plugin.h"
-
 #include "ishaders.h"
 #include "ifilesystem.h"
 #include "itextures.h"
diff --git a/plugins/shaders/plugin.h b/plugins/shaders/plugin.h
deleted file mode 100644 (file)
index 443a80e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
index 44cc0baf200d5c1ddeb96690d285e45ceabbec37..1a27dae307f13ba2533e77671a7119d28b269ed8 100644 (file)
 //
 // 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>
@@ -75,16 +77,22 @@ bool g_enableDefaultShaders = true;
 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 );
 
 
@@ -203,22 +211,10 @@ Image* loadHeightmap( void* environment, const char* name ){
        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;
@@ -268,7 +264,6 @@ bool Tokeniser_parseString( Tokeniser& tokeniser, ShaderString& string ){
 }
 
 
-
 typedef std::list<ShaderVariable> ShaderParameters;
 typedef std::list<ShaderVariable> ShaderArguments;
 
@@ -307,6 +302,7 @@ ShaderTemplate() :
 void IncRef(){
        ++m_refcount;
 }
+
 void DecRef(){
        ASSERT_MESSAGE( m_refcount != 0, "shader reference-count going below zero" );
        if ( --m_refcount == 0 ) {
@@ -321,6 +317,7 @@ std::size_t refcount(){
 const char* getName() const {
        return m_Name.c_str();
 }
+
 void setName( const char* name ){
        m_Name = name;
 }
@@ -328,7 +325,9 @@ void setName( const char* name ){
 // -----------------------------------------
 
 bool parseDoom3( Tokeniser& tokeniser );
+
 bool parseQuake3( Tokeniser& tokeniser );
+
 bool parseTemplate( Tokeniser& tokeniser );
 
 
@@ -357,19 +356,24 @@ MapLayerTemplate( const TextureExpression& texture, const BlendFuncExpression& b
        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;
 };
@@ -695,6 +699,7 @@ public:
 ShaderDefinition( ShaderTemplate* shaderTemplate, const ShaderArguments& args, const char* filename )
        : shaderTemplate( shaderTemplate ), args( args ), filename( filename ){
 }
+
 ShaderTemplate* shaderTemplate;
 ShaderArguments args;
 const char* filename;
@@ -837,7 +842,7 @@ std::size_t m_refcount;
 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;
@@ -871,6 +876,7 @@ CShader( const ShaderDefinition& definition ) :
 
        realise();
 }
+
 virtual ~CShader(){
        unrealise();
 
@@ -881,6 +887,7 @@ virtual ~CShader(){
 void IncRef(){
        ++m_refcount;
 }
+
 void DecRef(){
        ASSERT_MESSAGE( m_refcount != 0, "shader reference-count going below zero" );
        if ( --m_refcount == 0 ) {
@@ -896,48 +903,60 @@ std::size_t refcount(){
 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;
 }
@@ -950,9 +969,7 @@ void realise(){
                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 );
                }
        }
 
@@ -1052,15 +1069,19 @@ MapLayer( qtexture_t* texture, BlendFunc blendFunc, bool clampToBorder, float al
        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;
 }
@@ -1068,11 +1089,11 @@ float alphaTest() const {
 
 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;
@@ -1145,7 +1166,7 @@ void FreeShaders(){
 }
 
 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();
@@ -1355,7 +1376,7 @@ void ParseShaderFile( Tokeniser& tokeniser, const char* filename ){
                                         && !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 ) ) {
                                }
@@ -1370,9 +1391,9 @@ void ParseShaderFile( Tokeniser& tokeniser, const char* filename ){
                                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
@@ -1396,7 +1417,7 @@ void parseGuideFile( Tokeniser& tokeniser, const char* filename ){
                }
 
                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 ) {
@@ -1442,9 +1463,6 @@ void LoadShaderFile( const char* filename ){
        }
 }
 
-typedef FreeCaller1<const char*, LoadShaderFile> LoadShaderFileCaller;
-
-
 void loadGuideFile( const char* filename ){
        StringOutputStream fullname( 256 );
        fullname << "guides/" << filename;
@@ -1466,9 +1484,6 @@ void loadGuideFile( const char* filename ){
        }
 }
 
-typedef FreeCaller1<const char*, loadGuideFile> LoadGuideFileCaller;
-
-
 CShader* Try_Shader_ForName( const char* name ){
        {
                shaders_t::iterator i = g_ActiveShaders.find( name );
@@ -1508,8 +1523,6 @@ IShader *Shader_ForName( const char *name ){
 }
 
 
-
-
 // the list of scripts/*.shader files we need to work with
 // those are listed in shaderlist file
 GSList *l_shaderfiles = 0;
@@ -1543,7 +1556,8 @@ void IfFound_dumpUnreferencedShader( bool& bFound, const char* filename ){
                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;
@@ -1567,9 +1581,6 @@ void ShaderList_addShaderFile( const char* dirstring ){
        }
 }
 
-typedef FreeCaller1<const char*, ShaderList_addShaderFile> AddShaderFileCaller;
-
-
 /*
    ==================
    BuildShaderList
@@ -1624,8 +1635,6 @@ void ShaderList_addFromArchive( const char *archivename ){
        }
 }
 
-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 ){
@@ -1653,7 +1662,7 @@ bool shaderlist_findOrInstall( const char* enginePath, const char* toolsPath, co
 
 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" );
@@ -1675,12 +1684,12 @@ void Shaders_Load(){
                                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;
@@ -1694,7 +1703,7 @@ void Shaders_Load(){
                }
        }
 
-       //StringPool_analyse(ShaderPool::instance());
+       //StringPool_analyse( ShaderPool::instance() );
 }
 
 void Shaders_Free(){
@@ -1709,12 +1718,14 @@ std::size_t g_shaders_unrealised = 1; // wait until filesystem and is realised b
 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();
@@ -1733,9 +1744,11 @@ public:
 void realise(){
        Shaders_Realise();
 }
+
 void unrealise(){
        Shaders_Unrealise();
 }
+
 void refresh(){
        Shaders_Refresh();
 }
@@ -1754,22 +1767,27 @@ void foreachShaderName( const ShaderNameCallback& callback ){
 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 );
 }
@@ -1802,6 +1820,7 @@ ShaderSystem& GetShaderSystem(){
 void Shaders_Construct(){
        GlobalFileSystem().attach( g_Quake3ShaderSystem );
 }
+
 void Shaders_Destroy(){
        GlobalFileSystem().detach( g_Quake3ShaderSystem );
 
diff --git a/plugins/textool/.cvswrappers b/plugins/textool/.cvswrappers
deleted file mode 100644 (file)
index 21e5b0a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-*.dsp  -m 'COPY' -k 'b'
-*.rc   -m 'COPY' -k 'b'
index 4da3fab3b91d203a64daac3745e9e3ffbe170fd9..2e3ef5262c89ae2eb9fa5c72f4ad5a544d82a34d 100644 (file)
@@ -114,26 +114,26 @@ bool C2DView::OnRButtonUp( int x, int y ){
                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 );
diff --git a/plugins/textool/Doc/.cvswrappers b/plugins/textool/Doc/.cvswrappers
deleted file mode 100644 (file)
index 89bb1f8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-*.jpg  -m 'COPY' -k 'b'
diff --git a/plugins/textool/StdAfx.cpp b/plugins/textool/StdAfx.cpp
deleted file mode 100644 (file)
index 7fc0905..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-   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
index a31c0a6d8842bdcc9c80cf1b18c68332d720ccba..2ebd1b012c10209066a116a7a8db9778738bd6ab 100644 (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"
index 50fbf12566a76a120bc00aee0fdcc833ddc1246f..7d5eba90ff55354369f0bac8c9ff4e0e6350d579 100644 (file)
 #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" );
 
@@ -51,104 +50,104 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer
 }
 
 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 )
@@ -643,17 +642,17 @@ static GtkWidget* CreateOpenGLWidget(){
                                                   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;
 }
diff --git a/plugins/vfspk3/CMakeLists.txt b/plugins/vfspk3/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a55e9de
--- /dev/null
@@ -0,0 +1,12 @@
+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)
index a77b07286a96e91ae8bc54ad3c929c0002c3092a..cf2bdeeea792ebbfebf394a706aa5ac18b72300d 100644 (file)
@@ -37,8 +37,6 @@
 #include "archivelib.h"
 #include "fs_path.h"
 
-#include "vfspk3.h"
-
 
 class DirectoryArchive : public Archive
 {
index 893f002bdf66f46351df1b5d3325347aecac9550..1cd50a31bd9cf7ed852e6a9f2a7477d0c4ee38da 100644 (file)
@@ -42,6 +42,7 @@
 //
 
 #include "vfs.h"
+#include "globaldefs.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -59,11 +60,12 @@ ArchiveModules& FileSystemQ3API_getArchiveModules();
 #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
 
@@ -84,6 +86,7 @@ struct archive_entry_t
 };
 
 #include <list>
+#include <map>
 
 typedef std::list<archive_entry_t> archives_t;
 
@@ -125,14 +128,13 @@ static void FixDOSName( char *src ){
        }
 }
 
-
-
 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 ) {
@@ -143,7 +145,11 @@ static void InitPakFile( ArchiveModules& archiveModules, const char *filename ){
                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 ){
@@ -276,6 +282,168 @@ bool operator()( const CopiedString& self, const CopiedString& other ) const {
 
 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
 
@@ -337,15 +505,23 @@ void InitDirectory( const char* directory, ArchiveModules& archiveModules ){
        }
 
        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();
 
@@ -359,8 +535,6 @@ void InitDirectory( const char* directory, ArchiveModules& archiveModules ){
                                }
                        }
 
-                       Archives archives;
-                       Archives archivesOverride;
                        for (;; )
                        {
                                const char* name = g_dir_read_name( dir );
@@ -381,27 +555,31 @@ void InitDirectory( const char* directory, ArchiveModules& archiveModules ){
                                }
 
                                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;
                                }
 
@@ -410,7 +588,14 @@ void InitDirectory( const char* directory, ArchiveModules& archiveModules ){
                                        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;
                                }
 
@@ -420,19 +605,42 @@ void InitDirectory( const char* directory, ArchiveModules& archiveModules ){
                        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
@@ -454,10 +662,13 @@ void Shutdown(){
 
        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;
@@ -473,8 +684,8 @@ int GetFileCount( const char *filename, int flag ){
 
        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;
                        }
@@ -587,9 +798,48 @@ void initDirectory( const char *path ){
        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";
@@ -692,14 +942,15 @@ void forEachArchive( const ArchiveNameCallback& callback, bool pakonly, bool rev
 }
 };
 
+
 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(){
 }
index 478ce8f1a15cfef9ad265d2d2acc53add54548b8..55b273ec0ad11ab29f8ddc74ebb5c158736c2f8d 100644 (file)
@@ -19,8 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "vfspk3.h"
-
 #include "qerplugin.h"
 #include "iarchive.h"
 #include "ifilesystem.h"
diff --git a/plugins/vfspk3/vfspk3.h b/plugins/vfspk3/vfspk3.h
deleted file mode 100644 (file)
index f5fb5c0..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6f0a250
--- /dev/null
@@ -0,0 +1,135 @@
+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)
index fe42687cc640d12bb2e877cea69c4f669074407e..9921d4be4d9cd100e6b109cabab3b87fc3345f0c 100644 (file)
@@ -19,7 +19,9 @@
    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"
@@ -35,7 +37,7 @@
 #include "preferences.h"
 
 
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
 #define PATH_MAX 260
 #endif
 
@@ -91,7 +93,7 @@ void Map_Snapshot(){
        {
                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() );
        }
 }
 /*
@@ -174,8 +176,8 @@ void QE_CheckAutoSave( void ){
 }
 
 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 );
 }
@@ -184,7 +186,7 @@ void Autosave_constructPage( PreferenceGroup& group ){
        Autosave_constructPreferences( page );
 }
 void Autosave_registerPreferencesPage(){
-       PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Autosave_constructPage>() );
+       PreferencesDialog_addSettingsPage(makeCallbackF(Autosave_constructPage));
 }
 
 
@@ -192,9 +194,9 @@ void Autosave_registerPreferencesPage(){
 #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();
 }
index 5504f954a5531a76005f844128e457a8e424e414..298b161bd549c37b2cc71d6289a2ed14493cbdf0 100644 (file)
@@ -102,7 +102,6 @@ inline void print_3x3( const Matrix4& m ){
 }
 
 
-
 inline bool texdef_sane( const texdef_t& texdef ){
        return fabs( texdef.shift[0] ) < ( 1 << 16 )
                   && fabs( texdef.shift[1] ) < ( 1 << 16 );
@@ -308,23 +307,8 @@ class FaceShaderObserver
 {
 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;
@@ -335,12 +319,14 @@ class ContentsFlagsValue
 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;
@@ -395,9 +381,11 @@ FaceShader( const char* shader, const ContentsFlagsValue& flags = ContentsFlagsV
        m_realised( false ){
        captureShader();
 }
+
 ~FaceShader(){
        releaseShader();
 }
+
 // copy-construction not supported
 FaceShader( const FaceShader& other );
 
@@ -405,6 +393,7 @@ void instanceAttach(){
        m_instanced = true;
        m_state->incrementUsed();
 }
+
 void instanceDetach(){
        m_state->decrementUsed();
        m_instanced = false;
@@ -416,6 +405,7 @@ void captureShader(){
        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 );
@@ -426,11 +416,16 @@ void releaseShader(){
 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;
 }
 
@@ -462,6 +457,7 @@ void setShader( const char* name ){
                m_state->incrementUsed();
        }
 }
+
 ContentsFlagsValue getFlags() const {
        ASSERT_MESSAGE( m_realised, "FaceShader::getFlags: flags not valid when unrealised" );
        if ( !m_flags.m_specified ) {
@@ -474,6 +470,7 @@ ContentsFlagsValue getFlags() const {
        }
        return m_flags;
 }
+
 void setFlags( const ContentsFlagsValue& flags ){
        ASSERT_MESSAGE( m_realised, "FaceShader::setFlags: flags not valid when unrealised" );
        ContentsFlagsValue_assignMasked( m_flags, flags );
@@ -489,12 +486,14 @@ std::size_t width() const {
        }
        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();
@@ -504,14 +503,14 @@ unsigned int shaderFlags() const {
 };
 
 
-
-
 class FaceTexdef : public FaceShaderObserver
 {
 // not copyable
 FaceTexdef( const FaceTexdef& other );
+
 // not assignable
 FaceTexdef& operator=( const FaceTexdef& other );
+
 public:
 class SavedState
 {
@@ -543,6 +542,7 @@ FaceTexdef(
        m_scaleApplied( false ){
        m_shader.attach( *this );
 }
+
 ~FaceTexdef(){
        m_shader.detach( *this );
 }
@@ -552,6 +552,7 @@ void addScale(){
        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;
@@ -563,6 +564,7 @@ void realiseShader(){
                addScale();
        }
 }
+
 void unrealiseShader(){
        if ( m_projectionInitialised && m_scaleApplied ) {
                removeScale();
@@ -621,6 +623,7 @@ TextureProjection normalised() const {
        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 );
@@ -691,6 +694,7 @@ void exportState( FacePlane& facePlane ) const {
 
 FacePlane() : m_funcStaticOrigin( 0, 0, 0 ){
 }
+
 FacePlane( const FacePlane& other ) : m_funcStaticOrigin( 0, 0, 0 ){
        if ( !isDoom3Plane() ) {
                planepts_assign( m_planepts, other.m_planepts );
@@ -727,6 +731,7 @@ void reverse(){
                updateSource();
        }
 }
+
 void transform( const Matrix4& matrix, bool mirror ){
        if ( !isDoom3Plane() ) {
 
@@ -757,6 +762,7 @@ void transform( const Matrix4& matrix, bool mirror ){
                updateSource();
        }
 }
+
 void offset( float offset ){
        if ( !isDoom3Plane() ) {
                Vector3 move( vector3_scaled( m_planeCached.normal(), -offset ) );
@@ -777,6 +783,7 @@ void offset( float offset ){
 void updateTranslated(){
        m_planeCached = Plane3_applyTranslation( m_plane, m_funcStaticOrigin );
 }
+
 void updateSource(){
        m_plane = Plane3_applyTranslation( m_planeCached, vector3_negated( m_funcStaticOrigin ) );
 }
@@ -785,16 +792,20 @@ void updateSource(){
 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;
 }
@@ -810,6 +821,7 @@ void copy( const FacePlane& other ){
                updateSource();
        }
 }
+
 void copy( const Vector3& p0, const Vector3& p1, const Vector3& p2 ){
        if ( !isDoom3Plane() ) {
                m_planepts[0] = p0;
@@ -850,9 +862,11 @@ virtual bool filter( const Face& face ) const = 0;
 };
 
 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();
 
 
@@ -862,8 +876,11 @@ class FaceObserver
 {
 public:
 virtual void planeChanged() = 0;
+
 virtual void connectivityChanged() = 0;
+
 virtual void shaderChanged() = 0;
+
 virtual void evaluateTransform() = 0;
 };
 
@@ -919,6 +936,7 @@ MapFile* m_map;
 
 // assignment not supported
 Face& operator=( const Face& other );
+
 // copy-construction not supported
 Face( const Face& other );
 
@@ -937,6 +955,7 @@ Face( FaceObserver* observer ) :
        m_texdef.setBasis( m_plane.plane3().normal() );
        planeChanged();
 }
+
 Face(
        const Vector3& p0,
        const Vector3& p1,
@@ -957,6 +976,7 @@ Face(
        planeChanged();
        updateFiltered();
 }
+
 Face( const Face& other, FaceObserver* observer ) :
        m_refcount( 0 ),
        m_shader( other.m_shader.getShader(), other.m_shader.m_flags ),
@@ -971,6 +991,7 @@ Face( const Face& other, FaceObserver* observer ) :
        planeChanged();
        updateFiltered();
 }
+
 ~Face(){
        m_shader.detach( *this );
 }
@@ -983,6 +1004,7 @@ void planeChanged(){
 void realiseShader(){
        m_observer->shaderChanged();
 }
+
 void unrealiseShader(){
 }
 
@@ -1007,6 +1029,7 @@ void render( RenderStateFlags state ) const {
 void updateFiltered(){
        m_filtered = face_filtered( *this );
 }
+
 bool isFiltered() const {
        return m_filtered;
 }
@@ -1024,6 +1047,7 @@ void undoSave(){
 UndoMemento* exportState() const {
        return new SavedState( *this );
 }
+
 void importState( const UndoMemento* data ){
        undoSave();
 
@@ -1039,6 +1063,7 @@ void importState( const UndoMemento* data ){
 void IncRef(){
        ++m_refcount;
 }
+
 void DecRef(){
        if ( --m_refcount == 0 ) {
                delete this;
@@ -1087,6 +1112,7 @@ void revertTransform(){
        planepts_assign( m_move_planeptsTransformed, m_move_planepts );
        m_texdefTransformed = m_texdef.m_projection;
 }
+
 void freezeTransform(){
        undoSave();
        m_plane = m_planeTransformed;
@@ -1149,6 +1175,7 @@ void shaderChanged(){
 const char* GetShader() const {
        return m_shader.getShader();
 }
+
 void SetShader( const char* name ){
        undoSave();
        m_shader.setShader( name );
@@ -1158,6 +1185,7 @@ void SetShader( const char* name ){
 void revertTexdef(){
        m_texdefTransformed = m_texdef.m_projection;
 }
+
 void texdefChanged(){
        revertTexdef();
        EmitTextureCoordinates();
@@ -1167,6 +1195,7 @@ void texdefChanged(){
 void GetTexdef( TextureProjection& projection ) const {
        projection = m_texdef.normalised();
 }
+
 void SetTexdef( const TextureProjection& projection ){
        undoSave();
        m_texdef.setTexdef( projection );
@@ -1176,6 +1205,7 @@ void SetTexdef( const TextureProjection& projection ){
 void GetFlags( ContentsFlagsValue& flags ) const {
        flags = m_shader.getFlags();
 }
+
 void SetFlags( const ContentsFlagsValue& flags ){
        undoSave();
        m_shader.setFlags( flags );
@@ -1235,6 +1265,7 @@ void construct_centroid(){
 const Winding& getWinding() const {
        return m_winding;
 }
+
 Winding& getWinding(){
        return m_winding;
 }
@@ -1243,21 +1274,27 @@ const Plane3& plane3() const {
        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;
 }
@@ -1265,6 +1302,7 @@ const FaceShader& getShader() const {
 bool isDetail() const {
        return ( m_shader.m_flags.m_contentFlags & BRUSH_DETAIL_MASK ) != 0;
 }
+
 void setDetail( bool detail ){
        undoSave();
        if ( detail && !isDetail() ) {
@@ -1279,6 +1317,7 @@ void setDetail( bool detail ){
 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 )
        {
@@ -1304,6 +1343,7 @@ FaceVertexId( std::size_t face, std::size_t vertex )
 std::size_t getFace() const {
        return m_face;
 }
+
 std::size_t getVertex() const {
        return m_vertex;
 }
@@ -1319,6 +1359,7 @@ struct EdgeRenderIndices
        EdgeRenderIndices()
                : first( 0 ), second( 0 ){
        }
+
        EdgeRenderIndices( const RenderIndex _first, const RenderIndex _second )
                : first( _first ), second( _second ){
        }
@@ -1332,6 +1373,7 @@ struct EdgeFaces
        EdgeFaces()
                : first( c_brush_maxFaces ), second( c_brush_maxFaces ){
        }
+
        EdgeFaces( const faceIndex_t _first, const faceIndex_t _second )
                : first( _first ), second( _second ){
        }
@@ -1362,6 +1404,7 @@ const PointVertex* m_vertices;
 };
 
 class Brush;
+
 typedef std::vector<Brush*> brush_vector_t;
 
 class BrushFilter
@@ -1371,6 +1414,7 @@ virtual bool filter( const Brush& brush ) const = 0;
 };
 
 bool brush_filtered( Brush& brush );
+
 void add_brush_filter( BrushFilter& filter, int mask, bool invert = false );
 
 
@@ -1422,6 +1466,7 @@ FaceVertexId m_faceVertex;
 SelectableEdge( Faces& faces, FaceVertexId faceVertex )
        : m_faces( faces ), m_faceVertex( faceVertex ){
 }
+
 SelectableEdge& operator=( const SelectableEdge& other ){
        m_faceVertex = other.m_faceVertex;
        return *this;
@@ -1449,6 +1494,7 @@ FaceVertexId m_faceVertex;
 SelectableVertex( Faces& faces, FaceVertexId faceVertex )
        : m_faces( faces ), m_faceVertex( faceVertex ){
 }
+
 SelectableVertex& operator=( const SelectableVertex& other ){
        m_faceVertex = other.m_faceVertex;
        return *this;
@@ -1467,16 +1513,23 @@ class BrushObserver
 {
 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;
@@ -1530,8 +1583,8 @@ Array<EdgeFaces> m_edge_faces;
 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
@@ -1540,7 +1593,7 @@ 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;
@@ -1549,7 +1602,7 @@ 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 ),
@@ -1562,7 +1615,7 @@ Brush( scene::Node& node, const Callback& evaluateTransform, const Callback& bou
        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 ),
@@ -1575,6 +1628,7 @@ Brush( const Brush& other, scene::Node& node, const Callback& evaluateTransform,
        m_transformChanged( false ){
        copy( other );
 }
+
 Brush( const Brush& other ) :
        TransformNode( other ),
        Bounded( other ),
@@ -1595,6 +1649,7 @@ Brush( const Brush& other ) :
        m_transformChanged( false ){
        copy( other );
 }
+
 ~Brush(){
        ASSERT_MESSAGE( m_observers.empty(), "Brush::~Brush: observers still attached" );
 }
@@ -1631,6 +1686,7 @@ void attach( BrushObserver& observer ){
 
        m_observers.insert( &observer );
 }
+
 void detach( BrushObserver& observer ){
        m_observers.erase( &observer );
 }
@@ -1648,6 +1704,7 @@ void forEachFace_instanceAttach( MapFile* map ) const {
                ( *i )->instanceAttach( map );
        }
 }
+
 void forEachFace_instanceDetach( MapFile* map ) const {
        for ( Faces::const_iterator i = m_faces.begin(); i != m_faces.end(); ++i )
        {
@@ -1656,6 +1713,7 @@ void forEachFace_instanceDetach( MapFile* map ) const {
 }
 
 InstanceCounter m_instanceCounter;
+
 void instanceAttach( const scene::Path& path ){
        if ( ++m_instanceCounter.m_count == 1 ) {
                m_map = path_find_mapfile( path.begin(), path.end() );
@@ -1668,6 +1726,7 @@ void instanceAttach( const scene::Path& path ){
                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 );
@@ -1682,8 +1741,10 @@ void instanceDetach( const scene::Path& path ){
 const char* name() const {
        return "brush";
 }
+
 void attach( const NameCallback& callback ){
 }
+
 void detach( const NameCallback& callback ){
 }
 
@@ -1706,6 +1767,7 @@ void planeChanged(){
        aabbChanged();
        m_lightsChanged();
 }
+
 void shaderChanged(){
        updateFiltered();
        planeChanged();
@@ -1722,7 +1784,8 @@ void transformChanged(){
        m_transformChanged = true;
        planeChanged();
 }
-typedef MemberCaller<Brush, &Brush::transformChanged> TransformChangedCaller;
+
+typedef MemberCaller<Brush, void(), &Brush::transformChanged> TransformChangedCaller;
 
 void evaluateTransform(){
        if ( m_transformChanged ) {
@@ -1731,12 +1794,15 @@ void evaluateTransform(){
                m_evaluateTransform();
        }
 }
+
 const Matrix4& localToParent() const {
        return g_matrix4_identity;
 }
+
 void aabbChanged(){
        m_boundsChanged();
 }
+
 const AABB& localAABB() const {
        evaluateBRep();
        return m_aabb_local;
@@ -1771,18 +1837,21 @@ void transform( const Matrix4& matrix ){
                ( *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 )
        {
@@ -1814,6 +1883,7 @@ class BrushUndoMemento : public UndoMemento
 public:
 BrushUndoMemento( const Faces& faces ) : m_faces( faces ){
 }
+
 void release(){
        delete this;
 }
@@ -1892,6 +1962,7 @@ static void constructStatic( EBrushType type ){
 
        m_state_point = GlobalShaderCache().capture( "$POINT" );
 }
+
 static void destroyStatic(){
        GlobalShaderCache().release( "$POINT" );
 }
@@ -1905,6 +1976,7 @@ typedef Faces::const_iterator const_iterator;
 const_iterator begin() const {
        return m_faces.begin();
 }
+
 const_iterator end() const {
        return m_faces.end();
 }
@@ -1912,9 +1984,11 @@ const_iterator end() const {
 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 )
@@ -1922,6 +1996,7 @@ void reserve( std::size_t count ){
                ( *i )->reserve( count );
        }
 }
+
 void push_back( Faces::value_type face ){
        m_faces.push_back( face );
        if ( m_instanceCounter.m_count != 0 ) {
@@ -1933,6 +2008,7 @@ void push_back( Faces::value_type face ){
                ( *i )->DEBUG_verify();
        }
 }
+
 void pop_back(){
        if ( m_instanceCounter.m_count != 0 ) {
                m_faces.back()->instanceDetach( m_map );
@@ -1944,6 +2020,7 @@ void pop_back(){
                ( *i )->DEBUG_verify();
        }
 }
+
 void erase( std::size_t index ){
        if ( m_instanceCounter.m_count != 0 ) {
                m_faces[index]->instanceDetach( m_map );
@@ -1955,6 +2032,7 @@ void erase( std::size_t index ){
                ( *i )->DEBUG_verify();
        }
 }
+
 void connectivityChanged(){
        for ( Observers::iterator i = m_observers.begin(); i != m_observers.end(); ++i )
        {
@@ -1975,9 +2053,11 @@ void clear(){
                ( *i )->DEBUG_verify();
        }
 }
+
 std::size_t size() const {
        return m_faces.size();
 }
+
 bool empty() const {
        return m_faces.empty();
 }
@@ -2125,6 +2205,7 @@ void edge_push_back( FaceVertexId faceVertex ){
                ( *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 )
@@ -2132,6 +2213,7 @@ void edge_clear(){
                ( *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 )
@@ -2139,6 +2221,7 @@ void vertex_push_back( FaceVertexId faceVertex ){
                ( *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 )
@@ -2345,7 +2428,6 @@ void buildBRep();
 };
 
 
-
 class FaceInstance;
 
 class FaceInstanceSet
@@ -2356,6 +2438,7 @@ public:
 void insert( FaceInstance& faceInstance ){
        m_faceInstances.append( faceInstance );
 }
+
 void erase( FaceInstance& faceInstance ){
        m_faceInstances.erase( faceInstance );
 }
@@ -2371,6 +2454,7 @@ void foreach( Functor functor ){
 bool empty() const {
        return m_faceInstances.empty();
 }
+
 FaceInstance& last() const {
        return m_faceInstances.back();
 }
@@ -2396,6 +2480,7 @@ inline VertexSelection::iterator VertexSelection_insert( VertexSelection& self,
        }
        return i;
 }
+
 inline void VertexSelection_erase( VertexSelection& self, std::size_t value ){
        VertexSelection::iterator i = VertexSelection_find( self, value );
        if ( i != self.end() ) {
@@ -2406,10 +2491,12 @@ inline void VertexSelection_erase( VertexSelection& self, std::size_t value ){
 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;
@@ -2427,13 +2514,17 @@ public:
 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 )
        {
@@ -2463,6 +2554,7 @@ FaceInstance( Face& face, const SelectionChangeCallback& observer ) :
        m_selectableEdges( observer ),
        m_selectionChanged( observer ){
 }
+
 FaceInstance( const FaceInstance& other ) :
        m_face( other.m_face ),
        m_selectable( SelectedChangedCaller( *this ) ),
@@ -2470,6 +2562,7 @@ FaceInstance( const FaceInstance& other ) :
        m_selectableEdges( other.m_selectableEdges ),
        m_selectionChanged( other.m_selectionChanged ){
 }
+
 FaceInstance& operator=( const FaceInstance& other ){
        m_face = other.m_face;
        return *this;
@@ -2478,6 +2571,7 @@ FaceInstance& operator=( const FaceInstance& other ){
 Face& getFace(){
        return *m_face;
 }
+
 const Face& getFace() const {
        return *m_face;
 }
@@ -2492,14 +2586,17 @@ void selectedChanged( const Selectable& selectable ){
        }
        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();
 }
@@ -2507,6 +2604,7 @@ bool isSelected() const {
 bool selectedComponents() const {
        return selectedVertices() || selectedEdges() || isSelected();
 }
+
 bool selectedComponents( SelectionSystem::EComponentMode mode ) const {
        switch ( mode )
        {
@@ -2520,6 +2618,7 @@ bool selectedComponents( SelectionSystem::EComponentMode mode ) const {
                return false;
        }
 }
+
 void setSelected( SelectionSystem::EComponentMode mode, bool select ){
        switch ( mode )
        {
@@ -2553,6 +2652,7 @@ void SelectedVertices_foreach( Functor functor ) const {
                }
        }
 }
+
 template<typename Functor>
 void SelectedEdges_foreach( Functor functor ) const {
        for ( VertexSelection::const_iterator i = m_edgeSelection.begin(); i != m_edgeSelection.end(); ++i )
@@ -2565,6 +2665,7 @@ void SelectedEdges_foreach( Functor functor ) const {
                }
        }
 }
+
 template<typename Functor>
 void SelectedFaces_foreach( Functor functor ) const {
        if ( isSelected() ) {
@@ -2580,23 +2681,16 @@ void SelectedComponents_foreach( Functor functor ) const {
 }
 
 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 {
@@ -2619,6 +2713,7 @@ void testSelect( SelectionTest& test, SelectionIntersection& best ){
                m_face->testSelect( test, best );
        }
 }
+
 void testSelect( Selector& selector, SelectionTest& test ){
        SelectionIntersection best;
        testSelect( test, best );
@@ -2626,6 +2721,7 @@ void testSelect( Selector& selector, SelectionTest& test ){
                Selector_add( selector, m_selectable, best );
        }
 }
+
 void testSelect_centroid( Selector& selector, SelectionTest& test ){
        if ( m_face->contributes() && !m_face->isFiltered() ) {
                SelectionIntersection best;
@@ -2650,6 +2746,7 @@ void selectPlane( Selector& selector, const Line& line, PlanesIterator first, Pl
 
        selectedPlaneCallback( getFace().plane3() );
 }
+
 void selectReversedPlane( Selector& selector, const SelectedPlanes& selectedPlanes ){
        if ( selectedPlanes.contains( plane3_flipped( getFace().plane3() ) ) ) {
                Selector_add( selector, m_selectable );
@@ -2717,9 +2814,11 @@ void snapComponents( float snap ){
                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" );
@@ -2747,6 +2846,7 @@ void update_move_planepts_vertex2( std::size_t index, std::size_t other ){
        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 );
@@ -2773,6 +2873,7 @@ void update_selection_vertex(){
                }
        }
 }
+
 void select_vertex( std::size_t index, bool select ){
        if ( select ) {
                VertexSelection_insert( m_vertexSelection, getFace().getWinding()[index].adjacent );
@@ -2801,6 +2902,7 @@ void update_move_planepts_edge( std::size_t index ){
        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 );
@@ -2818,6 +2920,7 @@ void update_selection_edge(){
                }
        }
 }
+
 void select_edge( std::size_t index, bool select ){
        if ( select ) {
                VertexSelection_insert( m_edgeSelection, getFace().getWinding()[index].adjacent );
@@ -2858,6 +2961,7 @@ public:
 static void constructStatic(){
        m_state = GlobalShaderCache().capture( "$CLIPPER_OVERLAY" );
 }
+
 static void destroyStatic(){
        GlobalShaderCache().release( "$CLIPPER_OVERLAY" );
 }
@@ -2909,7 +3013,6 @@ inline void Face_addLight( const FaceInstance& face, const Matrix4& localToWorld
 }
 
 
-
 typedef std::vector<FaceInstance> FaceInstances;
 
 class EdgeInstance : public Selectable
@@ -2923,6 +3026,7 @@ void select_edge( bool select ){
        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() ) ) {
@@ -2948,6 +3052,7 @@ EdgeInstance& operator=( const EdgeInstance& other ){
 void setSelected( bool select ){
        select_edge( select );
 }
+
 bool isSelected() const {
        return selected_edge();
 }
@@ -2976,6 +3081,7 @@ void select_vertex( bool select ){
        }
        while ( faceVertex.getFace() != m_vertex->m_faceVertex.getFace() );
 }
+
 bool selected_vertex() const {
        FaceVertexId faceVertex = m_vertex->m_faceVertex;
        do
@@ -3001,6 +3107,7 @@ VertexInstance& operator=( const VertexInstance& other ){
 void setSelected( bool select ){
        select_vertex( select );
 }
+
 bool isSelected() const {
        return selected_vertex();
 }
@@ -3049,6 +3156,7 @@ TypeCasts(){
        InstanceIdentityCast<BrushInstance>::install( m_casts );
        InstanceContainedCast<BrushInstance, Transformable>::install( m_casts );
 }
+
 InstanceTypeCastTable& get(){
        return m_casts;
 }
@@ -3091,7 +3199,8 @@ typedef LazyStatic<TypeCasts> StaticTypeCasts;
 void lightsChanged(){
        m_lightList->lightsChanged();
 }
-typedef MemberCaller<BrushInstance, &BrushInstance::lightsChanged> LightsChangedCaller;
+
+typedef MemberCaller<BrushInstance, void(), &BrushInstance::lightsChanged> LightsChangedCaller;
 
 STRING_CONSTANT( Name, "BrushInstance" );
 
@@ -3112,10 +3221,11 @@ BrushInstance( const scene::Path& path, scene::Instance* parent, Brush& brush )
 
        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();
@@ -3133,9 +3243,11 @@ const Brush& getBrush() const {
 Bounded& get( NullType<Bounded>){
        return m_brush;
 }
+
 Cullable& get( NullType<Cullable>){
        return m_brush;
 }
+
 Transformable& get( NullType<Transformable>){
        return m_transform;
 }
@@ -3146,13 +3258,13 @@ void selectedChanged( const Selectable& selectable ){
 
        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 )
@@ -3165,6 +3277,7 @@ const BrushInstanceVisitor& forEachFaceInstance( const BrushInstanceVisitor& vis
 static void constructStatic(){
        m_state_selpoint = GlobalShaderCache().capture( "$SELPOINT" );
 }
+
 static void destroyStatic(){
        GlobalShaderCache().release( "$SELPOINT" );
 }
@@ -3172,6 +3285,7 @@ static void destroyStatic(){
 void clear(){
        m_faceInstances.clear();
 }
+
 void reserve( std::size_t size ){
        m_faceInstances.reserve( size );
 }
@@ -3179,14 +3293,17 @@ void reserve( std::size_t 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 )
        {
@@ -3197,6 +3314,7 @@ void connectivityChanged(){
 void edge_clear(){
        m_edgeInstances.clear();
 }
+
 void edge_push_back( SelectableEdge& edge ){
        m_edgeInstances.push_back( EdgeInstance( m_faceInstances, edge ) );
 }
@@ -3204,6 +3322,7 @@ void edge_push_back( SelectableEdge& edge ){
 void vertex_clear(){
        m_vertexInstances.clear();
 }
+
 void vertex_push_back( SelectableVertex& vertex ){
        m_vertexInstances.push_back( VertexInstance( m_faceInstances, vertex ) );
 }
@@ -3215,6 +3334,7 @@ void DEBUG_verify() const {
 bool isSelected() const {
        return m_selectable.isSelected();
 }
+
 void setSelected( bool select ){
        m_selectable.setSelected( select );
 }
@@ -3366,12 +3486,14 @@ bool isSelectedComponents() const {
        }
        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() );
 
@@ -3431,6 +3553,7 @@ void selectPlanes( Selector& selector, SelectionTest& test, const PlaneCallback&
                ( *i ).selectPlane( selector, Line( test.getNear(), test.getFar() ), brushPlanes, j, selectedPlaneCallback );
        }
 }
+
 void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPlanes ){
        for ( FaceInstances::iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i )
        {
@@ -3445,6 +3568,7 @@ void transformComponents( const Matrix4& matrix ){
                ( *i ).transformComponents( matrix );
        }
 }
+
 const AABB& getSelectedComponentsBounds() const {
        m_aabb_component = AABB();
 
@@ -3462,6 +3586,7 @@ void snapComponents( float snap ){
                ( *i ).snapComponents( snap );
        }
 }
+
 void evaluateTransform(){
        Matrix4 matrix( m_transform.calculateTransform() );
        //globalOutputStream() << "matrix: " << matrix << "\n";
@@ -3474,12 +3599,14 @@ void evaluateTransform(){
                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 );
@@ -3488,6 +3615,7 @@ void setClipPlane( const Plane3& 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 )
@@ -3495,6 +3623,7 @@ void insertLight( const RendererLight& light ){
                Face_addLight( *i, localToWorld, light );
        }
 }
+
 void clearLights(){
        for ( FaceInstances::const_iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i )
        {
@@ -3515,6 +3644,7 @@ const Functor& m_functor;
 public:
 BrushSelectedVisitor( const Functor& functor ) : m_functor( functor ){
 }
+
 void visit( scene::Instance& instance ) const {
        BrushInstance* brush = Instance_getBrush( instance );
        if ( brush != 0 ) {
@@ -3536,6 +3666,7 @@ const Functor& m_functor;
 public:
 BrushVisibleSelectedVisitor( const Functor& functor ) : m_functor( functor ){
 }
+
 void visit( scene::Instance& instance ) const {
        BrushInstance* brush = Instance_getBrush( instance );
        if ( brush != 0
@@ -3557,6 +3688,7 @@ const BrushInstanceVisitor& m_visitor;
 public:
 BrushForEachFace( const BrushInstanceVisitor& visitor ) : m_visitor( visitor ){
 }
+
 void operator()( BrushInstance& brush ) const {
        brush.forEachFaceInstance( m_visitor );
 }
@@ -3570,6 +3702,7 @@ public:
 FaceInstanceVisitFace( const Functor& functor )
        : functor( functor ){
 }
+
 void visit( FaceInstance& face ) const {
        functor( face.getFace() );
 }
@@ -3589,6 +3722,7 @@ public:
 FaceVisitAll( const Functor& functor )
        : functor( functor ){
 }
+
 void visit( Face& face ) const {
        functor( face );
 }
@@ -3614,6 +3748,7 @@ public:
 FaceInstanceVisitAll( const Functor& functor )
        : functor( functor ){
 }
+
 void visit( FaceInstance& face ) const {
        functor( face );
 }
@@ -3637,6 +3772,7 @@ class InstanceIfVisible : public Functor
 public:
 InstanceIfVisible( const Functor& functor ) : Functor( functor ){
 }
+
 void operator()( scene::Instance& instance ){
        if ( instance.path().top().get().visible() ) {
                Functor::operator()( instance );
@@ -3651,6 +3787,7 @@ const Functor& m_functor;
 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 );
index 85ee1e46ebbb95de2502733ad8aad23efba94ae8..872dfafb5e6bba9bb66c6b14acebb06c443f1c34 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "brush_primit.h"
+#include "globaldefs.h"
 
 #include "debugging/debugging.h"
 
@@ -397,11 +398,11 @@ inline BasicVector3<Element> vector3_inverse( const BasicVector3<Element>& self
 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
 
@@ -1317,7 +1318,7 @@ inline Matrix4 matrix4_reflection_for_plane45( const Plane3& plane, const Vector
        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 );
        }
@@ -1335,8 +1336,6 @@ inline Matrix4 matrix4_reflection_for_plane45( const Plane3& plane, const Vector
 
        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 );
index 0502e988ec77d7041bbe14902161e6bdb0429c15..f90b0a4c64c5f9fe9f7aa7c2ae2aa5991fb8ef35 100644 (file)
@@ -36,6 +36,7 @@
 #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 } };
@@ -404,146 +405,96 @@ void ConstructRegionBrushes( scene::Node* brushes[6], const Vector3& region_mins
 }
 
 
-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_projection;
-public:
-FaceSetFlags( const ContentsFlagsValue& flags ) : m_projection( flags ){
-}
-void operator()( Face& face ) const {
-       face.SetFlags( m_projection );
-}
-};
-
 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();
 }
 
@@ -555,55 +506,37 @@ bool Face_FindReplaceShader( Face& face, const char* find, const char* replace )
        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);
+               });
        }
 }
 
@@ -615,22 +548,13 @@ void Scene_BrushFindReplaceShader_Component_Selected( scene::Graph& graph, const
        }
        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 );
-}
-};
-
 class FaceFitTextureW
 {
 float m_s_repeat, m_t_repeat;
@@ -654,12 +578,16 @@ void operator()( Face& face ) const {
 };
 
 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();
 }
 
@@ -684,6 +612,7 @@ void Scene_BrushFitTexture_Component_SelectedH( scene::Graph& graph, float s_rep
 }
 
 TextureProjection g_defaultTextureProjection;
+
 const TextureProjection& TextureTransform_getDefault(){
        TexDef_Construct_Default( g_defaultTextureProjection );
        return g_defaultTextureProjection;
@@ -731,6 +660,7 @@ public:
 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() );
@@ -746,44 +676,23 @@ void Scene_BrushSelectByShader( scene::Graph& graph, const char* name ){
        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 ){
@@ -807,29 +716,18 @@ void Scene_BrushGetShaderSize_Component_Selected( scene::Graph& graph, size_t& w
 }
 
 
-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
@@ -849,28 +747,18 @@ void Scene_BrushGetFlags_Component_Selected( scene::Graph& graph, ContentsFlagsV
 }
 
 
-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
@@ -897,6 +785,7 @@ const char* m_shader;
 public:
 filter_face_shader( const char* shader ) : m_shader( shader ){
 }
+
 bool filter( const Face& face ) const {
        return shader_equal( face.GetShader(), m_shader );
 }
@@ -908,6 +797,7 @@ const char* m_prefix;
 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 ) );
 }
@@ -919,6 +809,7 @@ int m_flags;
 public:
 filter_face_flags( int flags ) : m_flags( flags ){
 }
+
 bool filter( const Face& face ) const {
        return ( face.getShader().shaderFlags() & m_flags ) != 0;
 }
@@ -930,6 +821,7 @@ int m_contents;
 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;
 }
@@ -937,49 +829,24 @@ bool filter( const Face& face ) const {
 
 
 
-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;
@@ -987,8 +854,12 @@ public:
 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;
 }
 };
@@ -1310,10 +1181,12 @@ public:
 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;
 };
 
 
@@ -1345,10 +1218,12 @@ public:
 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 );
@@ -1358,9 +1233,13 @@ BrushPrefab g_brushrock( eBrushRock );
 
 
 void FlipClip();
+
 void SplitClip();
+
 void Clip();
+
 void OnClipMode( bool enable );
+
 bool ClipMode();
 
 
@@ -1383,8 +1262,8 @@ void FlipClipper(){
 }
 
 
-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(){
@@ -1394,11 +1273,8 @@ 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 ) );
@@ -1413,32 +1289,33 @@ void Brush_registerCommands(){
        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, "Make _Hollow", "CSGHollow" );
+               create_menu_item_with_mnemonic( menu_in_menu, "Make _Room", "CSGRoom" );
                create_menu_item_with_mnemonic( menu_in_menu, "CSG _Subtract", "CSGSubtract" );
                create_menu_item_with_mnemonic( menu_in_menu, "CSG _Merge", "CSGMerge" );
        }
        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 );
                }
index f26e68abb4cd0c79509dd3e90205a070929cc960..ac34e45528215e1280e1ebd45e9bb28cb327048a 100644 (file)
@@ -23,8 +23,9 @@
 #define INCLUDED_BRUSHWRAPPER_H
 
 #include <cstddef>
+#include <uilib/uilib.h>
 #include "string/stringfwd.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 enum EBrushPrefab
 {
@@ -75,10 +76,9 @@ void Scene_BrushFitTexture_Component_SelectedW( scene::Graph& graph, float s_rep
 void Scene_BrushFitTexture_SelectedH( scene::Graph& graph, float s_repeat, float t_repeat );
 void Scene_BrushFitTexture_Component_SelectedH( 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();
index bc9c18ef67671262fa6cf553bd90cec4b1e54c9b..2ab573e514601c7d8b451eca7a8caa448b1e1ae3 100644 (file)
@@ -34,7 +34,7 @@
 #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;
 
@@ -42,21 +42,20 @@ bool getTextureLockEnabled(){
        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",
@@ -65,8 +64,7 @@ void Brush_constructPreferences( PreferencesPage& page ){
        if ( g_showAlternativeTextureProjectionOption ) {
                page.appendCheckBox(
                        "", "Use alternative texture-projection (\"brush primitives\")",
-                       LatchedBoolImportCaller( g_useAlternativeTextureProjection ),
-                       BoolExportCaller( g_useAlternativeTextureProjection.m_latched )
+                       make_property(g_useAlternativeTextureProjection)
                        );
        }
        // d1223m
@@ -80,7 +78,7 @@ void Brush_constructPage( PreferenceGroup& group ){
        Brush_constructPreferences( page );
 }
 void Brush_registerPreferencesPage(){
-       PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Brush_constructPage>() );
+       PreferencesDialog_addSettingsPage( makeCallbackF(Brush_constructPage) );
 }
 
 void Brush_unlatchPreferences(){
@@ -113,8 +111,7 @@ void Brush_Construct( EBrushType type ){
 
                GlobalPreferenceSystem().registerPreference(
                        "AlternativeTextureProjection",
-                       BoolImportStringCaller( g_useAlternativeTextureProjection.m_latched ),
-                       BoolExportStringCaller( g_useAlternativeTextureProjection.m_latched )
+                       make_property_string( g_useAlternativeTextureProjection.m_latched )
                        );
                g_useAlternativeTextureProjection.useLatched();
 
@@ -125,8 +122,8 @@ void Brush_Construct( EBrushType type ){
                // d1223m
                GlobalPreferenceSystem().registerPreference(
                        "BrushAlwaysCaulk",
-                       BoolImportStringCaller( g_brush_always_caulk ),
-                       BoolExportStringCaller( g_brush_always_caulk ) );
+            make_property_string( g_brush_always_caulk )
+        );
        }
 
        Brush_registerCommands();
@@ -154,12 +151,12 @@ void Brush_Construct( EBrushType type ){
                }
        }
 
-       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(){
@@ -188,8 +185,8 @@ void BrushFaceData_fromFace( const BrushFaceDataCallback& callback, Face& face )
        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
 {
index 073e0ddf12049b467afdb4b7b32a0cbec375e8b5..6462e382ab66aa3f61ccdadb2cfca67fdcead48d 100644 (file)
@@ -22,6 +22,7 @@
 #include "build.h"
 #include "debugging/debugging.h"
 
+#include <gtk/gtk.h>
 #include <map>
 #include <list>
 #include "stream/stringstream.h"
@@ -55,6 +56,7 @@ const char* build_get_variable( const char* name ){
 class Evaluatable
 {
 public:
+virtual ~Evaluatable() = default;
 virtual void evaluate( StringBuffer& output ) = 0;
 virtual void exportXML( XMLImporter& importer ) = 0;
 };
@@ -171,6 +173,7 @@ void exportXML( XMLImporter& importer ){
 class XMLElementParser : public TextOutputStream
 {
 public:
+virtual ~XMLElementParser() = default;
 virtual XMLElementParser& pushElement( const XMLElement& element ) = 0;
 virtual void popElement( const char* name ) = 0;
 };
@@ -293,7 +296,7 @@ void popElement( const char* name ){
 };
 
 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;
@@ -308,21 +311,12 @@ static bool is_separator( const BuildPair &p ){
 }
 
 
-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 ){
@@ -633,58 +627,45 @@ void build_commands_write( const char* filename ){
 
 
 #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};
 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() ) {
@@ -704,8 +685,7 @@ gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gch
                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();
        }
 
        gtk_tree_path_free( path );
@@ -715,15 +695,15 @@ gboolean project_cell_edited( GtkCellRendererText* cell, gchar* path_string, gch
        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 );
 
@@ -742,15 +722,15 @@ gboolean project_key_press( GtkWidget* widget, GdkEventKey* event, ProjectList*
 
 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 );
 
@@ -760,12 +740,9 @@ gboolean project_selection_changed( GtkTreeSelection* selection, GtkListStore* s
 
                        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
                {
@@ -780,18 +757,18 @@ gboolean project_selection_changed( GtkTreeSelection* selection, GtkListStore* s
        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() ) {
@@ -806,8 +783,7 @@ gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gc
 
                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 );
@@ -817,18 +793,18 @@ gboolean commands_cell_edited( GtkCellRendererText* cell, gchar* path_string, gc
        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 );
 
@@ -844,99 +820,92 @@ gboolean commands_key_press( GtkWidget* widget, GdkEventKey* event, GtkListStore
 }
 
 
-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_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_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 );
                                }
                        }
                }
@@ -959,7 +928,7 @@ void DoBuildMenu(){
 
        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();
@@ -971,7 +940,7 @@ void DoBuildMenu(){
                g_build_changed = true;
        }
 
-       gtk_widget_destroy( GTK_WIDGET( window ) );
+       window.destroy();
 }
 
 
@@ -981,32 +950,30 @@ void DoBuildMenu(){
 #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(){
        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 );
                }
@@ -1018,10 +985,10 @@ void Build_constructMenu( GtkMenu* 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();
@@ -1059,7 +1026,7 @@ void SaveBuildMenu(){
 #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(){
index 32a39718e2185f9465b4f81f69ce364688ce8353..4e49414637fa0a292adc1521ce7040143ef7dcb5 100644 (file)
@@ -18,6 +18,8 @@
    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
 
@@ -36,9 +38,8 @@ void DoBuildMenu();
 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;
 
 
 #endif
index 20fcb853829a2cf47dcf48795071c3f096d4c9f8..2ef5a9862a71d5c9396370c7037397a0aa192521 100644 (file)
@@ -27,6 +27,9 @@
 
 #include "camwindow.h"
 
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
 #include "debugging/debugging.h"
 
 #include "iscenegraph.h"
@@ -157,11 +160,11 @@ struct camera_t
        }
 
        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 ),
@@ -319,17 +322,8 @@ void Camera_FreeMove( camera_t& camera, int dx, int dy ){
 }
 
 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 ) {
@@ -519,25 +513,25 @@ void Camera_PitchDown_KeyUp( camera_t& camera ){
 }
 
 
-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 );
@@ -601,9 +595,9 @@ class RadiantCameraView : public CameraView
 {
 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 );
@@ -669,8 +663,8 @@ static Shader* m_state_select2;
 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;
@@ -729,7 +723,7 @@ private:
 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;
@@ -756,19 +750,19 @@ void GlobalCamera_setCamWnd( CamWnd& camwnd ){
 }
 
 
-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 ){
@@ -799,7 +793,7 @@ void Camera_setAngles( CamWnd& camwnd, const Vector3& angles ){
 // =============================================================================
 // 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 ) {
                camwnd->EnableFreeMove();
                return TRUE;
@@ -807,7 +801,7 @@ gboolean enable_freelook_button_press( GtkWidget* widget, GdkEventButton* event,
        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 ) {
                camwnd->DisableFreeMove();
                return TRUE;
@@ -816,7 +810,7 @@ gboolean disable_freelook_button_press( GtkWidget* widget, GdkEventButton* event
 }
 
 #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 );
        }
@@ -825,20 +819,20 @@ gboolean mousecontrol_button_press( GtkWidget* widget, GdkEventButton* event, Ca
 #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 ) );
        }
@@ -850,30 +844,31 @@ void selection_motion( gdouble x, gdouble y, guint state, void* data ){
        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 ) ) ) );
@@ -886,7 +881,7 @@ gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* cam
        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() );
@@ -895,7 +890,7 @@ gboolean camera_size_allocate( GtkWidget* widget, GtkAllocation* allocation, Cam
        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;
 }
@@ -913,60 +908,60 @@ void KeyEvent_disconnect( const char* name ){
 }
 
 void CamWnd_registerCommands( CamWnd& camwnd ){
-       GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_Up ),
-                                                       ReferenceCaller<camera_t, Camera_MoveForward_KeyDown>( camwnd.getCamera() ),
-                                                       ReferenceCaller<camera_t, Camera_MoveForward_KeyUp>( camwnd.getCamera() )
+       GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_KEY_Up ),
+                                                       ReferenceCaller<camera_t, void(), Camera_MoveForward_KeyDown>( camwnd.getCamera() ),
+                                                       ReferenceCaller<camera_t, void(), Camera_MoveForward_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_Down ),
-                                                       ReferenceCaller<camera_t, Camera_MoveBack_KeyDown>( camwnd.getCamera() ),
-                                                       ReferenceCaller<camera_t, Camera_MoveBack_KeyUp>( camwnd.getCamera() )
+       GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_KEY_Down ),
+                                                       ReferenceCaller<camera_t, void(), Camera_MoveBack_KeyDown>( camwnd.getCamera() ),
+                                                       ReferenceCaller<camera_t, void(), Camera_MoveBack_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_Left ),
-                                                       ReferenceCaller<camera_t, Camera_RotateLeft_KeyDown>( camwnd.getCamera() ),
-                                                       ReferenceCaller<camera_t, Camera_RotateLeft_KeyUp>( camwnd.getCamera() )
+       GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_KEY_Left ),
+                                                       ReferenceCaller<camera_t, void(), Camera_RotateLeft_KeyDown>( camwnd.getCamera() ),
+                                                       ReferenceCaller<camera_t, void(), Camera_RotateLeft_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_Right ),
-                                                       ReferenceCaller<camera_t, Camera_RotateRight_KeyDown>( camwnd.getCamera() ),
-                                                       ReferenceCaller<camera_t, Camera_RotateRight_KeyUp>( camwnd.getCamera() )
+       GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_KEY_Right ),
+                                                       ReferenceCaller<camera_t, void(), Camera_RotateRight_KeyDown>( camwnd.getCamera() ),
+                                                       ReferenceCaller<camera_t, void(), Camera_RotateRight_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_period ),
-                                                       ReferenceCaller<camera_t, Camera_MoveRight_KeyDown>( camwnd.getCamera() ),
-                                                       ReferenceCaller<camera_t, Camera_MoveRight_KeyUp>( camwnd.getCamera() )
+       GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_KEY_period ),
+                                                       ReferenceCaller<camera_t, void(), Camera_MoveRight_KeyDown>( camwnd.getCamera() ),
+                                                       ReferenceCaller<camera_t, void(), Camera_MoveRight_KeyUp>( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_comma ),
-                                                       ReferenceCaller<camera_t, Camera_MoveLeft_KeyDown>( camwnd.getCamera() ),
-                                                       ReferenceCaller<camera_t, Camera_MoveLeft_KeyUp>( camwnd.getCamera() )
+       GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_KEY_comma ),
+                                                       ReferenceCaller<camera_t, void(), Camera_MoveLeft_KeyDown>( camwnd.getCamera() ),
+                                                       ReferenceCaller<camera_t, void(), Camera_MoveLeft_KeyUp>( camwnd.getCamera() )
                                                        );
        GlobalKeyEvents_insert( "CameraUp", Accelerator( 'D' ),
-                                                       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( 'C' ),
-                                                       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( "CameraAngleDown", Accelerator( 'A' ),
-                                                       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( "CameraAngleUp", Accelerator( 'Z' ),
-                                                       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( "CameraFreeMoveForward", Accelerator( 'W' ),
+       GlobalKeyEvents_insert( "CameraFreeMoveForward", Accelerator( GDK_KEY_Up ),
                                                        FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveBack", Accelerator( 'S' ),
+       GlobalKeyEvents_insert( "CameraFreeMoveBack", Accelerator( GDK_KEY_Down ),
                                                        FreeMoveCameraMoveBackKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveBackKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveLeft", Accelerator( 'A' ),
+       GlobalKeyEvents_insert( "CameraFreeMoveLeft", Accelerator( GDK_KEY_Left ),
                                                        FreeMoveCameraMoveLeftKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveLeftKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveRight", Accelerator( 'D' ),
+       GlobalKeyEvents_insert( "CameraFreeMoveRight", Accelerator( GDK_KEY_Right ),
                                                        FreeMoveCameraMoveRightKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() )
                                                        );
@@ -988,26 +983,26 @@ void CamWnd_registerCommands( CamWnd& camwnd ){
                                                        FreeMoveCameraMoveRightKeyUpCaller( camwnd.getCamera() )
                                                        );
 
-       GlobalKeyEvents_insert( "CameraFreeMoveUp", Accelerator( GDK_period ),
+       GlobalKeyEvents_insert( "CameraFreeMoveUp", Accelerator( 'D' ),
                                                        FreeMoveCameraMoveUpKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveUpKeyUpCaller( camwnd.getCamera() )
                                                        );
-       GlobalKeyEvents_insert( "CameraFreeMoveDown", Accelerator( GDK_comma ),
+       GlobalKeyEvents_insert( "CameraFreeMoveDown", Accelerator( 'C' ),
                                                        FreeMoveCameraMoveDownKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveDownKeyUpCaller( camwnd.getCamera() )
                                                        );
 
-       GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, Camera_MoveForward_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Up ) );
-       GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, Camera_MoveBack_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Down ) );
-       GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, Camera_RotateLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Left ) );
-       GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, Camera_RotateRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_Right ) );
-       GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, Camera_MoveRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_period ) );
-       GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, Camera_MoveLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_comma ) );
+       GlobalCommands_insert( "CameraForward", ReferenceCaller<camera_t, void(), Camera_MoveForward_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_Up ) );
+       GlobalCommands_insert( "CameraBack", ReferenceCaller<camera_t, void(), Camera_MoveBack_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_Down ) );
+       GlobalCommands_insert( "CameraLeft", ReferenceCaller<camera_t, void(), Camera_RotateLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_Left ) );
+       GlobalCommands_insert( "CameraRight", ReferenceCaller<camera_t, void(), Camera_RotateRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_Right ) );
+       GlobalCommands_insert( "CameraStrafeRight", ReferenceCaller<camera_t, void(), Camera_MoveRight_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_period ) );
+       GlobalCommands_insert( "CameraStrafeLeft", ReferenceCaller<camera_t, void(), Camera_MoveLeft_Discrete>( camwnd.getCamera() ), Accelerator( GDK_KEY_comma ) );
 
-       GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, Camera_MoveUp_Discrete>( camwnd.getCamera() ), Accelerator( 'D' ) );
-       GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, Camera_MoveDown_Discrete>( camwnd.getCamera() ), Accelerator( 'C' ) );
-       GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, Camera_PitchUp_Discrete>( camwnd.getCamera() ), Accelerator( 'A' ) );
-       GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, Camera_PitchDown_Discrete>( camwnd.getCamera() ), Accelerator( 'Z' ) );
+       GlobalCommands_insert( "CameraUp", ReferenceCaller<camera_t, void(), Camera_MoveUp_Discrete>( camwnd.getCamera() ), Accelerator( 'D' ) );
+       GlobalCommands_insert( "CameraDown", ReferenceCaller<camera_t, void(), Camera_MoveDown_Discrete>( camwnd.getCamera() ), Accelerator( 'C' ) );
+       GlobalCommands_insert( "CameraAngleUp", ReferenceCaller<camera_t, void(), Camera_PitchUp_Discrete>( camwnd.getCamera() ), Accelerator( 'A' ) );
+       GlobalCommands_insert( "CameraAngleDown", ReferenceCaller<camera_t, void(), Camera_PitchDown_Discrete>( camwnd.getCamera() ), Accelerator( 'Z' ) );
 }
 
 void CamWnd_Move_Enable( CamWnd& camwnd ){
@@ -1062,12 +1057,23 @@ void CamWnd_Move_Discrete_Disable( 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 );
        }
 
@@ -1075,31 +1081,19 @@ void CamWnd_Move_Discrete_Import( CamWnd& camwnd, bool value ){
 
        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 );
@@ -1127,11 +1121,11 @@ void CamWnd_Remove_Handlers_Move( CamWnd& 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" );
@@ -1171,11 +1165,11 @@ void CamWnd_Remove_Handlers_FreeMove( CamWnd& camwnd ){
 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 ),
@@ -1187,16 +1181,16 @@ CamWnd::CamWnd() :
        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 ) );
 
@@ -1204,9 +1198,9 @@ CamWnd::CamWnd() :
 
        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 );
 }
@@ -1221,7 +1215,7 @@ CamWnd::~CamWnd(){
        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();
 }
@@ -1290,7 +1284,7 @@ if ( ( m_bFreeMove && ( buttons == ( RAD_CONTROL | RAD_SHIFT ) ) )
 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 ) );
@@ -1300,7 +1294,7 @@ void CamWnd::Cam_PositionDrag(){
                CamWnd_Update( camwnd );
                CameraMovedNotify();
 
-               Sys_SetCursorPos( GTK_WINDOW( m_parent ), m_PositionDragCursorX, m_PositionDragCursorY );
+               Sys_SetCursorPos( m_parent, m_PositionDragCursorX, m_PositionDragCursorY );
        }
 }
 #endif
@@ -1308,7 +1302,7 @@ void CamWnd::Cam_PositionDrag(){
 
 // 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;
 }
@@ -1324,7 +1318,7 @@ void CamWnd::EnableFreeMove(){
        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, Camera_motionDelta, &m_Camera );
 
        CamWnd_Update( *this );
@@ -1383,7 +1377,7 @@ void SetState( Shader* state, EStyle style ){
                m_state_stack.back().m_state = state;
        }
 }
-const EStyle getStyle() const {
+EStyle getStyle() const {
        return eFullMaterials;
 }
 void PushState(){
@@ -1426,15 +1420,13 @@ void render( const Matrix4& modelview, const Matrix4& projection ){
 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 );
 
 void CamWnd::Cam_Draw(){
@@ -1629,7 +1621,7 @@ void CamWnd::BenchMark(){
 }
 
 
-void fill_view_camera_menu( GtkMenu* menu ){
+void fill_view_camera_menu( ui::Menu menu ){
        create_check_menu_item_with_mnemonic( menu, "Camera View", "ToggleCamera" );
 }
 
@@ -1677,7 +1669,7 @@ bool Camera_GetFarClip(){
        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 ){
@@ -1688,12 +1680,22 @@ 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" );
 }
 
@@ -1746,7 +1748,7 @@ CameraModel* g_camera_model = 0;
 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() );
@@ -1769,7 +1771,7 @@ void CamWnd_LookThroughSelected( CamWnd& camwnd ){
                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 ) );
                }
        }
 }
@@ -1782,10 +1784,26 @@ void GlobalCamera_LookThroughCamera(){
        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;
@@ -1802,26 +1820,7 @@ void RenderModeImport( int value ){
                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 );
@@ -1830,13 +1829,11 @@ void Camera_constructPreferences( PreferencesPage& page ){
        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" ) {
@@ -1845,8 +1842,7 @@ void Camera_constructPreferences( PreferencesPage& page ){
                page.appendCombo(
                        "Render Mode",
                        STRING_ARRAY_RANGE( render_mode ),
-                       IntImportCallback( RenderModeImportCaller() ),
-                       IntExportCallback( RenderModeExportCaller() )
+                       make_property<RenderMode>()
                        );
        }
        else
@@ -1856,8 +1852,7 @@ void Camera_constructPreferences( PreferencesPage& page ){
                page.appendCombo(
                        "Render Mode",
                        STRING_ARRAY_RANGE( render_mode ),
-                       IntImportCallback( RenderModeImportCaller() ),
-                       IntExportCallback( RenderModeExportCaller() )
+                       make_property<RenderMode>()
                        );
        }
 
@@ -1874,15 +1869,13 @@ void Camera_constructPage( PreferenceGroup& group ){
        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;
@@ -1903,62 +1896,62 @@ void CameraSpeed_decrease(){
 
 /// \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( "CenterView", makeCallbackF(GlobalCamera_ResetAngles), Accelerator( GDK_KEY_End ) );
 
-       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( "CameraFreeMoveLeft2", Accelerator( GDK_Left ) );
        GlobalShortcuts_insert( "CameraFreeMoveRight2", Accelerator( GDK_Right ) );
 
-       GlobalToggles_insert( "ShowStats", ShowStatsToggleCaller(), 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();
 
index 1101d4310c249b6504bf81515f52416ddb0de125..ded8aefcba9456471890a6b1af02b647965a9b3e 100644 (file)
 #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 );
@@ -36,15 +34,13 @@ void AddCameraMovedCallback( const SignalHandler& handler );
 
 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 _GtkMenu GtkMenu;
-void fill_view_camera_menu( GtkMenu* menu );
-typedef struct _GtkToolbar GtkToolbar;
-void CamWnd_constructToolbar( GtkToolbar* toolbar );
+void fill_view_camera_menu( ui::Menu menu );
+void CamWnd_constructToolbar( ui::Toolbar toolbar );
 void CamWnd_registerShortcuts();
 
 void GlobalCamera_Benchmark();
index f608ea49709348fbc4574bdb7d062ccd7312b18f..9c1b7682246febb16f70c082faba1da1b418dbd2 100644 (file)
 
 #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
@@ -73,7 +71,7 @@ typedef std::map<CopiedString, Command> Commands;
 
 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 ) );
 }
@@ -89,7 +87,7 @@ typedef std::map<CopiedString, Toggle> Toggles;
 
 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 ) );
 }
@@ -104,7 +102,7 @@ typedef std::map<CopiedString, KeyEvent> KeyEvents;
 
 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 ) );
 }
@@ -150,13 +148,8 @@ void connect_accelerator( const char *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"
@@ -168,29 +161,29 @@ void connect_accelerator( const char *name ){
 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 ) ) {
@@ -199,7 +192,7 @@ void accelerator_clear_button_clicked( GtkButton *btn, gpointer dialogptr ){
 
        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!
@@ -211,35 +204,35 @@ void accelerator_clear_button_clicked( GtkButton *btn, gpointer dialogptr ){
        }
        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 ) {
@@ -253,20 +246,20 @@ gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gp
 #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
@@ -276,12 +269,12 @@ gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gp
        // 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;
        }
 
@@ -293,11 +286,11 @@ gboolean accelerator_window_key_press( GtkWidget *widget, GdkEventKey *event, gp
        {
        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 ) ) {
@@ -313,32 +306,32 @@ public:
                        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;
                        }
@@ -347,8 +340,8 @@ public:
        } 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
@@ -359,7 +352,7 @@ public:
                // 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 );
@@ -367,7 +360,7 @@ public:
 
        g_value_unset( &val );
 
-       dialog.m_model = NULL;
+       dialog.m_model = ui::TreeModel(ui::null);
 
        return true;
 }
@@ -376,9 +369,9 @@ public:
     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())
@@ -386,7 +379,7 @@ public:
         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);
     }
    };
  */
@@ -394,41 +387,43 @@ public:
 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
@@ -438,19 +433,15 @@ void DoCommandListDlg(){
                                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 );
@@ -465,33 +456,33 @@ public:
                                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"
index ea5a6f33db68f61c10d15218d105f3fee3f1774e..8c6b9f19063e1a9d272e34c80c654214f1bdb4ae 100644 (file)
@@ -35,13 +35,13 @@ public:
 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 );
 
 
index 72a64140fd0ba4af78aa8475cd06bb89551ea87e..82b08e3c2ab5468ca1919e0a094dd0a99af7a9e7 100644 (file)
 #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"
@@ -69,8 +67,8 @@ void Sys_LogFile( bool enable ){
                                                                 << "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 ) {
@@ -83,42 +81,41 @@ void Sys_LogFile( bool enable ){
        }
 }
 
-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();
@@ -127,8 +124,8 @@ GtkWidget* Console_constructWindow( GtkWindow* toplevel ){
 
                //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 );
@@ -145,7 +142,7 @@ public:
 GtkTextBufferOutputStream( GtkTextBuffer* textBuffer, GtkTextIter* iter, GtkTextTag* tag ) : textBuffer( textBuffer ), iter( iter ), tag( tag ){
 }
 std::size_t 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;
 }
 };
@@ -165,20 +162,20 @@ std::size_t Sys_Print( int level, const char* buf, std::size_t 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 )
                        {
@@ -210,9 +207,9 @@ std::size_t Sys_Print( int level, const char* buf, std::size_t length ){
 
                        // 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();
                                }
                        }
index 38e479fd5a96e12902c7aeba827b88d75f83059c..8bbe71e1c512ab05777f8e64de01a444892c7b49 100644 (file)
@@ -23,6 +23,7 @@
 #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
@@ -35,9 +36,7 @@ class TextOutputStream;
 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 );
index 68349f240ec910697f6f450310fbc98c57062ecf..24ca4035b82d3721310d91e7fb5236c485b4a8d0 100644 (file)
@@ -121,6 +121,7 @@ public:
 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() );
@@ -197,11 +198,9 @@ class Dereference
 {
 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 );
 }
 };
@@ -223,15 +222,14 @@ Face* Brush_findIf( const Brush& brush, const Predicate& predicate ){
 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 );
 }
 };
@@ -239,17 +237,16 @@ result_type operator()( first_argument_type firstArgument ) const {
 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 );
 }
 };
@@ -262,8 +259,8 @@ BindArguments2<Caller> bindArguments( const Caller& caller, FirstBound firstBoun
 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
@@ -339,9 +336,11 @@ public:
 SubtractBrushesFromUnselected( const brush_vector_t& brushlist, std::size_t& before, std::size_t& after )
        : m_brushlist( brushlist ), m_before( before ), m_after( after ){
 }
+
 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() );
@@ -436,9 +435,11 @@ public:
 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() );
@@ -502,6 +503,7 @@ public:
 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
index 68e907c048216359a8c7ea134aeb909b5e1f8a84..e05c9effbb4b65ab408e9be5637cd071c6d851cd 100644 (file)
 #define INCLUDED_CSG_H
 
 void CSG_MakeHollow( void );
+
 void CSG_MakeRoom( void );
+
 void CSG_Subtract( void );
+
 void CSG_Merge( void );
 
 namespace scene
@@ -33,15 +36,18 @@ class Graph;
 }
 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
index e98cac9212901178a72b793658ae43405ba9f71e..1c628ff17a3ee3c33c7e4cc856a18deae791fd74 100644 (file)
@@ -28,6 +28,8 @@
 
 #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(){
@@ -318,112 +297,112 @@ 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(){
@@ -451,12 +430,12 @@ EMessageBoxReturn Dialog::DoModal(){
        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 );
 
@@ -464,187 +443,183 @@ EMessageBoxReturn Dialog::DoModal(){
 }
 
 
-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;
 }
index 2a0454ebad33afe1d3208a7edeff3d5411383d39..78efa830ee541861c87063bba78054b84fa0d2ab 100644 (file)
 #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
index db65063a50ea28fefc99aaee562c74e43511a59c..90c8a11b2f2eda7d2d6f487398a536dd150779c5 100644 (file)
@@ -175,22 +175,11 @@ struct PathLess
 
 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));
+       }));
 }
 
 
@@ -336,14 +325,14 @@ EclassManagerAPI(){
        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();
 }
index 620cc276808309c33c868327dfb7e8e78aa30c62..4c7525ea4fdb9219bd60c0b958946954c5b2db5a 100644 (file)
@@ -84,7 +84,7 @@ inline void printParseError( const char* message ){
        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();
@@ -502,7 +502,9 @@ static bool EntityClass_parse( EntityClass& entityClass, Tokeniser& tokeniser ){
                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 ) ;
+                       }
                        EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, key ).second;
                        attribute.m_type = "string";
                        const char* value;
@@ -687,7 +689,7 @@ EntityClassDoom3() : m_unrealised( 2 ){
 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 )
index 7b87791520b4c5365acf8d92fbafe8383bf5a33d..b92afbfc6f1980a9676bfcf37edd338a5e517e71 100644 (file)
@@ -28,6 +28,7 @@
 #include "ifilesystem.h"
 #include "iscriplib.h"
 #include "qerplugin.h"
+#include "mainframe.h"
 
 #include "string/string.h"
 #include "eclasslib.h"
@@ -91,7 +92,7 @@ inline bool EntityClassFGD_parseToken( Tokeniser& tokeniser, const char* token )
        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 );
@@ -699,12 +700,12 @@ EntityClassFGDAPI(){
        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();
 }
index cc863c611f255fcb2d1b0e03ed212480ffa0d2ea..6a29380518408cb167d9bd894e2f2eb5b01184a6 100644 (file)
@@ -40,6 +40,8 @@
 #include "select.h"
 #include "map.h"
 #include "preferences.h"
+#include "preferencesystem.h"
+#include "stringio.h"
 #include "gtkdlgs.h"
 #include "mainframe.h"
 #include "qe3.h"
@@ -48,6 +50,8 @@
 #include "brushmanip.h"
 #include "patchmanip.h"
 
+#include "uilib/uilib.h"
+
 struct entity_globals_t
 {
        Vector3 color_entity;
@@ -67,9 +71,11 @@ public:
 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
@@ -153,11 +159,14 @@ class EntityFindSelected : public scene::Graph::Walker
 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
@@ -178,9 +187,11 @@ NodeSmartReference group, worldspawn;
 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() ) {
@@ -232,7 +243,6 @@ void Entity_groupSelected(){
 }
 
 
-
 void Entity_connectSelected(){
        if ( GlobalSelectionSystem().countSelected() == 2 ) {
                GlobalEntityCreator().connectEntities(
@@ -290,7 +300,7 @@ int g_iLastLightIntensity;
 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
@@ -384,7 +394,7 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){
        }
 
        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 );
                }
@@ -405,7 +415,7 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){
 
 #if 0
 bool DoNormalisedColor( Vector3& color ){
-       if ( !color_dialog( GTK_WIDGET( MainFrame_getWindow() ), color ) ) {
+       if ( !color_dialog( MainFrame_getWindow( ), color ) ) {
                return false;
        }
        /*
@@ -516,7 +526,7 @@ void Entity_setColour(){
                                normalize = false;
                        }
 
-                       if ( color_dialog( GTK_WIDGET( MainFrame_getWindow() ), g_entity_globals.color_entity ) ) {
+                       if ( color_dialog( MainFrame_getWindow(), g_entity_globals.color_entity ) ) {
                                if ( normalize ) {
                                        NormalizeColor( g_entity_globals.color_entity );
                                }
@@ -532,21 +542,32 @@ void Entity_setColour(){
        }
 }
 
-const char* misc_model_dialog( GtkWidget* parent ){
-       StringOutputStream buffer( 1024 );
+CopiedString g_strLastModelFolder = "";
 
-       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() << "/";
+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 charrelative = 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";
                }
@@ -555,34 +576,33 @@ const char* misc_model_dialog( GtkWidget* parent ){
        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 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" );
@@ -594,20 +614,16 @@ void Entity_constructMenu( GtkMenu* menu ){
 }
 
 
-
-#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>() );
-
-       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 ) );
+       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) );
+
+       GlobalPreferenceSystem().registerPreference( "SI_Colors5", make_property_string( g_entity_globals.color_entity ) );
+       GlobalPreferenceSystem().registerPreference( "LastLightIntensity", make_property_string( g_iLastLightIntensity ) );
 
        Entity_registerPreferencesPage();
 }
index eaf73cbb47041be9664248e8db6361cb2e28ed5c..fca38f92cd4c598852325ceccc19a725b4f9912f 100644 (file)
@@ -22,6 +22,8 @@
 #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 );
@@ -30,11 +32,9 @@ void Scene_EntitySetKeyValue_Selected( const char* key, const char* value );
 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();
index 407aaa1a000a76503b4dfd1aebcef777af252940..d2acdc80f3be71214fb9e73fcdf1c3ae4fe8be4d 100644 (file)
@@ -22,6 +22,7 @@
 #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;
 }
 
@@ -118,7 +104,8 @@ void Scene_EntitySetKeyValue_Selected_Undoable( const char* key, const char* val
 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;
 };
@@ -126,72 +113,72 @@ 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;
 }
 
@@ -200,17 +187,17 @@ void release(){
 }
 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
@@ -237,33 +224,33 @@ ModelAttribute( const char* key ) :
 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/";
@@ -274,7 +261,7 @@ const char* browse_sound( GtkWidget* parent ){
                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 ) {
@@ -300,30 +287,30 @@ SoundAttribute( const char* key ) :
 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 ){
@@ -333,43 +320,43 @@ 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
@@ -381,72 +368,72 @@ const String buttons[] = { "up", "down", "z-axis" };
 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 );
@@ -460,17 +447,17 @@ void applyRadio(){
                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 ){
 }
 };
 
@@ -481,28 +468,29 @@ class AnglesAttribute : public EntityAttribute
 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 );
        }
@@ -510,8 +498,8 @@ AnglesAttribute( const char* key ) :
 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 );
@@ -520,7 +508,7 @@ void apply(){
                   << " " << 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 );
@@ -532,34 +520,34 @@ void update(){
                }
 
                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 ){
 }
 };
 
@@ -568,28 +556,28 @@ class Vector3Attribute : public EntityAttribute
 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 );
        }
@@ -597,8 +585,8 @@ Vector3Attribute( const char* key ) :
 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 );
@@ -607,7 +595,7 @@ void apply(){
                        << " " << 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 );
@@ -619,44 +607,44 @@ void update(){
                }
 
                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 );
@@ -666,23 +654,23 @@ void setActive( GtkComboBox* combo, int value ){
 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;
@@ -690,13 +678,13 @@ ListAttribute( const char* key, const ListAttributeType& type ) :
 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() );
@@ -709,29 +697,29 @@ void update(){
                m_nonModal.setActive( m_combo, 0 );
        }
 }
-typedef MemberCaller<ListAttribute, &ListAttribute::update> UpdateCaller;
+typedef MemberCaller<ListAttribute, void(), &ListAttribute::update> UpdateCaller;
 };
 
 
 namespace
 {
-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_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;
@@ -742,9 +730,9 @@ int g_spawnflag_count;
 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;
 }
@@ -817,14 +805,12 @@ const char* keyvalues_valueforkey( KeyValues& keyvalues, const char* key ){
 
 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);
 }
 };
 
@@ -834,7 +820,7 @@ void EntityClassList_fill(){
 }
 
 void EntityClassList_clear(){
-       gtk_list_store_clear( g_entlist_store );
+       g_entlist_store.clear();
 }
 
 void SetComment( EntityClass* eclass ){
@@ -844,8 +830,7 @@ 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 ){
@@ -855,7 +840,7 @@ 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
@@ -873,47 +858,47 @@ void SurfaceFlags_setEntityClass( EntityClass* eclass ){
        {
                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 );
@@ -924,8 +909,8 @@ void EntityClassList_selectEntityClass( EntityClass* eclass ){
 }
 
 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 );
 }
 
 
@@ -981,7 +966,7 @@ void EntityInspector_setEntityClass( EntityClass *eclass ){
        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 )
@@ -1002,14 +987,14 @@ void EntityInspector_updateSpawnflags(){
                {
                        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 );
                }
        }
 }
@@ -1047,28 +1032,26 @@ void EntityInspector_updateKeyValues(){
 
        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 )
        {
@@ -1080,7 +1063,7 @@ class EntityInspectorDraw
 {
 IdleDraw m_idleDraw;
 public:
-EntityInspectorDraw() : m_idleDraw( FreeCaller<EntityInspector_updateKeyValues>( ) ){
+EntityInspectorDraw() : m_idleDraw( makeCallbackF(EntityInspector_updateKeyValues) ){
 }
 void queueDraw(){
        m_idleDraw.queueDraw();
@@ -1100,13 +1083,13 @@ void EntityInspector_selectionChanged( const Selectable& ){
 // 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;
        }
 
@@ -1134,14 +1117,14 @@ void EntityInspector_applyKeyValue(){
 
        // 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;
        }
 
@@ -1202,7 +1185,7 @@ void EntityInspector_clearAllKeyValues(){
 // =============================================================================
 // 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 ) ) {
@@ -1214,7 +1197,7 @@ static void EntityClassList_selection_changed( GtkTreeSelection* selection, gpoi
        }
 }
 
-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;
@@ -1222,17 +1205,17 @@ static gint EntityClassList_button_press( GtkWidget *widget, GdkEventButton *eve
        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
@@ -1246,9 +1229,9 @@ static gint EntityClassList_keypress( GtkWidget* widget, GdkEventKey* event, gpo
                        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 );
@@ -1267,7 +1250,7 @@ static gint EntityClassList_keypress( GtkWidget* widget, GdkEventKey* event, gpo
        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;
@@ -1279,22 +1262,22 @@ static void EntityProperties_selection_changed( GtkTreeSelection* selection, gpo
        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
                {
@@ -1303,25 +1286,24 @@ static gint EntityEntry_keypress( GtkEntry* widget, GdkEventKey* event, gpointer
                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_entitysplit1_position = gtk_paned_get_position( GTK_PANED( g_entity_split1 ) );
        g_entitysplit2_position = gtk_paned_get_position( GTK_PANED( g_entity_split2 ) );
 
@@ -1343,150 +1325,150 @@ static gint EntityInspector_destroyWindowKB( GtkWidget* widget, GdkEventKey* eve
        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_destroyWindowKB ), 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_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_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_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* split2 = gtk_vpaned_new();
+                       ui::Widget split2 = ui::VPaned(ui::New);
                        gtk_paned_add2( GTK_PANED( split1 ), split2 );
-                       gtk_widget_show( split2 );
+                       split2.show();
 
                        {
-                               GtkWidget* vbox2 = gtk_vbox_new( FALSE, 2 );
-                               gtk_widget_show( vbox2 );
+                auto vbox2 = ui::VBox( FALSE, 2 );
+                               vbox2.show();
                                gtk_paned_pack1( GTK_PANED( split2 ), 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;
                                        }
@@ -1494,87 +1476,79 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){
 
                                {
                                        // 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( split2 ), scr, FALSE, FALSE );
                        }
                }
@@ -1601,7 +1575,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){
        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 );
 
@@ -1643,8 +1617,8 @@ EntityInspector g_EntityInspector;
 void EntityInspector_construct(){
        GlobalEntityClassManager().attach( g_EntityInspector );
 
-       GlobalPreferenceSystem().registerPreference( "EntitySplit1", IntImportStringCaller( g_entitysplit1_position ), IntExportStringCaller( g_entitysplit1_position ) );
-       GlobalPreferenceSystem().registerPreference( "EntitySplit2", IntImportStringCaller( g_entitysplit2_position ), IntExportStringCaller( g_entitysplit2_position ) );
+       GlobalPreferenceSystem().registerPreference( "EntitySplit1", make_property_string( g_entitysplit1_position ) );
+       GlobalPreferenceSystem().registerPreference( "EntitySplit2", make_property_string( g_entitysplit2_position ) );
 
 }
 
index 1afa258463224104483383cb06be65730dbb07ce..e0d359ec57d984082375a3b8af259424b59d73fe 100644 (file)
    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();
index 4fdc5b4ea6e83f0f20c45085aa4c0141f3336be2..0230fe6d01cf9a7e2e2a80e169cbc4050efa9e05 100644 (file)
 
 #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"
@@ -43,9 +41,8 @@
 #include "treemodel.h"
 
 void RedrawEntityList();
-typedef FreeCaller<RedrawEntityList> RedrawEntityListCaller;
+typedef FreeCaller<void(), RedrawEntityList> RedrawEntityListCaller;
 
-typedef struct _GtkTreeView GtkTreeView;
 
 class EntityList
 {
@@ -62,20 +59,20 @@ EDirty m_dirty;
 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();
 }
 };
 
@@ -102,7 +99,7 @@ const char* node_get_name( scene::Node& node ){
 }
 
 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 );
@@ -110,7 +107,7 @@ inline void gtk_tree_model_get_pointer( GtkTreeModel* model, GtkTreeIter* iter,
 
 
 
-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;
@@ -118,26 +115,26 @@ void entitylist_treeviewcolumn_celldatafunc( GtkTreeViewColumn* column, GtkCellR
        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;
@@ -163,31 +160,31 @@ static gboolean entitylist_tree_select( GtkTreeSelection *selection, GtkTreeMode
        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 );
                }
@@ -200,9 +197,9 @@ gboolean treemodel_update_selection( GtkTreeModel* model, GtkTreePath* path, Gtk
        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 );
 }
 
@@ -212,7 +209,7 @@ void RedrawEntityList(){
        {
        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;
        }
@@ -238,23 +235,23 @@ void EntityList_SelectionChanged( const Selectable& selectable ){
        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;
@@ -271,23 +268,23 @@ gint graph_tree_model_compare_name( GtkTreeModel *model, GtkTreeIter *a, GtkTree
 
 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 );
 
@@ -295,29 +292,29 @@ void EntityList_constructWindow( GtkWindow* main_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;
                }
        }
 
@@ -378,9 +375,9 @@ void EntityList_Construct(){
 
        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(){
index e29f1b9a3a22cfdad20f24cfbc9c655fe30ea716..4830bb8d00b8b36525f9aea76c11fdbb8cb1394c 100644 (file)
    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();
 
index 99aa6c26769bffb13f137ac861b8f76fcc5cbf3a..a84a7d42bc7ba0b10fc25b465aa2098fbff582ae 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #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;
                }
        }
@@ -54,8 +59,9 @@ void args_init( int argc, char* argv[] ){
        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];
 
@@ -79,7 +85,7 @@ void gamedetect_found_game( char *game, char *path ){
        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 );
@@ -108,12 +114,14 @@ void gamedetect(){
        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 ) );
@@ -128,17 +136,17 @@ void gamedetect(){
                        // 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;
                        }
 
@@ -180,7 +188,7 @@ bool portable_app_setup(){
        return false;
 }
 
-#if defined( POSIX )
+#if GDEF_OS_POSIX
 
 #include <stdlib.h>
 #include <pwd.h>
@@ -189,7 +197,7 @@ bool portable_app_setup(){
 #include <glib.h>
 
 const char* LINK_NAME =
-#if defined ( __linux__ )
+#if GDEF_OS_LINUX
        "/proc/self/exe"
 #else // FreeBSD and OSX
        "/proc/curproc/file"
@@ -197,7 +205,7 @@ const char* LINK_NAME =
 ;
 
 /// 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 );
 
@@ -225,7 +233,7 @@ char* getexename( char *buf ){
        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;
@@ -246,14 +254,14 @@ void environment_init( int argc, char* argv[] ){
 
        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();
        }
        gamedetect();
 }
 
-#elif defined( WIN32 )
+#elif GDEF_OS_WINDOWS
 
 #include <windows.h>
 
@@ -269,7 +277,7 @@ void cmdMap(){
        }
 }
 
-void environment_init( int argc, char* argv[] ){
+void environment_init( int argc, char const* argv[] ){
        args_init( argc, argv );
 
        {
@@ -292,15 +300,7 @@ void environment_init( int argc, char* 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();
index 18398e8c0d7016e73a50214dfb614f415fc22dd8..98c33ab94568a90d726896e0298ac94db8f97969 100644 (file)
 #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 const** g_argv;
 
 #if defined( WIN32 )
 extern char* openCmdMap;
index fda7f79f8361fbc32619bd2d289b0173090076ad..50a089645b43140b52fe2c8a311123dfdc34d98f 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "error.h"
+#include "globaldefs.h"
 
 #include "debugging/debugging.h"
 #include "igl.h"
@@ -29,7 +30,7 @@
 #include "preferences.h"
 
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 #define UNICODE
 #include <windows.h>
 #else
@@ -63,7 +64,7 @@ void Error( const char *error, ... ){
 
        strcat( text, "\n" );
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        if ( GetLastError() != 0 ) {
                LPVOID lpMsgBuf;
                FormatMessage(
index 1d2856f58e8267ff54c0dcf6225234dfc307c341..33f6552b90f40b8400b447a5a1bc8152b9a5b595 100644 (file)
 
 #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"
@@ -228,13 +223,13 @@ void CWindingMsg::Draw2D( VIEWTYPE vt ){
 }
 
 // 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 );
        }
@@ -270,8 +265,8 @@ void CDbgDlg::Init(){
                g_ptr_array_remove_index( m_pFeedbackElements, 0 );
        }
 
-       if ( m_clist != NULL ) {
-               gtk_list_store_clear( m_clist );
+       if ( m_clist ) {
+               m_clist.clear();
        }
 }
 
@@ -279,54 +274,52 @@ void CDbgDlg::Push( ISAXHandler *pHandler ){
        // 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;
        }
index 04e98bb2d85ae26c48920caec664d13b58fd7caa..b683a316d76ea07abe1cc48b43c238b36614b68e 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "math/vector.h"
 #include "stream/stringstream.h"
-#include <glib.h>
 #include "xmlstuff.h"
 #include "dialog.h"
 #include "xywindow.h"
@@ -40,6 +39,7 @@
 class IGL2DWindow
 {
 public:
+virtual ~IGL2DWindow() = default;
 // Increment the number of references to this object
 virtual void IncRef() = 0;
 // Decrement the reference count
@@ -143,13 +143,12 @@ void DecRef() {
 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:
@@ -171,13 +170,13 @@ void draw2D( VIEWTYPE viewType ){
        }
 }
 void destroyWindow(){
-       if ( GetWidget() != 0 ) {
+       if ( GetWidget() ) {
                Destroy();
        }
 }
 //  void HideDlg();
 protected:
-GtkWindow* BuildDialog();
+ui::Window BuildDialog();
 };
 
 extern CDbgDlg g_DbgDlg;
index 87cb205c15b4afd6fc7519b3458b08d380f717d7..6a08cecd8c63a3afe63ff54a12cb7c869705435e 100644 (file)
@@ -35,7 +35,7 @@ class RadiantFileTypeRegistry : public IFileTypeRegistry
 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();
index 918f3d808b3ae12d9420333a71cf333fc14229bb..424280ce2f9da105cbe6b710b0e2832819e13d9d 100644 (file)
@@ -1,5 +1,7 @@
 #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"
 
 
-
-
 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" );
@@ -35,7 +37,7 @@ void SetCommonShader( const char* key, const char* shader ){
 }
 
 
-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;
@@ -59,7 +61,7 @@ gboolean Areaportals_button_press( GtkWidget *widget, GdkEventButton *event, gpo
 }
 
 
-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;
@@ -68,7 +70,8 @@ gboolean Caulk_button_press( GtkWidget *widget, GdkEventButton *event, gpointer
        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;
@@ -89,7 +92,8 @@ gboolean Clip_button_press( GtkWidget *widget, GdkEventButton *event, gpointer d
        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;
@@ -114,7 +118,7 @@ gboolean Liquids_button_press( GtkWidget *widget, GdkEventButton *event, gpointe
 }
 
 
-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;
@@ -138,7 +142,8 @@ gboolean Hint_button_press( GtkWidget *widget, GdkEventButton *event, gpointer d
        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;
@@ -147,7 +152,8 @@ gboolean Trigger_button_press( GtkWidget *widget, GdkEventButton *event, gpointe
        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;
@@ -156,7 +162,8 @@ gboolean Detail_button_press( GtkWidget *widget, GdkEventButton *event, gpointer
        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;
@@ -166,55 +173,77 @@ gboolean Structural_button_press( GtkWidget *widget, GdkEventButton *event, gpoi
 }
 
 
-GtkToolbar* create_filter_toolbar(){
-                       GtkToolbar* filter_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
-                       gtk_widget_show( GTK_WIDGET( filter_toolbar ) );
-                       g_signal_connect( G_OBJECT( filter_toolbar ), "enter_notify_event", G_CALLBACK( ToggleActions0 ), 0 );
+ui::Toolbar create_filter_toolbar(){
+                       auto filter_toolbar = ui::Toolbar::from( gtk_toolbar_new() );
+                       gtk_orientable_set_orientation( GTK_ORIENTABLE(filter_toolbar), GTK_ORIENTATION_HORIZONTAL );
+                       gtk_toolbar_set_style( filter_toolbar, GTK_TOOLBAR_ICONS );
+                       filter_toolbar.show();
 
-                       GtkToggleButton* button;
 
-                       toolbar_append_toggle_button( filter_toolbar, "World (ALT + 1)", "f-world.png", "FilterWorldBrushes" );
+                       auto space = [&]() {
+                               auto btn = ui::ToolItem::from(gtk_separator_tool_item_new());
+                                       btn.show();
+                                       filter_toolbar.add(btn);
+                       };
 
-                       button = toolbar_append_toggle_button( filter_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 );
+                       g_signal_connect( G_OBJECT( filter_toolbar ), "enter_notify_event", G_CALLBACK( ToggleActions0 ), 0 );
+
+                       toolbar_append_toggle_button( filter_toolbar, "World (ALT + 1)", "f-world.png", "FilterWorldBrushes" );
 
-                       button = toolbar_append_toggle_button( filter_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 );
+                       {
+                               auto button = toolbar_append_toggle_button( filter_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 button = toolbar_append_toggle_button( filter_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 );
+                       }
 
                        toolbar_append_toggle_button( filter_toolbar, "Patches (CTRL + P)", "patch_wireframe.png", "FilterPatches" );
-                       gtk_toolbar_append_space( GTK_TOOLBAR( filter_toolbar ) );
-
-                       button = toolbar_append_toggle_button( filter_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 );
+                       space();
 
+                       {
+                               auto button = toolbar_append_toggle_button( filter_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( filter_toolbar, "Translucent (ALT + 4)", "f-translucent.png", "FilterTranslucent" );
 
-                       button = toolbar_append_toggle_button( filter_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( filter_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( filter_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( filter_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( filter_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( filter_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( filter_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( filter_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( filter_toolbar, "Paths (ALT + 8)", "texture_lock.png", "FilterPaths" );
-                       gtk_toolbar_append_space( GTK_TOOLBAR( filter_toolbar ) );
+                       space();
                        toolbar_append_toggle_button( filter_toolbar, "Entities (ALT + 2)", "f-entities.png", "FilterEntities" );
                        toolbar_append_toggle_button( filter_toolbar, "Lights (ALT + 0)", "f-lights.png", "FilterLights" );
                        toolbar_append_toggle_button( filter_toolbar, "Models (SHIFT + M)", "f-models.png", "FilterModels" );
 
-                       button = toolbar_append_toggle_button( filter_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( filter_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( filter_toolbar, "Decals (SHIFT + D)", "f-decals.png", "FilterDecals" );
-                       gtk_toolbar_append_space( GTK_TOOLBAR( filter_toolbar ) );
+                       space();
                        toolbar_append_button( filter_toolbar, "InvertFilters", "f-invert.png", "InvertFilters" );
                        toolbar_append_button( filter_toolbar, "ResetFilters", "f-reset.png", "ResetFilters" );
                        return filter_toolbar;
index 7b2888bb03ab93be8609bda239087e9d2de6bee9..ee7053666b439f8caf71e7e598cd3e3d641f4761 100644 (file)
@@ -1,16 +1,8 @@
 #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
index 3ff4ddd0703c2290f65624d66ac96a9397ab7029..3957af62e41b74fd9df16a629fb07b006d0ce800 100644 (file)
@@ -127,10 +127,10 @@ ToggleFilterFlag( unsigned int mask ) : m_mask( mask ), m_item( ActiveCaller( *t
 }
 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();
@@ -141,7 +141,7 @@ void reset(){
        m_item.update();
        PerformFiltering();
 }
-typedef MemberCaller<ToggleFilterFlag, &ToggleFilterFlag::toggle> ToggleCaller;
+typedef MemberCaller<ToggleFilterFlag, void(), &ToggleFilterFlag::toggle> ToggleCaller;
 };
 
 
@@ -171,7 +171,7 @@ void ResetFilters(){
        }
 }
 
-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" ) {
@@ -216,10 +216,10 @@ void Filters_constructMenu( GtkMenu* menu_in_menu ){
 #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 ) );
index 97766ab8c312bf6ba639abf902bba18698279735..9779585a5e84d88a98ae67ac4b93d3c707917616 100644 (file)
    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
index 5fd58f7c426a7a1f0a001e3fdee569497918f3e6..d74fc6578ac7dcabc442a1ee328a58019e839659 100644 (file)
 
 #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"
 
@@ -60,14 +50,14 @@ static void setReplaceStr( const char* name );
 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();
 }
@@ -95,33 +85,33 @@ void FindTextureDialog_apply(){
        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;
 }
@@ -137,83 +127,76 @@ FindTextureDialog::FindTextureDialog(){
 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 ));
 
-       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:" );
-       gtk_widget_show( label );
-       gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       label = ui::Label( "Replace:" );
+       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 ) );
-
-       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) ( 0 ), 0, 0 );
-       g_signal_connect( G_OBJECT( entry ), "focus_in_event",
+       AddDialogData( entry, m_strFind );
+       GlobalTextureEntryCompletion::instance().connect( entry );
+
+       entry = ui::Entry(ui::New);
+       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;
 }
@@ -231,7 +214,7 @@ void FindTextureDialog::updateTextures( const char* name ){
 }
 
 bool FindTextureDialog::isOpen(){
-       return GTK_WIDGET_VISIBLE( g_FindTextureDialog.GetWidget() ) == TRUE;
+       return g_FindTextureDialog.GetWidget().visible();
 }
 
 void FindTextureDialog::setFindStr( const char* name ){
@@ -251,7 +234,7 @@ void FindTextureDialog::show(){
 }
 
 
-void FindTextureDialog_constructWindow( GtkWindow* main_window ){
+void FindTextureDialog_constructWindow( ui::Window main_window ){
        g_FindTextureDialog.constructWindow( main_window );
 }
 
index 2bf06dbbde57f02295ed75bd9cb9bcb327a57d28..66022e8b3451cd4c57415e032fcb7906a999e955 100644 (file)
    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 );
index 38e11239434071ddfc92d8f191eba3cd87a81b6e..8bfb21af194d6b1a99c1e015c654e302fc6b6de2 100644 (file)
@@ -133,11 +133,11 @@ void set(){
        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 );
@@ -192,10 +192,10 @@ void ToggleGridSnap(){
 }
 
 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 ) );
@@ -212,7 +212,7 @@ void Grid_registerCommands(){
 }
 
 
-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" );
@@ -246,7 +246,7 @@ void Grid_constructPage( PreferenceGroup& group ){
        Grid_constructPreferences( page );
 }
 void Grid_registerPreferencesPage(){
-       PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Grid_constructPage>() );
+       PreferencesDialog_addSettingsPage( makeCallbackF(Grid_constructPage) );
 }
 
 void Grid_construct(){
@@ -254,7 +254,7 @@ 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 );
index 53b717c12aebd2acfb5b81791ef172bc1abe8c45..d3c28ec27d5d0631f7c38ca8cc391f2032f6df65 100644 (file)
@@ -22,6 +22,7 @@
 #if !defined( INCLUDED_GRID_H )
 #define INCLUDED_GRID_H
 
+#include <uilib/uilib.h>
 #include "signal/signalfwd.h"
 
 float GetSnapGridSize();
@@ -31,8 +32,7 @@ int Grid_getPower();
 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();
 
index dc94603bfa7c9668bec2130e6ec10d15a64bbe67..ad64793f6ef4e34ab423bfcc9b6afdb6e877efbe 100644 (file)
 //
 
 #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 ){
@@ -69,10 +67,11 @@ void Show(){
                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;
@@ -83,30 +82,30 @@ namespace
 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 );
 
@@ -114,7 +113,7 @@ void GroupDlg::Create( GtkWindow* parent ){
 
        m_window = window;
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        if ( g_multimon_globals.m_bStartOnPrimMon ) {
                WindowPosition pos( m_position_tracker.getPosition() );
                PositionWindowOnPrimaryScreen( pos );
@@ -124,21 +123,21 @@ void GroupDlg::Create( GtkWindow* parent ){
        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;
@@ -146,7 +145,7 @@ GtkWidget* GroupDialog_addPage( const char* tabLabel, GtkWidget* widget, const S
 
 
 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();
@@ -155,39 +154,39 @@ void GroupDialog_ToggleShow(){
        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 );
        }
 }
@@ -197,7 +196,7 @@ void GroupDialog_cycle(){
        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 );
        }
@@ -207,9 +206,9 @@ void GroupDialog_updatePageTitle( GtkWidget* 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(){
 }
index 349802b17b7696d6ff790ba5d890c82fb7c8f374..f136f382c02f116f2c62123f5467f6f315a51b11 100644 (file)
 #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
index 57479b321727d8bdf4334e4319090cf24952af55..0a2206069f6a78f98c009dfc6abde978bc32f126 100644 (file)
@@ -35,6 +35,9 @@
 //
 
 #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 "os/path.h"
 #include "math/aabb.h"
@@ -170,11 +158,11 @@ inline void path_copy_clean( char* destination, const char* source ){
 
 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;
@@ -184,8 +172,8 @@ gboolean OnSelchangeComboWhatgame( GtkWidget *widget, GameCombo* combo ){
 
        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;
 }
@@ -214,97 +202,81 @@ class ProjectSettingsDialog
 {
 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;
                                }
@@ -317,8 +289,8 @@ GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal
        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();
@@ -369,13 +341,13 @@ void DoProjectSettings(){
                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();
        //}
 }
 
@@ -384,41 +356,40 @@ void DoProjectSettings(){
 
 void DoSides( int type, int axis ){
        ModalDialog dialog;
-       GtkEntry* sides_entry;
 
-       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  );
                }
                {
-                       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 );
                        }
                }
        }
@@ -429,21 +400,27 @@ void DoSides( int type, int axis ){
                Scene_BrushConstructPrefab( GlobalSceneGraph(), (EBrushPrefab)type, atoi( str ), 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() );
 }
 
@@ -451,131 +428,125 @@ void DoAbout(){
        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_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 );
                                }
                                {
-                                       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 );
                                }
                        }
                }
                {
-                       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();
                                        }
                                }
                        }
@@ -584,7 +555,7 @@ void DoAbout(){
 
        modal_dialog_show( window, dialog );
 
-       gtk_widget_destroy( GTK_WIDGET( window ) );
+       window.destroy();
 }
 
 // =============================================================================
@@ -598,82 +569,74 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){
        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 );
                        }
                }
        }
@@ -682,13 +645,13 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){
        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(  );
 
        EMessageBoxReturn ret = modal_dialog_show( window, dialog );
        if ( ret == eIDOK ) {
@@ -700,7 +663,7 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){
                last_used_texture_layout_scale_y = *fy;
        }
 
-       gtk_widget_destroy( GTK_WIDGET( window ) );
+       window.destroy();
 
        return ret;
 }
@@ -709,26 +672,26 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){
 // 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;
        }
 
@@ -747,58 +710,55 @@ static void editor_save( GtkWidget *widget, gpointer data ){
        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 );
 
-       dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
-
-       g_signal_connect( G_OBJECT( dlg ), "delete_event",
+       dlg.connect( "delete_event",
                                          G_CALLBACK( editor_delete ), 0 );
-       gtk_window_set_default_size( GTK_WINDOW( dlg ), 400, 600 );
+       gtk_window_set_default_size( dlg, 400, 300 );
 
-       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;
@@ -814,7 +774,7 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos, int length )
 
        if ( f == 0 ) {
                globalOutputStream() << "Unable to load file " << filename << " in shader editor.\n";
-               gtk_widget_hide( text_editor );
+               text_editor.hide();
        }
        else
        {
@@ -826,9 +786,9 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos, int length )
                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" );
@@ -838,11 +798,11 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos, int length )
                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..
@@ -857,7 +817,7 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos, int length )
                        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
 
@@ -872,64 +832,64 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos, int length )
 
 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;
 }
@@ -937,53 +897,51 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){
 // =============================================================================
 // 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 );
                        }
                }
        }
@@ -993,69 +951,69 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){
                *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
@@ -1065,7 +1023,7 @@ CopiedString g_TextEditor_editorCommand( "" );
 #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 );
@@ -1076,11 +1034,11 @@ void DoTextEditor( const char* filename, int cursorpos, int length ){
                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 << "\n";
index a0ad74018e8d6fd37d02654d9593b2c4847ed630..78646534e04531ac1306a03a693306235c435a9c 100644 (file)
 #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 );
 
@@ -47,7 +48,7 @@ void DoSides( int type, int axis );
 void DoAbout();
 
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 extern bool g_TextEditor_useWin32Editor;
 #else
 #include "string/stringfwd.h"
index 59dab2a9187265a454ad75883178f2d941b8f259..702f6ac4e38a339b2c7743bfccf60608495d7400 100644 (file)
 // 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"
@@ -43,7 +43,6 @@
 #include "gtkutil/dialog.h"
 #include "gtkutil/filechooser.h"
 #include "gtkutil/menu.h"
-#include "gtkutil/toolbar.h"
 #include "commands.h"
 
 
@@ -72,83 +71,75 @@ void toggle_remove_accelerator( const char* name ){
        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 );
        }
index 14cdd8168031fa0458bb01e4b419aa0bf96b4bb1..2019452b90720b85b39922c1567ffdf63c3e16dd 100644 (file)
 #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
index 0f3604a8d6802de35fc143b22611e23feb672777..c9508f55e9c1fa7d67e0e4c2157502899145cf19 100644 (file)
@@ -6,6 +6,8 @@
     email                : ashaduri '@' gmail.com
  ***************************************************************************/
 
+#define GARUX_DISABLE_GTKTHEME
+#ifndef GARUX_DISABLE_GTKTHEME
 
 #include <iostream>
 #include <fstream>
@@ -752,3 +754,5 @@ void apply_theme(const std::string& theme_name, const std::string& font)
 
 
 }
+
+#endif // GARUX_DISABLE_GTKTHEME
index 79425947fc50ba029387a7a92a15a375acd51b62..9aa723d8e9c9ef0f112db44424895dd5af1cd514 100644 (file)
@@ -6,9 +6,14 @@
     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
index d5319f30c0469575d9091c8baa81e483b56c7914..b11743d69319a9af587cf71b2302ec9330e4fb7e 100644 (file)
@@ -51,13 +51,13 @@ void HandleHelpCommand( CopiedString& str ){
        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 );
                        }
@@ -75,7 +75,8 @@ void process_xlink( const char* filename, const char *menu_name, const char *bas
 
                                                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 );
                                                }
@@ -93,7 +94,7 @@ void process_xlink( const char* filename, const char *menu_name, const char *bas
 
                                                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;
@@ -112,7 +113,7 @@ void process_xlink( const char* filename, const char *menu_name, const char *bas
        }
 }
 
-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 );
index d7e6263cbd6b4978c01b94007bff51790ae2bdce..1e85100a3b8978fb3eecbcaacdf29e9d561f269c 100644 (file)
    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
index f7f6cf6b27265fc6b198e0fbec13f8f2469568c0..88cd0cad4fd89e7a774ca8941be1a9fbd5b60144 100644 (file)
@@ -49,7 +49,7 @@
    \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
@@ -62,6 +62,7 @@
  */
 
 #include "main.h"
+#include "globaldefs.h"
 
 #include "version.h"
 
@@ -69,7 +70,7 @@
 
 #include "iundo.h"
 
-#include <gtk/gtkmain.h>
+#include "uilib/uilib.h"
 
 #include "cmdlib.h"
 #include "os/file.h"
@@ -89,7 +90,7 @@
 #include "referencecache.h"
 #include "stacktrace.h"
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 #include <windows.h>
 #endif
 
@@ -208,19 +209,17 @@ void error_redirect( const gchar *domain, GLogLevelFlags log_level, const gchar
        // 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
 }
@@ -303,16 +302,16 @@ bool handleMessage(){
        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;
 }
@@ -326,14 +325,7 @@ void streams_init(){
 }
 
 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() );
 
@@ -376,34 +368,31 @@ bool check_version(){
        // 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(){
@@ -426,25 +415,26 @@ 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
@@ -467,7 +457,7 @@ void remove_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 );
        }
 }
 
@@ -485,25 +475,26 @@ void create_local_pid(){
                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;
@@ -544,6 +535,15 @@ void user_shortcuts_save(){
 }
 
 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";
@@ -556,6 +556,7 @@ void add_local_rc_files(){
                gtk_rc_add_default_file( path.c_str() );
        }
 #endif
+#endif // GARUX_DISABLE_GTKTHEME
 }
 
 int main( int argc, char* argv[] ){
@@ -563,7 +564,7 @@ int main( int argc, char* argv[] ){
 
        streams_init();
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        HMODULE lib;
        lib = LoadLibrary( "dwmapi.dll" );
        if ( lib != 0 ) {
@@ -587,9 +588,33 @@ int main( int argc, char* argv[] ){
        _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 |
@@ -605,7 +630,7 @@ int main( int argc, char* argv[] ){
 
        GlobalDebugMessageHandler::instance().setHandler( GlobalPopupDebugMessageHandler::instance() );
 
-       environment_init( argc, argv );
+       environment_init(argc, (char const **) argv);
 
        paths_init();
 
@@ -643,8 +668,6 @@ int main( int argc, char* argv[] ){
 
        Radiant_Initialise();
 
-       global_accel_init();
-
        user_shortcuts_init();
 
        g_pParentWnd = 0;
@@ -658,7 +681,10 @@ int main( int argc, char* argv[] ){
        }
        else
 #endif // WIN32
-       if ( g_bLoadLastMap && !g_strLastMap.empty() ) {
+       if ( mapname != NULL ) {
+               Map_LoadFile( mapname );
+       }
+       else if ( g_bLoadLastMap && !g_strLastMap.empty() ) {
                Map_LoadFile( g_strLastMap.c_str() );
        }
        else
@@ -673,7 +699,7 @@ int main( int argc, char* argv[] ){
 
        remove_local_pid();
 
-       gtk_main();
+       ui::main();
 
        // avoid saving prefs when the app is minimized
        if ( g_pParentWnd->IsSleeping() ) {
@@ -691,8 +717,6 @@ int main( int argc, char* argv[] ){
 
        user_shortcuts_save();
 
-       global_accel_destroy();
-
        Radiant_Shutdown();
 
        // close the log file if any
index 60f3a5eb372dd73bb353bbce7db1e04f544f073e..38c46fafefbcf3a4db7abf1b92ff054242f3a183 100644 (file)
 //
 
 #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
@@ -148,22 +135,48 @@ glwindow_globals_t g_glwindow_globals;
 
 
 // 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();
 }
 };
 
@@ -172,13 +185,14 @@ VFSModuleObserver g_VFSModuleObserver;
 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}};
@@ -188,6 +202,7 @@ const GUID qFOLDERID_SavedGames = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D
 typedef HRESULT ( WINAPI qSHGetKnownFolderPath_t )( qREFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath );
 static qSHGetKnownFolderPath_t *qSHGetKnownFolderPath;
 #endif
+
 void HomePaths_Realise(){
        do
        {
@@ -195,16 +210,18 @@ void HomePaths_Realise(){
                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" );
@@ -243,7 +260,7 @@ void HomePaths_Realise(){
                        }
 #endif
 
-#if defined( POSIX )
+#if GDEF_OS_POSIX
                        path.clear();
                        path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/";
                        g_qeglobals.m_userEnginePath = path.c_str();
@@ -282,12 +299,14 @@ std::size_t m_unrealised;
 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();
@@ -300,6 +319,7 @@ HomePathsModuleObserver g_HomePathsModuleObserver;
 void HomePaths_Construct(){
        Radiant_attachEnginePathObserver( g_HomePathsModuleObserver );
 }
+
 void HomePaths_Destroy(){
        Radiant_detachEnginePathObserver( g_HomePathsModuleObserver );
 }
@@ -366,6 +386,59 @@ void setEnginePath( const char* path ){
        }
 }
 
+// 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
 
@@ -389,6 +462,7 @@ const char* LocalRcPath_get( void ){
 /// 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();
 }
@@ -409,41 +483,129 @@ const char* GameToolsPath_get(){
        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 ));
 }
 };
 
@@ -515,36 +677,30 @@ void gamemode_set( const char* gamemode ){
        }
 }
 
-#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 ){
@@ -576,11 +732,13 @@ std::size_t m_unrealised;
 public:
 WorldspawnColourEntityClassObserver() : m_unrealised( 1 ){
 }
+
 void realise(){
        if ( --m_unrealised == 0 ) {
                SetWorldspawnColour( g_xywindow_globals.color_brushes );
        }
 }
+
 void unrealise(){
        if ( ++m_unrealised == 1 ) {
        }
@@ -793,8 +951,8 @@ void ColorScheme_Ydnar(){
        XY_UpdateAllWindows();
 }
 
-typedef Callback1<Vector3&> GetColourCallback;
-typedef Callback1<const Vector3&> SetColourCallback;
+typedef Callback<void(Vector3&)> GetColourCallback;
+typedef Callback<void(const Vector3&)> SetColourCallback;
 
 class ChooseColour
 {
@@ -804,50 +962,56 @@ public:
 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
@@ -888,14 +1052,14 @@ 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 );
        }
@@ -905,7 +1069,9 @@ GtkMenuItem* create_colours_menu(){
        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 );
 
@@ -945,59 +1111,39 @@ void thunk_OnSleep(){
        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 );
@@ -1024,24 +1170,24 @@ template<bool( *BoolFunction ) ( )>
 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(){
@@ -1138,6 +1284,7 @@ NodeSmartReference worldspawn;
 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;
@@ -1159,6 +1306,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
 
        return true;
 }
+
 void post( const scene::Path& path, scene::Instance& instance ) const {
        if ( path.size() == 1 ) {
                return;
@@ -1203,6 +1351,7 @@ struct AxisBase
        Vector3 x;
        Vector3 y;
        Vector3 z;
+
        AxisBase( const Vector3& x_, const Vector3& y_, const Vector3& z_ )
                : x( x_ ), y( y_ ), z( z_ ){
        }
@@ -1315,44 +1464,44 @@ void Selection_NudgeRight(){
 }
 
 
-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(){
@@ -1539,6 +1688,7 @@ public:
 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() );
@@ -1562,6 +1712,7 @@ public:
 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 );
@@ -1609,47 +1760,47 @@ guint s_qe_every_second_id = 0;
 
 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;
 }
@@ -1675,7 +1826,7 @@ bool MainFrame_isActiveApp(){
        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;
                }
@@ -1693,8 +1844,8 @@ bool ScreenUpdates_Enabled(){
 }
 
 void ScreenUpdates_process(){
-       if ( redrawRequired() && GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
-               process_gui();
+       if ( redrawRequired() && g_wait.m_window.visible() ) {
+               ui::process();
        }
 }
 
@@ -1703,20 +1854,20 @@ void ScreenUpdates_Disable( const char* message, const char* title ){
        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 );
@@ -1727,22 +1878,21 @@ void ScreenUpdates_Enable(){
        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() );
@@ -1795,18 +1945,17 @@ void ClipperChangeNotify(){
 }
 
 
-LatchedInt g_Layout_viewStyle( 0, "Window Layout" );
-LatchedBool g_Layout_enableDetachableMenus( true, "Detachable Menus" );
-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_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 );
        }
@@ -1826,7 +1975,7 @@ GtkMenuItem* create_file_menu(){
        create_menu_item_with_mnemonic( menu, "_Import...", "ImportMap" );
        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" );
        menu_separator( menu );
        create_menu_item_with_mnemonic( menu, "Save re_gion...", "SaveRegion" );
 //     menu_separator( menu );
@@ -1844,10 +1993,10 @@ GtkMenuItem* create_file_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 );
        }
@@ -1872,7 +2021,7 @@ GtkMenuItem* create_edit_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 );
 //     }
@@ -1885,30 +2034,30 @@ GtkMenuItem* create_edit_menu(){
        return edit_menu_item;
 }
 
-void fill_view_xy_top_menu( GtkMenu* menu ){
+void fill_view_xy_top_menu( ui::Menu menu ){
        create_check_menu_item_with_mnemonic( menu, "XY (Top) View", "ToggleView" );
 }
 
 
-void fill_view_yz_side_menu( GtkMenu* menu ){
+void fill_view_yz_side_menu( ui::Menu menu ){
        create_check_menu_item_with_mnemonic( menu, "YZ (Side) View", "ToggleSideView" );
 }
 
 
-void fill_view_xz_front_menu( GtkMenu* menu ){
+void fill_view_xz_front_menu( ui::Menu menu ){
        create_check_menu_item_with_mnemonic( menu, "XZ (Front) View", "ToggleFrontView" );
 }
 
 
-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 );
        }
@@ -1934,7 +2083,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
 
        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 );
                }
@@ -1953,7 +2102,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
        }
        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 );
                }
@@ -1975,7 +2124,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
        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 );
                }
@@ -1996,7 +2145,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
        }
 
        {
-               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 );
                }
@@ -2015,7 +2164,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
        }
        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 );
                }
@@ -2030,16 +2179,16 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
        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 );
                }
@@ -2051,7 +2200,7 @@ GtkMenuItem* create_selection_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 );
                }
@@ -2061,7 +2210,7 @@ GtkMenuItem* create_selection_menu(){
                create_menu_item_with_mnemonic( menu_in_menu, "Nudge Down", "SelectNudgeDown" );
        }
        {
-               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 );
                }
@@ -2070,7 +2219,7 @@ GtkMenuItem* create_selection_menu(){
                create_menu_item_with_mnemonic( menu_in_menu, "Rotate Z", "RotateSelectionZ" );
        }
        {
-               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 );
                }
@@ -2085,10 +2234,10 @@ GtkMenuItem* create_selection_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 );
@@ -2105,10 +2254,10 @@ GtkMenuItem* create_bsp_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 );
        }
@@ -2118,31 +2267,31 @@ GtkMenuItem* create_grid_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 select", FreeCaller<WXY_BackgroundSelect>() );
+//  create_menu_item_with_mnemonic(menu, "_Print XY View", FreeCaller<void(), WXY_Print>());
+       create_menu_item_with_mnemonic( menu, "_Background select", makeCallbackF(WXY_BackgroundSelect) );
        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 );
        }
@@ -2152,10 +2301,10 @@ GtkMenuItem* create_entity_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 );
        }
@@ -2165,10 +2314,10 @@ GtkMenuItem* create_brush_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 );
        }
@@ -2178,10 +2327,10 @@ GtkMenuItem* create_patch_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 );
        }
@@ -2192,29 +2341,29 @@ GtkMenuItem* create_help_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 list", 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 list", 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;
 }
@@ -2227,10 +2376,10 @@ void PatchInspector_registerShortcuts(){
 void Patch_registerShortcuts(){
 //     command_connect_accelerator( "InvertCurveTextureX" );
 //     command_connect_accelerator( "InvertCurveTextureY" );
-       command_connect_accelerator( "IncPatchColumn" );
-       command_connect_accelerator( "IncPatchRow" );
-       command_connect_accelerator( "DecPatchColumn" );
-       command_connect_accelerator( "DecPatchRow" );
+       command_connect_accelerator( "PatchInsertInsertColumn" );
+       command_connect_accelerator( "PatchInsertInsertRow" );
+       command_connect_accelerator( "PatchDeleteLastColumn" );
+       command_connect_accelerator( "PatchDeleteLastRow" );
 //     command_connect_accelerator( "NaturalizePatch" );
        //command_connect_accelerator("CapCurrentCurve");
 }
@@ -2294,17 +2443,17 @@ void register_shortcuts(){
 //     SelectByType_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" );
@@ -2313,34 +2462,34 @@ void RotateFlip_constructToolbar( GtkToolbar* toolbar ){
        toolbar_append_button( toolbar, "z-axis Rotate", "brush_rotatez.png", "RotateSelectionZ" );
 }
 
-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, "Hollow", "selection_makehollow.png", "CSGHollow" );
-       toolbar_append_button( toolbar, "Room", "selection_makeroom.png", "CSGroom" );
+       toolbar_append_button( toolbar, "Make Hollow", "selection_makehollow.png", "CSGHollow" );
+       toolbar_append_button( toolbar, "Make Room", "selection_makeroom.png", "CSGRoom" );
 }
 
-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", "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", "select_mousescale.png", "MouseScale" );
@@ -2349,110 +2498,116 @@ void Manipulators_constructToolbar( GtkToolbar* toolbar ){
        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_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( GTK_TOOLBAR( toolbar ) );
+       space();
 
        UndoRedo_constructToolbar( toolbar );
 
-       gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+       space();
 
        RotateFlip_constructToolbar( toolbar );
 
-       gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+       space();
 
        Select_constructToolbar( toolbar );
 
-       gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+       space();
 
        CSG_constructToolbar( toolbar );
 
-       gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+       space();
 
        ComponentModes_constructToolbar( toolbar );
 
        if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating ) {
-               gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+               space();
 
                XYWnd_constructToolbar( toolbar );
        }
 
-       gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+       space();
 
        CamWnd_constructToolbar( toolbar );
 
-       gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+       space();
 
        Manipulators_constructToolbar( toolbar );
 
        if ( g_Layout_enablePatchToolbar.m_value ) {
-               gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+               space();
 
                Patch_constructToolbar( toolbar );
        }
 
-       gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+       space();
 
-       toolbar_append_toggle_button( toolbar, "Texture Lock (SHIFT + T)", "texture_lock.png", "TogTexLock" );
+       toolbar_append_toggle_button( toolbar, "Texture Lock (SHIFT +T)", "texture_lock.png", "TogTexLock" );
 
-       gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+       space();
 
-       GtkButton* g_view_entities_button = toolbar_append_button( toolbar, "Entities (N)", "entities.png", "ToggleEntityInspector" );
-       GtkButton* g_view_console_button = toolbar_append_button( toolbar, "Console (O)", "console.png", "ToggleConsole" );
-       GtkButton* g_view_textures_button = toolbar_append_button( toolbar, "Texture Browser (T)", "texture_browser.png", "ToggleTextures" );
+       /*auto g_view_entities_button =*/ toolbar_append_button( toolbar, "Entities (N)", "entities.png", "ToggleEntityInspector" );
+       auto g_view_console_button = toolbar_append_button( toolbar, "Console (O)", "console.png", "ToggleConsole" );
+       auto g_view_textures_button = 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( GTK_TOOLBAR( toolbar ) );
-       GtkButton* g_refresh_models_button = toolbar_append_button( toolbar, "Refresh Models", "refresh_models.png", "RefreshReferences" );
+       space();
+       /*auto g_refresh_models_button =*/ toolbar_append_button( toolbar, "Refresh Models", "refresh_models.png", "RefreshReferences" );
 
 
        // disable the console and texture button in the regular layouts
        if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft ) {
-               gtk_widget_set_sensitive( GTK_WIDGET( g_view_console_button ), FALSE );
-               gtk_widget_set_sensitive( GTK_WIDGET( g_view_textures_button ), FALSE );
+               gtk_widget_set_sensitive( g_view_console_button , FALSE );
+               gtk_widget_set_sensitive( g_view_textures_button , FALSE );
        }
 
        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
@@ -2464,15 +2619,15 @@ class WindowFocusPrinter
 {
 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";
        }
@@ -2485,11 +2640,11 @@ static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* s
 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 );
 }
 };
 
@@ -2499,16 +2654,17 @@ WindowFocusPrinter g_mainframeFocusPrinter( "mainframe" );
 
 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 );
 }
 };
 
@@ -2535,16 +2691,14 @@ void XYWindowMouseDown_disconnect( MouseEventHandlerId id ){
 
 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;
@@ -2552,9 +2706,8 @@ MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusText
        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;
@@ -2565,16 +2718,16 @@ MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusText
 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 ){
@@ -2636,7 +2789,7 @@ void MainFrame::CreateContexts(){
 #endif
 }
 
-#ifdef _DEBUG
+#if GDEF_DEBUG
 //#define DBG_SLEEP
 #endif
 
@@ -2694,35 +2847,35 @@ void MainFrame::OnSleep(){
 }
 
 
-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);
 
-       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;
@@ -2730,7 +2883,7 @@ WindowPositionTracker g_posXYWnd;
 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();
        }
@@ -2739,24 +2892,24 @@ static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data
 }
 
 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 ) {
                        gtk_window_set_icon( window, pixbuf );
-                       gdk_pixbuf_unref( pixbuf );
+                       g_object_unref( pixbuf );
                }
        }
 #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 );
 
@@ -2767,11 +2920,11 @@ void MainFrame::Create(){
 
        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();
 
        global_accel_connect_window( window );
 
@@ -2779,31 +2932,28 @@ void MainFrame::Create(){
 
        register_shortcuts();
 
-       GtkMenuBar* main_menu = create_main_menu( CurrentStyle() );
-       gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_menu ), FALSE, FALSE, 0 );
-
-       GtkToolbar* main_toolbar = create_main_toolbar( CurrentStyle() );
-       gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_toolbar ), FALSE, FALSE, 0 );
-
-
+    auto main_menu = create_main_menu( CurrentStyle() );
+       vbox.pack_start( main_menu, FALSE, FALSE, 0 );
 
+    auto main_toolbar = create_main_toolbar( CurrentStyle() );
+       vbox.pack_start( 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 );
                }
        }
 
@@ -2812,11 +2962,8 @@ void MainFrame::Create(){
                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_entity = GroupDialog_addPage( "Entities", EntityInspector_constructWindow( GroupDialog_getWindow() ), RawStringExportCaller( "Entities" ) );
@@ -2825,7 +2972,7 @@ void MainFrame::Create(){
                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 );
                window_set_position( window, g_layout_globals.m_position );
@@ -2844,21 +2991,25 @@ void MainFrame::Create(){
 
        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_add1( GTK_PANED( hsplit ), vsplit );
                                        gtk_paned_add2( GTK_PANED( hsplit ), vsplit2 );
@@ -2867,28 +3018,30 @@ void MainFrame::Create(){
                                        gtk_paned_add2( GTK_PANED( hsplit ), vsplit );
                                        gtk_paned_add1( GTK_PANED( hsplit ), vsplit2 );
                                }
+
                                // console
-                               GtkWidget* console_window = Console_constructWindow( window );
+                               ui::Widget console_window = Console_constructWindow( window );
                                gtk_paned_pack2( GTK_PANED( vsplit ), console_window, FALSE, 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_add1( GTK_PANED( vsplit ), xy_window );
+
                                {
                                        // 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_add1( GTK_PANED( vsplit2 ), GTK_WIDGET( camera_window ) );
+                                       gtk_paned_add1( GTK_PANED( vsplit2 ), camera_window  );
 
                                        // textures
-                                       GtkFrame* texture_window = create_framed_widget( TextureBrowser_constructWindow( window ) );
+                                       auto texture_window = create_framed_widget( TextureBrowser_constructWindow( window ) );
 
-                                       gtk_paned_add2( GTK_PANED( vsplit2 ), GTK_WIDGET( texture_window ) );
+                                       gtk_paned_add2( GTK_PANED( vsplit2 ), texture_window  );
                                }
                        }
                }
@@ -2907,28 +3060,31 @@ void MainFrame::Create(){
        }
        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 );
 
@@ -2938,18 +3094,20 @@ void MainFrame::Create(){
 
 
                        {
-                               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 );
 
@@ -2958,19 +3116,21 @@ void MainFrame::Create(){
                        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 );
 
@@ -2979,22 +3139,26 @@ void MainFrame::Create(){
                        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
 
                }
 
@@ -3006,31 +3170,33 @@ void MainFrame::Create(){
                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();
 
-               GtkHPaned* split = create_split_views( camera, yz, xy, xz );
-               gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( split ), TRUE, TRUE, 0 );
+        auto split = create_split_views( camera, yz, xy, xz );
+               vbox.pack_start( split, TRUE, TRUE, 0 );
 
                {
-                       GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( window ) );
-                       g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() );
+            auto frame = create_framed_widget( TextureBrowser_constructWindow( window ) );
+                       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
                }
        }
 
@@ -3043,7 +3209,7 @@ void MainFrame::Create(){
        SetActiveXY( m_pXYWnd );
 
        AddGridChangeCallback( SetGridStatusCaller( *this ) );
-       AddGridChangeCallback( ReferenceCaller<MainFrame, XY_UpdateAllWindows>( *this ) );
+       AddGridChangeCallback( ReferenceCaller<MainFrame, void(), XY_UpdateAllWindows>( *this ) );
 
        g_defaultToolMode = DragMode;
        g_defaultToolMode();
@@ -3071,7 +3237,7 @@ void MainFrame::SaveWindowInfo(){
 
        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(){
@@ -3103,11 +3269,11 @@ 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(){
@@ -3134,8 +3300,11 @@ int getFarClipDistance(){
 }
 
 float ( *GridStatus_getGridSize )() = GetGridSize;
+
 int ( *GridStatus_getRotateIncrement )() = getRotateIncrement;
+
 int ( *GridStatus_getFarClipDistance )() = getFarClipDistance;
+
 bool ( *GridStatus_getTextureLockEnabled )();
 
 void MainFrame::SetGridStatus(){
@@ -3161,7 +3330,8 @@ void GlobalGL_sharedContextCreated(){
        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() );
 
@@ -3170,11 +3340,11 @@ void GlobalGL_sharedContextCreated(){
        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 );
@@ -3197,31 +3367,26 @@ void Layout_constructPreferences( PreferencesPage& page ){
                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 )
                );
        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 )
                );
 }
 
@@ -3231,7 +3396,7 @@ void Layout_constructPage( PreferenceGroup& group ){
 }
 
 void Layout_registerPreferencesPage(){
-       PreferencesDialog_addInterfacePage( FreeCaller1<PreferenceGroup&, Layout_constructPage>() );
+       PreferencesDialog_addInterfacePage( makeCallbackF(Layout_constructPage) );
 }
 
 
@@ -3239,81 +3404,82 @@ void Layout_registerPreferencesPage(){
 #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' ) );
-
-       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' ) );
-
-       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( "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( "BuildMenuCustomize", FreeCaller<DoBuildMenu>() );
-
-       GlobalCommands_insert( "FindBrush", FreeCaller<DoFind>() );
-
-       GlobalCommands_insert( "MapInfo", FreeCaller<DoMapInfo>(), Accelerator( 'M' ) );
-
-
-       GlobalToggles_insert( "ToggleClipper", FreeCaller<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 ), 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>() );
+       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' ) );
+
+       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( "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( "ArbitraryRotation", makeCallbackF(DoRotateDlg) );
+       GlobalCommands_insert( "ArbitraryScale", makeCallbackF(DoScaleDlg) );
+
+       GlobalCommands_insert( "BuildMenuCustomize", makeCallbackF(DoBuildMenu) );
+
+       GlobalCommands_insert( "FindBrush", makeCallbackF(DoFind) );
+
+       GlobalCommands_insert( "MapInfo", makeCallbackF(DoMapInfo), Accelerator( 'M' ) );
+
+
+       GlobalToggles_insert( "ToggleClipper", makeCallbackF(ClipperMode), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) );
+
+       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 ), Accelerator( 'Q' ) );
+
+#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 ) );
@@ -3330,74 +3496,74 @@ void MainFrame_Construct(){
        GlobalCommands_insert( "ChooseOrthoViewNameColor", makeCallback( g_ColoursMenu.m_viewname ) );
 
 
-       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( "CSGHollow", FreeCaller<CSG_MakeHollow>() );
-       GlobalCommands_insert( "CSGroom", FreeCaller<CSG_MakeRoom>() );
+       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( "CSGHollow", makeCallbackF(CSG_MakeHollow) );
+       GlobalCommands_insert( "CSGRoom", makeCallbackF(CSG_MakeRoom) );
 
        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( "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( "DetachableMenus", make_property_string( g_Layout_enableDetachableMenus.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 ) );
        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
@@ -3405,10 +3571,16 @@ void MainFrame_Construct(){
                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();
@@ -3419,8 +3591,8 @@ void MainFrame_Construct(){
        Layout_registerPreferencesPage();
        Paths_registerPreferencesPage();
 
-       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;
@@ -3433,13 +3605,13 @@ void MainFrame_Destroy(){
        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(){
index 0b008a6b4625ff38c0829ebfb6b4c55796aa7874..85e60f47eb6ba671cc61c10c75d90c276b2df0c2 100644 (file)
@@ -22,6 +22,7 @@
 #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"
@@ -36,8 +37,6 @@ class XYWnd;
 class CamWnd;
 class ZWnd;
 
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
 
 const int c_command_status = 0;
 const int c_position_status = 1;
@@ -60,7 +59,7 @@ enum EViewStyle
 MainFrame();
 ~MainFrame();
 
-GtkWindow* m_window;
+ui::Window m_window{ui::null};
 
 CopiedString m_command_status;
 CopiedString m_position_status;
@@ -73,9 +72,9 @@ void Create();
 void SaveWindowInfo();
 void Shutdown();
 
-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};
 
 XYWnd* m_pXYWnd;
 XYWnd* m_pYZWnd;
@@ -86,7 +85,7 @@ XYWnd* m_pActiveXY;
 
 bool m_bSleeping;
 
-GtkWidget *m_pStatusLabel[c_count_status];
+void *m_pStatusLabel[c_count_status];
 
 
 EViewStyle m_nCurrentStyle;
@@ -104,10 +103,10 @@ void OnSleep();
 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(){
@@ -142,7 +141,7 @@ bool FloatingGroupDialog(){
 
 extern MainFrame* g_pParentWnd;
 
-GtkWindow* MainFrame_getWindow();
+ui::Window MainFrame_getWindow();
 
 enum EMouseButtonMode
 {
@@ -165,8 +164,7 @@ void GLWindow_Destroy();
 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();
 
@@ -207,6 +205,13 @@ void EnginePath_verify();
 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();
 
@@ -245,8 +250,8 @@ void gamemode_set( const char* gamemode );
 void Radiant_attachGameModeObserver( ModuleObserver& observer );
 void Radiant_detachGameModeObserver( ModuleObserver& observer );
 
-
-
+void VFS_Refresh();
+void VFS_Restart();
 void VFS_Construct();
 void VFS_Destroy();
 
@@ -271,6 +276,6 @@ void XYWindowDestroyed_disconnect( SignalHandlerId id );
 MouseEventHandlerId XYWindowMouseDown_connect( const MouseEventHandler& handler );
 void XYWindowMouseDown_disconnect( MouseEventHandlerId id );
 
-extern GtkWidget* g_page_entity;
+extern ui::Widget g_page_entity;
 
 #endif
index e664667bb0860f50478a41593a14323c19b775aa..a192231e30e63b02a911a9dd8af3d19425087cb7 100644 (file)
 
 #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"
@@ -35,21 +39,15 @@ MapModules& ReferenceAPI_getMapModules();
 #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"
@@ -61,6 +59,7 @@ MapModules& ReferenceAPI_getMapModules();
 #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"
@@ -80,6 +79,7 @@ MapModules& ReferenceAPI_getMapModules();
 #include "xywindow.h"
 #include "mainframe.h"
 #include "preferences.h"
+#include "preferencesystem.h"
 #include "referencecache.h"
 #include "mru.h"
 #include "commands.h"
@@ -87,6 +87,8 @@ MapModules& ReferenceAPI_getMapModules();
 #include "brushmodule.h"
 #include "brush.h"
 
+bool g_writeMapComments = true;
+
 class NameObserver
 {
 UniqueNames& m_names;
@@ -98,6 +100,7 @@ void construct(){
                m_names.insert( name_read( c_str() ) );
        }
 }
+
 void destroy(){
        if ( !empty() ) {
                //globalOutputStream() << "destroy " << makeQuoted(c_str()) << "\n";
@@ -106,6 +109,7 @@ void destroy(){
 }
 
 NameObserver& operator=( const NameObserver& other );
+
 public:
 NameObserver( UniqueNames& names ) : m_names( names ){
        construct();
@@ -113,21 +117,26 @@ NameObserver( UniqueNames& names ) : m_names( names ){
 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
@@ -139,12 +148,14 @@ public:
 ~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" );
@@ -199,11 +210,13 @@ class NamespaceAPI
 Namespace* m_namespace;
 public:
 typedef Namespace Type;
+
 STRING_CONSTANT( Name, "*" );
 
 NamespaceAPI(){
        m_namespace = &g_defaultNamespace;
 }
+
 Namespace* getTable(){
        return m_namespace;
 }
@@ -261,6 +274,7 @@ public:
 WorldNode()
        : m_node( 0 ){
 }
+
 void set( scene::Node* node ){
        if ( m_node != 0 ) {
                m_node->DecRef();
@@ -270,6 +284,7 @@ void set( scene::Node* node ){
                m_node->IncRef();
        }
 }
+
 scene::Node* get() const {
        return m_node;
 }
@@ -277,7 +292,9 @@ scene::Node* get() const {
 
 class Map;
 void Map_SetValid( Map& map, bool valid );
+
 void Map_UpdateTitle( const Map& map );
+
 void Map_SetWorldspawn( Map& map, scene::Node* node );
 
 
@@ -289,6 +306,7 @@ Resource* m_resource;
 bool m_valid;
 
 bool m_modified;
+
 void ( *m_modified_changed )( const Map& );
 
 Signal0 m_mapValidCallbacks;
@@ -319,6 +337,7 @@ void realise(){
                Map_SetValid( g_map, true );
        }
 }
+
 void unrealise(){
        if ( m_resource != 0 ) {
                Map_SetValid( g_map, false );
@@ -386,7 +405,6 @@ void Map_UpdateTitle( const Map& map ){
 }
 
 
-
 scene::Node* Map_GetWorldspawn( const Map& map ){
        return map.m_world_node.get();
 }
@@ -402,6 +420,7 @@ float g_MaxWorldCoord = 64 * 1024;
 float g_MinWorldCoord = -64 * 1024;
 
 void AddRegionBrushes( void );
+
 void RemoveRegionBrushes( void );
 
 
@@ -432,6 +451,7 @@ public:
 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() );
@@ -541,6 +561,7 @@ UnsortedNodeSet& m_nodes;
 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 );
@@ -584,12 +605,14 @@ public:
 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();
 }
@@ -602,6 +625,7 @@ public:
 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 );
@@ -631,6 +655,7 @@ bool pre( scene::Node& node ) const {
        }
        return false;
 }
+
 void post( scene::Node& node ) const {
        m_path.pop();
 }
@@ -645,6 +670,7 @@ public:
 TypeCasts(){
        NodeContainedCast<BasicContainer, scene::Traversable>::install( m_casts );
 }
+
 NodeTypeCastTable& get(){
        return m_casts;
 }
@@ -662,9 +688,11 @@ scene::Traversable& get( NullType<scene::Traversable>){
 
 BasicContainer() : m_node( this, this, StaticTypeCasts::instance().get() ){
 }
+
 void release(){
        delete this;
 }
+
 scene::Node& node(){
        return m_node;
 }
@@ -674,6 +702,7 @@ scene::Node& 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() );
@@ -702,6 +731,7 @@ public:
 CloneAll( scene::Node& root )
        : m_path( makeReference( root ) ){
 }
+
 bool pre( scene::Node& node ) const {
        if ( node.isRoot() ) {
                return false;
@@ -712,6 +742,7 @@ bool pre( scene::Node& node ) const {
 
        return true;
 }
+
 void post( scene::Node& node ) const {
        if ( node.isRoot() ) {
                return;
@@ -743,14 +774,17 @@ public:
 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;
 }
@@ -765,106 +799,98 @@ WindowPosition g_posMapInfoWnd( c_default_window_pos );
 
 void DoMapInfo(){
        ModalDialog dialog;
-       GtkEntry* brushes_entry;
-       GtkEntry* entities_entry;
-       GtkListStore* EntityBreakdownWalker;
+       ui::Entry brushes_entry{ui::null};
+       ui::Entry entities_entry{ui::null};
+       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, TRUE, 0 );
+                       auto hbox = create_dialog_hbox( 4 );
+                       vbox.pack_start( hbox, FALSE, TRUE, 0 );
 
                        {
-                               GtkTable* table = create_dialog_table( 2, 2, 4, 4 );
-                               gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+                               auto table = create_dialog_table( 2, 2, 4, 4 );
+                               hbox.pack_start( table, TRUE, TRUE, 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_entry_set_editable( entry, FALSE );
+                                       auto entry = ui::Entry(ui::New);
+                                       entry.show();
+                    table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
+                                       gtk_editable_set_editable( GTK_EDITABLE(entry), FALSE );
 
                                        brushes_entry = 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_entry_set_editable( entry, FALSE );
+                                       auto entry = ui::Entry(ui::New);
+                                       entry.show();
+                    table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
+                                       gtk_editable_set_editable( GTK_EDITABLE(entry), FALSE );
 
                                        entities_entry = entry;
                                }
                                {
-                                       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 );
+                                       ui::Widget 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.5 );
                                }
                                {
-                                       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 );
+                                       ui::Widget 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.5 );
                                }
                        }
                        {
-                               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 );
+                       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_STRING );
+                               auto 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_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;
                        }
@@ -881,26 +907,24 @@ void DoMapInfo(){
                {
                        char tmp[16];
                        sprintf( tmp, "%u", Unsigned( ( *i ).second ) );
-                       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, tmp, -1 );
+                       EntityBreakdownWalker.append(0, (*i).first.c_str(), 1, tmp);
                }
        }
 
-       g_object_unref( G_OBJECT( EntityBreakdownWalker ) );
+       EntityBreakdownWalker.unref();
 
        char tmp[16];
        sprintf( tmp, "%u", Unsigned( g_brushCount.get() ) );
-       gtk_entry_set_text( GTK_ENTRY( brushes_entry ), tmp );
+       brushes_entry.text(tmp);
        sprintf( tmp, "%u", Unsigned( g_entityCount.get() ) );
-       gtk_entry_set_text( GTK_ENTRY( entities_entry ), tmp );
+       entities_entry.text(tmp);
 
        modal_dialog_show( window, dialog );
 
        // save before exit
        window_get_position( window, g_posMapInfoWnd );
 
-       gtk_widget_destroy( GTK_WIDGET( window ) );
+    window.destroy();
 }
 
 
@@ -914,12 +938,15 @@ ScopeTimer( const char* message )
        : 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
@@ -927,9 +954,18 @@ ScopeTimer( const char* message )
  */
 
 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" );
 
@@ -945,8 +981,8 @@ void Map_LoadFile( const char *filename ){
                                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;
@@ -993,6 +1029,7 @@ public:
 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;
@@ -1004,6 +1041,7 @@ bool pre( scene::Node& node ) const {
        }
        return true;
 }
+
 void post( scene::Node& node ) const {
        if ( m_skip ) {
                m_skip = false;
@@ -1022,6 +1060,7 @@ public:
 AnyInstanceSelected( bool& selected ) : m_selected( selected ){
        m_selected = false;
 }
+
 void visit( scene::Instance& instance ) const {
        Selectable* selectable = Instance_getSelectable( instance );
        if ( selectable != 0
@@ -1083,10 +1122,12 @@ mutable bool m_skip;
 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 )
@@ -1103,6 +1144,7 @@ bool pre( scene::Node& node ) const {
                return false;
        }
 }
+
 void post( scene::Node& node ) const {
        if ( m_skip ) {
                m_skip = false;
@@ -1129,7 +1171,7 @@ void Map_Traverse_Selected( scene::Node& root, const scene::Traversable::Walker&
 }
 
 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 ){
@@ -1184,6 +1226,9 @@ void Map_RenameAbsolute( const char* absolute ){
        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 ){
@@ -1231,6 +1276,10 @@ void Map_New(){
        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 &region_mins, const Vector3 &region_maxs );
@@ -1321,6 +1370,7 @@ public:
 ExcludeAllWalker( bool exclude )
        : m_exclude( exclude ){
 }
+
 bool pre( const scene::Path& path, scene::Instance& instance ) const {
        exclude_node( path.top(), m_exclude );
 
@@ -1344,6 +1394,7 @@ public:
 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;
@@ -1361,6 +1412,7 @@ public:
 ExcludeRegionedWalker( bool exclude )
        : m_exclude( exclude ){
 }
+
 bool pre( const scene::Path& path, scene::Instance& instance ) const {
        exclude_node(
                path.top(),
@@ -1478,6 +1530,8 @@ void Map_RegionBrush( void ){
 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" ) ) {
@@ -1534,7 +1588,27 @@ tryDecompile:
                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" );
@@ -1581,7 +1655,13 @@ tryDecompile:
  */
 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;
 }
 
 //
@@ -1603,6 +1683,7 @@ class ParentSelectedBrushesToEntityWalker : public scene::Graph::Walker
 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 );
@@ -1612,6 +1693,7 @@ 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_pointer() == &m_parent )
                return;
@@ -1655,6 +1737,7 @@ public:
 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;
@@ -1667,6 +1750,7 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
        }
        return true;
 }
+
 void post( const scene::Path& path, scene::Instance& instance ) const {
        --m_depth;
 }
@@ -1753,6 +1837,7 @@ void Scene_parentSelected(){
 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() );
@@ -1770,7 +1855,6 @@ public:
 }
 
 
-
 void NewMap(){
        if ( ConfirmModified( "New Map" ) ) {
                Map_RegionOff();
@@ -1785,16 +1869,32 @@ const char* getMapsPath(){
        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(){
@@ -1804,7 +1904,7 @@ void OpenMap(){
 
        const char* filename = map_open( "Open Map" );
 
-       if ( filename != 0 ) {
+       if ( filename != NULL ) {
                MRU_AddFile( filename );
                Map_RegionOff();
                Map_Free();
@@ -1815,7 +1915,7 @@ void OpenMap(){
 void ImportMap(){
        const char* filename = map_import( "Import Map" );
 
-       if ( filename != 0 ) {
+       if ( filename != NULL ) {
                UndoableCommand undo( "mapImport" );
                Map_ImportFile( filename );
        }
@@ -1824,7 +1924,8 @@ void ImportMap(){
 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();
@@ -1848,7 +1949,8 @@ void SaveMap(){
 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 );
        }
 }
@@ -1856,7 +1958,8 @@ void ExportMap(){
 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 );
        }
 }
@@ -1899,6 +2002,7 @@ public:
 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 ) );
@@ -1915,6 +2019,7 @@ public:
 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 ) );
@@ -1963,6 +2068,7 @@ public:
 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() ) {
@@ -1984,6 +2090,7 @@ public:
 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() ) {
@@ -2012,66 +2119,58 @@ static void GetSelectionIndex( int *ent, int *brush ){
 
 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 );
                        }
                }
        }
@@ -2082,9 +2181,9 @@ void DoFind(){
 
        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 );
@@ -2092,11 +2191,12 @@ void DoFind(){
                SelectBrush( atoi( entstr ), atoi( brushstr ) );
        }
 
-       gtk_widget_destroy( GTK_WIDGET( window ) );
+    window.destroy();
 }
 
 void Map_constructPreferences( PreferencesPage& page ){
-       page.appendCheckBox( "", "Load last map on open", g_bLoadLastMap );
+       page.appendCheckBox( "", "Load last map at startup", g_bLoadLastMap );
+       page.appendCheckBox( "", "Add entity and brush number comments on map write", g_writeMapComments );
 }
 
 
@@ -2106,6 +2206,7 @@ std::size_t m_unrealised;
 public:
 MapEntityClasses() : m_unrealised( 1 ){
 }
+
 void realise(){
        if ( --m_unrealised == 0 ) {
                if ( g_map.m_resource != 0 ) {
@@ -2114,6 +2215,7 @@ void realise(){
                }
        }
 }
+
 void unrealise(){
        if ( ++m_unrealised == 1 ) {
                if ( g_map.m_resource != 0 ) {
@@ -2133,6 +2235,7 @@ std::size_t m_unrealised;
 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" );
@@ -2142,6 +2245,7 @@ void realise(){
                g_mapsPath = buffer.c_str();
        }
 }
+
 void unrealise(){
        if ( ++m_unrealised == 1 ) {
                g_mapsPath = "";
@@ -2151,22 +2255,21 @@ void unrealise(){
 
 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 ) ) );
+       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 ) ) );
 
-       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 ) );
+       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( FreeCaller1<PreferencesPage&, Map_constructPreferences>() );
+       PreferencesDialog_addSettingsPreferences( makeCallbackF(Map_constructPreferences) );
 
        GlobalEntityClassManager().attach( g_MapEntityClasses );
        Radiant_attachHomePathsObserver( g_MapModuleObserver );
index a359d46159a676405df4523b4961573c41f1d10a..c68b02751e270df0790012a283216e01dd98ccca 100644 (file)
@@ -37,11 +37,11 @@ bool Map_Valid( const Map& map );
 
 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;
@@ -73,7 +73,7 @@ inline void DeferredDraw_onMapValidChanged( DeferredDraw& self ){
                self.defer();
        }
 }
-typedef ReferenceCaller<DeferredDraw, DeferredDraw_onMapValidChanged> DeferredDrawOnMapValidChangedCaller;
+typedef ReferenceCaller<DeferredDraw, void(), DeferredDraw_onMapValidChanged> DeferredDrawOnMapValidChangedCaller;
 
 
 
index 24efcf0411093c7ed710677e36954ff77ddb67c9..dc0525029b1d87ffd28b797fc5ac218e1ba72008 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <string.h>
 #include <stdio.h>
-#include <gtk/gtklabel.h>
+#include <gtk/gtk.h>
 
 #include "os/file.h"
 #include "generic/callback.h"
@@ -120,8 +120,8 @@ void MRU_AddFile( const char *str ){
                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(){
@@ -130,13 +130,13 @@ 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();
                }
        }
 }
@@ -159,12 +159,13 @@ void MRU_Activate( std::size_t index ){
                        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();
                }
        }
 }
@@ -184,7 +185,7 @@ void load(){
 }
 };
 
-typedef MemberCaller<LoadMRU, &LoadMRU::load> LoadMRUCaller;
+typedef MemberCaller<LoadMRU, void(), &LoadMRU::load> LoadMRUCaller;
 
 LoadMRU g_load_mru1( 1 );
 LoadMRU g_load_mru2( 2 );
@@ -196,50 +197,50 @@ LoadMRU g_load_mru7( 7 );
 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 );
        }
 }
@@ -248,11 +249,11 @@ void MRU_constructMenu( GtkMenu* menu ){
 #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();
index 273c97f1a4d3d4fb11cedd5ebdd14b4d29aa9f16..33627d801338cbc0e5c3b68aa2736a74340e15a6 100644 (file)
    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();
index 04407591778e78f36bab95aa356dde4d8ffb26e9..9a4a4f22a2d572bd9bcf15ffb041c4866554e09e 100644 (file)
 
 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 );
 }
@@ -44,7 +43,7 @@ void MultiMonitor_constructPreferences( PreferencesPage& page ){
 #include "preferencesystem.h"
 #include "stringio.h"
 
-#include <gdk/gdkdisplay.h>
+#include <gdk/gdk.h>
 
 namespace
 {
@@ -87,12 +86,13 @@ void MultiMon_Construct(){
                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(){
 }
index a81220e72878b7e4333973c99d3af928a0c984c2..c51bb9d028ff874480f1cf00c6db2e5ab7caad4a 100644 (file)
@@ -22,6 +22,8 @@
 #if !defined( INCLUDED_MULTIMON_H )
 #define INCLUDED_MULTIMON_H
 
+#include "globaldefs.h"
+
 struct WindowPosition;
 
 void PositionWindowOnPrimaryScreen( WindowPosition& position );
@@ -37,7 +39,7 @@ struct multimon_globals_t
 
 extern multimon_globals_t g_multimon_globals;
 
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
 void MultiMon_Construct();
 void MultiMon_Destroy();
 #else
index 243cf8640355d3013d2f494e72186e02054e1068..f99e65451d52f90aadcf9df69afc448e799fa198 100644 (file)
@@ -19,6 +19,7 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#define _USE_MATH_DEFINES
 #include "patch.h"
 
 #include <glib.h>
@@ -1357,14 +1358,13 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std
                // 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;
@@ -1383,12 +1383,11 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std
                // 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 );
@@ -1410,13 +1409,12 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std
                // 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 );
@@ -1548,14 +1546,14 @@ void RenderablePatchSolid::RenderNormals() const {
        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 ){
index 7cca42862722f75e94aa07e2f28c307500637bb4..89deeac95ceadb55a04e9d2d5e311bb86d88dd66 100644 (file)
@@ -30,7 +30,7 @@
 /// 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"
@@ -317,7 +317,7 @@ void render( RenderStateFlags state ) const {
                }
        }
 
-#if defined( _DEBUG )
+#if GDEF_DEBUG
        RenderNormals();
 #endif
 }
@@ -447,8 +447,8 @@ RenderableIndexBuffer m_render_lattice;
 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;
@@ -465,14 +465,14 @@ void construct(){
 }
 
 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 ),
@@ -488,7 +488,7 @@ Patch( scene::Node& node, const Callback& evaluateTransform, const Callback& bou
        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 ),
@@ -674,7 +674,7 @@ void transformChanged(){
        m_lightsChanged();
        SceneChangeNotify();
 }
-typedef MemberCaller<Patch, &Patch::transformChanged> TransformChangedCaller;
+typedef MemberCaller<Patch, void(), &Patch::transformChanged> TransformChangedCaller;
 
 void evaluateTransform(){
        if ( m_transformChanged ) {
@@ -1346,7 +1346,7 @@ typedef LazyStatic<TypeCasts> StaticTypeCasts;
 void lightsChanged(){
        m_lightList->lightsChanged();
 }
-typedef MemberCaller<PatchInstance, &PatchInstance::lightsChanged> LightsChangedCaller;
+typedef MemberCaller<PatchInstance, void(), &PatchInstance::lightsChanged> LightsChangedCaller;
 
 STRING_CONSTANT( Name, "PatchInstance" );
 
@@ -1366,9 +1366,9 @@ PatchInstance( const scene::Path& path, scene::Instance* parent, Patch& patch )
        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 );
@@ -1381,13 +1381,13 @@ void selectedChanged( const Selectable& selectable ){
 
        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;
@@ -1620,7 +1620,7 @@ void applyTransform(){
        evaluateTransform();
        m_patch.freezeTransform();
 }
-typedef MemberCaller<PatchInstance, &PatchInstance::applyTransform> ApplyTransformCaller;
+typedef MemberCaller<PatchInstance, void(), &PatchInstance::applyTransform> ApplyTransformCaller;
 
 
 bool testLight( const RendererLight& light ) const {
index daa79f65e5337bb8ec6850345f8777ae44a53867..6a29298d592f8de1a599863a37669c572c66af22 100644 (file)
 
 #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"
@@ -145,56 +137,46 @@ void Scene_PatchGetFixedSubdivisions( PatchFixedSubdivisions& subdivisions ){
 #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(
@@ -204,15 +186,15 @@ void apply(){
                        )
                );
 }
-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;
@@ -235,8 +217,8 @@ float m_fZ;
    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;
 
@@ -248,7 +230,7 @@ bool m_bListenChanged;
 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;
@@ -265,7 +247,7 @@ PatchInspector() :
 }
 
 bool visible(){
-       return GTK_WIDGET_VISIBLE( GetWidget() );
+       return GetWidget().visible();
 }
 
 //  void UpdateInfo();
@@ -284,7 +266,7 @@ void exportData();
 
 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();
 }
@@ -320,7 +302,7 @@ void PatchInspector_toggleShown(){
 // 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" );
@@ -347,7 +329,7 @@ static void OnApply( GtkWidget *widget, gpointer data ){
        }
 }
 
-static void OnSelchangeComboColRow( GtkWidget *widget, gpointer data ){
+static void OnSelchangeComboColRow( ui::Widget widget, gpointer data ){
        if ( !g_PatchInspector.m_bListenChanged ) {
                return;
        }
@@ -359,73 +341,42 @@ static void OnSelchangeComboColRow( GtkWidget *widget, gpointer data ){
        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 ){
-       UndoableCommand command( "patchCapTexture" );
-
-       Scene_PatchCapTexture_Selected( GlobalSceneGraph() );
+static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){
+       Patch_CapTexture();
 }
 
-static void OnBtnPatchfit( GtkWidget *widget, gpointer data ){
-       UndoableCommand command( "patchFitTexture" );
-
-       Scene_PatchTileTexture_Selected( GlobalSceneGraph(), 1, 1 );
+static void OnBtnPatchfit( ui::Widget widget, gpointer data ){
+       Patch_FitTexture();
 }
 
-static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){
-       UndoableCommand command( "patchNaturalTexture" );
-
-       Scene_PatchNaturalTexture_Selected( GlobalSceneGraph() );
+static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){
+       Patch_NaturalTexture();
 }
 
-static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){
-       float fx, fy;
-       if ( DoTextureLayout( &fx, &fy ) == eIDOK ) {
-               UndoableCommand command( "patchTileTexture" );
-               Scene_PatchTileTexture_Selected( GlobalSceneGraph(), fx, fy );
-       }
+static void OnBtnPatchreset( ui::Widget widget, gpointer data ){
+       Patch_ResetTexture();
 }
 
-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 ) );
+static void OnBtnPatchFlipX( ui::Widget widget, gpointer data ){
+       Patch_FlipTextureX();
 }
 
-class PatchScaleTexture
-{
-float m_s, m_t;
-public:
-PatchScaleTexture( float s, float t ) : m_s( s ), m_t( t ){
+static void OnBtnPatchFlipY( ui::Widget widget, gpointer data ){
+       Patch_FlipTextureY();
 }
-void operator()( Patch& patch ) const {
-       patch.ScaleTexture( m_s, m_t );
+
+void Scene_PatchRotateTexture_Selected( scene::Graph& graph, float angle ){
+       Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+               patch.RotateTexture(angle);
+       });
 }
-};
 
 float Patch_convertScale( float scale ){
        if ( scale > 0 ) {
@@ -438,40 +389,38 @@ float Patch_convertScale( float scale ){
 }
 
 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{
@@ -481,7 +430,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){
        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{
@@ -493,7 +442,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){
                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{
@@ -505,7 +454,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){
                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{
@@ -515,7 +464,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){
        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{
@@ -523,7 +472,7 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){
                }
        }
 
-       adj->value = 0;
+       gtk_adjustment_set_value(adj, 0);
 
        // will scale shift rotate the patch accordingly
 
@@ -542,15 +491,15 @@ static void OnSpinChanged( GtkAdjustment *adj, gpointer data ){
        }
 
        // 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;
        }
@@ -560,8 +509,8 @@ static gint OnDialogKey( GtkWidget* widget, GdkEventKey* event, gpointer data ){
 // =============================================================================
 // 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 );
 
@@ -571,227 +520,187 @@ GtkWindow* PatchInspector::BuildDialog(){
 
 
        {
-               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 );
                                                        }
@@ -800,215 +709,206 @@ GtkWindow* PatchInspector::BuildDialog(){
                                }
                        }
                        {
-                               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, 3, 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, 3, 0, 1,
-                                                                                         (GtkAttachOptions)( GTK_FILL ),
-                                                                                         (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, 3, 1, 2,
-                                                                                         (GtkAttachOptions)( GTK_FILL ),
-                                                                                         (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 ),
-                                                                                         (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 );
                                                }
                                                {
-                                                       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 ),
-                                                                                         (GtkAttachOptions)( 0 ), 0, 0 );
+                                                       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);
+                                               }
+                                               {
+                                                       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 );
                                                }
                                                {
-                                                       GtkLabel* label = GTK_LABEL( gtk_label_new( "Rotate Step" ) );
-                                                       gtk_widget_show( GTK_WIDGET( label ) );
-                                                       gtk_table_attach( table, GTK_WIDGET( label ), 2, 3, 4, 5,
-                                                                                         (GtkAttachOptions)( GTK_FILL ),
-                                                                                         (GtkAttachOptions)( 0 ), 0, 0 );
+                                                       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);
+                                               }
+                                               {
+                                                       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 ), 10, -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(10, -1);
+                                                       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 ), 10, -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(10, -1);
+                                                       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 ), 10, -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(10, -1);
+                                                       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 ), 10, -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(10, -1);
+                                                       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 ), 10, -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(10, -1);
+                                                       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);
                                        }
                                }
                        }
@@ -1055,7 +955,7 @@ void PatchInspector::GetPatchInfo(){
 
                        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();
@@ -1063,7 +963,7 @@ void PatchInspector::GetPatchInfo(){
                        {
                                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 );
@@ -1074,7 +974,7 @@ void PatchInspector::GetPatchInfo(){
 
                        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();
@@ -1082,7 +982,7 @@ void PatchInspector::GetPatchInfo(){
                        {
                                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 );
@@ -1133,18 +1033,18 @@ void PatchInspector_SelectionChanged( const Selectable& selectable ){
 
 
 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(){
index 1304ccbe23cac1f203b0dd5fc9d674f7a551fd8c..ca1f6c9eeb0671cb5645c2cf9178298c42210ee3 100644 (file)
    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
index 5a6db29cb5b5f87dd9cc40edd110e5ca73a88ffa..2fbc322c68124249665e21b7ab30ed3d15b8d665 100644 (file)
@@ -21,6 +21,9 @@
 
 #include "patchmanip.h"
 
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
 #include "debugging/debugging.h"
 
 
@@ -67,6 +70,32 @@ void Scene_PatchConstructPrefab( scene::Graph& graph, const AABB aabb, const cha
        }
 }
 
+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 )
@@ -89,8 +118,10 @@ void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, co
                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();
@@ -102,8 +133,10 @@ void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, co
                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();
@@ -115,17 +148,6 @@ void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, co
 
 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,
@@ -164,7 +186,9 @@ void Scene_PatchDoCap_Selected( scene::Graph& graph, const char* shader ){
                }
 
                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 );
@@ -188,7 +212,9 @@ void Patch_deform( Patch& patch, scene::Instance& instance, const int deform ){
 void Scene_PatchDeform( scene::Graph& graph, const int deform )
 {
        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 );
@@ -265,7 +291,9 @@ void Patch_thicken( Patch& patch, scene::Instance& instance, const float thickne
 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 );
@@ -284,132 +312,62 @@ Patch* Scene_GetUltimateSelectedVisiblePatch(){
 }
 
 
-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 ) );
+       Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+               patch.InsertRemove(bInsert, bColumn, bFirst);
+       });
 }
 
-class PatchInvertMatrix
-{
-public:
-void operator()( Patch& patch ) const {
-       patch.InvertMatrix();
-}
-};
-
 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 ) );
-}
-
-class PatchSmooth
-{
-EMatrixMajor m_major;
-public:
-PatchSmooth( EMatrixMajor major ) : m_major( major ){
+       Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+               patch.Redisperse(major);
+       });
 }
-void operator()( Patch& patch ) const {
-       patch.Smooth( m_major );
-}
-};
 
 void Scene_PatchSmooth_Selected( scene::Graph& graph, EMatrixMajor major ){
-       Scene_forEachVisibleSelectedPatch( PatchSmooth( major ) );
+       Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+               patch.Smooth(major);
+       });
 }
 
-class PatchTransposeMatrix
-{
-public:
-void operator()( Patch& patch ) const {
-       patch.TransposeMatrix();
-}
-};
-
 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();
 }
 
@@ -420,45 +378,29 @@ void Scene_PatchGetShader_Selected( scene::Graph& graph, CopiedString& name ){
        }
 }
 
-class PatchSelectByShader
-{
-const char* m_name;
-public:
-inline PatchSelectByShader( const char* name )
-       : m_name( name ){
-}
-void operator()( PatchInstance& patch ) const {
-       if ( shader_equal( patch.getPatch().GetShader(), m_name ) ) {
-               patch.setSelected( true );
-       }
-}
-};
-
 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);
+               }
+       });
 }
 
 
-class PatchFindReplaceShader
-{
-const char* m_find;
-const char* m_replace;
-public:
-PatchFindReplaceShader( const char* find, const char* replace ) : m_find( find ), m_replace( replace ){
-}
-void operator()( Patch& patch ) const {
-       if ( shader_equal( patch.GetShader(), m_find ) ) {
-               patch.SetShader( m_replace );
-       }
-}
-};
-
 void Scene_PatchFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
-       Scene_forEachVisiblePatch( PatchFindReplaceShader( find, replace ) );
+       Scene_forEachVisiblePatch([&](Patch &patch) {
+               if (shader_equal(patch.GetShader(), find)) {
+                       patch.SetShader(replace);
+               }
+       });
 }
 
 void Scene_PatchFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
-       Scene_forEachVisibleSelectedPatch( PatchFindReplaceShader( find, replace ) );
+       Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
+               if (shader_equal(patch.GetShader(), find)) {
+                       patch.SetShader(replace);
+               }
+       });
 }
 
 
@@ -687,6 +629,26 @@ void Patch_NaturalTexture(){
        Scene_PatchNaturalTexture_Selected( GlobalSceneGraph() );
 }
 
+void Patch_CapTexture(){
+       UndoableCommand command( "patchCapTexture" );
+
+       Scene_PatchCapTexture_Selected( GlobalSceneGraph() );
+}
+
+void Patch_ResetTexture(){
+       float fx, fy;
+       if ( DoTextureLayout( &fx, &fy ) == eIDOK ) {
+               UndoableCommand command( "patchTileTexture" );
+               Scene_PatchTileTexture_Selected( GlobalSceneGraph(), fx, fy );
+       }
+}
+
+void Patch_FitTexture(){
+       UndoableCommand command( "patchFitTexture" );
+
+       Scene_PatchTileTexture_Selected( GlobalSceneGraph(), 1, 1 );
+}
+
 void DoPatchDeformDlg();
 
 void Patch_Deform(){
@@ -702,9 +664,6 @@ void Patch_Thicken(){
 
        DoPatchThickenDlg();
 }
-
-
-
 #include "ifilter.h"
 
 
@@ -762,71 +721,71 @@ void Patch_constructPage( PreferenceGroup& group ){
        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( "IncPatchColumn", FreeCaller<Patch_InsertInsertColumn>(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
-       GlobalCommands_insert( "IncPatchRow", FreeCaller<Patch_InsertInsertRow>(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
-       GlobalCommands_insert( "DecPatchColumn", FreeCaller<Patch_DeleteLastColumn>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
-       GlobalCommands_insert( "DecPatchRow", FreeCaller<Patch_DeleteLastRow>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_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( "PatchInsertInsertColumn", FreeCaller<Patch_InsertInsertColumn>() );
-       GlobalCommands_insert( "PatchInsertAddColumn", FreeCaller<Patch_InsertAddColumn>() );
-       GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller<Patch_InsertInsertRow>() );
-       GlobalCommands_insert( "PatchInsertAddRow", FreeCaller<Patch_InsertAddRow>() );
-       GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller<Patch_DeleteFirstColumn>() );
-       GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller<Patch_DeleteLastColumn>() );
-       GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller<Patch_DeleteFirstRow>() );
-       GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller<Patch_DeleteLastRow>() );
-       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>() );
-}
-
-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( "IncPatchColumn", makeCallbackF(Patch_InsertInsertColumn), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+       GlobalCommands_insert( "IncPatchRow", makeCallbackF(Patch_InsertInsertRow), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
+       GlobalCommands_insert( "DecPatchColumn", makeCallbackF(Patch_DeleteLastColumn), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+       GlobalCommands_insert( "DecPatchRow", makeCallbackF(Patch_DeleteLastRow), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_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( "PatchInsertInsertColumn", makeCallbackF(Patch_InsertInsertColumn), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+       GlobalCommands_insert( "PatchInsertAddColumn", makeCallbackF(Patch_InsertAddColumn) );
+       GlobalCommands_insert( "PatchInsertInsertRow", makeCallbackF(Patch_InsertInsertRow), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
+       GlobalCommands_insert( "PatchInsertAddRow", makeCallbackF(Patch_InsertAddRow) );
+       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) );
+}
+
+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, "Cylinder", "PatchCylinder" );
        {
-               GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" );
+               auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_in_menu );
                }
@@ -839,7 +798,7 @@ void Patch_constructMenu( GtkMenu* menu ){
        create_menu_item_with_mnemonic( menu, "End cap", "PatchEndCap" );
        create_menu_item_with_mnemonic( menu, "Bevel", "PatchBevel" );
        {
-//             GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" );
+//             auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" );
 //             if ( g_Layout_enableDetachableMenus.m_value ) {
 //                     menu_tearoff( menu_in_menu );
 //             }
@@ -856,7 +815,7 @@ void Patch_constructMenu( GtkMenu* menu ){
        create_menu_item_with_mnemonic( menu, "Simple Patch Mesh...", "SimplePatchMesh" );
        menu_separator( menu );
        {
-               GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" );
+               auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_in_menu );
                }
@@ -867,7 +826,7 @@ void Patch_constructMenu( GtkMenu* menu ){
                create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Rows", "PatchInsertAddRow" );
        }
        {
-               GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" );
+               auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_in_menu );
                }
@@ -879,32 +838,33 @@ void Patch_constructMenu( GtkMenu* 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 );
                }
                create_menu_item_with_mnemonic( menu_in_menu, "Invert", "InvertCurve" );
-               create_menu_item_with_mnemonic( menu_in_menu, "Transpose", "MatrixTranspose" );
-//             GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" );
+//             auto menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" );
 //             if ( g_Layout_enableDetachableMenus.m_value ) {
 //                     menu_tearoff( menu_3 );
 //             }
                menu_separator( menu_in_menu );
-               create_menu_item_with_mnemonic( menu_in_menu, "Re-disperse Rows", "RedisperseRows" );
-               create_menu_item_with_mnemonic( menu_in_menu, "Re-disperse Columns", "RedisperseCols" );
-//             GtkMenu* menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" );
+               create_menu_item_with_mnemonic( menu, "Rows", "RedisperseRows" );
+               create_menu_item_with_mnemonic( menu, "Columns", "RedisperseCols" );
+//             auto menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" );
 //             if ( g_Layout_enableDetachableMenus.m_value ) {
 //                     menu_tearoff( menu_4 );
 //             }
-               menu_separator( menu_in_menu );
-               create_menu_item_with_mnemonic( menu_in_menu, "Smooth Rows", "SmoothRows" );
-               create_menu_item_with_mnemonic( menu_in_menu, "Smooth Columns", "SmoothCols" );
+               create_menu_item_with_mnemonic( menu, "Rows", "SmoothRows" );
+               create_menu_item_with_mnemonic( menu, "Columns", "SmoothCols" );
+               create_menu_item_with_mnemonic( menu_in_menu, "Transpose", "MatrixTranspose" );
+
        }
        menu_separator( menu );
        create_menu_item_with_mnemonic( menu, "Cap Selection", "CapCurrentCurve" );
+       create_menu_item_with_mnemonic( menu, "Cycle Cap Texture", "CycleCapTexturePatch" );
        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 );
                }
@@ -916,7 +876,7 @@ void Patch_constructMenu( GtkMenu* menu ){
        }
        menu_separator( menu );
        {
-               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 );
                }
@@ -929,51 +889,40 @@ void Patch_constructMenu( GtkMenu* menu ){
 }
 
 
-#include <gtk/gtkbox.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtktogglebutton.h>
-#include <gtk/gtkradiobutton.h>
-#include <gtk/gtkcombobox.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;
 
-       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( 2, 2, 4, 4 );
-                       gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+                       auto table = create_dialog_table( 2, 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 );
@@ -990,16 +939,12 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
                                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 );
@@ -1016,29 +961,25 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
                                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});
                        }
                }
 
                {
-                       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 );
                        }
                }
        }
@@ -1054,7 +995,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
                Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), prefab, GlobalXYWnd_getCurrentViewType(), w, h );
        }
 
-       gtk_widget_destroy( GTK_WIDGET( window ) );
+       window.destroy();
 }
 
 
@@ -1062,16 +1003,16 @@ void DoPatchDeformDlg(){
        ModalDialog dialog;
        GtkWidget* deformW;
 
-       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:" ) );
@@ -1093,19 +1034,19 @@ void DoPatchDeformDlg(){
                        }
                }
                {
-                       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 );
                        }
                }
        }
@@ -1124,117 +1065,97 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){
        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;
                                }
@@ -1242,18 +1163,18 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){
                }
 
                {
-                       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 );
                        }
                }
        }
@@ -1280,7 +1201,7 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){
                }
        }
 
-       gtk_widget_destroy( GTK_WIDGET( window ) );
+       window.destroy();
 
        return ret;
 }
@@ -1295,16 +1216,16 @@ void DoPatchThickenDlg(){
        GtkWidget* radZ;
        GtkWidget* radNormals;
 
-       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:" ) );
@@ -1368,19 +1289,19 @@ void DoPatchThickenDlg(){
                        }
                }
                {
-                       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 );
                        }
                }
        }
index 4666ae73494a585c802afa8568360fa6e3cffeed..512a3f95c1132c05cd28f08f9c8d7930f3466e9a 100644 (file)
 #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
 {
@@ -51,6 +50,14 @@ void PatchPreferences_construct();
 
 void Patch_registerPreferencesPage();
 
+void Patch_NaturalTexture();
+void Patch_CapTexture();
+void Patch_ResetTexture();
+void Patch_FitTexture();
+void Patch_FlipTextureX();
+void Patch_FlipTextureY();
+void Patch_AutoCapTexture();
+
 class PatchCreator;
 extern PatchCreator* g_patchCreator;
 
index a43572aaf8c194154538b26ee36d7349521b4bbf..9d55cf3b4a5126afe5d54d8da82ce96097d762ea 100644 (file)
@@ -113,6 +113,10 @@ const char* TextureBrowser_getSelectedShader(){
        return TextureBrowser_GetSelectedShader( GlobalTextureBrowser() );
 }
 
+const char* getGameFile(){
+       return g_GamesDialog.m_sGameFile.c_str();
+}
+
 class RadiantCoreAPI
 {
 _QERFuncTable_1 m_radiantcore;
@@ -128,6 +132,7 @@ RadiantCoreAPI(){
        m_radiantcore.getSettingsPath = &SettingsPath_get;
        m_radiantcore.getMapsPath = &getMapsPath;
 
+       m_radiantcore.getGameFile = &getGameFile;
        m_radiantcore.getGameName = &gamename_get;
        m_radiantcore.getGameMode = &gamemode_get;
 
@@ -138,15 +143,6 @@ RadiantCoreAPI(){
        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;
index fff61864529a71f81a3fbeb2119693f67684abbf..c006913df8cb2a797185ba95994f0a106e575309 100644 (file)
@@ -51,7 +51,7 @@ void QERApp_GetCamWindowExtents( int *x, int *y, int *width, int *height ){
 #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;
index 30cc0c2390e42ddc6f6ad6b3892d73a8ac81c31b..91e9f9ae184f9af759c36e4e75d894c2de222c70 100644 (file)
@@ -53,7 +53,7 @@ public:
 /*!
    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
  */
@@ -69,7 +69,7 @@ bool ownsCommandID( std::size_t n );
 
 };
 
-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;
 
@@ -149,7 +149,7 @@ std::list<CPluginSlot *> mSlots;
 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 ) );
 }
 
@@ -190,13 +190,13 @@ bool CPluginSlots::Dispatch( std::size_t n, const char* p ){
 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 {
@@ -220,7 +220,7 @@ void CPlugInManager::Dispatch( std::size_t n, const char * p ){
        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 );
 }
 
index d7943fb35ea684551bceb8c4446d7f00f8c06fde..6603f6e1e4cc1db1e73449f2ae6c3c20ad3799e2 100644 (file)
@@ -23,8 +23,8 @@
 #define INCLUDED_PLUGINMANAGER_H
 
 #include <cstddef>
+#include <uilib/uilib.h>
 
-typedef struct _GtkWidget GtkWidget;
 
 /*!
    \class IPlugin
@@ -55,7 +55,7 @@ class CPlugInManager
 {
 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();
 };
index 4708a78ce42bd4b3441fff506fe00d96af66a8dc..8155d0a92d7d7bbe01c011111d9a9260c0854860 100644 (file)
 
 #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 )
                {
@@ -66,7 +65,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){
 
                        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, ">" ) ) {
@@ -77,11 +76,11 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){
                                                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;
@@ -100,12 +99,12 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){
                                }
                                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++ );
                        }
                }
@@ -125,15 +124,15 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){
        }
 }
 
-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 );
@@ -147,18 +146,18 @@ public:
 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 );
        }
@@ -167,7 +166,7 @@ GtkMenuItem* create_plugins_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 );
index 254db7773644a356e83c326ce37fcb74965cc18e..b1685a617ae347b69639c752b16ea022e5669ce4 100644 (file)
    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();
 
index 8fd420d73046cc1b6ef65bdc96d12bf83da2ea2c..6e24976d212c3a1eef45a14e0d9896b25e1b13bf 100644 (file)
 
 #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 << 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_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 {
@@ -121,16 +125,15 @@ public:
 }
 
 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_widget_show( GTK_WIDGET( toolbar ) );
+       toolbar.show();
 
        g_plugin_toolbar = toolbar;
 
index 7621cfd2585be7eed7db072fb86baa53fffa822f..97bbffb2f087e5ab3016cff42e731564127e9592 100644 (file)
    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
index 342c5be0fc09ed999fb3b4437574499d1831734b..c4a56492ee86ed73f0c2093d7f73ecfb08e91442 100644 (file)
@@ -330,9 +330,9 @@ void Pointfile_Construct(){
 
        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(){
index ce3f768685b40ff5d696fe5c5381434fc24a9a31..382271ee8a9795ceaa786d9622d7c1d40361d8df 100644 (file)
@@ -33,17 +33,16 @@ class PreferenceDictionary : public PreferenceSystem
 {
 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 );
 }
 };
 
@@ -66,11 +65,11 @@ iterator find( const char* name ){
        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 );
        }
 }
@@ -91,7 +90,7 @@ void importPref( const char* name, const char* value ){
 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
 {
index d93457c7122257b16da83909caf18007fe59cc85..a342d6c01a859daa8f1d956a45d632360d1e8f5c 100644 (file)
 //
 
 #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"
@@ -70,12 +58,12 @@ void Global_constructPreferences( PreferencesPage& page ){
 }
 
 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
@@ -94,7 +82,7 @@ void Mouse_constructPage( PreferenceGroup& group ){
        Mouse_constructPreferences( page );
 }
 void Mouse_registerPreferencesPage(){
-       PreferencesDialog_addInterfacePage( FreeCaller1<PreferenceGroup&, Mouse_constructPage>() );
+       PreferencesDialog_addInterfacePage( makeCallbackF(Mouse_constructPage) );
 }
 
 
@@ -105,6 +93,7 @@ void Mouse_registerPreferencesPage(){
  */
 
 #include <map>
+#include <uilib/uilib.h>
 
 inline const char* xmlAttr_getName( xmlAttrPtr attr ){
        return reinterpret_cast<const char*>( attr->name );
@@ -228,18 +217,22 @@ bool Preferences_Save_Safe( PreferenceDictionary& preferences, const char* filen
 }
 
 
+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>() );
 }
 
 
@@ -292,7 +285,7 @@ void CGameDialog::GameFileImport( int value ){
        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;
@@ -307,13 +300,15 @@ void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) cons
        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;
@@ -325,53 +320,25 @@ void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){
        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 );
@@ -389,7 +356,22 @@ void CGameDialog::ScanForGames(){
           (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(){
@@ -472,7 +454,7 @@ CGameDialog::~CGameDialog(){
                delete ( *iGame );
                *iGame = 0;
        }
-       if ( GetWidget() != 0 ) {
+       if ( GetWidget() ) {
                Destroy();
        }
 }
@@ -485,15 +467,6 @@ inline const char* GameDescription_getIdentifier( const CGameDescription& gameDe
        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;
 
@@ -501,11 +474,11 @@ 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 );
 
@@ -531,7 +504,7 @@ static void OnButtonClean( GtkWidget *widget, gpointer data ){
    ========
  */
 
-#define PREFS_LOCAL_FILENAME "local.pref"
+const char *PREFS_LOCAL_FILENAME = "local.pref";
 
 void PrefsDlg::Init(){
        // m_global_rc_path has been set above
@@ -551,25 +524,25 @@ void PrefsDlg::Init(){
        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 );
        }
@@ -629,50 +602,50 @@ void PreferencesDialog_addSettingsPage( const PreferenceGroupCallback& callback
        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 );
@@ -683,94 +656,94 @@ GtkWidget* PreferencePages_addPage( GtkWidget* notebook, const char* name ){
 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);
 
                                        {
                                                /********************************************************************/
@@ -781,14 +754,14 @@ GtkWindow* PrefsDlg::BuildDialog(){
                                                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 );
 
@@ -797,45 +770,45 @@ GtkWindow* PrefsDlg::BuildDialog(){
                                                }
 
                                                {
-                                                       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 ) );
                                }
@@ -843,7 +816,7 @@ GtkWindow* PrefsDlg::BuildDialog(){
                }
        }
 
-       gtk_notebook_set_page( GTK_NOTEBOOK( m_notebook ), 0 );
+       gtk_notebook_set_current_page( GTK_NOTEBOOK( m_notebook ), 0 );
 
        return dialog;
 }
@@ -853,7 +826,7 @@ preferences_globals_t g_preferences_globals;
 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();
 }
@@ -942,45 +915,42 @@ void PreferencesDialog_showDialog(){
                        {
                                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(){
index 8793d03904b091a075b6cdf1a8969a09d7100b28..59dd60daaa0c6e42633932892511d91fa594429c 100644 (file)
 #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 );
@@ -58,54 +59,54 @@ void appendCombo( const char* name, int& data, StringArrayRange 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
 {
@@ -113,7 +114,7 @@ public:
 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 );
@@ -125,31 +126,38 @@ void PreferencesDialog_addSettingsPage( 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
@@ -197,7 +205,6 @@ void Dump();
 
 extern CGameDescription *g_pGameDescription;
 
-typedef struct _GtkWidget GtkWidget;
 class PrefsDlg;
 
 class PreferencesPage;
@@ -250,8 +257,6 @@ CGameDialog() :
 }
 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
@@ -272,10 +277,10 @@ void DoGameDialog();
    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
@@ -331,7 +336,7 @@ std::list<CGameDescription *> mGames;
 
 public:
 
-GtkWidget *m_notebook;
+ui::Widget m_notebook{ui::null};
 
 virtual ~PrefsDlg(){
        g_string_free( m_rc_path, true );
@@ -364,12 +369,12 @@ GString *m_inipath;
 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 );
 };
 
@@ -384,8 +389,7 @@ struct preferences_globals_t
 };
 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();
index 82d5d85571d3233f08fbffaffa78741547ef181c..efae51c42438df2c94ea4dbb88e260a618814f8c 100644 (file)
 // Leonardo Zide (leo@lokigames.com)
 //
 
+#include "defaults.h"
 #include "qe3.h"
+#include "globaldefs.h"
+
+#include <gtk/gtk.h>
 
 #include "debugging/debugging.h"
 
@@ -41,7 +45,7 @@
 
 #include <map>
 
-#include <gtk/gtktearoffmenuitem.h>
+#include <uilib/uilib.h>
 
 #include "stream/textfilestream.h"
 #include "cmdlib.h"
@@ -64,7 +68,7 @@
 QEGlobals_t g_qeglobals;
 
 
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
 #define PATH_MAX 260
 #endif
 
@@ -80,17 +84,22 @@ void QE_InitVFS(){
        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() );
@@ -98,18 +107,25 @@ void QE_InitVFS(){
        }
 
        // ~/.<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;
@@ -140,11 +156,11 @@ bool ConfirmModified( const char* title ){
                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();
                }
@@ -164,6 +180,27 @@ void bsp_init(){
        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";
@@ -183,6 +220,7 @@ public:
 ArrayCommandListener(){
        m_array = g_ptr_array_new();
 }
+
 ~ArrayCommandListener(){
        g_ptr_array_free( m_array, TRUE );
 }
@@ -279,10 +317,10 @@ void RunBSP( const char* name ){
                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
@@ -292,7 +330,7 @@ void RunBSP( const char* name ){
                {
                        TextFileOutputStream batchFile( batpath );
                        if ( !batchFile.failed() ) {
-#if defined ( POSIX )
+#if GDEF_OS_POSIX
                                batchFile << "#!/bin/sh \n\n";
 #endif
                                BatchCommandListener listener( batchFile, junkpath );
@@ -301,7 +339,7 @@ void RunBSP( const char* name ){
                        }
                }
                if ( written ) {
-#if defined ( POSIX )
+#if GDEF_OS_POSIX
                        chmod( batpath, 0744 );
 #endif
                        globalOutputStream() << "Writing the compile script to '" << batpath << "'\n";
@@ -324,7 +362,7 @@ void Sys_SetTitle( const char *text, bool modified ){
                title << " *";
        }
 
-       gtk_window_set_title( MainFrame_getWindow(), title.c_str() );
+       gtk_window_set_title(MainFrame_getWindow(), title.c_str() );
 }
 
 bool g_bWaitCursor = false;
@@ -332,14 +370,14 @@ 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;
 }
 
index 2e44768c97973ef9b30f295dafe9b49986d5fc4e..d64b7a5fe2f37e3b95c768ef0ab83535eb0ae982 100644 (file)
@@ -21,6 +21,7 @@
 
 
 #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
@@ -45,7 +50,7 @@
 
 
 
-#if defined( _WIN32 )
+#if GDEF_OS_WINDOWS
 
 #include <wtypes.h>
 
@@ -55,12 +60,15 @@ PROC ( WINAPI * qwglGetProcAddress )( LPCSTR );
 
 #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
@@ -69,11 +77,12 @@ typedef void* ( *glXGetProcAddressARBProc )( const GLubyte *procName );
 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
@@ -130,7 +139,7 @@ bool QGL_ExtensionSupported( const char* extension ){
        }
 
        extensions = GlobalOpenGL().m_glGetString( GL_EXTENSIONS );
-#ifndef __APPLE__
+#if !GDEF_OS_MACOS
        if ( !extensions ) {
                return false;
        }
@@ -171,7 +180,16 @@ QGLFunctionPointer QGL_getExtensionFunc( const char* symbol ){
        {
                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
@@ -533,13 +551,14 @@ void QGL_clear( OpenGLBinding& table ){
 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
index ee3ab8061e17f4a16201458e6b66d641cfb4eef0..9ceeba1bc78fe0e0578d2d3ec97dca2459afa951 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #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"
@@ -54,6 +59,7 @@ ModelModules& ReferenceAPI_getModelModules();
 #include "map.h"
 #include "filetypes.h"
 
+extern bool g_writeMapComments;
 
 bool References_Saved();
 
@@ -105,7 +111,7 @@ bool MapResource_saveFile( const MapFormat& format, scene::Node& root, GraphTrav
        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;
        }
 
@@ -206,7 +212,7 @@ NodeSmartReference ModelResource_load( ModelLoader* loader, const char* name ){
 
 
 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 );
@@ -223,6 +229,7 @@ struct PathEqual
 struct PathHash
 {
        typedef hash_t hash_type;
+
        hash_type operator()( const CopiedString& path ) const {
                return path_hash( path.c_str() );
        }
@@ -240,6 +247,7 @@ struct ModelKeyEqual
 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() ) );
        }
@@ -344,20 +352,24 @@ struct ModelResource : public Resource
                        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;
        }
@@ -396,6 +408,7 @@ struct ModelResource : public Resource
 
                return m_model != g_nullModel;
        }
+
        bool save(){
                if ( !mapSaved() ) {
                        const char* moduleName = findModuleName( GetFileTypeRegistry(), MapFormat::Name(), m_type.c_str() );
@@ -409,11 +422,13 @@ struct ModelResource : public Resource
                }
                return false;
        }
+
        void flush(){
                if ( realised() ) {
                        ModelCache_flush( m_path.c_str(), m_name.c_str() );
                }
        }
+
        scene::Node* getNode(){
                //if(m_model != g_nullModel)
                {
@@ -421,6 +436,7 @@ struct ModelResource : public Resource
                }
                //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() ) {
@@ -430,21 +446,25 @@ struct ModelResource : public Resource
 
                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 ) {
@@ -456,6 +476,7 @@ struct ModelResource : public Resource
                        m_observers.realise();
                }
        }
+
        void unrealise(){
                if ( ++m_unrealised == 1 ) {
                        m_observers.unrealise();
@@ -464,20 +485,24 @@ struct ModelResource : public Resource
                        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 );
@@ -485,6 +510,7 @@ struct ModelResource : public Resource
                        map->save();
                }
        }
+
        bool mapSaved() const {
                MapFile* map = Node_getMapFile( m_model );
                if ( map != 0 ) {
@@ -492,11 +518,13 @@ struct ModelResource : public Resource
                }
                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();
@@ -519,6 +547,7 @@ typedef std::list<ModelReferences::iterator> Iterators;
 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 )
        {
@@ -526,15 +555,18 @@ ModelReferencesSnapshot( ModelReferences& references ) : m_references( reference
                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();
 }
@@ -550,6 +582,7 @@ HashtableReferenceCache() : m_unrealised( 1 ){
 iterator begin(){
        return m_references.begin();
 }
+
 iterator end(){
        return m_references.end();
 }
@@ -562,6 +595,7 @@ Resource* capture( const char* path ){
        //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";
@@ -574,6 +608,7 @@ void setEntityCreator( EntityCreator& entityCreator ){
 bool realised() const {
        return m_unrealised == 0;
 }
+
 void realise(){
        ASSERT_MESSAGE( m_unrealised != 0, "HashtableReferenceCache::realise: already realised" );
        if ( --m_unrealised == 0 ) {
@@ -591,6 +626,7 @@ void realise(){
                }
        }
 }
+
 void unrealise(){
        if ( ++m_unrealised == 1 ) {
                g_realised = false;
@@ -609,6 +645,7 @@ void unrealise(){
                ModelCache_clear();
        }
 }
+
 void refresh(){
        ModelReferencesSnapshot snapshot( m_references );
        for ( ModelReferencesSnapshot::iterator i = snapshot.begin(); i != snapshot.end(); ++i )
@@ -691,9 +728,11 @@ ReferenceDependencies() :
        m_map_modules( GlobalRadiant().getRequiredGameDescriptionKeyValue( "maptypes" ) )
 {
 }
+
 ModelModules& getModelModules(){
        return m_model_modules.get();
 }
+
 MapModules& getMapModules(){
        return m_map_modules.get();
 }
@@ -704,6 +743,7 @@ class ReferenceAPI : public TypeSystemRef
 ReferenceCache* m_reference;
 public:
 typedef ReferenceCache Type;
+
 STRING_CONSTANT( Name, "*" );
 
 ReferenceAPI(){
@@ -713,11 +753,13 @@ ReferenceAPI(){
 
        m_reference = &GetReferenceCache();
 }
+
 ~ReferenceAPI(){
        GlobalFileSystem().detach( g_referenceCache );
 
        g_nullModel = g_nullNode;
 }
+
 ReferenceCache* getTable(){
        return m_reference;
 }
@@ -730,6 +772,7 @@ StaticRegisterModule staticRegisterReference( StaticReferenceModule::instance()
 ModelModules& ReferenceAPI_getModelModules(){
        return StaticReferenceModule::instance().getDependencies().getModelModules();
 }
+
 MapModules& ReferenceAPI_getMapModules(){
        return StaticReferenceModule::instance().getDependencies().getMapModules( );
 }
index 62674d4624c739ac5a8d53b53d91c835b317443c..c67cf0ea1cee2362e052af06d95a9316dfcf83df 100644 (file)
@@ -130,7 +130,7 @@ void render( const Renderable& renderable ) const {
                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();
index ce7ff97485c6e3aad8f6c9a886a45fcecbec5bcc..6fc44a3656138ed4cabcd22f220a1def04700fa1 100644 (file)
@@ -54,7 +54,6 @@
 #include "xywindow.h"
 
 
-
 #define DEBUG_RENDER 0
 
 inline void debug_string( const char* string ){
@@ -351,12 +350,14 @@ void destroy(){
        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();
@@ -844,8 +845,6 @@ void OpenGLState_constructDefault( OpenGLState& state ){
 }
 
 
-
-
 /// \brief A container of Renderable references.
 /// May contain the same Renderable multiple times, with different transforms.
 class OpenGLStateBucket
@@ -872,6 +871,7 @@ Renderables m_renderables;
 public:
 OpenGLStateBucket(){
 }
+
 void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview, const RendererLight* light = 0 ){
        m_renderables.push_back( RenderTransform( renderable, modelview, light ) );
 }
@@ -908,11 +908,12 @@ OpenGLStateBucket& m_bucket;
 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 );
 }
@@ -922,13 +923,15 @@ class CountLights
 {
 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;
 }
@@ -944,9 +947,12 @@ ModuleObservers m_observers;
 public:
 OpenGLShader() : m_shader( 0 ), m_used( 0 ){
 }
+
 ~OpenGLShader(){
 }
+
 void construct( const char* name );
+
 void destroy(){
        if ( m_shader ) {
                m_shader->DecRef();
@@ -959,6 +965,7 @@ void destroy(){
        }
        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 )
        {
@@ -979,7 +986,7 @@ void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview
                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
@@ -989,31 +996,37 @@ void addRenderable( const OpenGLRenderable& renderable, const Matrix4& modelview
                }
        }
 }
+
 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() );
 
@@ -1028,6 +1041,7 @@ void realise( const CopiedString& name ){
 
        m_observers.realise();
 }
+
 void unrealise(){
        m_observers.unrealise();
 
@@ -1038,18 +1052,22 @@ void 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();
@@ -1071,16 +1089,17 @@ class LinearLightList : public LightList
 {
 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 ) {
@@ -1114,6 +1133,7 @@ void evaluateLights() const {
        }
 #endif
 }
+
 void forEachLight( const RendererLightCallback& callback ) const {
        evaluateLights();
 
@@ -1122,6 +1142,7 @@ void forEachLight( const RendererLightCallback& callback ) const {
                callback( *( *i ) );
        }
 }
+
 void lightsChanged() const {
        m_lightsChanged = true;
 }
@@ -1147,6 +1168,7 @@ public:
 explicit CreateOpenGLShader( OpenGLShaderCache* cache = 0 )
        : m_cache( cache ){
 }
+
 OpenGLShader* construct( const CopiedString& name ){
        OpenGLShader* shader = new OpenGLShader;
        if ( m_cache->realised() ) {
@@ -1154,6 +1176,7 @@ OpenGLShader* construct( const CopiedString& name ){
        }
        return shader;
 }
+
 void destroy( OpenGLShader* shader ){
        if ( m_cache->realised() ) {
                shader->unrealise();
@@ -1180,12 +1203,14 @@ OpenGLShaderCache()
        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 == '['
@@ -1197,6 +1222,7 @@ Shader* capture( const char* name ){
 #endif
        return m_shaders.capture( name ).get();
 }
+
 void release( const char *name ){
 #if DEBUG_SHADERS
        globalOutputStream() << "shaders release: " << makeQuoted( name ) << '\n';
@@ -1311,6 +1337,7 @@ void render( RenderStateFlags globalstate, const Matrix4& modelview, const Matri
        }
        debug_string( "end rendering" );
 }
+
 void realise(){
        if ( --m_unrealised == 0 ) {
                if ( lightingSupported() && lightingEnabled() ) {
@@ -1333,6 +1360,7 @@ void realise(){
                }
        }
 }
+
 void unrealise(){
        if ( ++m_unrealised == 1 ) {
                for ( Shaders::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i )
@@ -1354,6 +1382,7 @@ void unrealise(){
                }
        }
 }
+
 bool realised(){
        return m_unrealised == 0;
 }
@@ -1362,12 +1391,15 @@ bool realised(){
 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 );
 
@@ -1383,6 +1415,7 @@ void setLighting( bool supported, bool enabled ){
                realise();
        }
 }
+
 void extensionsInitialised(){
        setLighting( GlobalOpenGL().GL_1_3()
                                 && GlobalOpenGL().ARB_vertex_program()
@@ -1419,6 +1452,7 @@ void extensionsInitialised(){
                }
        }
 }
+
 void setLightingEnabled( bool enabled ){
        setLighting( m_lightingSupported, enabled );
 }
@@ -1433,27 +1467,33 @@ LightLists m_lightLists;
 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;
@@ -1463,7 +1503,8 @@ void evaluateChanged(){
                }
        }
 }
-typedef MemberCaller<OpenGLShaderCache, &OpenGLShaderCache::evaluateChanged> EvaluateChangedCaller;
+
+typedef MemberCaller<OpenGLShaderCache, void(), &OpenGLShaderCache::evaluateChanged> EvaluateChangedCaller;
 
 typedef std::set<const Renderable*> Renderables;
 Renderables m_renderables;
@@ -1475,11 +1516,13 @@ void attachRenderable( const Renderable& renderable ){
        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;
@@ -2018,9 +2061,11 @@ public:
 }
 
 typedef States::iterator iterator;
+
 iterator begin(){
        return m_states.begin();
 }
+
 iterator end(){
        return m_states.end();
 }
@@ -2033,6 +2078,7 @@ void insert( const char* name, const OpenGLState& state ){
        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" );
@@ -2341,16 +2387,22 @@ void OpenGLShader::construct( const char* name ){
                                {
                                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;
@@ -2386,14 +2438,17 @@ class OpenGLStateLibraryAPI
 OpenGLStateMap m_stateMap;
 public:
 typedef OpenGLStateLibrary Type;
+
 STRING_CONSTANT( Name, "*" );
 
 OpenGLStateLibraryAPI(){
        g_openglStates = &m_stateMap;
 }
+
 ~OpenGLStateLibraryAPI(){
        g_openglStates = 0;
 }
+
 OpenGLStateLibrary* getTable(){
        return &m_stateMap;
 }
@@ -2416,6 +2471,7 @@ class ShaderCacheAPI
 ShaderCache* m_shaderCache;
 public:
 typedef ShaderCache Type;
+
 STRING_CONSTANT( Name, "*" );
 
 ShaderCacheAPI(){
@@ -2423,9 +2479,11 @@ ShaderCacheAPI(){
 
        m_shaderCache = GetShaderCache();
 }
+
 ~ShaderCacheAPI(){
        ShaderCache_Destroy();
 }
+
 ShaderCache* getTable(){
        return m_shaderCache;
 }
index 1f885cff9e16d73c7dd6b7945abb53a2e5be87a1..c1730c333ed31b7134c26733202bbc38b990a5c6 100644 (file)
 #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
 {
@@ -56,7 +45,9 @@ public:
 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;
index 4c9b30f9bdd6ae019e8183ec95c45767d95ee95a..eb2cacbd8129ea80a5d76decef17c5a6aabf248a 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "select.h"
 
+#include <gtk/gtk.h>
+
 #include "debugging/debugging.h"
 
 #include "ientity.h"
@@ -355,7 +357,7 @@ void Selection_UpdateWorkzone(){
                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() );
 }
@@ -834,11 +836,11 @@ void SceneSelectionChange( const Selectable& selectable ){
 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() );
 }
 
@@ -848,10 +850,6 @@ void Selection_destroy(){
 
 
 #include "gtkdlgs.h"
-#include <gtk/gtkbox.h>
-#include <gtk/gtkspinbutton.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtklabel.h>
 #include <gdk/gdkkeysyms.h>
 
 
@@ -885,13 +883,13 @@ inline Quaternion quaternion_for_euler_xyz_degrees( const Vector3& eulerXYZ ){
 
 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 );
@@ -909,8 +907,8 @@ static gboolean rotatedlg_apply( GtkWidget *widget, RotateDialog* rotateDialog )
        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 );
@@ -919,115 +917,103 @@ static gboolean rotatedlg_cancel( GtkWidget *widget, RotateDialog* rotateDialog
        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, 0 ) );
-                                       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, 0 );
+                                       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, 0 ) );
-                                       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, 0 );
+                                       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, 0 ) );
-                                       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, 0 );
+                                       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();
 }
 
 
@@ -1040,13 +1026,13 @@ void DoRotateDlg(){
 
 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 ) ) ) );
@@ -1062,24 +1048,24 @@ static gboolean scaledlg_apply( GtkWidget *widget, ScaleDialog* scaleDialog ){
        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;
 }
@@ -1087,91 +1073,79 @@ static gboolean scaledlg_delete( GtkWidget *widget, GdkEventAny *event, ScaleDia
 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();
 }
index 5013af7ba466d3b66840e10fbcb02cd6b54df667..df18daa9c5ef23a908cc40e83b84b62eb09617c9 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "selection.h"
+#include "globaldefs.h"
 
 #include "debugging/debugging.h"
 
@@ -156,7 +157,7 @@ inline float angle_between( const Vector3& a, const Vector3& b ){
 }
 
 
-#if defined( _DEBUG )
+#if GDEF_DEBUG
 class test_quat
 {
 public:
@@ -206,6 +207,7 @@ void transform_local2object( Matrix4& object, const Matrix4& local, const Matrix
 class Rotatable
 {
 public:
+virtual ~Rotatable() = default;
 virtual void rotate( const Quaternion& rotation ) = 0;
 };
 
@@ -270,6 +272,7 @@ void translation_local2object( Vector3& object, const Vector3& local, const Matr
 class Translatable
 {
 public:
+virtual ~Translatable() = default;
 virtual void translate( const Vector3& translation ) = 0;
 };
 
@@ -329,6 +332,7 @@ void Transform( const Matrix4& manip2object, const Matrix4& device2manip, const
 class Scalable
 {
 public:
+virtual ~Scalable() = default;
 virtual void scale( const Vector3& scaling ) = 0;
 };
 
@@ -463,7 +467,7 @@ void add_one(){
 }
 };
 
-#if defined( _DEBUG )
+#if GDEF_DEBUG
 #define DEBUG_SELECTION
 #endif
 
@@ -1719,7 +1723,7 @@ void insert( const Plane3& plane ){
 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;
 };
 
 
@@ -1978,7 +1982,7 @@ void TestQuadStrip( const VertexPointer& vertices, const IndexPointer& indices,
 class SelectionCounter
 {
 public:
-typedef const Selectable& first_argument_type;
+using func = void(const Selectable &);
 
 SelectionCounter( const SelectionChangeCallback& onchanged )
        : m_count( 0 ), m_onchanged( onchanged ){
@@ -2597,11 +2601,11 @@ void pivotChanged() const {
        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 ) {
@@ -2636,11 +2640,11 @@ EManipulatorMode ManipulatorMode() const {
 
 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 {
@@ -2713,7 +2717,7 @@ void addSelectionChangeCallback( const SelectionChangeHandler& handler ){
 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(){
@@ -3394,7 +3398,7 @@ void SelectionSystem_Construct(){
 
        g_RadiantSelectionSystem = new RadiantSelectionSystem;
 
-       SelectionSystem_boundsChanged = GlobalSceneGraph().addBoundsChangedCallback( FreeCaller<SelectionSystem_OnBoundsChanged>() );
+       SelectionSystem_boundsChanged = GlobalSceneGraph().addBoundsChangedCallback( FreeCaller<void(), SelectionSystem_OnBoundsChanged>() );
 
        GlobalShaderCache().attachRenderable( getSelectionSystem() );
 }
@@ -3438,7 +3442,7 @@ inline WindowVector window_constrained( WindowVector window, std::size_t x, std:
        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;
@@ -3557,7 +3561,7 @@ void mouseMoved( DeviceVector position ){
        m_current = device_constrained( position );
        draw_area();
 }
-typedef MemberCaller1<Selector_, DeviceVector, &Selector_::mouseMoved> MouseMovedCaller;
+typedef MemberCaller<Selector_, void(DeviceVector), &Selector_::mouseMoved> MouseMovedCaller;
 
 void mouseUp( DeviceVector position ){
        testSelect( device_constrained( position ) );
@@ -3565,7 +3569,7 @@ void mouseUp( DeviceVector position ){
        g_mouseMovedCallback.clear();
        g_mouseUpCallback.clear();
 }
-typedef MemberCaller1<Selector_, DeviceVector, &Selector_::mouseUp> MouseUpCaller;
+typedef MemberCaller<Selector_, void(DeviceVector), &Selector_::mouseUp> MouseUpCaller;
 };
 
 
@@ -3582,14 +3586,14 @@ bool mouseDown( DeviceVector position ){
 void mouseMoved( DeviceVector position ){
        getSelectionSystem().MoveSelected( *m_view, &position[0] );
 }
-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 Scene_copyClosestTexture( SelectionTest& test );
index 16b9aa2f82cf46a470c5d4594919f512cf1b1cdd..99846fed6a61bda0686667f3cfc2f5f8bbd75445 100644 (file)
@@ -23,7 +23,7 @@
 #define INCLUDED_SELECTION_H
 
 #include "windowobserver.h"
-#include "generic/callbackfwd.h"
+#include "generic/callback.h"
 
 struct rect_t
 {
@@ -31,13 +31,14 @@ 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;
 };
index 1904867b949c0eeec93aacf717a4853d975f022a..2a264e6dcd14ede2803c2ee7e3789f5dff3aa416 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "server.h"
+#include "globaldefs.h"
 
 #include "debugging/debugging.h"
 #include "warnings.h"
@@ -60,7 +61,6 @@ DebugMessageHandler& getDebugMessageHandler(){
 }
 
 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";
        }
@@ -89,11 +89,11 @@ void foreachModule( const char* type, int version, const Visitor& visitor ){
 };
 
 
-#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(
@@ -140,13 +140,12 @@ FunctionPointer findSymbol( const char* symbol ){
 }
 };
 
-#elif defined( POSIX )
+#elif GDEF_OS_POSIX
 
 #include <dlfcn.h>
 
-class DynamicLibrary
-{
-void* m_library;
+class DynamicLibrary {
+       void *m_library;
 public:
 typedef int ( *FunctionPointer )();
 
index 79a7de95326101db7f621cc350bba3b9c7244b92..d2a27d7e01848315d92ff3aaf407a0ac3128f850 100644 (file)
@@ -1,25 +1,25 @@
-
 #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;
index 51ef50387bdc377685eac76242c3a20e7c63807a..5e63857428fae5ae54a22ea94ab0a55e965658b8 100644 (file)
  */
 
 #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 ){
@@ -48,7 +50,7 @@ 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"
@@ -288,7 +290,7 @@ void write_stack_trace( TextOutputStream& outputStream ){
        }
 }
 
-#elif defined ( WIN32 )
+#elif GDEF_OS_WINDOWS
 void write_stack_trace( TextOutputStream& outputStream ){
        outputStream << "\nStacktrace is disabled on this compiler\n";
 }
index e48f9b0233a8b420817a80da428fcd8acb41ed5d..dbf3666e22264b49b457993eaf3f371acf9c6052 100644 (file)
@@ -27,6 +27,8 @@
 
 #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"
@@ -89,18 +83,18 @@ namespace TexTool
 {
 
 //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(){
@@ -111,9 +105,9 @@ 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 );
@@ -126,26 +120,26 @@ class Increment
 {
 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;
@@ -165,11 +159,9 @@ GtkCheckButton* m_surfaceFlags[32];
 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;
@@ -180,7 +172,7 @@ Increment m_vshiftIncrement;
 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 ) ),
@@ -196,8 +188,6 @@ SurfaceInspector() :
        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] ),
@@ -208,16 +198,16 @@ SurfaceInspector() :
        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() ) {
@@ -226,13 +216,13 @@ void queueDraw(){
 }
 
 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
@@ -245,7 +235,7 @@ inline SurfaceInspector& getSurfaceInspector(){
 }
 }
 
-void SurfaceInspector_constructWindow( GtkWindow* main_window ){
+void SurfaceInspector_constructWindow( ui::Window main_window ){
        getSurfaceInspector().constructWindow( main_window );
 }
 void SurfaceInspector_destroyWindow(){
@@ -400,10 +390,10 @@ void SurfaceInspector_GridChange(){
 // 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";
@@ -417,7 +407,7 @@ static void OnBtnMatchGrid( GtkWidget *widget, gpointer data ){
 // 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();
 
        }
@@ -451,27 +441,23 @@ void SurfaceInspector_FitTextureH(){
        Select_FitTextureH( getSurfaceInspector().m_fitHorizontal, getSurfaceInspector().m_fitVertical );
 }
 
-static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){
-       Scene_PatchCapTexture_Selected( GlobalSceneGraph() );
+static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){
+       Patch_CapTexture();
 }
 
-static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){
-       Scene_PatchNaturalTexture_Selected( GlobalSceneGraph() );
+static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){
+       Patch_NaturalTexture();
 }
 
-static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){
-       float fx, fy;
-
-       if ( DoTextureLayout( &fx, &fy ) == eIDOK ) {
-               Scene_PatchTileTexture_Selected( GlobalSceneGraph(), fx, fy );
-       }
+static void OnBtnPatchreset( ui::Widget widget, gpointer data ){
+       Patch_ResetTexture();
 }
 
-static void OnBtnPatchFit( GtkWidget *widget, gpointer data ){
-       Scene_PatchTileTexture_Selected( GlobalSceneGraph(), 1, 1 );
+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;
@@ -500,7 +486,7 @@ static void OnBtnAxial( GtkWidget *widget, gpointer data ){
        Select_SetTexdef( projection );
 }
 
-static void OnBtnFaceFit( GtkWidget *widget, gpointer data ){
+static void OnBtnFaceFit( ui::Widget widget, gpointer data ){
        getSurfaceInspector().exportData();
        SurfaceInspector_FitTexture();
 }
@@ -609,12 +595,12 @@ const char* getContentFlagName( std::size_t bit ){
 // =============================================================================
 // 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 );
 
@@ -625,25 +611,25 @@ GtkWindow* SurfaceInspector::BuildDialog(){
 
        {
                // 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 );
@@ -652,358 +638,284 @@ GtkWindow* SurfaceInspector::BuildDialog(){
 
 
                {
-                       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 ) );
                                                        }
                                                }
@@ -1011,58 +923,56 @@ GtkWindow* SurfaceInspector::BuildDialog(){
                                }
                        }
                        {
-                               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 );
                                        }
@@ -1073,49 +983,49 @@ GtkWindow* SurfaceInspector::BuildDialog(){
 #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
@@ -1134,27 +1044,27 @@ GtkWindow* SurfaceInspector::BuildDialog(){
    ===============
  */
 
-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;
@@ -1210,12 +1120,12 @@ void SurfaceInspector::Update(){
 
                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 ) ) );
                }
        }
 }
@@ -1246,11 +1156,11 @@ void SurfaceInspector::ApplyShader(){
 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
@@ -1291,14 +1201,14 @@ void Face_getTexture( Face& face, CopiedString& shader, TextureProjection& proje
        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 ){
@@ -1306,16 +1216,16 @@ void Patch_getTexture( Patch& patch, CopiedString& shader, TextureProjection& pr
        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
 {
@@ -1330,8 +1240,8 @@ void Face_getClosest( Face& face, SelectionTest& test, SelectionIntersection& be
        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 );
        }
 }
 
@@ -1385,8 +1295,8 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
                                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
                                        {
@@ -1501,15 +1411,15 @@ void SurfaceInspector_constructPage( PreferenceGroup& group ){
        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) );
 }
 
 
@@ -1523,17 +1433,17 @@ void SurfaceInspector_Construct(){
 
        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() );
 
@@ -1909,14 +1819,14 @@ void focus(){
 //     << 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";
 
@@ -2015,7 +1925,7 @@ Vector2 trans;
 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 ) {
@@ -2077,7 +1987,7 @@ gboolean button_press( GtkWidget * win, GdkEventButton * e, gpointer ){
        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 ) {
@@ -2139,7 +2049,7 @@ gboolean button_release( GtkWidget * win, GdkEventButton * e, gpointer ){
    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 ) {
@@ -2316,7 +2226,7 @@ gboolean motion( GtkWidget * win, GdkEventMotion * e, gpointer ){
 
 //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...
@@ -2330,7 +2240,7 @@ void flipX( GtkToggleButton *, gpointer ){
        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];
index 0e0ed24a4b8e13d3e7f4642cff4fc3c22320457c..2c1d945dcd83c413f70d636f9376c7f51068a85f 100644 (file)
@@ -19,6 +19,8 @@
    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
 
@@ -26,9 +28,7 @@
 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();
index 781dcbe44ca8c96c3e4f233bdfbbec430dbd5e93..04512f6f6887374ec735eaa4bc92a013c7f811b7 100644 (file)
  */
 
 #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>;
index 3406d2a00e3d40c08bb277b1bfcc0bccca31afa9..ed2f9f5aee6d58ed4786645c98cd7d4cee5136eb 100644 (file)
@@ -22,9 +22,6 @@
 #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
index b223e2ee1318a87c40d0b7ccbab788f13a72f1c1..02f706b90e0629d6df7808ea62f3f88067abcba7 100644 (file)
@@ -166,7 +166,7 @@ inline const int& min_int( const int& left, const int& right ){
 
 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.
@@ -409,6 +409,7 @@ TexturesCacheObserver* m_observer;
 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;
@@ -548,9 +549,9 @@ void Textures_Unrealise(){
 }
 
 
-Callback g_texturesModeChangedNotify;
+Callback<void()> g_texturesModeChangedNotify;
 
-void Textures_setModeChangedNotify( const Callback& notify ){
+void Textures_setModeChangedNotify( const Callback<void()>& notify ){
        g_texturesModeChangedNotify = notify;
 }
 
@@ -620,99 +621,106 @@ void Textures_UpdateTextureCompressionFormat(){
        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 ){
        {
@@ -720,8 +728,7 @@ 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(
@@ -729,16 +736,14 @@ void Textures_constructPreferences( PreferencesPage& page ){
                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)
                        );
        }
        {
@@ -758,8 +763,7 @@ void Textures_constructPreferences( PreferencesPage& page ){
                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)
                        );
        }
 }
@@ -768,23 +772,27 @@ void Textures_constructPage( PreferenceGroup& group ){
        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();
 
index 297ebc998359841d6cd7a590f0c80d73c545d3cb..3176ce6db44a3f5779752cf479ec6de55c14d7b5 100644 (file)
 #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
index d18a152e8333fdc3efcbe67ef4bcc3bc2c1ba118..72573afe8dd64fc723a29a5934d245464b3c48c1 100644 (file)
 
 #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"
@@ -111,10 +109,58 @@ void TextureGroups_addWad( TextureGroups& groups, const char* archive ){
 #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 = true;
+}
+
+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 ) ) {
@@ -122,26 +168,22 @@ void TextureGroups_addShader( TextureGroups& groups, const char* shaderName ){
                }
        }
 }
-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 = true;
-}
+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;
 
@@ -154,31 +196,34 @@ static gboolean deferred_value_changed( gpointer 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 );
 
@@ -189,26 +234,37 @@ enum StartupShaders
        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
 {
@@ -219,28 +275,29 @@ int m_nTotalHeight;
 
 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;
@@ -275,6 +332,7 @@ bool m_tags;
 // The uniform size (in pixels) that textures are resized to when m_resizeTextures is true.
 int m_uniformTextureSize;
 int m_uniformTextureMinSize;
+
 // Return the display width of a texture in the texture browser
 /*void getTextureWH( qtexture_t* tex, int *width, int *height ){
        if ( !g_TextureBrowser_fixedSize ) {
@@ -314,6 +372,7 @@ int m_uniformTextureMinSize;
                }
        }
 }
+
 */
 void getTextureWH( qtexture_t* tex, int &W, int &H ){
                // Don't use uniform size
@@ -347,13 +406,14 @@ void getTextureWH( qtexture_t* tex, int &W, int &H ){
 }
 
 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 ),
@@ -507,14 +567,23 @@ bool TextureSearch_IsShown( const char* name ){
        }
 }
 
-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 ){
-       // 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" ) {
@@ -648,8 +717,10 @@ void realise(){
        /* texturebrowser tree update on vfs restart */
 //     TextureBrowser_constructTreeStore();
 }
+
 void unrealise(){
 }
+
 void insert( const SignalHandler& handler ){
        m_realiseCallbacks.connectLast( handler );
 }
@@ -671,14 +742,19 @@ void TextureBrowser_activeShadersChanged( TextureBrowser& textureBrowser ){
        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);
+               }
+       }
+};
 
 
 /*
@@ -716,14 +792,27 @@ bool texture_name_ignore( const char* name ){
                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;
 }
 
@@ -738,7 +827,7 @@ void visit( const char* name ){
 
 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 );
@@ -750,18 +839,18 @@ void TextureBrowser_updateTitle(){
 }
 
 
-
 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 ) ) {
@@ -791,7 +880,8 @@ void TextureDirectory_loadTexture( const char* directory, const char* texture ){
        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
 {
@@ -800,6 +890,7 @@ public:
 LoadTexturesByTypeVisitor( const char* dirstring )
        : m_dirstring( dirstring ){
 }
+
 void visit( const char* minor, const _QERPlugImageTable& table ) const {
        GlobalFileSystem().forEachFile( m_dirstring, minor, TextureDirectoryLoadTextureCaller( m_dirstring ) );
 }
@@ -818,7 +909,7 @@ void TextureBrowser_ShowDirectory( TextureBrowser& textureBrowser, const char* d
                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" ) {
@@ -842,7 +933,7 @@ void TextureBrowser_ShowTagSearchResult( TextureBrowser& textureBrowser, const c
        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" ) {
@@ -863,40 +954,53 @@ void TextureBrowser_ShowTagSearchResult( TextureBrowser& textureBrowser, const c
 
 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 FreeCaller<void(const Callback<void(bool)> &), TextureBrowser_filterMissing> TextureBrowser_filterMissingExport;
+
+void TextureBrowser_filterFallback( const Callback<void(bool)> & importer ){
+       importer( g_TextureBrowser_filterFallback );
 }
-typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_filterNotex> TextureBrowser_filterNotexExport;
 
-void TextureBrowser_enableAlpha( const BoolImportCallback& importer ){
+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 ){
        if ( hideUnused ) {
@@ -1091,6 +1195,7 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
 
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
        glDisable( GL_DEPTH_TEST );
+
        //glDisable( GL_BLEND );
        if ( g_TextureBrowser_enableAlpha ) {
                glEnable( GL_BLEND );
@@ -1275,7 +1380,7 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
 }
 
 void TextureBrowser_queueDraw( TextureBrowser& textureBrowser ){
-       if ( textureBrowser.m_gl_widget != 0 ) {
+       if ( textureBrowser.m_gl_widget ) {
                gtk_widget_queue_draw( textureBrowser.m_gl_widget );
        }
 }
@@ -1333,23 +1438,22 @@ enum
        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;
@@ -1357,35 +1461,33 @@ void BuildStoreAvailableTags(   GtkListStore* storeAvailable,
        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 );
                                        }
                                }
                        }
@@ -1393,7 +1495,7 @@ void BuildStoreAvailableTags(   GtkListStore* storeAvailable,
        }
 }
 
-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 ) {
@@ -1403,9 +1505,9 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event,
                                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() );
                        }
@@ -1419,13 +1521,15 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event,
 
                        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();
+               const char* sh = textureBrowser->shader.c_str();
                char* dir = strrchr( sh, '/' );
                if( dir != NULL ){
                        *(dir + 1) = '\0';
@@ -1440,6 +1544,7 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event,
                                }
                        }
                }
+               #endif
        }
        else if ( event->type == GDK_2BUTTON_PRESS && event->button == 3 ) {
                ScopeDisableScreenUpdates disableScreenUpdates( TextureBrowser_getComonShadersDir(), "Loading Textures" );
@@ -1449,7 +1554,7 @@ gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event,
        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 ) {
@@ -1460,11 +1565,11 @@ gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event
        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 );
        }
@@ -1479,8 +1584,8 @@ void TextureBrowser_scrollChanged( void* data, gdouble value ){
        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 ){
@@ -1489,20 +1594,20 @@ 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 );
@@ -1511,7 +1616,7 @@ gboolean TextureBrowser_size_allocate( GtkWidget* widget, GtkAllocation* allocat
        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 );
@@ -1543,7 +1648,7 @@ void TextureBrowser_ToggleHideUnused(){
        }
 }
 
-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;
 
@@ -1600,31 +1705,28 @@ TextureGroups TextureGroups_constructTreeView(){
 
 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 );
-
-       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];
@@ -1649,36 +1751,36 @@ void TreeView_onRowActivated( GtkTreeView* treeview, GtkTreePath* path, GtkTreeV
 }
 
 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 );
@@ -1688,12 +1790,12 @@ void TextureBrowser_createContextMenu( GtkWidget *treeview, GdkEventButton *even
                                        gdk_event_get_time( (GdkEvent*)event ) );
 }
 
-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 );
@@ -1706,29 +1808,34 @@ gboolean TreeViewTags_onButtonPressed( GtkWidget *treeview, GdkEventButton *even
 }
 
 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 );
 
 
@@ -1749,20 +1856,18 @@ GtkMenuItem* TextureBrowser_constructViewMenu( GtkMenu* 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;
 }
 
@@ -1770,8 +1875,8 @@ void Popup_View_Menu( GtkWidget *widget, GtkMenu *menu ){
        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 );
@@ -1783,8 +1888,8 @@ GtkMenuItem* TextureBrowser_constructToolsMenu( GtkMenu* 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 );
@@ -1800,10 +1905,10 @@ GtkMenuItem* TextureBrowser_constructTagsMenu( GtkMenu* 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;
@@ -1814,20 +1919,20 @@ void TextureBrowser_assignTags(){
        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() );
@@ -1846,8 +1951,7 @@ void TextureBrowser_assignTags(){
                                        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);
                                }
                        }
                }
@@ -1865,20 +1969,20 @@ void TextureBrowser_removeTags(){
        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 );
                                }
@@ -1897,15 +2001,13 @@ void TextureBrowser_removeTags(){
 }
 
 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());
        }
 }
 
@@ -1916,7 +2018,7 @@ void TextureBrowser_searchTags(){
        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 );
 
@@ -1926,13 +2028,13 @@ void TextureBrowser_searchTags(){
 
                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 );
@@ -1986,31 +2088,29 @@ void TextureBrowser_toggleSearchButton(){
                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(){
@@ -2052,16 +2152,17 @@ 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 );
 
-       name = NULL;
-       name << GlobalRadiant().getAppPath() << "bitmaps/shadernotex.png";
-       g_shadernotex = name.c_str();
+       g_notex = notex->getTexture()->name;
+       g_shadernotex = shadernotex->getTexture()->name;
+
+       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
@@ -2070,141 +2171,125 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){
        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_widget_show( 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  );
+               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();
-                       //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 menu_tags = ui::Menu(ui::New);
+                       // 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 );
                }
                { // 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
@@ -2212,126 +2297,126 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){
 
                        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_widget_show( 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  );
+                       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 ) );
+                       scrolled_win.show();
+                       gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW( scrolled_win ), g_TextureBrowser.m_assigned_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_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?
@@ -2341,12 +2426,12 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){
 }
 
 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 ){
@@ -2358,7 +2443,7 @@ void TextureBrowser_setBackgroundColour( TextureBrowser& textureBrowser, const V
        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;
@@ -2381,17 +2466,16 @@ void TextureBrowser_addTag(){
        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());
        }
 }
 
@@ -2405,7 +2489,7 @@ void TextureBrowser_renameTag(){
 
        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
@@ -2417,16 +2501,16 @@ void TextureBrowser_renameTag(){
                        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() );
@@ -2440,36 +2524,36 @@ void TextureBrowser_renameTag(){
        }
        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 );
@@ -2480,7 +2564,7 @@ void TextureBrowser_deleteTag(){
                }
        }
        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." );
        }
 }
 
@@ -2528,17 +2612,18 @@ void TextureBrowser_pasteTag(){
        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 );
@@ -2556,6 +2641,7 @@ void RefreshShaders(){
                TextureBrowser_ShowDirectory( GlobalTextureBrowser(), dirName );
                TextureBrowser_queueDraw( GlobalTextureBrowser() );
        }
+
        else{
                ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" );
                GlobalShaderSystem().refresh();
@@ -2563,7 +2649,6 @@ void RefreshShaders(){
                TextureBrowser_constructTreeStore();
                UpdateAllWindows();
        }
-
 }
 
 void TextureBrowser_ToggleShowShaders(){
@@ -2605,9 +2690,9 @@ void TextureBrowser_showAll(){
 }
 
 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;
@@ -2637,10 +2722,18 @@ void TextureBrowser_FixedSize(){
        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(){
@@ -2649,7 +2742,7 @@ 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() ) ) {
@@ -2662,76 +2755,81 @@ void TextureBrowser_exportTitle( const StringImportCallback& importer ){
        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;
+               }
+       }
+
+       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;
+               }
+       }
+};
 
-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;
+struct UniformTextureSize {
+       static void Export(const TextureBrowser &self, const Callback<void(int)> &returnz) {
+               returnz(g_TextureBrowser.m_uniformTextureSize);
        }
-}
-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;
+       static void Import(TextureBrowser &self, int value) {
+               if (value > 16)
+                       TextureBrowser_setUniformSize(self, value);
+       }
+};
 
-void UniformTextureMinSizeImport( TextureBrowser& textureBrowser, int value ){
-       if ( value >= 16 )
-               TextureBrowser_setUniformMinSize( textureBrowser, value );
-}
-typedef ReferenceCaller1<TextureBrowser, int, UniformTextureMinSizeImport> UniformTextureMinSizeImportCaller;
+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 );
@@ -2742,70 +2840,61 @@ void TextureBrowser_constructPreferences( PreferencesPage& page ){
                page.appendCombo( "Load Shaders at Startup", reinterpret_cast<int&>( GlobalTextureBrowser().m_startupShaders ), STRING_ARRAY_RANGE( startup_shaders ) );
        }
 }
+
 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 ) );
+       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 ) );
 
        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();
 
@@ -2813,12 +2902,13 @@ void TextureBrowser_Construct(){
 
        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;
 }
index d62c772a5a13cafc23d1421be2944e50d8b5aee8..d354c9dfd00f4dbfc26c67fd240b2fba813e5fb9 100644 (file)
 #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();
 
 
@@ -45,13 +44,9 @@ const char* TextureBrowser_GetSelectedShader( TextureBrowser& textureBrower );
 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 );
@@ -59,6 +54,8 @@ void TextureBrowser_setBackgroundColour( TextureBrowser& textureBrowser, const V
 void TextureBrowser_addActiveShadersChangedCallback( const SignalHandler& handler );
 void TextureBrowser_addShadersRealiseCallback( const SignalHandler& handler );
 
-GtkWidget* TextureBrowser_getGLWidget();
+void TextureBrowser_RefreshShaders();
+
+ui::Widget TextureBrowser_getGLWidget();
 
 #endif
index 1c55d93022c7f51ebb82b98e53f3eedda10991f4..8d10b82ba8b36cc8cda79ee82fcc541f0b78f263 100644 (file)
  */
 
 #include "timer.h"
+#include "globaldefs.h"
 
 
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
 
 #include <windows.h>
 
@@ -62,7 +63,7 @@ public:
 
 
 
-#elif defined( POSIX )
+#elif GDEF_OS_POSIX
 
 #include <time.h>
 #include "sys/time.h"
index 4d2f82384d8e62415ca44f9ac41644701bf063d6..12441f0e7ee0f5523f005c79dc8c8c1642902011 100644 (file)
  */
 
 #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"
@@ -45,7 +45,7 @@ inline Nameable* Node_getNameable( scene::Node& node ){
 #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 );
@@ -54,7 +54,7 @@ inline void gtk_tree_model_get_pointer( GtkTreeModel* model, GtkTreeIter* iter,
 
 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 );
 }
 
@@ -64,12 +64,12 @@ void graph_tree_model_delete( GraphTreeModel* model ){
 
 
 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, &current );
+               gtk_tree_model_get_pointer( model, iter, 0, &current );
                if ( current == node ) {
                        return true;
                }
@@ -110,7 +110,7 @@ bool graph_tree_model_find_parent( GraphTreeModel* model, const scene::Path& pat
        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 ) {
@@ -118,7 +118,7 @@ void node_attach_name_changed_callback( scene::Node& node, const Callback& callb
                }
        }
 }
-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 ) {
@@ -153,14 +153,14 @@ void graph_tree_model_row_inserted( GraphTreeModel* model, const scene::Instance
        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 );
 }
@@ -217,7 +217,7 @@ static GtkTreeModelFlags graph_tree_model_get_flags( GtkTreeModel* tree_model ){
        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;
 
@@ -240,14 +240,14 @@ inline void graph_iterator_write_tree_iter( graph_type::iterator i, GtkTreeIter*
        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 );
@@ -275,12 +275,12 @@ static gboolean graph_tree_model_get_iter( GtkTreeModel* tree_model, GtkTreeIter
        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 )
        {
@@ -301,7 +301,7 @@ static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTree
 }
 
 
-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" );
 
@@ -317,7 +317,7 @@ static void graph_tree_model_get_value( GtkTreeModel *tree_model, GtkTreeIter  *
        }
 }
 
-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 );
@@ -339,7 +339,7 @@ static gboolean graph_tree_model_iter_next( GtkTreeModel  *tree_model, GtkTreeIt
        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 );
@@ -357,7 +357,7 @@ static gboolean graph_tree_model_iter_children( GtkTreeModel *tree_model, GtkTre
        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 );
@@ -366,7 +366,7 @@ static gboolean graph_tree_model_iter_has_child( GtkTreeModel *tree_model, GtkTr
        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 );
@@ -386,7 +386,7 @@ static gint graph_tree_model_iter_n_children( GtkTreeModel *tree_model, GtkTreeI
        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 );
@@ -408,7 +408,7 @@ static gboolean graph_tree_model_iter_nth_child( GtkTreeModel *tree_model, GtkTr
        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 );
@@ -465,17 +465,17 @@ static void graph_tree_model_tree_model_init( GtkTreeModelIface *iface ){
        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;
@@ -486,8 +486,8 @@ static gboolean graph_tree_model_drag_data_delete( GtkTreeDragSource *drag_sourc
        }
 }
 
-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
@@ -504,8 +504,8 @@ static void graph_tree_model_drag_source_init( GtkTreeDragSourceIface *iface ){
        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;
@@ -528,23 +528,23 @@ static gboolean graph_tree_model_drag_data_received( GtkTreeDragDest *drag_dest,
        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 );
                                }
@@ -647,7 +647,13 @@ void detach( const NameCallback& callback ){
 };
 
 void node_attach_name_changed_callback( scene::Node& node, const NameCallback& callback ){
-       if ( &node != 0 ) {
+       // 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.
+       volatile intptr_t n = (intptr_t)&node;
+
+       if ( n != 0 ) {
                Nameable* nameable = Node_getNameable( node );
                if ( nameable != 0 ) {
                        nameable->attach( callback );
@@ -655,7 +661,9 @@ void node_attach_name_changed_callback( scene::Node& node, const NameCallback& c
        }
 }
 void node_detach_name_changed_callback( scene::Node& node, const NameCallback& callback ){
-       if ( &node != 0 ) {
+       volatile intptr_t n = (intptr_t)&node;  // see the comment on line 650
+
+       if ( n != 0 ) {
                Nameable* nameable = Node_getNameable( node );
                if ( nameable != 0 ) {
                        nameable->detach( callback );
@@ -669,12 +677,12 @@ void graph_tree_model_row_inserted( GraphTreeModel* model, graph_type::iterator
        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 );
 }
@@ -683,9 +691,9 @@ void graph_tree_model_row_deleted( GraphTreeModel* model, graph_type::iterator i
        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 );
 }
@@ -716,11 +724,11 @@ void graph_tree_model_insert( GraphTreeModel* model, const scene::Instance& inst
 
        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" );
@@ -752,7 +760,7 @@ GraphTreeNode( scene::Instance& instance ) : m_instance( instance ), m_parent( 0
        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" );
 }
 
@@ -791,7 +799,7 @@ void swap( GraphTreeNode& other ){
 void rowChanged(){
        graph_tree_model_row_changed( *this );
 }
-typedef MemberCaller<GraphTreeNode, &GraphTreeNode::rowChanged> RowChangedCaller;
+typedef MemberCaller<GraphTreeNode, void(), &GraphTreeNode::rowChanged> RowChangedCaller;
 };
 
 struct GraphTreeModel
@@ -806,14 +814,12 @@ struct GraphTreeModelClass
        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;
@@ -835,21 +841,21 @@ inline void graph_iterator_write_tree_iter( GraphTreeNode::iterator i, GtkTreeIt
        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;
@@ -860,7 +866,7 @@ static gboolean graph_tree_model_get_iter( GtkTreeModel* tree_model, GtkTreeIter
 
        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;
@@ -870,11 +876,11 @@ static gboolean graph_tree_model_get_iter( GtkTreeModel* tree_model, GtkTreeIter
        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 )
        {
@@ -893,8 +899,8 @@ static GtkTreePath* graph_tree_model_get_path( GtkTreeModel* tree_model, GtkTree
 }
 
 
-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 );
@@ -910,8 +916,8 @@ static void graph_tree_model_get_value( GtkTreeModel *tree_model, GtkTreeIter  *
        }
 }
 
-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;
 
@@ -926,9 +932,9 @@ static gboolean graph_tree_model_iter_next( GtkTreeModel  *tree_model, GtkTreeIt
        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;
@@ -937,21 +943,21 @@ static gboolean graph_tree_model_iter_children( GtkTreeModel *tree_model, GtkTre
        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 );
@@ -962,10 +968,10 @@ static gboolean graph_tree_model_iter_nth_child( GtkTreeModel *tree_model, GtkTr
        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 )
                {
@@ -1002,7 +1008,7 @@ static void graph_tree_model_init( GraphTreeModel *graph_tree_model ){
 }
 
 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;
 
@@ -1020,18 +1026,18 @@ static void graph_tree_model_class_init( GraphTreeModelClass *class_ ){
 }
 
 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 ){
@@ -1071,7 +1077,7 @@ 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;
 }
@@ -1084,7 +1090,7 @@ void graph_tree_model_row_changed( GraphTreeModel* model, GraphTreeNode::iterato
        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 );
 
@@ -1095,7 +1101,7 @@ void graph_tree_model_row_inserted( GraphTreeModel* model, GraphTreeNode::iterat
        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 );
 
@@ -1106,7 +1112,7 @@ void graph_tree_model_row_deleted( GraphTreeModel* model, GraphTreeNode::iterato
        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 );
 
@@ -1124,7 +1130,8 @@ void graph_tree_model_row_deleted( GraphTreeModel& model, GraphTreeNode::iterato
 const char* node_get_name( scene::Node& node );
 
 const char* node_get_name_safe( scene::Node& node ){
-       if ( &node == 0 ) {
+       volatile intptr_t n = (intptr_t)&node;  // see the comment on line 650
+       if ( n == 0 ) {
                return "";
        }
        return node_get_name( node );
@@ -1142,7 +1149,8 @@ GraphTreeNode* graph_tree_model_find_parent( GraphTreeModel* model, const scene:
 }
 
 void node_attach_name_changed_callback( scene::Node& node, const NameCallback& callback ){
-       if ( &node != 0 ) {
+       volatile intptr_t n = (intptr_t)&node;  // see the comment on line 650
+       if ( n != 0 ) {
                Nameable* nameable = Node_getNameable( node );
                if ( nameable != 0 ) {
                        nameable->attach( callback );
@@ -1150,7 +1158,8 @@ void node_attach_name_changed_callback( scene::Node& node, const NameCallback& c
        }
 }
 void node_detach_name_changed_callback( scene::Node& node, const NameCallback& callback ){
-       if ( &node != 0 ) {
+       volatile intptr_t n = (intptr_t)&node;  // see the comment on line 650
+       if ( n != 0 ) {
                Nameable* nameable = Node_getNameable( node );
                if ( nameable != 0 ) {
                        nameable->detach( callback );
@@ -1160,7 +1169,7 @@ void node_detach_name_changed_callback( scene::Node& node, const NameCallback& c
 
 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 )
        {
@@ -1168,7 +1177,7 @@ void graph_tree_node_foreach_pre( GraphTreeNode::iterator root, const Callback1<
        }
 }
 
-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 );
@@ -1190,12 +1199,12 @@ void graph_tree_model_set_name( const scene::Instance& instance, const char* nam
        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 ){
@@ -1205,11 +1214,11 @@ void graph_tree_model_insert( GraphTreeModel* model, const scene::Instance& inst
 
        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() );
 
@@ -1263,7 +1272,7 @@ TestGraphTreeModel(){
        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 );
@@ -1358,7 +1367,7 @@ TestGraphTreeModel(){
 
        {
                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 );
 
@@ -1368,7 +1377,7 @@ TestGraphTreeModel(){
 
        {
                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 );
 
@@ -1382,7 +1391,7 @@ TestGraphTreeModel(){
                ++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 );
@@ -1399,7 +1408,7 @@ TestGraphTreeModel(){
                ++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 );
index 9910fb98a1b68ac2bc7495b8af64eb0a492058a8..fb741abdd9db93059102f34a1ced0a595a78d531 100644 (file)
@@ -57,7 +57,7 @@ DebugScopeTimer( const char* operation )
 
 class RadiantUndoSystem : public UndoSystem
 {
-INTEGER_CONSTANT( MAX_UNDO_LEVELS, 1024 );
+UINT_CONSTANT( MAX_UNDO_LEVELS, 1024 );
 
 class Snapshot
 {
@@ -377,36 +377,36 @@ void trackersRedo() const {
 
 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
@@ -421,7 +421,7 @@ typedef UndoSystem Type;
 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 );
 }
index e5abc077f5b9424e2ddbb9afb66a368d410993b8..f49cb88664623315c2b08c51e9255d8e5f1fdd94 100644 (file)
  */
 
 #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];
@@ -56,6 +57,6 @@ void OpenURL( const char *url ){
        // 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!" );
        }
 }
index 7e8cdf957bfe69ceb89f934b48b3604e39b2c977..ad322d5d817c6e76da75e2723cdf0ab4a855e938 100644 (file)
 #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
 
index a598ff51c3a17205f676bd60209fed5a0ca1d87e..bbae3fab77af86854c191e8d4656fd249961213e 100644 (file)
@@ -34,9 +34,9 @@
 // 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"
@@ -77,86 +77,87 @@ void message_print( message_info_t* self, const char* characters, std::size_t le
 
 
 #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;
@@ -176,10 +177,10 @@ int g_WatchBSP_Timeout = 10;
 
 
 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 );
@@ -189,7 +190,7 @@ void Build_constructPage( PreferenceGroup& group ){
        Build_constructPreferences( page );
 }
 void Build_registerPreferencesPage(){
-       PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Build_constructPage>() );
+       PreferencesDialog_addSettingsPage( makeCallbackF(Build_constructPage) );
 }
 
 #include "preferencesystem.h"
@@ -200,10 +201,10 @@ void BuildMonitor_Construct(){
 
        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();
 }
@@ -343,7 +344,7 @@ static void saxEndElement( message_info_t *data, const xmlChar *name ){
        }
        if ( data->recurse == data->stop_depth ) {
                message_flush( data );
-#ifdef _DEBUG
+#if GDEF_DEBUG
                globalOutputStream() << "Received error msg .. shutting down..\n";
 #endif
                GetWatchBSP()->EndMonitoringLoop();
@@ -359,29 +360,30 @@ static void saxEndElement( message_info_t *data, const xmlChar *name ){
 
 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>
@@ -488,12 +490,12 @@ void CWatchBSP::Reset(){
        }
        m_eState = EIdle;
        if ( s_routine_id ) {
-               gtk_timeout_remove( s_routine_id );
+               g_source_remove( s_routine_id );
        }
 }
 
 bool CWatchBSP::SetupListening(){
-#ifdef _DEBUG
+#if GDEF_DEBUG
        if ( m_pListenSocket ) {
                globalOutputStream() << "ERROR: m_pListenSocket != NULL in CWatchBSP::SetupListening\n";
                return false;
@@ -514,7 +516,7 @@ void CWatchBSP::DoEBeginStep(){
        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
@@ -531,7 +533,7 @@ void CWatchBSP::DoEBeginStep(){
                        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
@@ -540,19 +542,19 @@ void CWatchBSP::DoEBeginStep(){
                }
        }
        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
@@ -560,15 +562,15 @@ void CWatchBSP::DoEBeginStep(){
 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 ){
@@ -611,7 +613,7 @@ void CWatchBSP::RoutineProcessing(){
        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 ) {
@@ -621,7 +623,7 @@ void CWatchBSP::RoutineProcessing(){
 #endif
                        return;
                }
-#ifdef _DEBUG
+#if GDEF_DEBUG
                // some debug checks
                if ( !m_pListenSocket ) {
                        globalErrorStream() << "ERROR: m_pListenSocket == NULL in CWatchBSP::RoutineProcessing EBeginStep state\n";
@@ -641,7 +643,7 @@ void CWatchBSP::RoutineProcessing(){
                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";
@@ -744,7 +746,7 @@ void CWatchBSP::RoutineProcessing(){
                                                        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();
@@ -772,11 +774,11 @@ void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ){
        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;
index 989c1196309ef7ea40f9fc65cffc1802dba0e4bf..3bd2334daf1f0f2d8e55bd8078338e7b146b0a70 100644 (file)
@@ -22,7 +22,7 @@
 #include "windowobservers.h"
 
 #include <vector>
-#include <gdk/gdkevents.h>
+#include <gdk/gdk.h>
 #include "generic/bitfield.h"
 
 namespace
@@ -50,21 +50,21 @@ inline void WindowObservers_OnModifierUp( WindowObservers& observers, ModifierFl
 
 #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;
@@ -72,21 +72,21 @@ gboolean selection_modifier_key_press( GtkWidget* widget, GdkEventKey* event, Wi
        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;
@@ -109,21 +109,21 @@ void WindowObservers_UpdateModifiers( WindowObservers& observers, ModifierFlags
        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;
 }
@@ -139,13 +139,28 @@ void GlobalWindowObservers_add( WindowObserver* observer ){
        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;
 }
index eab5fe5989e4606a5b2a828a3cdf87fedf808262..37fe2f1598b52c57c7bbdc5c975b1d5a0316e57a 100644 (file)
 
 #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 )
@@ -48,19 +46,7 @@ inline ButtonIdentifier button_for_button( unsigned int 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 ) );
index a30303f4c8273bee5cbb4c57fc33f6719a19b4cb..7fe6120f6031b46fa531744bc2db7bfc29236412 100644 (file)
@@ -68,8 +68,8 @@ class IGL2DWindow;
 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;
index 393a957ad7a05b446c4a70b3726ebd69b59a61d6..9177f9fefd81b2b0405293fd987656412ad9266e 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "xywindow.h"
 
+#include <gtk/gtk.h>
+
 #include "debugging/debugging.h"
 
 #include "ientity.h"
@@ -39,8 +41,8 @@
 #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"
@@ -346,6 +348,8 @@ struct xywindow_globals_private_t
        bool m_bChaseMouse;
        bool m_bSizePaint;
 
+       bool g_bCrossHairs;
+
        xywindow_globals_private_t() :
                d_showgrid( true ),
 
@@ -361,7 +365,9 @@ struct xywindow_globals_private_t
 
                m_bCamXYUpdate( true ),
                m_bChaseMouse( true ),
-               m_bSizePaint( true ){
+               m_bSizePaint( true ),
+
+               g_bCrossHairs( false ){
        }
 
 };
@@ -410,6 +416,7 @@ inline unsigned int buttons_for_button_and_modifiers( ButtonIdentifier button, M
 
        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;
@@ -548,9 +555,7 @@ VIEWTYPE GlobalXYWnd_getCurrentViewType(){
 // =============================================================================
 // 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
@@ -562,7 +567,7 @@ void WXY_Print(){
        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;
        }
@@ -719,7 +724,7 @@ bool XYWnd::chaseMouseMotion( int pointx, int pointy ){
 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;
@@ -733,7 +738,7 @@ void xy_update_xor_rectangle( XYWnd& self, rect_t area ){
        }
 }
 
-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 ) {
                g_pParentWnd->SetActiveXY( xywnd );
 
@@ -744,7 +749,7 @@ gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xy
        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 ) );
 
@@ -753,7 +758,7 @@ gboolean xywnd_button_release( GtkWidget* widget, GdkEventButton* event, XYWnd*
        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 ) {
                        g_pParentWnd->SetActiveXY( xywnd );
@@ -769,7 +774,7 @@ void xywnd_motion( gdouble x, gdouble y, guint state, void* data ){
        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 ( event->direction == GDK_SCROLL_UP ) {
                xywnd->ZoomInWithMouse( (int)event->x, (int)event->y );
        }
@@ -779,7 +784,7 @@ gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xy
        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();
@@ -787,7 +792,7 @@ gboolean xywnd_size_allocate( GtkWidget* widget, GtkAllocation* allocation, XYWn
        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();
@@ -810,9 +815,9 @@ void XYWnd_CameraMoved( XYWnd& xywnd ){
 
 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 ){
@@ -841,36 +846,36 @@ XYWnd::XYWnd() :
 
        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 );
-       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 );
+       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 );
 
@@ -880,15 +885,15 @@ XYWnd::XYWnd() :
 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();
 }
@@ -967,12 +972,12 @@ void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){
        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 );
        }
 }
 
@@ -1081,15 +1086,15 @@ void XYWnd::NewBrushDrag( int x, int y ){
                                                                "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,
@@ -1097,21 +1102,21 @@ void entitycreate_activated( GtkWidget* item ){
        }
 }
 
-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, "" ) );
 }
@@ -1128,12 +1133,12 @@ void visit( EntityClass* e ){
        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 ) );
 }
@@ -1174,8 +1179,8 @@ void XYWnd::OnContextMenu(){
                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 );
@@ -1195,7 +1200,7 @@ void XYWnd_moveDelta( int x, int y, unsigned int state, void* data ){
        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;
 }
@@ -1205,13 +1210,13 @@ void XYWnd::Move_Begin(){
                Move_End();
        }
        m_move_started = true;
-       g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), 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(), 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() );
+       g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow() );
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_move_focusOut );
 }
 
@@ -1239,7 +1244,7 @@ void XYWnd_zoomDelta( int x, int y, unsigned int state, void* data ){
        }
 }
 
-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;
 }
@@ -1250,13 +1255,13 @@ void XYWnd::Zoom_Begin(){
        }
        m_zoom_started = true;
        g_dragZoom = 0;
-       g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), 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(), 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() );
+       g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow() );
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut );
 }
 
@@ -1277,7 +1282,7 @@ void XYWnd::SetViewType( VIEWTYPE viewType ){
        m_viewType = viewType;
        updateModelview();
 
-       if ( m_parent != 0 ) {
+       if ( m_parent ) {
                gtk_window_set_title( m_parent, ViewType_getTitle( m_viewType ) );
        }
 }
@@ -1379,7 +1384,7 @@ void XYWnd::XY_MouseMoved( int x, int y, unsigned int buttons ){
                           << "  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 );
                }
 
@@ -1507,12 +1512,12 @@ void XYWnd::XY_DisableBackground( void ){
 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 );
@@ -2086,7 +2091,7 @@ void SetState( Shader* state, EStyle style ){
                m_state_stack.back().m_state = state;
        }
 }
-const EStyle getStyle() const {
+EStyle getStyle() const {
        return eWireframeOnly;
 }
 void PushState(){
@@ -2313,7 +2318,7 @@ void XYWnd::XY_Draw(){
                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 ) {
@@ -2543,7 +2548,7 @@ void XY_ZoomOut(){
 
 
 void ToggleShowCrosshair(){
-       g_bCrossHairs ^= 1;
+       g_xywindow_globals_private.g_bCrossHairs ^= 1;
        XY_UpdateAllWindows();
 }
 
@@ -2559,20 +2564,20 @@ void ToggleShowGrid(){
 
 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 );
 }
 
 
@@ -2588,9 +2593,9 @@ void realise(){
 }
 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);
                }
        }
 }
@@ -2605,98 +2610,98 @@ void ShowNamesToggle(){
        GlobalEntityCreator().setShowNames( !GlobalEntityCreator().getShowNames() );
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowNamesToggle> ShowNamesToggleCaller;
-void ShowNamesExport( const BoolImportCallback& importer ){
+typedef FreeCaller<void(), ShowNamesToggle> ShowNamesToggleCaller;
+void ShowNamesExport( const Callback<void(bool)> & importer ){
        importer( GlobalEntityCreator().getShowNames() );
 }
-typedef FreeCaller1<const BoolImportCallback&, ShowNamesExport> ShowNamesExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowNamesExport> ShowNamesExportCaller;
 
 void ShowAnglesToggle(){
        GlobalEntityCreator().setShowAngles( !GlobalEntityCreator().getShowAngles() );
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowAnglesToggle> ShowAnglesToggleCaller;
-void ShowAnglesExport( const BoolImportCallback& importer ){
+typedef FreeCaller<void(), ShowAnglesToggle> ShowAnglesToggleCaller;
+void ShowAnglesExport( const Callback<void(bool)> & importer ){
        importer( GlobalEntityCreator().getShowAngles() );
 }
-typedef FreeCaller1<const BoolImportCallback&, ShowAnglesExport> ShowAnglesExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowAnglesExport> ShowAnglesExportCaller;
 
 void ShowBlocksToggle(){
        g_xywindow_globals_private.show_blocks ^= 1;
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowBlocksToggle> ShowBlocksToggleCaller;
-void ShowBlocksExport( const BoolImportCallback& importer ){
+typedef FreeCaller<void(), ShowBlocksToggle> ShowBlocksToggleCaller;
+void ShowBlocksExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_blocks );
 }
-typedef FreeCaller1<const BoolImportCallback&, ShowBlocksExport> ShowBlocksExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowBlocksExport> ShowBlocksExportCaller;
 
 void ShowCoordinatesToggle(){
        g_xywindow_globals_private.show_coordinates ^= 1;
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowCoordinatesToggle> ShowCoordinatesToggleCaller;
-void ShowCoordinatesExport( const BoolImportCallback& importer ){
+typedef FreeCaller<void(), ShowCoordinatesToggle> ShowCoordinatesToggleCaller;
+void ShowCoordinatesExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_coordinates );
 }
-typedef FreeCaller1<const BoolImportCallback&, ShowCoordinatesExport> ShowCoordinatesExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowCoordinatesExport> ShowCoordinatesExportCaller;
 
 void ShowOutlineToggle(){
        g_xywindow_globals_private.show_outline ^= 1;
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowOutlineToggle> ShowOutlineToggleCaller;
-void ShowOutlineExport( const BoolImportCallback& importer ){
+typedef FreeCaller<void(), ShowOutlineToggle> ShowOutlineToggleCaller;
+void ShowOutlineExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_outline );
 }
-typedef FreeCaller1<const BoolImportCallback&, ShowOutlineExport> ShowOutlineExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowOutlineExport> ShowOutlineExportCaller;
 
 void ShowAxesToggle(){
        g_xywindow_globals_private.show_axis ^= 1;
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowAxesToggle> ShowAxesToggleCaller;
-void ShowAxesExport( const BoolImportCallback& importer ){
+typedef FreeCaller<void(), ShowAxesToggle> ShowAxesToggleCaller;
+void ShowAxesExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_axis );
 }
-typedef FreeCaller1<const BoolImportCallback&, ShowAxesExport> ShowAxesExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowAxesExport> ShowAxesExportCaller;
 
 void ShowWorkzoneToggle(){
        g_xywindow_globals_private.d_show_work ^= 1;
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowWorkzoneToggle> ShowWorkzoneToggleCaller;
-void ShowWorkzoneExport( const BoolImportCallback& importer ){
+typedef FreeCaller<void(), ShowWorkzoneToggle> ShowWorkzoneToggleCaller;
+void ShowWorkzoneExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.d_show_work );
 }
-typedef FreeCaller1<const BoolImportCallback&, ShowWorkzoneExport> ShowWorkzoneExportCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowWorkzoneExport> ShowWorkzoneExportCaller;
 
 ShowNamesExportCaller g_show_names_caller;
-BoolExportCallback g_show_names_callback( 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;
-BoolExportCallback g_show_angles_callback( 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;
-BoolExportCallback g_show_blocks_callback( 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;
-BoolExportCallback g_show_coordinates_callback( 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;
-BoolExportCallback g_show_outline_callback( 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;
-BoolExportCallback g_show_axes_callback( 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;
-BoolExportCallback g_show_workzone_callback( 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 );
 
 void XYShow_registerCommands(){
@@ -2727,7 +2732,7 @@ void Orthographic_constructPage( PreferenceGroup& group ){
        Orthographic_constructPreferences( page );
 }
 void Orthographic_registerPreferencesPage(){
-       PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Orthographic_constructPage>() );
+       PreferencesDialog_addSettingsPage( makeCallbackF(Orthographic_constructPage) );
 }
 
 void Clipper_constructPreferences( PreferencesPage& page ){
@@ -2738,7 +2743,7 @@ void Clipper_constructPage( PreferenceGroup& group ){
        Clipper_constructPreferences( page );
 }
 void Clipper_registerPreferencesPage(){
-       PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Clipper_constructPage>() );
+       PreferencesDialog_addSettingsPage( makeCallbackF(Clipper_constructPage) );
 }
 
 
@@ -2746,63 +2751,62 @@ void Clipper_registerPreferencesPage(){
 #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_Colors14", Vector3ImportStringCaller( g_xywindow_globals.color_gridmajor_alt ), Vector3ExportStringCaller( g_xywindow_globals.color_gridmajor_alt ) );
-
-
-       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_Colors14", make_property_string( g_xywindow_globals.color_gridmajor_alt ) );
+
+
+       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();
index a8b4aaa2206bca913a7dbfb8d8f5d0f8874e987b..3842e8f66f1f2d0602c848f96c78e9013c06c6bd 100644 (file)
@@ -40,8 +40,6 @@ namespace scene
 {
 class Node;
 }
-typedef struct _GtkWindow GtkWindow;
-typedef struct _GtkMenu GtkMenu;
 
 
 void FlipClip();
@@ -65,21 +63,21 @@ inline const char* ViewType_getTitle( VIEWTYPE viewtype ){
 
 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;
 }
 
@@ -146,7 +144,7 @@ void DropClipPoint( int pointx, int pointy );
 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;
@@ -230,7 +228,7 @@ int Height(){
 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 ){
@@ -287,10 +285,9 @@ extern xywindow_globals_t g_xywindow_globals;
 
 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();
index dfb0d41d0d0cd9e15444131f6be8474179721729..dc338837b5361fe8b00d399e86cb2e42ff1457c4 100644 (file)
-*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
+}
index 4e23fd496d737caacbccc9e16d1ac829d47eb169..ec5987f687f99d2356b42bbedc2dd8681ba51d6b 100644 (file)
-*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
+}
index 0e8727e04878b9400971d750fe0d6e177cf681ca..59689a3ea278f556b5622cf6c82cc7de274073db 100644 (file)
-*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
+}
diff --git a/setup/apple/.gitignore b/setup/apple/.gitignore
new file mode 100644 (file)
index 0000000..e420ee4
--- /dev/null
@@ -0,0 +1 @@
+target/*
diff --git a/setup/apple/Makefile b/setup/apple/Makefile
new file mode 100644 (file)
index 0000000..cf85d97
--- /dev/null
@@ -0,0 +1,83 @@
+# 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)/*
diff --git a/setup/apple/NetRadiant.app/Contents/Info.plist b/setup/apple/NetRadiant.app/Contents/Info.plist
new file mode 100644 (file)
index 0000000..75796b1
--- /dev/null
@@ -0,0 +1,28 @@
+<?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>
diff --git a/setup/apple/NetRadiant.app/Contents/MacOS/radiant b/setup/apple/NetRadiant.app/Contents/MacOS/radiant
new file mode 100755 (executable)
index 0000000..701a7fe
--- /dev/null
@@ -0,0 +1,35 @@
+#!/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
diff --git a/setup/apple/NetRadiant.app/Contents/Resources/etc/fonts/fonts.conf b/setup/apple/NetRadiant.app/Contents/Resources/etc/fonts/fonts.conf
new file mode 100644 (file)
index 0000000..7183a4b
--- /dev/null
@@ -0,0 +1,133 @@
+<?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>
+
diff --git a/setup/apple/NetRadiant.app/Contents/Resources/etc/gtk-2.0/gtkrc b/setup/apple/NetRadiant.app/Contents/Resources/etc/gtk-2.0/gtkrc
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/setup/apple/NetRadiant.app/Contents/Resources/etc/pango/pangorc b/setup/apple/NetRadiant.app/Contents/Resources/etc/pango/pangorc
new file mode 100644 (file)
index 0000000..f56d343
--- /dev/null
@@ -0,0 +1 @@
+[Pango]
\ No newline at end of file
diff --git a/setup/apple/NetRadiant.app/Contents/Resources/lib/.turd b/setup/apple/NetRadiant.app/Contents/Resources/lib/.turd
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/setup/apple/NetRadiant.app/Contents/Resources/radiant.icns b/setup/apple/NetRadiant.app/Contents/Resources/radiant.icns
new file mode 100644 (file)
index 0000000..339e718
Binary files /dev/null and b/setup/apple/NetRadiant.app/Contents/Resources/radiant.icns differ
diff --git a/setup/apple/NetRadiant.app/Contents/Resources/share/gtk-2.0/icons/.turd b/setup/apple/NetRadiant.app/Contents/Resources/share/gtk-2.0/icons/.turd
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/setup/apple/NetRadiant.app/Contents/Resources/share/gtk-2.0/themes/.turd b/setup/apple/NetRadiant.app/Contents/Resources/share/gtk-2.0/themes/.turd
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/setup/apple/README.md b/setup/apple/README.md
new file mode 100644 (file)
index 0000000..069cf3d
--- /dev/null
@@ -0,0 +1,50 @@
+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..
diff --git a/setup/data/osx/NetRadiant.app/Contents/Info.plist b/setup/data/osx/NetRadiant.app/Contents/Info.plist
deleted file mode 100644 (file)
index 81e377d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?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>
diff --git a/setup/data/osx/NetRadiant.app/Contents/MacOS/install/fonts.conf b/setup/data/osx/NetRadiant.app/Contents/MacOS/install/fonts.conf
deleted file mode 100755 (executable)
index 86dc8af..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-<?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>
diff --git a/setup/data/osx/NetRadiant.app/Contents/MacOS/install/fonts.dtd b/setup/data/osx/NetRadiant.app/Contents/MacOS/install/fonts.dtd
deleted file mode 100755 (executable)
index cbdfdab..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-<!-- 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;)>
diff --git a/setup/data/osx/NetRadiant.app/Contents/MacOS/install/gdk-pixbuf.loaders b/setup/data/osx/NetRadiant.app/Contents/MacOS/install/gdk-pixbuf.loaders
deleted file mode 100644 (file)
index f8852a2..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# 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
-
diff --git a/setup/data/osx/NetRadiant.app/Contents/MacOS/install/pango.modules b/setup/data/osx/NetRadiant.app/Contents/MacOS/install/pango.modules
deleted file mode 100644 (file)
index 9eecea4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# 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:
diff --git a/setup/data/osx/NetRadiant.app/Contents/MacOS/install/pangorc b/setup/data/osx/NetRadiant.app/Contents/MacOS/install/pangorc
deleted file mode 100644 (file)
index 282e977..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-[Pango]
-ModuleFiles = ./pango.modules
-
-[PangoX]
-AliasFiles = ./pangox.aliases
diff --git a/setup/data/osx/NetRadiant.app/Contents/MacOS/install/pangox.aliases b/setup/data/osx/NetRadiant.app/Contents/MacOS/install/pangox.aliases
deleted file mode 100644 (file)
index 9b41aa7..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-# 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"
diff --git a/setup/data/osx/NetRadiant.app/Contents/PkgInfo b/setup/data/osx/NetRadiant.app/Contents/PkgInfo
deleted file mode 100644 (file)
index bd04210..0000000
+++ /dev/null
@@ -1 +0,0 @@
-APPL????
\ No newline at end of file
diff --git a/setup/data/osx/NetRadiant.app/Contents/Resources/English.lproj/InfoPlist.strings b/setup/data/osx/NetRadiant.app/Contents/Resources/English.lproj/InfoPlist.strings
deleted file mode 100755 (executable)
index 4a182e5..0000000
Binary files a/setup/data/osx/NetRadiant.app/Contents/Resources/English.lproj/InfoPlist.strings and /dev/null differ
diff --git a/setup/data/osx/NetRadiant.app/Contents/Resources/NetRadiant.icns b/setup/data/osx/NetRadiant.app/Contents/Resources/NetRadiant.icns
deleted file mode 100644 (file)
index 339e718..0000000
Binary files a/setup/data/osx/NetRadiant.app/Contents/Resources/NetRadiant.icns and /dev/null differ
diff --git a/setup/data/tools-src/notex.xcf b/setup/data/tools-src/notex.xcf
new file mode 100644 (file)
index 0000000..6aa111a
Binary files /dev/null and b/setup/data/tools-src/notex.xcf differ
diff --git a/setup/data/tools-src/shadernotex.xcf b/setup/data/tools-src/shadernotex.xcf
new file mode 100644 (file)
index 0000000..de43725
Binary files /dev/null and b/setup/data/tools-src/shadernotex.xcf differ
diff --git a/setup/data/tools-src/texbro_tags.xcf b/setup/data/tools-src/texbro_tags.xcf
new file mode 100644 (file)
index 0000000..2719ad5
Binary files /dev/null and b/setup/data/tools-src/texbro_tags.xcf differ
diff --git a/setup/data/tools/base/textures/radiant/notex.png b/setup/data/tools/base/textures/radiant/notex.png
new file mode 100644 (file)
index 0000000..e09df39
Binary files /dev/null and b/setup/data/tools/base/textures/radiant/notex.png differ
diff --git a/setup/data/tools/base/textures/radiant/shadernotex.png b/setup/data/tools/base/textures/radiant/shadernotex.png
new file mode 100644 (file)
index 0000000..0eab827
Binary files /dev/null and b/setup/data/tools/base/textures/radiant/shadernotex.png differ
diff --git a/setup/data/tools/bitmaps/cap_curve.png b/setup/data/tools/bitmaps/cap_curve.png
new file mode 100644 (file)
index 0000000..a46d1dd
Binary files /dev/null and b/setup/data/tools/bitmaps/cap_curve.png differ
diff --git a/setup/data/tools/bitmaps/curve_cap.png b/setup/data/tools/bitmaps/curve_cap.png
deleted file mode 100644 (file)
index a46d1dd..0000000
Binary files a/setup/data/tools/bitmaps/curve_cap.png and /dev/null differ
diff --git a/setup/data/tools/bitmaps/notex.png b/setup/data/tools/bitmaps/notex.png
deleted file mode 100644 (file)
index e09df39..0000000
Binary files a/setup/data/tools/bitmaps/notex.png and /dev/null differ
index 8b44a8ce0b1a795110d9d830ad5b086053864206..c17ee28165c96c683b44f281eb41ad7548841e50 100644 (file)
Binary files a/setup/data/tools/bitmaps/selection_makeroom.png and b/setup/data/tools/bitmaps/selection_makeroom.png differ
diff --git a/setup/data/tools/bitmaps/shadernotex.png b/setup/data/tools/bitmaps/shadernotex.png
deleted file mode 100644 (file)
index 0eab827..0000000
Binary files a/setup/data/tools/bitmaps/shadernotex.png and /dev/null differ
diff --git a/setup/data/tools/bitmaps/texbro_tags.png b/setup/data/tools/bitmaps/texbro_tags.png
new file mode 100644 (file)
index 0000000..8b0da1e
Binary files /dev/null and b/setup/data/tools/bitmaps/texbro_tags.png differ
index 86b2945f4785e151046be388833848e912d3f63a..4b6d0343f124f42a2b7ec31e315865a1f3b84ce7 100644 (file)
@@ -1,16 +1,7 @@
 <?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 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="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>
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1fcce20
--- /dev/null
@@ -0,0 +1,3 @@
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+
+add_subdirectory(quake3)
index 8c663dc7523258c056868cad4eed8d5ea0b1e86c..4caeab57f8604f34dd2fd33db41c82577377a58a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 7d4788018a2df8eb9190bd8ec2072d75e6162d91..279e7302a120268cbb5ed93dc07097ab12ab3e9d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index db6e2418fb55fdafd44654c8ce098e712c0a3a00..02e0be87c39cbb3a610852ab6268a99a4911b7e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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
 
@@ -93,7 +95,7 @@ char archivedir[1024];
 #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;
@@ -328,7 +330,7 @@ double I_FloatTime( void ){
 void Q_getwd( char *out ){
        int i = 0;
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        _getcwd( out, 256 );
        strcat( out, "\\" );
 #else
@@ -347,7 +349,7 @@ void Q_getwd( char *out ){
 
 
 void Q_mkdir( const char *path ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        if ( _mkdir( path ) != -1 ) {
                return;
        }
@@ -952,11 +954,7 @@ int ParseNum( const char *str ){
    ============================================================================
  */
 
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
 
 short   LittleShort( short l ){
        byte b1,b2;
@@ -1128,7 +1126,7 @@ void    CreatePath( const char *path ){
        char c;
        char dir[1024];
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        int olddrive = -1;
 
        if ( path[1] == ':' ) {
@@ -1151,7 +1149,7 @@ void    CreatePath( const char *path ){
                }
        }
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        if ( olddrive != -1 ) {
                _chdrive( olddrive );
        }
@@ -1177,10 +1175,10 @@ void QCopyFile( const char *from, const char *to ){
 }
 
 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
 }
index 2955d53f2a966aaa962cb9be569240b89c5b1328..f8d8e0d361a415c2e4996fd651a0cad789393e79 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -24,6 +24,8 @@
 #ifndef __CMDLIB__
 #define __CMDLIB__
 
+#include "globaldefs.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -32,7 +34,7 @@
 #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
@@ -40,7 +42,7 @@
        #endif
 #endif
 
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
        #pragma intrinsic( memset, memcpy )
 #endif
 
index 30ae39df7ee9026ae3cae5d94afff7083691c9de..f81aff94bd6d46a2daa0fc590e021cf4bedceb1a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -26,6 +26,7 @@
 // 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"
@@ -33,7 +34,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 #include <direct.h>
 #include <windows.h>
 #endif
@@ -42,7 +43,7 @@
 #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;
index be0bd9a4a596a6c626312861879fc2ab64d33b18..934189f2cb034b481a3deb6ea450a5fe132ca2be 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -22,6 +22,7 @@
 #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"
@@ -52,7 +53,7 @@ void Sys_Printf( const char *text, ... );
 void Sys_FPrintf( int flag, const char *text, ... );
 void Error( const char *error, ... );
 
-#ifdef _DEBUG
+#if GDEF_DEBUG
 #define DBG_XML 1
 #endif
 
index b3d67b29b692bdea06f1ef476186e452541096c4..d4a096ada034da1468e2f8fcb5320fa43dc8e202 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 0f7ff877aacb47a401b964ce890cb232fa1a35ad..41cb344e38b2eb6c3bee5dbd519a5b0dffe52b35 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index b40b7cb94f320e9d8076aea2914f7395775acddb..bb5458c05790765fed9d4de381fdd17e0084f5f7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index ab4141ced53baba9ea3984b30fb788100b02205b..8bc9cafc79826113ead9e67da0487cf5eec465e8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index f218f0c0f04de513b553924fe057d6ec0ae921bb..25d5f8283fad410d585d0989dc4516f30adfc9fb 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 497cf8938193c470f0ff5266d7e79144e9b74e88..1999b71fdd94d2c5c665d8726ac79ddfb0c91f54 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 5d729f2498edf2fe8cdc6b5b03f25d6f0a618409..cd413805b9acda86e4628818a07fb38720161730 100644 (file)
@@ -1,6 +1,6 @@
 /* -------------------------------------------------------------------------------
 
-   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
 
index ab83418ac69738a7355972edad3e13bbf5071a62..9d45084169aef84daffa45dc4a7a591f459a3409 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 5254248aae7b69c769432f03a680c64ff87e3f5e..a0eb3f0923a454fd1461aba4b1dd48317c5ca4c3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 7f7b3cafd2384080fb2ac3f5357585fd4e4dce7d..decd226a343c684ab9ec41687e875bbefcbf7c69 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index d2b6f106be81a9f679d53f7e02ba860f4954d8e5..a677a22adbaa0233056accde8af760cefd51b25b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -32,7 +32,8 @@
    ========================================================================
  */
 
-#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
index 9069de714f07a3dfe99d5e7eb1e0ffc6e3d3a28e..2f3f3eecf078a36d07b46fbf5e86d2335e1eef33 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 39c2717b11c724b372c3f927f166ca68763d2af2..306533be696e61394a29e935937b99a8408b8e70 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 0b5f4ece2ba263f37da9e65d491b957c4a40c444..d648e99e490b07165e6117fdc484207eb97613f7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -19,7 +19,9 @@
    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
@@ -106,7 +108,7 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )(
 
    ===================================================================
  */
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 
 #define USED
 
@@ -415,7 +417,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    =======================================================================
  */
 
-#if defined( __linux__ ) || defined( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
 #define USED
 
 // Setting default Threads to 1
index 7bded9d7a82fdbb5c98da202b17835c1dd878eed..cbe23ccf8f8d9fd7f968ce0394d1367d5fa96c8c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 5dbe002f8607b587a3548a4a022609d47465ac46..6ff4a853d2ab44427b5da3445c89a25e8fc7f142 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 670254605d9a1b07e77d0fae3d3b5bb622ef6f26..5311e8eb04ebe6929b53137a5159b70b095e657e 100644 (file)
@@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ===========================================================================
 */
 
+#include "globaldefs.h"
 #include "cmdlib.h"
 #include "mathlib.h"
 #include "bspfile.h"
@@ -27,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "threads.h"
 #include "lbmlib.h"
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 #include <windows.h>
 #endif
 
index 60f615a0be05692795716c7c7153798eb68b1c39..792690790530546297e0254c17cc776dd40c8505 100644 (file)
@@ -23,10 +23,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // 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
 
@@ -58,7 +60,7 @@ Mimic unix command line expansion
 #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)
 {
@@ -305,7 +307,7 @@ double I_FloatTime (void)
 
 void Q_getwd (char *out)
 {
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
    _getcwd (out, 256);
    strcat (out, "\\");
 #else
@@ -317,7 +319,7 @@ void Q_getwd (char *out)
 
 void Q_mkdir (char *path)
 {
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        if (_mkdir (path) != -1)
                return;
 #else
@@ -830,11 +832,7 @@ int ParseNum (char *str)
 ============================================================================
 */
 
-#ifdef _SGI_SOURCE
-#define        __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
 
 short   LittleShort (short l)
 {
index 0045a09d5c5e2e24229035523129e8dbe8c5f6a4..0821ce512f517de8b02ef2d56584fa7679a5e20b 100644 (file)
@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #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
index 25a87c78e4dbc6b662ec0bb23c88b89e8a2a07dd..24dc5561aa83b9bed89148f2e9a23a8de2097353 100644 (file)
@@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "cmdlib.h"
 #include "threads.h"
+#include "globaldefs.h"
 
 #define        MAX_THREADS     64
 
@@ -99,7 +100,7 @@ WIN32
 
 ===================================================================
 */
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 
 #define        USED
 
index 2f93b728397ab5c24448625d8cab51e061bd02e9..16c65c710c4c3ca2ad3d722a72603a9d5ff0981e 100644 (file)
@@ -211,7 +211,7 @@ PackDirectory_r
 
 ===============
 */
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
 #include "io.h"
 void PackDirectory_r (char *dir)
 {
index 87565490683498dcc763c804c7616a0e30be68cf..aebd6fb4b2f5f44e2e8879f5041efe995d7148f1 100644 (file)
@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // cmdlib.c
 
 #include "cmdlib.h"
+#include "globaldefs.h"
 
 #define PATHSEPERATOR   '/'
 
@@ -567,11 +568,7 @@ int ParseNum (char *str)
 ============================================================================
 */
 
-#ifdef _SGI_SOURCE
-#define        __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
 
 short   LittleShort (short l)
 {
index 84a5a3eb4e859a654d6eaea9ec92ff6108586513..d6ac83a5492e3c543778b718283da75311d625cb 100644 (file)
@@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 //*************************************************************
 
+#include "globaldefs.h"
 #include <windows.h>
 #include <windowsx.h>
 #include <string.h>
@@ -505,7 +506,7 @@ WORD i;
   return TRUE;
 }
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 
 BOOL IsWin395OrHigher(void)
 {
index b78b986ced3add415f5696b8b20351d553e64a0b..052a6e9a3bda8b899a9ae8276ab92ed9c85c045b 100644 (file)
@@ -36,6 +36,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #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
@@ -83,7 +85,7 @@ void            PlaceMenuMRUItem(LPMRUMENU lpMruMenu,HMENU hMenu,UINT uiItem);
 
 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);
 
index 679305991b23eeaee8825145fc63932c3e1f3bb0..538b54e2a598ecc419f03a8e34074f10af52debb 100644 (file)
@@ -24,9 +24,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #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>
 
index 022db65329568a419d21041338024d46bd55f9a2..3ca734bbcfbb9ac8c9a97ae0e85caca04a9862b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -1293,7 +1293,7 @@ tree_t *BrushBSP( bspbrush_t *brushlist, vec3_t mins, vec3_t maxs ){
 
                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 );
                }
 
index 0b0bda93d29f30ca869690a37f293fb466999c5e..bc6f340afb86c14650f20599699c25dca4ad7c01 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 7607dbc218ca2d7ba47a0c3914e06a8ddfe8a766..15bb095fdc7aa5ba57bd8da266766514207ba849 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -653,7 +653,7 @@ int GetEdge2( int v1, int v2,  face_t *f ){
                        }
        #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
index 587e19025139c80249533ead727ee148d872d613..4a4cac053d49bf0e7dc00af7891dd07cfb9edd0e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 55c8becf834ac50085959b75bfe654946c21279c..0f08d1e3f29e0c3917360c7ca1c31bdb0fa0d530 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 0cd600dbc25a3e36b45ddd1388330329c17258fc..731ca685aa9f288c704e34ca6649ba658a636c49 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index e78b3fbf42d4c8c975e4319d198749837d5c2c5d..d8034a047c0558423a8eb74e35355d8a9449b6a5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 70c04585f7574bd4effdbcd411c97cc8df98166c..8d82b6da2d7f5e3f593036203d9c0cf7439d7cd0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -874,7 +874,7 @@ void CreateDirectLights( void ){
                        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
index 4eb3f393a103a85ce073a22922e5f3b5074c0fb7..fb85403b0a128a4750eae2b12bfaa10fe3b3d95e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -649,7 +649,7 @@ int main( int argc, char **argv ){
        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
        {
index ed68ccae676a346317c2faaaa3bce6da45b48ec2..f812393e784c71e4ef5dda9ac5d7f440e6e9ea5e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index bd4817634fa7fcbc4fb69420af3f30d2e53dacfa..398a8aab09286a5d5bff4a134c491ae0d2739ef8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 1e8b91c88ec566800a180704d5706bed708ef224..4782b80a252f588160f0359b4ce75765211b706b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 1c83d75d48dd34f1528fef31dd49ebc110dbe74f..d2d9652717e27947c72f976b5f37ecbfc2ca8ee4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -554,13 +554,13 @@ void MakeTreePortals_r( node_t *node ){
 
        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;
                }
        }
@@ -756,7 +756,7 @@ void FloodAreas_r( node_t *node ){
 
                // 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] ) {
@@ -854,7 +854,7 @@ void SetAreaPortalAreas_r( node_t *node ){
                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;
                }
        }
index c15916b7e92e6442835512a7eaa953431058fded..06a36e8af49c08c8a9a700895119f8218e230a32 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 401e6f740072129a2dae00806a9b28f6c0e8ac7a..644f7b9e88fda0a536d8eaaa01fef6c974823666 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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
 
@@ -31,7 +33,7 @@
        #include <limits.h>
 #endif
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        #include <windows.h>
 #endif
 
index 128fb7ab1576f74871102144dce0d151c8018cbc..0f4591b04bb9a37db65afcc880196fcc1fac5f32 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 56ac1b2fa716b94ef40cda234593521fd88a04d3..8f3ef9e037803dcd880fb2a5b180a7db3c6f165d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -38,6 +38,7 @@
 
  */
 
+#include "globaldefs.h"
 #include "cmdlib.h"
 #include "mathlib.h"
 #include "scriplib.h"
@@ -46,7 +47,7 @@
 #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
index 0ae19f24cb36c279bd871b8b92ac6014be43624b..c17b5bb9e01cd47b632f72dad55b7fc90adf7c6e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index d8e3791e73767a78174a180a3ec37e209f7139c3..7f5df16c61b58d4464f96194445577ecac2e6b4a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -27,7 +27,7 @@
 
  */
 
-
+#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
index 72e7a46e2a33838af6e9ba3c7168bcf5fc5336b0..ce1dd103ba56c90d5dd41200aa2bf244b34f4761 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -209,7 +209,7 @@ void ClusterMerge( int leafnum ){
        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 ) );
index a509d00978663f96cba9b625a1ddb7bb1b58a131..07e0d24756e602f5ff6eb3487970c9c630203078 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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
index c7ac4f60073f905422612a3a908078b1ba9b0b76..c43fabbb664fad8445e49f7bee9458b657244b94 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index af1edfa2c4a43fa56c7f900d0e460e659f06a944..8425022f4f066704362e5dfa119993924fd1e405 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index c73f62293ba5a1a1373e4192e272c51bc27a758a..89658abd24ac412c5815c10417c15a092be89f17 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 0d3c6a480c371ff5aa09dd36e9a5cbf658c71aef..c116b20f5c1fcf697bfb455050e379f3f146d53b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 4c87760082ee0fe50028c02c21d6c92033f27771..00f30e05701dd2389ed641576cb42f04d1e19c23 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 8b9614ddc7211a4c712dcce675c98bbc8b5536c2..848e67524ded7821bd144994c0e59a24f85d5b0a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 50132690531cfbedc93e898c4e86a18cc477436a..1d9f6c78d48c650816a798d2581a674b81660ad1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -212,7 +212,7 @@ void Cmd_File( void ){
 
    ===============
  */
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
 #include "io.h"
 void PackDirectory_r( char *dir ){
        struct _finddata_t fileinfo;
index cb00003a4191515235d8f98073b092bb847fd977..8d06be4c41468e4b801b770163b79ba97cb40feb 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -19,6 +19,7 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include "globaldefs.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <math.h>
@@ -34,7 +35,7 @@
 #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
index 16eb00c687db7106b27728cdb0503aad580bb676..38aa1f5fcb10cf420d081de51255af5f8f9fa70f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index fa9085c135974461ae60f44545bba85c291a9701..00e89547996b358fc347d69429bf49264d44a8a7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 0fc06757bb5ea48d515887646b669d7c7ae36415..b6fe51173cb3a3121c8fd5c6a1cb472ddebd8be2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 387ee191d1980ab3a1e529edd73f4c1eee0ab582..aad74eaac69483b55d0007ed431d11b8ffcefea2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index fbcd21dd710ae096f0531d2e092ea739790b2778..a7619325cba14b7fbf0548106f3c9956e9e30804 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 9c531b2614ba367d2a56f68be2125bdda08d7701..36ea3b1fb56865df47f6e3c5d7afa0112c9fa5d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 8aef344cfba4edc447311bbdc8249729e66a1af5..65e92ef14c6affa9c8d9190afb47db325f0fc36f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 066a52239a06b896f24f1e2a138e706e3c66ce9d..412aefe88062523444e3f071a037e8f8fb0c7c70 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index f76ae1458ede551883a6897969b86fc8be572b72..add0ef30ae3ae992b1e955dcf799c40699d9b932 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 6585147a47e678bd94c869013fc55021e873d965..f66659b559dd50c93161b0a7d01cf41b0f1c50f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 514a1c7b16fd02d9f527a3c41bc42d03f20a7f1f..7a49c52e8e26748d7430381cae21bbe58dc8e6ad 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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
 
@@ -84,7 +85,7 @@ void *SafeMalloc( size_t n, char *desc ){
        return p;
 }
 
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
 void strlwr( char *conv_str ){
        int i;
 
@@ -115,7 +116,7 @@ char archivedir[1024];
 #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;
@@ -342,7 +343,7 @@ double I_FloatTime( void ){
 void Q_getwd( char *out ){
        int i = 0;
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        _getcwd( out, 256 );
        strcat( out, "\\" );
 #else
@@ -361,7 +362,7 @@ void Q_getwd( char *out ){
 
 
 void Q_mkdir( const char *path ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        if ( _mkdir( path ) != -1 ) {
                return;
        }
@@ -964,11 +965,7 @@ int ParseNum( const char *str ){
    ============================================================================
  */
 
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
 
 short   LittleShort( short l ){
        byte b1,b2;
@@ -1140,7 +1137,7 @@ void    CreatePath( const char *path ){
        char c;
        char dir[1024];
 
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
        int olddrive = -1;
 
        if ( path[1] == ':' ) {
@@ -1163,7 +1160,7 @@ void    CreatePath( const char *path ){
                }
        }
 
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
        if ( olddrive != -1 ) {
                _chdrive( olddrive );
        }
@@ -1189,10 +1186,10 @@ void QCopyFile( const char *from, const char *to ){
 }
 
 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
 }
index c94ce37744eb31283c43fee6e491d4fd7000835b..b8b1aa3da84b498cf46d6aa0e2d34d2ac5b40797 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -24,7 +24,7 @@
 #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
@@ -44,7 +44,7 @@
 #include <time.h>
 #include <stdarg.h>
 
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
 
 #pragma intrinsic( memset, memcpy )
 
index 7e6cc468e77470b731f69775265e8b112244b687..6027a69502114728c3981411cf4996826654deb1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 30ae39df7ee9026ae3cae5d94afff7083691c9de..f81aff94bd6d46a2daa0fc590e021cf4bedceb1a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -26,6 +26,7 @@
 // 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"
@@ -33,7 +34,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 #include <direct.h>
 #include <windows.h>
 #endif
@@ -42,7 +43,7 @@
 #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;
index be0bd9a4a596a6c626312861879fc2ab64d33b18..934189f2cb034b481a3deb6ea450a5fe132ca2be 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -22,6 +22,7 @@
 #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"
@@ -52,7 +53,7 @@ void Sys_Printf( const char *text, ... );
 void Sys_FPrintf( int flag, const char *text, ... );
 void Error( const char *error, ... );
 
-#ifdef _DEBUG
+#if GDEF_DEBUG
 #define DBG_XML 1
 #endif
 
index 3c4c5d363557007787a654a5b6a4ebc1d0845e44..708577a13e3fde1139629e859aeb7424cf70b07e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 0c2f634ffda84965f404a53926036e4bb486fc7c..0b1b5379104a9e10ad8faee7070d259d02533ae0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 8b0abd24b73941f626aa3f00a7d954fd2f506f29..7eabd19cccbf5df8543332c273e1ef46142a3de9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 489afc868a09c011036504371ef36c37c2c15bc8..5ee2909f59abab0c17e0ae5e940dc7ea5efbdf45 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 2fa7eabe710a28dbe3e57790504d7ed10ffe181f..8243d86d682da5bb43c799185e2acd8ae5bb8546 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -94,8 +94,10 @@ void _VectorScale( vec3_t v, vec_t scale, vec3_t out ){
        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;
@@ -136,7 +138,9 @@ vec_t ColorNormalize( vec3_t in, vec3_t out ){
        return max;
 }
 
+#if GDEF_COMPILER_MSVC
 #pragma optimize("", on)
+#endif
 
 void VectorInverse( vec3_t v ){
        v[0] = -v[0];
index 7ae3c07445b89f4d6c0aec6f484d709970c1aa12..cd989ea3f65c9579ac89d3df1853c961600633ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index afe5e9f02c5e76b61146213da7f553ec13377f92..1447037759aec6699c8b3d3516156c17c38b0a3d 100644 (file)
@@ -1,6 +1,6 @@
 /* -------------------------------------------------------------------------------
 
-   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
 
index fa38efe1e5ee72dc570b374154b8a3453c7936bf..af5df499e84037eee47cf4f4f9d3b61aa0bf5eaf 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index a6820aadfc37f4a90283b49c6158c298d54cb85d..00b7b39425abb17c0b2034354e1c61bc9de87f2c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 4abe741b82731d53893983125f64aac817530cc3..53452f367be82c2a01cc366eda23b203eab31612 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index fd20cc990429dfa55ee099b5884350dd701b11d1..bee4b4fccf113028f47120168768b4821693790f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 925fcfd18e41bee3d6426c1f40b1cd4b597600da..af5e57165c83e629400a14a7037158e4b4e8e257 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 737b47f81e19beb5bb3e5151bb769c1fc2f00ab6..8c441c8be9020d63b1bbd34efb9b9f629dc2f45c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 3938807d54d1d8c73ea8fda5e4f801080da2e47e..0ee1e2d5203b1409338b992a5c84717cf4970368 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -19,7 +19,9 @@
    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
@@ -106,7 +108,7 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )(
 
    ===================================================================
  */
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 
 #define USED
 
@@ -414,7 +416,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    =======================================================================
  */
 
-#ifdef __linux__
+#if GDEF_OS_LINUX
 #define USED
 
 int numthreads = 4;
index a14bcd71f1e02265388f595237fb24e1c15c0d8e..632cfe40873b56ba4cf17c232f7a609c91a2e5dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 345aca02d1e64ee8d30f72c4792c72b798b76358..6dca1a1a8a0d3718f837022d9ecf77d792e715a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 847b80909b89d43e0603f709650616ebcb120c5e..29acab6faf6400a79bf83d9f13d398b51689de0f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 1e3e82c16b31bea9d0d9758b2531a553d39d629a..8dfd6d284255b8f4fc5be4dafaba3197841ca6a8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index a3e06c0b9f29649f91c527accc3728f2767c02e6..7d8df18af26e06019347ef2f7a990d5d1c96e211 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -148,7 +148,7 @@ void GetOneGroup( trigroup_t *tris, int grp, triangle_t* triangles );
 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;
index 3b07715a8abeb2a7f3ab36d672ffd0131b595ce5..a7138b11184be12bd9f6fcb2899e6f549f411189 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -21,7 +21,7 @@
 
 #include "qdata.h"
 
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
  #include <windows.h>
 #endif
 
index 7879733f151c04d1eac8257b9bd0d33c333a535a..de8b802a69be11c79205e33bf3dbe6fc9d00ad47 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index e6e935f3b9b978843cc0bcf24a5e4d1d0bfddc4a..264d31753f8ece2bed03daffa8000ced30cb2524 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 074734e9b9b672bdc6508f5456cb0341dc3c42ec..f8e64bf5c17660f271ef2bc44007fbb6e8ab9bbe 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -22,6 +22,8 @@
 #ifndef JOINTS_H
 #define JOINTS_H
 
+#include "globaldefs.h"
+
 #ifdef _HERETIC2_
 #include "angles.h"
 #endif
@@ -29,7 +31,7 @@
 //typedef float vec3_t[3];
 //typedef unsigned char byte;
 
-#ifndef _WIN32
+#if !GDEF_OS_WINDOWS
 #define stricmp strcasecmp
 #define strcmpi strcasecmp
 #endif
index 223368172a1df0a62335ef051e9f4f754fea6589..244f24acdb5d2b621d0f9fe9c05a8f89a6d7b5e2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index ca1f1fb733a91eb2d07214672c0430fc39e9b2d9..e9e91c27c175abeb5c16645b32e5f576aff8a96b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 8e8934461f3d809cd2607ace5215f4306f71954e..b0baf31476b420a67c2b34a7e2653f830a91143a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -71,5 +71,6 @@
 
 #define SHORT_TO_ANGLE  ( 360.0 / 65536 )
 
-
+#if GDEF_COMPILER_MSVC
 #pragma warning(disable : 4305)     // 'initializing' : truncation from 'const double ' to 'float '
+#endif
index 25bf5483ee3c54785cb5a5bea0960332822ff631..e54ad223275f109ac23d435b553ca0a679753bf7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -33,13 +33,7 @@ typedef struct ArrayedListNode_s
 
 #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 )
@@ -54,13 +48,7 @@ int GetFreeNode( ArrayedListNode_t *nodeArray, int max ){
        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;
 }
 
index 8acd7c2119d7897c26d8cfa3a45c35cac29c4ff8..98184e870bd0cf14bdf29dc2f845d88c7dc4639e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index f1352d31437b0b08b888000186ce7f60249a364e..e2ebfa8d276ae6f37eca95fdeb44f702432e6ac6 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index b326e8201bcb2460b4eababcf5d2b392915ddde2..e1f2559189415eb2c7d6534469593f6ef5d60a7a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 9f7166e9d5b556c69f1da175efefa33b3eaddea6..9151183fb32a29242a103f8e2578b0a380424a10 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index c980b544a58e409028a5cd865b7190c61387cc67..cbe69dd1e61f93243501cb8066c3f8e2eee2c57d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index f787779c6a1a8ec2b8fe5c93847105fb964dffcc..4d0648c1a58bbe86de09cd4863ea3cdac30f358a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index e426f69776a21e351800e43769b273ec47190b7d..7be9740dc4bb46ff0ba4556b5d5213f03395f55d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 3454e355f4d633e8c12d16181da9715871ab771d..747c4d43230cf8e56f1036bb8dbad6e6f807ca3c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 2b5a40bb3612d77f1dec43728a59f8b2b05b4134..2eb014098143da7afe808bb70179244b080c4e86 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 579931ae9b4c6d189ebddeeed2461a999e36a78a..be82d7866024453b5d5bdf1f550f32c76a5d2135 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 7025ceb5b608d97ef42369ff706422cd8d05523d..453cb77a59066b85fbf04ccfd54011addf5ef207 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index aba4a0c889c860ca890244787e1b0a9bf016a163..9d7fe961bd74e6028f1bf7aa8719203cfcb0979e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index bd4a03da6edc821c6ad75440ce0962c29881fa5a..286fb07197bab92f45d501fd8626fcd893127356 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 4001078d5adc443c46355cb65ac1996417e5a056..97e2a1f8cae14c9c5df97b67524d3735b413b98e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 55ef01b072f6c1779712198bad5d6d2f461c0b6b..7765c57995790dfa72377ab267bb47e45b715c1d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index a715927a3aaf7e1a1a64008755c75f501a929f9d..5ec53a9e60f6db05dfd3c1786edebead27a98483 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -20,6 +20,7 @@
  */
 
 #include "qdata.h"
+#include "globaldefs.h"
 #include "md4.h"
 
 void TK_Init();
@@ -202,7 +203,7 @@ void Cmd_File( void ){
 
    ===============
  */
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
 #include "io.h"
 void PackDirectory_r( char *dir ){
        struct _finddata_t fileinfo;
index 2ead9751e2c191e3ba0c87e36e3048b77a6de013..0cfa6067098dcc295e0c4af988c68e5ac7466b45 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -21,7 +21,7 @@
 
 // qdata.h
 
-
+#include "globaldefs.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <math.h>
@@ -38,7 +38,7 @@
 #include "l3dslib.h"
 #include "bspfile.h"
 
-#ifndef _WIN32
+#if !GDEF_OS_WINDOWS
 #define stricmp strcasecmp
 #define strcmpi strcasecmp
 #endif
index 098e6a1452ca1333866a566dc595c243808b2dba..ecb9d0960afc809c4338857216b4a7751a8abdbb 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 63811395b22d0b6c35047c3b631c3c59966d2769..14865af310431c834b4a500f2751c10fd9965198 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index f42128be75fd7390d771f4d75029c267ef79b6a0..ad86c1ee1d5253ddc0db40df7a1b587f23d0a284 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 75674a017c93e491c009355bbca76bd6a70338f1..58cc369f1ffe85e9edf644219dfc367fc4d72cb2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 8ebb5fe240c4b7b3fd6e1a0171e1ce422f89d8c7..51bf46201ccce52b76780291d2065d820da2fefc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
diff --git a/tools/quake3/CMakeLists.txt b/tools/quake3/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b1e8e67
--- /dev/null
@@ -0,0 +1,194 @@
+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 ()
index 76215232aee5b414599a322400848eeb243f6ce6..bb3be0ea50b1ce99bda7178dc50e3c0b6d9a993d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -19,8 +19,8 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-
 #include "aselib.h"
+#include "globaldefs.h"
 #include "inout.h"
 
 #include <assert.h>
@@ -114,7 +114,7 @@ static char gl_filename[1024];
 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;
@@ -217,7 +217,7 @@ polyset_t *ASE_GetSurfaceAnimation( int which, int *pNumFrames, int skipFrameSta
        {
                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" );
                }
        }
 
@@ -411,9 +411,9 @@ static void ASE_SkipRestOfLine( void ){
 }
 
 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 );
 
@@ -472,7 +472,7 @@ static void ASE_KeyMAP_DIFFUSE( const char *token ){
                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
@@ -882,7 +882,7 @@ static void ASE_Process( void ){
                        }
                }
                else if ( s_token[0] ) {
-                       Sys_Printf( "Unknown token '%s'\n", s_token );
+                       Error( "Unknown token '%s'\n", s_token );
                }
        }
 
index 2f5f015a51ebbb518dd44f592180e8ab15d6b15f..f9a254db1fbda700661615d807378d44063e85a7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 9214550a8a517452aea9e26c0aaf782850c2ab8a..4fc45bd6af7d347f9d6bbf4d44e7c9c8e555f944 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -294,10 +294,7 @@ void SwapBSPFile( void ) {
    =============
  */
 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" );
index 1f08a2d5bfb5e566ea9fcd18bc4f5d69fcad2f10..a6f8679e389c70141e0f06a70d8e56d7390db0eb 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 103047c029eb85e2542c86d7d199bbdff6fc14ab..b74c7b3362ba47b5bfeaa1edfff692bf8fbf5c63 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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
 
@@ -95,7 +96,7 @@ char archivedir[1024];
 #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;
@@ -292,7 +293,7 @@ double I_FloatTime( void ){
 void Q_getwd( char *out ){
        int i = 0;
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        _getcwd( out, 256 );
        strcat( out, "\\" );
 #else
@@ -318,7 +319,7 @@ void Q_mkdir( const char *path ){
        int retry = 2;
        while ( retry-- )
        {
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
                const char *q = NULL;
                if ( _mkdir( path ) != -1 ) {
                        return;
@@ -882,11 +883,7 @@ int ParseNum( const char *str ){
    ============================================================================
  */
 
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
+#if GDEF_ARCH_ENDIAN_BIG
 
 short   LittleShort( short l ){
        byte b1,b2;
@@ -1058,7 +1055,7 @@ void    CreatePath( const char *path ){
        char c;
        char dir[1024];
 
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
        int olddrive = -1;
 
        if ( path[1] == ':' ) {
@@ -1081,7 +1078,7 @@ void    CreatePath( const char *path ){
                }
        }
 
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
        if ( olddrive != -1 ) {
                _chdrive( olddrive );
        }
@@ -1107,10 +1104,10 @@ void QCopyFile( const char *from, const char *to ){
 }
 
 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
 }
index 701b30164c1ac840311dafd81873e7d6606a0191..b57c81a9e760bef4c87512081236027c2740698b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -25,8 +25,9 @@
 #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
@@ -46,7 +47,7 @@
 #include <time.h>
 #include <stdarg.h>
 
-#ifdef _WIN32
+#if GDEF_COMPILER_MSVC
 
 #pragma intrinsic( memset, memcpy )
 
@@ -97,11 +98,7 @@ void ExpandWildcards( int *argc, char ***argv );
 
 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 );
index c349b498c3b4003cd2bdd2355453527343fb5d93..5bc5ff71df9a0e2fee1c039f4224d2f300d17057 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -23,6 +23,7 @@
 
 #include "inout.h"
 #include "cmdlib.h"
+#include "etclib.h"
 #include "imagelib.h"
 #include "vfs.h"
 
@@ -1171,7 +1172,7 @@ void WriteTGA( const char *filename, byte *data, int width, int height ) {
 
 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
@@ -1232,3 +1233,302 @@ void Load32BitImage( const char *name, unsigned **pixels,  int *width, int *heig
                }
        }
 }
+
+
+/*
+   ============================================================================
+
+   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" );
+               }
+       }
+}
index 194ac5b13e2edea15dfb660b37d188d95b969cde..2c028bfd9d58e3cbcfa5460006b855e20fba81ce 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -43,3 +43,5 @@ void WriteTGAGray( const char *filename, byte *data, int width, int height );
 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 );
index 14e9eaafe5ffff974579c5bdd946a7a6ef46d755..5ade8802ca7eac347f2ebe14f81c85b36c89802c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -26,6 +26,7 @@
 // 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"
@@ -33,7 +34,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 #include <direct.h>
 #include <windows.h>
 #endif
@@ -45,7 +46,7 @@
 // utf8 conversion
 #include <glib.h>
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 HWND hwndOut = NULL;
 qboolean lookedForServer = qfalse;
 UINT wm_BroadcastCommand = -1;
@@ -55,6 +56,7 @@ socket_t *brdcst_socket;
 netmessage_t msg;
 
 qboolean verbose = qfalse;
+qboolean werror = qfalse;
 
 // our main document
 // is streamed through the network to Radiant
@@ -151,7 +153,7 @@ void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError ){
        xmlNodeSetContent( 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" );
@@ -315,6 +317,11 @@ void Sys_FPrintf( int flag, const char *format, ... ){
        vsprintf( out_buffer, format, argptr );
        va_end( argptr );
 
+       if ( ( flag == SYS_WRN ) && ( werror == qtrue ) ) {
+               Error( out_buffer );
+               return;
+       }
+
        FPrintf( flag, out_buffer );
 }
 
index 4efe0dacb05953cf6b8cfe838ea42f75ba5ffb2e..a4d7f38bf64c6c1bad6260012f13097beb62f87c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -22,6 +22,7 @@
 #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"
@@ -48,10 +49,11 @@ void Broadcast_Shutdown();
 #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
 
index 5d775e80f0d0b0f9da5bfe0656d06fbc58fd0781..5e340b9da166c4dbef7349ebd9d904f4efe813dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index cc5cddabe5454c4b5a11f3b088bd263e29f4e97e..98ed502876bacf7c432ed713f1829c2a21e47ecc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index d128a03145a822c5ceb598d10e2233ad2c26020b..d44226761b13237608732e24c724ea1e67e114d8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -19,7 +19,7 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-
+#include "globaldefs.h"
 #include "cmdlib.h"
 #include "qthreads.h"
 #include "mutex.h"
@@ -31,7 +31,7 @@
 
    ===================================================================
  */
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 
 #define USED
 
index ca8da18db23ae031c0cdf060557432c1915ce227..cbc23f66ab7482d2c4a25f868c6209d27dcdf615 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index c7b85dd3aa818192b38d75de6ac0824cc7d3b270..bef8fbd4d917313a0880d335a58daf75e3744641 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -19,7 +19,6 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-
 #include "cmdlib.h"
 #include "mathlib.h"
 #include "inout.h"
@@ -542,7 +541,7 @@ winding_t   *ReverseWinding( winding_t *w ){
    =============
  */
 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];
index 19603649853544f6916db4f876bb0a086e64ca59..08bf9aafadcd15475b3cfd4fa75bfceb1199bd59 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 62114f36f5dd0382635f5ef39d2d9b19f3fccce0..089d0e6c55d0aed0857b0961e72fa3ee25fe3a04 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index ddb363145a590cdd21a8e81e4504d29f127dd13c..202351c31e433c7695206e9a1b1db6304c63bd82 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 624cebde23cceb9273946b5fd8796be399acf03b..823cb63a3167f7c14e18cf0f7840e1c6a500d2e9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index c223bca297bd23f59898e6ff7e4605db1828ac38..d726c04b072d3d3bc2cc461b77441c91f76dd2d7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -58,6 +58,7 @@ qboolean tokenready;                     // only qtrue if UnGetToken was just ca
  */
 void AddScriptToStack( const char *filename, int index ){
        int size;
+       void* buffer;
 
        script++;
        if ( script == &scriptstack[MAX_INCLUDES] ) {
@@ -65,10 +66,11 @@ void AddScriptToStack( const char *filename, int index ){
        }
        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
        {
@@ -78,11 +80,12 @@ void AddScriptToStack( const char *filename, int index ){
                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;
+       }
 }
 
 
@@ -181,7 +184,7 @@ qboolean EndOfScript( qboolean crossline ){
        }
 
        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 );
index a1cf4defb36976d1e5d628c72d5f809b0f1f90d4..0ee62bde3d199e9eb35ca40a7ba449b9c4c4c162 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index e9f1b5cc2718d91af2f89020642943211f36ed40..12b9c2561aa82312cee1897599f3e236e1da5650 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 04946dd2f72edfc87566a954fee655d57becd854..0fb78ac4bd5963251b6c9a165fd38bdc2403c1f6 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -19,7 +19,9 @@
    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
@@ -59,7 +61,7 @@ int GetThreadWork( void ){
 
        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 )
@@ -116,7 +118,7 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )(
 
    ===================================================================
  */
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 
 #define USED
 
@@ -424,7 +426,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    =======================================================================
  */
 
-#if defined( __linux__ ) || ( defined( __APPLE__ ) && !MAC_STATIC_HACK )
+#if GDEF_OS_LINUX || ( GDEF_OS_MACOS && !MAC_STATIC_HACK )
 #define USED
 
 #include <unistd.h>
@@ -576,7 +578,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
                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" );
                        }
                }
@@ -626,7 +628,6 @@ void ThreadUnlock( void ){
    =============
  */
 void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
-       int i;
        int start, end;
 
        dispatch = 0;
index 8b063b0f5c3876fe6b4d25d8a8514223824ff57f..5f403418ff449077f8c7a2f1a83d5451ac0b4278 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -23,6 +23,7 @@
 // trilib.c: library for loading triangles from an Alias triangle file
 //
 
+#include "globaldefs.h"
 #include <stdio.h>
 #include "cmdlib.h"
 #include "mathlib.h"
@@ -38,7 +39,7 @@
 
 //#define NOISY 1
 
-#if defined ( __linux__ ) || defined ( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
 #define strlwr strlower
 #endif
 
@@ -61,7 +62,7 @@ typedef struct {
 
 
 static void ByteSwapTri( tf_triangle *tri ){
-       int i;
+       unsigned int i;
 
        for ( i = 0 ; i < sizeof( tf_triangle ) / 4 ; i++ )
        {
index ad14dec857bdc215e23d0a67b4dc6f9b1fc6e774..47dc14bf97d3f5198ed53d85473fda56e6add86d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
diff --git a/tools/quake3/common/unzip.c b/tools/quake3/common/unzip.c
deleted file mode 100644 (file)
index f833a34..0000000
+++ /dev/null
@@ -1,4610 +0,0 @@
-/*
-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
diff --git a/tools/quake3/common/unzip.h b/tools/quake3/common/unzip.h
deleted file mode 100644 (file)
index ca5a2a4..0000000
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
-   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
- */
index f14504706bd5fed1ac3b83e2dc83ec2aa9716f4a..48a1f86fbde046b5b81b411cb15f18167991125e 100644 (file)
 #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*   name;
-       unz_s zipinfo;
        unzFile zipfile;
+       unz_file_pos zippos;
        guint32 size;
 } VFS_PAKFILE;
 
@@ -123,6 +127,7 @@ static void vfsInitPakFile( const char *filename ){
        for ( i = 0; i < gi.number_entry; i++ )
        {
                char filename_inzip[NAME_MAX];
+               char *filename_lower;
                unz_file_info file_info;
                VFS_PAKFILE* file;
 
@@ -130,17 +135,23 @@ static void vfsInitPakFile( const char *filename ){
                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;
-               memcpy( &file->zipinfo, uf, sizeof( unz_s ) );
+               file->zippos = pos;
 
                if ( ( i + 1 ) < gi.number_entry ) {
                        err = unzGoToNextFile( uf );
@@ -148,6 +159,7 @@ static void vfsInitPakFile( const char *filename ){
                                break;
                        }
                }
+               g_free( filename_lower );
        }
 }
 
@@ -219,18 +231,18 @@ void vfsInitDirectory( const char *path ){
                                {
                                        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;
                                        }
                                }
@@ -275,7 +287,7 @@ void vfsListShaderFiles( char* list, int *num ){
                                }
 
                                for ( k = 0; k < *num; k++ ){
-                                       if ( !stricmp( list + k*65, dirlist ) ) goto shISdouplicate;
+                                       if ( !Q_stricmp( list + k*65, dirlist ) ) goto shISdouplicate;
                                }
                                strcpy( list + (*num)*65, dirlist );
                                (*num)++;
@@ -302,7 +314,7 @@ shISdouplicate:
                ext++;
 
                for ( k = 0; k < *num; k++ ){
-                       if ( !stricmp( list + k*65, ext ) ) goto shISdouplicate2;
+                       if ( !Q_stricmp( list + k*65, ext ) ) goto shISdouplicate2;
                }
                strcpy( list + (*num)*65, ext );
                (*num)++;
@@ -332,17 +344,18 @@ void vfsShutdown(){
 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++;
                }
        }
@@ -350,12 +363,12 @@ int vfsGetFileCount( const char *filename ){
        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;
 }
 
@@ -363,6 +376,7 @@ int vfsGetFileCount( const char *filename ){
 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
@@ -400,7 +414,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
        *bufferptr = NULL;
        strcpy( fixed, filename );
        vfsFixDOSName( fixed );
-       g_strdown( fixed );
+       lower = g_ascii_strdown( fixed, -1 );
 
        for ( i = 0; i < g_numDirs; i++ )
        {
@@ -446,13 +460,15 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
        {
                VFS_PAKFILE* file = (VFS_PAKFILE*)lst->data;
 
-               if ( strcmp( file->name, fixed ) != 0 ) {
+               if ( strcmp( file->name, lower ) != 0 ) {
                        continue;
                }
 
                if ( count == index ) {
-                       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;
                        }
@@ -467,20 +483,20 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
                                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;
@@ -565,4 +581,7 @@ qboolean vfsPackFile( const char *filename, const char *packname, const int comp
        }
 
        return qfalse;
+#else
+               Error( "Disabled because of miniz issue" );
+#endif
 }
index 95a21e15825e7c2f6d4f09be75f66aef4843ae2e..e47cadbaf41e061a6e794475d6afd697be85224b 100644 (file)
 #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
 #include <wtypes.h>
 #include <io.h>
-#define R_OK 04
 #define S_ISDIR( mode ) ( mode & _S_IFDIR )
 #define PATH_MAX 260
 #endif
-#include <glib.h>
 
 #define VFS_MAXDIRS 64
 
diff --git a/tools/quake3/q3data/.cvswrappers b/tools/quake3/q3data/.cvswrappers
deleted file mode 100644 (file)
index 2ea7d17..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-*.dsp  -m 'COPY' -k 'b'
-*.dsw  -m 'COPY' -k 'b'
index 164f9d1b2a1ce7eae8b9c73acdc94999b7048122..3e37f5e4b7217e15c9193849610c1e156fc86c65 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -47,7 +47,7 @@ static int ReadString( FILE *fp, char *buffer ){
        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;
        }
index 5490e939e0968d0dfb6a8973261741310d2fbc23..8a8a34c49fbf6d4f2481005874f2696af5d50037 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index e09975b2378aa62c57cea2365e8735fcf40896eb..ce442ced4471f5b75c757a93ba2437b9fbcc1c20 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 6de25fdc9f6f8c06770e2dc1f1c2369fc8025c86..bae43f75c1f698df97d91ef651544757231ec24f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -381,11 +381,9 @@ byte AveragePixels( int count ){
        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];
index f2f0eee5501ca6fcb98871d498e24a84cbe8ec84..93b1dfe0028787d2a015149839f62ca7788c54df 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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;
@@ -149,8 +152,8 @@ void MD3_Dump( const char *filename ){
                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 );
 
@@ -168,7 +171,7 @@ void MD3_Dump( const char *filename ){
        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 );
index 5158b5394a1a24e2109f00793612f849fba4f2d5..b899d6a786d2a0d23e016a4132fb331bba52a6ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -25,4 +25,4 @@
 #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] );
index 65fde8580109fbc4e1e5da89aad48f7e095267ee..b7492628ff5c80cbcf26a26644906c5c9aa318a3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -559,7 +559,6 @@ static void CopyTrianglesToBaseTriangles( triangle_t *ptri, int numtri, baseTria
 //     float           s_scale, t_scale;
 //     float           scale;
 //     vec3_t          mins, maxs;
-       float       *pbasevert;
 
 /*
     //
@@ -618,8 +617,6 @@ static void CopyTrianglesToBaseTriangles( triangle_t *ptri, int numtri, baseTria
 
                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 );
 
@@ -1905,8 +1902,9 @@ static void ConvertASE( const char *filename, int type, qboolean grabAnims ){
                        }
                }
 
-               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!" );
index 00cd5742cc5beb3ef86acd96cb32ffbdba5360da..02088c7c888eb6ea96180e3e21643a0936a0bc61 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 2da1ae9b6aed31e5b3a64791d518cb2f5709c667..97cc3f6a229510eda76ba7932e1773e94575113f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -20,8 +20,9 @@
  */
 
 #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
 {
@@ -67,7 +71,7 @@ int P3DLoad( const char *filename ){
 
        memset( &p3d, 0, sizeof( p3d ) );
 
-       p3d.len = filelength( fileno( fp ) );
+       p3d.len = filelength( fp );
 
        p3d.curpos = p3d.buffer = malloc( p3d.len );
 
index 4b2fcf1956a1f8b0a0f7bbbc08f20409e3377a2c..e35a996346fd4a7abaab215f8ba53b6df1ae1a1f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 3b6433b7342d0d2d7583ea1ccf8be541b1f83277..fcfc52a93d4d2fa0ad4f7b04e6a836c5bac86784 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -89,6 +89,7 @@ polyset_t *Polyset_LoadSets( const char *file, int *numpolysets, int maxTrisPerS
        }
        else{
                Error( "TRI files no longer supported" );
+               return NULL;
        }
 //             TRI_LoadPolysets( file, &psets, numpolysets );
 
index f517beb0e47afa2a4749b9ff73a553de2d8f70e3..331f6138c352448d04e97fc5bcef5c2940b898ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -19,7 +19,8 @@
    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"
@@ -40,7 +41,7 @@ char *moddir = NULL;
 // 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
 
@@ -301,7 +302,7 @@ void Cmd_File( void ){
 
    ===============
  */
-#ifdef _WIN32
+#if GDEF_OS_WINDOWS
 #include "io.h"
 void PackDirectory_r( char *dir ){
        struct _finddata_t fileinfo;
@@ -334,7 +335,7 @@ void PackDirectory_r( char *dir ){
 #else
 
 #include <sys/types.h>
-#ifndef WIN32
+#if !GDEF_OS_WINDOWS
 #include <sys/dir.h>
 #else
 #include <sys/dirent.h>
index d852369a0a33cd5c92837098496baa7adfdaaa7c..a8086ad5542d940bec0c5e7530d9bdf8b8982a50 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index 2e90bcefb5cbc820abe65ae6f900ba50a954ae79..a7a513731f6cd4ae4e8b114975d8d2de520c652c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
index b7be982cf0d6599ae0855e9569374489c4c1efe3..2fa7cee2ca14d2e6120389fe22149b9317273848 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   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.
@@ -106,7 +106,7 @@ void FindNextChunk( char *name ){
 //                     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;
                }
        }
@@ -128,7 +128,7 @@ void DumpChunks( void ){
                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 );
 }
@@ -155,7 +155,7 @@ wavinfo_t GetWavinfo( char *name, byte *wav, int wavlength ){
 
 // 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;
        }
@@ -191,7 +191,7 @@ wavinfo_t GetWavinfo( char *name, byte *wav, int wavlength ){
                // 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;
@@ -596,11 +596,11 @@ static float BTCCompressBlock( float inBlock[4][4][3], unsigned long out[2] ){
        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
        //
@@ -1107,7 +1107,7 @@ void Cmd_Video( void ){
 
        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 );
 
index ae89a127752eddba8103f2ff380e440a1bcab7e9..c6400cbc1ac3fc4859e2e917a34b3516b7c754bb 100644 (file)
@@ -93,7 +93,6 @@ brush_t *AllocBrush( int numSides ){
        brush_t     *bb;
        size_t c;
 
-
        /* allocate and clear */
        if ( numSides <= 0 ) {
                Error( "AllocBrush called with numsides = %d", numSides );
@@ -256,7 +255,7 @@ void SnapWeldVector( vec3_t a, vec3_t b, vec3_t out ){
        {
                /* 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 ] ) {
@@ -267,7 +266,7 @@ void SnapWeldVector( vec3_t a, vec3_t b, vec3_t out ){
                }
 
                /* 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{
@@ -282,6 +281,8 @@ void SnapWeldVector( vec3_t a, vec3_t b, vec3_t out ){
        }
 }
 
+
+
 /*
    ==================
    SnapWeldVectorAccu
@@ -329,6 +330,8 @@ void SnapWeldVectorAccu( vec3_accu_t a, vec3_accu_t b, vec3_accu_t out ){
        }
 }
 
+
+
 /*
    FixWinding() - ydnar
    removes degenerate edges from a winding
@@ -1041,8 +1044,9 @@ void SplitBrush( brush_t *brush, int planenum, brush_t **front, brush_t **back )
                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] ) {
index 6d61c58a5b19f80d3c35865600f823eaa9e42c1e..96da9ba864c9f7650f23841b5bcf93ad87d31513 100644 (file)
@@ -193,10 +193,10 @@ static void SetCloneModelNumbers( void ){
                                /* 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 );
@@ -265,7 +265,7 @@ static void FixBrushSides( entity_t *e ){
    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;
@@ -347,7 +347,7 @@ void ProcessWorldModel( void ){
                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" );
                xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
                xmlAddChild( leaknode, polyline );
@@ -384,7 +384,7 @@ void ProcessWorldModel( void ){
        /* save out information for visibility processing */
        NumberClusters( tree );
        if ( !leaked ) {
-               WritePortalFile( tree );
+               WritePortalFile( tree, portalFilePath );
        }
 
        /* flood from entities */
@@ -598,7 +598,7 @@ void ProcessSubModel( void ){
    process world + other models into the bsp
  */
 
-void ProcessModels( void ){
+void ProcessModels( const char *portalFilePath, const char *lineFilePath ){
        qboolean oldVerbose;
        entity_t    *entity;
 
@@ -624,7 +624,7 @@ void ProcessModels( void ){
                /* process the model */
                Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
                if ( mapEntityNum == 0 ) {
-                       ProcessWorldModel();
+                       ProcessWorldModel(portalFilePath, lineFilePath);
                }
                else{
                        ProcessSubModel();
@@ -653,17 +653,14 @@ void ProcessModels( void ){
    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" );
@@ -696,7 +693,7 @@ void OnlyEnts( void ){
        numBSPEntities = numEntities;
        UnparseEntities();
 
-       WriteBSPFile( out );
+       WriteBSPFile( BSPFilePath );
 }
 
 
@@ -710,6 +707,14 @@ int BSPMain( int argc, char **argv ){
        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 */
@@ -996,6 +1001,30 @@ int BSPMain( int argc, char **argv ){
                        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" );
                }
@@ -1021,13 +1050,23 @@ int BSPMain( int argc, char **argv ){
        /* 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 ] ) );
@@ -1040,7 +1079,7 @@ int BSPMain( int argc, char **argv ){
 
        /* if onlyents, just grab the entites and resave */
        if ( onlyents ) {
-               OnlyEnts();
+               OnlyEnts( BSPFilePath );
                return 0;
        }
 
@@ -1065,7 +1104,7 @@ int BSPMain( int argc, char **argv ){
        SetCloneModelNumbers();
 
        /* process world and submodels */
-       ProcessModels();
+       ProcessModels( portalFilePath, lineFilePath );
 
        /* set light styles from targetted light entities */
        SetLightStyles();
@@ -1074,7 +1113,7 @@ int BSPMain( int argc, char **argv ){
        ProcessAdvertisements();
 
        /* finish and write bsp */
-       EndBSPFile( qtrue );
+       EndBSPFile( qtrue, BSPFilePath, surfaceFilePath );
 
        /* remove temp map source file if appropriate */
        if ( strlen( tempSource ) > 0 ) {
diff --git a/tools/quake3/q3map2/bsp_analyze.c b/tools/quake3/q3map2/bsp_analyze.c
new file mode 100644 (file)
index 0000000..e84439d
--- /dev/null
@@ -0,0 +1,195 @@
+/* -------------------------------------------------------------------------------
+
+   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;
+}
diff --git a/tools/quake3/q3map2/bsp_info.c b/tools/quake3/q3map2/bsp_info.c
new file mode 100644 (file)
index 0000000..2cc79cf
--- /dev/null
@@ -0,0 +1,94 @@
+/* -------------------------------------------------------------------------------
+
+   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;
+}
diff --git a/tools/quake3/q3map2/bsp_scale.c b/tools/quake3/q3map2/bsp_scale.c
new file mode 100644 (file)
index 0000000..79bb815
--- /dev/null
@@ -0,0 +1,355 @@
+/* -------------------------------------------------------------------------------
+
+   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;
+}
index 27ea7c158ffc4761424fe63d0e978bd566dcaf1c..33583126e0c4ffbc8a72c4cf97205c5880842217 100644 (file)
@@ -109,7 +109,7 @@ void SetDrawSurfacesBuffer(){
 
        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 ){
@@ -122,7 +122,7 @@ 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(){
@@ -277,7 +277,7 @@ int GetLumpElements( bspHeader_t *header, int lump, int size ){
        /* 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{
@@ -321,7 +321,7 @@ int CopyLump( bspHeader_t *header, int lump, void *dest, int size ){
        }
        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{
@@ -620,6 +620,8 @@ void ParseEntities( void ){
        numBSPEntities = numEntities;
 }
 
+
+
 /*
  * must be called before UnparseEntities
  */
@@ -665,6 +667,8 @@ if (nocmdline)
        SetKeyValue( &entities[0], "_q3map2_version", Q3MAP_VERSION );
 }
 
+
+
 /*
    UnparseEntities()
    generates the dentdata string from all the entities.
@@ -791,6 +795,8 @@ void SetKeyValue( entity_t *ent, const char *key, const char *value ){
        ep->value = copystring( value );
 }
 
+
+
 /*
    KeyExists()
    returns true if entity has this key
@@ -811,6 +817,8 @@ qboolean KeyExists( const entity_t *ent, const char *key ){
        return qfalse;
 }
 
+
+
 /*
    ValueForKey()
    gets the value for an entity key
@@ -874,7 +882,7 @@ vec_t FloatForKey( const entity_t *ent, const char *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;
 
@@ -888,6 +896,9 @@ void GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec ){
        vec[ 0 ] = v1;
        vec[ 1 ] = v2;
        vec[ 2 ] = v3;
+
+       /* true if the key is found, false otherwise */
+       return strlen( k );
 }
 
 
index 4a6c7258e24ec03b27b9180ac508b0bd2b6b242c..1b0be1eca476c884aef59ee0779aca78e6b1839e 100644 (file)
@@ -169,7 +169,7 @@ static void ConvertSurface( FILE *f, bspModel_t *model, int modelNum, bspDrawSur
                        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{
@@ -253,7 +253,7 @@ static void ConvertShader( FILE *f, bspShader_t *shader, int shaderNum ){
        /* 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;
        }
 
diff --git a/tools/quake3/q3map2/convert_bsp.c b/tools/quake3/q3map2/convert_bsp.c
new file mode 100644 (file)
index 0000000..9db3260
--- /dev/null
@@ -0,0 +1,273 @@
+/* -------------------------------------------------------------------------------
+
+   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 );
+}
index 64b6dcef2e72c4f116c4850430f30bcc7a3e8fbf..7415eebfdf501de4ab026c240ca5d1ab724c805b 100644 (file)
@@ -76,11 +76,11 @@ static void ConvertSurfaceToOBJ( FILE *f, bspModel_t *model, int modelNum, bspDr
                        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;
                }
        }
@@ -160,7 +160,7 @@ static void ConvertShaderToMTL( FILE *f, bspShader_t *shader, int shaderNum ){
        /* 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;
        }
 
index 86421b95bc387a4464424fb9759d90f34eaa1402..f7471c96ccea19869331abff927a067d81371b6f 100644 (file)
@@ -337,7 +337,7 @@ static int MakeDecalProjector( shaderInfo_t *si, vec4_t projection, float distan
 
        /* 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;
        }
 
@@ -431,7 +431,7 @@ void ProcessDecals( void ){
 
                /* 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;
                }
@@ -442,7 +442,7 @@ void ProcessDecals( void ){
 
                /* 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;
                }
 
diff --git a/tools/quake3/q3map2/exportents.c b/tools/quake3/q3map2/exportents.c
new file mode 100644 (file)
index 0000000..b123660
--- /dev/null
@@ -0,0 +1,112 @@
+/* -------------------------------------------------------------------------------
+
+   Copyright (C) 1999-2013 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."
+
+   ------------------------------------------------------------------------------- */
+
+
+
+/* marker */
+#define EXPORTENTS_C
+
+
+
+/* dependencies */
+#include "q3map2.h"
+
+
+
+
+/* -------------------------------------------------------------------------------
+
+   this file contains code that exports entities to a .ent file.
+
+   ------------------------------------------------------------------------------- */
+
+/*
+   ExportEntities()
+   exports the entities to a text file (.ent)
+ */
+
+void ExportEntities( void ){
+        char filename[ 1024 ];
+        FILE *file;
+               
+        /* note it */
+        Sys_FPrintf( SYS_VRB, "--- ExportEntities ---\n" );
+               
+        /* do some path mangling */
+        strcpy( filename, source );
+        StripExtension( filename );
+        strcat( filename, ".ent" );
+               
+        /* sanity check */
+        if ( bspEntData == NULL || bspEntDataSize == 0 ) {
+                Sys_FPrintf( SYS_WRN, "WARNING: No BSP entity data. aborting...\n" );
+                return;
+        }
+               
+        /* write it */
+        Sys_Printf( "Writing %s\n", filename );
+        Sys_FPrintf( SYS_VRB, "(%d bytes)\n", bspEntDataSize );
+        file = fopen( filename, "w" );
+               
+        if ( file == NULL ) {
+                Error( "Unable to open %s for writing", filename );
+        }
+               
+        fprintf( file, "%s\n", bspEntData );
+        fclose( file );
+}
+
+
+
+/*
+   ExportEntitiesMain()
+   exports the entities to a text file (.ent)
+ */
+
+int ExportEntitiesMain( int argc, char **argv ){
+        /* arg checking */
+        if ( argc < 1 ) {
+                Sys_Printf( "Usage: q3map -exportents [-v] <mapname>\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 );
+               
+        /* export the lightmaps */
+        ExportEntities();
+               
+        /* return to sender */
+        return 0;
+}
\ No newline at end of file
index e35f289206b658ba708fa309d244a84edd1dd4fd..e5390ede45a1fcc32da6a2893b4df1d17674e161 100644 (file)
@@ -77,12 +77,12 @@ void    FreeBspFace( face_t *f ) {
  */
 
 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;
@@ -90,9 +90,6 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum,
        int planenum;
        float sizeBias;
 
-       //int frontC,backC,splitsC,facingC;
-
-
        /* ydnar: set some defaults */
        *splitPlaneNum = -1; /* leaf */
        *compileFlags = 0;
@@ -179,10 +176,6 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum,
                if ( value > bestValue ) {
                        bestValue = value;
                        bestSplit = split;
-                       //frontC=front;
-                       //backC=back;
-                       //splitsC=splits;
-                       //facingC=facing;
                }
        }
 
@@ -191,24 +184,10 @@ static void SelectSplitPlaneNum( node_t *node, face_t *list, int *splitPlaneNum,
                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++;
        }
@@ -248,9 +227,6 @@ void BuildFaceTree_r( node_t *node, face_t *list ){
        winding_t   *frontWinding, *backWinding;
        int i;
        int splitPlaneNum, compileFlags;
-#if 0
-       qboolean isstruct = qfalse;
-#endif
 
 
        /* count faces left */
@@ -286,19 +262,14 @@ void BuildFaceTree_r( node_t *node, face_t *list ){
                        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;
@@ -351,25 +322,10 @@ void BuildFaceTree_r( node_t *node, face_t *list ){
                }
        }
 
-#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
 }
 
 
diff --git a/tools/quake3/q3map2/fixaas.c b/tools/quake3/q3map2/fixaas.c
new file mode 100644 (file)
index 0000000..e08cd13
--- /dev/null
@@ -0,0 +1,110 @@
+/* -------------------------------------------------------------------------------
+
+   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;
+}
index 78b6d5988dbb62ac5ebb8d55cb24b8db766f757e..a8bbec9cf1351ac715c4ed04eef22638a73545c3 100644 (file)
        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 */
index 0841283da3179b83a7d76bfdcd387435a29b58e1..f4303f2e63153470c2f3431d8d14567239c923f2 100644 (file)
        "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 */
index 3df7e141068d7516dd4ad09f7357117dd17eb412..5cd5b0386648ffc7c493778cfddf107399b2fad4 100644 (file)
 
 {
        "qfusion",          /* -game x */
-       "baseq3",           /* default base game data dir */
-       ".q3a",             /* unix home sub-dir */
-       "quake",            /* magic path word */
+       "base",             /* default base game data dir */
+       ".qfusion",         /* unix home sub-dir */
+       "qfusion",          /* magic path word */
        "scripts",          /* shader directory */
-       2048,               /* max lightmapped surface verts */
-       2048,               /* max surface verts */
-       12288,              /* max surface indexes */
-       qtrue,              /* flares */
+       65535,              /* max lightmapped surface verts */
+       65535,              /* max surface verts */
+       393210,             /* max surface indexes */
+       qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
        512,                /* lightmap width/height */
        1.0f,               /* lightmap gamma */
-       qfalse,             /* lightmap sRGB */
-       qfalse,             /* texture sRGB */
-       qfalse,             /* color sRGB */
+       qtrue,              /* lightmap sRGB */
+       qtrue,              /* texture sRGB */
+       qtrue,              /* color sRGB */
        0.0f,               /* lightmap exposure */
        1.0f,               /* lightmap compensate */
        1.0f,               /* lightgrid scale */
        qtrue,              /* light angle attenuation uses half-lambert curve */
        qtrue,              /* disable shader lightstyles hack */
        qtrue,              /* keep light entities on bsp */
-       8,                  /* default patchMeta subdivisions tolerance */
+       4,                  /* default patchMeta subdivisions tolerance */
        qtrue,              /* patch casting enabled */
        qtrue,              /* compile deluxemaps */
        0,                  /* deluxemaps default mode */
-       256,                /* minimap size */
+       512,                /* minimap size */
        1.0f,               /* minimap sharpener */
-       0.0f,               /* minimap border */
+       1.0f / 66.0f,       /* minimap border */
        qtrue,              /* minimap keep aspect */
-       MINIMAP_MODE_WHITE, /* minimap mode */
+       MINIMAP_MODE_GRAY,  /* minimap mode */
        "../minimaps/%s.tga", /* minimap name format */
        "FBSP",             /* bsp file prefix */
        1,                  /* bsp file version */
index a130ead1312941f2efbe31ec5923983c34d99f1d..3f7a29daa659119121701e1b59164a702223e7b5 100644 (file)
    ------------------------------------------------------------------------------- */
 
 
+   /* -------------------------------------------------------------------------------
+
+   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.)
+
 
 /* -------------------------------------------------------------------------------
 
@@ -52,9 +64,9 @@
 
 {
        "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 },
diff --git a/tools/quake3/q3map2/game_t.h b/tools/quake3/q3map2/game_t.h
deleted file mode 100644 (file)
index 385afae..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-
-/*
-   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;
diff --git a/tools/quake3/q3map2/game_unvanquished.h b/tools/quake3/q3map2/game_unvanquished.h
new file mode 100644 (file)
index 0000000..cf74973
--- /dev/null
@@ -0,0 +1,173 @@
+/* -------------------------------------------------------------------------------
+
+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."
+
+------------------------------------------------------------------------------- */
+
+/* Derived from Tremulous support by LinuxManMikeC */
+/* Updated to Unvanquished support by Neumond */
+
+
+/* marker */
+#ifndef GAME_UNVANQUISHED_H
+#define GAME_UNVANQUISHED_H
+
+
+
+/* -------------------------------------------------------------------------------
+
+content and surface flags - also uses defines from game_quake3.h
+
+------------------------------------------------------------------------------- */
+
+#define UNV_CONT_NOALIENBUILD         0x1000
+#define UNV_CONT_NOHUMANBUILD         0x2000
+#define UNV_CONT_NOBUILD              0x4000
+
+#define UNV_SURF_NOALIENBUILDSURFACE  0x80000
+#define UNV_SURF_NOHUMANBUILDSURFACE  0x100000
+#define UNV_SURF_NOBUILDSURFACE       0x200000
+
+
+
+/* -------------------------------------------------------------------------------
+
+game_t struct
+
+------------------------------------------------------------------------------- */
+
+{
+       "unvanquished",         /* -game x */
+       "pkg",                  /* default base game data dir */
+       ".local/share/unvanquished", /* unix home sub-dir */
+       "unvanquished",         /* magic path word */
+       "scripts",              /* shader directory */
+       1048575,                /* max lightmapped surface verts */
+       1048575,                /* max surface verts */
+       1048575,                /* max surface indexes */
+       qfalse,                 /* flares */
+       "flareshader",          /* default flare shader */
+       qfalse,                 /* wolf lighting model? */
+       128,                    /* lightmap width/height */
+       1.0f,                   /* lightmap gamma */
+       qfalse,                 /* lightmap sRGB */
+       qfalse,                 /* texture sRGB */
+       qfalse,                 /* color sRGB */
+       0.0f,                   /* lightmap exposure */
+       1.0f,                   /* lightmap compensate */
+       1.0f,                   /* lightgrid scale */
+       1.0f,                   /* lightgrid ambient scale */
+       qfalse,                 /* light angle attenuation uses half-lambert curve */
+       qfalse,                 /* disable shader lightstyles hack */
+       qtrue,                  /* keep light entities on bsp */
+       8,                      /* default patchMeta subdivisions tolerance */
+       qfalse,                 /* patch casting enabled */
+       qfalse,                 /* compile deluxemaps */
+       0,                      /* deluxemaps default mode */
+       512,                    /* minimap size */
+       1.0f,                   /* minimap sharpener */
+       0.0f,                   /* minimap border */
+       qtrue,                  /* minimap keep aspect */
+       MINIMAP_MODE_WHITE,     /* minimap mode */
+       "../minimaps/%s.tga",   /* minimap name format */
+       "IBSP",                 /* bsp file prefix */
+       46,                     /* bsp file version */
+       qfalse,                 /* cod-style lump len/ofs order */
+       LoadIBSPFile,           /* bsp load function */
+       WriteIBSPFile,          /* bsp write function */
+
+       {
+               /* name                 contentFlags            contentFlagsClear           surfaceFlags                   surfaceFlagsClear            compileFlags                    compileFlagsClear */
+
+               /* default */
+               { "default",            Q_CONT_SOLID,           -1,                         0,                              -1,                         C_SOLID,                        -1 },
+
+               /* ydnar */
+               { "lightgrid",          0,                      0,                          0,                              0,                          C_LIGHTGRID,                    0 },
+               { "antiportal",         0,                      0,                          0,                              0,                          C_ANTIPORTAL,                   0 },
+               { "skip",               0,                      0,                          0,                              0,                          C_SKIP,                         0 },
+
+               /* compiler */
+               { "origin",             Q_CONT_ORIGIN,          Q_CONT_SOLID,               0,                              0,                          C_ORIGIN | C_TRANSLUCENT,       C_SOLID },
+               { "areaportal",         Q_CONT_AREAPORTAL,      Q_CONT_SOLID,               0,                              0,                          C_AREAPORTAL | C_TRANSLUCENT,   C_SOLID },
+               { "trans",              Q_CONT_TRANSLUCENT,     0,                          0,                              0,                          C_TRANSLUCENT,                  0 },
+               { "detail",             Q_CONT_DETAIL,          0,                          0,                              0,                          C_DETAIL,                       0 },
+               { "structural",         Q_CONT_STRUCTURAL,      0,                          0,                              0,                          C_STRUCTURAL,                   0 },
+               { "hint",               0,                      0,                          Q_SURF_HINT,                    0,                          C_HINT,                         0 },
+               { "nodraw",             0,                      0,                          Q_SURF_NODRAW,                  0,                          C_NODRAW,                       0 },
+
+               { "alphashadow",        0,                      0,                          Q_SURF_ALPHASHADOW,             0,                          C_ALPHASHADOW | C_TRANSLUCENT,  0 },
+               { "lightfilter",        0,                      0,                          Q_SURF_LIGHTFILTER,             0,                          C_LIGHTFILTER | C_TRANSLUCENT,  0 },
+               { "nolightmap",         0,                      0,                          Q_SURF_VERTEXLIT,               0,                          C_VERTEXLIT,                    0 },
+               { "pointlight",         0,                      0,                          Q_SURF_VERTEXLIT,               0,                          C_VERTEXLIT,                    0 },
+
+               /* game */
+               { "nonsolid",           0,                      Q_CONT_SOLID,               Q_SURF_NONSOLID,                0,                          0,                              C_SOLID },
+
+               { "trigger",            Q_CONT_TRIGGER,         Q_CONT_SOLID,               0,                              0,                          C_TRANSLUCENT,                  C_SOLID },
+
+               { "water",              Q_CONT_WATER,           Q_CONT_SOLID,               0,                              0,                          C_LIQUID | C_TRANSLUCENT,       C_SOLID },
+               { "slime",              Q_CONT_SLIME,           Q_CONT_SOLID,               0,                              0,                          C_LIQUID | C_TRANSLUCENT,       C_SOLID },
+               { "lava",               Q_CONT_LAVA,            Q_CONT_SOLID,               0,                              0,                          C_LIQUID | C_TRANSLUCENT,       C_SOLID },
+
+               { "playerclip",         Q_CONT_PLAYERCLIP,      Q_CONT_SOLID,               0,                              0,                          C_DETAIL | C_TRANSLUCENT,       C_SOLID },
+               { "monsterclip",        Q_CONT_MONSTERCLIP,     Q_CONT_SOLID,               0,                              0,                          C_DETAIL | C_TRANSLUCENT,       C_SOLID },
+               { "nodrop",             Q_CONT_NODROP,          Q_CONT_SOLID,               0,                              0,                          C_TRANSLUCENT,                  C_SOLID },
+
+               { "clusterportal",      Q_CONT_CLUSTERPORTAL,   Q_CONT_SOLID,               0,                              0,                          C_TRANSLUCENT,                  C_SOLID },
+               { "donotenter",         Q_CONT_DONOTENTER,      Q_CONT_SOLID,               0,                              0,                          C_TRANSLUCENT,                  C_SOLID },
+               { "botclip",            Q_CONT_BOTCLIP,         Q_CONT_SOLID,               0,                              0,                          C_TRANSLUCENT,                  C_SOLID },
+
+               { "fog",                Q_CONT_FOG,             Q_CONT_SOLID,               0,                              0,                          C_FOG,                          C_SOLID },
+               { "sky",                0,                      0,                          Q_SURF_SKY,                     0,                          C_SKY,                          0 },
+
+               { "slick",              0,                      0,                          Q_SURF_SLICK,                   0,                          0,                              0 },
+
+               { "noimpact",           0,                      0,                          Q_SURF_NOIMPACT,                0,                          0,                              0 },
+               { "nomarks",            0,                      0,                          Q_SURF_NOMARKS,                 0,                          C_NOMARKS,                      0 },
+               { "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 },
+               { "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 },
+               { "dust",               0,                      0,                          Q_SURF_DUST,                    0,                          0,                              0 },
+
+               /* unvanquished */
+               {"noalienbuild",        UNV_CONT_NOALIENBUILD,  0,                         0,                               0,                          0,                              0 },
+               {"nohumanbuild",        UNV_CONT_NOHUMANBUILD,  0,                         0,                               0,                          0,                              0 },
+               {"nobuild",             UNV_CONT_NOBUILD,       0,                         0,                               0,                          0,                              0 },
+
+               {"noalienbuildsurface", 0,                      0,                         UNV_SURF_NOALIENBUILDSURFACE,    0,                          0,                              0 },
+               {"nohumanbuildsurface", 0,                      0,                         UNV_SURF_NOHUMANBUILDSURFACE,    0,                          0,                              0 },
+               {"nobuildsurface",      0,                      0,                         UNV_SURF_NOBUILDSURFACE,         0,                          0,                              0 },
+
+               /* null */
+               { NULL,                 0,                      0,                         0,                               0,                          0,                              0 }
+       }
+}
+
+/* end marker */
+#endif
index b4a3f7d6555e9e7fd494434132e587588f0c575d..fcfd17ec964f65a877d118b9b496d3fd3f995a62 100644 (file)
                { "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 },
index 1401323adb15595dc1295af1fadd787d44cf0034..c783b9a0805a89a4b3d7799171668c8ab2f57f1c 100644 (file)
                { "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 },
diff --git a/tools/quake3/q3map2/help.c b/tools/quake3/q3map2/help.c
new file mode 100644 (file)
index 0000000..104213b
--- /dev/null
@@ -0,0 +1,425 @@
+/* -------------------------------------------------------------------------------
+
+   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"
+
+
+
+struct HelpOption
+{
+       const char* name;
+       const char* description;
+};
+
+void HelpOptions(const char* group_name, int indentation, int width, struct HelpOption* options, int count)
+{
+       indentation *= 2;
+       char* indent = malloc(indentation+1);
+       memset(indent, ' ', indentation);
+       indent[indentation] = 0;
+       printf("%s%s:\n", indent, group_name);
+       indentation += 2;
+       indent = realloc(indent, indentation+1);
+       memset(indent, ' ', indentation);
+       indent[indentation] = 0;
+
+       int i;
+       for ( i = 0; i < count; i++ )
+       {
+               int printed = printf("%s%-24s  ", indent, options[i].name);
+               int descsz = strlen(options[i].description);
+               int j = 0;
+               while ( j < descsz && descsz-j > width - printed )
+               {
+                       if ( j != 0 )
+                               printf("%s%26c",indent,' ');
+                       int fragment = width - printed;
+                       while ( fragment > 0 && options[i].description[j+fragment-1] != ' ')
+                                       fragment--;
+                       j += fwrite(options[i].description+j, sizeof(char), fragment, stdout);
+                       putchar('\n');
+                       printed = indentation+26;
+               }
+               if ( j == 0 )
+               {
+                       printf("%s\n",options[i].description+j);
+               }
+               else if ( j < descsz )
+               {
+                       printf("%s%26c%s\n",indent,' ',options[i].description+j);
+               }
+       }
+
+       putchar('\n');
+
+       free(indent);
+}
+
+void HelpBsp()
+{
+       struct HelpOption bsp[] = {
+               {"-bsp <filename.map>", "Switch that enters this stage"},
+               {"-altsplit", "Alternate BSP tree splitting weights (should give more fps)"},
+               {"-bspfile <filename.bsp>", "BSP file to write"},
+               {"-celshader <shadername>", "Sets a global cel shader name"},
+               {"-custinfoparms", "Read scripts/custinfoparms.txt"},
+               {"-debuginset", "Push all triangle vertexes towards the triangle center"},
+               {"-debugportals", "Make BSP portals visible in the map"},
+               {"-debugsurfaces", "Color the vertexes according to the index of the surface"},
+               {"-deep", "Use detail brushes in the BSP tree, but at lowest priority (should give more fps)"},
+               {"-de <F>", "Distance epsilon for plane snapping etc."},
+               {"-fakemap", "Write fakemap.map containing all world brushes"},
+               {"-flares", "Turn on support for flares (TEST?)"},
+               {"-flat", "Enable flat shading (good for combining with -celshader)"},
+               {"-fulldetail", "Treat detail brushes as structural ones"},
+               {"-leaktest", "Abort if a leak was found"},
+               {"-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"},
+               {"-mv <N>", "Sets the maximum number of vertices of a lightmapped surface"},
+               {"-ne <F>", "Normal epsilon for plane snapping etc."},
+               {"-nocurves", "Turn off support for patches"},
+               {"-nodetail", "Leave out detail brushes"},
+               {"-noflares", "Turn off support for flares"},
+               {"-nofog", "Turn off support for fog volumes"},
+               {"-nohint", "Turn off support for hint brushes"},
+               {"-nosubdivide", "Turn off support for `q3map_tessSize` (breaks water vertex deforms)"},
+               {"-notjunc", "Do not fix T-junctions (causes cracks between triangles, do not use)"},
+               {"-nowater", "Turn off support for water, slime or lava (Stef, this is for you)"},
+               {"-np <A>", "Force all surfaces to be nonplanar with a given shade angle"},
+               {"-onlyents", "Only update entities in the BSP"},
+               {"-patchmeta", "Turn patches into triangle meshes for display"},
+               {"-prtfile <filename.prt>", "Portal file to write"},
+               {"-rename", "Append suffix to miscmodel shaders (needed for SoF2)"},
+               {"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"},
+               {"-skyfix", "Turn sky box into six surfaces to work around ATI problems"},
+               {"-snap <N>", "Snap brush bevel planes to the given number of units"},
+               {"-srffile <filename.srf>", "Surface file to write"},
+               {"-tempname <filename.map>", "Read the MAP file from the given file name"},
+               {"-texrange <N>", "Limit per-surface texture range to the given number of units, and subdivide surfaces like with `q3map_tessSize` if this is not met"},
+               {"-tmpout", "Write the BSP file to /tmp"},
+               {"-verboseentities", "Enable `-v` only for map entities, not for the world"},
+       };
+       HelpOptions("BSP Stage", 0, 80, bsp, sizeof(bsp)/sizeof(struct HelpOption));
+}
+
+void HelpVis()
+{
+       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)"},
+               {"-nosort", "Do not sort the portals before calculating vis (usually slower)"},
+               {"-passageOnly", "Just use PassageFlow vis (usually less fps)"},
+               {"-prtfile <filename.prt>", "Portal file to read"},
+               {"-saveprt", "Keep the Portal file after running vis (so you can run vis again)"},
+               {"-tmpin", "Use /tmp folder for input"},
+               {"-tmpout", "Use /tmp folder for output"},
+       };
+       HelpOptions("VIS Stage", 0, 80, vis, sizeof(vis)/sizeof(struct HelpOption));
+}
+
+void HelpLight()
+{
+       struct HelpOption light[] = {
+               {"-light <filename.map>", "Switch that enters this stage"},
+               {"-vlight <filename.map>", "Deprecated alias for `-light -fast` ... filename.map"},
+               {"-approx <N>", "Vertex light approximation tolerance (never use in conjunction with deluxemapping)"},
+               {"-areascale <F, `-area` F>", "Scaling factor for area lights (surfacelight)"},
+               {"-border", "Add a red border to lightmaps for debugging"},
+               {"-bouncegrid", "Also compute radiosity on the light grid"},
+               {"-bounceonly", "Only compute radiosity"},
+               {"-bouncescale <F>", "Scaling factor for radiosity"},
+               {"-bounce <N>", "Number of bounces for radiosity"},
+               {"-bspfile <filename.bsp>", "BSP file to write"},
+               {"-cheapgrid", "Use `-cheap` style lighting for radiosity"},
+               {"-cheap", "Abort vertex light calculations when white is reached"},
+               {"-compensate <F>", "Lightmap compensate (darkening factor applied after everything else)"},
+               {"-cpma", "CPMA vertex lighting mode"},
+               {"-custinfoparms", "Read scripts/custinfoparms.txt"},
+               {"-dark", "Darken lightmap seams"},
+               {"-debugaxis", "Color the lightmaps according to the lightmap axis"},
+               {"-debugcluster", "Color the lightmaps according to the index of the cluster"},
+               {"-debugdeluxe", "Show deluxemaps on the lightmap"},
+               {"-debugnormals", "Color the lightmaps according to the direction of the surface normal"},
+               {"-debugorigin", "Color the lightmaps according to the origin of the luxels"},
+               {"-debugsurfaces, -debugsurface", "Color the lightmaps according to the index of the surface"},
+               {"-debugunused", "This option does nothing"},
+               {"-debug", "Mark the lightmaps according to the cluster: unmapped clusters get yellow, occluded ones get pink, flooded ones get blue overlay color, otherwise red"},
+               {"-deluxemode 0", "Use modelspace deluxemaps (DarkPlaces)"},
+               {"-deluxemode 1", "Use tangentspace deluxemaps"},
+               {"-deluxe, -deluxemap", "Enable deluxemapping (light direction maps)"},
+               {"-dirtdebug, -debugdirt", "Store the dirtmaps as lightmaps for debugging"},
+               {"-dirtdepth", "Dirtmapping depth"},
+               {"-dirtgain", "Dirtmapping exponent"},
+               {"-dirtmode 0", "Ordered direction dirtmapping"},
+               {"-dirtmode 1", "Randomized direction dirtmapping"},
+               {"-dirtscale", "Dirtmapping scaling factor"},
+               {"-dirty", "Enable dirtmapping"},
+               {"-dump", "Dump radiosity from `-bounce` into numbered MAP file prefabs"},
+               {"-export", "Export lightmaps when compile finished (like `-export` mode)"},
+               {"-exposure <F>", "Lightmap exposure to better support overbright spots"},
+               {"-external", "Force external lightmaps even if at size of internal lightmaps"},
+               {"-extravisnudge", "Broken feature to nudge the luxel origin to a better vis cluster"},
+               {"-extrawide", "Deprecated alias for `-super 2 -filter`"},
+               {"-extra", "Deprecated alias for `-super 2`"},
+               {"-fastallocate", "Use `-fastallocate` to trade lightmap size against allocation time (useful with hi res lightmaps on large maps: reduce allocation time from days to minutes for only some extra bytes)"},
+               {"-fastbounce", "Use `-fast` style lighting for radiosity"},
+               {"-faster", "Use a faster falloff curve for lighting; also implies `-fast`"},
+               {"-fastgrid", "Use `-fast` style lighting for the light grid"},
+               {"-fast", "Ignore tiny light contributions"},
+               {"-filter", "Lightmap filtering"},
+               {"-floodlight", "Enable floodlight (zero-effort somewhat decent lighting)"},
+               {"-gamma <F>", "Lightmap gamma"},
+               {"-gridambientscale <F>", "Scaling factor for the light grid ambient components only"},
+               {"-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"},
+               {"-nocollapse", "Do not collapse identical lightmaps"},
+               {"-nodeluxe, -nodeluxemap", "Disable deluxemapping"},
+               {"-nogrid", "Disable grid light calculation (makes all entities fullbright)"},
+               {"-nolightmapsearch", "Do not optimize lightmap packing for GPU memory usage (as doing so costs fps)"},
+               {"-normalmap", "Color the lightmaps according to the direction of the surface normal (TODO is this identical to `-debugnormals`?)"},
+               {"-nostyle, -nostyles", "Disable support for light styles"},
+               {"-nosurf", "Disable tracing against surfaces (only uses BSP nodes then)"},
+               {"-notrace", "Disable shadow occlusion"},
+               {"-novertex", "Disable vertex lighting"},
+               {"-patchshadows", "Cast shadows from patches"},
+               {"-pointscale <F, `-point` F>", "Scaling factor for point lights (light entities)"},
+               {"-q3", "Use nonlinear falloff curve by default (like Q3A)"},
+               {"-samplescale <F>", "Scales all lightmap resolutions"},
+               {"-samplesize <N>", "Sets default lightmap resolution in luxels/qu"},
+               {"-samples <N>", "Adaptive supersampling quality"},
+               {"-scale <F>", "Scaling factor for all light types"},
+               {"-shadeangle <A>", "Angle for phong shading"},
+               {"-shade", "Enable phong shading at default shade angle"},
+               {"-skyscale <F, `-sky` F>", "Scaling factor for sky and sun light"},
+               {"-smooth", "Deprecated alias for `-samples 2`"},
+               {"-srffile <filename.srf>", "Surface file to read"},
+               {"-style, -styles", "Enable support for light styles"},
+               {"-sunonly", "Only compute sun light"},
+               {"-super <N, `-supersample` N>", "Ordered grid supersampling quality"},
+               {"-thresh <F>", "Triangle subdivision threshold"},
+               {"-trianglecheck", "Broken check that should ensure luxels apply to the right triangle"},
+               {"-trisoup", "Convert brush faces to triangle soup"},
+               {"-wolf", "Use linear falloff curve by default (like W:ET)"},
+       };
+
+       HelpOptions("Light Stage", 0, 80, light, sizeof(light)/sizeof(struct HelpOption));
+}
+
+void HelpAnalyze()
+{
+       struct HelpOption analyze[] = {
+               {"-analyze <filename.bsp>", "Switch that enters this mode"},
+               {"-lumpswap", "Swap byte order in the lumps"},
+       };
+
+       HelpOptions("Analyzing BSP-like file structure", 0, 80, analyze, sizeof(analyze)/sizeof(struct HelpOption));
+}
+
+void HelpScale()
+{
+       struct HelpOption scale[] = {
+               {"-scale <S filename.bsp>", "Scale uniformly"},
+               {"-scale <SX SY SZ filename.bsp>", "Scale non-uniformly"},
+               {"-scale -tex <S filename.bsp>", "Scale uniformly without texture lock"},
+               {"-scale -tex <SX SY SZ filename.bsp>", "Scale non-uniformly without texture lock"},
+       };
+       HelpOptions("Scaling", 0, 80, scale, sizeof(scale)/sizeof(struct HelpOption));
+}
+
+void HelpConvert()
+{
+       struct HelpOption convert[] = {
+               {"-convert <filename.bsp>", "Switch that enters this mode"},
+               {"-de <number>", "Distance epsilon for the conversion"},
+               {"-format <converter>", "Select the converter (available: map, ase, or game names)"},
+               {"-ne <F>", "Normal epsilon for the conversion"},
+               {"-shadersasbitmap", "(only for ase) use the shader names as \\*BITMAP key so they work as prefabs"},
+       };
+
+       HelpOptions("Converting & Decompiling", 0, 80, convert, sizeof(convert)/sizeof(struct HelpOption));
+}
+
+void HelpExport()
+{
+       struct HelpOption exportl[] = {
+               {"-export <filename.bsp>", "Copies lightmaps from the BSP to `filename/lightmap_0000.tga` ff"}
+       };
+
+       HelpOptions("Exporting lightmaps", 0, 80, exportl, sizeof(exportl)/sizeof(struct HelpOption));
+}
+
+void HelpExportEnts()
+{
+       struct HelpOption exportents[] = {
+               {"-exportents <filename.bsp>", "Exports the entities to a text file (.ent)"},
+       };
+       HelpOptions("ExportEnts Stage", 0, 80, exportents, sizeof(exportents)/sizeof(struct HelpOption));
+}
+
+void HelpFixaas()
+{
+       struct HelpOption fixaas[] = {
+               {"-fixaas <filename.bsp>", "Switch that enters this mode"},
+       };
+
+       HelpOptions("Fixing AAS checksum", 0, 80, fixaas, sizeof(fixaas)/sizeof(struct HelpOption));
+}
+
+void HelpInfo()
+{
+       struct HelpOption info[] = {
+               {"-info <filename.bsp>", "Switch that enters this mode"},
+       };
+
+       HelpOptions("Get info about BSP file", 0, 80, info, sizeof(info)/sizeof(struct HelpOption));
+}
+
+void HelpImport()
+{
+       struct HelpOption import[] = {
+               {"-import <filename.bsp>", "Copies lightmaps from `filename/lightmap_0000.tga` ff into the BSP"},
+       };
+
+       HelpOptions("Importing lightmaps", 0, 80, import, sizeof(import)/sizeof(struct HelpOption));
+}
+
+void HelpMinimap()
+{
+       struct HelpOption minimap[] = {
+               {"-minimap <filename.bsp>", "Creates a minimap of the BSP, by default writes to `../gfx/filename_mini.tga`"},
+               {"-black", "Write the minimap as a black-on-transparency RGBA32 image"},
+               {"-boost <F>", "Sets the contrast boost value (higher values make a brighter image); contrast boost is somewhat similar to gamma, but continuous even at zero"},
+               {"-border <F>", "Sets the amount of border pixels relative to the total image size"},
+               {"-gray", "Write the minimap as a white-on-black GRAY8 image"},
+               {"-keepaspect", "Ensure the aspect ratio is kept (the minimap is then letterboxed to keep aspect)"},
+               {"-minmax <xmin ymin zmin xmax ymax zmax>", "Forces specific map dimensions (note: the minimap actually uses these dimensions, scaled to the target size while keeping aspect with centering, and 1/64 of border appended to all sides)"},
+               {"-nokeepaspect", "Do not ensure the aspect ratio is kept (makes it easier to use the image in your code, but looks bad together with sharpening)"},
+               {"-o <filename.tga>", "Sets the output file name"},
+               {"-random <N>", "Sets the randomized supersampling count (cannot be combined with `-samples`)"},
+               {"-samples <N>", "Sets the ordered supersampling count (cannot be combined with `-random`)"},
+               {"-sharpen <F>", "Sets the sharpening coefficient"},
+               {"-size <N>", "Sets the width and height of the output image"},
+               {"-white", "Write the minimap as a white-on-transparency RGBA32 image"},
+       };
+
+       HelpOptions("MiniMap", 0, 80, minimap, sizeof(minimap)/sizeof(struct HelpOption));
+}
+
+void HelpCommon()
+{
+       struct HelpOption common[] = {
+               {"-connect <address>", "Talk to a NetRadiant instance using a specific XML based protocol"},
+               {"-force", "Allow reading some broken/unsupported BSP files e.g. when decompiling, may also crash"},
+               {"-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_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"},
+               {"-werror", "Make all warnings into errors"}
+       };
+
+       HelpOptions("Common Options", 0, 80, common, sizeof(common)/sizeof(struct HelpOption));
+
+}
+
+void HelpMain(const char* arg)
+{
+       printf("Usage: q3map2 [stage] [common options...] [stage options...] [stage source file]\n");
+       printf("       q3map2 -help [stage]\n\n");
+
+       HelpCommon();
+
+       struct HelpOption stages[] = {
+               {"-bsp", "BSP Stage"},
+               {"-vis", "VIS Stage"},
+               {"-light", "Light Stage"},
+               {"-analyze", "Analyzing BSP-like file structure"},
+               {"-scale", "Scaling"},
+               {"-convert", "Converting & Decompiling"},
+               {"-export", "Exporting lightmaps"},
+               {"-exportents", "Exporting entities"},
+               {"-fixaas", "Fixing AAS checksum"},
+               {"-info", "Get info about BSP file"},
+               {"-import", "Importing lightmaps"},
+               {"-minimap", "MiniMap"},
+       };
+       void(*help_funcs[])() = {
+               HelpBsp,
+               HelpVis,
+               HelpLight,
+               HelpAnalyze,
+               HelpScale,
+               HelpConvert,
+               HelpExport,
+               HelpExportEnts,
+               HelpFixaas,
+               HelpInfo,
+               HelpImport,
+               HelpMinimap,
+       };
+
+       if ( arg && strlen(arg) > 0 )
+       {
+               if ( arg[0] == '-' )
+                       arg++;
+
+               unsigned i;
+               for ( i = 0; i < sizeof(stages)/sizeof(struct HelpOption); i++ )
+                       if ( strcmp(arg, stages[i].name+1) == 0 )
+                       {
+                               help_funcs[i]();
+                               return;
+                       }
+       }
+
+       HelpOptions("Stages", 0, 80, stages, sizeof(stages)/sizeof(struct HelpOption));
+}
index 60062a1705b983c641a27cd0c70f402bb34911c2..e5f97a40c1dbc8d4d71531bbc237926ef033020f 100644 (file)
@@ -36,7 +36,7 @@
 /* dependencies */
 #include "q3map2.h"
 
-
+#include "webp/decode.h"
 
 /* -------------------------------------------------------------------------------
 
@@ -67,13 +67,13 @@ static void LoadDDSBuffer( byte *buffer, int size, byte **pixels, int *width, in
 
        /* 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;
        }
 
@@ -86,6 +86,28 @@ static void LoadDDSBuffer( byte *buffer, int size, byte **pixels, int *width, in
        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
 
 
 /*
@@ -123,7 +145,6 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in
        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;
@@ -140,27 +161,27 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in
 
        /* 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;
        }
@@ -170,11 +191,10 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in
        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;
        }
@@ -228,6 +248,34 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in
 
 
 
+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
@@ -384,56 +432,71 @@ image_t *ImageLoad( const char *filename ){
        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 );
 
@@ -464,8 +527,8 @@ image_t *ImageLoad( const char *filename ){
                        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;
index 5d448ba54045ac7241688550b328ae8500c3e758..243af8a3c45ea0e3dc10775ed00da2be74c711f6 100644 (file)
@@ -43,7 +43,7 @@
 
    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;
@@ -76,7 +75,6 @@ xmlNodePtr LeakFile( tree_t *tree ){
        //
        // write the points to the file
        //
-       sprintf( filename, "%s.lin", source );
        linefile = fopen( filename, "w" );
        if ( !linefile ) {
                Error( "Couldn't open %s\n", filename );
index 9b3926e5fe02c82dafd9488c7cef223e607843f2..100bed593a748c7e0e2657ce235b08ab6eef5d7a 100644 (file)
@@ -442,7 +442,7 @@ void CreateEntityLights( void ){
                        /* 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;
                        }
@@ -1159,7 +1159,7 @@ int LightContributionToSample( trace_t *trace ){
                /* return to sender */
                return 1;
        }
-       else{
+       else {
                Error( "Light of undefined type!" );
        }
 
@@ -1890,7 +1890,7 @@ void SetupGrid( void ){
    does what it says...
  */
 
-void LightWorld( void ){
+void LightWorld( const char *BSPFilePath, qboolean fastAllocate ){
        vec3_t color;
        float f;
        int b, bt;
@@ -1910,14 +1910,15 @@ void LightWorld( void ){
 
        /* 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" );
@@ -2033,10 +2034,10 @@ void LightWorld( void ){
        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 );
@@ -2054,7 +2055,7 @@ void LightWorld( void ){
                SetupEnvelopes( qfalse, fastbounce );
                if ( numLights == 0 ) {
                        Sys_Printf( "No diffuse light to calculate, ending radiosity.\n" );
-                       break;
+                       return;
                }
 
                /* add to lightgrid */
@@ -2097,6 +2098,8 @@ void LightWorld( void ){
                bounce--;
                b++;
        }
+       /* ydnar: store off lightmaps */
+       StoreSurfaceLightmaps( fastAllocate );
 }
 
 
@@ -2109,11 +2112,14 @@ void LightWorld( void ){
 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" );
@@ -2529,6 +2535,7 @@ int LightMain( int argc, char **argv ){
                        }
                        i++;
                }
+
                else if ( !strcmp( argv[ i ], "-deluxe" ) || !strcmp( argv[ i ], "-deluxemap" ) ) {
                        deluxemap = qtrue;
                        Sys_Printf( "Generating deluxemaps for average light direction\n" );
@@ -2558,7 +2565,7 @@ int LightMain( int argc, char **argv ){
 
                        /* 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++;
@@ -2682,6 +2689,11 @@ int LightMain( int argc, char **argv ){
                        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" );
@@ -2827,6 +2839,14 @@ int LightMain( int argc, char **argv ){
                        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 );
@@ -2920,10 +2940,22 @@ int LightMain( int argc, char **argv ){
                        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 ] );
                }
 
        }
@@ -2973,29 +3005,37 @@ int LightMain( int argc, char **argv ){
                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();
@@ -3006,7 +3046,7 @@ int LightMain( int argc, char **argv ){
        /* 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 */
@@ -3022,15 +3062,12 @@ int LightMain( int argc, char **argv ){
        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 ) {
index b9cb8242463ae72fd3c3ac61b92003ea6737c4b4..478819e7a3abcccd4ac1e8f7d6ea9f943c0b5c62 100644 (file)
@@ -556,7 +556,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw
        light->falloffTolerance = falloffTolerance;
 
        /* bouncing light? */
-       if ( !bouncing ) {
+       if ( bouncing == qfalse ) {
                /* This is weird. This actually handles surfacelight and not
                 * bounces. */
 
index 08606f7e466615972f2124988704107e19a3a28c..f9afbf7833f779b7c3bc4e6ac8da2ff064220a2a 100644 (file)
@@ -56,7 +56,8 @@
 #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
 
@@ -198,9 +199,6 @@ static int AllocTraceNode( void ){
        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 */
@@ -406,8 +404,6 @@ static int SetupTraceNodes_r( int bspNodeNum ){
                }
        }
 
-       /* Sys_Printf("node %d children: %d %d\n", nodeNum, traceNodes[ nodeNum ].children[0], traceNodes[ nodeNum ].children[1]); */
-
        /* return node number */
        return nodeNum;
 }
index 4aa7eac7d8b9913b2630a401bb1af6bf9b47fe68..5f46268f5b7c57fc0ee1e51677b998c93e440103 100644 (file)
@@ -1759,9 +1759,8 @@ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float
                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 ] );
@@ -1785,15 +1784,12 @@ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float
                //%     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 ] );
 
@@ -1804,10 +1800,6 @@ static qboolean SubmapRawLuxel( rawLightmap_t *lm, int x, int y, float bx, float
        }
 
        /* 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 );
 
@@ -2215,7 +2207,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){
 
                        /* 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;
                        }
 
@@ -2267,42 +2259,31 @@ void IlluminateRawLightmap( int rawLightmapNum ){
                                        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++;
                                        }
                                }
                        }
@@ -2630,8 +2611,6 @@ void IlluminateRawLightmap( int rawLightmapNum ){
                                {
                                        /* 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 );
@@ -2755,45 +2734,6 @@ void IlluminateRawLightmap( int rawLightmapNum ){
                        }
                }
        }
-
-
-#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
 }
 
 
@@ -3219,7 +3159,7 @@ void IlluminateVertexes( int num ){
    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;
        qboolean inside;
@@ -3711,7 +3651,7 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag ){
                                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 ) {
@@ -3830,7 +3770,7 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag ){
                                        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 ] );
index 82de24747d5615f07ae52ff6d62e13789a5fce0b..ea36b921f8bd6a41b75be713a64286de5ae7019c 100644 (file)
@@ -35,7 +35,7 @@
 
 /* dependencies */
 #include "q3map2.h"
-
+#include <glib.h>
 
 
 
@@ -127,7 +127,7 @@ void ExportLightmaps( void ){
 
        /* sanity check */
        if ( bspLightBytes == NULL ) {
-               Sys_Printf( "WARNING: No BSP lightmap data\n" );
+               Sys_FPrintf( SYS_WRN, "WARNING: No BSP lightmap data\n" );
                return;
        }
 
@@ -226,7 +226,7 @@ int ImportLightmapsMain( int argc, char **argv ){
                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;
                }
 
@@ -237,11 +237,11 @@ int ImportLightmapsMain( int argc, char **argv ){
 
                /* 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 );
                }
 
@@ -525,7 +525,7 @@ qboolean AddPatchToRawLightmap( int num, rawLightmap_t *lm ){
        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;
        }
@@ -538,7 +538,7 @@ qboolean AddPatchToRawLightmap( int num, rawLightmap_t *lm ){
        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;
        }
@@ -769,7 +769,7 @@ qboolean AddSurfaceToRawLightmap( int num, rawLightmap_t *lm ){
 
        /* 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;
        }
@@ -907,7 +907,6 @@ static int CompareSurfaceInfo( const void *a, const void *b ){
                return -1;
        }
 
-
        /* then lightmap sample size */
        if ( aInfo->sampleSize < bInfo->sampleSize ) {
                return 1;
@@ -988,7 +987,7 @@ void SetupSurfaceLightmaps( void ){
                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;
        }
 
@@ -1998,7 +1997,7 @@ static void SetupOutLightmap( rawLightmap_t *lm, outLightmap_t *olm ){
  */
 
 #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;
@@ -2006,6 +2005,7 @@ static void FindOutLightmaps( rawLightmap_t *lm ){
        vec3_t color, direction;
        byte                *pixel;
        qboolean ok;
+       int xIncrement, yIncrement;
 
 
        /* set default lightmap number (-3 = LIGHTMAP_BY_VERTEX) */
@@ -2116,6 +2116,13 @@ static void FindOutLightmaps( rawLightmap_t *lm ){
                                        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 ) {
@@ -2133,10 +2140,20 @@ static void FindOutLightmaps( rawLightmap_t *lm ){
                                        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 );
@@ -2350,6 +2367,8 @@ static int CompareRawLightmap( const void *a, const void *b ){
        return 0;
 }
 
+
+
 void FillOutLightmap( outLightmap_t *olm ){
        int x, y;
        int ofs;
@@ -2462,12 +2481,14 @@ void FillOutLightmap( outLightmap_t *olm ){
        }
 }
 
+
+
 /*
    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;
@@ -2485,8 +2506,8 @@ void StoreSurfaceLightmaps( void ){
        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 */
@@ -2509,7 +2530,7 @@ void StoreSurfaceLightmaps( void ){
           ----------------------------------------------------------------- */
 
        /* note it */
-       Sys_Printf( "Subsampling..." );
+       Sys_FPrintf( SYS_VRB, "Subsampling..." );
 
        /* walk the list of raw lightmaps */
        numUsed = 0;
@@ -2977,7 +2998,7 @@ void StoreSurfaceLightmaps( void ){
 
        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++ )
@@ -3046,7 +3067,7 @@ void StoreSurfaceLightmaps( void ){
           ----------------------------------------------------------------- */
 
        /* note it */
-       Sys_Printf( "sorting..." );
+       Sys_FPrintf( SYS_VRB, "sorting..." );
 
        /* allocate a new sorted list */
        if ( sortLightmaps == NULL ) {
@@ -3063,7 +3084,7 @@ void StoreSurfaceLightmaps( void ){
           ----------------------------------------------------------------- */
 
        /* note it */
-       Sys_Printf( "allocating..." );
+       Sys_FPrintf( SYS_VRB, "allocating..." );
 
        /* kill all existing output lightmaps */
        if ( outLightmaps != NULL ) {
@@ -3085,7 +3106,7 @@ void StoreSurfaceLightmaps( void ){
        for ( i = 0; i < numRawLightmaps; i++ )
        {
                lm = &rawLightmaps[ sortLightmaps[ i ] ];
-               FindOutLightmaps( lm );
+               FindOutLightmaps( lm, fastAllocate );
        }
 
        /* set output numbers in twinned lightmaps */
@@ -3116,7 +3137,7 @@ void StoreSurfaceLightmaps( void ){
           ----------------------------------------------------------------- */
 
        /* note it */
-       Sys_Printf( "storing..." );
+       Sys_FPrintf( SYS_VRB, "storing..." );
 
        /* count the bsp lightmaps and allocate space */
        if ( bspLightBytes != NULL ) {
@@ -3186,7 +3207,7 @@ void StoreSurfaceLightmaps( void ){
        }
 
        if ( numExtLightmaps > 0 ) {
-               Sys_Printf( "\n" );
+               Sys_FPrintf( SYS_VRB, "\n" );
        }
 
        /* delete unused external lightmaps */
@@ -3207,7 +3228,7 @@ void StoreSurfaceLightmaps( void ){
           ----------------------------------------------------------------- */
 
        /* note it */
-       Sys_Printf( "projecting..." );
+       Sys_FPrintf( SYS_VRB, "projecting..." );
 
        /* walk the list of surfaces */
        for ( i = 0; i < numBSPDrawSurfaces; i++ )
@@ -3486,7 +3507,7 @@ void StoreSurfaceLightmaps( void ){
        }
 
        /* finish */
-       Sys_Printf( "done.\n" );
+       Sys_FPrintf( SYS_VRB, "done.\n" );
 
        /* calc num stored */
        numStored = numBSPLightBytes / 3;
index 2e97c89d0c5cb20eaeea7c4a13242f0757c2dd96..1e2e67d5b07379670e6d449fe1c7a2011d30d49f 100644 (file)
@@ -1,4 +1,4 @@
-/* -------------------------------------------------------------------------------;
+/* -------------------------------------------------------------------------------
 
    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 );
-       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;
 }
 
 
@@ -1532,13 +156,13 @@ int ShiftBSPMain( int argc, char **argv ){
                /* 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 ] );
@@ -1660,10 +284,10 @@ void tex2list( char* texlist, int *texnum, char* EXtex, int *EXtexnum ){
        StripExtension( token );
        FixDOSName( token );
        for ( i = 0; i < *texnum; i++ ){
-               if ( !stricmp( texlist + i*65, token ) ) return;
+               if ( !Q_stricmp( texlist[i], token ) ) return;
        }
        for ( i = 0; i < *EXtexnum; i++ ){
-               if ( !stricmp( EXtex + i*65, token ) ) return;
+               if ( !Q_stricmp( EXtex[i], token ) ) return;
        }
        strcpy ( texlist + (*texnum)*65, token );
        (*texnum)++;
@@ -1677,7 +301,7 @@ void tex2list2( char* texlist, int *texnum, char* EXtex, int *EXtexnum, char* rE
        //StripExtension( token );
        char* dot = strrchr( token, '.' );
        if ( dot != NULL){
-               if ( stricmp( dot, ".tga" ) && stricmp( dot, ".jpg" ) && stricmp( dot, ".png" ) ){
+               if ( Q_stricmp( dot, ".tga" ) && Q_stricmp( dot, ".jpg" ) && Q_stricmp( dot, ".png" ) ){
                        Sys_Printf( "WARNING4: %s : weird or missing extension in shader\n", token );
                }
                else{
@@ -1690,13 +314,13 @@ void tex2list2( char* texlist, int *texnum, char* EXtex, int *EXtexnum, char* rE
 
        /* exclude */
        for ( i = 0; i < *texnum; i++ ){
-               if ( !stricmp( texlist + i*65, texlist + (*texnum)*65 ) ) return;
+               if ( !Q_stricmp( texlist + i*65, texlist + (*texnum)*65 ) ) return;
        }
        for ( i = 0; i < *EXtexnum; i++ ){
-               if ( !stricmp( EXtex + i*65, texlist + (*texnum)*65 ) ) return;
+               if ( !Q_stricmp( EXtex + i*65, texlist + (*texnum)*65 ) ) return;
        }
        for ( i = 0; i < *rEXtexnum; i++ ){
-               if ( !stricmp( rEXtex + i*65, texlist + (*texnum)*65 ) ) return;
+               if ( !Q_stricmp( rEXtex + i*65, texlist + (*texnum)*65 ) ) return;
        }
        (*texnum)++;
        return;
@@ -1717,7 +341,7 @@ void res2list( char* data, int *num ){
        }
        if ( *( data + (*num)*65 ) == '\0') return;
        for ( i = 0; i < *num; i++ ){
-               if ( !stricmp( data + i*65, data + (*num)*65 ) ) return;
+               if ( !Q_stricmp( data[i], data[*num] ) ) return;
        }
        (*num)++;
        return;
@@ -1825,7 +449,7 @@ int pk3BSPMain( int argc, char **argv ){
        epair_t *ep;
        for ( ep = entities[0].epairs; ep != NULL; ep = ep->next )
        {
-               if ( !strnicmp( ep->key, "vertexremapshader", 17 ) ) {
+               if ( !Q_strncasecmp( ep->key, "vertexremapshader", 17 ) ) {
                        sscanf( ep->value, "%*[^;] %*[;] %s", pk3Shaders + pk3ShadersN*65 );
                        res2list( pk3Shaders, &pk3ShadersN );
                }
@@ -1846,13 +470,13 @@ int pk3BSPMain( int argc, char **argv ){
                        res2list( pk3Sounds, &pk3SoundsN );
                }
 
-               if ( !stricmp( ValueForKey( &entities[i], "classname" ), "func_plat" ) ){
+               if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "func_plat" ) ){
                        strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_strt.wav");
                        res2list( pk3Sounds, &pk3SoundsN );
                        strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_end.wav");
                        res2list( pk3Sounds, &pk3SoundsN );
                }
-               if ( !stricmp( ValueForKey( &entities[i], "classname" ), "target_push" ) ){
+               if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "target_push" ) ){
                        if ( !(IntForKey( &entities[i], "spawnflags") & 1) ){
                                strcpy( pk3Sounds + pk3SoundsN*65, "sound/misc/windfly.wav");
                                res2list( pk3Sounds, &pk3SoundsN );
@@ -1940,19 +564,19 @@ int pk3BSPMain( int argc, char **argv ){
                }
 
                /* blocks */
-               if ( !stricmp( token, "textures" ) ){
+               if ( !Q_stricmp( token, "textures" ) ){
                        parseEXblock ( ExTextures, &ExTexturesN, exName );
                }
-               else if ( !stricmp( token, "shaders" ) ){
+               else if ( !Q_stricmp( token, "shaders" ) ){
                        parseEXblock ( ExShaders, &ExShadersN, exName );
                }
-               else if ( !stricmp( token, "shaderfiles" ) ){
+               else if ( !Q_stricmp( token, "shaderfiles" ) ){
                        parseEXblock ( ExShaderfiles, &ExShaderfilesN, exName );
                }
-               else if ( !stricmp( token, "sounds" ) ){
+               else if ( !Q_stricmp( token, "sounds" ) ){
                        parseEXblock ( ExSounds, &ExSoundsN, exName );
                }
-               else if ( !stricmp( token, "videos" ) ){
+               else if ( !Q_stricmp( token, "videos" ) ){
                        parseEXblock ( ExVideos, &ExVideosN, exName );
                }
                else{
@@ -1965,7 +589,7 @@ int pk3BSPMain( int argc, char **argv ){
 
        for ( i = 0; i < ExTexturesN; i++ ){
                for ( j = 0; j < ExShadersN; j++ ){
-                       if ( !stricmp( ExTextures + i*65, ExShaders + j*65 ) ){
+                       if ( !Q_stricmp( ExTextures + i*65, ExShaders + j*65 ) ){
                                break;
                        }
                }
@@ -1995,7 +619,7 @@ skipEXfile:
        /* can exclude pure textures right now, shouldn't create shaders for them anyway */
        for ( i = 0; i < pk3ShadersN ; i++ ){
                for ( j = 0; j < ExPureTexturesN ; j++ ){
-                       if ( !stricmp( pk3Shaders + i*65, ExPureTextures + j*65 ) ){
+                       if ( !Q_stricmp( pk3Shaders + i*65, ExPureTextures + j*65 ) ){
                                *( pk3Shaders + i*65 ) = '\0';
                                break;
                        }
@@ -2019,7 +643,7 @@ skipEXfile:
 
                /* do wanna le shader file? */
                for ( j = 0; j < ExShaderfilesN; j++ ){
-                       if ( !stricmp( ExShaderfiles + j*65, pk3Shaderfiles + i*65 ) ){
+                       if ( !Q_stricmp( ExShaderfiles + j*65, pk3Shaderfiles + i*65 ) ){
                                ShaderFileExcluded = qtrue;
                                reasonShaderFile = ExShaderfiles + j*65;
                                break;
@@ -2036,7 +660,7 @@ skipEXfile:
 
                        /* does it contain restricted shaders/textures? */
                        for ( j = 0; j < ExShadersN; j++ ){
-                               if ( !stricmp( ExShaders + j*65, token ) ){
+                               if ( !Q_stricmp( ExShaders + j*65, token ) ){
                                        ShaderFileExcluded = qtrue;
                                        reasonShader = ExShaders + j*65;
                                        break;
@@ -2045,7 +669,7 @@ skipEXfile:
                        if ( ShaderFileExcluded )
                                break;
                        for ( j = 0; j < ExPureTexturesN; j++ ){
-                               if ( !stricmp( ExPureTextures + j*65, token ) ){
+                               if ( !Q_stricmp( ExPureTextures + j*65, token ) ){
                                        ShaderFileExcluded = qtrue;
                                        reasonShader = ExPureTextures + j*65;
                                        break;
@@ -2101,7 +725,7 @@ skipEXfile:
                        /* do wanna le shader? */
                        wantShader = qfalse;
                        for ( j = 0; j < pk3ShadersN; j++ ){
-                               if ( !stricmp( pk3Shaders + j*65, token) ){
+                               if ( !Q_stricmp( pk3Shaders + j*65, token) ){
                                        shader = j;
                                        wantShader = qtrue;
                                        break;
@@ -2146,15 +770,15 @@ skipEXfile:
                                                if ( !strcmp( token, "{" ) ) {
                                                        Sys_Printf( "WARNING9: %s : line %d : opening brace inside shader stage\n", temp, scriptline );
                                                }
-                                               if ( !stricmp( token, "mapComp" ) || !stricmp( token, "mapNoComp" ) || !stricmp( token, "animmapcomp" ) || !stricmp( token, "animmapnocomp" ) ){
+                                               if ( !Q_stricmp( token, "mapComp" ) || !Q_stricmp( token, "mapNoComp" ) || !Q_stricmp( token, "animmapcomp" ) || !Q_stricmp( token, "animmapnocomp" ) ){
                                                        Sys_Printf( "WARNING7: %s : line %d : unsupported '%s' map directive\n", temp, scriptline, token );
                                                }
                                                /* skip the shader */
                                                if ( !wantShader ) continue;
 
                                                /* digest any images */
-                                               if ( !stricmp( token, "map" ) ||
-                                                       !stricmp( token, "clampMap" ) ) {
+                                               if ( !Q_stricmp( token, "map" ) ||
+                                                       !Q_stricmp( token, "clampMap" ) ) {
                                                        hasmap = qtrue;
                                                        /* get an image */
                                                        GetToken( qfalse );
@@ -2162,8 +786,8 @@ skipEXfile:
                                                                tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
                                                        }
                                                }
-                                               else if ( !stricmp( token, "animMap" ) ||
-                                                       !stricmp( token, "clampAnimMap" ) ) {
+                                               else if ( !Q_stricmp( token, "animMap" ) ||
+                                                       !Q_stricmp( token, "clampAnimMap" ) ) {
                                                        hasmap = qtrue;
                                                        GetToken( qfalse );// skip num
                                                        while ( TokenAvailable() ){
@@ -2171,7 +795,7 @@ skipEXfile:
                                                                tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
                                                        }
                                                }
-                                               else if ( !stricmp( token, "videoMap" ) ){
+                                               else if ( !Q_stricmp( token, "videoMap" ) ){
                                                        hasmap = qtrue;
                                                        GetToken( qfalse );
                                                        FixDOSName( token );
@@ -2181,12 +805,12 @@ skipEXfile:
                                                        }
                                                        FixDOSName( token );
                                                        for ( j = 0; j < pk3VideosN; j++ ){
-                                                               if ( !stricmp( pk3Videos + j*65, token ) ){
+                                                               if ( !Q_stricmp( pk3Videos + j*65, token ) ){
                                                                        goto away;
                                                                }
                                                        }
                                                        for ( j = 0; j < ExVideosN; j++ ){
-                                                               if ( !stricmp( ExVideos + j*65, token ) ){
+                                                               if ( !Q_stricmp( ExVideos + j*65, token ) ){
                                                                        goto away;
                                                                }
                                                        }
@@ -2197,7 +821,7 @@ skipEXfile:
                                                }
                                        }
                                }
-                               else if ( !strnicmp( token, "implicit", 8 ) ){
+                               else if ( !Q_strncasecmp( token, "implicit", 8 ) ){
                                        Sys_Printf( "WARNING5: %s : line %d : unsupported %s shader\n", temp, scriptline, token );
                                }
                                /* skip the shader */
@@ -2208,22 +832,22 @@ skipEXfile:
                                ----------------------------------------------------------------- */
 
                                /* match surfaceparm */
-                               else if ( !stricmp( token, "surfaceparm" ) ) {
+                               else if ( !Q_stricmp( token, "surfaceparm" ) ) {
                                        GetToken( qfalse );
-                                       if ( !stricmp( token, "nodraw" ) ) {
+                                       if ( !Q_stricmp( token, "nodraw" ) ) {
                                                wantShader = qfalse;
                                                *( pk3Shaders + shader*65 ) = '\0';
                                        }
                                }
 
                                /* skyparms <outer image> <cloud height> <inner image> */
-                               else if ( !stricmp( token, "skyParms" ) ) {
+                               else if ( !Q_stricmp( token, "skyParms" ) ) {
                                        hasmap = qtrue;
                                        /* get image base */
                                        GetToken( qfalse );
 
                                        /* ignore bogus paths */
-                                       if ( stricmp( token, "-" ) && stricmp( token, "full" ) ) {
+                                       if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) {
                                                strcpy ( temp, token );
                                                sprintf( token, "%s_up", temp );
                                                tex2list( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN );
@@ -2242,7 +866,7 @@ skipEXfile:
                                        GetToken( qfalse );
                                        GetToken( qfalse );
                                }
-                               else if ( !stricmp( token, "fogparms" ) ){
+                               else if ( !Q_stricmp( token, "fogparms" ) ){
                                        hasmap = qtrue;
                                }
                        }
@@ -2250,7 +874,7 @@ skipEXfile:
                        //exclude shader
                        if ( wantShader ){
                                for ( j = 0; j < ExShadersN; j++ ){
-                                       if ( !stricmp( ExShaders + j*65, pk3Shaders + shader*65 ) ){
+                                       if ( !Q_stricmp( ExShaders + j*65, pk3Shaders + shader*65 ) ){
                                                wantShader = qfalse;
                                                *( pk3Shaders + shader*65 ) = '\0';
                                                break;
@@ -2305,14 +929,14 @@ skipEXfile:
                if ( *( pk3Shaders + i*65 ) != '\0' ){
                        FixDOSName( pk3Shaders + i*65 );
                        for ( j = 0; j < pk3TexturesN; j++ ){
-                               if ( !stricmp( pk3Shaders + i*65, pk3Textures + j*65 ) ){
+                               if ( !Q_stricmp( pk3Shaders + i*65, pk3Textures + j*65 ) ){
                                        *( pk3Shaders + i*65 ) = '\0';
                                        break;
                                }
                        }
                        if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
                        for ( j = 0; j < ExTexturesN; j++ ){
-                               if ( !stricmp( pk3Shaders + i*65, ExTextures + j*65 ) ){
+                               if ( !Q_stricmp( pk3Shaders + i*65, ExTextures + j*65 ) ){
                                        *( pk3Shaders + i*65 ) = '\0';
                                        break;
                                }
@@ -2323,7 +947,7 @@ skipEXfile:
 //snds
        for ( i = 0; i < pk3SoundsN; i++ ){
                for ( j = 0; j < ExSoundsN; j++ ){
-                       if ( !stricmp( pk3Sounds + i*65, ExSounds + j*65 ) ){
+                       if ( !Q_stricmp( pk3Sounds + i*65, ExSounds + j*65 ) ){
                                *( pk3Sounds + i*65 ) = '\0';
                                break;
                        }
@@ -2550,19 +1174,19 @@ int repackBSPMain( int argc, char **argv ){
                }
 
                /* blocks */
-               if ( !stricmp( token, "textures" ) ){
+               if ( !Q_stricmp( token, "textures" ) ){
                        parseEXblock ( ExTextures, &ExTexturesN, exName );
                }
-               else if ( !stricmp( token, "shaders" ) ){
+               else if ( !Q_stricmp( token, "shaders" ) ){
                        parseEXblock ( ExShaders, &ExShadersN, exName );
                }
-               else if ( !stricmp( token, "shaderfiles" ) ){
+               else if ( !Q_stricmp( token, "shaderfiles" ) ){
                        parseEXblock ( ExShaderfiles, &ExShaderfilesN, exName );
                }
-               else if ( !stricmp( token, "sounds" ) ){
+               else if ( !Q_stricmp( token, "sounds" ) ){
                        parseEXblock ( ExSounds, &ExSoundsN, exName );
                }
-               else if ( !stricmp( token, "videos" ) ){
+               else if ( !Q_stricmp( token, "videos" ) ){
                        parseEXblock ( ExVideos, &ExVideosN, exName );
                }
                else{
@@ -2575,7 +1199,7 @@ int repackBSPMain( int argc, char **argv ){
 
        for ( i = 0; i < ExTexturesN; i++ ){
                for ( j = 0; j < ExShadersN; j++ ){
-                       if ( !stricmp( ExTextures + i*65, ExShaders + j*65 ) ){
+                       if ( !Q_stricmp( ExTextures + i*65, ExShaders + j*65 ) ){
                                break;
                        }
                }
@@ -2647,19 +1271,19 @@ skipEXfile:
                }
 
                /* blocks */
-               if ( !stricmp( token, "textures" ) ){
+               if ( !Q_stricmp( token, "textures" ) ){
                        parseEXblock ( rExTextures, &rExTexturesN, exName );
                }
-               else if ( !stricmp( token, "shaders" ) ){
+               else if ( !Q_stricmp( token, "shaders" ) ){
                        parseEXblock ( rExShaders, &rExShadersN, exName );
                }
-               else if ( !stricmp( token, "shaderfiles" ) ){
+               else if ( !Q_stricmp( token, "shaderfiles" ) ){
                        parseEXblock ( rExShaderfiles, &rExShaderfilesN, exName );
                }
-               else if ( !stricmp( token, "sounds" ) ){
+               else if ( !Q_stricmp( token, "sounds" ) ){
                        parseEXblock ( rExSounds, &rExSoundsN, exName );
                }
-               else if ( !stricmp( token, "videos" ) ){
+               else if ( !Q_stricmp( token, "videos" ) ){
                        parseEXblock ( rExVideos, &rExVideosN, exName );
                }
                else{
@@ -2693,7 +1317,7 @@ skipEXrefile:
 
        /* do some path mangling */
        strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
-       if ( !stricmp( strrchr( source, '.' ), ".bsp" ) ){
+       if ( !Q_stricmp( strrchr( source, '.' ), ".bsp" ) ){
                strcpy( bspList, source );
                bspListN++;
        }
@@ -2790,7 +1414,7 @@ skipEXrefile:
                epair_t *ep;
                for ( ep = entities[0].epairs; ep != NULL; ep = ep->next )
                {
-                       if ( !strnicmp( ep->key, "vertexremapshader", 17 ) ) {
+                       if ( !!Q_strncasecmp( ep->key, "vertexremapshader", 17 ) ) {
                                sscanf( ep->value, "%*[^;] %*[;] %s", pk3Shaders + pk3ShadersN*65 );
                                res2list( pk3Shaders, &pk3ShadersN );
                        }
@@ -2811,13 +1435,13 @@ skipEXrefile:
                                res2list( pk3Sounds, &pk3SoundsN );
                        }
 
-                       if ( !stricmp( ValueForKey( &entities[i], "classname" ), "func_plat" ) ){
+                       if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "func_plat" ) ){
                                strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_strt.wav");
                                res2list( pk3Sounds, &pk3SoundsN );
                                strcpy( pk3Sounds + pk3SoundsN*65, "sound/movers/plats/pt1_end.wav");
                                res2list( pk3Sounds, &pk3SoundsN );
                        }
-                       if ( !stricmp( ValueForKey( &entities[i], "classname" ), "target_push" ) ){
+                       if ( !Q_stricmp( ValueForKey( &entities[i], "classname" ), "target_push" ) ){
                                if ( !(IntForKey( &entities[i], "spawnflags") & 1) ){
                                        strcpy( pk3Sounds + pk3SoundsN*65, "sound/misc/windfly.wav");
                                        res2list( pk3Sounds, &pk3SoundsN );
@@ -2988,7 +1612,7 @@ skipEXrefile:
        /* can exclude pure *base* textures right now, shouldn't create shaders for them anyway */
        for ( i = 0; i < pk3ShadersN ; i++ ){
                for ( j = 0; j < ExPureTexturesN ; j++ ){
-                       if ( !stricmp( pk3Shaders + i*65, ExPureTextures + j*65 ) ){
+                       if ( !Q_stricmp( pk3Shaders + i*65, ExPureTextures + j*65 ) ){
                                *( pk3Shaders + i*65 ) = '\0';
                                break;
                        }
@@ -2997,7 +1621,7 @@ skipEXrefile:
        /* can exclude repack.exclude shaders, assuming they got all their images */
        for ( i = 0; i < pk3ShadersN ; i++ ){
                for ( j = 0; j < rExShadersN ; j++ ){
-                       if ( !stricmp( pk3Shaders + i*65, rExShaders + j*65 ) ){
+                       if ( !Q_stricmp( pk3Shaders + i*65, rExShaders + j*65 ) ){
                                *( pk3Shaders + i*65 ) = '\0';
                                break;
                        }
@@ -3040,7 +1664,7 @@ skipEXrefile:
                        /* do wanna le shader? */
                        wantShader = qfalse;
                        for ( j = 0; j < pk3ShadersN; j++ ){
-                               if ( !stricmp( pk3Shaders + j*65, token) ){
+                               if ( !Q_stricmp( pk3Shaders + j*65, token) ){
                                        shader = j;
                                        wantShader = qtrue;
                                        break;
@@ -3048,7 +1672,7 @@ skipEXrefile:
                        }
                        if ( wantShader ){
                                for ( j = 0; j < rExTexturesN ; j++ ){
-                                       if ( !stricmp( pk3Shaders + shader*65, rExTextures + j*65 ) ){
+                                       if ( !Q_stricmp( pk3Shaders + shader*65, rExTextures + j*65 ) ){
                                                Sys_Printf( "WARNING3: %s : about to include shader for excluded texture\n", pk3Shaders + shader*65 );
                                                break;
                                        }
@@ -3101,8 +1725,8 @@ skipEXrefile:
                                                if ( !wantShader ) continue;
 
                                                /* digest any images */
-                                               if ( !stricmp( token, "map" ) ||
-                                                       !stricmp( token, "clampMap" ) ) {
+                                               if ( !Q_stricmp( token, "map" ) ||
+                                                       !Q_stricmp( token, "clampMap" ) ) {
                                                        strcat( shaderText, "\n\t\t" );
                                                        strcat( shaderText, token );
                                                        hasmap = qtrue;
@@ -3115,8 +1739,8 @@ skipEXrefile:
                                                        strcat( shaderText, " " );
                                                        strcat( shaderText, token );
                                                }
-                                               else if ( !stricmp( token, "animMap" ) ||
-                                                       !stricmp( token, "clampAnimMap" ) ) {
+                                               else if ( !Q_stricmp( token, "animMap" ) ||
+                                                       !Q_stricmp( token, "clampAnimMap" ) ) {
                                                        strcat( shaderText, "\n\t\t" );
                                                        strcat( shaderText, token );
                                                        hasmap = qtrue;
@@ -3132,7 +1756,7 @@ skipEXrefile:
                                                        }
                                                        tokenready = qtrue;
                                                }
-                                               else if ( !stricmp( token, "videoMap" ) ){
+                                               else if ( !Q_stricmp( token, "videoMap" ) ){
                                                        strcat( shaderText, "\n\t\t" );
                                                        strcat( shaderText, token );
                                                        hasmap = qtrue;
@@ -3146,17 +1770,17 @@ skipEXrefile:
                                                        }
                                                        FixDOSName( token );
                                                        for ( j = 0; j < pk3VideosN; j++ ){
-                                                               if ( !stricmp( pk3Videos + j*65, token ) ){
+                                                               if ( !Q_stricmp( pk3Videos + j*65, token ) ){
                                                                        goto away;
                                                                }
                                                        }
                                                        for ( j = 0; j < ExVideosN; j++ ){
-                                                               if ( !stricmp( ExVideos + j*65, token ) ){
+                                                               if ( !Q_stricmp( ExVideos + j*65, token ) ){
                                                                        goto away;
                                                                }
                                                        }
                                                        for ( j = 0; j < rExVideosN; j++ ){
-                                                               if ( !stricmp( rExVideos + j*65, token ) ){
+                                                               if ( !Q_stricmp( rExVideos + j*65, token ) ){
                                                                        goto away;
                                                                }
                                                        }
@@ -3165,7 +1789,7 @@ skipEXrefile:
                                                        away:
                                                        j = 0;
                                                }
-                                               else if ( !stricmp( token, "mapComp" ) || !stricmp( token, "mapNoComp" ) || !stricmp( token, "animmapcomp" ) || !stricmp( token, "animmapnocomp" ) ){
+                                               else if ( !Q_stricmp( token, "mapComp" ) || !Q_stricmp( token, "mapNoComp" ) || !Q_stricmp( token, "animmapcomp" ) || !Q_stricmp( token, "animmapnocomp" ) ){
                                                        Sys_Printf( "WARNING7: %s : %s shader\n", pk3Shaders + shader*65, token );
                                                        hasmap = qtrue;
                                                        if ( line == scriptline ){
@@ -3195,18 +1819,18 @@ skipEXrefile:
                                ----------------------------------------------------------------- */
 
                                /* match surfaceparm */
-                               else if ( !stricmp( token, "surfaceparm" ) ) {
+                               else if ( !Q_stricmp( token, "surfaceparm" ) ) {
                                        strcat( shaderText, "\n\tsurfaceparm " );
                                        GetToken( qfalse );
                                        strcat( shaderText, token );
-                                       if ( !stricmp( token, "nodraw" ) ) {
+                                       if ( !Q_stricmp( token, "nodraw" ) ) {
                                                wantShader = qfalse;
                                                *( pk3Shaders + shader*65 ) = '\0';
                                        }
                                }
 
                                /* skyparms <outer image> <cloud height> <inner image> */
-                               else if ( !stricmp( token, "skyParms" ) ) {
+                               else if ( !Q_stricmp( token, "skyParms" ) ) {
                                        strcat( shaderText, "\n\tskyParms " );
                                        hasmap = qtrue;
                                        /* get image base */
@@ -3214,7 +1838,7 @@ skipEXrefile:
                                        strcat( shaderText, token );
 
                                        /* ignore bogus paths */
-                                       if ( stricmp( token, "-" ) && stricmp( token, "full" ) ) {
+                                       if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) {
                                                strcpy ( temp, token );
                                                sprintf( token, "%s_up", temp );
                                                tex2list2( pk3Textures, &pk3TexturesN, ExTextures, &ExTexturesN, rExTextures, &rExTexturesN );
@@ -3237,7 +1861,7 @@ skipEXrefile:
                                        strcat( shaderText, " " );
                                        strcat( shaderText, token );
                                }
-                               else if ( !strnicmp( token, "implicit", 8 ) ){
+                               else if ( !!Q_strncasecmp( token, "implicit", 8 ) ){
                                        Sys_Printf( "WARNING5: %s : %s shader\n", pk3Shaders + shader*65, token );
                                        hasmap = qtrue;
                                        if ( line == scriptline ){
@@ -3249,7 +1873,7 @@ skipEXrefile:
                                                strcat( shaderText, token );
                                        }
                                }
-                               else if ( !stricmp( token, "fogparms" ) ){
+                               else if ( !Q_stricmp( token, "fogparms" ) ){
                                        hasmap = qtrue;
                                        if ( line == scriptline ){
                                                strcat( shaderText, " " );
@@ -3273,7 +1897,7 @@ skipEXrefile:
                        //exclude shader
                        if ( wantShader ){
                                for ( j = 0; j < ExShadersN; j++ ){
-                                       if ( !stricmp( ExShaders + j*65, pk3Shaders + shader*65 ) ){
+                                       if ( !Q_stricmp( ExShaders + j*65, pk3Shaders + shader*65 ) ){
                                                wantShader = qfalse;
                                                *( pk3Shaders + shader*65 ) = '\0';
                                                break;
@@ -3304,7 +1928,7 @@ skipEXrefile:
                                FixDOSName( pk3Shaders + i*65 );
                                //what if theres properly slashed one in the list?
                                for ( j = 0; j < pk3ShadersN; j++ ){
-                                       if ( !stricmp( pk3Shaders + i*65, pk3Shaders + j*65 ) && (i != j) ){
+                                       if ( !Q_stricmp( pk3Shaders + i*65, pk3Shaders + j*65 ) && (i != j) ){
                                                *( pk3Shaders + i*65 ) = '\0';
                                                break;
                                        }
@@ -3312,21 +1936,21 @@ skipEXrefile:
                        }
                        if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
                        for ( j = 0; j < pk3TexturesN; j++ ){
-                               if ( !stricmp( pk3Shaders + i*65, pk3Textures + j*65 ) ){
+                               if ( !Q_stricmp( pk3Shaders + i*65, pk3Textures + j*65 ) ){
                                        *( pk3Shaders + i*65 ) = '\0';
                                        break;
                                }
                        }
                        if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
                        for ( j = 0; j < ExTexturesN; j++ ){
-                               if ( !stricmp( pk3Shaders + i*65, ExTextures + j*65 ) ){
+                               if ( !Q_stricmp( pk3Shaders + i*65, ExTextures + j*65 ) ){
                                        *( pk3Shaders + i*65 ) = '\0';
                                        break;
                                }
                        }
                        if ( *( pk3Shaders + i*65 ) == '\0' ) continue;
                        for ( j = 0; j < rExTexturesN; j++ ){
-                               if ( !stricmp( pk3Shaders + i*65, rExTextures + j*65 ) ){
+                               if ( !Q_stricmp( pk3Shaders + i*65, rExTextures + j*65 ) ){
                                        *( pk3Shaders + i*65 ) = '\0';
                                        break;
                                }
@@ -3337,14 +1961,14 @@ skipEXrefile:
 //snds
        for ( i = 0; i < pk3SoundsN; i++ ){
                for ( j = 0; j < ExSoundsN; j++ ){
-                       if ( !stricmp( pk3Sounds + i*65, ExSounds + j*65 ) ){
+                       if ( !Q_stricmp( pk3Sounds + i*65, ExSounds + j*65 ) ){
                                *( pk3Sounds + i*65 ) = '\0';
                                break;
                        }
                }
                if ( *( pk3Sounds + i*65 ) == '\0' ) continue;
                for ( j = 0; j < rExSoundsN; j++ ){
-                       if ( !stricmp( pk3Sounds + i*65, rExSounds + j*65 ) ){
+                       if ( !Q_stricmp( pk3Sounds + i*65, rExSounds + j*65 ) ){
                                *( pk3Sounds + i*65 ) = '\0';
                                break;
                        }
@@ -3443,246 +2067,6 @@ skipEXrefile:
 
 
 
-/*
-   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...
@@ -3691,6 +2075,7 @@ int ConvertBSPMain( int argc, char **argv ){
 int main( int argc, char **argv ){
        int i, r;
        double start, end;
+       extern qboolean werror;
 
 
        /* we want consistent 'randomness' */
@@ -3708,6 +2093,13 @@ int main( int argc, char **argv ){
        /* read general options first */
        for ( i = 1; i < argc; i++ )
        {
+               /* -help */
+               if ( !strcmp( argv[ i ], "-h" ) || !strcmp( argv[ i ], "--help" )
+                       || !strcmp( argv[ i ], "-help" ) ) {
+                       HelpMain(argv[i+1]);
+                       return 0;
+               }
+
                /* -connect */
                if ( !strcmp( argv[ i ], "-connect" ) ) {
                        argv[ i ] = NULL;
@@ -3730,6 +2122,12 @@ int main( int argc, char **argv ){
                        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;
@@ -3802,17 +2200,17 @@ int main( int argc, char **argv ){
 
        /* 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 */
@@ -3827,11 +2225,16 @@ int main( int argc, char **argv ){
 
        /* 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 );
        }
 
+       /* QBall: export entities */
+       else if ( !strcmp( argv[ 1 ], "-exportents" ) ) {
+               r = ExportEntitiesMain( argc - 1, argv + 1 );
+       }
+
        /* ydnar: lightmap export */
        else if ( !strcmp( argv[ 1 ], "-export" ) ) {
                r = ExportLightmapsMain( argc - 1, argv + 1 );
index 9c219d5cf488a6c7b222efcf47157e190a4d9e68..7fb21bbf79be8f1c6446d8b97b075978260e1f4f 100644 (file)
@@ -1506,13 +1506,13 @@ void LoadEntityIndexMap( entity_t *e ){
                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;
        }
@@ -1523,7 +1523,7 @@ void LoadEntityIndexMap( entity_t *e ){
                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;
        }
@@ -1582,7 +1582,7 @@ void LoadEntityIndexMap( entity_t *e ){
 
        /* 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;
@@ -1663,7 +1663,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
 
        /* 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;
@@ -1687,7 +1687,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
        {
                /* 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;
                }
@@ -1709,7 +1709,7 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
                        }
                        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 ) {
@@ -1982,7 +1982,7 @@ void LoadMapFile( char *filename, qboolean onlyLights, qboolean noCollapseGroups
                /* 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 */
diff --git a/tools/quake3/q3map2/minimap.c b/tools/quake3/q3map2/minimap.c
new file mode 100644 (file)
index 0000000..204e396
--- /dev/null
@@ -0,0 +1,778 @@
+/* -------------------------------------------------------------------------------
+
+   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;
+}
index c7f0a6b83251f62dc93d499025d653798dd44ea4..6bbbe5c532c1b1b3d11b8413bd8ae648f6e502e1 100644 (file)
@@ -58,11 +58,11 @@ void PicoPrintFunc( int level, const char *str ){
                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:
@@ -1392,7 +1392,6 @@ void AddTriangleModels( entity_t *e ){
                }
        }
 
-
        /* walk the entity list */
        for ( num = 1; num < numEntities; num++ )
        {
@@ -1413,7 +1412,7 @@ void AddTriangleModels( entity_t *e ){
                /* 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;
                }
@@ -1490,7 +1489,7 @@ void AddTriangleModels( entity_t *e ){
                                /* 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;
index 8f1b179a4c56cf71da06e7cae6dcd1be9f5a23b0..f8d978040ed5d6c22627ceb365dd31b81f2fc165 100644 (file)
@@ -41,6 +41,7 @@
 /* path support */
 #define MAX_BASE_PATHS  10
 #define MAX_GAME_PATHS  10
+#define MAX_PAK_PATHS  200
 
 char                    *homePath;
 char installPath[ MAX_OS_PATH ];
@@ -49,6 +50,8 @@ int numBasePaths;
 char                    *basePaths[ MAX_BASE_PATHS ];
 int numGamePaths;
 char                    *gamePaths[ MAX_GAME_PATHS ];
+int numPakPaths;
+char                    *pakPaths[ MAX_PAK_PATHS ];
 char                    *homeBasePath = NULL;
 
 
@@ -98,7 +101,7 @@ char *LokiGetHomeDir( void ){
  */
 
 void LokiInitPaths( char *argv0 ){
-       char        *home;
+       char *home;
 
        if ( !homePath ) {
                /* get home dir */
@@ -118,10 +121,10 @@ void LokiInitPaths( char *argv0 ){
        /* this is kinda crap, but hey */
        strcpy( installPath, "../" );
        #else
+
        char temp[ MAX_OS_PATH ];
-       char last0[ 2 ];
-       char        *path;
-       char        *last;
+       char *path;
+       char *last;
        qboolean found;
 
 
@@ -133,6 +136,25 @@ void LokiInitPaths( char *argv0 ){
                argv0 = strrchr( argv0, '/' ) + 1;
        }
        else if ( path ) {
+
+               /*
+                  This code has a special behavior when q3map2 is a symbolic link.
+
+                  For each dir in ${PATH} (example: "/usr/bin", "/usr/local/bin" if ${PATH} == "/usr/bin:/usr/local/bin"),
+                  it looks for "${dir}/q3map2" (file exists and is executable),
+                  then it uses "dirname(realpath("${dir}/q3map2"))/../" as installPath.
+
+                  So, if "/usr/bin/q3map2" is a symbolic link to "/opt/radiant/tools/q3map2",
+                  it will find the installPath "/usr/share/radiant/",
+                  so q3map2 will look for "/opt/radiant/baseq3" to find paks.
+
+                  More precisely, it looks for "${dir}/${argv[0]}",
+                  so if "/usr/bin/q3map2" is a symbolic link to "/opt/radiant/tools/q3map2",
+                  and if "/opt/radiant/tools/q3ma2" is a symbolic link to "/opt/radiant/tools/q3map2.x86_64",
+                  it will use "dirname("/opt/radiant/tools/q3map2.x86_64")/../" as path,
+                  so it will use "/opt/radiant/" as installPath, which will be expanded later to "/opt/radiant/baseq3" to find paks.
+               */
+
                found = qfalse;
                last = path;
 
@@ -156,15 +178,17 @@ void LokiInitPaths( char *argv0 ){
 
                        /* concatenate */
                        if ( last > ( path + 1 ) ) {
-                               Q_strncat( temp, sizeof( temp ), path, ( last - path ) );
+                               // +1 hack: Q_strncat calls Q_strncpyz that expects a len including '\0'
+                               // so that extraneous char will be rewritten by '\0', so it's ok.
+                               // Also, in this case this extraneous char is always ':' or '\0', so it's ok.
+                               Q_strncat( temp, sizeof( temp ), path, ( last - path + 1) );
                                Q_strcat( temp, sizeof( temp ), "/" );
                        }
-                       Q_strcat( temp, sizeof( temp ), "./" );
                        Q_strcat( temp, sizeof( temp ), argv0 );
 
                        /* verify the path */
                        if ( access( temp, X_OK ) == 0 ) {
-                               found++;
+                               found = qtrue;
                        }
                        path = last + 1;
                }
@@ -172,9 +196,12 @@ void LokiInitPaths( char *argv0 ){
 
        /* flake */
        if ( realpath( temp, installPath ) ) {
-               /* q3map is in "tools/" */
+               /*
+                  if "q3map2" is "/opt/radiant/tools/q3map2",
+                  installPath is "/opt/radiant"
+               */
+               *( strrchr( installPath, '/' ) ) = '\0';
                *( strrchr( installPath, '/' ) ) = '\0';
-               *( strrchr( installPath, '/' ) + 1 ) = '\0';
        }
        #endif
 }
@@ -351,6 +378,24 @@ void AddGamePath( char *path ){
 }
 
 
+/*
+   AddPakPath()
+   adds a pak path to the list
+ */
+
+void AddPakPath( char *path ){
+       /* dummy check */
+       if ( path == NULL || path[ 0 ] == '\0' || numPakPaths >= MAX_PAK_PATHS ) {
+               return;
+       }
+
+       /* add it to the list */
+       pakPaths[ numPakPaths ] = safe_malloc( strlen( path ) + 1 );
+       strcpy( pakPaths[ numPakPaths ], path );
+       CleanPath( pakPaths[ numPakPaths ] );
+       numPakPaths++;
+}
+
 
 
 /*
@@ -363,6 +408,9 @@ void InitPaths( int *argc, char **argv ){
        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" );
@@ -412,6 +460,20 @@ void InitPaths( int *argc, char **argv ){
                        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 ) {
@@ -442,6 +504,12 @@ void InitPaths( int *argc, char **argv ){
                        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 ) {
@@ -462,6 +530,16 @@ void InitPaths( int *argc, char **argv ){
                        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 */
@@ -478,8 +556,8 @@ void InitPaths( int *argc, char **argv ){
        /* 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++ )
@@ -517,12 +595,18 @@ void InitPaths( int *argc, char **argv ){
                }
        }
 
-       /* 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 */
@@ -545,6 +629,18 @@ void InitPaths( int *argc, char **argv ){
                }
        }
 
+       /* initialize vfs paths */
+       if ( numPakPaths > MAX_PAK_PATHS ) {
+               numPakPaths = MAX_PAK_PATHS;
+       }
+
+       /* walk the list of pak paths */
+       for ( i = 0; i < numPakPaths; i++ )
+       {
+               /* initialize this pak path */
+               vfsInitDirectory( pakPaths[ i ] );
+       }
+
        /* done */
        Sys_Printf( "\n" );
 }
index aee1446ea5a4fb237299f4ac1c11c644ae1438c9..676fa31599df4754276c9580b5e532edd709912c 100644 (file)
@@ -409,8 +409,9 @@ void SplitNodePortals( node_t *node ){
 //
 // 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 ) {
@@ -519,7 +520,7 @@ void MakeTreePortals_r( node_t *node ){
 
        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],
@@ -664,7 +665,7 @@ qboolean PlaceOccupant( node_t *headnode, vec3_t origin, entity_t *occupant, qbo
 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;
@@ -684,10 +685,10 @@ int FloodEntities( tree_t *tree ){
                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;
                }
 
@@ -811,7 +812,7 @@ void FloodAreas_r( node_t *node ){
 
                // 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 ) {
@@ -898,7 +899,7 @@ void CheckAreas_r( node_t *node ){
 
        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 ) {
@@ -906,7 +907,7 @@ void CheckAreas_r( node_t *node ){
 
                // 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 );
                }
        }
 }
index 514d255f7b556ba2ce35597a04a1feb874f35f38..2cd7015c35acb47090c90e996b8121cfcfdb9a25 100644 (file)
@@ -371,17 +371,15 @@ void NumberClusters( tree_t *tree ) {
    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 );
index fbc2b5e52d8100e4013cfb93cc066434c691c082..ff97ba02eb6a6d59cbdc8f9b6d1ab5d6edb003ed 100644 (file)
@@ -32,7 +32,7 @@
 #ifndef Q3MAP2_H
 #define Q3MAP2_H
 
-
+#include "globaldefs.h"
 
 /* version */
 #ifndef Q3MAP_VERSION
@@ -50,7 +50,7 @@
    ------------------------------------------------------------------------------- */
 
 /* platform-specific */
-#if defined( __linux__ ) || defined( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
        #define Q_UNIX
 #endif
 
@@ -60,7 +60,7 @@
        #include <limits.h>
 #endif
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        #include <windows.h>
 #endif
 
@@ -72,6 +72,9 @@
 #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
 
@@ -959,8 +962,9 @@ typedef struct parseMesh_s
        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;
@@ -1516,33 +1520,51 @@ vec_t                       Random( void );
 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);
 
 /* path_init.c */
 game_t                      *GetGame( 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 );
@@ -1616,12 +1638,12 @@ void                        MakeTreePortals( tree_t *tree );
 
 
 /* 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 */
@@ -1631,7 +1653,7 @@ void                        SetLightStyles( void );
 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 );
 
@@ -1743,8 +1765,8 @@ int                         GetSurfaceExtraMinSampleSize( int num );
 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 */
@@ -1815,7 +1837,7 @@ void                        FloodLightRawLightmap( int num );
 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 );
@@ -1838,7 +1860,12 @@ int                         ImportLightmapsMain( int argc, char **argv );
 
 void                        SetupSurfaceLightmaps( void );
 void                        StitchSurfaceLightmaps( void );
-void                        StoreSurfaceLightmaps( void );
+void                        StoreSurfaceLightmaps( qboolean fastAllocate );
+
+
+/* exportents.c */
+void                        ExportEntities( void );
+int                         ExportEntitiesMain( int argc, char **argv );
 
 
 /* image.c */
@@ -1899,7 +1926,7 @@ qboolean                    KeyExists( const entity_t *ent, const char *key ); /
 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 );
@@ -1942,19 +1969,21 @@ Q_EXTERN game_t games[]
        {
                                                                #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" /* 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"
        ,
@@ -1962,9 +1991,9 @@ Q_EXTERN game_t games[]
        ,
                                                                #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 */
        ,
@@ -2007,7 +2036,7 @@ Q_EXTERN float jitters[ MAX_JITTERS ];
 Q_EXTERN qboolean doingBSP Q_ASSIGN( qfalse );
 
 /* commandline arguments */
-Q_EXTERN qboolean                      nocmdline Q_ASSIGN( qfalse );
+Q_EXTERN qboolean nocmdline Q_ASSIGN( qfalse );
 Q_EXTERN qboolean verbose;
 Q_EXTERN qboolean verboseEntities Q_ASSIGN( qfalse );
 Q_EXTERN qboolean force Q_ASSIGN( qfalse );
@@ -2232,7 +2261,7 @@ Q_EXTERN qboolean keepLights Q_ASSIGN( qfalse );
 
 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 );
 
index c771d89b5702cff75db2fb035f809e8bb6d1b063..10b2b414fcf70181aaec69e0e10a3ead9ad1ddd8 100644 (file)
@@ -383,7 +383,7 @@ void WriteMapShaderFile( void ){
        /* 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;
        }
 
@@ -776,7 +776,7 @@ static void LoadShaderImages( shaderInfo_t *si ){
                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 );
                        }
                }
 
@@ -844,7 +844,7 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName ){
 
        /* 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";
        }
 
@@ -866,7 +866,7 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName ){
                                /* 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;
@@ -1092,7 +1092,7 @@ static void ParseShaderFile( const char *filename ){
                        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 );
                                }
                        }
 
@@ -1573,7 +1573,7 @@ static void ParseShaderFile( const char *filename ){
                                        }
                                        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 );
                                        }
                                }
@@ -1588,7 +1588,7 @@ static void ParseShaderFile( const char *filename ){
                                        /* 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;
@@ -1733,7 +1733,7 @@ static void ParseShaderFile( const char *filename ){
                                        }
                                        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 ] );
                                        }
@@ -1835,7 +1835,7 @@ static void ParseShaderFile( const char *filename ){
 
                                        /* unknown */
                                        else{
-                                               Sys_Printf( "WARNING: Unknown colorMod method: %s\n", token );
+                                               Sys_FPrintf( SYS_WRN, "WARNING: Unknown colorMod method: %s\n", token );
                                        }
                                }
 
@@ -1873,7 +1873,7 @@ static void ParseShaderFile( const char *filename ){
                                                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 );
                                        }
                                }
 
@@ -1963,7 +1963,7 @@ static void ParseShaderFile( const char *filename ){
                                        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 );
                                        }
                                }
 
@@ -1986,7 +1986,7 @@ static void ParseShaderFile( const char *filename ){
                                {
                                        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
@@ -2043,13 +2043,13 @@ static void ParseCustomInfoParms( void ){
                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;
        }
 
@@ -2069,13 +2069,13 @@ static void ParseCustomInfoParms( void ){
                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" );
        }
 }
 
index 65a651c425b471e8ab8dc063479a2a8bba249140..96f7270c8d4b37067a3dce8f9d3fb93c04e8b80f 100644 (file)
@@ -569,7 +569,7 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){
                                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;
@@ -590,7 +590,7 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){
                        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 );
                }
 
                /* -----------------------------------------------------------------
@@ -781,6 +781,10 @@ byte GetShaderIndexForPoint( indexMap_t *im, vec3_t eMins, vec3_t eMaxs, vec3_t
 }
 
 
+#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
@@ -827,10 +831,10 @@ shaderInfo_t *GetIndexedShader( shaderInfo_t *parent, indexMap_t *im, int numPoi
 
        /* 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 */
@@ -926,17 +930,17 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin
        /* 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 );
        }
 
@@ -1164,7 +1168,7 @@ mapDrawSurface_t *DrawSurfaceForMesh( entity_t *e, parseMesh_t *p, mesh_t *mesh
 
        /* spew forth errors */
        if ( VectorLength( plane ) < 0.001f ) {
-               Sys_Printf( "BOGUS " );
+               Sys_Printf( "DrawSurfaceForMesh: bogus plane\n" );
        }
 
        /* test each vert */
@@ -2051,6 +2055,8 @@ int FilterPointIntoTree_r( vec3_t point, mapDrawSurface_t *ds, node_t *node ){
        return AddReferenceToLeaf( ds, node );
 }
 
+
+
 /*
    FilterPointConvexHullIntoTree_r() - ydnar
    filters the convex hull of multiple points from a surface into the tree
@@ -2101,6 +2107,7 @@ int FilterPointConvexHullIntoTree_r( vec3_t **points, int npoints, mapDrawSurfac
 }
 
 
+
 /*
    FilterWindingIntoTree_r() - ydnar
    filters a winding from a drawsurface into the tree
@@ -2124,7 +2131,7 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){
                   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;
                }
 
@@ -2184,6 +2191,7 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){
                                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 */
@@ -2518,7 +2526,7 @@ void EmitDrawIndexes( mapDrawSurface_t *ds, bspDrawSurface_t *out ){
                        /* 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 ],
@@ -2589,6 +2597,8 @@ void EmitFlareSurface( mapDrawSurface_t *ds ){
        numSurfacesByType[ ds->type ]++;
 }
 
+
+
 /*
    EmitPatchSurface()
    emits a bsp patch drawsurface
@@ -2696,6 +2706,8 @@ void EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds ){
        numSurfacesByType[ ds->type ]++;
 }
 
+
+
 /*
    OptimizeTriangleSurface() - ydnar
    optimizes the vertex/index data in a triangle surface
@@ -2966,6 +2978,7 @@ static void EmitFaceSurface( mapDrawSurface_t *ds ){
 }
 
 
+
 /*
    MakeDebugPortalSurfs_r() - ydnar
    generates drawsurfaces for passable portals in the bsp
@@ -3753,7 +3766,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){
                                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 );
                                }
index 291cce263075356d3732b737ce39f5d782363d3d..93ee30ecfda37e93651f98fb651a11ffc9dd33bd 100644 (file)
@@ -211,15 +211,14 @@ void GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis ){
    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;
        }
 
@@ -227,13 +226,10 @@ void WriteSurfaceExtraFile( const char *path ){
        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 */
@@ -321,31 +317,27 @@ void WriteSurfaceExtraFile( const char *path ){
    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 )
@@ -365,7 +357,7 @@ void LoadSurfaceExtraFile( const char *path ){
                {
                        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();
@@ -374,7 +366,7 @@ void LoadSurfaceExtraFile( const char *path ){
 
                /* 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 )
                {
index 453b7531af5b277ea740c657cf9e15aae6dfb766..e189d0648af3f618ceb2818f47bf6d408aeeac1e 100644 (file)
@@ -341,6 +341,7 @@ void TriangulatePatchSurface( entity_t *e, mapDrawSurface_t *ds ){
        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;
@@ -419,6 +420,8 @@ void TriangulatePatchSurface( entity_t *e, mapDrawSurface_t *ds ){
        ClassifySurfaces( 1, ds );
 }
 
+
+
 #define TINY_AREA 1.0f
 #define MAXAREA_MAXTRIES 8
 int MaxAreaIndexes( bspDrawVert_t *vert, int cnt, int *indexes ){
@@ -589,6 +592,8 @@ int MaxAreaIndexes( bspDrawVert_t *vert, int cnt, int *indexes ){
        return -1;
 }
 
+
+
 /*
    MaxAreaFaceSurface() - divVerent
    creates a triangle list using max area indexes
@@ -631,6 +636,7 @@ void MaxAreaFaceSurface( mapDrawSurface_t *ds ){
 }
 
 
+
 /*
    FanFaceSurface() - ydnar
    creates a tri-fan from a brush face winding
@@ -835,6 +841,7 @@ void StripFaceSurface( mapDrawSurface_t *ds ){
 }
 
 
+
 /*
    EmitMetaStatictics
    vortex: prints meta statistics in general output
@@ -851,6 +858,8 @@ void EmitMetaStats(){
        Sys_Printf( "%9d meta triangles\n", numMetaTriangles );
 }
 
+
+
 /*
    MakeEntityMetaTriangles()
    builds meta triangles from brush faces (tristrips and fans)
@@ -1469,8 +1478,6 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri,
                }
        }
 
-
-
        if ( metaMaxBBoxDistance >= 0 ) {
                if ( ds->numIndexes > 0 ) {
                        VectorCopy( ds->mins, mins );
@@ -1595,7 +1602,7 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri,
                         ( 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 ] );
@@ -1705,8 +1712,8 @@ static void MetaTrianglesToSurface( int numPossibles, metaTriangle_t *possibles,
                ClearBounds( ds->mins, ds->maxs );
 
                /* clear verts/indexes */
-               memset( verts, 0, sizeof( verts ) );
-               memset( indexes, 0, sizeof( indexes ) );
+               memset( verts, 0, sizeof( *verts ) * maxSurfaceVerts );
+               memset( indexes, 0, sizeof( *indexes ) * maxSurfaceIndexes );
 
                /* add the first triangle */
                if ( AddMetaTriangleToSurface( ds, seed, qfalse ) ) {
index c405d3170b5de1d0001b3d913039d3703b164780..1929e3e8b229ee3c09b5104517578374b7b5665b 100644 (file)
@@ -55,7 +55,8 @@ typedef struct edgeLine_s {
        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 {
@@ -67,8 +68,7 @@ originalEdge_t  *originalEdges = NULL;
 int numOriginalEdges;
 int allocatedOriginalEdges = 0;
 
-
-edgeLine_t      *edgeLines = NULL;
+edgeLine_t *edgeLines = NULL;
 int numEdgeLines;
 int allocatedEdgeLines = 0;
 
@@ -373,7 +373,7 @@ void FixSurfaceJunctions( mapDrawSurface_t *ds ) {
                        p = e->chain->prev;
                }
 
-               for (  ; p != e->chain ; ) {
+               for ( ; p != e->chain ; ) {
                        if ( start < end ) {
                                if ( p->intercept > end - ON_EPSILON ) {
                                        break;
index fd3df83e26197e6ac4d5873babb377991859eaf3..df398c3ec5d4fd5b02967d4f62946bffa0b7eeae 100644 (file)
@@ -163,7 +163,9 @@ int LeafVectorFromPortalVector( byte *portalbits, byte *leafbits ){
    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];
@@ -204,13 +206,13 @@ void ClusterMerge( int leafnum ){
        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 );
@@ -821,16 +823,16 @@ int CountActivePortals( void ){
  */
 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;
@@ -1108,8 +1110,9 @@ void LoadPortals( char *name ){
    ===========
  */
 int VisMain( int argc, char **argv ){
-       char portalfile[1024];
        int i;
+       char portalFilePath[ 1024 ];
+       portalFilePath[0] = 0;
 
 
        /* note it */
@@ -1157,22 +1160,26 @@ int VisMain( int argc, char **argv ){
                        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" );
        }
 
 
@@ -1184,11 +1191,13 @@ int VisMain( int argc, char **argv ){
        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 ) {
@@ -1220,7 +1229,7 @@ int VisMain( int argc, char **argv ){
 
        /* delete the prt file */
        if ( !saveprt ) {
-               remove( portalfile );
+               remove( portalFilePath );
        }
 
        /* write the bsp file */
index 6b4ea592020e0f3d3934a4a469b2e8d9357df8bf..c3262a04fb2129994f944f3209126923edec0fdf 100644 (file)
@@ -75,8 +75,6 @@ int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags ){
                }
        }
 
-       // i == numBSPShaders
-
        /* get shaderinfo */
        si = ShaderInfoForShader( shader );
 
@@ -169,7 +167,7 @@ void EmitLeaf( node_t *node ){
        {
                /* 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 )
@@ -407,9 +405,7 @@ void BeginBSPFile( void ){
    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" );
 
@@ -420,12 +416,11 @@ void EndBSPFile( qboolean do_write ){
 
        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 );
        }
 }