- Timestamp:
- May 18, 2006, 12:55:34 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 33 edited
- 27 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/acinclude.m4
r6274 r7661 10 10 if [test "x$_header_check" = "xyes" && test "x$_lib_check" = "xyes"] ; then 11 11 LIBS="$LIBS -l$2" 12 12 $4 13 13 else 14 14 echo "no Support for $2" 15 15 $5 16 16 fi 17 17 ]) … … 34 34 if [test x$_header_check = "xyes" && test "x$_lib_check" = "xyes"] ; then 35 35 LIBS="$LIBS -l$2" 36 36 $4 37 37 else 38 38 echo "------------------" … … 40 40 echo "please install the $2-LIBRARY-package which can be found at $6" 41 41 echo "------------------" 42 42 $5 43 43 exit -1 44 44 fi 45 45 ]) 46 47 48 49 dnl AX_CHECK_REQUIRED_LIB([LIBRARY-NAME], [FUNCTION-IN-LIB], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [LIB-WEB-PAGE]) 50 AC_DEFUN([AX_CHECK_REQUIRED_LIB], [ 51 _lib_check="" 52 _found_lib="" 53 54 55 for _lib in $1 56 do 57 AC_CHECK_LIB([$_lib], [$2], [_lib_check="yes"], [_lib_check="no"]) 58 if test "x$_lib_check" = "xyes" ; then 59 _found_lib=$_lib 60 break 61 fi 62 done 63 64 if [test "x$_lib_check" = "xyes"] ; then 65 LIBS="$LIBS -l$_found_lib" 66 $3 67 else 68 echo "------------------" 69 echo "LIBRARY $1 not found." 70 echo "please install the $1-LIBRARY-package which can be found at $5" 71 echo "------------------" 72 $4 73 exit -1 74 fi 75 ]) 76 77 78 79 80 dnl AX_CHECK_QT([QTDIR], [LIBRARIES], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [LIB-WEB-PAGE]) 81 AC_DEFUN([AX_CHECK_QT], [ 82 _lib_check="" 83 _found_lib="" 84 QT_PREFIX="$1" 85 QT_INCLUDE_DIRECTORY="" 86 QT_LIB_DIRECTORY="" 87 88 89 QT_COMMON_INCLUDE_DIRECTORIES=" 90 `ls -dr ${QT_PREFIX}/include 2>/dev/null` 91 /usr/include 92 `ls -dr /usr/include/qt* 2>/dev/null` 93 `ls -dr /usr/lib/qt*/include 2>/dev/null` 94 `ls -dr /usr/local/qt*/include 2>/dev/null` 95 `ls -dr /opt/qt*/include 2>/dev/null` 96 `ls -dr /Developer/qt*/include 2>/dev/null` 97 " 98 99 QT_COMMON_LIB_DIRECTORIES=" 100 `ls -dr ${QT_PREFIX}/lib 2>/dev/null` 101 /usr/include 102 `ls -dr /usr/lib/qt* 2>/dev/null` 103 `ls -dr /usr/lib/qt* 2>/dev/null` 104 `ls -dr /usr/local/qt*/lib 2>/dev/null` 105 `ls -dr /opt/qt*/lib 2>/dev/null` 106 `ls -dr /Developer/qt*/lib 2>/dev/null` 107 " 108 109 ## Search in all IncludeDirectories for QT-includes 110 for _include_directory in ${QT_COMMON_INCLUDE_DIRECTORIES} 111 do 112 if test -e ${_include_directory}/Qt/QtCore ; then 113 QT_INCLUDE_DIRECTORY=${_include_directory} 114 break 115 fi 116 done 117 if test -n ${QT_INCLUDE_DIRECTORY} ; then 118 echo "Qt-Include Directory is: ${QT_INCLUDE_DIRECTORY}" 119 else 120 AC_MSG_ERROR([Qt Headers not found]) 121 fi 122 123 ## Search in all LibraryDirectories for QT-includes 124 for _lib_directory in ${QT_COMMON_LIB_DIRECTORIES} 125 do 126 if test -e ${_lib_directory}/libQtCore.so || test -e ${_lib_directory}/libQtCore.dll ; then 127 QT_LIB_DIRECTORY=${_lib_directory} 128 break 129 fi 130 done 131 if test -n ${QT_LIB_DIRECTORY} ; then 132 echo "Qt-Library Directory is: ${QT_LIB_DIRECTORY}" 133 else 134 AC_MSG_ERROR([Qt LIB not found]) 135 fi 136 137 ## Setting up the Environment Variables. 138 QT_LIBS="" 139 QT_CXXFLAGS="-I${QT_INCLUDE_DIRECTORY}" 140 LDFLAGS="${LDFLAGS} -L${QT_LIB_DIRECTORY} -Wl,-rpath -Wl,${QT_LIB_DIRECTORY}" 141 QT_BIN_DIR="${QT_PREFIX}/bin" 142 143 CACHED_CPPFLAG=${CPPFLAGS} 144 CACHED_LDFLAGS=${LDFLAGS} 145 146 LDFLAGS="${LDFLAGS} ${QT_LDFLAGS}" 147 for _lib in $2 148 do 149 AC_CHECK_LIB([$_lib], [main], [_lib_check="yes"], [_lib_check="no"]) 150 if test "x$_lib_check" = "xyes" ; then 151 _found_lib=$_lib 152 break 153 fi 154 done 155 156 if [test "x$_lib_check" = "xyes"] ; then 157 QT_LIBS="${QT_LIBS} -l$_found_lib" 158 AX_CHECK_REQUIRED_LIB([QtCore QtCore4], [main],,,[http://www.trolltech.com] ) 159 AX_CHECK_REQUIRED_LIB([QtGui QtGui4], [main],,,[http://www.trolltech.com] ) 160 AX_CHECK_REQUIRED_LIB([QtOpenGL QtOpenGL4], [main],,,[http://www.trolltech.com] ) 161 162 $3 163 else 164 echo "------------------" 165 echo "LIBRARY $2 not found.in $1" 166 echo "please install the $1-LIBRARY-package which can be found at $5" 167 echo "------------------" 168 $4 169 exit -1 170 fi 171 172 echo "QT_LIBS = ${QT_LIBS}" 173 echo "QT_CXXFLAGS = ${QT_CXXFLAGS}" 174 echo "QT_LD_FLAGS = ${QT_LDFLAGS}" 175 176 AC_SUBST([QT_LIBS]) 177 AC_SUBST([QT_CXXFLAGS]) 178 AC_SUBST([QT_LDFLAGS]) 179 180 #----------# 181 # QT - MOC # 182 #----------# 183 AC_PATH_PROG([QT_MOC], [moc], [no], ["${QT_BIN_DIR}:${PATH}"]) 184 if test x${QT_MOC} = xno ; then 185 AC_MSG_ERROR([QT MOC not found]) 186 fi 187 AC_SUBST([QT_MOC]) 188 189 AC_PATH_PROG([QT_UIC], [uic], [no], ["${QT_BIN_DIR}:${PATH}"]) 190 # if test x${QT_UIC} = xno ; then 191 # AC_MSG_WARN([QT UIC not found]) 192 # fi 193 AC_SUBST([QT_UIC]) 194 195 AC_PATH_PROG([QT_RCC], [rcc], [no], ["${QT_BIN_DIR}:${PATH}"]) 196 # if test x${QT_RCC} = xno ; then 197 # AC_MSG_WARN([QT RCC not found]) 198 # fi 199 AC_SUBST([QT_RCC]) 200 201 202 203 # Restore Values of CPPFLAGS and LDFLAGS 204 CPPFLAGS=${CACHED_CPPFLAG} 205 LDFLAGS=${CACHED_LDFLAGS} 206 ]) -
trunk/config.h.in
r6838 r7661 1 1 /* config.h.in. Generated from configure.ac by autoheader. */ 2 3 /* Define to the read-only architecture-independent data directory. */4 #undef DATADIR5 2 6 3 /* in which debug mode we are */ … … 95 92 #undef MODULAR_DEBUG 96 93 94 /* Define to the read-only architecture-independent data directory of ORXONOX. 95 */ 96 #undef ORX_DATADIR 97 97 98 /* Name of package */ 98 99 #undef PACKAGE -
trunk/configure.ac
r7256 r7661 38 38 AM_INIT_AUTOMAKE 39 39 40 AC_CONFIG_SRCDIR([ ./src])40 AC_CONFIG_SRCDIR([src/orxonox.cc]) 41 41 AC_CONFIG_HEADER([config.h]) 42 42 … … 64 64 echo "given: $DATA_DIR" 65 65 fi 66 AC_DEFINE_UNQUOTED([ DATADIR], ["$DATA_DIR"],66 AC_DEFINE_UNQUOTED([ORX_DATADIR], ["$DATA_DIR"], 67 67 [Define to the read-only architecture-independent 68 data directory .])68 data directory of ORXONOX.]) 69 69 70 70 #-----------------# … … 108 108 fi 109 109 fi 110 111 if test $DEBUD > 3 ; then 112 CPPFLAGS="${CPPFLAGS} -g" 113 fi 110 114 AC_DEFINE_UNQUOTED(DEBUG, $DEBUG, [in which debug mode we are]) 111 115 AC_SUBST(DEBUG) … … 127 131 fi 128 132 129 #--------------#130 # GTK-disabled #131 #--------------#132 AC_MSG_CHECKING([if gtk should be enabled])133 AC_ARG_ENABLE([gtk],134 AS_HELP_STRING(--disable-gtk,Prevents GTK from being loaded), [def_gtk=no], [def_gtk=yes])135 if test x$def_gtk = xyes; then136 echo "yes"137 fi138 if test x$def_gtk = xno; then139 echo "no"140 fi141 133 142 134 #------------------# … … 152 144 echo "no" 153 145 fi 146 147 #--------------# 148 # GTK-disabled # 149 #--------------# 150 151 AC_MSG_CHECKING([if gtk should be enabled]) 152 AC_ARG_WITH([gtk], 153 AS_HELP_STRING(--with-gtk, uses GTK for the GUI), [def_gtk=yes], [def_gtk=no]) 154 if test x$def_gtk = xyes; then 155 echo "yes - will be overwritten if Qt is enabled" 156 fi 157 if test x$def_gtk = xno; then 158 echo "no" 159 fi 160 161 154 162 155 163 #-------------------# … … 211 219 fi 212 220 AM_CONDITIONAL(DOCUMENTATION, test x$def_documentation = xyes) 213 214 215 221 216 222 #---------------------------# … … 228 234 CPPFLAGS="${CPPFLAGS} -I${PREFIX}/include" 229 235 LDFLAGS="${LDFLAGS} -L$PREFIX/${ARCH}/lib -Wl,-rpath -Wl,${PREFIX}/${ARCH}/lib" 236 237 ## QT 238 QT_PREFIX=/usr/pack/qt-4.1.1-mo/${ARCH} 239 # CPPFLAGS="${CPPFLAGS} -I${PREFIX_QT}/include" 240 # LDFLAGS="${LDFLAGS} -L${QT_PREFIX}/lib -Wl,-rpath -Wl,${QT_PREFIX}/${ARCH}/lib" 241 242 243 230 244 ## GTK 231 245 GTKPREFIX=/usr/pack/gtk-2.8.3-mo … … 238 252 echo "no" 239 253 fi 254 255 240 256 241 257 ####################### … … 272 288 ## here the system is checked, and openGL is included 273 289 ## also checking for SDL on differen Systems 274 275 CPPFLAGS="$CPPFLAGS -g"276 277 290 278 291 AC_MSG_CHECKING([for System]) … … 557 570 558 571 559 #---------# 560 # libcURL # 561 #---------# 562 AX_CHECK_HEADER_LIB([curl/curl.h], [curl], [main], [ 563 have_curl=yes 564 CURL_LIBS=`curl-config --libs` 565 CURLCFLAGS=`curl-config --cflags` 566 AC_DEFINE_UNQUOTED(HAVE_CURL, 1, [if we have CURL]) ] 567 ,, [http://curl.haxx.se/]) 568 569 AC_SUBST(CURL_LIBS) 570 AC_SUBST(CURL_CFLAGS) 571 AM_CONDITIONAL(HAVE_CURL, test "x$have_curl" = "xyes") 572 573 #--------# 574 # efence # 575 #--------# 576 if test x$def_efence = xyes ; then 577 AC_CHECK_LIB([efence], [main], [FOUND_efence=yes; LIBS="$LIBS -lefence"]) 578 if test x$FOUND_efence != xyes ; then 579 echo "efence was requested, but is not installed!! going on" 580 fi 581 582 fi 572 #----# 573 # QT # 574 #----# 575 AX_CHECK_QT([${QT_PREFIX}], [QtCore],, [http://www.trolltech.com]) 576 if test x$have_qt = xno ; then 577 WITH_QT=no 578 fi 579 583 580 584 581 #-----# … … 607 604 AM_CONDITIONAL(HAVE_GTK2, test x$have_gtk2 = xyes) 608 605 606 607 #---------# 608 # libcURL # 609 #---------# 610 AX_CHECK_HEADER_LIB([curl/curl.h], [curl], [main], [ 611 have_curl=yes 612 CURL_LIBS=`curl-config --libs` 613 CURLCFLAGS=`curl-config --cflags` 614 AC_DEFINE_UNQUOTED(HAVE_CURL, 1, [if we have CURL]) ] 615 ,, [http://curl.haxx.se/]) 616 617 AC_SUBST(CURL_LIBS) 618 AC_SUBST(CURL_CFLAGS) 619 AM_CONDITIONAL(HAVE_CURL, test "x$have_curl" = "xyes") 620 621 #--------# 622 # efence # 623 #--------# 624 if test x$def_efence = xyes ; then 625 AC_CHECK_LIB([efence], [main], [FOUND_efence=yes; LIBS="$LIBS -lefence"]) 626 if test x$FOUND_efence != xyes ; then 627 echo "efence was requested, but is not installed!! going on" 628 fi 629 630 fi 609 631 610 632 # FIXME: Replace `main' with a function in `-lm': … … 643 665 src/lib/gui/gtk_gui/Makefile 644 666 src/lib/gui/gl_gui/Makefile 667 src/lib/gui/qt_gui/Makefile 645 668 src/lib/parser/Makefile 646 669 src/lib/parser/tinyxml/Makefile 647 670 src/lib/parser/ini_parser/Makefile 648 671 src/lib/parser/cmdline_parser/Makefile 649 672 src/lib/parser/preferences/Makefile 650 673 src/util/Makefile 651 674 src/world_entities/Makefile -
trunk/src/Makefile.am
r7462 r7661 12 12 bin_PROGRAMS = orxonox 13 13 14 orxonox_CPPFLAGS = -DIS_ORXONOX 15 orxonox_LDFLAGS = -u global_ModelParticles_Factory 14 orxonox_CPPFLAGS = \ 15 -DIS_ORXONOX \ 16 @QT_CXXFLAGS@ 17 18 orxonox_LDFLAGS = @QT_LDFLAGS@ 16 19 17 20 orxonox_DEPENDENCIES = \ … … 24 27 util/libORXutils.a \ 25 28 $(libORXlibs_a_LIBRARIES_) \ 26 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) 29 $(CURL_LIBS) \ 30 @QT_LIBS@ 27 31 28 32 orxonox_SOURCES = \ … … 66 70 67 71 ## orxonox.conf will be used from home-dir instead. 68 EXTRA_DIST = proto/proto_class.h \ 69 proto/proto_class.cc \ 70 proto/proto_singleton.h \ 71 proto/proto_singleton.cc \ 72 proto/proto_world_entity.h \ 73 proto/proto_world_entity.cc \ 74 defs/include_paths.am \ 75 story_entities/Makefile.am 72 EXTRA_DIST = \ 73 proto/proto_class.h \ 74 proto/proto_class.cc \ 75 proto/proto_singleton.h \ 76 proto/proto_singleton.cc \ 77 proto/proto_world_entity.h \ 78 proto/proto_world_entity.cc \ 79 defs/include_paths.am \ 80 story_entities/Makefile.am 76 81 77 82 if SUB_PROJECTS … … 81 86 endif 82 87 83 SUBDIRS = lib \ 84 util \ 85 world_entities \ 86 . \ 87 $(SUB_PROGS) 88 SUBDIRS = \ 89 lib \ 90 util \ 91 world_entities \ 92 . \ 93 $(SUB_PROGS) 88 94 89 95 -
trunk/src/defs/class_id.h
r7486 r7661 322 322 CL_GLGUI_BAR = 0x00000b30, 323 323 324 // QT_GUI 325 CL_GUI_SAVEABLE = 0x00b10000, 326 CL_QTGUI_BUTTON = 0x00000ba0, 327 CL_QTGUI_PUSHBUTTON = 0x00000ba3, 328 CL_QTGUI_CHECKBUTTON = 0x00000ba4, 329 CL_QTGUI_RADIOBUTTON = 0x00000ba5, 330 CL_QTGUI_CONTAINER = 0x00b200a0, 331 CL_QTGUI_BOX = 0x00000ba7, 332 CL_QTGUI_FRAME = 0x00000ba8, 333 CL_QTGUI_WINDOW = 0x00000ba9, 334 CL_QTMENU_IMAGE_SCREEN = 0x00000ba0, 335 CL_QTGUI_BAR = 0x00000ba0, 336 324 337 /// AUDIO stuff (range from 0x00000c00 to 0x00000cff) 325 338 CL_SOUND_BUFFER = 0x00000c01, -
trunk/src/defs/debug.h
r7374 r7661 28 28 #include "confincl.h" 29 29 #ifndef NO_SHELL 30 #include "shell_buffer.h"30 #include "lib/shell/shell_buffer.h" 31 31 #endif /* NO_SHELL */ 32 32 -
trunk/src/defs/globals.h
r7256 r7661 25 25 #define DEFAULT_CONFIG_FILE "~/.orxonox/orxonox.conf" 26 26 #define DEFAULT_LOCK_FILE "~/.orxonox/orxonox.lock" 27 #define DEFAULT_DATA_DIR DATADIR "/orxonox/"27 #define DEFAULT_DATA_DIR ORX_DATADIR "/orxonox/" 28 28 #define DEFAULT_DATA_DIR_CHECKFILE "data.oxd" 29 29 … … 33 33 //! Name of Section Misc in the config-File 34 34 #define CONFIG_SECTION_MISC "misc" 35 #define CONFIG_SECTION_MISC_KEYS "miscKeys" 36 #define CONFIG_SECTION_PLAYER "player" 35 #define CONFIG_SECTION_CONTROL "control" 37 36 #define CONFIG_SECTION_VIDEO "video" 38 37 #define CONFIG_SECTION_VIDEO_ADVANCED "video_advanced" 39 38 #define CONFIG_SECTION_AUDIO "audio" 40 #define CONFIG_SECTION_EXEC "exec" 41 #define CONFIG_SECTION_DATA "data" 39 #define CONFIG_SECTION_GENERAL "general" 42 40 43 41 /* … … 54 52 #define CONFIG_NAME_FOG "Fog" 55 53 #define CONFIG_NAME_REFLECTIONS "Reflections" 56 #define CONFIG_NAME_TEXTURES "T EXTURES"54 #define CONFIG_NAME_TEXTURES "Textures" 57 55 #define CONFIG_NAME_TEXTURE_DETAIL "Texture-Detail" 58 56 #define CONFIG_NAME_MODEL_DETAIL "Model-Detail" … … 61 59 #define CONFIG_NAME_FILTER_METHOD "Filtering-Method" 62 60 61 #define CONFIG_NAME_SOUNDCARD "Soundcard" 63 62 #define CONFIG_NAME_DISABLE_AUDIO "Disable-Audio" 64 63 #define CONFIG_NAME_AUDIO_CHANNELS "Audio-Channels" … … 69 68 #define CONFIG_NAME_VERBOSE_MODE "Verbose-Mode" 70 69 #define CONFIG_NAME_ALWAYS_SHOW_GUI "Always-Show-The-Gui" 70 #define CONFIG_NAME_DEBUG_LEVEL "Debug-Level" 71 71 72 // evenets 72 73 #define CONFIG_NAME_PLAYER_FORWARD "Forward" … … 80 81 81 82 #define CONFIG_NAME_PLAYER_FIRE "Fire" 82 #define CONFIG_NAME_PLAYER_NEXT_WEAPON "Next "83 #define CONFIG_NAME_PLAYER_PREV_WEAPON "Prev "84 #define CONFIG_NAME_PLAYER_CHANGE_SHIP "Change _Ship"83 #define CONFIG_NAME_PLAYER_NEXT_WEAPON "Next-Weapon" 84 #define CONFIG_NAME_PLAYER_PREV_WEAPON "Previous-Weapon" 85 #define CONFIG_NAME_PLAYER_CHANGE_SHIP "Change-Ship" 85 86 86 87 #define CONFIG_NAME_QUIT "Quit" -
trunk/src/lib/BuildLibs.am
r7457 r7661 3 3 $(LIB_PREFIX)/libORXlibs.a \ 4 4 $(LIB_PREFIX)/shell/libORXshell.a \ 5 $(LIB_PREFIX)/gui/ gtk_gui/libORXgui.a \5 $(LIB_PREFIX)/gui/qt_gui/libORXqtgui.a \ 6 6 $(LIB_PREFIX)/gui/gl_gui/libORXglgui.a \ 7 $(LIB_PREFIX)/gui/libORXbasegui.a \ 7 8 $(LIB_PREFIX)/graphics/importer/libORXimporter.a \ 8 9 $(LIB_PREFIX)/graphics/libORXgraphics.a \ -
trunk/src/lib/Makefile.am
r7422 r7661 25 25 util/preferences.cc \ 26 26 util/threading.cc \ 27 util/file.cc \ 28 util/directory.cc \ 27 29 \ 28 30 data/data_tank.cc … … 43 45 util/preferences.h \ 44 46 util/threading.h \ 45 util/osdir.h \ 47 util/file.h \ 48 util/directory.h \ 46 49 \ 47 50 util/loading/resource_manager.h \ -
trunk/src/lib/event/key_mapper.cc
r7256 r7661 27 27 #include "util/preferences.h" 28 28 #include "key_names.h" 29 #include "event_def.h" 29 30 #include "debug.h" 30 31 … … 71 72 * and you do not have to care about The namings, as they might change 72 73 */ 73 orxKeyMapping map[] = { 74 {&KeyMapper::PEV_FORWARD, CONFIG_NAME_PLAYER_FORWARD}, 75 {&KeyMapper::PEV_BACKWARD, CONFIG_NAME_PLAYER_BACKWARD}, 76 {&KeyMapper::PEV_UP, CONFIG_NAME_PLAYER_UP}, 77 {&KeyMapper::PEV_DOWN, CONFIG_NAME_PLAYER_DOWN}, 78 {&KeyMapper::PEV_LEFT, CONFIG_NAME_PLAYER_LEFT}, 79 {&KeyMapper::PEV_RIGHT, CONFIG_NAME_PLAYER_RIGHT}, 80 {&KeyMapper::PEV_ROLL_LEFT, CONFIG_NAME_PLAYER_ROLL_RIGHT}, 81 {&KeyMapper::PEV_ROLL_RIGHT, CONFIG_NAME_PLAYER_ROLL_LEFT}, 82 {&KeyMapper::PEV_STRAFE_LEFT, "StrafeLeft"}, 83 {&KeyMapper::PEV_STRAFE_RIGHT, "StrafeRight"}, 84 85 {&KeyMapper::PEV_FIRE1, CONFIG_NAME_PLAYER_FIRE}, 86 {&KeyMapper::PEV_FIRE1, "Fire1"}, 87 {&KeyMapper::PEV_FIRE2, "Fire2"}, 88 {&KeyMapper::PEV_NEXT_WEAPON, CONFIG_NAME_PLAYER_NEXT_WEAPON}, 89 {&KeyMapper::PEV_PREVIOUS_WEAPON, CONFIG_NAME_PLAYER_PREV_WEAPON}, 90 91 {&KeyMapper::PEV_CHANGE_SHIP, CONFIG_NAME_PLAYER_CHANGE_SHIP}, 92 93 94 {&KeyMapper::PEV_VIEW0, CONFIG_NAME_VIEW0}, 95 {&KeyMapper::PEV_VIEW1, CONFIG_NAME_VIEW1}, 96 {&KeyMapper::PEV_VIEW2, CONFIG_NAME_VIEW2}, 97 {&KeyMapper::PEV_VIEW3, CONFIG_NAME_VIEW3}, 98 {&KeyMapper::PEV_VIEW4, CONFIG_NAME_VIEW4}, 99 {&KeyMapper::PEV_VIEW5, CONFIG_NAME_VIEW5}, 100 101 {&KeyMapper::PEV_NEXT_WORLD, CONFIG_NAME_NEXT_WORLD}, 102 {&KeyMapper::PEV_PREVIOUS_WORLD, CONFIG_NAME_PREV_WORLD}, 103 104 {&KeyMapper::PEV_PAUSE, CONFIG_NAME_PAUSE}, 105 {&KeyMapper::PEV_QUIT, CONFIG_NAME_QUIT}, 106 {NULL, NULL} 74 KeyMapper::KeyMapping KeyMapper::map[] = { 75 {&KeyMapper::PEV_FORWARD, CONFIG_NAME_PLAYER_FORWARD, SDLK_w}, 76 {&KeyMapper::PEV_BACKWARD, CONFIG_NAME_PLAYER_BACKWARD, SDLK_s}, 77 {&KeyMapper::PEV_UP, CONFIG_NAME_PLAYER_UP, SDLK_r}, 78 {&KeyMapper::PEV_DOWN, CONFIG_NAME_PLAYER_DOWN, SDLK_f}, 79 {&KeyMapper::PEV_LEFT, CONFIG_NAME_PLAYER_LEFT, SDLK_a}, 80 {&KeyMapper::PEV_RIGHT, CONFIG_NAME_PLAYER_RIGHT, SDLK_d}, 81 {&KeyMapper::PEV_ROLL_RIGHT, CONFIG_NAME_PLAYER_ROLL_LEFT, SDLK_z}, 82 {&KeyMapper::PEV_ROLL_LEFT, CONFIG_NAME_PLAYER_ROLL_RIGHT, SDLK_c}, 83 {&KeyMapper::PEV_STRAFE_LEFT, "StrafeLeft", SDLK_q}, 84 {&KeyMapper::PEV_STRAFE_RIGHT, "StrafeRight", SDLK_e}, 85 86 {&KeyMapper::PEV_FIRE1, CONFIG_NAME_PLAYER_FIRE, EV_MOUSE_BUTTON_LEFT}, 87 {&KeyMapper::PEV_FIRE2, "Fire2", EV_MOUSE_BUTTON_RIGHT}, 88 {&KeyMapper::PEV_NEXT_WEAPON, CONFIG_NAME_PLAYER_NEXT_WEAPON, EV_MOUSE_BUTTON_WHEELUP}, 89 {&KeyMapper::PEV_PREVIOUS_WEAPON, CONFIG_NAME_PLAYER_PREV_WEAPON, EV_MOUSE_BUTTON_WHEELDOWN}, 90 91 {&KeyMapper::PEV_CHANGE_SHIP, CONFIG_NAME_PLAYER_CHANGE_SHIP, SDLK_g}, 92 93 94 {&KeyMapper::PEV_VIEW0, CONFIG_NAME_VIEW0, SDLK_1}, 95 {&KeyMapper::PEV_VIEW1, CONFIG_NAME_VIEW1, SDLK_2}, 96 {&KeyMapper::PEV_VIEW2, CONFIG_NAME_VIEW2, SDLK_3}, 97 {&KeyMapper::PEV_VIEW3, CONFIG_NAME_VIEW3, SDLK_4}, 98 {&KeyMapper::PEV_VIEW4, CONFIG_NAME_VIEW4, SDLK_5}, 99 {&KeyMapper::PEV_VIEW5, CONFIG_NAME_VIEW5, SDLK_6}, 100 101 {&KeyMapper::PEV_NEXT_WORLD, CONFIG_NAME_NEXT_WORLD, SDLK_x}, 102 {&KeyMapper::PEV_PREVIOUS_WORLD, CONFIG_NAME_PREV_WORLD, SDLK_z}, 103 104 {&KeyMapper::PEV_PAUSE, CONFIG_NAME_PAUSE, SDLK_p}, 105 {&KeyMapper::PEV_QUIT, CONFIG_NAME_QUIT, SDLK_ESCAPE}, 106 {NULL, "", 0} 107 107 }; 108 108 … … 138 138 void KeyMapper::loadKeyBindings(IniParser* iniParser) 139 139 { 140 if( !iniParser->getSection (CONFIG_SECTION_ PLAYER "1"))141 { 142 PRINTF(1)("Could not find key bindings " CONFIG_SECTION_ PLAYER"1\n");140 if( !iniParser->getSection (CONFIG_SECTION_CONTROL)) 141 { 142 PRINTF(1)("Could not find key bindings " CONFIG_SECTION_CONTROL "\n"); 143 143 return; 144 144 } … … 158 158 159 159 // PARSE MISC SECTION 160 if( !iniParser->getSection (CONFIG_SECTION_MISC_KEYS)) 161 { 162 PRINTF(1)("Could not find key bindings" CONFIG_SECTION_MISC_KEYS "\n"); 160 // if( !iniParser->getSection (CONFIG_SECTION_MISC_KEYS)) 161 // { 162 // PRINTF(1)("Could not find key bindings" CONFIG_SECTION_MISC_KEYS "\n"); 163 // return; 164 // } 165 // 166 // iniParser->firstVar(); 167 // while( iniParser->getCurrentName() != "" ) 168 // { 169 // PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue()); 170 // index = nameToIndex (iniParser->getCurrentValue()); 171 // this->mapKeys(iniParser->getCurrentName(), index); 172 // iniParser->nextVar(); 173 // } 174 } 175 176 void KeyMapper::loadKeyBindings() 177 { 178 if( !Preferences::getInstance()->sectionExists(CONFIG_SECTION_CONTROL)) 179 { 180 PRINTF(1)("Could not find key bindings " CONFIG_SECTION_CONTROL "\n"); 163 181 return; 164 182 } 165 166 iniParser->firstVar();167 while( iniParser->getCurrentName() != "" )168 {169 PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());170 index = nameToIndex (iniParser->getCurrentValue());171 this->mapKeys(iniParser->getCurrentName(), index);172 iniParser->nextVar();173 }174 }175 176 void KeyMapper::loadKeyBindings()177 {178 if( !Preferences::getInstance()->sectionExists(CONFIG_SECTION_PLAYER "1"))179 {180 PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1\n");181 return;182 }183 183 int* index; 184 184 185 std::list<std::string> keys = Preferences::getInstance()->listKeys(CONFIG_SECTION_ PLAYER "1");185 std::list<std::string> keys = Preferences::getInstance()->listKeys(CONFIG_SECTION_CONTROL); 186 186 for ( std::list<std::string>::const_iterator it = keys.begin(); it!=keys.end(); it++ ) 187 187 { 188 PRINTF(3)("Keys: Parsing %s, %s now.\n", it->c_str(), Preferences::getInstance()->getString(CONFIG_SECTION_ PLAYER "1", *it, "").c_str());188 PRINTF(3)("Keys: Parsing %s, %s now.\n", it->c_str(), Preferences::getInstance()->getString(CONFIG_SECTION_CONTROL, *it, "").c_str()); 189 189 // map the name to an sdl index 190 index = nameToIndex (Preferences::getInstance()->getString(CONFIG_SECTION_ PLAYER "1", *it, ""));190 index = nameToIndex (Preferences::getInstance()->getString(CONFIG_SECTION_CONTROL, *it, "")); 191 191 // map the index to a internal name 192 this->mapKeys(*it, index);193 }194 195 196 // PARSE MISC SECTION197 if( !Preferences::getInstance()->sectionExists (CONFIG_SECTION_MISC_KEYS))198 {199 PRINTF(1)("Could not find key bindings " CONFIG_SECTION_MISC_KEYS "\n");200 return;201 }202 203 keys = Preferences::getInstance()->listKeys(CONFIG_SECTION_MISC_KEYS);204 for ( std::list<std::string>::const_iterator it = keys.begin(); it!=keys.end(); it++ )205 {206 PRINTF(3)("MISC: Parsing %s, %s now.\n", it->c_str(), Preferences::getInstance()->getString(CONFIG_SECTION_MISC_KEYS, *it, "").c_str());207 index = nameToIndex (Preferences::getInstance()->getString(CONFIG_SECTION_MISC_KEYS, *it, ""));208 192 this->mapKeys(*it, index); 209 193 } … … 266 250 for(int i = 0; map[i].pValue != NULL; ++i) 267 251 { 268 PRINT(0)("%s = %i\n",map[i].pName , *map[i].pValue);252 PRINT(0)("%s = %i\n",map[i].pName.c_str(), *map[i].pValue); 269 253 } 270 254 PRINT(0)("=======================================================\n"); -
trunk/src/lib/event/key_mapper.h
r7256 r7661 10 10 11 11 #include "base_object.h" 12 //#include "event_def.h" 13 12 #include <string> 14 13 class IniParser; 15 14 16 //! A mapping from key-name to key-id17 typedef struct orxKeyMapping 15 //! The map class functionalities 16 class KeyMapper : public BaseObject 18 17 { 19 int* pValue; 20 char* pName; 21 }; 18 public: 19 //! A mapping from key-name to key-id 20 typedef struct KeyMapping 21 { 22 int* pValue; 23 const std::string pName; 24 int defaultValue; 25 }; 22 26 23 24 //! The map class functionalities 25 class KeyMapper : public BaseObject { 26 27 public: 27 public: 28 28 KeyMapper(); 29 29 virtual ~KeyMapper(); … … 33 33 void loadKeyBindings(IniParser* iniParser); 34 34 35 static const KeyMapping* getKeyMapping() { return KeyMapper::map; }; 36 35 37 void debug(); 36 38 37 39 private: 38 40 int* nameToIndex (const std::string& name); 39 41 void mapKeys(const std::string& name, int* index); 40 42 41 43 public: 42 44 static int PEV_FORWARD; //!< forward button 43 45 static int PEV_BACKWARD; //!< backward buttton … … 73 75 static int PEV_QUIT; //!< quit button 74 76 75 private: 76 int coord[2]; //!< temp place to save variables in nameToIndex() function 77 private: 78 int coord[2]; //!< temp place to save variables in nameToIndex() function 79 static KeyMapping map[]; //!< The KeyMapping that maps strings to ID's and Vice Versa 77 80 }; 78 81 -
trunk/src/lib/event/key_names.cc
r7221 r7661 17 17 #include "event_def.h" 18 18 19 #include "stdincl.h" 20 21 #include <string.h> 22 23 using namespace std; 19 std::string EVToKeyName(int key) 20 { 21 std::string name = SDLBToButtonname( key ); 22 if (name != "UNKNOWN") 23 return name; 24 else 25 return SDLKToKeyname( key ); 26 } 27 28 int KeyNameToEV(const std::string& keyName) 29 { 30 int key = buttonnameToSDLB( keyName ); 31 if (key != -1) 32 return key; 33 else 34 return keynameToSDLK( keyName ); 35 } 36 24 37 25 38 int buttonnameToSDLB(const std::string& name) … … 33 46 } 34 47 35 const char*SDLBToButtonname( int button)48 std::string SDLBToButtonname( int button) 36 49 { 37 50 if( button == EV_MOUSE_BUTTON_LEFT) return "BUTTON_LEFT"; … … 181 194 } 182 195 183 const char*SDLKToKeyname(int key)196 std::string SDLKToKeyname(int key) 184 197 { 185 198 if( key == SDLK_BACKSPACE) return "BACKSPACE"; -
trunk/src/lib/event/key_names.h
r7221 r7661 11 11 12 12 /** 13 * converts a button name string to a integer representing the corresponding SDL mouse button identifier 13 * @brief converts an EVKey into a String, naming the Event. 14 * @param key the Key (either key or button) to convert. 15 * @returns the String containing the Event. 16 */ 17 std::string EVToKeyName(int key); 18 /** 19 * @brief converts a KeyName into an Event. 20 * @param keyName the Key to transform. 21 * @returns the Event-Number 22 */ 23 int KeyNameToEV(const std::string& keyName); 24 25 26 /** 27 * @brief converts a button name string to a integer representing the corresponding SDL mouse button identifier 14 28 * @param name: the name of the mouse button 15 29 * @return an int containing the SDL identifier of the mouse button or -1 if the button name is not valid … … 18 32 19 33 /** 20 * converst a SDL mouse button identifier to a name string34 * @brief converst a SDL mouse button identifier to a name string 21 35 * @param button: an SDL mouse button identifier 22 36 * @return a pointer to a string containing the name of the mouse button 23 37 */ 24 const char*SDLBToButtonname( int button);38 std::string SDLBToButtonname( int button); 25 39 26 40 /** 27 * converts a key name string to a integer representing the corresponding SDLK sym41 * @brief converts a key name string to a integer representing the corresponding SDLK sym 28 42 * @param name: the name of the key 29 43 * @return the SDLK sym of the named key or -1 if the key name is not valid … … 32 46 33 47 /** 34 * converts an SDLK sym to a name string48 * @brief converts an SDLK sym to a name string 35 49 * @param key: the SDLK sym 36 50 * @return a pointer to a string containig the name of the key 37 51 */ 38 const char* SDLKToKeyname( int key); 39 52 std::string SDLKToKeyname( int key); 40 53 41 54 #endif /* _KEY_NAMES_H */ -
trunk/src/lib/graphics/graphics_engine.cc
r7428 r7661 155 155 { 156 156 // looking if we are in fullscreen-mode 157 const std::stringfullscreen = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_FULLSCREEN, "0");158 159 if (fullscreen [0] == '1' || fullscreen == "true")157 MultiType fullscreen = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO, CONFIG_NAME_FULLSCREEN, "0"); 158 159 if (fullscreen.getBool()) 160 160 this->fullscreenFlag = SDL_FULLSCREEN; 161 161 162 162 // looking if we are in fullscreen-mode 163 const std::string textures = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO_ADVANCED, CONFIG_NAME_TEXTURES, "0"); 164 if (textures[0] == '1' || textures == "true") 165 Texture::setTextureEnableState(true); 166 else 167 Texture::setTextureEnableState(false); 163 MultiType textures = Preferences::getInstance()->getString(CONFIG_SECTION_VIDEO_ADVANCED, CONFIG_NAME_TEXTURES, "1"); 164 Texture::setTextureEnableState(textures.getBool()); 168 165 169 166 // searching for a usefull resolution -
trunk/src/lib/gui/Makefile.am
r5315 r7661 1 SUBDIRS = gtk_gui \ 2 gl_gui 1 MAINSRCDIR=../.. 2 include $(MAINSRCDIR)/defs/include_paths.am 3 4 AM_LDFLAGS = 5 6 noinst_LIBRARIES = libORXbasegui.a 7 8 9 libORXbasegui_a_SOURCES = \ 10 gui_element.cc \ 11 gui_saveable.cc \ 12 gui.cc 13 14 15 noinst_HEADERS= \ 16 gui_element.h \ 17 gui_saveable.h \ 18 gui.h 19 20 21 EXTRA_DIST = 22 23 SUBDIRS = \ 24 . \ 25 gl_gui \ 26 qt_gui 27 28 # gtk_gui -
trunk/src/lib/gui/gtk_gui/Makefile.am
r5463 r7661 2 2 include $(MAINSRCDIR)/defs/include_paths.am 3 3 4 noinst_LIBRARIES = libORXg ui.a4 noinst_LIBRARIES = libORXgtkgui.a 5 5 6 libORXgui_a_CPPFLAGS = -DBUILD_ORXONOX \ 7 $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS) 6 libORXgtkgui_a_CPPFLAGS = \ 7 -DBUILD_ORXONOX \ 8 $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS) 8 9 9 libORXgui_a_SOURCES = gui.cc \ 10 gui_gtk.cc \ 11 gui_element.cc \ 12 gui_video.cc \ 13 gui_audio.cc \ 14 gui_exec.cc \ 15 gui_flags.cc \ 16 gui_banner.cc \ 17 gui_keys.cc \ 18 gui_update.cc 10 libORXgtkgui_a_SOURCES = \ 11 gui.cc \ 12 gui_gtk.cc \ 13 gui_element.cc \ 14 gui_video.cc \ 15 gui_audio.cc \ 16 gui_exec.cc \ 17 gui_flags.cc \ 18 gui_banner.cc \ 19 gui_keys.cc \ 20 gui_update.cc 19 21 20 22 noinst_HEADERS= gui.h \ 21 22 23 24 25 26 27 28 29 23 gui_gtk.h \ 24 gui_element.h \ 25 gui_video.h \ 26 gui_audio.h \ 27 gui_exec.h \ 28 gui_flags.h \ 29 gui_banner.h \ 30 gui_keys.h \ 31 gui_update.h 30 32 31 33 EXTRA_DIST = rc \ -
trunk/src/lib/gui/gtk_gui/gui_element.h
r5039 r7661 1 /*! 1 /*! 2 2 * @file gui_element.h 3 3 * Definition of ... 4 4 5 5 */ … … 16 16 GuiElement(); 17 17 virtual ~GuiElement(); 18 18 19 19 /** @returns the main Widget of this GuiElement. */ 20 Widget* getWidget() { return this->mainWidget;}20 Widget* getWidget() { return this->mainWidget; } 21 21 protected: 22 22 void setMainWidget(Widget* widget); 23 23 24 24 private: 25 25 Widget* mainWidget; -
trunk/src/lib/gui/gtk_gui/gui_exec.cc
r7221 r7661 26 26 #include "gui_exec.h" 27 27 28 #include "file.h" 28 29 #include "util/loading/resource_manager.h" 29 30 #include "parser/ini_parser/ini_parser.h" … … 33 34 #include <sys/stat.h> 34 35 #include <sys/types.h> 36 35 37 36 38 … … 147 149 void GuiExec::setConfDir(const char* confDir) 148 150 { 149 this->confDir = ResourceManager::homeDirCheck(confDir);151 this->confDir = File(confDir).name(); 150 152 151 153 PRINTF(5)("Config Directory is: %s.\n", this->confDir); … … 199 201 IniParser iniParser; 200 202 this->writeFileText(widget, &iniParser, 0); 201 std::string fileName = ResourceManager::homeDirCheck(confFile); 202 iniParser.writeFile(fileName); 203 iniParser.writeFile(File(confFile).name()); 203 204 } 204 205 … … 253 254 void GuiExec::readFromFile(Widget* widget) 254 255 { 255 std::string fileName = ResourceManager::homeDirCheck(confFile);256 std::string fileName = File(confFile).name(); 256 257 IniParser iniParser(fileName); 257 258 if (!iniParser.isOpen()) -
trunk/src/lib/gui/gtk_gui/gui_update.cc
r5766 r7661 51 51 52 52 this->updateFrame = new Frame("Update-Options:"); 53 this->updateFrame->setGroupName(CONFIG_SECTION_ DATA);53 this->updateFrame->setGroupName(CONFIG_SECTION_GENERAL); 54 54 this->updateBox = new Box('v'); 55 55 -
trunk/src/lib/lang/base_object.cc
r7429 r7661 20 20 21 21 #include "util/loading/load_param.h" 22 #include "compiler.h"23 22 #include "class_list.h" 24 23 … … 32 31 * @param root the element to load from 33 32 */ 34 BaseObject::BaseObject( )33 BaseObject::BaseObject(const std::string& objectName) 35 34 { 36 35 this->classID = CL_BASE_OBJECT; 37 36 this->className = "BaseObject"; 38 37 39 this->objectName = "";38 this->objectName = objectName; 40 39 this->classList = NULL; 41 40 this->xmlElem = NULL; -
trunk/src/lib/lang/base_object.h
r7221 r7661 27 27 28 28 public: 29 BaseObject ();29 BaseObject (const std::string& objectName = ""); 30 30 virtual ~BaseObject (); 31 31 -
trunk/src/lib/parser/ini_parser/ini_parser.cc
r7256 r7661 108 108 if( (stream = fopen (fileName.c_str(), "r")) == NULL) 109 109 { 110 PRINTF(1)("IniParser could not open %s \n", fileName.c_str());110 PRINTF(1)("IniParser could not open %s for reading\n", fileName.c_str()); 111 111 return false; 112 112 } … … 216 216 if( (stream = fopen (fileName.c_str(), "w")) == NULL) 217 217 { 218 PRINTF(1)("IniParser could not open %s \n", fileName.c_str());218 PRINTF(1)("IniParser could not open %s for writing\n", fileName.c_str()); 219 219 return false; 220 220 } … … 401 401 * @return true if everything is ok false on error 402 402 */ 403 bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName )403 bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName, bool createMissing) 404 404 { 405 405 std::list<IniSection>::iterator section; … … 416 416 if (section == this->sections.end()) 417 417 { 418 IniSection sec; 419 sec.comment = ""; 420 sec.name = sectionName; 421 section = this->sections.insert(this->sections.end(), sec); 422 } 423 424 if (section == this->sections.end()) 425 { 426 PRINTF(2)("section '%s' not found for value '%s'\n", sectionName.c_str(), entryName.c_str()); 427 return false; 428 } 429 else 430 { 431 //try find item 432 std::list<IniEntry>::iterator entry; 433 for (entry = section->entries.begin(); entry!=section->entries.end(); entry++) 434 if (entry->name == entryName ) 418 this->addSection(sectionName); 419 for (section = this->sections.begin(); section != this->sections.end(); section++) 420 if ((*section).name == sectionName) 435 421 break; 436 437 //found it? 438 if ( entry != section->entries.end() ) 439 { 440 entry->value = value; 441 442 return true; 443 } 444 422 } 423 424 //try find item 425 std::list<IniEntry>::iterator entry; 426 for (entry = section->entries.begin(); entry!=section->entries.end(); entry++) 427 if (entry->name == entryName ) 428 break; 429 430 //found it? 431 if ( entry != section->entries.end() ) 432 { 433 entry->value = value; 434 435 return true; 436 } 437 else 438 { 445 439 //not found -> create it 446 440 (*section).entries.push_back(IniEntry()); … … 448 442 (*section).entries.back().name = entryName; 449 443 (*section).entries.back().value = value; 450 PRINTF(5)("Added Entry %s with Value '%s' to Section %s\n",451 (*section).entries.back().name.c_str(),452 (*section).entries.back().value.c_str(),453 (*section).name);444 PRINTF(5)("Added Entry '%s' with Value '%s' to Section '%s'\n", 445 (*section).entries.back().name.c_str(), 446 (*section).entries.back().value.c_str(), 447 (*section).name); 454 448 this->currentEntry = --(*section).entries.end(); 455 449 return true; 456 450 } 451 return false; 457 452 } 458 453 … … 725 720 void IniParser::debug() const 726 721 { 727 PRINT F(0)("Iniparser %s- debug\n", this->fileName.c_str());722 PRINT(0)("Iniparser '%s' - debug\n", this->fileName.c_str()); 728 723 if (!this->comment.empty()) 729 PRINT F(0)("FileComment:\n %s\n\n", this->comment.c_str());724 PRINT(0)("FileComment:\n '%s'\n\n", this->comment.c_str()); 730 725 731 726 if (!this->fileName.empty()) 732 727 { 728 if (sections.empty()) 729 PRINT(0)("No Sections defined\n"); 733 730 std::list<IniSection>::const_iterator section; 734 731 for (section = this->sections.begin(); section != this->sections.end(); section++) … … 737 734 PRINTF(0)(" %s\n", (*section).comment.c_str()); 738 735 PRINTF(0)(" [%s]\n", (*section).name.c_str()); 736 737 if ((*section).entries.empty()) 738 PRINT(0)("No Entries defined within Section '%s'\n", (*section).name.c_str()); 739 739 740 740 std::list<IniEntry>::const_iterator entry; … … 748 748 } 749 749 else 750 PRINTF( 1)("no opened ini-file.\n");751 } 752 750 PRINTF(0)("no opened ini-file.\n"); 751 } 752 -
trunk/src/lib/parser/ini_parser/ini_parser.h
r7256 r7661 10 10 11 11 #define PARSELINELENGHT 512 //!< how many chars to read at once 12 #ifndef NULL13 #define NULL 0x0 //!< NULL14 #endif15 12 13 #include "src/lib/util/file.h" 16 14 #include <list> 17 #include <string>18 15 19 16 //! ini-file parser … … 21 18 * This class can be used to load an initializer file and parse it's contents for variablename=value pairs. 22 19 */ 23 class IniParser 20 class IniParser : public File 24 21 { 25 22 private: … … 47 44 48 45 /** @returns true if the file is opened, false otherwise*/ 49 bool isOpen() const { return (!this->fileName.empty())? true : false; };46 bool isOpen() const { return true; } ///HACK //(this->fileName.empty()) ? false : true; }; 50 47 /** @returns the fileName we have opened. */ 51 48 const std::string& getFileName() const { return this->fileName; }; … … 69 66 bool addVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "" ); 70 67 const std::string& getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue = "") const; 71 bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "" );68 bool IniParser::editVar(const std::string& entryName, const std::string& value, const std::string& sectionName = "", bool createMissing = true); 72 69 void setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName); 73 70 const std::string& getEntryComment(const std::string& entryName, const std::string& sectionName) const; -
trunk/src/lib/parser/preferences/ini_file_prefs_reader.cc
r7256 r7661 28 28 IniParser iniParser; 29 29 30 31 Preferences* prefs = Preferences::getInstance(); 32 33 prefs->setUserIni( fileName ); 34 30 35 if ( !iniParser.readFile( fileName ) ) 31 36 return; 32 33 Preferences* prefs = Preferences::getInstance();34 37 35 38 iniParser.firstSection(); -
trunk/src/lib/particles/dot_emitter.cc
r7302 r7661 23 23 #include "util/loading/factory.h" 24 24 #include "debug.h" 25 #include "stdlibincl.h"26 25 27 26 using namespace std; -
trunk/src/lib/shell/shell_buffer.h
r7374 r7661 10 10 #include <stdarg.h> 11 11 #include <list> 12 #include " threading.h"12 #include "lib/util/threading.h" 13 13 14 14 #define SHELL_BUFFER_SIZE 16384 //!< The Size of the input-buffers (should be large enough to carry any kind of input) -
trunk/src/lib/shell/shell_completion_plugin.cc
r7424 r7661 25 25 #include "loading/resource_manager.h" 26 26 27 #include " osdir.h"27 #include "directory.h" 28 28 #include "debug.h" 29 29 … … 94 94 void CompletorFileSystem::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const 95 95 { 96 OS::Directory dir;96 Directory dir; 97 97 98 98 if (completionBegin.empty()) // if we do not yet have the beginning of the line, start with the chosen startDir. 99 99 { 100 dir.open(ResourceManager::getInstance()->getDataDir() + this->_subDir); 100 dir.setFileName(ResourceManager::getInstance()->getDataDir() + this->_subDir); 101 dir.open(); 101 102 while(dir) 102 103 { … … 112 113 directoryName = completionBegin.substr(0, pos); 113 114 114 dir.open(ResourceManager::getInstance()->getDataDir() + directoryName); 115 dir.setFileName(ResourceManager::getInstance()->getDataDir() + directoryName); 116 dir.open(); 115 117 116 118 std::string fileName; … … 136 138 printf("%s\n", (ResourceManager::getInstance()->getDataDir() + fileName).c_str()); 137 139 if (!nocaseCmp(completionBegin, fileName, completionBegin.size()) && 138 ResourceManager::is Dir(ResourceManager::getInstance()->getDataDir() +fileName))140 ResourceManager::isInDataDir(fileName)) 139 141 { 140 142 printf("Dir %s\n", fileName.c_str()); -
trunk/src/lib/util/loading/resource_manager.cc
r7460 r7661 17 17 18 18 #include "util/loading/resource_manager.h" 19 19 #include "file.h" 20 20 #include "substring.h" 21 21 #include "debug.h" … … 60 60 61 61 this->dataDir = "./"; 62 this->_cwd = "";63 62 this->tryDataDir("./data"); 64 63 } … … 87 86 bool ResourceManager::setDataDir(const std::string& dataDir) 88 87 { 89 std::string realDir = ResourceManager::homeDirCheck(dataDir); 90 if (isDir(realDir)) 91 { 92 if (dataDir[dataDir.size()-1] == '/' || dataDir[dataDir.size()-1] == '\\') 88 File dataDirectory(dataDir); 89 if (dataDirectory.isDirectory()) 90 { 91 this->dataDir = dataDirectory.name(); 92 93 if (dataDir[dataDir.size()-1] != '/' && dataDir[dataDir.size()-1] != '\\') 93 94 { 94 this->dataDir = realDir;95 }96 else97 {98 this->dataDir = realDir;99 95 this->dataDir += '/'; 100 96 } … … 103 99 else 104 100 { 105 PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", realDir.c_str(), this->dataDir.c_str());101 PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", dataDir.c_str(), this->dataDir.c_str()); 106 102 return false; 107 103 } … … 116 112 bool ResourceManager::tryDataDir(const std::string& dataDir) 117 113 { 118 std::string realDir = ResourceManager::homeDirCheck(dataDir); 119 if (isDir(realDir)) 120 { 121 if (dataDir[dataDir.size()-1] == '/' || dataDir[dataDir.size()-1] == '\\') 114 File dataDirectory(dataDir); 115 if (dataDirectory.isDirectory()) 116 { 117 this->dataDir = dataDirectory.name(); 118 119 if (dataDir[dataDir.size()-1] != '/' && dataDir[dataDir.size()-1] != '\\') 122 120 { 123 this->dataDir = realDir;124 }125 else126 {127 this->dataDir = realDir;128 121 this->dataDir += '/'; 129 122 } … … 140 133 bool ResourceManager::verifyDataDir(const std::string& fileInside) 141 134 { 142 bool retVal;143 if (! isDir(this->dataDir))144 { 145 PRINTF(1)(" %sis not a directory\n", this->dataDir.c_str());135 File dataDirectory(this->dataDir); 136 if (!dataDirectory.isDirectory()) 137 { 138 PRINTF(1)("'%s' is not a directory\n", this->dataDir.c_str()); 146 139 return false; 147 140 } 148 141 149 std::string testFile = this->dataDir + fileInside; 150 retVal = isFile(testFile); 151 return retVal; 142 File testFile(this->dataDir + fileInside); 143 return testFile.isFile(); 152 144 } 153 145 … … 161 153 bool ResourceManager::addImageDir(const std::string& imageDir) 162 154 { 163 std::string newDir; 164 if (imageDir[imageDir.size()-1] == '/' || imageDir[imageDir.size()-1] == '\\') 165 { 166 newDir = imageDir; 167 } 168 else 169 { 170 newDir = imageDir; 155 std::string newDir = imageDir; 156 if (imageDir[imageDir.size()-1] != '/' && imageDir[imageDir.size()-1] != '\\') 157 { 171 158 newDir += '/'; 172 159 } 173 160 // check if the param is a Directory 174 if ( isDir(newDir))161 if (File(newDir).isDirectory()) 175 162 { 176 163 // check if the Directory has been added before … … 381 368 tmpResource->param[0] = 1.0f; 382 369 383 if( ResourceManager::isFile(fullName))370 if(File(fullName).isFile()) 384 371 tmpResource->pointer = new OBJModel(fullName, tmpResource->param[0].getFloat()); 385 372 else … … 407 394 break; 408 395 case MD2: 409 if( ResourceManager::isFile(fullName))396 if(File(fullName).isFile()) 410 397 { 411 398 tmpResource->param[0] = param0; … … 425 412 tmpResource->param[0] = FONT_DEFAULT_RENDER_SIZE; 426 413 427 if( isFile(fullName))414 if(File(fullName).isFile()) 428 415 tmpResource->pointer = new Font(fullName, (unsigned int) tmpResource->param[0].getInt()); 429 416 else … … 433 420 #ifndef NO_AUDIO 434 421 case WAV: 435 if( isFile(fullName))422 if(File(fullName).isFile()) 436 423 tmpResource->pointer = new OrxSound::SoundBuffer(fullName); 437 424 break; 438 425 case OGG: 439 if ( isFile(fullName))426 if (File(fullName).isFile()) 440 427 tmpResource->pointer = new OrxSound::OggPlayer(fullName); 441 428 break; … … 447 434 else 448 435 tmpResource->param[0] = GL_TEXTURE_2D; 449 if( isFile(fullName))436 if(File(fullName).isFile()) 450 437 { 451 438 PRINTF(4)("Image %s resides to %s\n", fileName, fullName); … … 458 445 { 459 446 std::string imgName = *imageDir + fileName; 460 if( isFile(imgName))447 if(File(imgName).isFile()) 461 448 { 462 449 PRINTF(4)("Image %s resides to %s\n", fileName, imgName); … … 472 459 #ifndef NO_SHADERS 473 460 case SHADER: 474 if( ResourceManager::isFile(fullName))461 if(File(fullName).isFile()) 475 462 { 476 463 if (param0 != MT_NULL) … … 478 465 MultiType param = param0; /// HACK 479 466 std::string secFullName = ResourceManager::getFullName(param.getCString()); 480 if ( ResourceManager::isFile(secFullName))467 if (File(secFullName).isFile()) 481 468 { 482 469 tmpResource->param[0] = secFullName; … … 750 737 751 738 /** 752 * @brief Checks if it is a Directory753 * @param directoryName the Directory to check for754 * @returns true if it is a directory/symlink false otherwise755 */756 bool ResourceManager::isDir(const std::string& directoryName)757 {758 std::string tmpDirName = directoryName;759 struct stat status;760 761 // checking for the termination of the string given. If there is a "/" at the end cut it away762 if (directoryName[directoryName.size()-1] == '/' ||763 directoryName[directoryName.size()-1] == '\\')764 {765 tmpDirName.erase(tmpDirName.size()-1);766 }767 768 if(!stat(tmpDirName.c_str(), &status))769 {770 if (status.st_mode & (S_IFDIR771 #ifndef __WIN32__772 | S_IFLNK773 #endif774 ))775 {776 return true;777 }778 else779 return false;780 }781 else782 return false;783 }784 785 /**786 * @brief Checks if the file is either a Regular file or a Symlink787 * @param fileName the File to check for788 * @returns true if it is a regular file/symlink, false otherwise789 */790 bool ResourceManager::isFile(const std::string& fileName)791 {792 if (fileName.empty())793 return false;794 std::string tmpFileName = ResourceManager::homeDirCheck(fileName);795 // actually checks the File796 struct stat status;797 if (!stat(tmpFileName.c_str(), &status))798 {799 if (status.st_mode & (S_IFREG800 #ifndef __WIN32__801 | S_IFLNK802 #endif803 ))804 {805 return true;806 }807 else808 return false;809 }810 else811 return false;812 }813 814 /**815 * @brief touches a File on the disk (thereby creating it)816 * @param fileName The file to touch817 */818 bool ResourceManager::touchFile(const std::string& fileName)819 {820 std::string tmpName = ResourceManager::homeDirCheck(fileName);821 if (tmpName.empty())822 return false;823 FILE* stream;824 if( (stream = fopen (tmpName.c_str(), "w")) == NULL)825 {826 PRINTF(1)("could not open %s fro writing\n", fileName.c_str());827 return false;828 }829 fclose(stream);830 }831 832 /**833 * @brief deletes a File from disk834 * @param fileName the File to delete835 */836 bool ResourceManager::deleteFile(const std::string& fileName)837 {838 std::string tmpName = ResourceManager::homeDirCheck(fileName);839 unlink(tmpName.c_str());840 }841 842 /**843 * @param name the Name of the file to check844 * @returns The name of the file, including the HomeDir845 */846 std::string ResourceManager::homeDirCheck(const std::string& name)847 {848 if (name.size() >= 2 && name[0] == '~' && name[1] == '/')849 {850 std::string homeDir;851 std::string newName = name.substr(1);852 #ifdef __WIN32__853 homeDir = getenv("USERPROFILE");854 #else855 homeDir = getenv("HOME");856 #endif857 return homeDir + newName;858 }859 else860 return name;861 }862 863 /**864 * @param name the relative name of the File/Directory.865 * @returns a new std::string with the name in abs-dir-format866 */867 std::string ResourceManager::getAbsDir(const std::string& name)868 {869 if (name.empty())870 return "";871 std::string retName = name;872 if (strncmp(name.c_str(), "/", 1))873 {874 if (name[0] == '.' && name[1] != '.')875 retName.erase(0);876 const std::string& absDir = ResourceManager::cwd();877 retName = absDir + retName;878 }879 return retName;880 }881 882 883 /**884 739 * @param fileName the Name of the File to check 885 740 * @returns The full name of the file, including the DataDir, and NULL if the file does not exist … … 892 747 893 748 std::string retName = ResourceManager::getInstance()->getDataDir() +fileName; 894 if ( ResourceManager::isFile(retName) || ResourceManager::isDir(retName))749 if (File(retName).isFile() || File(retName).isDirectory()) 895 750 return retName; 896 751 else 897 752 return ""; 898 }899 900 #ifdef __unix__901 #include <unistd.h>902 #elif __WIN32__ || _MS_DOS_903 #include <dir.h>904 #else905 #include <direct.h> /* Visual C++ */906 #endif907 /**908 * @returns the Current Woring Directory909 */910 const std::string& ResourceManager::cwd()911 {912 if (ResourceManager::getInstance()->_cwd.empty())913 {914 char cwd[1024];915 char* errorCode = getcwd(cwd, 1024);916 if (errorCode == 0)917 return ResourceManager::getInstance()->_cwd;918 919 ResourceManager::getInstance()->_cwd = cwd;920 }921 return ResourceManager::getInstance()->_cwd;922 753 } 923 754 … … 936 767 std::string checkFile = ResourceManager::getInstance()->getDataDir() + fileName; 937 768 938 if ( ResourceManager::isFile(checkFile) || ResourceManager::isDir(checkFile))769 if (File(checkFile).exists()) 939 770 retVal = true; 940 771 else -
trunk/src/lib/util/loading/resource_manager.h
r7225 r7661 21 21 22 22 #include "base_object.h" 23 #include "file.h" 24 23 25 #include "multi_type.h" 24 25 26 #include <vector> 26 27 … … 130 131 131 132 // utility functions for handling files in and around the data-directory 132 static bool isDir(const std::string& directory);133 static bool isFile(const std::string& fileName);134 static bool touchFile(const std::string& fileName);135 static bool deleteFile(const std::string& fileName);136 static std::string homeDirCheck(const std::string& fileName);137 133 static std::string getFullName(const std::string& fileName); 138 134 static bool isInDataDir(const std::string& fileName); 139 static std::string getAbsDir(const std::string& fileName);140 static const std::string& cwd();141 135 142 136 static const char* ResourceTypeToChar(ResourceType type); … … 151 145 static ResourceManager* singletonRef; //!< singleton Reference 152 146 153 std::string _cwd; //!< The currend Working directory.154 147 std::string dataDir; //!< The Data Directory, where all relevant Data is stored. 155 148 std::vector<std::string> imageDirs; //!< A list of directories in which images are stored. -
trunk/src/lib/util/preferences.cc
r7256 r7661 17 17 18 18 #include "preferences.h" 19 20 using namespace std; 19 #include "lib/parser/ini_parser/ini_parser.h" 21 20 22 21 … … 137 136 * @return value of the item if found. defaultValue else 138 137 */ 139 conststd::string Preferences::getString(const std::string& section, const std::string& name, const std::string& defaultValue)138 std::string Preferences::getString(const std::string& section, const std::string& name, const std::string& defaultValue) 140 139 { 141 140 return getMultiType(section, name, MultiType(defaultValue)).getString(); … … 260 259 IniParser iniParser(this->fileName); 261 260 262 if ( !iniParser.isOpen() )263 return false;264 265 261 std::list<prefSection>::iterator it = data.begin(); 266 262 bool didChanges = false; … … 278 274 } 279 275 } 280 281 if ( didChanges )276 /// HACK DO WE HAVE TO CHECK THIS?? 277 //if ( didChanges ) 282 278 { 283 279 iniParser.writeFile( this->fileName ); … … 314 310 { 315 311 std::list<std::string> lst; 316 312 317 313 std::list<prefSection>::const_iterator it = data.begin(); 318 314 -
trunk/src/lib/util/preferences.h
r7256 r7661 9 9 #include "base_object.h" 10 10 #include "multi_type.h" 11 #include "lib/parser/ini_parser/ini_parser.h"12 11 13 12 // FORWARD DECLARATION … … 44 43 void setMultiType(const std::string& section, const std::string& name, const MultiType& value, bool dontSetModified = false); 45 44 46 conststd::string getString(const std::string& section, const std::string& name, const std::string& defaultValue);45 std::string getString(const std::string& section, const std::string& name, const std::string& defaultValue); 47 46 int getInt(const std::string& section, const std::string& name, int defaultValue); 48 47 float getFloat(const std::string& section, const std::string& name, float defaultValue); … … 54 53 55 54 void debug(); 56 55 57 56 std::list<std::string> listKeys( const std::string section ); 58 57 -
trunk/src/orxonox.cc
r7460 r7661 30 30 #include "globals.h" 31 31 32 #include "gui.h" 33 32 #include "gui/qt_gui/qt_gui.h" 33 34 #include "file.h" 34 35 #include "parser/ini_parser/ini_parser.h" 35 36 #include "util/loading/game_loader.h" … … 189 190 const std::string& Orxonox::getConfigFile () 190 191 { 191 if (ResourceManager::isFile("orxonox.conf")) 192 File orxConfFile("orxonox.conf"); 193 if (orxConfFile.isFile()) 192 194 { 193 195 this->configFileName = "orxonox.conf"; 194 196 } 195 197 else 196 this->configFileName = ResourceManager::homeDirCheck(DEFAULT_CONFIG_FILE);198 this->configFileName = File(DEFAULT_CONFIG_FILE).name(); 197 199 198 200 PRINTF(3)("Parsed Config File: '%s'\n", this->configFileName); … … 280 282 PRINT(3)("> Initializing input\n"); 281 283 284 EventHandler::getInstance()-> 282 285 EventHandler::getInstance()->init(); 283 286 EventHandler::getInstance()->subscribe(GraphicsEngine::getInstance(), ES_ALL, EV_VIDEO_RESIZE); … … 319 322 // init the resource manager 320 323 std::string dataPath; 321 if ((dataPath = Preferences::getInstance()->getString(CONFIG_SECTION_ DATA, CONFIG_NAME_DATADIR, ""))!= "")324 if ((dataPath = Preferences::getInstance()->getString(CONFIG_SECTION_GENERAL, CONFIG_NAME_DATADIR, ""))!= "") 322 325 { 323 326 if (!ResourceManager::getInstance()->setDataDir(dataPath) && … … 334 337 ResourceManager::getInstance()->getDataDir().c_str(), 335 338 this->configFileName.c_str(), 336 CONFIG_SECTION_ DATA,339 CONFIG_SECTION_GENERAL, 337 340 CONFIG_NAME_DATADIR ); 338 Gui* gui = newGui(argc, argv);341 OrxGui::Gui* gui = new OrxGui::QtGui(argc, argv); 339 342 gui->startGui(); 340 343 delete gui; … … 425 428 CmdLinePrefsReader prefs; 426 429 427 IniFilePrefsReader ini(ResourceManager::homeDirCheck(DEFAULT_CONFIG_FILE)); 430 IniFilePrefsReader ini(File(DEFAULT_CONFIG_FILE).name()); 431 Preferences::getInstance()->setUserIni(File(DEFAULT_CONFIG_FILE).name()); 428 432 429 433 prefs.parse(argc, argv); … … 501 505 { 502 506 // checking for existence of the configuration-files, or if the lock file is still used 503 if (showGui || (! ResourceManager::isFile("./orxonox.conf") &&504 !ResourceManager::isFile(DEFAULT_CONFIG_FILE))507 if (showGui || (!File("./orxonox.conf").isFile() && 508 !File(DEFAULT_CONFIG_FILE).isFile()) 505 509 #if DEBUG < 3 // developers do not need to see the GUI, when orxonox fails 506 510 || ResourceManager::isFile(DEFAULT_LOCK_FILE) … … 508 512 ) 509 513 { 510 if (ResourceManager::isFile(DEFAULT_LOCK_FILE)) 511 ResourceManager::deleteFile(DEFAULT_LOCK_FILE); 514 File lockFile(DEFAULT_LOCK_FILE); 515 if (lockFile.isFile()) 516 lockFile.remove(); 512 517 513 518 // starting the GUI 514 Gui* gui = new Gui(argc, argv);515 gui ->startGui();516 517 if ( ! gui->startOrxonox)519 OrxGui::QtGui gui(argc, argv); 520 gui.startGui(); 521 522 if (gui.getState() & OrxGui::Gui::Quitting) 518 523 return 0; 519 524 520 delete gui;521 525 } 522 526 523 527 PRINT(0)(">>> Starting Orxonox <<<\n"); 524 528 525 ResourceManager::touchFile(DEFAULT_LOCK_FILE);529 File(DEFAULT_LOCK_FILE).touch(); 526 530 527 531 Orxonox *orx = Orxonox::getInstance(); … … 537 541 538 542 delete orx; 539 ResourceManager::deleteFile("~/.orxonox/orxonox.lock");540 } 543 File("~/.orxonox/orxonox.lock").remove(); 544 } -
trunk/src/story_entities/story_entity.cc
r7283 r7661 22 22 #include "story_entity.h" 23 23 24 #include "util/file.h" 25 #include "util/loading/load_param.h" 24 26 #include "util/loading/resource_manager.h" 25 #include "util/loading/load_param.h"26 27 27 28 … … 102 103 void StoryEntity::setLoadFile(const std::string& fileName) 103 104 { 104 if ( ResourceManager::isFile(fileName))105 if (File(fileName).isFile()) 105 106 { 106 107 this->loadFile = fileName;
Note: See TracChangeset
for help on using the changeset viewer.