Initial commit
This commit is contained in:
commit
600a90924e
832 changed files with 233873 additions and 0 deletions
275
CMakeLists.txt
Normal file
275
CMakeLists.txt
Normal file
|
@ -0,0 +1,275 @@
|
|||
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
project(WorldSpawn C CXX)
|
||||
|
||||
option(BUILD_RADIANT "Build the GUI" ON)
|
||||
|
||||
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(WorldSpawn_VERSION_MAJOR 1)
|
||||
set(WorldSpawn_VERSION_MINOR 0)
|
||||
set(WorldSpawn_VERSION_PATCH 0)
|
||||
set(WorldSpawn_VERSION "${WorldSpawn_VERSION_MAJOR}.${WorldSpawn_VERSION_MINOR}.${WorldSpawn_VERSION_PATCH}")
|
||||
|
||||
SET(CMAKE_C_COMPILER gcc-9)
|
||||
SET(CMAKE_CXX_COMPILER g++-9)
|
||||
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/WorldSpawn_MAJOR" ${WorldSpawn_VERSION_MAJOR})
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/WorldSpawn_MINOR" ${WorldSpawn_VERSION_MINOR})
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/WorldSpawn_PATCH" ${WorldSpawn_VERSION_PATCH})
|
||||
|
||||
#set(WorldSpawn_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(WorldSpawn_VERSION_STRING "${WorldSpawn_VERSION}n")
|
||||
if (GIT_VERSION)
|
||||
set(WorldSpawn_VERSION_STRING "${WorldSpawn_VERSION_STRING}-git-${GIT_VERSION}")
|
||||
endif ()
|
||||
|
||||
message(STATUS "Building ${PROJECT_NAME} ${WorldSpawn_VERSION_STRING} ${WorldSpawn_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 ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
#disabled due to GTK bug 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(-DWorldSpawn_VERSION="${WorldSpawn_VERSION}")
|
||||
add_definitions(-DWorldSpawn_MAJOR_VERSION="${WorldSpawn_VERSION_MAJOR}")
|
||||
add_definitions(-DWorldSpawn_MINOR_VERSION="${WorldSpawn_VERSION_MINOR}")
|
||||
add_definitions(-DWorldSpawn_PATCH_VERSION="${WorldSpawn_VERSION_PATCH}")
|
||||
|
||||
add_definitions(-DWorldSpawn_ABOUTMSG="${WorldSpawn_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 "^[.]" "" WorldSpawn_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
|
||||
else ()
|
||||
execute_process(
|
||||
COMMAND uname -m
|
||||
OUTPUT_VARIABLE WorldSpawn_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 ".${WorldSpawn_EXECUTABLE}"))
|
||||
add_custom_command(TARGET ${name} POST_BUILD
|
||||
COMMAND ln -f -s "$<TARGET_FILE_NAME:${name}>" "${PROJECT_BINARY_DIR}/${name}.${WorldSpawn_EXECUTABLE}"
|
||||
VERBATIM
|
||||
)
|
||||
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
${name}${CMAKE_EXECUTABLE_SUFFIX} ${CMAKE_INSTALL_PREFIX}/${name}.${WorldSpawn_EXECUTABLE})
|
||||
")
|
||||
endif ()
|
||||
endmacro()
|
||||
|
||||
if (BUILD_RADIANT)
|
||||
add_subdirectory(radiant _radiant)
|
||||
set_target_properties(worldspawn PROPERTIES
|
||||
COMPILE_DEFINITIONS WorldSpawn_EXECUTABLE="${WorldSpawn_EXECUTABLE}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Tools
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
add_subdirectory(tools)
|
||||
|
||||
file(GLOB DATA_FILES "${PROJECT_SOURCE_DIR}/resources/*")
|
||||
|
||||
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 ()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Install
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
install(
|
||||
FILES
|
||||
"${PROJECT_BINARY_DIR}/WorldSpawn_MAJOR"
|
||||
"${PROJECT_BINARY_DIR}/WorldSpawn_MINOR"
|
||||
"${PROJECT_BINARY_DIR}/WorldSpawn_PATCH"
|
||||
DESTINATION .
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY
|
||||
resources/
|
||||
DESTINATION .
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY
|
||||
DESTINATION .
|
||||
OPTIONAL
|
||||
)
|
||||
|
||||
include(cmake/scripts/package.cmake)
|
340
LICENSE-GPL
Normal file
340
LICENSE-GPL
Normal file
|
@ -0,0 +1,340 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
36
LICENSE-LGPL
Normal file
36
LICENSE-LGPL
Normal file
|
@ -0,0 +1,36 @@
|
|||
LICENSE ( last update: Wed Feb 8 17:16:40 CST 2006 )
|
||||
-----------------------------------------------------
|
||||
|
||||
There are 3 license types used throughout GtkRadiant source code.
|
||||
|
||||
BSD - modified Berkeley Software Distribution license
|
||||
( each BSD licensed source file starts with the appropriate header )
|
||||
LGPL - GNU Lesser General Public License v2.1
|
||||
( see LGPL at the root of the tree )
|
||||
GPL - GNU General Public License
|
||||
( see GPL at the root of the tree )
|
||||
|
||||
How do I check which license applies to a given part of the source code?
|
||||
|
||||
Each source file in the tree comes with a license header which explains what
|
||||
license applies. To sum up shortly:
|
||||
|
||||
GPL: ( except some files contributed by Loki Software under BSD license )
|
||||
GtkRadiant Core
|
||||
GtkRadiant Modules
|
||||
GtkRadiant Libraries
|
||||
Quake III Tools
|
||||
Quake II Tools
|
||||
Background2D Plugin
|
||||
HydraToolz Plugin
|
||||
|
||||
BSD:
|
||||
JPEG Library
|
||||
MD5 Library
|
||||
DDS Library
|
||||
PicoModel Library
|
||||
PrtView Plugin
|
||||
|
||||
LGPL
|
||||
BobToolz Plugin
|
||||
GenSurf Plugin
|
2
build_binarydist.sh
Executable file
2
build_binarydist.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
zip worldspawn_bin.zip -@ < build_contents.txt
|
150
build_contents.txt
Normal file
150
build_contents.txt
Normal file
|
@ -0,0 +1,150 @@
|
|||
WorldSpawn.app
|
||||
WorldSpawn.app/base
|
||||
WorldSpawn.app/base/textures
|
||||
WorldSpawn.app/base/textures/radiant
|
||||
WorldSpawn.app/base/textures/radiant/notex.png
|
||||
WorldSpawn.app/base/textures/radiant/shadernotex.png
|
||||
WorldSpawn.app/bitmaps
|
||||
WorldSpawn.app/bitmaps/black.png
|
||||
WorldSpawn.app/bitmaps/brush_flipx.png
|
||||
WorldSpawn.app/bitmaps/brush_flipy.png
|
||||
WorldSpawn.app/bitmaps/brush_flipz.png
|
||||
WorldSpawn.app/bitmaps/brush_rotatex.png
|
||||
WorldSpawn.app/bitmaps/brush_rotatey.png
|
||||
WorldSpawn.app/bitmaps/brush_rotatez.png
|
||||
WorldSpawn.app/bitmaps/cap_bevel.png
|
||||
WorldSpawn.app/bitmaps/cap_curve.png
|
||||
WorldSpawn.app/bitmaps/cap_cylinder.png
|
||||
WorldSpawn.app/bitmaps/cap_endcap.png
|
||||
WorldSpawn.app/bitmaps/cap_ibevel.png
|
||||
WorldSpawn.app/bitmaps/cap_iendcap.png
|
||||
WorldSpawn.app/bitmaps/console.png
|
||||
WorldSpawn.app/bitmaps/dontselectcurve.png
|
||||
WorldSpawn.app/bitmaps/dontselectmodel.png
|
||||
WorldSpawn.app/bitmaps/ellipsis.png
|
||||
WorldSpawn.app/bitmaps/entities.png
|
||||
WorldSpawn.app/bitmaps/file_open.png
|
||||
WorldSpawn.app/bitmaps/file_save.png
|
||||
WorldSpawn.app/bitmaps/icon.png
|
||||
WorldSpawn.app/bitmaps/lightinspector.png
|
||||
WorldSpawn.app/bitmaps/logo.png
|
||||
WorldSpawn.app/bitmaps/modify_edges.png
|
||||
WorldSpawn.app/bitmaps/modify_faces.png
|
||||
WorldSpawn.app/bitmaps/modify_vertices.png
|
||||
WorldSpawn.app/bitmaps/noFalloff.png
|
||||
WorldSpawn.app/bitmaps/notex.png
|
||||
WorldSpawn.app/bitmaps/patch_bend.png
|
||||
WorldSpawn.app/bitmaps/patch_drilldown.png
|
||||
WorldSpawn.app/bitmaps/patch_insdel.png
|
||||
WorldSpawn.app/bitmaps/patch_showboundingbox.png
|
||||
WorldSpawn.app/bitmaps/patch_weld.png
|
||||
WorldSpawn.app/bitmaps/patch_wireframe.png
|
||||
WorldSpawn.app/bitmaps/popup_selection.png
|
||||
WorldSpawn.app/bitmaps/redo.png
|
||||
WorldSpawn.app/bitmaps/refresh_models.png
|
||||
WorldSpawn.app/bitmaps/scalelockx.png
|
||||
WorldSpawn.app/bitmaps/scalelocky.png
|
||||
WorldSpawn.app/bitmaps/scalelockz.png
|
||||
WorldSpawn.app/bitmaps/selection_csgmerge.png
|
||||
WorldSpawn.app/bitmaps/selection_csgsubtract.png
|
||||
WorldSpawn.app/bitmaps/selection_makehollow.png
|
||||
WorldSpawn.app/bitmaps/selection_makeroom.png
|
||||
WorldSpawn.app/bitmaps/selection_selectcompletetall.png
|
||||
WorldSpawn.app/bitmaps/selection_selectinside.png
|
||||
WorldSpawn.app/bitmaps/selection_selectpartialtall.png
|
||||
WorldSpawn.app/bitmaps/selection_selecttouching.png
|
||||
WorldSpawn.app/bitmaps/select_mouseresize.png
|
||||
WorldSpawn.app/bitmaps/select_mouserotate.png
|
||||
WorldSpawn.app/bitmaps/select_mousescale.png
|
||||
WorldSpawn.app/bitmaps/select_mousetranslate.png
|
||||
WorldSpawn.app/bitmaps/shadernotex.png
|
||||
WorldSpawn.app/bitmaps/show_entities.png
|
||||
WorldSpawn.app/bitmaps/splash.png
|
||||
WorldSpawn.app/bitmaps/texture_browser.png
|
||||
WorldSpawn.app/bitmaps/texture_lock.png
|
||||
WorldSpawn.app/bitmaps/textures_popup.png
|
||||
WorldSpawn.app/bitmaps/undo.png
|
||||
WorldSpawn.app/bitmaps/view_cameratoggle.png
|
||||
WorldSpawn.app/bitmaps/view_cameraupdate.png
|
||||
WorldSpawn.app/bitmaps/view_change.png
|
||||
WorldSpawn.app/bitmaps/view_clipper.png
|
||||
WorldSpawn.app/bitmaps/view_cubicclipping.png
|
||||
WorldSpawn.app/bitmaps/view_entity.png
|
||||
WorldSpawn.app/bitmaps/white.png
|
||||
WorldSpawn.app/bitmaps/window1.png
|
||||
WorldSpawn.app/bitmaps/window2.png
|
||||
WorldSpawn.app/bitmaps/window3.png
|
||||
WorldSpawn.app/bitmaps/window4.png
|
||||
WorldSpawn.app/games
|
||||
WorldSpawn.app/games/tw.game
|
||||
WorldSpawn.app/gl
|
||||
WorldSpawn.app/gl/lighting_DBS_omni_fp.glp
|
||||
WorldSpawn.app/gl/lighting_DBS_omni_fp.glsl
|
||||
WorldSpawn.app/gl/lighting_DBS_omni_vp.glp
|
||||
WorldSpawn.app/gl/lighting_DBS_omni_vp.glsl
|
||||
WorldSpawn.app/gl/lighting_DBS_XY_Z_arbfp1.cg
|
||||
WorldSpawn.app/gl/lighting_DBS_XY_Z_arbvp1.cg
|
||||
WorldSpawn.app/gl/utils.cg
|
||||
WorldSpawn.app/gl/zfill_arbfp1.cg
|
||||
WorldSpawn.app/gl/zfill_arbvp1.cg
|
||||
WorldSpawn.app/gl/zfill_fp.glp
|
||||
WorldSpawn.app/gl/zfill_fp.glsl
|
||||
WorldSpawn.app/gl/zfill_vp.glp
|
||||
WorldSpawn.app/gl/zfill_vp.glsl
|
||||
WorldSpawn.app/global.xlink
|
||||
WorldSpawn.app/modules
|
||||
WorldSpawn.app/modules/libarchivezip.so
|
||||
WorldSpawn.app/modules/libentity.so
|
||||
WorldSpawn.app/modules/libimage.so
|
||||
WorldSpawn.app/modules/libiqmmodel.so
|
||||
WorldSpawn.app/modules/libmapq3.so
|
||||
WorldSpawn.app/modules/libmodel.so
|
||||
WorldSpawn.app/modules/libshaders.so
|
||||
WorldSpawn.app/modules/libvfspk3.so
|
||||
WorldSpawn.app/plugins
|
||||
WorldSpawn.app/plugins/bitmaps
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_caulk.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_cleanup.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_dropent.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_merge.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_poly.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_splitcol.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_split.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_splitrow.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_trainpathplot.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_treeplanter.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_turnedge.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_actorclip.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level1.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level2.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level3.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level4.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level5.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level6.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level7.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level8.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_nodraw.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_stepon.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_weaponclip.png
|
||||
WorldSpawn.app/plugins/bt
|
||||
WorldSpawn.app/plugins/bt/bt-el1.txt
|
||||
WorldSpawn.app/plugins/bt/bt-el2.txt
|
||||
WorldSpawn.app/plugins/bt/door-tex-trim.txt
|
||||
WorldSpawn.app/plugins/bt/door-tex.txt
|
||||
WorldSpawn.app/plugins/bt/tp_ent.txt
|
||||
WorldSpawn.app/plugins/libbobtoolz.so
|
||||
WorldSpawn.app/plugins/libbrushexport.so
|
||||
WorldSpawn.app/plugins/libprtview.so
|
||||
WorldSpawn.app/plugins/libshaderplug.so
|
||||
WorldSpawn.app/plugins/libsunplug.so
|
||||
WorldSpawn.app/tw.game
|
||||
WorldSpawn.app/tw.game/default_build_menu.xml
|
||||
WorldSpawn.app/tw.game/game.xlink
|
||||
WorldSpawn.app/tw.game/wastes
|
||||
WorldSpawn.app/tw.game/wastes/entities.def
|
||||
WorldSpawn.app/Resources
|
||||
WorldSpawn.app/Resources/Info-gnustep.plist
|
||||
WorldSpawn.app/Resources/icon.tiff
|
||||
WorldSpawn.app/vmap
|
||||
WorldSpawn.app/worldspawn
|
||||
WorldSpawn.app/WorldSpawn
|
21
cmake/FindGLIB.cmake
Normal file
21
cmake/FindGLIB.cmake
Normal file
|
@ -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)
|
21
cmake/FindGTK2.cmake
Normal file
21
cmake/FindGTK2.cmake
Normal file
|
@ -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)
|
21
cmake/FindGTK3.cmake
Normal file
21
cmake/FindGTK3.cmake
Normal file
|
@ -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)
|
27
cmake/FindGtkGLExt.cmake
Normal file
27
cmake/FindGtkGLExt.cmake
Normal file
|
@ -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)
|
21
cmake/FindMinizip.cmake
Normal file
21
cmake/FindMinizip.cmake
Normal file
|
@ -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)
|
23
cmake/FindPango.cmake
Normal file
23
cmake/FindPango.cmake
Normal file
|
@ -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)
|
16
cmake/scripts/package.cmake
Normal file
16
cmake/scripts/package.cmake
Normal file
|
@ -0,0 +1,16 @@
|
|||
set(CPACK_PACKAGE_NAME "WorldSpawn")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${WorldSpawn_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${WorldSpawn_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${WorldSpawn_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)
|
1
compile_debug.sh
Executable file
1
compile_debug.sh
Executable file
|
@ -0,0 +1 @@
|
|||
cmake -G "Unix Makefiles" -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug && cmake --build build -- -j$(nproc)
|
1
compile_release.sh
Executable file
1
compile_release.sh
Executable file
|
@ -0,0 +1 @@
|
|||
cmake -G "Unix Makefiles" -H. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build -- -j$(nproc)
|
16
contrib/CMakeLists.txt
Normal file
16
contrib/CMakeLists.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
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(brushexport)
|
||||
add_subdirectory(prtview)
|
10
contrib/brushexport/CMakeLists.txt
Normal file
10
contrib/brushexport/CMakeLists.txt
Normal file
|
@ -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)
|
7
contrib/brushexport/brushexport.def
Normal file
7
contrib/brushexport/brushexport.def
Normal file
|
@ -0,0 +1,7 @@
|
|||
; brushexport.def : Declares the module parameters for the DLL.
|
||||
|
||||
LIBRARY "BRUSHEXPORT"
|
||||
|
||||
EXPORTS
|
||||
; Explicit exports can go here
|
||||
Radiant_RegisterModules @1
|
148
contrib/brushexport/callbacks.cpp
Normal file
148
contrib/brushexport/callbacks.cpp
Normal file
|
@ -0,0 +1,148 @@
|
|||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <set>
|
||||
|
||||
#include "qerplugin.h"
|
||||
#include "debugging/debugging.h"
|
||||
#include "support.h"
|
||||
#include "export.h"
|
||||
|
||||
// stuff from interface.cpp
|
||||
void DestroyWindow();
|
||||
|
||||
|
||||
namespace callbacks {
|
||||
|
||||
void OnDestroy(ui::Widget w, gpointer data)
|
||||
{
|
||||
DestroyWindow();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
std::string path(cpath);
|
||||
|
||||
// get ignore list from ui
|
||||
std::set<std::string> ignore;
|
||||
|
||||
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(list, &iter);
|
||||
while (valid) {
|
||||
gchar *data;
|
||||
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(list, &iter);
|
||||
}
|
||||
|
||||
for (std::set<std::string>::iterator it(ignore.begin()); it != ignore.end(); ++it) {
|
||||
globalOutputStream() << it->c_str() << "\n";
|
||||
}
|
||||
|
||||
// collapse mode
|
||||
collapsemode mode = COLLAPSE_NONE;
|
||||
|
||||
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(button, "r_collapsebymaterial");
|
||||
ASSERT_TRUE(radio);
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio))) {
|
||||
mode = COLLAPSE_BY_MATERIAL;
|
||||
} else {
|
||||
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?
|
||||
auto toggle = lookup_widget(button, "t_exportmaterials");
|
||||
ASSERT_TRUE(toggle);
|
||||
|
||||
bool exportmat = FALSE;
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle))) {
|
||||
exportmat = TRUE;
|
||||
}
|
||||
|
||||
// limit material names?
|
||||
toggle = lookup_widget(button, "t_limitmatnames");
|
||||
ASSERT_TRUE(toggle);
|
||||
|
||||
bool limitMatNames = FALSE;
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)) && exportmat) {
|
||||
limitMatNames = TRUE;
|
||||
}
|
||||
|
||||
// create objects instead of groups?
|
||||
toggle = lookup_widget(button, "t_objects");
|
||||
ASSERT_TRUE(toggle);
|
||||
|
||||
bool objects = FALSE;
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)) && exportmat) {
|
||||
objects = TRUE;
|
||||
}
|
||||
|
||||
// export
|
||||
ExportSelection(ignore, mode, exportmat, path, limitMatNames, objects);
|
||||
}
|
||||
|
||||
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) {
|
||||
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(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)) {
|
||||
gtk_list_store_remove(list, &iter);
|
||||
}
|
||||
}
|
||||
|
||||
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(toggleLimit, TRUE);
|
||||
gtk_widget_set_sensitive(toggleObject, TRUE);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(toggleLimit, FALSE);
|
||||
gtk_widget_set_sensitive(toggleObject, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
} // callbacks
|
16
contrib/brushexport/callbacks.h
Normal file
16
contrib/brushexport/callbacks.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
#include <uilib/uilib.h>
|
||||
|
||||
namespace callbacks {
|
||||
|
||||
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
|
365
contrib/brushexport/export.cpp
Normal file
365
contrib/brushexport/export.cpp
Normal file
|
@ -0,0 +1,365 @@
|
|||
#include "export.h"
|
||||
#include "globaldefs.h"
|
||||
#include "debugging/debugging.h"
|
||||
#include "ibrush.h"
|
||||
#include "iscenegraph.h"
|
||||
#include "iselection.h"
|
||||
#include "stream/stringstream.h"
|
||||
#include "stream/textfilestream.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
// this is very evil, but right now there is no better way
|
||||
#include "../../radiant/brush.h"
|
||||
|
||||
// for limNames
|
||||
const int MAX_MATERIAL_NAME = 20;
|
||||
|
||||
/*
|
||||
Abstract baseclass for modelexporters
|
||||
the class collects all the data which then gets
|
||||
exported through the WriteToFile method.
|
||||
*/
|
||||
class ExportData {
|
||||
public:
|
||||
ExportData(const std::set<std::string> &ignorelist, collapsemode mode, bool limNames, bool objs);
|
||||
|
||||
virtual ~ExportData(void);
|
||||
|
||||
virtual void BeginBrush(Brush &b);
|
||||
|
||||
virtual void AddBrushFace(Face &f);
|
||||
|
||||
virtual void EndBrush(void);
|
||||
|
||||
virtual bool WriteToFile(const std::string &path, collapsemode mode) const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
// a group of faces
|
||||
class group {
|
||||
public:
|
||||
std::string name;
|
||||
std::list<const Face *> faces;
|
||||
};
|
||||
|
||||
std::list<group> groups;
|
||||
|
||||
private:
|
||||
|
||||
// "textures/common/caulk" -> "caulk"
|
||||
void GetShaderNameFromShaderPath(const char *path, std::string &name);
|
||||
|
||||
group *current;
|
||||
collapsemode mode;
|
||||
const std::set<std::string> &ignorelist;
|
||||
};
|
||||
|
||||
ExportData::ExportData(const std::set<std::string> &_ignorelist, collapsemode _mode, bool _limNames, bool _objs)
|
||||
: mode(_mode),
|
||||
ignorelist(_ignorelist)
|
||||
{
|
||||
current = 0;
|
||||
|
||||
// in this mode, we need just one group
|
||||
if (mode == COLLAPSE_ALL) {
|
||||
groups.push_back(group());
|
||||
current = &groups.back();
|
||||
current->name = "all";
|
||||
}
|
||||
}
|
||||
|
||||
ExportData::~ExportData(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ExportData::BeginBrush(Brush &b)
|
||||
{
|
||||
// create a new group for each brush
|
||||
if (mode == COLLAPSE_NONE) {
|
||||
groups.push_back(group());
|
||||
current = &groups.back();
|
||||
|
||||
StringOutputStream str(256);
|
||||
str << "Brush" << (const unsigned int) groups.size();
|
||||
current->name = str.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
void ExportData::EndBrush(void)
|
||||
{
|
||||
// all faces of this brush were on the ignorelist, discard the emptygroup
|
||||
if (mode == COLLAPSE_NONE) {
|
||||
ASSERT_NOTNULL(current);
|
||||
if (current->faces.empty()) {
|
||||
groups.pop_back();
|
||||
current = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExportData::AddBrushFace(Face &f)
|
||||
{
|
||||
std::string shadername;
|
||||
GetShaderNameFromShaderPath(f.GetShader(), shadername);
|
||||
|
||||
// ignore faces from ignore list
|
||||
if (ignorelist.find(shadername) != ignorelist.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == COLLAPSE_BY_MATERIAL) {
|
||||
// find a group for this material
|
||||
current = 0;
|
||||
const std::list<group>::iterator end(groups.end());
|
||||
for (std::list<group>::iterator it(groups.begin()); it != end; ++it) {
|
||||
if (it->name == shadername) {
|
||||
current = &(*it);
|
||||
}
|
||||
}
|
||||
|
||||
// no group found, create one
|
||||
if (!current) {
|
||||
groups.push_back(group());
|
||||
current = &groups.back();
|
||||
current->name = shadername;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_NOTNULL(current);
|
||||
|
||||
// add face to current group
|
||||
current->faces.push_back(&f);
|
||||
|
||||
#if GDEF_DEBUG
|
||||
globalOutputStream() << "Added Face to group " << current->name.c_str() << "\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExportData::GetShaderNameFromShaderPath(const char *path, std::string &name)
|
||||
{
|
||||
std::string tmp(path);
|
||||
|
||||
size_t last_slash = tmp.find_last_of("/");
|
||||
|
||||
if (last_slash != std::string::npos && last_slash == (tmp.length() - 1)) {
|
||||
name = path;
|
||||
} else {
|
||||
name = tmp.substr(last_slash + 1, tmp.length() - last_slash);
|
||||
}
|
||||
|
||||
#if GDEF_DEBUG
|
||||
globalOutputStream() << "Last: " << (const unsigned int) last_slash << " " << "length: "
|
||||
<< (const unsigned int) tmp.length() << "Name: " << name.c_str() << "\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Exporter writing facedata as wavefront object
|
||||
*/
|
||||
class ExportDataAsWavefront : public ExportData {
|
||||
private:
|
||||
bool expmat;
|
||||
bool limNames;
|
||||
bool objs;
|
||||
|
||||
public:
|
||||
ExportDataAsWavefront(const std::set<std::string> &_ignorelist, collapsemode _mode, bool _expmat, bool _limNames,
|
||||
bool _objs)
|
||||
: ExportData(_ignorelist, _mode, _limNames, _objs)
|
||||
{
|
||||
expmat = _expmat;
|
||||
limNames = _limNames;
|
||||
objs = _objs;
|
||||
}
|
||||
|
||||
bool WriteToFile(const std::string &path, collapsemode mode) const;
|
||||
};
|
||||
|
||||
bool ExportDataAsWavefront::WriteToFile(const std::string &path, collapsemode mode) const
|
||||
{
|
||||
std::string objFile = path;
|
||||
|
||||
if (path.compare(path.length() - 4, 4, ".obj") != 0) {
|
||||
objFile += ".obj";
|
||||
}
|
||||
|
||||
std::string mtlFile = objFile.substr(0, objFile.length() - 4) + ".mtl";
|
||||
|
||||
std::set<std::string> materials;
|
||||
|
||||
TextFileOutputStream out(objFile.c_str());
|
||||
|
||||
if (out.failed()) {
|
||||
globalErrorStream() << "Unable to open file\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
out
|
||||
<< "# Wavefront Objectfile exported with radiants brushexport plugin 3.0 by Thomas 'namespace' Nitschke, spam@codecreator.net\n\n";
|
||||
|
||||
if (expmat) {
|
||||
size_t last = mtlFile.find_last_of("//");
|
||||
std::string mtllib = mtlFile.substr(last + 1, mtlFile.size() - last).c_str();
|
||||
out << "mtllib " << mtllib.c_str() << "\n";
|
||||
}
|
||||
|
||||
unsigned int vertex_count = 0;
|
||||
|
||||
const std::list<ExportData::group>::const_iterator gend(groups.end());
|
||||
for (std::list<ExportData::group>::const_iterator git(groups.begin()); git != gend; ++git) {
|
||||
typedef std::multimap<std::string, std::string> bm;
|
||||
bm brushMaterials;
|
||||
typedef std::pair<std::string, std::string> String_Pair;
|
||||
|
||||
const std::list<const Face *>::const_iterator end(git->faces.end());
|
||||
|
||||
// submesh starts here
|
||||
if (objs) {
|
||||
out << "\no ";
|
||||
} else {
|
||||
out << "\ng ";
|
||||
}
|
||||
out << git->name.c_str() << "\n";
|
||||
|
||||
// material
|
||||
if (expmat && mode == COLLAPSE_ALL) {
|
||||
out << "usemtl material" << "\n\n";
|
||||
materials.insert("material");
|
||||
}
|
||||
|
||||
for (std::list<const Face *>::const_iterator it(git->faces.begin()); it != end; ++it) {
|
||||
const Winding &w((*it)->getWinding());
|
||||
|
||||
// vertices
|
||||
for (size_t i = 0; i < w.numpoints; ++i) {
|
||||
out << "v " << FloatFormat(w[i].vertex.x(), 1, 6) << " " << FloatFormat(w[i].vertex.z(), 1, 6) << " "
|
||||
<< FloatFormat(w[i].vertex.y(), 1, 6) << "\n";
|
||||
}
|
||||
}
|
||||
out << "\n";
|
||||
|
||||
for (std::list<const Face *>::const_iterator it(git->faces.begin()); it != end; ++it) {
|
||||
const Winding &w((*it)->getWinding());
|
||||
|
||||
// texcoords
|
||||
for (size_t i = 0; i < w.numpoints; ++i) {
|
||||
out << "vt " << FloatFormat(w[i].texcoord.x(), 1, 6) << " " << FloatFormat(w[i].texcoord.y(), 1, 6)
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
|
||||
for (std::list<const Face *>::const_iterator it(git->faces.begin()); it != end; ++it) {
|
||||
const Winding &w((*it)->getWinding());
|
||||
|
||||
// faces
|
||||
StringOutputStream faceLine(256);
|
||||
faceLine << "\nf";
|
||||
for (size_t i = 0; i < w.numpoints; ++i, ++vertex_count) {
|
||||
faceLine << " " << vertex_count + 1 << "/" << vertex_count + 1;
|
||||
}
|
||||
|
||||
if (mode != COLLAPSE_ALL) {
|
||||
materials.insert((*it)->getShader().getShader());
|
||||
brushMaterials.insert(String_Pair((*it)->getShader().getShader(), faceLine.c_str()));
|
||||
} else {
|
||||
out << faceLine.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
if (mode != COLLAPSE_ALL) {
|
||||
std::string lastMat;
|
||||
std::string mat;
|
||||
std::string faces;
|
||||
|
||||
for (bm::iterator iter = brushMaterials.begin(); iter != brushMaterials.end(); iter++) {
|
||||
mat = (*iter).first.c_str();
|
||||
faces = (*iter).second.c_str();
|
||||
|
||||
if (mat != lastMat) {
|
||||
if (limNames && mat.size() > MAX_MATERIAL_NAME) {
|
||||
out << "\nusemtl " << mat.substr(mat.size() - MAX_MATERIAL_NAME, mat.size()).c_str();
|
||||
} else {
|
||||
out << "\nusemtl " << mat.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
out << faces.c_str();
|
||||
lastMat = mat;
|
||||
}
|
||||
}
|
||||
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
if (expmat) {
|
||||
TextFileOutputStream outMtl(mtlFile.c_str());
|
||||
if (outMtl.failed()) {
|
||||
globalErrorStream() << "Unable to open material file\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
outMtl << "# Wavefront material file exported with NetRadiants brushexport plugin.\n";
|
||||
outMtl << "# Material Count: " << (const Unsigned) materials.size() << "\n\n";
|
||||
for (std::set<std::string>::const_iterator it(materials.begin()); it != materials.end(); ++it) {
|
||||
if (limNames && it->size() > MAX_MATERIAL_NAME) {
|
||||
outMtl << "newmtl " << it->substr(it->size() - MAX_MATERIAL_NAME, it->size()).c_str() << "\n";
|
||||
} else {
|
||||
outMtl << "newmtl " << it->c_str() << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
class ForEachFace : public BrushVisitor {
|
||||
public:
|
||||
ForEachFace(ExportData &_exporter)
|
||||
: exporter(_exporter)
|
||||
{}
|
||||
|
||||
void visit(Face &face) const
|
||||
{
|
||||
exporter.AddBrushFace(face);
|
||||
}
|
||||
|
||||
private:
|
||||
ExportData &exporter;
|
||||
};
|
||||
|
||||
class ForEachSelected : public SelectionSystem::Visitor {
|
||||
public:
|
||||
ForEachSelected(ExportData &_exporter)
|
||||
: exporter(_exporter)
|
||||
{}
|
||||
|
||||
void visit(scene::Instance &instance) const
|
||||
{
|
||||
BrushInstance *bptr = InstanceTypeCast<BrushInstance>::cast(instance);
|
||||
if (bptr) {
|
||||
Brush &brush(bptr->getBrush());
|
||||
|
||||
exporter.BeginBrush(brush);
|
||||
ForEachFace face_vis(exporter);
|
||||
brush.forEachFace(face_vis);
|
||||
exporter.EndBrush();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ExportData &exporter;
|
||||
};
|
||||
|
||||
bool ExportSelection(const std::set<std::string> &ignorelist, collapsemode m, bool exmat, const std::string &path,
|
||||
bool limNames, bool objs)
|
||||
{
|
||||
ExportDataAsWavefront exporter(ignorelist, m, exmat, limNames, objs);
|
||||
|
||||
ForEachSelected vis(exporter);
|
||||
GlobalSelectionSystem().foreachSelected(vis);
|
||||
|
||||
return exporter.WriteToFile(path, m);
|
||||
}
|
16
contrib/brushexport/export.h
Normal file
16
contrib/brushexport/export.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef EXPORT_H
|
||||
#define EXPORT_H
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
enum collapsemode {
|
||||
COLLAPSE_ALL,
|
||||
COLLAPSE_BY_MATERIAL,
|
||||
COLLAPSE_NONE
|
||||
};
|
||||
|
||||
bool ExportSelection(const std::set<std::string> &ignorelist, collapsemode m, bool exmat, const std::string &path,
|
||||
bool limitMatNames, bool objects);
|
||||
|
||||
#endif
|
219
contrib/brushexport/interface.cpp
Normal file
219
contrib/brushexport/interface.cpp
Normal file
|
@ -0,0 +1,219 @@
|
|||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "debugging/debugging.h"
|
||||
#include "callbacks.h"
|
||||
#include "support.h"
|
||||
|
||||
#define GLADE_HOOKUP_OBJECT(component, widget, name) \
|
||||
g_object_set_data_full( G_OBJECT( component ), name, \
|
||||
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, (void *) widget )
|
||||
|
||||
// created by glade
|
||||
ui::Widget create_w_plugplug2(void)
|
||||
{
|
||||
GSList *r_collapse_group = NULL;
|
||||
|
||||
auto w_plugplug2 = ui::Window(ui::window_type::TOP);
|
||||
gtk_widget_set_name(w_plugplug2, "w_plugplug2");
|
||||
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);
|
||||
|
||||
auto vbox1 = ui::VBox(FALSE, 0);
|
||||
gtk_widget_set_name(vbox1, "vbox1");
|
||||
vbox1.show();
|
||||
w_plugplug2.add(vbox1);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5);
|
||||
|
||||
auto hbox2 = ui::HBox(TRUE, 5);
|
||||
gtk_widget_set_name(hbox2, "hbox2");
|
||||
hbox2.show();
|
||||
vbox1.pack_start(hbox2, FALSE, FALSE, 0);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(hbox2), 5);
|
||||
|
||||
auto vbox4 = ui::VBox(TRUE, 0);
|
||||
gtk_widget_set_name(vbox4, "vbox4");
|
||||
vbox4.show();
|
||||
hbox2.pack_start(vbox4, TRUE, FALSE, 0);
|
||||
|
||||
auto r_collapse = ui::Widget::from(gtk_radio_button_new_with_mnemonic(NULL, "Collapse mesh"));
|
||||
gtk_widget_set_name(r_collapse, "r_collapse");
|
||||
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));
|
||||
|
||||
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_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));
|
||||
|
||||
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_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));
|
||||
|
||||
auto vbox3 = ui::VBox(FALSE, 0);
|
||||
gtk_widget_set_name(vbox3, "vbox3");
|
||||
vbox3.show();
|
||||
hbox2.pack_start(vbox3, FALSE, FALSE, 0);
|
||||
|
||||
auto b_export = ui::Button::from(gtk_button_new_from_stock("gtk-save"));
|
||||
gtk_widget_set_name(b_export, "b_export");
|
||||
b_export.show();
|
||||
vbox3.pack_start(b_export, TRUE, FALSE, 0);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(b_export), 5);
|
||||
|
||||
auto b_close = ui::Button::from(gtk_button_new_from_stock("gtk-cancel"));
|
||||
gtk_widget_set_name(b_close, "b_close");
|
||||
b_close.show();
|
||||
vbox3.pack_start(b_close, TRUE, FALSE, 0);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(b_close), 5);
|
||||
|
||||
auto vbox2 = ui::VBox(FALSE, 5);
|
||||
gtk_widget_set_name(vbox2, "vbox2");
|
||||
vbox2.show();
|
||||
vbox1.pack_start(vbox2, TRUE, TRUE, 0);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox2), 2);
|
||||
|
||||
auto label1 = ui::Label("Ignored materials:");
|
||||
gtk_widget_set_name(label1, "label1");
|
||||
label1.show();
|
||||
vbox2.pack_start(label1, FALSE, FALSE, 0);
|
||||
|
||||
auto scrolledwindow1 = ui::ScrolledWindow(ui::New);
|
||||
gtk_widget_set_name(scrolledwindow1, "scrolledwindow1");
|
||||
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);
|
||||
|
||||
auto t_materialist = ui::TreeView(ui::New);
|
||||
gtk_widget_set_name(t_materialist, "t_materialist");
|
||||
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);
|
||||
|
||||
auto ed_materialname = ui::Entry(ui::New);
|
||||
gtk_widget_set_name(ed_materialname, "ed_materialname");
|
||||
ed_materialname.show();
|
||||
vbox2.pack_start(ed_materialname, FALSE, FALSE, 0);
|
||||
|
||||
auto hbox1 = ui::HBox(TRUE, 0);
|
||||
gtk_widget_set_name(hbox1, "hbox1");
|
||||
hbox1.show();
|
||||
vbox2.pack_start(hbox1, FALSE, FALSE, 0);
|
||||
|
||||
auto b_addmaterial = ui::Button::from(gtk_button_new_from_stock("gtk-add"));
|
||||
gtk_widget_set_name(b_addmaterial, "b_addmaterial");
|
||||
b_addmaterial.show();
|
||||
hbox1.pack_start(b_addmaterial, FALSE, FALSE, 0);
|
||||
|
||||
auto b_removematerial = ui::Button::from(gtk_button_new_from_stock("gtk-remove"));
|
||||
gtk_widget_set_name(b_removematerial, "b_removematerial");
|
||||
b_removematerial.show();
|
||||
hbox1.pack_start(b_removematerial, FALSE, FALSE, 0);
|
||||
|
||||
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");
|
||||
t_limitmatnames.show();
|
||||
vbox2.pack_end(t_limitmatnames, FALSE, FALSE, 0);
|
||||
|
||||
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");
|
||||
t_objects.show();
|
||||
vbox2.pack_end(t_objects, FALSE, FALSE, 0);
|
||||
|
||||
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");
|
||||
t_exportmaterials.show();
|
||||
vbox2.pack_end(t_exportmaterials, FALSE, FALSE, 10);
|
||||
|
||||
using namespace callbacks;
|
||||
w_plugplug2.connect("destroy", G_CALLBACK(OnDestroy), NULL);
|
||||
g_signal_connect_swapped(G_OBJECT(b_close), "clicked", G_CALLBACK(OnDestroy), 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");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, vbox1, "vbox1");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, hbox2, "hbox2");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, vbox4, "vbox4");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, r_collapse, "r_collapse");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, r_collapsebymaterial, "r_collapsebymaterial");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, r_nocollapse, "r_nocollapse");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, vbox3, "vbox3");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, b_export, "b_export");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, b_close, "b_close");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, vbox2, "vbox2");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, label1, "label1");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, scrolledwindow1, "scrolledwindow1");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, t_materialist, "t_materialist");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, ed_materialname, "ed_materialname");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, hbox1, "hbox1");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, b_addmaterial, "b_addmaterial");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, b_removematerial, "b_removematerial");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, t_exportmaterials, "t_exportmaterials");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, t_limitmatnames, "t_limitmatnames");
|
||||
GLADE_HOOKUP_OBJECT(w_plugplug2, t_objects, "t_objects");
|
||||
|
||||
return w_plugplug2;
|
||||
}
|
||||
|
||||
// global main window, is 0 when not created
|
||||
ui::Widget g_brushexp_window{ui::null};
|
||||
|
||||
// spawn plugin window (and make sure it got destroyed first or never created)
|
||||
void CreateWindow(void)
|
||||
{
|
||||
ASSERT_TRUE(!g_brushexp_window);
|
||||
|
||||
ui::Widget wnd = create_w_plugplug2();
|
||||
|
||||
// column & renderer
|
||||
auto col = ui::TreeViewColumn::from(gtk_tree_view_column_new());
|
||||
gtk_tree_view_column_set_title(col, "materials");
|
||||
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
|
||||
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()
|
||||
{
|
||||
ASSERT_TRUE(g_brushexp_window);
|
||||
ui::Widget(g_brushexp_window).destroy();
|
||||
g_brushexp_window = ui::Widget(ui::null);
|
||||
}
|
||||
|
||||
bool IsWindowOpen()
|
||||
{
|
||||
return g_brushexp_window;
|
||||
}
|
135
contrib/brushexport/plugin.cpp
Normal file
135
contrib/brushexport/plugin.cpp
Normal file
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
Copyright (C) 2006, Thomas Nitschke.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public 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 "iplugin.h"
|
||||
#include "qerplugin.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "debugging/debugging.h"
|
||||
#include "string/string.h"
|
||||
#include "modulesystem/singletonmodule.h"
|
||||
#include "stream/textfilestream.h"
|
||||
#include "stream/stringstream.h"
|
||||
#include "gtkutil/messagebox.h"
|
||||
#include "gtkutil/filechooser.h"
|
||||
|
||||
#include "ibrush.h"
|
||||
#include "iscenegraph.h"
|
||||
#include "iselection.h"
|
||||
#include "ifilesystem.h"
|
||||
#include "ifiletypes.h"
|
||||
|
||||
#include "support.h"
|
||||
|
||||
#include "typesystem.h"
|
||||
|
||||
void CreateWindow(void);
|
||||
|
||||
void DestroyWindow(void);
|
||||
|
||||
bool IsWindowOpen(void);
|
||||
|
||||
namespace BrushExport {
|
||||
ui::Window g_mainwnd{ui::null};
|
||||
|
||||
const char *init(void *hApp, void *pMainWidget)
|
||||
{
|
||||
g_mainwnd = ui::Window::from(pMainWidget);
|
||||
ASSERT_TRUE(g_mainwnd);
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *getName()
|
||||
{
|
||||
return "Brush export Plugin";
|
||||
}
|
||||
|
||||
const char *getCommandList()
|
||||
{
|
||||
return "About;Export selected as Wavefront OBJ";
|
||||
}
|
||||
|
||||
const char *getCommandTitleList()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void dispatch(const char *command, float *vMin, float *vMax, bool bSingleBrush)
|
||||
{
|
||||
if (string_equal(command, "About")) {
|
||||
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);
|
||||
} else if (string_equal(command, "Export selected as Wavefront OBJ")) {
|
||||
if (IsWindowOpen()) {
|
||||
DestroyWindow();
|
||||
}
|
||||
CreateWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BrushExportDependencies :
|
||||
public GlobalRadiantModuleRef,
|
||||
public GlobalFiletypesModuleRef,
|
||||
public GlobalBrushModuleRef,
|
||||
public GlobalFileSystemModuleRef,
|
||||
public GlobalSceneGraphModuleRef,
|
||||
public GlobalSelectionModuleRef {
|
||||
public:
|
||||
BrushExportDependencies(void)
|
||||
: GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes"))
|
||||
{}
|
||||
};
|
||||
|
||||
class BrushExportModule : public TypeSystemRef {
|
||||
_QERPluginTable m_plugin;
|
||||
public:
|
||||
typedef _QERPluginTable Type;
|
||||
|
||||
STRING_CONSTANT(Name, "Export Brushes");
|
||||
|
||||
BrushExportModule()
|
||||
{
|
||||
m_plugin.m_pfnQERPlug_Init = &BrushExport::init;
|
||||
m_plugin.m_pfnQERPlug_GetName = &BrushExport::getName;
|
||||
m_plugin.m_pfnQERPlug_GetCommandList = &BrushExport::getCommandList;
|
||||
m_plugin.m_pfnQERPlug_GetCommandTitleList = &BrushExport::getCommandTitleList;
|
||||
m_plugin.m_pfnQERPlug_Dispatch = &BrushExport::dispatch;
|
||||
}
|
||||
|
||||
_QERPluginTable *getTable()
|
||||
{
|
||||
return &m_plugin;
|
||||
}
|
||||
};
|
||||
|
||||
typedef SingletonModule<BrushExportModule, BrushExportDependencies> SingletonBrushExportModule;
|
||||
SingletonBrushExportModule g_BrushExportModule;
|
||||
|
||||
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server)
|
||||
{
|
||||
initialiseModule(server);
|
||||
g_BrushExportModule.selfRegister();
|
||||
}
|
25
contrib/brushexport/plugin.h
Normal file
25
contrib/brushexport/plugin.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
Copyright (C) 2006, Thomas Nitschke.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_BRUSH_EXPORT_H )
|
||||
#define INCLUDED_BRUSH_EXPORT_H
|
||||
|
||||
#endif
|
32
contrib/brushexport/support.cpp
Normal file
32
contrib/brushexport/support.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <uilib/uilib.h>
|
||||
|
||||
#include "support.h"
|
||||
|
||||
ui::Widget
|
||||
lookup_widget(ui::Widget widget,
|
||||
const gchar *widget_name)
|
||||
{
|
||||
ui::Widget parent{ui::null};
|
||||
|
||||
for (;;) {
|
||||
if (GTK_IS_MENU(widget)) {
|
||||
parent = ui::Widget::from(gtk_menu_get_attach_widget(GTK_MENU(widget)));
|
||||
} else {
|
||||
parent = ui::Widget::from(gtk_widget_get_parent(widget));
|
||||
}
|
||||
if (!parent) {
|
||||
parent = ui::Widget::from(g_object_get_data(G_OBJECT(widget), "GladeParentKey"));
|
||||
}
|
||||
if (parent == NULL) {
|
||||
break;
|
||||
}
|
||||
widget = parent;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
return found_widget;
|
||||
}
|
22
contrib/brushexport/support.h
Normal file
22
contrib/brushexport/support.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* DO NOT EDIT THIS FILE - it is generated by Glade.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <uilib/uilib.h>
|
||||
|
||||
/*
|
||||
* Public Functions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This function returns a widget in a component created by Glade.
|
||||
* Call it with the toplevel widget in the component (i.e. a window/dialog),
|
||||
* or alternatively any widget in the component, and the name of the widget
|
||||
* you want returned.
|
||||
*/
|
||||
ui::Widget lookup_widget(ui::Widget widget,
|
||||
const gchar *widget_name);
|
99
contrib/prtview/AboutDialog.cpp
Normal file
99
contrib/prtview/AboutDialog.cpp
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
PrtView plugin for GtkRadiant
|
||||
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
#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(ui::Widget widget, gpointer data)
|
||||
{
|
||||
int *loop, *ret;
|
||||
|
||||
auto parent = widget.window();
|
||||
loop = (int *) g_object_get_data(G_OBJECT(parent), "loop");
|
||||
ret = (int *) g_object_get_data(G_OBJECT(parent), "ret");
|
||||
|
||||
*loop = 0;
|
||||
*ret = gpointer_to_int(data);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
int loop = 1, ret = IDCANCEL;
|
||||
|
||||
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 WorldSpawn " WorldSpawn_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);
|
||||
dlg.destroy();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDialog message handlers
|
25
contrib/prtview/AboutDialog.h
Normal file
25
contrib/prtview/AboutDialog.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
PrtView plugin for GtkRadiant
|
||||
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
#if !defined( INCLUDED_ABOUTDIALOG_H )
|
||||
#define INCLUDED_ABOUTDIALOG_H
|
||||
|
||||
void DoAboutDlg();
|
||||
|
||||
#endif
|
13
contrib/prtview/CMakeLists.txt
Normal file
13
contrib/prtview/CMakeLists.txt
Normal file
|
@ -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)
|
481
contrib/prtview/ConfigDialog.cpp
Normal file
481
contrib/prtview/ConfigDialog.cpp
Normal file
|
@ -0,0 +1,481 @@
|
|||
/*
|
||||
PrtView plugin for GtkRadiant
|
||||
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
#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(ui::Widget widget, gpointer data)
|
||||
{
|
||||
int *loop, *ret;
|
||||
|
||||
auto parent = widget.window();
|
||||
loop = (int *) g_object_get_data(G_OBJECT(parent), "loop");
|
||||
ret = (int *) g_object_get_data(G_OBJECT(parent), "ret");
|
||||
|
||||
*loop = 0;
|
||||
*ret = gpointer_to_int(data);
|
||||
}
|
||||
|
||||
static gint dialog_delete_callback(ui::Widget widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
widget.hide();
|
||||
int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
|
||||
*loop = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Color selection dialog
|
||||
|
||||
static int DoColor(PackedColour *c)
|
||||
{
|
||||
GdkColor clr;
|
||||
int loop = 1, ret = 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);
|
||||
|
||||
dlg.show();
|
||||
gtk_grab_add(dlg);
|
||||
|
||||
while (loop) {
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
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);
|
||||
dlg.destroy();
|
||||
|
||||
if (ret == IDOK) {
|
||||
*c = RGB(clr.red / (65535 / 255), clr.green / (65535 / 255), clr.blue / (65535 / 255));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void Set2DText(ui::Widget label)
|
||||
{
|
||||
char s[40];
|
||||
|
||||
sprintf(s, "Line Width = %6.3f", portals.width_2d * 0.5f);
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(label), s);
|
||||
}
|
||||
|
||||
static void Set3DText(ui::Widget label)
|
||||
{
|
||||
char s[40];
|
||||
|
||||
sprintf(s, "Line Width = %6.3f", portals.width_3d * 0.5f);
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(label), s);
|
||||
}
|
||||
|
||||
static void Set3DTransText(ui::Widget label)
|
||||
{
|
||||
char s[40];
|
||||
|
||||
sprintf(s, "Polygon transparency = %d%%", (int) portals.trans_3d);
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(label), s);
|
||||
}
|
||||
|
||||
static void SetClipText(ui::Widget label)
|
||||
{
|
||||
char s[40];
|
||||
|
||||
sprintf(s, "Cubic clip range = %d", (int) portals.clip_range * 64);
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(label), s);
|
||||
}
|
||||
|
||||
static void OnScroll2d(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(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(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(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(ui::Widget widget, gpointer data)
|
||||
{
|
||||
portals.aa_2d = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ? true : false;
|
||||
|
||||
Portals_shadersChanged();
|
||||
|
||||
SceneChangeNotify();
|
||||
}
|
||||
|
||||
static void OnConfig2d(ui::Widget widget, gpointer data)
|
||||
{
|
||||
portals.show_2d = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ? true : false;
|
||||
|
||||
SceneChangeNotify();
|
||||
}
|
||||
|
||||
static void OnColor2d(ui::Widget widget, gpointer data)
|
||||
{
|
||||
if (DoColor(&portals.color_2d) == IDOK) {
|
||||
Portals_shadersChanged();
|
||||
|
||||
SceneChangeNotify();
|
||||
}
|
||||
}
|
||||
|
||||
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(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(ui::Widget widget, gpointer data)
|
||||
{
|
||||
if (DoColor(&portals.color_3d) == IDOK) {
|
||||
Portals_shadersChanged();
|
||||
|
||||
SceneChangeNotify();
|
||||
}
|
||||
}
|
||||
|
||||
static void OnColorFog(ui::Widget widget, gpointer data)
|
||||
{
|
||||
if (DoColor(&portals.color_fog) == IDOK) {
|
||||
Portals_shadersChanged();
|
||||
|
||||
SceneChangeNotify();
|
||||
}
|
||||
}
|
||||
|
||||
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(ui::Widget widget, gpointer data)
|
||||
{
|
||||
portals.zbuffer = gpointer_to_int(data);
|
||||
|
||||
Portals_shadersChanged();
|
||||
SceneChangeNotify();
|
||||
}
|
||||
|
||||
static void OnPoly(ui::Widget widget, gpointer data)
|
||||
{
|
||||
portals.polygons = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
||||
|
||||
SceneChangeNotify();
|
||||
}
|
||||
|
||||
static void OnLines(ui::Widget widget, gpointer data)
|
||||
{
|
||||
portals.lines = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
||||
|
||||
SceneChangeNotify();
|
||||
}
|
||||
|
||||
static void OnClip(ui::Widget widget, gpointer data)
|
||||
{
|
||||
portals.clip = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ? true : false;
|
||||
|
||||
SceneChangeNotify();
|
||||
}
|
||||
|
||||
void DoConfigDialog()
|
||||
{
|
||||
int loop = 1, ret = IDCANCEL;
|
||||
|
||||
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);
|
||||
|
||||
auto vbox = ui::VBox(FALSE, 5);
|
||||
vbox.show();
|
||||
dlg.add(vbox);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
|
||||
|
||||
auto frame = ui::Frame("3D View");
|
||||
frame.show();
|
||||
vbox.pack_start(frame, TRUE, TRUE, 0);
|
||||
|
||||
auto vbox2 = ui::VBox(FALSE, 5);
|
||||
vbox2.show();
|
||||
frame.add(vbox2);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox2), 5);
|
||||
|
||||
auto hbox = ui::HBox(FALSE, 5);
|
||||
hbox.show();
|
||||
vbox2.pack_start(hbox, 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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
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);
|
||||
adj.connect("value_changed", G_CALLBACK(OnScrollClip), cliplabel);
|
||||
|
||||
hbox = ui::HBox(TRUE, 5);
|
||||
hbox.show();
|
||||
vbox2.pack_start(hbox, TRUE, FALSE, 0);
|
||||
|
||||
auto show3check = ui::CheckButton("Show");
|
||||
show3check.show();
|
||||
hbox.pack_start(show3check, TRUE, TRUE, 0);
|
||||
show3check.connect("toggled", G_CALLBACK(OnConfig3d), 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 = ui::Frame("2D View");
|
||||
frame.show();
|
||||
vbox.pack_start(frame, TRUE, TRUE, 0);
|
||||
|
||||
vbox2 = ui::VBox(FALSE, 5);
|
||||
vbox2.show();
|
||||
frame.add(vbox2);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox2), 5);
|
||||
|
||||
hbox = ui::HBox(FALSE, 5);
|
||||
hbox.show();
|
||||
vbox2.pack_start(hbox, TRUE, FALSE, 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);
|
||||
|
||||
auto lw2label = ui::Label("");
|
||||
lw2label.show();
|
||||
hbox.pack_start(lw2label, FALSE, TRUE, 0);
|
||||
adj.connect("value_changed", G_CALLBACK(OnScroll2d), lw2label);
|
||||
|
||||
hbox = ui::HBox(FALSE, 5);
|
||||
hbox.show();
|
||||
vbox2.pack_start(hbox, TRUE, FALSE, 0);
|
||||
|
||||
button = ui::Button("Color");
|
||||
button.show();
|
||||
hbox.pack_start(button, FALSE, FALSE, 0);
|
||||
button.connect("clicked", G_CALLBACK(OnColor2d), NULL);
|
||||
button.dimensions(60, -1);
|
||||
|
||||
auto aa2check = ui::CheckButton("Anti-Alias (May not work on some video cards)");
|
||||
aa2check.show();
|
||||
hbox.pack_start(aa2check, TRUE, TRUE, 0);
|
||||
aa2check.connect("toggled", G_CALLBACK(OnAntiAlias2d), NULL);
|
||||
|
||||
hbox = ui::HBox(FALSE, 5);
|
||||
hbox.show();
|
||||
vbox2.pack_start(hbox, TRUE, FALSE, 0);
|
||||
|
||||
auto show2check = ui::CheckButton("Show");
|
||||
show2check.show();
|
||||
hbox.pack_start(show2check, FALSE, FALSE, 0);
|
||||
show2check.connect("toggled", G_CALLBACK(OnConfig2d), NULL);
|
||||
|
||||
hbox = ui::HBox(FALSE, 5);
|
||||
hbox.show();
|
||||
vbox.pack_start(hbox, FALSE, FALSE, 0);
|
||||
|
||||
button = ui::Button("OK");
|
||||
button.show();
|
||||
hbox.pack_end(button, FALSE, FALSE, 0);
|
||||
button.connect("clicked",
|
||||
G_CALLBACK(dialog_button_callback), GINT_TO_POINTER(IDOK));
|
||||
button.dimensions(60, -1);
|
||||
|
||||
// initialize dialog
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show2check), portals.show_2d);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa2check), portals.aa_2d);
|
||||
Set2DText(lw2label);
|
||||
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show3check), portals.show_3d);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(depthcheck), portals.fog);
|
||||
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_combo_box_set_active(zlist, portals.zbuffer);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(portalcheck), portals.clip);
|
||||
|
||||
Set3DText(lw3label);
|
||||
Set3DTransText(translabel);
|
||||
SetClipText(cliplabel);
|
||||
|
||||
gtk_grab_add(dlg);
|
||||
dlg.show();
|
||||
|
||||
while (loop) {
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
gtk_grab_remove(dlg);
|
||||
dlg.destroy();
|
||||
}
|
25
contrib/prtview/ConfigDialog.h
Normal file
25
contrib/prtview/ConfigDialog.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
PrtView plugin for GtkRadiant
|
||||
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
#if !defined( INCLUDED_CONFIGDIALOG_H )
|
||||
#define INCLUDED_CONFIGDIALOG_H
|
||||
|
||||
void DoConfigDialog();
|
||||
|
||||
#endif
|
169
contrib/prtview/LoadPortalFileDialog.cpp
Normal file
169
contrib/prtview/LoadPortalFileDialog.cpp
Normal file
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
PrtView plugin for GtkRadiant
|
||||
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
// LoadPortalFileDialog.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "LoadPortalFileDialog.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtkutil/pointer.h>
|
||||
#include "stream/stringstream.h"
|
||||
#include "convert.h"
|
||||
#include "gtkutil/pointer.h"
|
||||
|
||||
#include "qerplugin.h"
|
||||
|
||||
#include "prtview.h"
|
||||
#include "portals.h"
|
||||
|
||||
static void dialog_button_callback(ui::Widget widget, gpointer data)
|
||||
{
|
||||
int *loop, *ret;
|
||||
|
||||
auto parent = widget.window();
|
||||
loop = (int *) g_object_get_data(G_OBJECT(parent), "loop");
|
||||
ret = (int *) g_object_get_data(G_OBJECT(parent), "ret");
|
||||
|
||||
*loop = 0;
|
||||
*ret = gpointer_to_int(data);
|
||||
}
|
||||
|
||||
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 change_clicked(ui::Widget widget, gpointer data)
|
||||
{
|
||||
char *filename = NULL;
|
||||
|
||||
auto file_sel = ui::Widget::from(
|
||||
gtk_file_chooser_dialog_new("Locate portal (.prt) file", nullptr, GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
||||
nullptr));
|
||||
|
||||
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file_sel), portals.fn);
|
||||
|
||||
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);
|
||||
gtk_entry_set_text(GTK_ENTRY(data), filename);
|
||||
g_free(filename);
|
||||
}
|
||||
}
|
||||
|
||||
int DoLoadPortalFileDialog()
|
||||
{
|
||||
int loop = 1, ret = IDCANCEL;
|
||||
|
||||
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);
|
||||
|
||||
auto vbox = ui::VBox(FALSE, 5);
|
||||
vbox.show();
|
||||
dlg.add(vbox);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
|
||||
|
||||
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, '.');
|
||||
if (fn != NULL) {
|
||||
strcpy(fn, ".prt");
|
||||
}
|
||||
|
||||
StringOutputStream value(256);
|
||||
value << portals.fn;
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), value.c_str());
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check2d), portals.show_2d);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check3d), portals.show_3d);
|
||||
|
||||
gtk_grab_add(dlg);
|
||||
dlg.show();
|
||||
|
||||
while (loop) {
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
if (ret == IDOK) {
|
||||
portals.Purge();
|
||||
|
||||
portals.show_3d = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check3d)) ? true : false;
|
||||
portals.show_2d = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check2d)) ? true : false;
|
||||
}
|
||||
|
||||
gtk_grab_remove(dlg);
|
||||
dlg.destroy();
|
||||
|
||||
return ret;
|
||||
}
|
25
contrib/prtview/LoadPortalFileDialog.h
Normal file
25
contrib/prtview/LoadPortalFileDialog.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
PrtView plugin for GtkRadiant
|
||||
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
#if !defined( INCLUDED_LOADPORTALFILEDIALOG_H )
|
||||
#define INCLUDED_LOADPORTALFILEDIALOG_H
|
||||
|
||||
int DoLoadPortalFileDialog();
|
||||
|
||||
#endif
|
BIN
contrib/prtview/PrtView.aps
Normal file
BIN
contrib/prtview/PrtView.aps
Normal file
Binary file not shown.
7
contrib/prtview/PrtView.def
Normal file
7
contrib/prtview/PrtView.def
Normal file
|
@ -0,0 +1,7 @@
|
|||
; PrtView.def : Declares the module parameters for the DLL.
|
||||
|
||||
LIBRARY "PrtView"
|
||||
|
||||
EXPORTS
|
||||
; Explicit exports can go here
|
||||
Radiant_RegisterModules @1
|
12
contrib/prtview/PrtView.txt
Normal file
12
contrib/prtview/PrtView.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
Put PrtView.dll in the Q3Radiant plugins directory.
|
||||
|
||||
This program is pretty self explanitary, but point needs to
|
||||
be mentioned. In the configuration menu for 3D view options,
|
||||
the lines and polygons flags are tri-state. In the third state,
|
||||
the lines or polygons will only be drawn if the have the
|
||||
hint flag set. Older version of q3map will not set this flag
|
||||
and the hint shader may have to be modified to set it. As of
|
||||
this writing, I do not know all the details.
|
||||
|
||||
Geoffrey DeWan
|
||||
gdewan@prairienet.org
|
639
contrib/prtview/portals.cpp
Normal file
639
contrib/prtview/portals.cpp
Normal file
|
@ -0,0 +1,639 @@
|
|||
/*
|
||||
PrtView plugin for GtkRadiant
|
||||
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
#include "portals.h"
|
||||
#include "globaldefs.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !GDEF_OS_MACOS
|
||||
|
||||
#include <search.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "iglrender.h"
|
||||
#include "cullable.h"
|
||||
|
||||
#include "prtview.h"
|
||||
|
||||
const int LINE_BUF = 1000;
|
||||
|
||||
CPortals portals;
|
||||
CPortalsRender render;
|
||||
|
||||
int compare(const void *arg1, const void *arg2)
|
||||
{
|
||||
|
||||
if (portals.portal[*((int *) arg1)].dist > portals.portal[*((int *) arg2)].dist) {
|
||||
return -1;
|
||||
} else if (portals.portal[*((int *) arg1)].dist < portals.portal[*((int *) arg2)].dist) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
CBspPortal::CBspPortal()
|
||||
{
|
||||
memset(this, 0, sizeof(CBspPortal));
|
||||
}
|
||||
|
||||
CBspPortal::~CBspPortal()
|
||||
{
|
||||
delete[] point;
|
||||
delete[] inner_point;
|
||||
}
|
||||
|
||||
bool CBspPortal::Build(char *def)
|
||||
{
|
||||
char *c = def;
|
||||
unsigned int n;
|
||||
int dummy1, dummy2;
|
||||
int res_cnt, i;
|
||||
|
||||
if (portals.hint_flags) {
|
||||
res_cnt = sscanf(def, "%u %d %d %d", &point_count, &dummy1, &dummy2, (int *) &hint);
|
||||
} else {
|
||||
sscanf(def, "%u", &point_count);
|
||||
hint = false;
|
||||
}
|
||||
|
||||
if (point_count < 3 || (portals.hint_flags && res_cnt < 4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
point = new CBspPoint[point_count];
|
||||
inner_point = new CBspPoint[point_count];
|
||||
|
||||
for (n = 0; n < point_count; n++) {
|
||||
for (; *c != 0 && *c != '('; c++) {}
|
||||
|
||||
if (*c == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
c++;
|
||||
|
||||
sscanf(c, "%f %f %f", point[n].p, point[n].p + 1, point[n].p + 2);
|
||||
|
||||
center.p[0] += point[n].p[0];
|
||||
center.p[1] += point[n].p[1];
|
||||
center.p[2] += point[n].p[2];
|
||||
|
||||
if (n == 0) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
min[i] = point[n].p[i];
|
||||
max[i] = point[n].p[i];
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (min[i] > point[n].p[i]) {
|
||||
min[i] = point[n].p[i];
|
||||
}
|
||||
if (max[i] < point[n].p[i]) {
|
||||
max[i] = point[n].p[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
center.p[0] /= (float) point_count;
|
||||
center.p[1] /= (float) point_count;
|
||||
center.p[2] /= (float) point_count;
|
||||
|
||||
for (n = 0; n < point_count; n++) {
|
||||
inner_point[n].p[0] = (0.01f * center.p[0]) + (0.99f * point[n].p[0]);
|
||||
inner_point[n].p[1] = (0.01f * center.p[1]) + (0.99f * point[n].p[1]);
|
||||
inner_point[n].p[2] = (0.01f * center.p[2]) + (0.99f * point[n].p[2]);
|
||||
}
|
||||
|
||||
fp_color_random[0] = (float) (rand() & 0xff) / 255.0f;
|
||||
fp_color_random[1] = (float) (rand() & 0xff) / 255.0f;
|
||||
fp_color_random[2] = (float) (rand() & 0xff) / 255.0f;
|
||||
fp_color_random[3] = 1.0f;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CPortals::CPortals()
|
||||
{
|
||||
memset(this, 0, sizeof(CPortals));
|
||||
}
|
||||
|
||||
CPortals::~CPortals()
|
||||
{
|
||||
Purge();
|
||||
}
|
||||
|
||||
void CPortals::Purge()
|
||||
{
|
||||
delete[] portal;
|
||||
delete[] portal_sort;
|
||||
portal = NULL;
|
||||
portal_sort = NULL;
|
||||
portal_count = 0;
|
||||
|
||||
/*
|
||||
delete[] node;
|
||||
node = NULL;
|
||||
node_count = 0;
|
||||
*/
|
||||
}
|
||||
|
||||
void CPortals::Load()
|
||||
{
|
||||
char buf[LINE_BUF + 1];
|
||||
|
||||
memset(buf, 0, LINE_BUF + 1);
|
||||
|
||||
Purge();
|
||||
|
||||
globalOutputStream() << MSG_PREFIX "Loading portal file " << fn << ".\n";
|
||||
|
||||
FILE *in;
|
||||
|
||||
in = fopen(fn, "rt");
|
||||
|
||||
if (in == NULL) {
|
||||
globalOutputStream() << " ERROR - could not open file.\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fgets(buf, LINE_BUF, in)) {
|
||||
fclose(in);
|
||||
|
||||
globalOutputStream() << " ERROR - File ended prematurely.\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp("PRT1", buf, 4) != 0) {
|
||||
fclose(in);
|
||||
|
||||
globalOutputStream() << " ERROR - File header indicates wrong file type (should be \"PRT1\").\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fgets(buf, LINE_BUF, in)) {
|
||||
fclose(in);
|
||||
|
||||
globalOutputStream() << " ERROR - File ended prematurely.\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sscanf(buf, "%u", &node_count);
|
||||
/*
|
||||
if(node_count > 0xFFFF)
|
||||
{
|
||||
fclose(in);
|
||||
|
||||
node_count = 0;
|
||||
|
||||
globalOutputStream() << " ERROR - Extreme number of nodes, aborting.\n";
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
if (!fgets(buf, LINE_BUF, in)) {
|
||||
fclose(in);
|
||||
|
||||
node_count = 0;
|
||||
|
||||
globalOutputStream() << " ERROR - File ended prematurely.\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sscanf(buf, "%u", &portal_count);
|
||||
|
||||
if (portal_count > 0xFFFF) {
|
||||
fclose(in);
|
||||
|
||||
portal_count = 0;
|
||||
node_count = 0;
|
||||
|
||||
globalOutputStream() << " ERROR - Extreme number of portals, aborting.\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (portal_count == 0) {
|
||||
fclose(in);
|
||||
|
||||
portal_count = 0;
|
||||
node_count = 0;
|
||||
|
||||
globalOutputStream() << " ERROR - number of portals equals 0, aborting.\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// node = new CBspNode[node_count];
|
||||
portal = new CBspPortal[portal_count];
|
||||
portal_sort = new int[portal_count];
|
||||
|
||||
unsigned int n;
|
||||
bool first = true;
|
||||
unsigned test_vals_1, test_vals_2;
|
||||
|
||||
hint_flags = false;
|
||||
|
||||
for (n = 0; n < portal_count;) {
|
||||
if (!fgets(buf, LINE_BUF, in)) {
|
||||
fclose(in);
|
||||
|
||||
Purge();
|
||||
|
||||
globalOutputStream() << " ERROR - Could not find information for portal number " << n + 1 << " of "
|
||||
<< portal_count << ".\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!portal[n].Build(buf)) {
|
||||
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;
|
||||
}
|
||||
|
||||
first = false;
|
||||
|
||||
fclose(in);
|
||||
|
||||
Purge();
|
||||
|
||||
globalOutputStream() << " ERROR - Information for portal number " << n + 1 << " of " << portal_count
|
||||
<< " is not formatted correctly.\n";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
n++;
|
||||
}
|
||||
|
||||
fclose(in);
|
||||
|
||||
globalOutputStream() << " " << node_count << " portals read in.\n";
|
||||
}
|
||||
|
||||
#include "math/matrix.h"
|
||||
|
||||
const char *g_state_solid = "$plugins/prtview/solid";
|
||||
const char *g_state_solid_outline = "$plugins/prtview/solid_outline";
|
||||
const char *g_state_wireframe = "$plugins/prtview/wireframe";
|
||||
Shader *g_shader_solid = 0;
|
||||
Shader *g_shader_solid_outline = 0;
|
||||
Shader *g_shader_wireframe = 0;
|
||||
|
||||
void Portals_constructShaders()
|
||||
{
|
||||
OpenGLState state;
|
||||
GlobalOpenGLStateLibrary().getDefaultState(state);
|
||||
state.m_state = RENDER_COLOURWRITE | RENDER_DEPTHWRITE;
|
||||
state.m_sort = OpenGLState::eSortOverlayFirst;
|
||||
state.m_linewidth = portals.width_2d * 0.5f;
|
||||
state.m_colour[0] = portals.fp_color_2d[0];
|
||||
state.m_colour[1] = portals.fp_color_2d[1];
|
||||
state.m_colour[2] = portals.fp_color_2d[2];
|
||||
state.m_colour[3] = portals.fp_color_2d[3];
|
||||
if (portals.aa_2d) {
|
||||
state.m_state |= RENDER_BLEND | RENDER_LINESMOOTH;
|
||||
}
|
||||
GlobalOpenGLStateLibrary().insert(g_state_wireframe, state);
|
||||
|
||||
GlobalOpenGLStateLibrary().getDefaultState(state);
|
||||
state.m_state = RENDER_FILL | RENDER_BLEND | RENDER_COLOURWRITE | RENDER_COLOURCHANGE | RENDER_SMOOTH;
|
||||
|
||||
if (portals.aa_3d) {
|
||||
state.m_state |= RENDER_POLYGONSMOOTH;
|
||||
}
|
||||
|
||||
switch (portals.zbuffer) {
|
||||
case 1:
|
||||
state.m_state |= RENDER_DEPTHTEST;
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
default:
|
||||
state.m_state |= RENDER_DEPTHTEST;
|
||||
state.m_state |= RENDER_DEPTHWRITE;
|
||||
}
|
||||
|
||||
if (portals.fog) {
|
||||
state.m_state |= RENDER_FOG;
|
||||
|
||||
state.m_fog.mode = GL_EXP;
|
||||
state.m_fog.density = 0.001f;
|
||||
state.m_fog.start = 10.0f;
|
||||
state.m_fog.end = 10000.0f;
|
||||
state.m_fog.index = 0;
|
||||
state.m_fog.colour[0] = portals.fp_color_fog[0];
|
||||
state.m_fog.colour[1] = portals.fp_color_fog[1];
|
||||
state.m_fog.colour[2] = portals.fp_color_fog[2];
|
||||
state.m_fog.colour[3] = portals.fp_color_fog[3];
|
||||
}
|
||||
|
||||
GlobalOpenGLStateLibrary().insert(g_state_solid, state);
|
||||
|
||||
GlobalOpenGLStateLibrary().getDefaultState(state);
|
||||
state.m_state = RENDER_COLOURWRITE | RENDER_DEPTHWRITE;
|
||||
state.m_sort = OpenGLState::eSortOverlayFirst;
|
||||
state.m_linewidth = portals.width_3d * 0.5f;
|
||||
state.m_colour[0] = portals.fp_color_3d[0];
|
||||
state.m_colour[1] = portals.fp_color_3d[1];
|
||||
state.m_colour[2] = portals.fp_color_3d[2];
|
||||
state.m_colour[3] = portals.fp_color_3d[3];
|
||||
|
||||
if (portals.aa_3d) {
|
||||
state.m_state |= RENDER_LINESMOOTH;
|
||||
}
|
||||
|
||||
switch (portals.zbuffer) {
|
||||
case 1:
|
||||
state.m_state |= RENDER_DEPTHTEST;
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
default:
|
||||
state.m_state |= RENDER_DEPTHTEST;
|
||||
state.m_state |= RENDER_DEPTHWRITE;
|
||||
}
|
||||
|
||||
if (portals.fog) {
|
||||
state.m_state |= RENDER_FOG;
|
||||
|
||||
state.m_fog.mode = GL_EXP;
|
||||
state.m_fog.density = 0.001f;
|
||||
state.m_fog.start = 10.0f;
|
||||
state.m_fog.end = 10000.0f;
|
||||
state.m_fog.index = 0;
|
||||
state.m_fog.colour[0] = portals.fp_color_fog[0];
|
||||
state.m_fog.colour[1] = portals.fp_color_fog[1];
|
||||
state.m_fog.colour[2] = portals.fp_color_fog[2];
|
||||
state.m_fog.colour[3] = portals.fp_color_fog[3];
|
||||
}
|
||||
|
||||
GlobalOpenGLStateLibrary().insert(g_state_solid_outline, state);
|
||||
|
||||
g_shader_solid = GlobalShaderCache().capture(g_state_solid);
|
||||
g_shader_solid_outline = GlobalShaderCache().capture(g_state_solid_outline);
|
||||
g_shader_wireframe = GlobalShaderCache().capture(g_state_wireframe);
|
||||
}
|
||||
|
||||
void Portals_destroyShaders()
|
||||
{
|
||||
GlobalShaderCache().release(g_state_solid);
|
||||
GlobalShaderCache().release(g_state_solid_outline);
|
||||
GlobalShaderCache().release(g_state_wireframe);
|
||||
GlobalOpenGLStateLibrary().erase(g_state_solid);
|
||||
GlobalOpenGLStateLibrary().erase(g_state_solid_outline);
|
||||
GlobalOpenGLStateLibrary().erase(g_state_wireframe);
|
||||
}
|
||||
|
||||
void Portals_shadersChanged()
|
||||
{
|
||||
Portals_destroyShaders();
|
||||
portals.FixColors();
|
||||
Portals_constructShaders();
|
||||
}
|
||||
|
||||
void CPortals::FixColors()
|
||||
{
|
||||
fp_color_2d[0] = (float) GetRValue(color_2d) / 255.0f;
|
||||
fp_color_2d[1] = (float) GetGValue(color_2d) / 255.0f;
|
||||
fp_color_2d[2] = (float) GetBValue(color_2d) / 255.0f;
|
||||
fp_color_2d[3] = 1.0f;
|
||||
|
||||
fp_color_3d[0] = (float) GetRValue(color_3d) / 255.0f;
|
||||
fp_color_3d[1] = (float) GetGValue(color_3d) / 255.0f;
|
||||
fp_color_3d[2] = (float) GetBValue(color_3d) / 255.0f;
|
||||
fp_color_3d[3] = 1.0f;
|
||||
|
||||
fp_color_fog[0] = 0.0f; //(float)GetRValue(color_fog) / 255.0f;
|
||||
fp_color_fog[1] = 0.0f; //(float)GetGValue(color_fog) / 255.0f;
|
||||
fp_color_fog[2] = 0.0f; //(float)GetBValue(color_fog) / 255.0f;
|
||||
fp_color_fog[3] = 1.0f;
|
||||
}
|
||||
|
||||
void CPortalsRender::renderWireframe(Renderer &renderer, const VolumeTest &volume) const
|
||||
{
|
||||
if (!portals.show_2d || portals.portal_count < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
renderer.SetState(g_shader_wireframe, Renderer::eWireframeOnly);
|
||||
|
||||
renderer.addRenderable(m_drawWireframe, g_matrix4_identity);
|
||||
}
|
||||
|
||||
void CPortalsDrawWireframe::render(RenderStateFlags state) const
|
||||
{
|
||||
unsigned int n, p;
|
||||
|
||||
for (n = 0; n < portals.portal_count; n++) {
|
||||
glBegin(GL_LINE_LOOP);
|
||||
|
||||
for (p = 0; p < portals.portal[n].point_count; p++)
|
||||
glVertex3fv(portals.portal[n].point[p].p);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
CubicClipVolume calculateCubicClipVolume(const Matrix4 &viewproj)
|
||||
{
|
||||
CubicClipVolume clip;
|
||||
clip.cam = vector4_projected(
|
||||
matrix4_transformed_vector4(
|
||||
matrix4_full_inverse(viewproj),
|
||||
Vector4(0, 0, -1, 1)
|
||||
)
|
||||
);
|
||||
clip.min[0] = clip.cam[0] + (portals.clip_range * 64.0f);
|
||||
clip.min[1] = clip.cam[1] + (portals.clip_range * 64.0f);
|
||||
clip.min[2] = clip.cam[2] + (portals.clip_range * 64.0f);
|
||||
clip.max[0] = clip.cam[0] - (portals.clip_range * 64.0f);
|
||||
clip.max[1] = clip.cam[1] - (portals.clip_range * 64.0f);
|
||||
clip.max[2] = clip.cam[2] - (portals.clip_range * 64.0f);
|
||||
return clip;
|
||||
}
|
||||
|
||||
void CPortalsRender::renderSolid(Renderer &renderer, const VolumeTest &volume) const
|
||||
{
|
||||
if (!portals.show_3d || portals.portal_count < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
CubicClipVolume clip = calculateCubicClipVolume(
|
||||
matrix4_multiplied_by_matrix4(volume.GetProjection(), volume.GetModelview()));
|
||||
|
||||
if (portals.polygons) {
|
||||
renderer.SetState(g_shader_solid, Renderer::eWireframeOnly);
|
||||
renderer.SetState(g_shader_solid, Renderer::eFullMaterials);
|
||||
|
||||
m_drawSolid.clip = clip;
|
||||
renderer.addRenderable(m_drawSolid, g_matrix4_identity);
|
||||
}
|
||||
|
||||
if (portals.lines) {
|
||||
renderer.SetState(g_shader_solid_outline, Renderer::eWireframeOnly);
|
||||
renderer.SetState(g_shader_solid_outline, Renderer::eFullMaterials);
|
||||
|
||||
m_drawSolidOutline.clip = clip;
|
||||
renderer.addRenderable(m_drawSolidOutline, g_matrix4_identity);
|
||||
}
|
||||
}
|
||||
|
||||
void CPortalsDrawSolid::render(RenderStateFlags state) const
|
||||
{
|
||||
float trans = (100.0f - portals.trans_3d) / 100.0f;
|
||||
|
||||
unsigned int n, p;
|
||||
|
||||
if (portals.zbuffer != 0) {
|
||||
float d;
|
||||
|
||||
for (n = 0; n < portals.portal_count; n++) {
|
||||
d = (float) clip.cam[0] - portals.portal[n].center.p[0];
|
||||
portals.portal[n].dist = d * d;
|
||||
|
||||
d = (float) clip.cam[1] - portals.portal[n].center.p[1];
|
||||
portals.portal[n].dist += d * d;
|
||||
|
||||
d = (float) clip.cam[2] - portals.portal[n].center.p[2];
|
||||
portals.portal[n].dist += d * d;
|
||||
|
||||
portals.portal_sort[n] = n;
|
||||
}
|
||||
|
||||
qsort(portals.portal_sort, portals.portal_count, 4, compare);
|
||||
|
||||
for (n = 0; n < portals.portal_count; n++) {
|
||||
if (portals.polygons == 2 && !portals.portal[portals.portal_sort[n]].hint) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (portals.clip) {
|
||||
if (clip.min[0] < portals.portal[portals.portal_sort[n]].min[0]) {
|
||||
continue;
|
||||
} else if (clip.min[1] < portals.portal[portals.portal_sort[n]].min[1]) {
|
||||
continue;
|
||||
} else if (clip.min[2] < portals.portal[portals.portal_sort[n]].min[2]) {
|
||||
continue;
|
||||
} else if (clip.max[0] > portals.portal[portals.portal_sort[n]].max[0]) {
|
||||
continue;
|
||||
} else if (clip.max[1] > portals.portal[portals.portal_sort[n]].max[1]) {
|
||||
continue;
|
||||
} else if (clip.max[2] > portals.portal[portals.portal_sort[n]].max[2]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
glColor4f(portals.portal[portals.portal_sort[n]].fp_color_random[0],
|
||||
portals.portal[portals.portal_sort[n]].fp_color_random[1],
|
||||
portals.portal[portals.portal_sort[n]].fp_color_random[2], trans);
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
|
||||
for (p = 0; p < portals.portal[portals.portal_sort[n]].point_count; p++)
|
||||
glVertex3fv(portals.portal[portals.portal_sort[n]].point[p].p);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
} else {
|
||||
for (n = 0; n < portals.portal_count; n++) {
|
||||
if (portals.polygons == 2 && !portals.portal[n].hint) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (portals.clip) {
|
||||
if (clip.min[0] < portals.portal[n].min[0]) {
|
||||
continue;
|
||||
} else if (clip.min[1] < portals.portal[n].min[1]) {
|
||||
continue;
|
||||
} else if (clip.min[2] < portals.portal[n].min[2]) {
|
||||
continue;
|
||||
} else if (clip.max[0] > portals.portal[n].max[0]) {
|
||||
continue;
|
||||
} else if (clip.max[1] > portals.portal[n].max[1]) {
|
||||
continue;
|
||||
} else if (clip.max[2] > portals.portal[n].max[2]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
glColor4f(portals.portal[n].fp_color_random[0], portals.portal[n].fp_color_random[1],
|
||||
portals.portal[n].fp_color_random[2], trans);
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
|
||||
for (p = 0; p < portals.portal[n].point_count; p++)
|
||||
glVertex3fv(portals.portal[n].point[p].p);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPortalsDrawSolidOutline::render(RenderStateFlags state) const
|
||||
{
|
||||
for (unsigned int n = 0; n < portals.portal_count; n++) {
|
||||
if (portals.lines == 2 && !portals.portal[n].hint) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (portals.clip) {
|
||||
if (clip.min[0] < portals.portal[n].min[0]) {
|
||||
continue;
|
||||
}
|
||||
if (clip.min[1] < portals.portal[n].min[1]) {
|
||||
continue;
|
||||
}
|
||||
if (clip.min[2] < portals.portal[n].min[2]) {
|
||||
continue;
|
||||
}
|
||||
if (clip.max[0] > portals.portal[n].max[0]) {
|
||||
continue;
|
||||
}
|
||||
if (clip.max[1] > portals.portal[n].max[1]) {
|
||||
continue;
|
||||
}
|
||||
if (clip.max[2] > portals.portal[n].max[2]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
|
||||
for (unsigned int p = 0; p < portals.portal[n].point_count; p++)
|
||||
glVertex3fv(portals.portal[n].inner_point[p].p);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
}
|
162
contrib/prtview/portals.h
Normal file
162
contrib/prtview/portals.h
Normal file
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
PrtView plugin for GtkRadiant
|
||||
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
|
||||
|
||||
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 _PORTALS_H_
|
||||
#define _PORTALS_H_
|
||||
|
||||
#include <glib.h>
|
||||
#include "irender.h"
|
||||
#include "renderable.h"
|
||||
#include "math/vector.h"
|
||||
|
||||
|
||||
class CBspPoint {
|
||||
public:
|
||||
float p[3];
|
||||
};
|
||||
|
||||
class CBspPortal {
|
||||
public:
|
||||
CBspPortal();
|
||||
|
||||
~CBspPortal();
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
CBspPoint center;
|
||||
unsigned point_count;
|
||||
CBspPoint *point;
|
||||
CBspPoint *inner_point;
|
||||
float fp_color_random[4];
|
||||
float min[3];
|
||||
float max[3];
|
||||
float dist;
|
||||
bool hint;
|
||||
|
||||
bool Build(char *def);
|
||||
};
|
||||
|
||||
#ifdef PATH_MAX
|
||||
const int PRTVIEW_PATH_MAX = PATH_MAX;
|
||||
#else
|
||||
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 ) ) )
|
||||
#define GetRValue(rgb) ( (guint8)( rgb ) )
|
||||
#define GetGValue(rgb) ( (guint8)( ( (guint16)( rgb ) ) >> 8 ) )
|
||||
#define GetBValue(rgb) ( (guint8)( ( rgb ) >> 16 ) )
|
||||
|
||||
|
||||
class CPortals {
|
||||
public:
|
||||
|
||||
CPortals();
|
||||
|
||||
~CPortals();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
public:
|
||||
|
||||
void Load(); // use filename in fn
|
||||
void Purge();
|
||||
|
||||
void FixColors();
|
||||
|
||||
char fn[PRTVIEW_PATH_MAX];
|
||||
|
||||
int zbuffer;
|
||||
int polygons;
|
||||
int lines;
|
||||
bool show_3d;
|
||||
bool aa_3d;
|
||||
bool fog;
|
||||
PackedColour color_3d;
|
||||
float width_3d; // in 8'ths
|
||||
float fp_color_3d[4];
|
||||
PackedColour color_fog;
|
||||
float fp_color_fog[4];
|
||||
float trans_3d;
|
||||
float clip_range;
|
||||
bool clip;
|
||||
|
||||
bool show_2d;
|
||||
bool aa_2d;
|
||||
PackedColour color_2d;
|
||||
float width_2d; // in 8'ths
|
||||
float fp_color_2d[4];
|
||||
|
||||
CBspPortal *portal;
|
||||
int *portal_sort;
|
||||
bool hint_flags;
|
||||
// CBspNode *node;
|
||||
|
||||
unsigned int node_count;
|
||||
unsigned int portal_count;
|
||||
};
|
||||
|
||||
class CubicClipVolume {
|
||||
public:
|
||||
Vector3 cam, min, max;
|
||||
};
|
||||
|
||||
class CPortalsDrawSolid : public OpenGLRenderable {
|
||||
public:
|
||||
mutable CubicClipVolume clip;
|
||||
|
||||
void render(RenderStateFlags state) const;
|
||||
};
|
||||
|
||||
class CPortalsDrawSolidOutline : public OpenGLRenderable {
|
||||
public:
|
||||
mutable CubicClipVolume clip;
|
||||
|
||||
void render(RenderStateFlags state) const;
|
||||
};
|
||||
|
||||
class CPortalsDrawWireframe : public OpenGLRenderable {
|
||||
public:
|
||||
void render(RenderStateFlags state) const;
|
||||
};
|
||||
|
||||
class CPortalsRender : public Renderable {
|
||||
public:
|
||||
CPortalsDrawSolid m_drawSolid;
|
||||
CPortalsDrawSolidOutline m_drawSolidOutline;
|
||||
CPortalsDrawWireframe m_drawWireframe;
|
||||
|
||||
void renderSolid(Renderer &renderer, const VolumeTest &volume) const;
|
||||
|
||||
void renderWireframe(Renderer &renderer, const VolumeTest &volume) const;
|
||||
};
|
||||
|
||||
extern CPortals portals;
|
||||
extern CPortalsRender render;
|
||||
|
||||
void Portals_constructShaders();
|
||||
|
||||
void Portals_destroyShaders();
|
||||
|
||||
void Portals_shadersChanged();
|
||||
|
||||
|
||||
#endif // _PORTALS_H_
|
323
contrib/prtview/prtview.cpp
Normal file
323
contrib/prtview/prtview.cpp
Normal file
|
@ -0,0 +1,323 @@
|
|||
/*
|
||||
PrtView plugin for GtkRadiant
|
||||
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
|
||||
#include "prtview.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "profile/profile.h"
|
||||
|
||||
#include "qerplugin.h"
|
||||
#include "iscenegraph.h"
|
||||
#include "iglrender.h"
|
||||
#include "iplugin.h"
|
||||
#include "stream/stringstream.h"
|
||||
|
||||
#include "portals.h"
|
||||
#include "AboutDialog.h"
|
||||
#include "ConfigDialog.h"
|
||||
#include "LoadPortalFileDialog.h"
|
||||
|
||||
#define Q3R_CMD_SPLITTER "-"
|
||||
#define Q3R_CMD_ABOUT "About Portal Viewer"
|
||||
#define Q3R_CMD_LOAD "Load .prt file"
|
||||
#define Q3R_CMD_RELEASE "Unload .prt file"
|
||||
#define Q3R_CMD_SHOW_3D "Toggle portals (3D)"
|
||||
#define Q3R_CMD_SHOW_2D "Toggle portals (2D)"
|
||||
#define Q3R_CMD_OPTIONS "Configure Portal Viewer"
|
||||
|
||||
CopiedString INIfn;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPrtViewApp construction
|
||||
|
||||
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()
|
||||
{
|
||||
StringOutputStream tmp(64);
|
||||
tmp << GlobalRadiant().getSettingsPath() << "prtview.ini";
|
||||
INIfn = tmp.c_str();
|
||||
|
||||
portals.show_2d = INIGetInt(RENDER_2D, FALSE) ? true : false;
|
||||
portals.aa_2d = INIGetInt(AA_2D, FALSE) ? true : false;
|
||||
portals.width_2d = (float) INIGetInt(WIDTH_2D, 10);
|
||||
portals.color_2d = (PackedColour) INIGetInt(COLOR_2D, RGB(0, 0, 255)) & 0xFFFFFF;
|
||||
|
||||
if (portals.width_2d > 40.0f) {
|
||||
portals.width_2d = 40.0f;
|
||||
} else if (portals.width_2d < 2.0f) {
|
||||
portals.width_2d = 2.0f;
|
||||
}
|
||||
|
||||
portals.show_3d = INIGetInt(RENDER_3D, TRUE) ? true : false;
|
||||
|
||||
portals.zbuffer = INIGetInt(ZBUFFER, 1);
|
||||
portals.fog = INIGetInt(FOG, FALSE) ? true : false;
|
||||
portals.polygons = INIGetInt(POLYGON, TRUE);
|
||||
portals.lines = INIGetInt(LINE, TRUE);
|
||||
portals.aa_3d = INIGetInt(AA_3D, FALSE) ? true : false;
|
||||
portals.width_3d = (float) INIGetInt(WIDTH_3D, 4);
|
||||
portals.color_3d = (PackedColour) INIGetInt(COLOR_3D, RGB(255, 255, 0)) & 0xFFFFFF;
|
||||
portals.color_fog = (PackedColour) INIGetInt(COLOR_FOG, RGB(127, 127, 127)) & 0xFFFFFF;
|
||||
portals.trans_3d = (float) INIGetInt(TRANS_3D, 50);
|
||||
portals.clip = INIGetInt(CLIP, FALSE) ? true : false;
|
||||
portals.clip_range = (float) INIGetInt(CLIP_RANGE, 16);
|
||||
|
||||
if (portals.clip_range < 1) {
|
||||
portals.clip_range = 1;
|
||||
} else if (portals.clip_range > 128) {
|
||||
portals.clip_range = 128;
|
||||
}
|
||||
|
||||
if (portals.zbuffer < 0) {
|
||||
portals.zbuffer = 0;
|
||||
} else if (portals.zbuffer > 2) {
|
||||
portals.zbuffer = 0;
|
||||
}
|
||||
|
||||
if (portals.width_3d > 40.0f) {
|
||||
portals.width_3d = 40.0f;
|
||||
} else if (portals.width_3d < 2.0f) {
|
||||
portals.width_3d = 2.0f;
|
||||
}
|
||||
|
||||
if (portals.trans_3d > 100.0f) {
|
||||
portals.trans_3d = 100.0f;
|
||||
} else if (portals.trans_3d < 0.0f) {
|
||||
portals.trans_3d = 0.0f;
|
||||
}
|
||||
|
||||
SaveConfig();
|
||||
|
||||
portals.FixColors();
|
||||
|
||||
Portals_constructShaders();
|
||||
GlobalShaderCache().attachRenderable(render);
|
||||
}
|
||||
|
||||
void PrtView_destroy()
|
||||
{
|
||||
GlobalShaderCache().detachRenderable(render);
|
||||
Portals_destroyShaders();
|
||||
}
|
||||
|
||||
void SaveConfig()
|
||||
{
|
||||
INISetInt(RENDER_2D, portals.show_2d, "Draw in 2D windows");
|
||||
INISetInt(WIDTH_2D, (int) portals.width_2d, "Width of lines in 2D windows (in units of 1/2)");
|
||||
INISetInt(COLOR_2D, (int) portals.color_2d, "Color of lines in 2D windows");
|
||||
INISetInt(AA_2D, portals.aa_2d, "Draw lines in 2D window anti-aliased");
|
||||
|
||||
INISetInt(ZBUFFER, portals.zbuffer, "ZBuffer level in 3D window");
|
||||
INISetInt(FOG, portals.fog, "Use depth cueing in 3D window");
|
||||
INISetInt(POLYGON, portals.polygons, "Render using polygons polygons in 3D window");
|
||||
INISetInt(LINE, portals.polygons, "Render using lines in 3D window");
|
||||
INISetInt(RENDER_3D, portals.show_3d, "Draw in 3D windows");
|
||||
INISetInt(WIDTH_3D, (int) portals.width_3d, "Width of lines in 3D window (in units of 1/2)");
|
||||
INISetInt(COLOR_3D, (int) portals.color_3d, "Color of lines/polygons in 3D window");
|
||||
INISetInt(COLOR_FOG, (int) portals.color_fog, "Color of distant lines/polygons in 3D window");
|
||||
INISetInt(AA_3D, portals.aa_3d, "Draw lines in 3D window anti-aliased");
|
||||
INISetInt(TRANS_3D, (int) portals.trans_3d, "Transparency in 3d view (0 = solid, 100 = invisible)");
|
||||
INISetInt(CLIP, portals.clip, "Cubic clipper active for portal viewer");
|
||||
INISetInt(CLIP_RANGE, (int) portals.clip_range, "Portal viewer cubic clip distance (in units of 64)");
|
||||
}
|
||||
|
||||
|
||||
const char *CONFIG_SECTION = "Configuration";
|
||||
|
||||
int INIGetInt(const char *key, int def)
|
||||
{
|
||||
char value[1024];
|
||||
|
||||
if (read_var(INIfn.c_str(), CONFIG_SECTION, key, value)) {
|
||||
return atoi(value);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
void INISetInt(const char *key, int val, const char *comment /* = NULL */ )
|
||||
{
|
||||
char s[1000];
|
||||
|
||||
if (comment) {
|
||||
sprintf(s, "%d ; %s", val, comment);
|
||||
} else {
|
||||
sprintf(s, "%d", val);
|
||||
}
|
||||
save_var(INIfn.c_str(), CONFIG_SECTION, key, s);
|
||||
}
|
||||
|
||||
|
||||
// plugin name
|
||||
static const char *PLUGIN_NAME = "Portal Viewer";
|
||||
// commands in the menu
|
||||
static const char *PLUGIN_COMMANDS =
|
||||
Q3R_CMD_ABOUT ";"
|
||||
Q3R_CMD_SPLITTER ";"
|
||||
Q3R_CMD_OPTIONS ";"
|
||||
Q3R_CMD_SPLITTER ";"
|
||||
Q3R_CMD_SHOW_2D ";"
|
||||
Q3R_CMD_SHOW_3D ";"
|
||||
Q3R_CMD_SPLITTER ";"
|
||||
Q3R_CMD_RELEASE ";"
|
||||
Q3R_CMD_LOAD;
|
||||
|
||||
|
||||
const char *QERPlug_Init(void *hApp, void *pMainWidget)
|
||||
{
|
||||
return "Portal Viewer for WorldSpawn";
|
||||
}
|
||||
|
||||
const char *QERPlug_GetName()
|
||||
{
|
||||
return PLUGIN_NAME;
|
||||
}
|
||||
|
||||
const char *QERPlug_GetCommandList()
|
||||
{
|
||||
return PLUGIN_COMMANDS;
|
||||
}
|
||||
|
||||
|
||||
const char *QERPlug_GetCommandTitleList()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
void QERPlug_Dispatch(const char *p, float *vMin, float *vMax, bool bSingleBrush)
|
||||
{
|
||||
globalOutputStream() << MSG_PREFIX "Command \"" << p << "\"\n";
|
||||
|
||||
if (!strcmp(p, Q3R_CMD_ABOUT)) {
|
||||
DoAboutDlg();
|
||||
} else if (!strcmp(p, Q3R_CMD_LOAD)) {
|
||||
if (DoLoadPortalFileDialog() == IDOK) {
|
||||
portals.Load();
|
||||
SceneChangeNotify();
|
||||
} else {
|
||||
globalOutputStream() << MSG_PREFIX "Portal file load aborted.\n";
|
||||
}
|
||||
} else if (!strcmp(p, Q3R_CMD_RELEASE)) {
|
||||
portals.Purge();
|
||||
|
||||
SceneChangeNotify();
|
||||
|
||||
globalOutputStream() << MSG_PREFIX "Portals unloaded.\n";
|
||||
} else if (!strcmp(p, Q3R_CMD_SHOW_2D)) {
|
||||
portals.show_2d = !portals.show_2d;
|
||||
|
||||
SceneChangeNotify();
|
||||
SaveConfig();
|
||||
|
||||
if (portals.show_2d) {
|
||||
globalOutputStream() << MSG_PREFIX "Portals will be rendered in 2D view.\n";
|
||||
} else {
|
||||
globalOutputStream() << MSG_PREFIX "Portals will NOT be rendered in 2D view.\n";
|
||||
}
|
||||
} else if (!strcmp(p, Q3R_CMD_SHOW_3D)) {
|
||||
portals.show_3d = !portals.show_3d;
|
||||
SaveConfig();
|
||||
|
||||
SceneChangeNotify();
|
||||
|
||||
if (portals.show_3d) {
|
||||
globalOutputStream() << MSG_PREFIX "Portals will be rendered in 3D view.\n";
|
||||
} else {
|
||||
globalOutputStream() << MSG_PREFIX "Portals will NOT be rendered in 3D view.\n";
|
||||
}
|
||||
} else if (!strcmp(p, Q3R_CMD_OPTIONS)) {
|
||||
DoConfigDialog();
|
||||
SaveConfig();
|
||||
|
||||
SceneChangeNotify();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "modulesystem/singletonmodule.h"
|
||||
|
||||
class PrtViewPluginDependencies :
|
||||
public GlobalSceneGraphModuleRef,
|
||||
public GlobalRadiantModuleRef,
|
||||
public GlobalShaderCacheModuleRef,
|
||||
public GlobalOpenGLModuleRef,
|
||||
public GlobalOpenGLStateLibraryModuleRef {
|
||||
};
|
||||
|
||||
class PrtViewPluginModule {
|
||||
_QERPluginTable m_plugin;
|
||||
public:
|
||||
typedef _QERPluginTable Type;
|
||||
|
||||
STRING_CONSTANT(Name, "PRT Viewer");
|
||||
|
||||
PrtViewPluginModule()
|
||||
{
|
||||
m_plugin.m_pfnQERPlug_Init = QERPlug_Init;
|
||||
m_plugin.m_pfnQERPlug_GetName = QERPlug_GetName;
|
||||
m_plugin.m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
|
||||
m_plugin.m_pfnQERPlug_GetCommandTitleList = QERPlug_GetCommandTitleList;
|
||||
m_plugin.m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
|
||||
|
||||
PrtView_construct();
|
||||
}
|
||||
|
||||
~PrtViewPluginModule()
|
||||
{
|
||||
PrtView_destroy();
|
||||
}
|
||||
|
||||
_QERPluginTable *getTable()
|
||||
{
|
||||
return &m_plugin;
|
||||
}
|
||||
};
|
||||
|
||||
typedef SingletonModule<PrtViewPluginModule, PrtViewPluginDependencies> SingletonPrtViewPluginModule;
|
||||
|
||||
SingletonPrtViewPluginModule g_PrtViewPluginModule;
|
||||
|
||||
|
||||
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server)
|
||||
{
|
||||
initialiseModule(server);
|
||||
|
||||
g_PrtViewPluginModule.selfRegister();
|
||||
}
|
37
contrib/prtview/prtview.h
Normal file
37
contrib/prtview/prtview.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
PrtView plugin for GtkRadiant
|
||||
Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
#if !defined( INCLUDED_PRTVIEW_H )
|
||||
#define INCLUDED_PRTVIEW_H
|
||||
|
||||
#define MSG_PREFIX "Portal Viewer plugin: "
|
||||
|
||||
void InitInstance();
|
||||
|
||||
void SaveConfig();
|
||||
|
||||
int INIGetInt(const char *key, int def);
|
||||
|
||||
void INISetInt(const char *key, int val, const char *comment = 0);
|
||||
|
||||
const int IDOK = 1;
|
||||
const int IDCANCEL = 2;
|
||||
|
||||
|
||||
#endif
|
13
contrib/prtview/res/PrtView.rc2
Normal file
13
contrib/prtview/res/PrtView.rc2
Normal file
|
@ -0,0 +1,13 @@
|
|||
//
|
||||
// PRTVIEW.RC2 - resources Microsoft Visual C++ does not edit directly
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#error this file is not editable by Microsoft Visual C++
|
||||
#endif //APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Add manually edited resources here...
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
BIN
icon.png
Normal file
BIN
icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
48
include/CMakeLists.txt
Normal file
48
include/CMakeLists.txt
Normal file
|
@ -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
|
||||
)
|
1
include/aboutmsg.default
Normal file
1
include/aboutmsg.default
Normal file
|
@ -0,0 +1 @@
|
|||
Custom build based on trunk
|
4
include/aboutmsg.h
Normal file
4
include/aboutmsg.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Makefile appends preprocessor flags instead now
|
||||
#ifndef WorldSpawn_ABOUTMSG
|
||||
#error no WorldSpawn_ABOUTMSG defined
|
||||
#endif
|
66
include/crypt.h
Normal file
66
include/crypt.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* crypt.h -- base code for traditional PKWARE encryption
|
||||
Version 1.2.0, September 16th, 2017
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
Modifications for Info-ZIP crypting
|
||||
http://www.winimage.com/zLibDll/minizip.html
|
||||
Copyright (C) 2003 Terry Thorsen
|
||||
|
||||
This code is a modified version of crypting code in Info-ZIP distribution
|
||||
|
||||
Copyright (C) 1990-2000 Info-ZIP. All rights reserved.
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
#ifndef _MINICRYPT_H
|
||||
#define _MINICRYPT_H
|
||||
|
||||
#if ZLIB_VERNUM < 0x1270
|
||||
typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RAND_HEAD_LEN 12
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define zdecode(pkeys,pcrc_32_tab,c) \
|
||||
(update_keys(pkeys,pcrc_32_tab, c ^= decrypt_byte(pkeys)))
|
||||
|
||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||
(t = decrypt_byte(pkeys), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Return the next byte in the pseudo-random sequence */
|
||||
uint8_t decrypt_byte(uint32_t *pkeys);
|
||||
|
||||
/* Update the encryption keys with the next byte of plain text */
|
||||
uint8_t update_keys(uint32_t *pkeys, const z_crc_t *pcrc_32_tab, int32_t c);
|
||||
|
||||
/* Initialize the encryption keys and the random header according to the given password. */
|
||||
void init_keys(const char *passwd, uint32_t *pkeys, const z_crc_t *pcrc_32_tab);
|
||||
|
||||
#ifndef NOCRYPT
|
||||
/* Generate cryptographically secure random numbers */
|
||||
int cryptrand(unsigned char *buf, unsigned int len);
|
||||
|
||||
/* Create encryption header */
|
||||
int crypthead(const char *passwd, uint8_t *buf, int buf_size, uint32_t *pkeys,
|
||||
const z_crc_t *pcrc_32_tab, uint8_t verify1, uint8_t verify2);
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
71
include/cullable.h
Normal file
71
include/cullable.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_CULLABLE_H )
|
||||
#define INCLUDED_CULLABLE_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
template<typename Element> class BasicVector3;
|
||||
typedef BasicVector3<float> Vector3;
|
||||
class Plane3;
|
||||
class Matrix4;
|
||||
class AABB;
|
||||
class Segment;
|
||||
|
||||
template<typename Enumeration> class EnumeratedValue;
|
||||
struct VolumeIntersection;
|
||||
typedef EnumeratedValue<VolumeIntersection> VolumeIntersectionValue;
|
||||
|
||||
class VolumeTest
|
||||
{
|
||||
public:
|
||||
|
||||
/// \brief Returns true if \p point intersects volume.
|
||||
virtual bool TestPoint( const Vector3& point ) const = 0;
|
||||
/// \brief Returns true if \p segment intersects volume.
|
||||
virtual bool TestLine( const Segment& segment ) const = 0;
|
||||
/// \brief Returns true if \p plane faces towards volume.
|
||||
virtual bool TestPlane( const Plane3& plane ) const = 0;
|
||||
/// \brief Returns true if \p plane transformed by \p localToWorld faces the viewer.
|
||||
virtual bool TestPlane( const Plane3& plane, const Matrix4& localToWorld ) const = 0;
|
||||
/// \brief Returns the intersection of \p aabb and volume.
|
||||
virtual VolumeIntersectionValue TestAABB( const AABB& aabb ) const = 0;
|
||||
/// \brief Returns the intersection of \p aabb transformed by \p localToWorld and volume.
|
||||
virtual VolumeIntersectionValue TestAABB( const AABB& aabb, const Matrix4& localToWorld ) const = 0;
|
||||
|
||||
virtual bool fill() const = 0;
|
||||
|
||||
virtual const Matrix4& GetViewport() const = 0;
|
||||
virtual const Matrix4& GetProjection() const = 0;
|
||||
virtual const Matrix4& GetModelview() const = 0;
|
||||
};
|
||||
|
||||
class Cullable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Cullable" );
|
||||
|
||||
virtual VolumeIntersectionValue intersectVolume( const VolumeTest& test, const Matrix4& localToWorld ) const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
33
include/defaults.h
Normal file
33
include/defaults.h
Normal file
|
@ -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
|
91
include/dpkdeps.h
Normal file
91
include/dpkdeps.h
Normal file
|
@ -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
|
58
include/editable.h
Normal file
58
include/editable.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_EDITABLE_H )
|
||||
#define INCLUDED_EDITABLE_H
|
||||
|
||||
template<typename Element> class BasicVector3;
|
||||
typedef BasicVector3<float> Vector3;
|
||||
template<typename Element> class BasicVector4;
|
||||
typedef BasicVector4<float> Vector4;
|
||||
class Matrix4;
|
||||
typedef Vector4 Quaternion;
|
||||
|
||||
#include "scenelib.h"
|
||||
|
||||
class Editable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Editable" );
|
||||
|
||||
virtual const Matrix4& getLocalPivot() const = 0;
|
||||
};
|
||||
|
||||
inline Editable* Node_getEditable( scene::Node& node ){
|
||||
return NodeTypeCast<Editable>::cast( node );
|
||||
}
|
||||
|
||||
class Snappable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Snappable" );
|
||||
|
||||
virtual void snapto( float snap ) = 0;
|
||||
};
|
||||
|
||||
inline Snappable* Node_getSnappable( scene::Node& node ){
|
||||
return NodeTypeCast<Snappable>::cast( node );
|
||||
}
|
||||
|
||||
#endif
|
163
include/iarchive.h
Normal file
163
include/iarchive.h
Normal file
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IARCHIVE_H )
|
||||
#define INCLUDED_IARCHIVE_H
|
||||
|
||||
#include <cstddef>
|
||||
#include "generic/constant.h"
|
||||
|
||||
class InputStream;
|
||||
|
||||
/// \brief A file opened in binary mode.
|
||||
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.
|
||||
virtual std::size_t size() const = 0;
|
||||
/// \brief Returns the path to this file (relative to the filesystem root)
|
||||
virtual const char* getName() const = 0;
|
||||
/// \brief Returns the stream associated with this file.
|
||||
/// Subsequent calls return the same stream.
|
||||
/// The stream may be read forwards until it is exhausted.
|
||||
/// The stream remains valid for the lifetime of the file.
|
||||
virtual InputStream& getInputStream() = 0;
|
||||
};
|
||||
|
||||
class TextInputStream;
|
||||
|
||||
/// \brief A file opened in text mode.
|
||||
class ArchiveTextFile
|
||||
{
|
||||
public:
|
||||
virtual ~ArchiveTextFile() = default;
|
||||
/// \brief Destroys the file object.
|
||||
virtual void release() = 0;
|
||||
/// \brief Returns the stream associated with this file.
|
||||
/// Subsequent calls return the same stream.
|
||||
/// The stream may be read forwards until it is exhausted.
|
||||
/// The stream remains valid for the lifetime of the file.
|
||||
virtual TextInputStream& getInputStream() = 0;
|
||||
};
|
||||
|
||||
class ScopedArchiveFile
|
||||
{
|
||||
ArchiveFile& m_file;
|
||||
public:
|
||||
ScopedArchiveFile( ArchiveFile& file ) : m_file( file ){
|
||||
}
|
||||
~ScopedArchiveFile(){
|
||||
m_file.release();
|
||||
}
|
||||
};
|
||||
|
||||
class CustomArchiveVisitor;
|
||||
|
||||
class Archive
|
||||
{
|
||||
public:
|
||||
virtual ~Archive() = default;
|
||||
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* name ) = 0;
|
||||
};
|
||||
|
||||
typedef CustomArchiveVisitor VisitorFunc;
|
||||
|
||||
enum EMode
|
||||
{
|
||||
eFiles = 0x01,
|
||||
eDirectories = 0x02,
|
||||
eFilesAndDirectories = 0x03,
|
||||
};
|
||||
|
||||
/// \brief Destroys the archive object.
|
||||
/// Any unreleased file object associated with the archive remains valid. */
|
||||
virtual void release() = 0;
|
||||
/// \brief Returns a new object associated with the file identified by \p name, or 0 if the file cannot be opened.
|
||||
/// Name comparisons are case-insensitive.
|
||||
virtual ArchiveFile* openFile( const char* name ) = 0;
|
||||
/// \brief Returns a new object associated with the file identified by \p name, or 0 if the file cannot be opened.
|
||||
/// Name comparisons are case-insensitive.
|
||||
virtual ArchiveTextFile* openTextFile( const char* name ) = 0;
|
||||
/// Returns true if the file identified by \p name can be opened.
|
||||
/// Name comparisons are case-insensitive.
|
||||
virtual bool containsFile( const char* name ) = 0;
|
||||
/// \brief Performs a depth-first traversal of the archive tree starting at \p root.
|
||||
/// Traverses the entire tree if \p root is "".
|
||||
/// When a file is encountered, calls \c visitor.file passing the file name.
|
||||
/// When a directory is encountered, calls \c visitor.directory passing the directory name.
|
||||
/// Skips the directory if \c visitor.directory returned true.
|
||||
/// Root comparisons are case-insensitive.
|
||||
/// Names are mixed-case.
|
||||
virtual void forEachFile( VisitorFunc visitor, const char* root ) = 0;
|
||||
};
|
||||
|
||||
class CustomArchiveVisitor
|
||||
{
|
||||
Archive::Visitor* m_visitor;
|
||||
Archive::EMode m_mode;
|
||||
std::size_t m_depth;
|
||||
public:
|
||||
CustomArchiveVisitor( Archive::Visitor& visitor, Archive::EMode mode, std::size_t depth )
|
||||
: m_visitor( &visitor ), m_mode( mode ), m_depth( depth ){
|
||||
}
|
||||
void file( const char* name ){
|
||||
if ( ( m_mode & Archive::eFiles ) != 0 ) {
|
||||
m_visitor->visit( name );
|
||||
}
|
||||
}
|
||||
bool directory( const char* name, std::size_t depth ){
|
||||
if ( ( m_mode & Archive::eDirectories ) != 0 ) {
|
||||
m_visitor->visit( name );
|
||||
}
|
||||
if ( depth == m_depth ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
typedef Archive* ( *PFN_OPENARCHIVE )( const char* name );
|
||||
|
||||
class _QERArchiveTable
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "archive" );
|
||||
|
||||
PFN_OPENARCHIVE m_pfnOpenArchive;
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class Modules;
|
||||
typedef Modules<_QERArchiveTable> ArchiveModules;
|
||||
|
||||
template<typename Type>
|
||||
class ModulesRef;
|
||||
typedef ModulesRef<_QERArchiveTable> ArchiveModulesRef;
|
||||
|
||||
#endif
|
126
include/ibrush.h
Normal file
126
include/ibrush.h
Normal file
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IBRUSH_H )
|
||||
#define INCLUDED_IBRUSH_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
#include "generic/vector.h"
|
||||
#include "itexdef.h"
|
||||
|
||||
namespace scene
|
||||
{
|
||||
class Node;
|
||||
}
|
||||
|
||||
#if 0
|
||||
class IBrushFace
|
||||
{
|
||||
public:
|
||||
virtual const char* GetShader() const = 0;
|
||||
virtual void SetShader( const char* name ) = 0;
|
||||
virtual const TextureProjection& GetTexdef() const = 0;
|
||||
virtual void GetTexdef( TextureProjection& projection ) const = 0;
|
||||
virtual void SetTexdef( const TextureProjection& projection ) = 0;
|
||||
virtual void GetFlags( ContentsFlagsValue& flags ) const = 0;
|
||||
virtual void SetFlags( const ContentsFlagsValue& flags ) = 0;
|
||||
virtual void ShiftTexdef( float s, float t ) = 0;
|
||||
virtual void ScaleTexdef( float s, float t ) = 0;
|
||||
virtual void RotateTexdef( float angle ) = 0;
|
||||
virtual void FitTexture( float s_repeat, float t_repeat ) = 0;
|
||||
virtual bool isDetail() const = 0;
|
||||
virtual void setDetail( bool detail ) = 0;
|
||||
};
|
||||
|
||||
class IBrush
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "IBrush" );
|
||||
virtual void reserve( std::size_t count ) = 0;
|
||||
virtual void clear() = 0;
|
||||
virtual void copy( const IBrush& other ) = 0;
|
||||
virtual IBrushFace* addPlane( const Vector3& p0, const Vector3& p1, const Vector3& p2, const char* shader, const TextureProjection& projection ) = 0;
|
||||
virtual const AABB& localAABB() const = 0;
|
||||
virtual void removeEmptyFaces() = 0;
|
||||
};
|
||||
|
||||
class IBrushFaceInstance
|
||||
{
|
||||
public:
|
||||
virtual IBrushFace& getFace() = 0;
|
||||
virtual const IBrushFace& getFace() const = 0;
|
||||
virtual bool isSelected() const = 0;
|
||||
virtual void setSelected( SelectionSystem::EComponentMode mode, bool select ) const = 0;
|
||||
};
|
||||
|
||||
class IBrushInstance
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "IBrushInstance" );
|
||||
virtual void forEachFaceInstance( const BrushInstanceVisitor& visitor ) = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
class _QERFaceData
|
||||
{
|
||||
public:
|
||||
_QERFaceData() : m_shader( "" ), contents( 0 ), flags( 0 ), value( 0 ){
|
||||
}
|
||||
Vector3 m_p0;
|
||||
Vector3 m_p1;
|
||||
Vector3 m_p2;
|
||||
texdef_t m_texdef;
|
||||
const char* m_shader;
|
||||
int contents;
|
||||
int flags;
|
||||
int value;
|
||||
};
|
||||
|
||||
typedef Callback<void(const _QERFaceData&)> BrushFaceDataCallback;
|
||||
|
||||
class BrushCreator
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "brush" );
|
||||
virtual scene::Node& createBrush() = 0;
|
||||
virtual EBrushType getBrushType() = 0;
|
||||
virtual void setBrushType(EBrushType t) = 0;
|
||||
virtual void Brush_forEachFace( scene::Node& brush, const BrushFaceDataCallback& callback ) = 0;
|
||||
virtual bool Brush_addFace( scene::Node& brush, const _QERFaceData& faceData ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<BrushCreator> GlobalBrushModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<BrushCreator> GlobalBrushModuleRef;
|
||||
|
||||
inline BrushCreator& GlobalBrushCreator(){
|
||||
return GlobalBrushModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
67
include/icamera.h
Normal file
67
include/icamera.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// camera interface
|
||||
//
|
||||
|
||||
#if !defined( INCLUDED_ICAMERA_H )
|
||||
#define INCLUDED_ICAMERA_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
|
||||
class Matrix4;
|
||||
|
||||
class CameraView
|
||||
{
|
||||
public:
|
||||
virtual void setModelview( const Matrix4& modelview ) = 0;
|
||||
virtual void setFieldOfView( float fieldOfView ) = 0;
|
||||
};
|
||||
|
||||
class CameraModel
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "CameraModel" );
|
||||
virtual void setCameraView( CameraView* view, const Callback<void()>& disconnect ) = 0;
|
||||
};
|
||||
|
||||
template<typename Element> class BasicVector3;
|
||||
typedef BasicVector3<float> Vector3;
|
||||
|
||||
typedef void ( *PFN_GETCAMERA )( Vector3& origin, Vector3& angles );
|
||||
typedef void ( *PFN_SETCAMERA )( const Vector3& origin, const Vector3& angles );
|
||||
typedef void ( *PFN_GETCAMWINDOWEXTENTS )( int *x, int *y, int *width, int *height );
|
||||
|
||||
struct _QERCameraTable
|
||||
{
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "camera" );
|
||||
|
||||
PFN_GETCAMERA m_pfnGetCamera;
|
||||
PFN_SETCAMERA m_pfnSetCamera;
|
||||
PFN_GETCAMWINDOWEXTENTS m_pfnGetCamWindowExtents;
|
||||
};
|
||||
|
||||
#endif
|
83
include/idatastream.h
Normal file
83
include/idatastream.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IDATASTREAM_H )
|
||||
#define INCLUDED_IDATASTREAM_H
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
class StreamBase
|
||||
{
|
||||
public:
|
||||
typedef std::size_t size_type;
|
||||
typedef unsigned char byte_type;
|
||||
};
|
||||
|
||||
/// \brief A read-only byte-stream.
|
||||
class InputStream : public StreamBase
|
||||
{
|
||||
public:
|
||||
/// \brief Attempts to read the next \p length bytes from the stream to \p buffer.
|
||||
/// Returns the number of bytes actually stored in \p buffer.
|
||||
virtual size_type read( byte_type* buffer, size_type length ) = 0;
|
||||
};
|
||||
|
||||
/// \brief A write-only byte-stream.
|
||||
class OutputStream : public StreamBase
|
||||
{
|
||||
public:
|
||||
/// \brief Attempts to write \p length bytes to the stream from \p buffer.
|
||||
/// Returns the number of bytes actually read from \p buffer.
|
||||
virtual size_type write( const byte_type* buffer, size_type length ) = 0;
|
||||
};
|
||||
|
||||
class SeekableStream
|
||||
{
|
||||
public:
|
||||
typedef int offset_type;
|
||||
typedef std::size_t position_type;
|
||||
|
||||
enum seekdir
|
||||
{
|
||||
beg,
|
||||
cur,
|
||||
end,
|
||||
};
|
||||
|
||||
/// \brief Sets the current \p position of the stream relative to the start.
|
||||
virtual position_type seek( position_type position ) = 0;
|
||||
/// \brief Sets the current \p position of the stream relative to either the start, end or current position.
|
||||
virtual position_type seek( offset_type offset, seekdir direction ) = 0;
|
||||
/// \brief Returns the current position of the stream.
|
||||
virtual position_type tell() const = 0;
|
||||
};
|
||||
|
||||
/// \brief A seekable read-only byte-stream.
|
||||
class SeekableInputStream : public InputStream, public SeekableStream
|
||||
{
|
||||
};
|
||||
|
||||
/// \brief A seekable write-only byte-stream.
|
||||
class SeekableOutputStream : public OutputStream, public SeekableStream
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
117
include/ieclass.h
Normal file
117
include/ieclass.h
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
/// \file ieclass.h
|
||||
/// \brief Entity Class definition loader API.
|
||||
|
||||
|
||||
#if !defined( INCLUDED_IECLASS_H )
|
||||
#define INCLUDED_IECLASS_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
#define MAX_FLAGS 16
|
||||
|
||||
// eclass show flags
|
||||
|
||||
#define ECLASS_LIGHT 0x00000001
|
||||
#define ECLASS_ANGLE 0x00000002
|
||||
#define ECLASS_PATH 0x00000004
|
||||
#define ECLASS_MISCMODEL 0x00000008
|
||||
|
||||
class Shader;
|
||||
|
||||
class EntityClass;
|
||||
class ListAttributeType;
|
||||
|
||||
class EntityClassCollector
|
||||
{
|
||||
public:
|
||||
virtual void insert( EntityClass* eclass ) = 0;
|
||||
virtual void insert( const char* name, const ListAttributeType& list ){
|
||||
}
|
||||
};
|
||||
|
||||
struct EntityClassScanner
|
||||
{
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "eclass" );
|
||||
|
||||
void ( *scanFile )( EntityClassCollector& collector, const char* filename );
|
||||
const char* ( *getExtension )( );
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class ModuleRef;
|
||||
typedef ModuleRef<EntityClassScanner> EClassModuleRef;
|
||||
|
||||
template<typename Type>
|
||||
class Modules;
|
||||
typedef Modules<EntityClassScanner> EClassModules;
|
||||
|
||||
template<typename Type>
|
||||
class ModulesRef;
|
||||
typedef ModulesRef<EntityClassScanner> EClassModulesRef;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class EntityClassVisitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( EntityClass* eclass ) = 0;
|
||||
};
|
||||
|
||||
class ModuleObserver;
|
||||
|
||||
|
||||
struct EntityClassManager
|
||||
{
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "eclassmanager" );
|
||||
|
||||
EntityClass* ( *findOrInsert )( const char* name, bool has_brushes );
|
||||
const ListAttributeType* ( *findListType )(const char* name);
|
||||
void ( *forEach )( EntityClassVisitor& visitor );
|
||||
void ( *forEachPoint )( EntityClassVisitor& visitor ); /* eukara */
|
||||
void ( *attach )( ModuleObserver& observer );
|
||||
void ( *detach )( ModuleObserver& observer );
|
||||
void ( *realise )();
|
||||
void ( *unrealise )();
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<EntityClassManager> GlobalEntityClassManagerModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<EntityClassManager> GlobalEntityClassManagerModuleRef;
|
||||
|
||||
inline EntityClassManager& GlobalEntityClassManager(){
|
||||
return GlobalEntityClassManagerModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
151
include/ientity.h
Normal file
151
include/ientity.h
Normal file
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IENTITY_H )
|
||||
#define INCLUDED_IENTITY_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
#include "string/string.h"
|
||||
#include "scenelib.h"
|
||||
|
||||
class EntityClass;
|
||||
|
||||
typedef Callback<void(const char*)> KeyObserver;
|
||||
|
||||
class EntityKeyValue
|
||||
{
|
||||
public:
|
||||
virtual ~EntityKeyValue() = default;
|
||||
virtual const char* c_str() const = 0;
|
||||
virtual void assign( const char* other ) = 0;
|
||||
virtual void attach( const KeyObserver& observer ) = 0;
|
||||
virtual void detach( const KeyObserver& observer ) = 0;
|
||||
};
|
||||
|
||||
class Entity
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Entity" );
|
||||
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
virtual void insert( const char* key, EntityKeyValue& value ) = 0;
|
||||
virtual void erase( const char* key, EntityKeyValue& value ) = 0;
|
||||
virtual void clear() { };
|
||||
};
|
||||
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* key, const char* value ) = 0;
|
||||
};
|
||||
|
||||
virtual const EntityClass& getEntityClass() const = 0;
|
||||
virtual void forEachKeyValue( Visitor& visitor ) const = 0;
|
||||
virtual void setKeyValue( const char* key, const char* value ) = 0;
|
||||
virtual const char* getKeyValue( const char* key ) const = 0;
|
||||
virtual int getKeyEntries( void ) const = 0;
|
||||
virtual bool isContainer() const = 0;
|
||||
virtual void attach( Observer& observer ) = 0;
|
||||
virtual void detach( Observer& observer ) = 0;
|
||||
};
|
||||
|
||||
class EntityCopyingVisitor : public Entity::Visitor
|
||||
{
|
||||
Entity& m_entity;
|
||||
public:
|
||||
EntityCopyingVisitor( Entity& entity )
|
||||
: m_entity( entity ){
|
||||
}
|
||||
|
||||
void visit( const char* key, const char* value ){
|
||||
if ( !string_equal( key, "classname" ) ) {
|
||||
m_entity.setKeyValue( key, value );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline Entity* Node_getEntity( scene::Node& node ){
|
||||
return NodeTypeCast<Entity>::cast( node );
|
||||
}
|
||||
|
||||
|
||||
template<typename value_type>
|
||||
class Stack;
|
||||
template<typename Contained>
|
||||
class Reference;
|
||||
|
||||
namespace scene
|
||||
{
|
||||
class Node;
|
||||
}
|
||||
|
||||
typedef Reference<scene::Node> NodeReference;
|
||||
|
||||
namespace scene
|
||||
{
|
||||
typedef Stack<NodeReference> Path;
|
||||
}
|
||||
|
||||
class Counter;
|
||||
|
||||
class EntityCreator
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 2 );
|
||||
STRING_CONSTANT( Name, "entity" );
|
||||
|
||||
virtual scene::Node& createEntity( EntityClass* eclass ) = 0;
|
||||
|
||||
typedef void ( *KeyValueChangedFunc )();
|
||||
virtual void setKeyValueChangedFunc( KeyValueChangedFunc func ) = 0;
|
||||
|
||||
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() const = 0;
|
||||
virtual void setShowNames( bool showNames ) = 0;
|
||||
virtual bool getShowNames() = 0;
|
||||
virtual void setShowAngles( bool showAngles ) = 0;
|
||||
virtual bool getShowAngles() = 0;
|
||||
|
||||
virtual void printStatistics() const = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<EntityCreator> GlobalEntityModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<EntityCreator> GlobalEntityModuleRef;
|
||||
|
||||
inline EntityCreator& GlobalEntityCreator(){
|
||||
return GlobalEntityModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
134
include/ifilesystem.h
Normal file
134
include/ifilesystem.h
Normal file
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IFILESYSTEM_H )
|
||||
#define INCLUDED_IFILESYSTEM_H
|
||||
|
||||
#include <cstddef>
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
|
||||
typedef Callback<void(const char*)> ArchiveNameCallback;
|
||||
typedef Callback<void(const char*)> FileNameCallback;
|
||||
|
||||
class ArchiveFile;
|
||||
class ArchiveTextFile;
|
||||
class Archive;
|
||||
|
||||
class ModuleObserver;
|
||||
|
||||
typedef struct _GSList GSList;
|
||||
|
||||
/// The Virtual File System.
|
||||
class VirtualFileSystem
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "VFS" );
|
||||
|
||||
/// \brief Adds a root search \p path.
|
||||
/// Called before \c initialise.
|
||||
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;
|
||||
|
||||
/// \brief Returns the file identified by \p filename opened in binary mode, or 0 if not found.
|
||||
/// The caller must \c release() the file returned if it is not 0.
|
||||
virtual ArchiveFile* openFile( const char* filename ) = 0;
|
||||
/// \brief Returns the file identified by \p filename opened in text mode, or 0 if not found.
|
||||
/// The caller must \c release() the file returned if it is not 0.
|
||||
virtual ArchiveTextFile* openTextFile( const char* filename ) = 0;
|
||||
|
||||
/// \brief Opens the file identified by \p filename and reads it into \p buffer, or sets *\p buffer to 0 if not found.
|
||||
/// Returns the size of the buffer allocated, or undefined value if *\p buffer is 0;
|
||||
/// The caller must free the allocated buffer by calling \c freeFile
|
||||
/// \deprecated Deprecated - use \c openFile.
|
||||
virtual std::size_t loadFile( const char *filename, void **buffer ) = 0;
|
||||
/// \brief Frees the buffer returned by \c loadFile.
|
||||
/// \deprecated Deprecated.
|
||||
virtual void freeFile( void *p ) = 0;
|
||||
|
||||
/// \brief Calls \p callback for each directory under \p basedir.
|
||||
virtual void forEachDirectory( const char* basedir, const FileNameCallback& callback, std::size_t depth = 1 ) = 0;
|
||||
/// \brief Calls \p callback for each file under \p basedir matching \p extension.
|
||||
/// Use "*" as \p extension to match all file extensions.
|
||||
virtual void forEachFile( const char* basedir, const char* extension, const FileNameCallback& callback, std::size_t depth = 1 ) = 0;
|
||||
|
||||
/// \brief Returns a list containing the relative names of all the directories under \p basedir.
|
||||
/// The caller must free the returned list by calling \c clearFileDirList;
|
||||
/// \deprecated Deprecated - use \c forEachDirectory.
|
||||
virtual GSList* getDirList( const char *basedir ) = 0;
|
||||
/// \brief Returns a list containing the relative names of the files under \p basedir (\p extension can be "*" for all files).
|
||||
/// The caller must free the returned list by calling \c clearFileDirList.
|
||||
/// \deprecated Deprecated - use \c forEachFile.
|
||||
virtual GSList* getFileList( const char *basedir, const char *extension ) = 0;
|
||||
/// \brief Frees the \p list returned from \c getDirList or \c getFileList.
|
||||
/// \deprecated Deprecated.
|
||||
virtual void clearFileDirList( GSList **list ) = 0;
|
||||
|
||||
/// \brief Returns the absolute filename for a relative \p name, or "" if not found.
|
||||
virtual const char* findFile( const char* name ) = 0;
|
||||
/// \brief Returns the filesystem root for an absolute \p name, or "" if not found.
|
||||
/// This can be used to convert an absolute name to a relative name.
|
||||
virtual const char* findRoot( const char* name ) = 0;
|
||||
|
||||
/// \brief Attach an \p observer whose realise() and unrealise() methods will be called when the filesystem is initialised or shut down.
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
/// \brief Detach an \p observer previously-attached by calling \c attach.
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
|
||||
virtual Archive* getArchive( const char* archiveName, bool pakonly = true ) = 0;
|
||||
virtual void forEachArchive( const ArchiveNameCallback& callback, bool pakonly = true, bool reverse = false ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<VirtualFileSystem> GlobalFileSystemModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<VirtualFileSystem> GlobalFileSystemModuleRef;
|
||||
|
||||
inline VirtualFileSystem& GlobalFileSystem(){
|
||||
return GlobalFileSystemModule::getTable();
|
||||
}
|
||||
|
||||
|
||||
/// \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 ){
|
||||
GlobalFileSystem().freeFile( p );
|
||||
}
|
||||
|
||||
#endif
|
76
include/ifiletypes.h
Normal file
76
include/ifiletypes.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IFILETYPES_H )
|
||||
#define INCLUDED_IFILETYPES_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
class filetype_t
|
||||
{
|
||||
public:
|
||||
filetype_t()
|
||||
: name( "" ), pattern( "" ){
|
||||
}
|
||||
filetype_t( const char* _name, const char* _pattern, bool _can_load = true, bool _can_import = true, bool _can_save = true )
|
||||
: name( _name ), pattern( _pattern ), can_load( _can_load ), can_import( _can_import ), can_save( _can_save ){
|
||||
}
|
||||
const char* name;
|
||||
const char* pattern;
|
||||
bool can_load;
|
||||
bool can_import;
|
||||
bool can_save;
|
||||
};
|
||||
|
||||
|
||||
class IFileTypeList
|
||||
{
|
||||
public:
|
||||
virtual void addType( const char* moduleName, filetype_t type ) = 0;
|
||||
};
|
||||
|
||||
class IFileTypeRegistry
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "filetypes" );
|
||||
|
||||
virtual void addType( const char* moduleType, const char* moduleName, filetype_t type ) = 0;
|
||||
virtual void getTypeList( const char* moduleType, IFileTypeList* typelist, bool want_load = false, bool want_import = false, bool want_save = false ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<IFileTypeRegistry> GlobalFiletypesModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<IFileTypeRegistry> GlobalFiletypesModuleRef;
|
||||
|
||||
inline IFileTypeRegistry& GlobalFiletypes(){
|
||||
return GlobalFiletypesModule::getTable();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
89
include/ifilter.h
Normal file
89
include/ifilter.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IFILTER_H )
|
||||
#define INCLUDED_IFILTER_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
enum
|
||||
{
|
||||
EXCLUDE_WORLD = 0x00000001,
|
||||
EXCLUDE_ENT = 0x00000002,
|
||||
EXCLUDE_CURVES = 0x00000004,
|
||||
EXCLUDE_TRANSLUCENT = 0x00000008,
|
||||
EXCLUDE_LIQUIDS = 0x00000010,
|
||||
EXCLUDE_CAULK = 0x00000020,
|
||||
EXCLUDE_CLIP = 0x00000040,
|
||||
EXCLUDE_PATHS = 0x00000080,
|
||||
EXCLUDE_LIGHTS = 0x00000100,
|
||||
EXCLUDE_DETAILS = 0x00000200,
|
||||
EXCLUDE_HINTSSKIPS = 0x00000400,
|
||||
EXCLUDE_MODELS = 0x00000800,
|
||||
EXCLUDE_AREAPORTALS = 0x00001000,
|
||||
EXCLUDE_TRIGGERS = 0x00002000,
|
||||
EXCLUDE_CLUSTERPORTALS = 0x00004000,
|
||||
EXCLUDE_TERRAIN = 0x00008000,
|
||||
EXCLUDE_LIGHTGRID = 0x00010000,
|
||||
EXCLUDE_STRUCTURAL = 0x00020000,
|
||||
EXCLUDE_BOTCLIP = 0x00040000,
|
||||
EXCLUDE_VISPORTALS = 0x00080000,
|
||||
EXCLUDE_DECALS = 0x00100000,
|
||||
EXCLUDE_GROUP = 0x00200000,
|
||||
};
|
||||
|
||||
class Filter
|
||||
{
|
||||
public:
|
||||
virtual void setActive( bool active ) = 0;
|
||||
};
|
||||
|
||||
class Filterable
|
||||
{
|
||||
public:
|
||||
virtual void updateFiltered() = 0;
|
||||
};
|
||||
|
||||
class FilterSystem
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "filters" );
|
||||
virtual void addFilter( Filter& filter, int mask ) = 0;
|
||||
virtual void registerFilterable( Filterable& filterable ) = 0;
|
||||
virtual void unregisterFilterable( Filterable& filterable ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<FilterSystem> GlobalFilterModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<FilterSystem> GlobalFilterModuleRef;
|
||||
|
||||
inline FilterSystem& GlobalFilterSystem(){
|
||||
return GlobalFilterModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
2816
include/igl.h
Normal file
2816
include/igl.h
Normal file
File diff suppressed because it is too large
Load diff
128
include/iglrender.h
Normal file
128
include/iglrender.h
Normal file
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IGLRENDER_H )
|
||||
#define INCLUDED_IGLRENDER_H
|
||||
|
||||
#include "igl.h"
|
||||
#include "generic/vector.h"
|
||||
class AABB;
|
||||
class Matrix4;
|
||||
|
||||
|
||||
class GLProgram
|
||||
{
|
||||
public:
|
||||
virtual void enable() = 0;
|
||||
virtual void disable() = 0;
|
||||
virtual void setParameters( const Vector3& viewer, const Matrix4& localToWorld, const Vector3& origin, const Vector3& colour, const Matrix4& world2light ) = 0;
|
||||
};
|
||||
|
||||
class OpenGLFogState
|
||||
{
|
||||
public:
|
||||
OpenGLFogState() : mode( GL_EXP ), density( 0 ), start( 0 ), end( 0 ), index( 0 ), colour( 1, 1, 1, 1 ){
|
||||
}
|
||||
GLenum mode;
|
||||
GLfloat density;
|
||||
GLfloat start;
|
||||
GLfloat end;
|
||||
GLint index;
|
||||
Vector4 colour;
|
||||
};
|
||||
|
||||
//! A collection of opengl state information.
|
||||
class OpenGLState
|
||||
{
|
||||
public:
|
||||
enum ESort
|
||||
{
|
||||
eSortFirst = 0,
|
||||
eSortOpaque = 1,
|
||||
eSortMultiFirst = 2,
|
||||
eSortMultiLast = 1023,
|
||||
eSortOverbrighten = 1024,
|
||||
eSortFullbright = 1025,
|
||||
eSortHighlight = 1026,
|
||||
eSortTranslucent = 1027,
|
||||
eSortOverlayFirst = 1028,
|
||||
eSortOverlayLast = 2047,
|
||||
eSortControlFirst = 2048,
|
||||
eSortControlLast = 3071,
|
||||
eSortGUI0 = 3072,
|
||||
eSortGUI1 = 3073,
|
||||
eSortLast = 4096,
|
||||
};
|
||||
|
||||
unsigned int m_state;
|
||||
std::size_t m_sort;
|
||||
GLint m_texture;
|
||||
GLint m_texture1;
|
||||
GLint m_texture2;
|
||||
GLint m_texture3;
|
||||
GLint m_texture4;
|
||||
GLint m_texture5;
|
||||
GLint m_texture6;
|
||||
GLint m_texture7;
|
||||
Vector4 m_colour;
|
||||
GLenum m_blend_src, m_blend_dst;
|
||||
GLenum m_depthfunc;
|
||||
GLenum m_alphafunc;
|
||||
GLfloat m_alpharef;
|
||||
GLfloat m_linewidth;
|
||||
GLfloat m_pointsize;
|
||||
GLint m_linestipple_factor;
|
||||
GLint m_polygonoffset;
|
||||
GLushort m_linestipple_pattern;
|
||||
OpenGLFogState m_fog;
|
||||
GLProgram* m_program;
|
||||
|
||||
OpenGLState() : m_program( 0 ){
|
||||
}
|
||||
};
|
||||
|
||||
class OpenGLStateLibrary
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "openglshaderlibrary" );
|
||||
|
||||
virtual void getDefaultState( OpenGLState& state ) const = 0;
|
||||
|
||||
virtual void insert( const char* name, const OpenGLState& state ) = 0;
|
||||
virtual void erase( const char* name ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<OpenGLStateLibrary> GlobalOpenGLStateLibraryModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<OpenGLStateLibrary> GlobalOpenGLStateLibraryModuleRef;
|
||||
|
||||
inline OpenGLStateLibrary& GlobalOpenGLStateLibrary(){
|
||||
return GlobalOpenGLStateLibraryModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
42
include/igtkgl.h
Normal file
42
include/igtkgl.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IGTKGL_H )
|
||||
#define INCLUDED_IGTKGL_H
|
||||
|
||||
#include <uilib/uilib.h>
|
||||
#include "generic/constant.h"
|
||||
|
||||
template<class T>
|
||||
using func = T *;
|
||||
|
||||
struct _QERGtkGLTable {
|
||||
STRING_CONSTANT(Name, "gtkgl");
|
||||
INTEGER_CONSTANT(Version, 1);
|
||||
|
||||
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
|
73
include/iimage.h
Normal file
73
include/iimage.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IIMAGE_H )
|
||||
#define INCLUDED_IIMAGE_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
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;
|
||||
virtual unsigned int getHeight() const = 0;
|
||||
|
||||
virtual int getSurfaceFlags() const {
|
||||
return 0;
|
||||
}
|
||||
virtual int getContentFlags() const {
|
||||
return 0;
|
||||
}
|
||||
virtual int getValue() const {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class ArchiveFile;
|
||||
|
||||
struct _QERPlugImageTable
|
||||
{
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "image" );
|
||||
|
||||
/// Read an image from the file.
|
||||
/// Returns 0 if the image could not be read.
|
||||
Image* ( *loadImage )( ArchiveFile & file );
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class ModuleRef;
|
||||
typedef ModuleRef<_QERPlugImageTable> ImageModuleRef;
|
||||
|
||||
template<typename Type>
|
||||
class Modules;
|
||||
typedef Modules<_QERPlugImageTable> ImageModules;
|
||||
|
||||
template<typename Type>
|
||||
class ModulesRef;
|
||||
typedef ModulesRef<_QERPlugImageTable> ImageModulesRef;
|
||||
|
||||
#endif // _IIMAGE_H
|
83
include/imap.h
Normal file
83
include/imap.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IMAP_H )
|
||||
#define INCLUDED_IMAP_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
class Tokeniser;
|
||||
class TokenWriter;
|
||||
|
||||
/// \brief A node whose state can be imported from a token stream.
|
||||
class MapImporter
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "MapImporter" );
|
||||
|
||||
virtual bool importTokens( Tokeniser& tokeniser ) = 0;
|
||||
};
|
||||
|
||||
/// \brief A node whose state can be exported to a token stream.
|
||||
class MapExporter
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "MapExporter" );
|
||||
|
||||
virtual void exportTokens( TokenWriter& writer ) const = 0;
|
||||
};
|
||||
|
||||
#include "iscenegraph.h"
|
||||
|
||||
class EntityCreator;
|
||||
|
||||
class TextInputStream;
|
||||
class TextOutputStream;
|
||||
|
||||
|
||||
typedef void ( *GraphTraversalFunc )( scene::Node& root, const scene::Traversable::Walker& walker );
|
||||
|
||||
/// \brief A module that reads and writes a map in a specific format.
|
||||
class MapFormat
|
||||
{
|
||||
public:
|
||||
virtual ~MapFormat() = default;
|
||||
INTEGER_CONSTANT( Version, 2 );
|
||||
STRING_CONSTANT( Name, "map" );
|
||||
mutable bool wrongFormat;
|
||||
|
||||
/// \brief Read a map graph into \p root from \p outputStream, using \p entityTable to create entities.
|
||||
virtual void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const = 0;
|
||||
/// \brief Write the map graph obtained by applying \p traverse to \p root into \p outputStream.
|
||||
virtual void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const = 0;
|
||||
};
|
||||
|
||||
|
||||
template<typename Type>
|
||||
class Modules;
|
||||
typedef Modules<MapFormat> MapModules;
|
||||
|
||||
template<typename Type>
|
||||
class ModulesRef;
|
||||
typedef ModulesRef<MapFormat> MapModulesRef;
|
||||
|
||||
|
||||
#endif
|
50
include/imodel.h
Normal file
50
include/imodel.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IMODEL_H )
|
||||
#define INCLUDED_IMODEL_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
namespace scene
|
||||
{
|
||||
class Node;
|
||||
}
|
||||
|
||||
class ArchiveFile;
|
||||
|
||||
class ModelLoader
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "model" );
|
||||
virtual scene::Node& loadModel( ArchiveFile& file ) = 0;
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class Modules;
|
||||
typedef Modules<ModelLoader> ModelModules;
|
||||
|
||||
template<typename Type>
|
||||
class ModulesRef;
|
||||
typedef ModulesRef<ModelLoader> ModelModulesRef;
|
||||
|
||||
#endif /* _IMODEL_H_ */
|
52
include/ioapi_buf.h
Normal file
52
include/ioapi_buf.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* ioapi_buf.h -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
This version of ioapi is designed to buffer IO.
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
#ifndef _IOAPI_BUF_H
|
||||
#define _IOAPI_BUF_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zlib.h"
|
||||
#include "ioapi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
voidpf ZCALLBACK fopen_buf_func(voidpf opaque, const char* filename, int mode);
|
||||
voidpf ZCALLBACK fopen64_buf_func(voidpf opaque, const void* filename, int mode);
|
||||
voidpf ZCALLBACK fopendisk_buf_func(voidpf opaque, voidpf stream_cd, uint32_t number_disk, int mode);
|
||||
voidpf ZCALLBACK fopendisk64_buf_func(voidpf opaque, voidpf stream_cd, uint32_t number_disk, int mode);
|
||||
uint32_t ZCALLBACK fread_buf_func(voidpf opaque, voidpf stream, void* buf, uint32_t size);
|
||||
uint32_t ZCALLBACK fwrite_buf_func(voidpf opaque, voidpf stream, const void* buf, uint32_t size);
|
||||
long ZCALLBACK ftell_buf_func(voidpf opaque, voidpf stream);
|
||||
uint64_t ZCALLBACK ftell64_buf_func(voidpf opaque, voidpf stream);
|
||||
long ZCALLBACK fseek_buf_func(voidpf opaque, voidpf stream, uint32_t offset, int origin);
|
||||
long ZCALLBACK fseek64_buf_func(voidpf opaque, voidpf stream, uint64_t offset, int origin);
|
||||
int ZCALLBACK fclose_buf_func(voidpf opaque,voidpf stream);
|
||||
int ZCALLBACK ferror_buf_func(voidpf opaque,voidpf stream);
|
||||
|
||||
typedef struct ourbuffer_s {
|
||||
zlib_filefunc_def filefunc;
|
||||
zlib_filefunc64_def filefunc64;
|
||||
} ourbuffer_t;
|
||||
|
||||
void fill_buffer_filefunc(zlib_filefunc_def* pzlib_filefunc_def, ourbuffer_t *ourbuf);
|
||||
void fill_buffer_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def, ourbuffer_t *ourbuf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
52
include/ioapi_mem.h
Normal file
52
include/ioapi_mem.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* ioapi_mem.h -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
This version of ioapi is designed to access memory rather than files.
|
||||
We do use a region of memory to put data in to and take it out of.
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri (https://github.com/nmoinvaz/minizip)
|
||||
(C) 2003 Justin Fletcher
|
||||
(C) 1998-2003 Gilles Vollant
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
#ifndef _IOAPI_MEM_H
|
||||
#define _IOAPI_MEM_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zlib.h"
|
||||
#include "ioapi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
voidpf ZCALLBACK fopen_mem_func(voidpf opaque, const char* filename, int mode);
|
||||
voidpf ZCALLBACK fopendisk_mem_func(voidpf opaque, voidpf stream, uint32_t number_disk, int mode);
|
||||
uint32_t ZCALLBACK fread_mem_func(voidpf opaque, voidpf stream, void* buf, uint32_t size);
|
||||
uint32_t ZCALLBACK fwrite_mem_func(voidpf opaque, voidpf stream, const void* buf, uint32_t size);
|
||||
long ZCALLBACK ftell_mem_func(voidpf opaque, voidpf stream);
|
||||
long ZCALLBACK fseek_mem_func(voidpf opaque, voidpf stream, uint32_t offset, int origin);
|
||||
int ZCALLBACK fclose_mem_func(voidpf opaque, voidpf stream);
|
||||
int ZCALLBACK ferror_mem_func(voidpf opaque, voidpf stream);
|
||||
|
||||
typedef struct ourmemory_s {
|
||||
char *base; /* Base of the region of memory we're using */
|
||||
uint32_t size; /* Size of the region of memory we're using */
|
||||
uint32_t limit; /* Furthest we've written */
|
||||
uint32_t cur_offset; /* Current offset in the area */
|
||||
int grow; /* Growable memory buffer */
|
||||
} ourmemory_t;
|
||||
|
||||
void fill_memory_filefunc(zlib_filefunc_def* pzlib_filefunc_def, ourmemory_t *ourmem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
257
include/ipatch.h
Normal file
257
include/ipatch.h
Normal file
|
@ -0,0 +1,257 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IPATCH_H )
|
||||
#define INCLUDED_IPATCH_H
|
||||
|
||||
#include "globaldefs.h"
|
||||
#include "debugging/debugging.h"
|
||||
#include "generic/constant.h"
|
||||
#include "generic/vector.h"
|
||||
|
||||
namespace scene
|
||||
{
|
||||
class Node;
|
||||
}
|
||||
|
||||
template<typename Element>
|
||||
class ArrayReference
|
||||
{
|
||||
std::size_t m_size;
|
||||
Element* m_data;
|
||||
public:
|
||||
typedef Element value_type;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
|
||||
ArrayReference()
|
||||
: m_size( 0 ), m_data( 0 ){
|
||||
}
|
||||
ArrayReference( std::size_t size, Element* data )
|
||||
: m_size( size ), m_data( data ){
|
||||
}
|
||||
|
||||
iterator begin(){
|
||||
return m_data;
|
||||
}
|
||||
const_iterator begin() const {
|
||||
return m_data;
|
||||
}
|
||||
iterator end(){
|
||||
return m_data + m_size;
|
||||
}
|
||||
const_iterator end() const {
|
||||
return m_data + m_size;
|
||||
}
|
||||
|
||||
value_type& operator[]( std::size_t index ){
|
||||
#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 GDEF_DEBUG
|
||||
ASSERT_MESSAGE( index < size(), "array index out of bounds" );
|
||||
#endif
|
||||
return m_data[index];
|
||||
}
|
||||
value_type* data(){
|
||||
return m_data;
|
||||
}
|
||||
const value_type* data() const {
|
||||
return m_data;
|
||||
}
|
||||
std::size_t size() const {
|
||||
return m_size;
|
||||
}
|
||||
bool empty() const {
|
||||
return m_size == 0;
|
||||
}
|
||||
};
|
||||
|
||||
#if 0
|
||||
template<typename Element>
|
||||
class MatrixIterator
|
||||
{
|
||||
Element* m_position;
|
||||
|
||||
void increment(){
|
||||
++m_position;
|
||||
}
|
||||
|
||||
public:
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef difference_type distance_type;
|
||||
typedef KeyValue<Key, Value> value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef value_type& reference;
|
||||
|
||||
MatrixIterator( Element* position ) : m_position( position ){
|
||||
}
|
||||
|
||||
Element* position(){
|
||||
return m_position;
|
||||
}
|
||||
|
||||
bool operator==( const MatrixIterator& other ) const {
|
||||
return m_position == other.m_position;
|
||||
}
|
||||
bool operator!=( const MatrixIterator& other ) const {
|
||||
return !operator==( other );
|
||||
}
|
||||
MatrixIterator& operator++(){
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
MatrixIterator operator++( int ){
|
||||
MatrixIterator tmp = *this;
|
||||
increment();
|
||||
return tmp;
|
||||
}
|
||||
value_type& operator*() const {
|
||||
return m_position->m_value;
|
||||
}
|
||||
value_type* operator->() const {
|
||||
return &( operator*() );
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename Element>
|
||||
class Matrix
|
||||
{
|
||||
std::size_t m_x, m_y;
|
||||
Element* m_data;
|
||||
public:
|
||||
typedef Element value_type;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
|
||||
Matrix()
|
||||
: m_x( 0 ), m_y( 0 ), m_data( 0 ){
|
||||
}
|
||||
Matrix( std::size_t x, std::size_t y, Element* data )
|
||||
: m_x( x ), m_y( y ), m_data( data ){
|
||||
}
|
||||
|
||||
iterator begin(){
|
||||
return m_data;
|
||||
}
|
||||
const_iterator begin() const {
|
||||
return m_data;
|
||||
}
|
||||
iterator end(){
|
||||
return m_data + size();
|
||||
}
|
||||
const_iterator end() const {
|
||||
return m_data + size();
|
||||
}
|
||||
|
||||
value_type& operator[]( std::size_t index ){
|
||||
#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 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 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 GDEF_DEBUG
|
||||
ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" );
|
||||
#endif
|
||||
return m_data[x * m_y + y];
|
||||
}
|
||||
value_type* data(){
|
||||
return m_data;
|
||||
}
|
||||
const value_type* data() const {
|
||||
return m_data;
|
||||
}
|
||||
std::size_t x() const {
|
||||
return m_x;
|
||||
}
|
||||
std::size_t y() const {
|
||||
return m_y;
|
||||
}
|
||||
std::size_t size() const {
|
||||
return m_x * m_y;
|
||||
}
|
||||
bool empty() const {
|
||||
return m_x == 0;
|
||||
}
|
||||
};
|
||||
|
||||
class PatchControl
|
||||
{
|
||||
public:
|
||||
Vector3 m_vertex;
|
||||
Vector2 m_texcoord;
|
||||
Vector4 m_color;
|
||||
};
|
||||
|
||||
typedef Matrix<PatchControl> PatchControlMatrix;
|
||||
|
||||
|
||||
class PatchCreator
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "patch" );
|
||||
virtual scene::Node& createPatch(bool def3, bool ws) = 0;
|
||||
virtual void Patch_undoSave( scene::Node& patch ) const = 0;
|
||||
virtual void Patch_resize( scene::Node& patch, std::size_t width, std::size_t height ) const = 0;
|
||||
virtual PatchControlMatrix Patch_getControlPoints( scene::Node& patch ) const = 0;
|
||||
virtual void Patch_controlPointsChanged( scene::Node& patch ) const = 0;
|
||||
virtual const char* Patch_getShader( scene::Node& patch ) const = 0;
|
||||
virtual void Patch_setShader( scene::Node& patch, const char* shader ) const = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class ModuleRef;
|
||||
typedef ModuleRef<PatchCreator> PatchModuleRef;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<PatchCreator> GlobalPatchModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<PatchCreator> GlobalPatchModuleRef;
|
||||
|
||||
inline PatchCreator& GlobalPatchCreator(){
|
||||
return GlobalPatchModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
53
include/iplugin.h
Normal file
53
include/iplugin.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
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_IPLUGIN_H )
|
||||
#define INCLUDED_IPLUGIN_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
typedef const char* ( *PFN_QERPLUG_INIT )( void* hApp, void* pMainWidget );
|
||||
typedef const char* ( *PFN_QERPLUG_GETNAME )();
|
||||
typedef const char* ( *PFN_QERPLUG_GETCOMMANDLIST )();
|
||||
typedef const char* ( *PFN_QERPLUG_GETCOMMANDTITLELIST )();
|
||||
typedef void ( *PFN_QERPLUG_DISPATCH )( const char* p, float* vMin, float* vMax, bool bSingleBrush );
|
||||
|
||||
struct _QERPluginTable
|
||||
{
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "plugin" );
|
||||
|
||||
PFN_QERPLUG_INIT m_pfnQERPlug_Init;
|
||||
PFN_QERPLUG_GETNAME m_pfnQERPlug_GetName;
|
||||
PFN_QERPLUG_GETCOMMANDLIST m_pfnQERPlug_GetCommandList;
|
||||
PFN_QERPLUG_GETCOMMANDTITLELIST m_pfnQERPlug_GetCommandTitleList;
|
||||
PFN_QERPLUG_DISPATCH m_pfnQERPlug_Dispatch;
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class Modules;
|
||||
typedef Modules<_QERPluginTable> PluginModules;
|
||||
|
||||
template<typename Type>
|
||||
class ModulesRef;
|
||||
typedef ModulesRef<_QERPluginTable> PluginModulesRef;
|
||||
|
||||
#endif
|
77
include/ireference.h
Normal file
77
include/ireference.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IREFERENCE_H )
|
||||
#define INCLUDED_IREFERENCE_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
namespace scene
|
||||
{
|
||||
class Node;
|
||||
}
|
||||
|
||||
class ModuleObserver;
|
||||
|
||||
class Resource
|
||||
{
|
||||
public:
|
||||
virtual bool load() = 0;
|
||||
virtual bool save() = 0;
|
||||
virtual void flush() = 0;
|
||||
virtual void refresh() = 0;
|
||||
virtual scene::Node* getNode() = 0;
|
||||
virtual void setNode( scene::Node* node ) = 0;
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
};
|
||||
|
||||
class EntityCreator;
|
||||
|
||||
class ReferenceCache
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "reference" );
|
||||
|
||||
virtual Resource* capture( const char* path ) = 0;
|
||||
virtual void release( const char* path ) = 0;
|
||||
|
||||
virtual void setEntityCreator( EntityCreator& entityCreator ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<ReferenceCache> GlobalReferenceModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<ReferenceCache> GlobalReferenceModuleRef;
|
||||
|
||||
inline ReferenceCache& GlobalReferenceCache(){
|
||||
return GlobalReferenceModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
177
include/irender.h
Normal file
177
include/irender.h
Normal file
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IRENDER_H )
|
||||
#define INCLUDED_IRENDER_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
|
||||
|
||||
// Rendering states to sort by.
|
||||
// Higher bits have the most effect - slowest state changes should be highest.
|
||||
|
||||
const unsigned int RENDER_DEFAULT = 0;
|
||||
const unsigned int RENDER_LINESTIPPLE = 1 << 0; // glEnable(GL_LINE_STIPPLE)
|
||||
const unsigned int RENDER_LINESMOOTH = 1 << 1; // glEnable(GL_LINE_SMOOTH)
|
||||
const unsigned int RENDER_POLYGONSTIPPLE = 1 << 2; // glEnable(GL_POLYGON_STIPPLE)
|
||||
const unsigned int RENDER_POLYGONSMOOTH = 1 << 3; // glEnable(GL_POLYGON_SMOOTH)
|
||||
const unsigned int RENDER_ALPHATEST = 1 << 4; // glEnable(GL_ALPHA_TEST)
|
||||
const unsigned int RENDER_DEPTHTEST = 1 << 5; // glEnable(GL_DEPTH_TEST)
|
||||
const unsigned int RENDER_DEPTHWRITE = 1 << 6; // glDepthMask(GL_TRUE)
|
||||
const unsigned int RENDER_COLOURWRITE = 1 << 7; // glColorMask(GL_TRUE; GL_TRUE; GL_TRUE; GL_TRUE)
|
||||
const unsigned int RENDER_CULLFACE = 1 << 8; // glglEnable(GL_CULL_FACE)
|
||||
const unsigned int RENDER_SCALED = 1 << 9; // glEnable(GL_NORMALIZE)
|
||||
const unsigned int RENDER_SMOOTH = 1 << 10; // glShadeModel
|
||||
const unsigned int RENDER_FOG = 1 << 11; // glEnable(GL_FOG)
|
||||
const unsigned int RENDER_LIGHTING = 1 << 12; // glEnable(GL_LIGHTING)
|
||||
const unsigned int RENDER_BLEND = 1 << 13; // glEnable(GL_BLEND)
|
||||
const unsigned int RENDER_OFFSETLINE = 1 << 14; // glEnable(GL_POLYGON_OFFSET_LINE)
|
||||
const unsigned int RENDER_FILL = 1 << 15; // glPolygonMode
|
||||
const unsigned int RENDER_COLOURARRAY = 1 << 16; // glEnableClientState(GL_COLOR_ARRAY)
|
||||
const unsigned int RENDER_COLOURCHANGE = 1 << 17; // render() is allowed to call glColor*()
|
||||
const unsigned int RENDER_TEXTURE = 1 << 18; // glEnable(GL_TEXTURE_2D)
|
||||
const unsigned int RENDER_BUMP = 1 << 19;
|
||||
const unsigned int RENDER_PROGRAM = 1 << 20;
|
||||
const unsigned int RENDER_SCREEN = 1 << 21;
|
||||
const unsigned int RENDER_OVERRIDE = 1 << 22;
|
||||
const unsigned int RENDER_POLYOFS = 1 << 23; // glEnable(GL_POLYGON_OFFSET_FILL)
|
||||
typedef unsigned int RenderStateFlags;
|
||||
|
||||
|
||||
class AABB;
|
||||
class Matrix4;
|
||||
|
||||
template<typename Element> class BasicVector3;
|
||||
typedef BasicVector3<float> Vector3;
|
||||
|
||||
class Shader;
|
||||
|
||||
class RendererLight
|
||||
{
|
||||
public:
|
||||
virtual Shader* getShader() const = 0;
|
||||
virtual const AABB& aabb() const = 0;
|
||||
virtual bool testAABB( const AABB& other ) const = 0;
|
||||
virtual const Matrix4& rotation() const = 0;
|
||||
virtual const Vector3& offset() const = 0;
|
||||
virtual const Vector3& colour() const = 0;
|
||||
virtual bool isProjected() const = 0;
|
||||
virtual const Matrix4& projection() const = 0;
|
||||
};
|
||||
|
||||
class LightCullable
|
||||
{
|
||||
public:
|
||||
virtual bool testLight( const RendererLight& light ) const = 0;
|
||||
virtual void insertLight( const RendererLight& light ){
|
||||
}
|
||||
virtual void clearLights(){
|
||||
}
|
||||
};
|
||||
|
||||
class Renderable;
|
||||
typedef Callback<void(const Renderable&)> RenderableCallback;
|
||||
|
||||
typedef Callback<void(const RendererLight&)> RendererLightCallback;
|
||||
|
||||
class LightList
|
||||
{
|
||||
public:
|
||||
virtual void evaluateLights() const = 0;
|
||||
virtual void lightsChanged() const = 0;
|
||||
virtual void forEachLight( const RendererLightCallback& callback ) const = 0;
|
||||
};
|
||||
|
||||
const int c_attr_TexCoord0 = 1;
|
||||
const int c_attr_Tangent = 3;
|
||||
const int c_attr_Binormal = 4;
|
||||
|
||||
class OpenGLRenderable
|
||||
{
|
||||
public:
|
||||
virtual ~OpenGLRenderable() = default;
|
||||
virtual void render( RenderStateFlags state ) const = 0;
|
||||
};
|
||||
|
||||
class Matrix4;
|
||||
struct qtexture_t;
|
||||
class ModuleObserver;
|
||||
|
||||
#include "generic/vector.h"
|
||||
|
||||
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;
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
virtual qtexture_t& getTexture() const = 0;
|
||||
virtual unsigned int getFlags() const = 0;
|
||||
};
|
||||
|
||||
class ShaderCache
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "renderstate" );
|
||||
|
||||
virtual Shader* capture( const char* name ) = 0;
|
||||
virtual void release( const char* name ) = 0;
|
||||
/*! Render all Shader objects. */
|
||||
virtual void render( RenderStateFlags globalstate, const Matrix4& modelview, const Matrix4& projection, const Vector3& viewer = Vector3( 0, 0, 0 ) ) = 0;
|
||||
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
|
||||
virtual bool lightingSupported() const = 0;
|
||||
virtual bool useShaderLanguage() const = 0;
|
||||
|
||||
virtual const LightList& attach( LightCullable& cullable ) = 0;
|
||||
virtual void detach( LightCullable& cullable ) = 0;
|
||||
virtual void changed( LightCullable& cullable ) = 0;
|
||||
virtual void attach( RendererLight& light ) = 0;
|
||||
virtual void detach( RendererLight& light ) = 0;
|
||||
virtual void changed( RendererLight& light ) = 0;
|
||||
|
||||
virtual void attachRenderable( const Renderable& renderable ) = 0;
|
||||
virtual void detachRenderable( const Renderable& renderable ) = 0;
|
||||
virtual void forEachRenderable( const RenderableCallback& callback ) const = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<ShaderCache> GlobalShaderCacheModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<ShaderCache> GlobalShaderCacheModuleRef;
|
||||
|
||||
inline ShaderCache& GlobalShaderCache(){
|
||||
return GlobalShaderCacheModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
215
include/iscenegraph.h
Normal file
215
include/iscenegraph.h
Normal file
|
@ -0,0 +1,215 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_ISCENEGRAPH_H )
|
||||
#define INCLUDED_ISCENEGRAPH_H
|
||||
|
||||
#include <cstddef>
|
||||
#include "generic/constant.h"
|
||||
#include "signal/signalfwd.h"
|
||||
|
||||
template<typename value_type>
|
||||
class Stack;
|
||||
template<typename Contained>
|
||||
class Reference;
|
||||
|
||||
namespace scene
|
||||
{
|
||||
class Instance;
|
||||
const Instance* const nullInstancePointer = 0;
|
||||
inline const Instance& nullInstance(){
|
||||
return *nullInstancePointer;
|
||||
}
|
||||
|
||||
class Node;
|
||||
const Node* const nullNodePointer = 0;
|
||||
inline const Node& nullNode(){
|
||||
return *nullNodePointer;
|
||||
}
|
||||
}
|
||||
|
||||
typedef Reference<scene::Node> NodeReference;
|
||||
|
||||
typedef std::size_t TypeId;
|
||||
|
||||
const TypeId NODETYPEID_MAX = 64;
|
||||
const TypeId NODETYPEID_NONE = NODETYPEID_MAX;
|
||||
|
||||
const TypeId INSTANCETYPEID_MAX = 64;
|
||||
const TypeId INSTANCETYPEID_NONE = INSTANCETYPEID_MAX;
|
||||
|
||||
namespace scene
|
||||
{
|
||||
/// \brief A unique key to an instance of a node in the scene-graph.
|
||||
typedef Stack<NodeReference> Path;
|
||||
|
||||
/// \brief A scene-graph - a Directed Acyclic Graph (DAG).
|
||||
///
|
||||
/// - Each node may refer to zero or more 'child' nodes (directed).
|
||||
/// - A node may never have itself as one of its ancestors (acyclic).
|
||||
/// - Each node may have more than one 'parent', thus having more than one 'instance' in the graph.
|
||||
/// - Each instance is uniquely identified by the list of its ancestors plus itself, known as a 'path'.
|
||||
class Graph
|
||||
{
|
||||
public:
|
||||
virtual ~Graph() = default;
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "scenegraph" );
|
||||
|
||||
class Walker
|
||||
{
|
||||
public:
|
||||
/// \brief Called before traversing the first child-instance of 'instance'. If the return value is false, the children of the current instance are not traversed.
|
||||
virtual bool pre( const Path& path, Instance& instance ) const = 0;
|
||||
/// \brief Called after traversing the last child-instance of 'instance'.
|
||||
virtual void post( const Path& path, Instance& instance ) const {
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief Returns the root-node of the graph.
|
||||
virtual Node& root() = 0;
|
||||
/// \brief Sets the root-node of the graph to be 'node'.
|
||||
virtual void insert_root( Node& root ) = 0;
|
||||
/// \brief Clears the root-node of the graph.
|
||||
virtual void erase_root() = 0;
|
||||
/// \brief Traverses all nodes in the graph depth-first, starting from the root node.
|
||||
virtual void traverse( const Walker& walker ) = 0;
|
||||
/// \brief Traverses all nodes in the graph depth-first, starting from 'start'.
|
||||
virtual void traverse_subgraph( const Walker& walker, const Path& start ) = 0;
|
||||
/// \brief Returns the instance at the location identified by 'path', or 0 if it does not exist.
|
||||
virtual scene::Instance* find( const Path& path ) = 0;
|
||||
|
||||
/// \brief Invokes all scene-changed callbacks. Called when any part of the scene changes the way it will appear when the scene is rendered.
|
||||
/// \todo Move to a separate class.
|
||||
virtual void sceneChanged() = 0;
|
||||
/// \brief Add a \p callback to be invoked when the scene changes.
|
||||
/// \todo Move to a separate class.
|
||||
virtual void addSceneChangedCallback( const SignalHandler& handler ) = 0;
|
||||
|
||||
/// \brief Invokes all bounds-changed callbacks. Called when the bounds of any instance in the scene change.
|
||||
/// \todo Move to a separate class.
|
||||
virtual void boundsChanged() = 0;
|
||||
/// \brief Add a \p callback to be invoked when the bounds of any instance in the scene change.
|
||||
virtual SignalHandlerId addBoundsChangedCallback( const SignalHandler& boundsChanged ) = 0;
|
||||
/// \brief Remove a \p callback to be invoked when the bounds of any instance in the scene change.
|
||||
virtual void removeBoundsChangedCallback( SignalHandlerId id ) = 0;
|
||||
|
||||
virtual TypeId getNodeTypeId( const char* name ) = 0;
|
||||
virtual TypeId getInstanceTypeId( const char* name ) = 0;
|
||||
};
|
||||
|
||||
class Traversable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "scene::Traversable" );
|
||||
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
/// \brief Called when a node is added to the container.
|
||||
virtual void insert( Node& node ) = 0;
|
||||
/// \brief Called when a node is removed from the container.
|
||||
virtual void erase( Node& node ) = 0;
|
||||
};
|
||||
|
||||
class Walker
|
||||
{
|
||||
public:
|
||||
/// \brief Called before traversing the first child-node of 'node'. If the return value is false, the children of the current node are not traversed.
|
||||
virtual bool pre( Node& node ) const = 0;
|
||||
/// \brief Called after traversing the last child-node of 'node'.
|
||||
virtual void post( Node& node ) const {
|
||||
}
|
||||
};
|
||||
/// \brief Adds a node to the container.
|
||||
virtual void insert( Node& node ) = 0;
|
||||
/// \brief Removes a node from the container.
|
||||
virtual void erase( Node& node ) = 0;
|
||||
/// \brief Traverses the subgraphs rooted at each node in the container, depth-first.
|
||||
virtual void traverse( const Walker& walker ) = 0;
|
||||
/// \brief Returns true if the container contains no nodes.
|
||||
virtual bool empty() const = 0;
|
||||
};
|
||||
|
||||
class Instantiable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "scene::Instantiable" );
|
||||
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
/// \brief Called when an instance is added to the container.
|
||||
virtual void insert( scene::Instance* instance ) = 0;
|
||||
/// \brief Called when an instance is removed from the container.
|
||||
virtual void erase( scene::Instance* instance ) = 0;
|
||||
};
|
||||
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( Instance& instance ) const = 0;
|
||||
};
|
||||
|
||||
/// \brief Returns a new instance uniquely identified by 'path'.
|
||||
virtual scene::Instance* create( const scene::Path& path, scene::Instance* parent ) = 0;
|
||||
/// \brief Calls Visitor::visit(instance) for each instance in the container.
|
||||
virtual void forEachInstance( const Visitor& visitor ) = 0;
|
||||
/// \brief Adds an instance to the container.
|
||||
virtual void insert( Observer* observer, const Path& path, scene::Instance* instance ) = 0;
|
||||
/// \brief Returns an instance removed from the container.
|
||||
virtual scene::Instance* erase( Observer* observer, const Path& path ) = 0;
|
||||
};
|
||||
|
||||
class Cloneable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "scene::Cloneable" );
|
||||
|
||||
/// \brief Returns a copy of itself.
|
||||
virtual scene::Node& clone() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<scene::Graph> GlobalSceneGraphModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<scene::Graph> GlobalSceneGraphModuleRef;
|
||||
|
||||
inline scene::Graph& GlobalSceneGraph(){
|
||||
return GlobalSceneGraphModule::getTable();
|
||||
}
|
||||
|
||||
inline void AddSceneChangeCallback( const SignalHandler& handler ){
|
||||
GlobalSceneGraph().addSceneChangedCallback( handler );
|
||||
}
|
||||
inline void SceneChangeNotify(){
|
||||
GlobalSceneGraph().sceneChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
86
include/iscriplib.h
Normal file
86
include/iscriplib.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_ISCRIPLIB_H )
|
||||
#define INCLUDED_ISCRIPLIB_H
|
||||
|
||||
/// \file iscriplib.h
|
||||
/// \brief Token input/output stream module.
|
||||
|
||||
#include <cstddef>
|
||||
#include "generic/constant.h"
|
||||
|
||||
#define MAXTOKEN 1024
|
||||
|
||||
class Tokeniser
|
||||
{
|
||||
public:
|
||||
virtual ~Tokeniser() = default;
|
||||
virtual void release() = 0;
|
||||
virtual void nextLine() = 0;
|
||||
virtual const char* getToken() = 0;
|
||||
virtual void ungetToken() = 0;
|
||||
virtual std::size_t getLine() const = 0;
|
||||
virtual std::size_t getColumn() const = 0;
|
||||
};
|
||||
|
||||
class TextInputStream;
|
||||
|
||||
class TokenWriter
|
||||
{
|
||||
public:
|
||||
virtual ~TokenWriter() = default;
|
||||
virtual void release() = 0;
|
||||
virtual void nextLine() = 0;
|
||||
virtual void writeToken( const char* token ) = 0;
|
||||
virtual void writeString( const char* string ) = 0;
|
||||
virtual void writeInteger( int i ) = 0;
|
||||
virtual void writeUnsigned( std::size_t i ) = 0;
|
||||
virtual void writeFloat( double f ) = 0;
|
||||
};
|
||||
|
||||
class TextOutputStream;
|
||||
|
||||
struct _QERScripLibTable
|
||||
{
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "scriptlib" );
|
||||
|
||||
Tokeniser& ( *m_pfnNewScriptTokeniser )( TextInputStream & istream );
|
||||
Tokeniser& ( *m_pfnNewSimpleTokeniser )( TextInputStream & istream );
|
||||
TokenWriter& ( *m_pfnNewSimpleTokenWriter )( TextOutputStream & ostream );
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<_QERScripLibTable> GlobalScripLibModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<_QERScripLibTable> GlobalScripLibModuleRef;
|
||||
|
||||
inline _QERScripLibTable& GlobalScriptLibrary(){
|
||||
return GlobalScripLibModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
145
include/iselection.h
Normal file
145
include/iselection.h
Normal file
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_ISELECTION_H )
|
||||
#define INCLUDED_ISELECTION_H
|
||||
|
||||
#include <cstddef>
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
#include "signal/signalfwd.h"
|
||||
|
||||
class Renderer;
|
||||
class View;
|
||||
|
||||
class Selectable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Selectable" );
|
||||
|
||||
virtual void setSelected( bool select ) = 0;
|
||||
virtual bool isSelected() const = 0;
|
||||
};
|
||||
|
||||
namespace scene
|
||||
{
|
||||
class Instance;
|
||||
}
|
||||
|
||||
class InstanceSelectionObserver
|
||||
{
|
||||
public:
|
||||
virtual void onSelectedChanged( scene::Instance& instance ) = 0;
|
||||
};
|
||||
|
||||
template<typename Element> class BasicVector3;
|
||||
typedef BasicVector3<float> Vector3;
|
||||
template<typename Element> class BasicVector4;
|
||||
typedef BasicVector4<float> Vector4;
|
||||
class Matrix4;
|
||||
typedef Vector4 Quaternion;
|
||||
|
||||
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" );
|
||||
|
||||
enum EMode
|
||||
{
|
||||
eEntity,
|
||||
ePrimitive,
|
||||
eComponent,
|
||||
};
|
||||
|
||||
enum EComponentMode
|
||||
{
|
||||
eDefault,
|
||||
eVertex,
|
||||
eEdge,
|
||||
eFace,
|
||||
};
|
||||
|
||||
enum EManipulatorMode
|
||||
{
|
||||
eTranslate,
|
||||
eRotate,
|
||||
eScale,
|
||||
eDrag,
|
||||
eClip,
|
||||
};
|
||||
|
||||
virtual void SetMode( EMode mode ) = 0;
|
||||
virtual EMode Mode() const = 0;
|
||||
virtual void SetComponentMode( EComponentMode mode ) = 0;
|
||||
virtual EComponentMode ComponentMode() const = 0;
|
||||
virtual void SetManipulatorMode( EManipulatorMode mode ) = 0;
|
||||
virtual EManipulatorMode ManipulatorMode() const = 0;
|
||||
|
||||
virtual SelectionChangeCallback getObserver( EMode mode ) = 0;
|
||||
virtual std::size_t countSelected() const = 0;
|
||||
virtual std::size_t countSelectedComponents() const = 0;
|
||||
virtual void onSelectedChanged( scene::Instance& instance, const Selectable& selectable ) = 0;
|
||||
virtual void onComponentSelection( scene::Instance& instance, const Selectable& selectable ) = 0;
|
||||
virtual scene::Instance& ultimateSelected() const = 0;
|
||||
virtual scene::Instance& penultimateSelected() const = 0;
|
||||
virtual void setSelectedAll( bool selected ) = 0;
|
||||
virtual void setSelectedAllComponents( bool selected ) = 0;
|
||||
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( scene::Instance& instance ) const = 0;
|
||||
};
|
||||
virtual void foreachSelected( const Visitor& visitor ) const = 0;
|
||||
virtual void foreachSelectedComponent( const Visitor& visitor ) const = 0;
|
||||
|
||||
virtual void addSelectionChangeCallback( const SelectionChangeHandler& handler ) = 0;
|
||||
|
||||
virtual void NudgeManipulator( const Vector3& nudge, const Vector3& view ) = 0;
|
||||
|
||||
virtual void translateSelected( const Vector3& translation ) = 0;
|
||||
virtual void rotateSelected( const Quaternion& rotation ) = 0;
|
||||
virtual void scaleSelected( const Vector3& scaling ) = 0;
|
||||
|
||||
virtual void pivotChanged() const = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<SelectionSystem> GlobalSelectionModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<SelectionSystem> GlobalSelectionModuleRef;
|
||||
|
||||
inline SelectionSystem& GlobalSelectionSystem(){
|
||||
return GlobalSelectionModule::getTable();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
195
include/ishaders.h
Normal file
195
include/ishaders.h
Normal file
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
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_ISHADERS_H )
|
||||
#define INCLUDED_ISHADERS_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
|
||||
enum
|
||||
{
|
||||
QER_TRANS = 1 << 0,
|
||||
QER_NOCARVE = 1 << 1,
|
||||
QER_NODRAW = 1 << 2,
|
||||
QER_NONSOLID = 1 << 3,
|
||||
QER_WATER = 1 << 4,
|
||||
QER_LAVA = 1 << 5,
|
||||
QER_FOG = 1 << 6,
|
||||
QER_ALPHATEST = 1 << 7,
|
||||
QER_CULL = 1 << 8,
|
||||
QER_AREAPORTAL = 1 << 9,
|
||||
QER_CLIP = 1 << 10,
|
||||
QER_BOTCLIP = 1 << 11,
|
||||
QER_POLYOFS = 1 << 12,
|
||||
};
|
||||
|
||||
struct qtexture_t;
|
||||
|
||||
template<typename Element> class BasicVector3;
|
||||
typedef BasicVector3<float> Vector3;
|
||||
typedef Vector3 Colour3;
|
||||
|
||||
typedef unsigned char BlendFactor;
|
||||
const BlendFactor BLEND_ZERO = 0;
|
||||
const BlendFactor BLEND_ONE = 1;
|
||||
const BlendFactor BLEND_SRC_COLOUR = 2;
|
||||
const BlendFactor BLEND_ONE_MINUS_SRC_COLOUR = 3;
|
||||
const BlendFactor BLEND_SRC_ALPHA = 4;
|
||||
const BlendFactor BLEND_ONE_MINUS_SRC_ALPHA = 5;
|
||||
const BlendFactor BLEND_DST_COLOUR = 6;
|
||||
const BlendFactor BLEND_ONE_MINUS_DST_COLOUR = 7;
|
||||
const BlendFactor BLEND_DST_ALPHA = 8;
|
||||
const BlendFactor BLEND_ONE_MINUS_DST_ALPHA = 9;
|
||||
const BlendFactor BLEND_SRC_ALPHA_SATURATE = 10;
|
||||
|
||||
class BlendFunc
|
||||
{
|
||||
public:
|
||||
BlendFunc( BlendFactor src, BlendFactor dst ) : m_src( src ), m_dst( dst ){
|
||||
}
|
||||
BlendFactor m_src;
|
||||
BlendFactor m_dst;
|
||||
};
|
||||
|
||||
class ShaderLayer
|
||||
{
|
||||
public:
|
||||
virtual qtexture_t* texture() const = 0;
|
||||
virtual BlendFunc blendFunc() const = 0;
|
||||
virtual bool clampToBorder() const = 0;
|
||||
virtual float alphaTest() const = 0;
|
||||
};
|
||||
|
||||
typedef Callback<void(const ShaderLayer&)> ShaderLayerCallback;
|
||||
|
||||
|
||||
class IShader
|
||||
{
|
||||
public:
|
||||
enum EAlphaFunc
|
||||
{
|
||||
eAlways,
|
||||
eEqual,
|
||||
eLess,
|
||||
eGreater,
|
||||
eLEqual,
|
||||
eGEqual,
|
||||
};
|
||||
enum ECull
|
||||
{
|
||||
eCullNone,
|
||||
eCullBack,
|
||||
};
|
||||
// Increment the number of references to this object
|
||||
virtual void IncRef() = 0;
|
||||
// Decrement the reference count
|
||||
virtual void DecRef() = 0;
|
||||
// get/set the qtexture_t* Radiant uses to represent this shader object
|
||||
virtual qtexture_t* getTexture() const = 0;
|
||||
virtual qtexture_t* getDiffuse() const = 0;
|
||||
virtual qtexture_t* getBump() const = 0;
|
||||
virtual qtexture_t* getSpecular() const = 0;
|
||||
// get shader name
|
||||
virtual const char* getName() const = 0;
|
||||
virtual bool IsInUse() const = 0;
|
||||
virtual void SetInUse( bool bInUse ) = 0;
|
||||
// get the editor flags (QER_NOCARVE QER_TRANS)
|
||||
virtual int getFlags() const = 0;
|
||||
// get the transparency value
|
||||
virtual float getTrans() const = 0;
|
||||
virtual int getPolygonOffset() const = 0;
|
||||
// test if it's a true shader, or a default shader created to wrap around a texture
|
||||
virtual bool IsDefault() const = 0;
|
||||
// get the alphaFunc
|
||||
virtual void getAlphaFunc( EAlphaFunc *func, float *ref ) = 0;
|
||||
virtual BlendFunc getBlendFunc() const = 0;
|
||||
// get the cull type
|
||||
virtual ECull getCull() = 0;
|
||||
// get shader file name (ie the file where this one is defined)
|
||||
virtual const char* getShaderFileName() const = 0;
|
||||
|
||||
virtual const ShaderLayer* firstLayer() const = 0;
|
||||
virtual void forEachLayer( const ShaderLayerCallback& layer ) const = 0;
|
||||
|
||||
virtual qtexture_t* lightFalloffImage() const = 0;
|
||||
};
|
||||
|
||||
typedef struct _GSList GSList;
|
||||
typedef Callback<void(const char*)> ShaderNameCallback;
|
||||
|
||||
class ModuleObserver;
|
||||
|
||||
class ShaderSystem
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "shaders" );
|
||||
// NOTE: shader and texture names used must be full path.
|
||||
// Shaders usable as textures have prefix equal to getTexturePrefix()
|
||||
|
||||
virtual void realise() = 0;
|
||||
virtual void unrealise() = 0;
|
||||
virtual void refresh() = 0;
|
||||
// activate the shader for a given name and return it
|
||||
// will return the default shader if name is not found
|
||||
virtual IShader* getShaderForName( const char* name ) = 0;
|
||||
|
||||
virtual void foreachShaderName( const ShaderNameCallback& callback ) = 0;
|
||||
|
||||
// iterate over the list of active shaders
|
||||
virtual void beginActiveShadersIterator() = 0;
|
||||
virtual bool endActiveShadersIterator() = 0;
|
||||
virtual IShader* dereferenceActiveShadersIterator() = 0;
|
||||
virtual void incrementActiveShadersIterator() = 0;
|
||||
|
||||
virtual void setActiveShadersChangedNotify( const Callback<void()>& notify ) = 0;
|
||||
|
||||
virtual void attach( ModuleObserver& observer ) = 0;
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
|
||||
virtual void setLightingEnabled( bool enabled ) = 0;
|
||||
|
||||
virtual const char* getTexturePrefix() const = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<ShaderSystem> GlobalShadersModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<ShaderSystem> GlobalShadersModuleRef;
|
||||
|
||||
inline ShaderSystem& GlobalShaderSystem(){
|
||||
return GlobalShadersModule::getTable();
|
||||
}
|
||||
|
||||
|
||||
#define QERApp_Shader_ForName GlobalShaderSystem().getShaderForName
|
||||
#define QERApp_ActiveShaders_IteratorBegin GlobalShaderSystem().beginActiveShadersIterator
|
||||
#define QERApp_ActiveShaders_IteratorAtEnd GlobalShaderSystem().endActiveShadersIterator
|
||||
#define QERApp_ActiveShaders_IteratorCurrent GlobalShaderSystem().dereferenceActiveShadersIterator
|
||||
#define QERApp_ActiveShaders_IteratorIncrement GlobalShaderSystem().incrementActiveShadersIterator
|
||||
|
||||
#endif
|
52
include/itexdef.h
Normal file
52
include/itexdef.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_ITEXDEF_H )
|
||||
#define INCLUDED_ITEXDEF_H
|
||||
|
||||
enum EBrushType {
|
||||
eBrushTypeQuake,
|
||||
eBrushTypeQuake2,
|
||||
eBrushTypeQuake3,
|
||||
eBrushTypeQuake3BP,
|
||||
eBrushTypeDoom3,
|
||||
eBrushTypeQuake4,
|
||||
eBrushTypeHalfLife,
|
||||
eBrushTypeQuake3Valve
|
||||
};
|
||||
|
||||
class texdef_t
|
||||
{
|
||||
public:
|
||||
float shift[2];
|
||||
float rotate;
|
||||
float scale[2];
|
||||
|
||||
texdef_t(){
|
||||
shift[0] = 0;
|
||||
shift[1] = 0;
|
||||
rotate = 0;
|
||||
scale[0] = 1;
|
||||
scale[1] = 1;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
107
include/itextstream.h
Normal file
107
include/itextstream.h
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_ITEXTSTREAM_H )
|
||||
#define INCLUDED_ITEXTSTREAM_H
|
||||
|
||||
/// \file
|
||||
/// \brief Text-stream interfaces.
|
||||
|
||||
#include <cstddef>
|
||||
#include "generic/static.h"
|
||||
|
||||
/// \brief A read-only character-stream.
|
||||
class TextInputStream
|
||||
{
|
||||
public:
|
||||
/// \brief Attempts to read the next \p length characters from the stream to \p buffer.
|
||||
/// Returns the number of characters actually stored in \p buffer.
|
||||
virtual std::size_t read( char* buffer, std::size_t length ) = 0;
|
||||
};
|
||||
|
||||
/// \brief A write-only character-stream.
|
||||
class TextOutputStream
|
||||
{
|
||||
public:
|
||||
/// \brief Attempts to write \p length characters to the stream from \p buffer.
|
||||
/// Returns the number of characters actually read from \p buffer.
|
||||
virtual std::size_t write( const char* buffer, std::size_t length ) = 0;
|
||||
};
|
||||
|
||||
/// \brief Calls the overloaded function ostream_write() to perform text formatting specific to the type being written.
|
||||
/*! Note that ostream_write() is not globally defined - it must be defined once for each type supported.\n
|
||||
To support writing a custom type MyClass to any kind of text-output-stream with operator<<:
|
||||
\code
|
||||
template<typename TextOutputStreamType>
|
||||
TextOutputStreamType& ostream_write(TextOutputStreamType& ostream, const MyClass& myClass)
|
||||
{
|
||||
return ostream << myClass.getName() << ' ' << myClass.getText();
|
||||
}
|
||||
\endcode
|
||||
Expressing this as a template allows it to be used directly with any concrete text-output-stream type, not just the abstract TextOutputStream\n
|
||||
\n
|
||||
This overload writes a single character to any text-output-stream - ostream_write(TextOutputStreamType& ostream, char c).
|
||||
*/
|
||||
template<typename T>
|
||||
inline TextOutputStream& operator<<( TextOutputStream& ostream, const T& t ){
|
||||
return ostream_write( ostream, t );
|
||||
}
|
||||
|
||||
class NullOutputStream : public TextOutputStream
|
||||
{
|
||||
public:
|
||||
std::size_t write( const char*, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
};
|
||||
|
||||
class OutputStreamHolder
|
||||
{
|
||||
NullOutputStream m_nullOutputStream;
|
||||
TextOutputStream* m_outputStream;
|
||||
public:
|
||||
OutputStreamHolder()
|
||||
: m_outputStream( &m_nullOutputStream ){
|
||||
}
|
||||
void setOutputStream( TextOutputStream& outputStream ){
|
||||
m_outputStream = &outputStream;
|
||||
}
|
||||
TextOutputStream& getOutputStream(){
|
||||
return *m_outputStream;
|
||||
}
|
||||
};
|
||||
|
||||
typedef Static<OutputStreamHolder> GlobalOutputStream;
|
||||
|
||||
/// \brief Returns the global output stream. Used to display messages to the user.
|
||||
inline TextOutputStream& globalOutputStream(){
|
||||
return GlobalOutputStream::instance().getOutputStream();
|
||||
}
|
||||
|
||||
class ErrorStreamHolder : public OutputStreamHolder {};
|
||||
typedef Static<ErrorStreamHolder> GlobalErrorStream;
|
||||
|
||||
/// \brief Returns the global error stream. Used to display error messages to the user.
|
||||
inline TextOutputStream& globalErrorStream(){
|
||||
return GlobalErrorStream::instance().getOutputStream();
|
||||
}
|
||||
|
||||
#endif
|
88
include/itextures.h
Normal file
88
include/itextures.h
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_ITEXTURES_H )
|
||||
#define INCLUDED_ITEXTURES_H
|
||||
|
||||
#include "iimage.h"
|
||||
#include "generic/constant.h"
|
||||
|
||||
struct qtexture_t;
|
||||
|
||||
class LoadImageCallback
|
||||
{
|
||||
typedef Image* ( *LoadFunc )( void* environment, const char* name );
|
||||
public:
|
||||
void* m_environment;
|
||||
LoadFunc m_func;
|
||||
|
||||
LoadImageCallback( void* environment, LoadFunc func ) : m_environment( environment ), m_func( func ){
|
||||
}
|
||||
Image* loadImage( const char* name ) const {
|
||||
return m_func( m_environment, name );
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==( const LoadImageCallback& self, const LoadImageCallback& other ){
|
||||
return self.m_environment == other.m_environment && self.m_func == other.m_func;
|
||||
}
|
||||
inline bool operator<( const LoadImageCallback& self, const LoadImageCallback& other ){
|
||||
return self.m_environment < other.m_environment ||
|
||||
( !( other.m_environment < self.m_environment ) && self.m_func < other.m_func );
|
||||
}
|
||||
|
||||
class TexturesCacheObserver
|
||||
{
|
||||
public:
|
||||
virtual void unrealise() = 0;
|
||||
virtual void realise() = 0;
|
||||
};
|
||||
|
||||
class TexturesCache
|
||||
{
|
||||
public:
|
||||
virtual ~TexturesCache() = default;
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "textures" );
|
||||
virtual LoadImageCallback defaultLoader() const = 0;
|
||||
virtual Image* loadImage( const char* name ) = 0;
|
||||
virtual qtexture_t* capture( const char* name ) = 0;
|
||||
virtual qtexture_t* capture( const LoadImageCallback& load, const char* name ) = 0;
|
||||
virtual void release( qtexture_t* texture ) = 0;
|
||||
virtual void attach( TexturesCacheObserver& observer ) = 0;
|
||||
virtual void detach( TexturesCacheObserver& observer ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<TexturesCache> GlobalTexturesModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<TexturesCache> GlobalTexturesModuleRef;
|
||||
|
||||
inline TexturesCache& GlobalTexturesCache(){
|
||||
return GlobalTexturesModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
65
include/itoolbar.h
Normal file
65
include/itoolbar.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
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_IPLUGTOOLBAR_H )
|
||||
#define INCLUDED_IPLUGTOOLBAR_H
|
||||
|
||||
#include <cstddef>
|
||||
#include "generic/constant.h"
|
||||
|
||||
class IToolbarButton
|
||||
{
|
||||
public:
|
||||
enum EType
|
||||
{
|
||||
eSpace,
|
||||
eButton,
|
||||
eToggleButton,
|
||||
};
|
||||
|
||||
virtual const char* getImage() const = 0;
|
||||
virtual const char* getText() const = 0;
|
||||
virtual const char* getTooltip() const = 0;
|
||||
virtual EType getType() const = 0;
|
||||
virtual void activate() const = 0;
|
||||
};
|
||||
|
||||
typedef std::size_t ( *PFN_TOOLBARBUTTONCOUNT )();
|
||||
typedef const IToolbarButton* ( *PFN_GETTOOLBARBUTTON )( std::size_t index );
|
||||
|
||||
struct _QERPlugToolbarTable
|
||||
{
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "toolbar" );
|
||||
|
||||
PFN_TOOLBARBUTTONCOUNT m_pfnToolbarButtonCount;
|
||||
PFN_GETTOOLBARBUTTON m_pfnGetToolbarButton;
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class Modules;
|
||||
typedef Modules<_QERPlugToolbarTable> ToolbarModules;
|
||||
|
||||
template<typename Type>
|
||||
class ModulesRef;
|
||||
typedef ModulesRef<_QERPlugToolbarTable> ToolbarModulesRef;
|
||||
|
||||
#endif
|
118
include/iundo.h
Normal file
118
include/iundo.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_IUNDO_H )
|
||||
#define INCLUDED_IUNDO_H
|
||||
|
||||
/// \file
|
||||
/// \brief The undo-system interface. Uses the 'memento' pattern.
|
||||
|
||||
#include <cstddef>
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
|
||||
class UndoMemento
|
||||
{
|
||||
public:
|
||||
virtual void release() = 0;
|
||||
virtual ~UndoMemento() {
|
||||
}
|
||||
};
|
||||
|
||||
class Undoable
|
||||
{
|
||||
public:
|
||||
virtual UndoMemento* exportState() const = 0;
|
||||
virtual void importState( const UndoMemento* state ) = 0;
|
||||
virtual ~Undoable() {
|
||||
}
|
||||
};
|
||||
|
||||
class UndoObserver
|
||||
{
|
||||
public:
|
||||
virtual void save( Undoable* undoable ) = 0;
|
||||
virtual ~UndoObserver() {
|
||||
}
|
||||
};
|
||||
|
||||
class UndoTracker
|
||||
{
|
||||
public:
|
||||
virtual void clear() = 0;
|
||||
virtual void begin() = 0;
|
||||
virtual void undo() = 0;
|
||||
virtual void redo() = 0;
|
||||
virtual ~UndoTracker() {
|
||||
}
|
||||
};
|
||||
|
||||
class UndoSystem
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "undo" );
|
||||
|
||||
virtual UndoObserver* observer( Undoable* undoable ) = 0;
|
||||
virtual void release( Undoable* undoable ) = 0;
|
||||
|
||||
virtual std::size_t size() const = 0;
|
||||
virtual void start() = 0;
|
||||
virtual void finish( const char* command ) = 0;
|
||||
virtual void undo() = 0;
|
||||
virtual void redo() = 0;
|
||||
virtual void clear() = 0;
|
||||
|
||||
virtual void trackerAttach( UndoTracker& tracker ) = 0;
|
||||
virtual void trackerDetach( UndoTracker& tracker ) = 0;
|
||||
|
||||
virtual ~UndoSystem() {
|
||||
}
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<UndoSystem> GlobalUndoModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<UndoSystem> GlobalUndoModuleRef;
|
||||
|
||||
inline UndoSystem& GlobalUndoSystem(){
|
||||
return GlobalUndoModule::getTable();
|
||||
}
|
||||
|
||||
class UndoableCommand
|
||||
{
|
||||
const char* m_command;
|
||||
public:
|
||||
UndoableCommand( const char* command ) : m_command( command ){
|
||||
GlobalUndoSystem().start();
|
||||
}
|
||||
~UndoableCommand(){
|
||||
GlobalUndoSystem().finish( m_command );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
72
include/mapfile.h
Normal file
72
include/mapfile.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_MAPFILE_H )
|
||||
#define INCLUDED_MAPFILE_H
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "iscenegraph.h"
|
||||
#include "generic/callback.h"
|
||||
|
||||
const std::size_t MAPFILE_MAX_CHANGES = std::numeric_limits<std::size_t>::max();
|
||||
|
||||
class MapFile
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "MapFile" );
|
||||
|
||||
virtual void save() = 0;
|
||||
virtual bool saved() const = 0;
|
||||
virtual void changed() = 0;
|
||||
virtual void setChangedCallback( const Callback<void()>& changed ) = 0;
|
||||
virtual std::size_t changes() const = 0;
|
||||
};
|
||||
|
||||
#include "scenelib.h"
|
||||
|
||||
inline MapFile* Node_getMapFile( scene::Node& node ){
|
||||
return NodeTypeCast<MapFile>::cast( node );
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
inline MapFile* path_find_mapfile( Iterator first, Iterator last ){
|
||||
Iterator i = last;
|
||||
for (;; )
|
||||
{
|
||||
--i;
|
||||
|
||||
MapFile* map = Node_getMapFile( *i );
|
||||
if ( map != 0 ) {
|
||||
return map;
|
||||
}
|
||||
|
||||
if ( i == first ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
ERROR_MESSAGE( "failed to find parent mapfile for path" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
92
include/modelskin.h
Normal file
92
include/modelskin.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_MODELSKIN_H )
|
||||
#define INCLUDED_MODELSKIN_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
|
||||
class SkinRemap
|
||||
{
|
||||
public:
|
||||
const char* m_from;
|
||||
const char* m_to;
|
||||
SkinRemap( const char* from, const char* to ) : m_from( from ), m_to( to ){
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
/// \brief Detach an \p observer previously-attached by calling \c attach.
|
||||
virtual void detach( ModuleObserver& observer ) = 0;
|
||||
/// \brief Returns true if this skin is currently loaded.
|
||||
virtual bool realised() const = 0;
|
||||
/// \brief Returns the shader identifier that \p name remaps to, or "" if not found or not realised.
|
||||
virtual const char* getRemap( const char* name ) const = 0;
|
||||
/// \brief Calls \p callback for each remap pair. Has no effect if not realised.
|
||||
virtual void forEachRemap( const SkinRemapCallback& callback ) const = 0;
|
||||
};
|
||||
|
||||
class SkinnedModel
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "SkinnedModel" );
|
||||
/// \brief Instructs the skinned model to update its skin.
|
||||
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'.
|
||||
virtual ModelSkin& capture( const char* name ) = 0;
|
||||
/// \brief Decrements the reference-count of the skin uniquely identified by 'name'.
|
||||
virtual void release( const char* name ) = 0;
|
||||
};
|
||||
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<ModelSkinCache> GlobalModelSkinCacheModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<ModelSkinCache> GlobalModelSkinCacheModuleRef;
|
||||
|
||||
inline ModelSkinCache& GlobalModelSkinCache(){
|
||||
return GlobalModelSkinCacheModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
33
include/moduleobserver.h
Normal file
33
include/moduleobserver.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_MODULEOBSERVER_H )
|
||||
#define INCLUDED_MODULEOBSERVER_H
|
||||
|
||||
class ModuleObserver
|
||||
{
|
||||
public:
|
||||
virtual ~ModuleObserver() = default;
|
||||
virtual void unrealise() = 0;
|
||||
virtual void realise() = 0;
|
||||
};
|
||||
|
||||
#endif
|
233
include/modulesystem.h
Normal file
233
include/modulesystem.h
Normal file
|
@ -0,0 +1,233 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_MODULESYSTEM_H )
|
||||
#define INCLUDED_MODULESYSTEM_H
|
||||
|
||||
#include "globaldefs.h"
|
||||
#include "generic/static.h"
|
||||
#include "debugging/debugging.h"
|
||||
|
||||
#if GDEF_OS_WINDOWS
|
||||
#define RADIANT_DLLEXPORT __declspec(dllexport)
|
||||
#define RADIANT_DLLIMPORT __declspec(dllimport)
|
||||
#else
|
||||
#define RADIANT_DLLEXPORT __attribute__((visibility("default")))
|
||||
#define RADIANT_DLLIMPORT
|
||||
#endif
|
||||
|
||||
|
||||
class Module
|
||||
{
|
||||
public:
|
||||
virtual void capture() = 0;
|
||||
virtual void release() = 0;
|
||||
virtual void* getTable() = 0;
|
||||
};
|
||||
|
||||
inline void* Module_getTable( Module& module ){
|
||||
return module.getTable();
|
||||
}
|
||||
|
||||
class TextOutputStream;
|
||||
class DebugMessageHandler;
|
||||
|
||||
class ModuleServer
|
||||
{
|
||||
public:
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* name, Module& module ) const = 0;
|
||||
};
|
||||
|
||||
virtual void setError( bool error ) = 0;
|
||||
virtual bool getError() const = 0;
|
||||
|
||||
virtual TextOutputStream& getOutputStream() = 0;
|
||||
virtual TextOutputStream& getErrorStream() = 0;
|
||||
virtual DebugMessageHandler& getDebugMessageHandler() = 0;
|
||||
|
||||
virtual void registerModule( const char* type, int version, const char* name, Module& module ) = 0;
|
||||
virtual Module* findModule( const char* type, int version, const char* name ) const = 0;
|
||||
virtual void foreachModule( const char* type, int version, const Visitor& visitor ) = 0;
|
||||
};
|
||||
|
||||
class ModuleServerHolder
|
||||
{
|
||||
ModuleServer* m_server;
|
||||
public:
|
||||
ModuleServerHolder()
|
||||
: m_server( 0 ){
|
||||
}
|
||||
void set( ModuleServer& server ){
|
||||
m_server = &server;
|
||||
}
|
||||
ModuleServer& get(){
|
||||
return *m_server;
|
||||
}
|
||||
};
|
||||
|
||||
typedef Static<ModuleServerHolder> GlobalModuleServer;
|
||||
|
||||
inline ModuleServer& globalModuleServer(){
|
||||
return GlobalModuleServer::instance().get();
|
||||
}
|
||||
|
||||
|
||||
inline void initialiseModule( ModuleServer& server ){
|
||||
GlobalErrorStream::instance().setOutputStream( server.getErrorStream() );
|
||||
GlobalOutputStream::instance().setOutputStream( server.getOutputStream() );
|
||||
GlobalDebugMessageHandler::instance().setHandler( server.getDebugMessageHandler() );
|
||||
GlobalModuleServer::instance().set( server );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename Type>
|
||||
class Modules
|
||||
{
|
||||
public:
|
||||
class Visitor
|
||||
{
|
||||
public:
|
||||
virtual void visit( const char* name, const Type& table ) const = 0;
|
||||
};
|
||||
|
||||
virtual Type* findModule( const char* name ) = 0;
|
||||
virtual void foreachModule( const Visitor& visitor ) = 0;
|
||||
};
|
||||
|
||||
#include "debugging/debugging.h"
|
||||
|
||||
template<typename Type>
|
||||
class ModuleRef
|
||||
{
|
||||
Module* m_module;
|
||||
Type* m_table;
|
||||
public:
|
||||
ModuleRef( const char* name ) : m_table( 0 ){
|
||||
if ( !globalModuleServer().getError() ) {
|
||||
m_module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
|
||||
if ( m_module == 0 ) {
|
||||
globalModuleServer().setError( true );
|
||||
globalErrorStream() << "ModuleRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_module->capture();
|
||||
if ( !globalModuleServer().getError() ) {
|
||||
m_table = static_cast<Type*>( m_module->getTable() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
~ModuleRef(){
|
||||
if ( m_module != 0 ) {
|
||||
m_module->release();
|
||||
}
|
||||
}
|
||||
Type* getTable(){
|
||||
#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;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class SingletonModuleRef
|
||||
{
|
||||
Module* m_module;
|
||||
Type* m_table;
|
||||
public:
|
||||
|
||||
SingletonModuleRef()
|
||||
: m_module( 0 ), m_table( 0 ){
|
||||
}
|
||||
|
||||
bool initialised() const {
|
||||
return m_module != 0;
|
||||
}
|
||||
|
||||
void initialise( const char* name ){
|
||||
m_module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
|
||||
if ( m_module == 0 ) {
|
||||
globalModuleServer().setError( true );
|
||||
globalErrorStream() << "SingletonModuleRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
|
||||
}
|
||||
}
|
||||
|
||||
Type* getTable(){
|
||||
#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;
|
||||
}
|
||||
void capture(){
|
||||
if ( initialised() ) {
|
||||
m_module->capture();
|
||||
m_table = static_cast<Type*>( m_module->getTable() );
|
||||
}
|
||||
}
|
||||
void release(){
|
||||
if ( initialised() ) {
|
||||
m_module->release();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule
|
||||
{
|
||||
static SingletonModuleRef<Type> m_instance;
|
||||
public:
|
||||
static SingletonModuleRef<Type>& instance(){
|
||||
return m_instance;
|
||||
}
|
||||
static Type& getTable(){
|
||||
return *m_instance.getTable();
|
||||
}
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
SingletonModuleRef<Type> GlobalModule<Type>::m_instance;
|
||||
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef
|
||||
{
|
||||
public:
|
||||
GlobalModuleRef( const char* name = "*" ){
|
||||
if ( !globalModuleServer().getError() ) {
|
||||
GlobalModule<Type>::instance().initialise( name );
|
||||
}
|
||||
GlobalModule<Type>::instance().capture();
|
||||
}
|
||||
~GlobalModuleRef(){
|
||||
GlobalModule<Type>::instance().release();
|
||||
}
|
||||
Type& getTable(){
|
||||
return GlobalModule<Type>::getTable();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
41
include/nameable.h
Normal file
41
include/nameable.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_NAMEABLE_H )
|
||||
#define INCLUDED_NAMEABLE_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
|
||||
typedef Callback<void(const char*)> NameCallback;
|
||||
|
||||
class Nameable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Nameable" );
|
||||
|
||||
virtual const char* name() const = 0;
|
||||
virtual void attach( const NameCallback& callback ) = 0;
|
||||
virtual void detach( const NameCallback& callback ) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
62
include/namespace.h
Normal file
62
include/namespace.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_NAMESPACE_H )
|
||||
#define INCLUDED_NAMESPACE_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
|
||||
typedef Callback<void(const char*)> NameCallback;
|
||||
typedef Callback<void(const NameCallback&)> NameCallbackCallback;
|
||||
|
||||
class Namespace
|
||||
{
|
||||
public:
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "namespace" );
|
||||
virtual void attach( const NameCallback& setName, const NameCallbackCallback& attachObserver ) = 0;
|
||||
virtual void detach( const NameCallback& setName, const NameCallbackCallback& detachObserver ) = 0;
|
||||
virtual void makeUnique( const char* name, const NameCallback& setName ) const = 0;
|
||||
};
|
||||
|
||||
class Namespaced
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "Namespaced" );
|
||||
|
||||
virtual void setNamespace( Namespace& space ) = 0;
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<Namespace> GlobalNamespaceModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<Namespace> GlobalNamespaceModuleRef;
|
||||
|
||||
inline Namespace& GlobalNamespace(){
|
||||
return GlobalNamespaceModule::getTable();
|
||||
}
|
||||
#endif
|
187
include/preferencesystem.cpp
Normal file
187
include/preferencesystem.cpp
Normal file
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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 0
|
||||
|
||||
#include "preferencesystem.h"
|
||||
#include "preferencedictionary.h"
|
||||
|
||||
#include "xml/xmlparser.h"
|
||||
#include "xml/xmlwriter.h"
|
||||
|
||||
|
||||
void LoadPrefs( PreferenceDictionary& preferences, const char* filename ){
|
||||
TextFileInputStream file( filename );
|
||||
if ( !file.failed() ) {
|
||||
XMLStreamParser parser( file );
|
||||
XMLPreferenceDictionaryImporter importer( preferences );
|
||||
parser.exportXML( importer );
|
||||
}
|
||||
else
|
||||
{
|
||||
// error
|
||||
}
|
||||
}
|
||||
|
||||
void SavePrefs( PreferenceDictionary& preferences, const char* filename ){
|
||||
TextFileOutputStream file( filename );
|
||||
if ( !file.failed() ) {
|
||||
XMLStreamWriter writer( file );
|
||||
XMLPreferenceDictionaryExporter exporter( preferences, "1" );
|
||||
exporter.exportXML( writer );
|
||||
}
|
||||
else
|
||||
{
|
||||
// error
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class StringPreference
|
||||
{
|
||||
public:
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
virtual void onChanged() = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
CopiedString m_string;
|
||||
Observer& m_observer;
|
||||
public:
|
||||
StringPreference( Observer& observer )
|
||||
: m_observer( observer ){
|
||||
}
|
||||
void importString( const char* value ){
|
||||
m_string = value;
|
||||
m_observer.onChanged();
|
||||
}
|
||||
typedef MemberCaller<StringPreference, void(const char*), &StringPreference::importString> ImportStringCaller;
|
||||
void exportString( Callback<void(const char *)>& importer ){
|
||||
importer( m_string.c_str() );
|
||||
}
|
||||
typedef MemberCaller<StringPreference, void(Callback<void(const char *)>&), &StringPreference::exportString> ExportStringCaller;
|
||||
};
|
||||
|
||||
inline void int_export( int i, Callback<void(const char *)>& importer ){
|
||||
char buffer[16];
|
||||
sprintf( buffer, "%d", i );
|
||||
importer( buffer );
|
||||
}
|
||||
|
||||
inline int int_import( const char* value ){
|
||||
return atoi( value );
|
||||
}
|
||||
|
||||
class IntPreference
|
||||
{
|
||||
public:
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
virtual void onChanged() = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
int m_int;
|
||||
Observer& m_observer;
|
||||
public:
|
||||
|
||||
IntPreference( Observer& observer )
|
||||
: m_observer( observer ){
|
||||
}
|
||||
void importString( const char* value ){
|
||||
m_int = int_import( value );
|
||||
m_observer.onChanged();
|
||||
}
|
||||
typedef MemberCaller<IntPreference, void(const char*), &IntPreference::importString> ImportStringCaller;
|
||||
void exportString( Callback<void(const char *)>& importer ){
|
||||
int_export( m_int, importer );
|
||||
}
|
||||
typedef MemberCaller<IntPreference, void(Callback<void(const char *)>&), &IntPreference::exportString> ExportStringCaller;
|
||||
};
|
||||
|
||||
class IntPreferenceImporter
|
||||
{
|
||||
int& m_i;
|
||||
public:
|
||||
|
||||
IntPreferenceImporter( int& i )
|
||||
: m_i( i ){
|
||||
}
|
||||
void importString( const char* value ){
|
||||
m_i = int_import( value );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TestPrefs
|
||||
{
|
||||
public:
|
||||
TestPrefs(){
|
||||
PreferenceDictionary preferences;
|
||||
|
||||
class StringObserver : public StringPreference::Observer
|
||||
{
|
||||
public:
|
||||
void onChanged(){
|
||||
int bleh = 0;
|
||||
}
|
||||
} string_observer;
|
||||
StringPreference string1( string_observer );
|
||||
string1.importString( "twenty-three" );
|
||||
|
||||
class IntObserver : public IntPreference::Observer
|
||||
{
|
||||
public:
|
||||
void onChanged(){
|
||||
int bleh = 0;
|
||||
}
|
||||
|
||||
} int_observer;
|
||||
IntPreference int1( int_observer );
|
||||
int1.importString( "23" );
|
||||
|
||||
preferences.registerPreference( "string1", StringPreference::ImportStringCaller( string1 ), StringPreference::ExportStringCaller( string1 ) );
|
||||
preferences.registerPreference( "int1", IntPreference::ImportStringCaller( int1 ), IntPreference::ExportStringCaller( int1 ) );
|
||||
|
||||
LoadPrefs( preferences, "test.pref" );
|
||||
SavePrefs( preferences, "test.pref" );
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#if 0
|
||||
TestPrefs g_TestPrefs;
|
||||
#endif
|
||||
|
||||
void readpref( PreferenceDictionary& preferences, int& int_variable ){
|
||||
PreferenceDictionary::iterator i = preferences.find( "int_variable" );
|
||||
IntPreferenceImporter importer( int_variable );
|
||||
( *i ).second.exporter().exportString( importer );
|
||||
}
|
||||
|
||||
void writepref( PreferenceDictionary& preferences, int& int_variable ){
|
||||
PreferenceDictionary::iterator i = preferences.find( "int_variable" );
|
||||
int_export( int_variable, ( *i ).second.importer() );
|
||||
}
|
||||
#endif
|
67
include/preferencesystem.h
Normal file
67
include/preferencesystem.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_PREFERENCESYSTEM_H )
|
||||
#define INCLUDED_PREFERENCESYSTEM_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
#include "generic/callback.h"
|
||||
#include "property.h"
|
||||
|
||||
class PreferenceSystem {
|
||||
public:
|
||||
INTEGER_CONSTANT(Version, 1);
|
||||
STRING_CONSTANT(Name, "preferences");
|
||||
|
||||
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>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<PreferenceSystem> GlobalPreferenceSystemModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<PreferenceSystem> GlobalPreferenceSystemModuleRef;
|
||||
|
||||
inline PreferenceSystem& GlobalPreferenceSystem(){
|
||||
return GlobalPreferenceSystemModule::getTable();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
168
include/qerplugin.h
Normal file
168
include/qerplugin.h
Normal file
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// QERadiant PlugIns
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef __QERPLUGIN_H__
|
||||
#define __QERPLUGIN_H__
|
||||
|
||||
#include "uilib/uilib.h"
|
||||
#include "generic/constant.h"
|
||||
|
||||
|
||||
// ========================================
|
||||
// GTK+ helper functions
|
||||
|
||||
// NOTE: parent can be 0 in all functions but it's best to set them
|
||||
|
||||
// this API does not depend on gtk+ or glib
|
||||
|
||||
enum EMessageBoxType
|
||||
{
|
||||
eMB_OK,
|
||||
eMB_OKCANCEL,
|
||||
eMB_YESNO,
|
||||
eMB_YESNOCANCEL,
|
||||
eMB_NOYES,
|
||||
};
|
||||
|
||||
enum EMessageBoxIcon
|
||||
{
|
||||
eMB_ICONDEFAULT,
|
||||
eMB_ICONERROR,
|
||||
eMB_ICONWARNING,
|
||||
eMB_ICONQUESTION,
|
||||
eMB_ICONASTERISK,
|
||||
};
|
||||
|
||||
enum EMessageBoxReturn
|
||||
{
|
||||
eIDOK,
|
||||
eIDCANCEL,
|
||||
eIDYES,
|
||||
eIDNO,
|
||||
};
|
||||
|
||||
// simple Message Box, see above for the 'type' flags
|
||||
|
||||
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 )( 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 )( 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 )( 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 ui::Image ( *PFN_QERAPP_NEWIMAGE )( const char* filename );
|
||||
|
||||
// ========================================
|
||||
|
||||
namespace scene
|
||||
{
|
||||
class Node;
|
||||
}
|
||||
|
||||
class ModuleObserver;
|
||||
|
||||
#include "signal/signalfwd.h"
|
||||
#include "windowobserver.h"
|
||||
#include "generic/vector.h"
|
||||
|
||||
typedef SignalHandler3<const WindowVector&, ButtonIdentifier, ModifierFlags> MouseEventHandler;
|
||||
typedef SignalFwd<MouseEventHandler>::handler_id_type MouseEventHandlerId;
|
||||
|
||||
enum VIEWTYPE
|
||||
{
|
||||
YZ = 0,
|
||||
XZ = 1,
|
||||
XY = 2
|
||||
};
|
||||
|
||||
// the radiant core API
|
||||
struct _QERFuncTable_1
|
||||
{
|
||||
INTEGER_CONSTANT( Version, 1 );
|
||||
STRING_CONSTANT( Name, "radiant" );
|
||||
|
||||
const char* ( *getEnginePath )( );
|
||||
const char* ( *getLocalRcPath )( );
|
||||
const char* ( *getGameToolsPath )( );
|
||||
const char* ( *getAppPath )( );
|
||||
const char* ( *getSettingsPath )( );
|
||||
const char* ( *getMapsPath )( );
|
||||
|
||||
const char* ( *getGameFile )( );
|
||||
const char* ( *getGameName )( );
|
||||
const char* ( *getGameMode )( );
|
||||
|
||||
const char* ( *getMapName )( );
|
||||
scene::Node& ( *getMapWorldEntity )( );
|
||||
float ( *getGridSize )();
|
||||
|
||||
const char* ( *getGameDescriptionKeyValue )(const char* key);
|
||||
const char* ( *getRequiredGameDescriptionKeyValue )(const char* key);
|
||||
|
||||
SignalHandlerId ( *XYWindowDestroyed_connect )( const SignalHandler& handler );
|
||||
void ( *XYWindowDestroyed_disconnect )( SignalHandlerId id );
|
||||
MouseEventHandlerId ( *XYWindowMouseDown_connect )( const MouseEventHandler& handler );
|
||||
void ( *XYWindowMouseDown_disconnect )( MouseEventHandlerId id );
|
||||
VIEWTYPE ( *XYWindow_getViewType )();
|
||||
Vector3 ( *XYWindow_windowToWorld )( const WindowVector& position );
|
||||
const char* ( *TextureBrowser_getSelectedShader )( );
|
||||
|
||||
// GTK+ functions
|
||||
PFN_QERAPP_MESSAGEBOX m_pfnMessageBox;
|
||||
PFN_QERAPP_FILEDIALOG m_pfnFileDialog;
|
||||
PFN_QERAPP_DIRDIALOG m_pfnDirDialog;
|
||||
PFN_QERAPP_COLORDIALOG m_pfnColorDialog;
|
||||
PFN_QERAPP_NEWIMAGE m_pfnNewImage;
|
||||
|
||||
};
|
||||
|
||||
#include "modulesystem.h"
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModule;
|
||||
typedef GlobalModule<_QERFuncTable_1> GlobalRadiantModule;
|
||||
|
||||
template<typename Type>
|
||||
class GlobalModuleRef;
|
||||
typedef GlobalModuleRef<_QERFuncTable_1> GlobalRadiantModuleRef;
|
||||
|
||||
inline _QERFuncTable_1& GlobalRadiant(){
|
||||
return GlobalRadiantModule::getTable();
|
||||
}
|
||||
|
||||
#endif
|
74
include/renderable.h
Normal file
74
include/renderable.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_RENDERABLE_H )
|
||||
#define INCLUDED_RENDERABLE_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
|
||||
class Shader;
|
||||
class OpenGLRenderable;
|
||||
class LightList;
|
||||
class Matrix4;
|
||||
|
||||
class Renderer
|
||||
{
|
||||
public:
|
||||
enum EHighlightMode
|
||||
{
|
||||
eFace = 1 << 0,
|
||||
/*! Full highlighting. */
|
||||
ePrimitive = 1 << 1,
|
||||
};
|
||||
|
||||
enum EStyle
|
||||
{
|
||||
eWireframeOnly,
|
||||
eFullMaterials,
|
||||
};
|
||||
|
||||
virtual void PushState() = 0;
|
||||
virtual void PopState() = 0;
|
||||
virtual void SetState( Shader* state, EStyle mode ) = 0;
|
||||
virtual EStyle getStyle() const = 0;
|
||||
virtual void Highlight( EHighlightMode mode, bool bEnable = true ) = 0;
|
||||
virtual void setLights( const LightList& lights ){
|
||||
}
|
||||
virtual void addRenderable( const OpenGLRenderable& renderable, const Matrix4& world ) = 0;
|
||||
};
|
||||
|
||||
class VolumeTest;
|
||||
|
||||
class Renderable
|
||||
{
|
||||
public:
|
||||
virtual ~Renderable() = default;
|
||||
STRING_CONSTANT( Name, "Renderable" );
|
||||
|
||||
virtual void renderSolid( Renderer& renderer, const VolumeTest& volume ) const = 0;
|
||||
virtual void renderWireframe( Renderer& renderer, const VolumeTest& volume ) const = 0;
|
||||
virtual void renderComponents( Renderer&, const VolumeTest& ) const {
|
||||
}
|
||||
virtual void viewChanged() const {
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
272
include/selectable.h
Normal file
272
include/selectable.h
Normal file
|
@ -0,0 +1,272 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_SELECTABLE_H )
|
||||
#define INCLUDED_SELECTABLE_H
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "generic/vector.h"
|
||||
#include "scenelib.h"
|
||||
#include "generic/callback.h"
|
||||
|
||||
class SelectionIntersection
|
||||
{
|
||||
float m_depth;
|
||||
float m_distance;
|
||||
public:
|
||||
SelectionIntersection() : m_depth( 1 ), m_distance( 2 ){
|
||||
}
|
||||
SelectionIntersection( float depth, float distance ) : m_depth( depth ), m_distance( distance ){
|
||||
}
|
||||
bool operator<( const SelectionIntersection& other ) const {
|
||||
if ( m_distance != other.m_distance ) {
|
||||
return m_distance < other.m_distance;
|
||||
}
|
||||
if ( m_depth != other.m_depth ) {
|
||||
return m_depth < other.m_depth;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool equalEpsilon( const SelectionIntersection& other, float distanceEpsilon, float depthEpsilon ) const {
|
||||
return float_equal_epsilon( m_distance, other.m_distance, distanceEpsilon )
|
||||
&& float_equal_epsilon( m_depth, other.m_depth, depthEpsilon );
|
||||
}
|
||||
float depth() const {
|
||||
return m_depth;
|
||||
}
|
||||
bool valid() const {
|
||||
return depth() < 1;
|
||||
}
|
||||
};
|
||||
|
||||
// returns true if self is closer than other
|
||||
inline bool SelectionIntersection_closer( const SelectionIntersection& self, const SelectionIntersection& other ){
|
||||
return self < other;
|
||||
}
|
||||
|
||||
// assigns other to best if other is closer than best
|
||||
inline void assign_if_closer( SelectionIntersection& best, const SelectionIntersection& other ){
|
||||
if ( SelectionIntersection_closer( other, best ) ) {
|
||||
best = other;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class VertexPointer
|
||||
{
|
||||
typedef const unsigned char* byte_pointer;
|
||||
public:
|
||||
typedef float elem_type;
|
||||
typedef const elem_type* pointer;
|
||||
typedef const elem_type& reference;
|
||||
|
||||
class iterator
|
||||
{
|
||||
public:
|
||||
iterator() {}
|
||||
iterator( byte_pointer vertices, std::size_t stride )
|
||||
: m_iter( vertices ), m_stride( stride ) {}
|
||||
|
||||
bool operator==( const iterator& other ) const {
|
||||
return m_iter == other.m_iter;
|
||||
}
|
||||
bool operator!=( const iterator& other ) const {
|
||||
return !operator==( other );
|
||||
}
|
||||
|
||||
iterator operator+( std::size_t i ){
|
||||
return iterator( m_iter + i * m_stride, m_stride );
|
||||
}
|
||||
iterator operator+=( std::size_t i ){
|
||||
m_iter += i * m_stride;
|
||||
return *this;
|
||||
}
|
||||
iterator& operator++(){
|
||||
m_iter += m_stride;
|
||||
return *this;
|
||||
}
|
||||
iterator operator++( int ){
|
||||
iterator tmp = *this;
|
||||
m_iter += m_stride;
|
||||
return tmp;
|
||||
}
|
||||
reference operator*() const {
|
||||
return *reinterpret_cast<pointer>( m_iter );
|
||||
}
|
||||
private:
|
||||
byte_pointer m_iter;
|
||||
std::size_t m_stride;
|
||||
};
|
||||
|
||||
VertexPointer( pointer vertices, std::size_t stride )
|
||||
: m_vertices( reinterpret_cast<byte_pointer>( vertices ) ), m_stride( stride ) {}
|
||||
|
||||
iterator begin() const {
|
||||
return iterator( m_vertices, m_stride );
|
||||
}
|
||||
|
||||
reference operator[]( std::size_t i ) const {
|
||||
return *reinterpret_cast<pointer>( m_vertices + m_stride * i );
|
||||
}
|
||||
|
||||
private:
|
||||
byte_pointer m_vertices;
|
||||
std::size_t m_stride;
|
||||
};
|
||||
|
||||
class IndexPointer
|
||||
{
|
||||
public:
|
||||
typedef unsigned int index_type;
|
||||
typedef const index_type* pointer;
|
||||
|
||||
class iterator
|
||||
{
|
||||
public:
|
||||
iterator( pointer iter ) : m_iter( iter ) {}
|
||||
|
||||
bool operator==( const iterator& other ) const {
|
||||
return m_iter == other.m_iter;
|
||||
}
|
||||
bool operator!=( const iterator& other ) const {
|
||||
return !operator==( other );
|
||||
}
|
||||
|
||||
iterator operator+( std::size_t i ){
|
||||
return m_iter + i;
|
||||
}
|
||||
iterator operator+=( std::size_t i ){
|
||||
return m_iter += i;
|
||||
}
|
||||
iterator operator++(){
|
||||
return ++m_iter;
|
||||
}
|
||||
iterator operator++( int ){
|
||||
return m_iter++;
|
||||
}
|
||||
const index_type& operator*() const {
|
||||
return *m_iter;
|
||||
}
|
||||
private:
|
||||
void increment(){
|
||||
++m_iter;
|
||||
}
|
||||
pointer m_iter;
|
||||
};
|
||||
|
||||
IndexPointer( pointer indices, std::size_t count )
|
||||
: m_indices( indices ), m_finish( indices + count ) {}
|
||||
|
||||
iterator begin() const {
|
||||
return m_indices;
|
||||
}
|
||||
iterator end() const {
|
||||
return m_finish;
|
||||
}
|
||||
|
||||
private:
|
||||
pointer m_indices;
|
||||
pointer m_finish;
|
||||
};
|
||||
|
||||
template<typename Element> class BasicVector3;
|
||||
typedef BasicVector3<float> Vector3;
|
||||
class Matrix4;
|
||||
class VolumeTest;
|
||||
|
||||
class SelectionTest
|
||||
{
|
||||
public:
|
||||
virtual void BeginMesh( const Matrix4& localToWorld, bool twoSided = false ) = 0;
|
||||
virtual const VolumeTest& getVolume() const = 0;
|
||||
virtual const Vector3& getNear() const = 0;
|
||||
virtual const Vector3& getFar() const = 0;
|
||||
virtual void TestPoint( const Vector3& point, SelectionIntersection& best ) = 0;
|
||||
virtual void TestPolygon( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best ) = 0;
|
||||
virtual void TestLineLoop( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best ) = 0;
|
||||
virtual void TestLineStrip( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best ) = 0;
|
||||
virtual void TestLines( const VertexPointer& vertices, std::size_t count, SelectionIntersection& best ) = 0;
|
||||
virtual void TestTriangles( const VertexPointer& vertices, const IndexPointer& indices, SelectionIntersection& best ) = 0;
|
||||
virtual void TestQuads( const VertexPointer& vertices, const IndexPointer& indices, SelectionIntersection& best ) = 0;
|
||||
virtual void TestQuadStrip( const VertexPointer& vertices, const IndexPointer& indices, SelectionIntersection& best ) = 0;
|
||||
};
|
||||
|
||||
class Selectable;
|
||||
|
||||
class Selector
|
||||
{
|
||||
public:
|
||||
virtual void pushSelectable( Selectable& selectable ) = 0;
|
||||
virtual void popSelectable() = 0;
|
||||
virtual void addIntersection( const SelectionIntersection& intersection ) = 0;
|
||||
};
|
||||
|
||||
inline void Selector_add( Selector& selector, Selectable& selectable ){
|
||||
selector.pushSelectable( selectable );
|
||||
selector.addIntersection( SelectionIntersection( 0, 0 ) );
|
||||
selector.popSelectable();
|
||||
}
|
||||
|
||||
inline void Selector_add( Selector& selector, Selectable& selectable, const SelectionIntersection& intersection ){
|
||||
selector.pushSelectable( selectable );
|
||||
selector.addIntersection( intersection );
|
||||
selector.popSelectable();
|
||||
}
|
||||
|
||||
|
||||
class VolumeTest;
|
||||
class SelectionTestable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "SelectionTestable" );
|
||||
|
||||
virtual void testSelect( Selector& selector, SelectionTest& test ) = 0;
|
||||
};
|
||||
|
||||
inline SelectionTestable* Instance_getSelectionTestable( scene::Instance& instance ){
|
||||
return InstanceTypeCast<SelectionTestable>::cast( instance );
|
||||
}
|
||||
|
||||
|
||||
class Plane3;
|
||||
typedef Callback<void(const Plane3&)> PlaneCallback;
|
||||
|
||||
class SelectedPlanes
|
||||
{
|
||||
public:
|
||||
virtual bool contains( const Plane3& plane ) const = 0;
|
||||
};
|
||||
|
||||
class PlaneSelectable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT( Name, "PlaneSelectable" );
|
||||
|
||||
virtual void selectPlanes( Selector& selector, SelectionTest& test, const PlaneCallback& selectedPlaneCallback ) = 0;
|
||||
virtual void selectReversedPlanes( Selector& selector, const SelectedPlanes& selectedPlanes ) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
2
include/stream_version.h
Normal file
2
include/stream_version.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
// version defines for q3map stream
|
||||
#define Q3MAP_STREAM_VERSION "1"
|
308
include/unzip.h
Normal file
308
include/unzip.h
Normal file
|
@ -0,0 +1,308 @@
|
|||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.2.0, September 16th, 2017
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 2009-2010 Mathias Svensson
|
||||
Modifications for Zip64 support on both zip and unzip
|
||||
http://result42.com
|
||||
Copyright (C) 2007-2008 Even Rouault
|
||||
Modifications of Unzip for Zip64
|
||||
Copyright (C) 1998-2010 Gilles Vollant
|
||||
http://www.winimage.com/zLibDll/minizip.html
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
#ifndef _UNZ_H
|
||||
#define _UNZ_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BZIP2
|
||||
#include "bzlib.h"
|
||||
#endif
|
||||
|
||||
#define Z_BZIP2ED 12
|
||||
|
||||
#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; } unz_file__;
|
||||
typedef unz_file__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
#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_BADPASSWORD (-106)
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info64_s
|
||||
{
|
||||
uint64_t number_entry; /* total number of entries in the central dir on this disk */
|
||||
uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
|
||||
uint16_t size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info64;
|
||||
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uint32_t number_entry; /* total number of entries in the central dir on this disk */
|
||||
uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/
|
||||
uint16_t 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_info64_s
|
||||
{
|
||||
uint16_t version; /* version made by 2 bytes */
|
||||
uint16_t version_needed; /* version needed to extract 2 bytes */
|
||||
uint16_t flag; /* general purpose bit flag 2 bytes */
|
||||
uint16_t compression_method; /* compression method 2 bytes */
|
||||
uint32_t dos_date; /* last mod file date in Dos fmt 4 bytes */
|
||||
uint32_t crc; /* crc-32 4 bytes */
|
||||
uint64_t compressed_size; /* compressed size 8 bytes */
|
||||
uint64_t uncompressed_size; /* uncompressed size 8 bytes */
|
||||
uint16_t size_filename; /* filename length 2 bytes */
|
||||
uint16_t size_file_extra; /* extra field length 2 bytes */
|
||||
uint16_t size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uint32_t disk_num_start; /* disk number start 4 bytes */
|
||||
uint16_t internal_fa; /* internal file attributes 2 bytes */
|
||||
uint32_t external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
uint64_t disk_offset;
|
||||
|
||||
uint16_t size_file_extra_internal;
|
||||
} unz_file_info64;
|
||||
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uint16_t version; /* version made by 2 bytes */
|
||||
uint16_t version_needed; /* version needed to extract 2 bytes */
|
||||
uint16_t flag; /* general purpose bit flag 2 bytes */
|
||||
uint16_t compression_method; /* compression method 2 bytes */
|
||||
uint32_t dos_date; /* last mod file date in Dos fmt 4 bytes */
|
||||
uint32_t crc; /* crc-32 4 bytes */
|
||||
uint32_t compressed_size; /* compressed size 4 bytes */
|
||||
uint32_t uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uint16_t size_filename; /* filename length 2 bytes */
|
||||
uint16_t size_file_extra; /* extra field length 2 bytes */
|
||||
uint16_t size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uint16_t disk_num_start; /* disk number start 2 bytes */
|
||||
uint16_t internal_fa; /* internal file attributes 2 bytes */
|
||||
uint32_t external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
uint64_t disk_offset;
|
||||
} unz_file_info;
|
||||
|
||||
/***************************************************************************/
|
||||
/* Opening and close a zip file */
|
||||
|
||||
extern unzFile ZEXPORT unzOpen(const char *path);
|
||||
extern unzFile ZEXPORT unzOpen64(const void *path);
|
||||
/* Open a Zip file.
|
||||
|
||||
path should contain the full path (by example, on a Windows XP computer
|
||||
"c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip".
|
||||
return NULL if zipfile cannot be opened or doesn't exist
|
||||
return unzFile handle if no error
|
||||
|
||||
NOTE: The "64" function take a const void *pointer, because the path is just the value passed to the
|
||||
open64_file_func callback. Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
|
||||
is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char *does not describe the reality */
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc_def);
|
||||
/* Open a Zip file, like unzOpen, but provide a set of file low level API for read/write operations */
|
||||
extern unzFile ZEXPORT unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def);
|
||||
/* Open a Zip file, like unz64Open, but provide a set of file low level API for read/write 64-bit operations */
|
||||
|
||||
extern int ZEXPORT unzClose(unzFile file);
|
||||
/* Close a ZipFile opened with unzOpen. If there is files inside the .Zip opened with unzOpenCurrentFile,
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
|
||||
return UNZ_OK if there is no error */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info);
|
||||
extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info);
|
||||
/* Write info about the ZipFile in the *pglobal_info structure.
|
||||
|
||||
return UNZ_OK if no error */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment(unzFile file, char *comment, uint16_t comment_size);
|
||||
/* Get the global comment string of the ZipFile, in the comment buffer.
|
||||
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0 */
|
||||
|
||||
/***************************************************************************/
|
||||
/* 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 ZEXPORT unzOpenCurrentFile(unzFile file);
|
||||
/* Open for reading data the current file in the zipfile.
|
||||
|
||||
return UNZ_OK if no error */
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char *password);
|
||||
/* Open for reading data the current file in the zipfile.
|
||||
password is a crypting password
|
||||
|
||||
return UNZ_OK if no error */
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw);
|
||||
/* Same as unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1 *method will receive method of compression, *level will receive level of compression
|
||||
|
||||
NOTE: you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL */
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password);
|
||||
/* Same as unzOpenCurrentFile, but takes extra parameter password for encrypted files */
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, uint32_t len);
|
||||
/* Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
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 ZEXPORT unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size);
|
||||
extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size);
|
||||
/* Get Info about the current file
|
||||
|
||||
pfile_info if != NULL, the *pfile_info structure will contain somes info about the current file
|
||||
filename if != NULL, the file name string will be copied in filename
|
||||
filename_size is the size of the filename buffer
|
||||
extrafield if != NULL, the extra field information from the central header will be copied in to
|
||||
extrafield_size is the size of the extraField buffer
|
||||
comment if != NULL, the comment string of the file will be copied in to
|
||||
comment_size is the size of the comment buffer */
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, uint32_t 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.
|
||||
|
||||
return number of bytes copied in buf, or (if <0) the error code */
|
||||
|
||||
extern int ZEXPORT 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 */
|
||||
|
||||
/***************************************************************************/
|
||||
/* Browse the directory of the zipfile */
|
||||
|
||||
typedef int (*unzFileNameComparer)(unzFile file, const char *filename1, const char *filename2);
|
||||
typedef int (*unzIteratorFunction)(unzFile file);
|
||||
typedef int (*unzIteratorFunction2)(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size);
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile(unzFile file);
|
||||
/* Set the current file of the zipfile to the first file.
|
||||
|
||||
return UNZ_OK if no error */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile2(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size);
|
||||
/* Set the current file of the zipfile to the first file and retrieves the current info on success.
|
||||
Not as seek intensive as unzGoToFirstFile + unzGetCurrentFileInfo.
|
||||
|
||||
return UNZ_OK if no error */
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile(unzFile file);
|
||||
/* Set the current file of the zipfile to the next file.
|
||||
|
||||
return UNZ_OK if no error
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest */
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile2(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size);
|
||||
/* Set the current file of the zipfile to the next file and retrieves the current
|
||||
info on success. Does less seeking around than unzGotoNextFile + unzGetCurrentFileInfo.
|
||||
|
||||
return UNZ_OK if no error
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest */
|
||||
|
||||
extern int ZEXPORT unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func);
|
||||
/* Try locate the file szFileName in the zipfile. For custom filename comparison pass in comparison function.
|
||||
|
||||
return UNZ_OK if the file is found (it becomes the current file)
|
||||
return UNZ_END_OF_LIST_OF_FILE if the file is not found */
|
||||
|
||||
/***************************************************************************/
|
||||
/* Raw access to zip file */
|
||||
|
||||
typedef struct unz_file_pos_s
|
||||
{
|
||||
uint32_t pos_in_zip_directory; /* offset in zip file directory */
|
||||
uint32_t num_of_file; /* # of file */
|
||||
} unz_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos *file_pos);
|
||||
extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos *file_pos);
|
||||
|
||||
typedef struct unz64_file_pos_s
|
||||
{
|
||||
uint64_t pos_in_zip_directory; /* offset in zip file directory */
|
||||
uint64_t num_of_file; /* # of file */
|
||||
} unz64_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos *file_pos);
|
||||
extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos);
|
||||
|
||||
extern int32_t ZEXPORT unzGetOffset(unzFile file);
|
||||
extern int64_t ZEXPORT unzGetOffset64(unzFile file);
|
||||
/* Get the current file offset */
|
||||
|
||||
extern int ZEXPORT unzSetOffset(unzFile file, uint32_t pos);
|
||||
extern int ZEXPORT unzSetOffset64(unzFile file, uint64_t pos);
|
||||
/* Set the current file offset */
|
||||
|
||||
extern int32_t ZEXPORT unzTell(unzFile file);
|
||||
extern int64_t ZEXPORT unzTell64(unzFile file);
|
||||
/* return current position in uncompressed data */
|
||||
|
||||
extern int ZEXPORT unzSeek(unzFile file, uint32_t offset, int origin);
|
||||
extern int ZEXPORT unzSeek64(unzFile file, uint64_t offset, int origin);
|
||||
/* Seek within the uncompressed data if compression method is storage */
|
||||
|
||||
extern int ZEXPORT unzEndOfFile(unzFile file);
|
||||
/* return 1 if the end of file was reached, 0 elsewhere */
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _UNZ_H */
|
13
include/version.h
Normal file
13
include/version.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Makefile appends preprocessor flags instead now
|
||||
#ifndef WorldSpawn_VERSION
|
||||
#error no WorldSpawn_VERSION defined
|
||||
#endif
|
||||
#ifndef WorldSpawn_MAJOR_VERSION
|
||||
#error no WorldSpawn_MAJOR_VERSION defined
|
||||
#endif
|
||||
#ifndef WorldSpawn_MINOR_VERSION
|
||||
#error no WorldSpawn_MINOR_VERSION defined
|
||||
#endif
|
||||
#ifndef WorldSpawn_PATCH_VERSION
|
||||
#error no WorldSpawn_PATCH_VERSION defined
|
||||
#endif
|
32
include/warnings.h
Normal file
32
include/warnings.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_WARNINGS_H )
|
||||
#define INCLUDED_WARNINGS_H
|
||||
|
||||
#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
|
||||
|
||||
#endif
|
92
include/windowobserver.h
Normal file
92
include/windowobserver.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_WINDOWOBSERVER_H )
|
||||
#define INCLUDED_WINDOWOBSERVER_H
|
||||
|
||||
template<typename Enumeration> class BitFieldValue;
|
||||
struct ModifierEnumeration;
|
||||
typedef BitFieldValue<ModifierEnumeration> ModifierFlags;
|
||||
|
||||
template<typename Enumeration> class EnumeratedValue;
|
||||
struct ButtonEnumeration;
|
||||
typedef EnumeratedValue<ButtonEnumeration> ButtonIdentifier;
|
||||
|
||||
|
||||
#include "generic/bitfield.h"
|
||||
|
||||
struct ModifierEnumeration
|
||||
{
|
||||
enum Value
|
||||
{
|
||||
SHIFT = 0,
|
||||
CONTROL = 1,
|
||||
ALT = 2
|
||||
};
|
||||
};
|
||||
|
||||
typedef BitFieldValue<ModifierEnumeration> ModifierFlags;
|
||||
|
||||
const ModifierFlags c_modifierNone;
|
||||
const ModifierFlags c_modifierShift( ModifierEnumeration::SHIFT );
|
||||
const ModifierFlags c_modifierControl( ModifierEnumeration::CONTROL );
|
||||
const ModifierFlags c_modifierAlt( ModifierEnumeration::ALT );
|
||||
|
||||
#include "generic/enumeration.h"
|
||||
|
||||
struct ButtonEnumeration
|
||||
{
|
||||
enum Value
|
||||
{
|
||||
INVALID = 0,
|
||||
LEFT = 1,
|
||||
MIDDLE = 3,
|
||||
RIGHT = 2
|
||||
};
|
||||
};
|
||||
|
||||
typedef EnumeratedValue<ButtonEnumeration> ButtonIdentifier;
|
||||
|
||||
const ButtonIdentifier c_buttonInvalid( ButtonEnumeration::INVALID );
|
||||
const ButtonIdentifier c_buttonLeft( ButtonEnumeration::LEFT );
|
||||
const ButtonIdentifier c_buttonMiddle( ButtonEnumeration::MIDDLE );
|
||||
const ButtonIdentifier c_buttonRight( ButtonEnumeration::RIGHT );
|
||||
|
||||
|
||||
template<typename Element>
|
||||
class BasicVector2;
|
||||
typedef BasicVector2<float> Vector2;
|
||||
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;
|
||||
virtual void onMouseUp( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers ) = 0;
|
||||
virtual void onMouseMotion( const WindowVector& position, ModifierFlags modifiers ) = 0;
|
||||
virtual void onModifierDown( ModifierFlags modifier ) = 0;
|
||||
virtual void onModifierUp( ModifierFlags modifier ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
212
include/zip.h
Normal file
212
include/zip.h
Normal file
|
@ -0,0 +1,212 @@
|
|||
/* zip.h -- IO on .zip files using zlib
|
||||
Version 1.2.0, September 16th, 2017
|
||||
part of the MiniZip project
|
||||
|
||||
Copyright (C) 2012-2017 Nathan Moinvaziri
|
||||
https://github.com/nmoinvaz/minizip
|
||||
Copyright (C) 2009-2010 Mathias Svensson
|
||||
Modifications for Zip64 support
|
||||
http://result42.com
|
||||
Copyright (C) 1998-2010 Gilles Vollant
|
||||
http://www.winimage.com/zLibDll/minizip.html
|
||||
|
||||
This program is distributed under the terms of the same license as zlib.
|
||||
See the accompanying LICENSE file for the full text of the license.
|
||||
*/
|
||||
|
||||
#ifndef _ZIP_H
|
||||
#define _ZIP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
# include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
# include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BZIP2
|
||||
# include "bzlib.h"
|
||||
#endif
|
||||
|
||||
#define Z_BZIP2ED 12
|
||||
|
||||
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagzipFile__ { int unused; } zip_file__;
|
||||
typedef zip_file__ *zipFile;
|
||||
#else
|
||||
typedef voidp zipFile;
|
||||
#endif
|
||||
|
||||
#define ZIP_OK (0)
|
||||
#define ZIP_EOF (0)
|
||||
#define ZIP_ERRNO (Z_ERRNO)
|
||||
#define ZIP_PARAMERROR (-102)
|
||||
#define ZIP_BADZIPFILE (-103)
|
||||
#define ZIP_INTERNALERROR (-104)
|
||||
|
||||
#ifndef DEF_MEM_LEVEL
|
||||
# if MAX_MEM_LEVEL >= 8
|
||||
# define DEF_MEM_LEVEL 8
|
||||
# else
|
||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t dos_date;
|
||||
uint16_t internal_fa; /* internal file attributes 2 bytes */
|
||||
uint32_t external_fa; /* external file attributes 4 bytes */
|
||||
} zip_fileinfo;
|
||||
|
||||
#define APPEND_STATUS_CREATE (0)
|
||||
#define APPEND_STATUS_CREATEAFTER (1)
|
||||
#define APPEND_STATUS_ADDINZIP (2)
|
||||
|
||||
/***************************************************************************/
|
||||
/* Writing a zip file */
|
||||
|
||||
extern zipFile ZEXPORT zipOpen(const char *path, int append);
|
||||
extern zipFile ZEXPORT zipOpen64(const void *path, int append);
|
||||
/* Create a zipfile.
|
||||
|
||||
path should contain the full path (by example, on a Windows XP computer
|
||||
"c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip".
|
||||
|
||||
return NULL if zipfile cannot be opened
|
||||
return zipFile handle if no error
|
||||
|
||||
If the file path exist and append == APPEND_STATUS_CREATEAFTER, the zip
|
||||
will be created at the end of the file. (useful if the file contain a self extractor code)
|
||||
If the file path exist and append == APPEND_STATUS_ADDINZIP, we will add files in existing
|
||||
zip (be sure you don't add file that doesn't exist)
|
||||
|
||||
NOTE: There is no delete function into a zipfile. If you want delete file into a zipfile,
|
||||
you must open a zipfile, and create another. Of course, you can use RAW reading and writing to copy
|
||||
the file you did not want delete. */
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2(const char *path, int append, const char **globalcomment,
|
||||
zlib_filefunc_def *pzlib_filefunc_def);
|
||||
|
||||
extern zipFile ZEXPORT zipOpen2_64(const void *path, int append, const char **globalcomment,
|
||||
zlib_filefunc64_def *pzlib_filefunc_def);
|
||||
|
||||
extern zipFile ZEXPORT zipOpen3(const char *path, int append, uint64_t disk_size,
|
||||
const char **globalcomment, zlib_filefunc_def *pzlib_filefunc_def);
|
||||
/* Same as zipOpen2 but allows specification of spanned zip size */
|
||||
|
||||
extern zipFile ZEXPORT zipOpen3_64(const void *path, int append, uint64_t disk_size,
|
||||
const char **globalcomment, zlib_filefunc64_def *pzlib_filefunc_def);
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t method, int level);
|
||||
/* Open a file in the ZIP for writing.
|
||||
|
||||
filename : the filename in zip (if NULL, '-' without quote will be used
|
||||
*zipfi contain supplemental information
|
||||
extrafield_local buffer to store the local header extra field data, can be NULL
|
||||
size_extrafield_local size of extrafield_local buffer
|
||||
extrafield_global buffer to store the global header extra field data, can be NULL
|
||||
size_extrafield_global size of extrafield_local buffer
|
||||
comment buffer for comment string
|
||||
method contain the compression method (0 for store, Z_DEFLATED for deflate)
|
||||
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
|
||||
zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
|
||||
this MUST be '1' if the uncompressed size is >= 0xffffffff. */
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int zip64);
|
||||
/* Same as zipOpenNewFileInZip with zip64 support */
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw);
|
||||
/* Same as zipOpenNewFileInZip, except if raw=1, we write raw file */
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int zip64);
|
||||
/* Same as zipOpenNewFileInZip3 with zip64 support */
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
|
||||
int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting);
|
||||
/* Same as zipOpenNewFileInZip2, except
|
||||
windowBits, memLevel, strategy : see parameter strategy in deflateInit2
|
||||
password : crypting password (NULL for no crypting)
|
||||
crc_for_crypting : crc of file to compress (needed for crypting) */
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
|
||||
int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, int zip64);
|
||||
/* Same as zipOpenNewFileInZip3 with zip64 support */
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
|
||||
int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, uint16_t version_madeby, uint16_t flag_base);
|
||||
/* Same as zipOpenNewFileInZip3 except versionMadeBy & flag fields */
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
|
||||
uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
|
||||
int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, uint16_t version_madeby, uint16_t flag_base, int zip64);
|
||||
/* Same as zipOpenNewFileInZip4 with zip64 support */
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip5(zipFile file,
|
||||
const char *filename,
|
||||
const zip_fileinfo *zipfi,
|
||||
const void *extrafield_local,
|
||||
uint16_t size_extrafield_local,
|
||||
const void *extrafield_global,
|
||||
uint16_t size_extrafield_global,
|
||||
const char *comment,
|
||||
uint16_t flag_base,
|
||||
int zip64,
|
||||
uint16_t method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char *password,
|
||||
int aes);
|
||||
/* Allowing optional aes */
|
||||
|
||||
extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len);
|
||||
/* Write data in the zipfile */
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZip(zipFile file);
|
||||
/* Close the current file in the zipfile */
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uint32_t uncompressed_size, uint32_t crc32);
|
||||
extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, uint64_t uncompressed_size, uint32_t crc32);
|
||||
/* Close the current file in the zipfile, for file opened with parameter raw=1 in zipOpenNewFileInZip2
|
||||
where raw is compressed data. Parameters uncompressed_size and crc32 are value for the uncompressed data. */
|
||||
|
||||
extern int ZEXPORT zipClose(zipFile file, const char *global_comment);
|
||||
/* Close the zipfile */
|
||||
|
||||
extern int ZEXPORT zipClose_64(zipFile file, const char *global_comment);
|
||||
|
||||
extern int ZEXPORT zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby);
|
||||
/* Same as zipClose_64 except version_madeby field */
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ZIP_H */
|
64
libs/CMakeLists.txt
Normal file
64
libs/CMakeLists.txt
Normal file
|
@ -0,0 +1,64 @@
|
|||
add_subdirectory(cmdlib)
|
||||
add_subdirectory(container)
|
||||
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})
|
1
libs/_.cpp
Normal file
1
libs/_.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
|
224
libs/archivelib.h
Normal file
224
libs/archivelib.h
Normal file
|
@ -0,0 +1,224 @@
|
|||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General 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_ARCHIVELIB_H )
|
||||
#define INCLUDED_ARCHIVELIB_H
|
||||
|
||||
#include "debugging/debugging.h"
|
||||
#include "iarchive.h"
|
||||
#include "stream/filestream.h"
|
||||
#include "stream/textfilestream.h"
|
||||
#include "memory/allocator.h"
|
||||
#include "string/string.h"
|
||||
|
||||
/// \brief A single-byte-reader wrapper around an InputStream.
|
||||
/// Optimised for reading one byte at a time.
|
||||
/// Uses a buffer to reduce the number of times the wrapped stream must be read.
|
||||
template<typename InputStreamType, int SIZE = 1024>
|
||||
class SingleByteInputStream
|
||||
{
|
||||
typedef typename InputStreamType::byte_type byte_type;
|
||||
|
||||
InputStreamType& m_inputStream;
|
||||
byte_type m_buffer[SIZE];
|
||||
byte_type* m_cur;
|
||||
byte_type* m_end;
|
||||
|
||||
public:
|
||||
|
||||
SingleByteInputStream( InputStreamType& inputStream ) : m_inputStream( inputStream ), m_cur( m_buffer + SIZE ), m_end( m_cur ){
|
||||
}
|
||||
bool readByte( byte_type& b ){
|
||||
if ( m_cur == m_end ) {
|
||||
if ( m_end != m_buffer + SIZE ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_end = m_buffer + m_inputStream.read( m_buffer, SIZE );
|
||||
m_cur = m_buffer;
|
||||
|
||||
if ( m_end == m_buffer ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
b = *m_cur++;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief A binary-to-text wrapper around an InputStream.
|
||||
/// Converts CRLF or LFCR line-endings to LF line-endings.
|
||||
template<typename BinaryInputStreamType>
|
||||
class BinaryToTextInputStream : public TextInputStream
|
||||
{
|
||||
SingleByteInputStream<BinaryInputStreamType> m_inputStream;
|
||||
public:
|
||||
BinaryToTextInputStream( BinaryInputStreamType& inputStream ) : m_inputStream( inputStream ){
|
||||
}
|
||||
std::size_t read( char* buffer, std::size_t length ){
|
||||
char* p = buffer;
|
||||
for (;; )
|
||||
{
|
||||
if ( length != 0 && m_inputStream.readByte( *reinterpret_cast<typename BinaryInputStreamType::byte_type*>( p ) ) ) {
|
||||
if ( *p != '\r' ) {
|
||||
++p;
|
||||
--length;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return p - buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief An ArchiveFile which is stored uncompressed as part of a larger archive file.
|
||||
class StoredArchiveFile : public ArchiveFile
|
||||
{
|
||||
CopiedString m_name;
|
||||
FileInputStream m_filestream;
|
||||
SubFileInputStream m_substream;
|
||||
FileInputStream::size_type m_size;
|
||||
public:
|
||||
typedef FileInputStream::size_type size_type;
|
||||
typedef FileInputStream::position_type position_type;
|
||||
|
||||
StoredArchiveFile( const char* name, const char* archiveName, position_type position, size_type stream_size, size_type file_size )
|
||||
: m_name( name ), m_filestream( archiveName ), m_substream( m_filestream, position, stream_size ), m_size( file_size ){
|
||||
}
|
||||
|
||||
static StoredArchiveFile* create( const char* name, const char* archiveName, position_type position, size_type stream_size, size_type file_size ){
|
||||
return New<StoredArchiveFile>().scalar( name, archiveName, position, stream_size, file_size );
|
||||
}
|
||||
|
||||
void release(){
|
||||
Delete<StoredArchiveFile>().scalar( this );
|
||||
}
|
||||
size_type size() const {
|
||||
return m_size;
|
||||
}
|
||||
const char* getName() const {
|
||||
return m_name.c_str();
|
||||
}
|
||||
InputStream& getInputStream(){
|
||||
return m_substream;
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief An ArchiveTextFile which is stored uncompressed as part of a larger archive file.
|
||||
class StoredArchiveTextFile : public ArchiveTextFile
|
||||
{
|
||||
CopiedString m_name;
|
||||
FileInputStream m_filestream;
|
||||
SubFileInputStream m_substream;
|
||||
BinaryToTextInputStream<SubFileInputStream> m_textStream;
|
||||
public:
|
||||
typedef FileInputStream::size_type size_type;
|
||||
typedef FileInputStream::position_type position_type;
|
||||
|
||||
StoredArchiveTextFile( const char* name, const char* archiveName, position_type position, size_type stream_size )
|
||||
: m_name( name ), m_filestream( archiveName ), m_substream( m_filestream, position, stream_size ), m_textStream( m_substream ){
|
||||
}
|
||||
|
||||
static StoredArchiveTextFile* create( const char* name, const char* archiveName, position_type position, size_type stream_size ){
|
||||
return New<StoredArchiveTextFile>().scalar( name, archiveName, position, stream_size );
|
||||
}
|
||||
|
||||
void release(){
|
||||
Delete<StoredArchiveTextFile>().scalar( this );
|
||||
}
|
||||
const char* getName() const {
|
||||
return m_name.c_str();
|
||||
}
|
||||
TextInputStream& getInputStream(){
|
||||
return m_textStream;
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief An ArchiveFile which is stored as a single file on disk.
|
||||
class DirectoryArchiveFile : public ArchiveFile
|
||||
{
|
||||
CopiedString m_name;
|
||||
FileInputStream m_istream;
|
||||
FileInputStream::size_type m_size;
|
||||
public:
|
||||
typedef FileInputStream::size_type size_type;
|
||||
|
||||
DirectoryArchiveFile( const char* name, const char* filename )
|
||||
: m_name( name ), m_istream( filename ){
|
||||
if ( !failed() ) {
|
||||
m_istream.seek( 0, FileInputStream::end );
|
||||
m_size = m_istream.tell();
|
||||
m_istream.seek( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_size = 0;
|
||||
}
|
||||
}
|
||||
bool failed() const {
|
||||
return m_istream.failed();
|
||||
}
|
||||
|
||||
void release(){
|
||||
delete this;
|
||||
}
|
||||
size_type size() const {
|
||||
return m_size;
|
||||
}
|
||||
const char* getName() const {
|
||||
return m_name.c_str();
|
||||
}
|
||||
InputStream& getInputStream(){
|
||||
return m_istream;
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief An ArchiveTextFile which is stored as a single file on disk.
|
||||
class DirectoryArchiveTextFile : public ArchiveTextFile
|
||||
{
|
||||
CopiedString m_name;
|
||||
TextFileInputStream m_inputStream;
|
||||
public:
|
||||
|
||||
DirectoryArchiveTextFile( const char* name, const char* filename )
|
||||
: m_name( name ), m_inputStream( filename ){
|
||||
}
|
||||
bool failed() const {
|
||||
return m_inputStream.failed();
|
||||
}
|
||||
|
||||
void release(){
|
||||
delete this;
|
||||
}
|
||||
const char* getName() const {
|
||||
return m_name.c_str();
|
||||
}
|
||||
TextInputStream& getInputStream(){
|
||||
return m_inputStream;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue