Changeset 2685
- Timestamp:
- Feb 20, 2009, 5:32:04 PM (16 years ago)
- Location:
- code/branches/buildsystem3
- Files:
-
- 5 added
- 8 deleted
- 28 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/buildsystem3/CMakeLists.txt
r2683 r2685 47 47 ADD_SUBDIRECTORY(media) 48 48 49 ADD_SUBDIRECTORY(config) 50 ADD_SUBDIRECTORY(log) 51 49 52 # Creates the actual project 50 53 ADD_SUBDIRECTORY(src) -
code/branches/buildsystem3/bin/CMakeLists.txt
r2684 r2685 21 21 # Reto Grieder 22 22 # Description: 23 # Configures the binary output directory with files required for Orxonox 24 # to run like orxonox.ini or the default keybindings. 25 # Also creates a run-script in the root directory of the build tree. 23 # Creates a run-script in the root directory of the build tree. 26 24 # 27 28 SET(READ_ONLY_CONFIG_FILES29 def_keybindings.ini30 def_masterKeybindings.ini31 disco.txt32 irc.tcl33 remote.tcl34 telnet_server.tcl35 )36 25 37 SET(WRITABLE_CONFIG_FILES 38 ) 39 40 # Not getting installed 41 SET(ORXONOX_INI orxonox.ini) 42 43 IF(TARDIS) 44 # OGRE can't find fonts to display config screen on Tardis, 45 # so providing default config file here (bug). 46 LIST(APPEND WRITABLE_CONFIG_FILES ogre.cfg) 47 ENDIF(TARDIS) 48 49 # We need the same code for both READ_ONLY and WRITABLE config files 50 MACRO(CONFIGURE_FILES _file_name _build_configs _read_only_arg) 51 SET(_read_only ${_read_only_arg}) 52 FOREACH(_build_config ${_build_configs}) 53 # Is there an extra file in bin/Debug or bin/Release? 54 IF(${_build_config} MATCHES "Rel") 55 SET(_build_config_short "Release") 56 ELSE() 57 SET(_build_config_short "Debug") 58 ENDIF() 59 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_build_config_short}/${_file_name}) 60 SET(_in_file ${CMAKE_CURRENT_SOURCE_DIR}/${_build_config_short}/${_file_name}) 61 ELSE() 62 SET(_in_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file_name}) 63 ENDIF() 64 65 # Copy to the folder named like the build config for Visual Studio 66 IF(CMAKE_CONFIGURATION_TYPES) 67 SET(_out_file ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_build_config}/${_file_name}) 68 ELSE() 69 SET(_out_file ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_file_name}) 70 ENDIF() 71 # Only copy if target file doesn't exist. This may result in problems but 72 # otherwise we might delete a user's config 73 IF(NOT EXISTS ${_out_file} OR _read_only) 74 CONFIGURE_FILE(${_in_file} ${_out_file} @ONLY) 75 ENDIF() 76 ENDFOREACH(_build_config) 77 ENDMACRO(CONFIGURE_FILES) 78 79 # Copy config files to all Visual Studio output directories 80 IF(CMAKE_CONFIGURATION_TYPES) 81 SET(BUILD_CONFIGS ${CMAKE_CONFIGURATION_TYPES}) 82 ELSE() 83 SET(CONFIG_OUT_PATHS_REL ".") 84 SET(BUILD_CONFIGS ${CMAKE_BUILD_TYPE}) 85 ENDIF() 86 87 FOREACH(_file_name ${READ_ONLY_CONFIG_FILES}) 88 CONFIGURE_FILES("${_file_name}" "${BUILD_CONFIGS}" TRUE) 89 ENDFOREACH(_file_name) 90 FOREACH(_file_name ${WRITABLE_CONFIG_FILES} ${ORXONOX_INI}) 91 CONFIGURE_FILES("${_file_name}" "${BUILD_CONFIGS}" FALSE) 92 ENDFOREACH(_file_name) 93 94 95 ################ Installation ################# 96 97 # Not using collective call to allow configuration with CMake. 98 FOREACH(_file ${READ_ONLY_CONFIG_FILES} ${WRITABLE_CONFIG_FILES}) 99 IF(CMAKE_CONFIGURATION_TYPES) 100 FOREACH(_configuration ${CMAKE_CONFIGURATION_TYPES}) 101 INSTALL( 102 FILES ${CMAKE_BINARY_DIR}/bin/${_configuration}/${_file} 103 DESTINATION ${ORXONOX_RUNTIME_INSTALL_PATH} 104 CONFIGURATIONS ${_configuration} 105 ) 106 ENDFOREACH(_configuration) 107 ELSE() 108 INSTALL(FILES ${CMAKE_BINARY_DIR}/bin/${_file} DESTINATION ${ORXONOX_RUNTIME_INSTALL_PATH}) 109 ENDIF() 110 ENDFOREACH(_file) 26 ############ Configure Dev Build ############## 111 27 112 28 … … 140 56 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${RUN_SCRIPT}.in ${CMAKE_BINARY_DIR}/${RUN_SCRIPT} @ONLY) 141 57 ENDIF() 58 59 # In order to evaluate at run time whether it is a dev build in the build tree, 60 # we plant a special file 61 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/orxonox_dev_build.keep_me ${CURRENT_RUNTIME_DIR}/orxonox_dev_build.keep_me) 142 62 ENDFOREACH(_subdir) -
code/branches/buildsystem3/cmake/BuildConfig.cmake
r2680 r2685 123 123 SET(ORXONOX_MEDIA_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/orxonox) 124 124 SET(ORXONOX_DOC_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/share/doc/orxonox) 125 # Not yet used126 125 SET(ORXONOX_LOG_INSTALL_PATH ~/.orxonox/log) 127 126 SET(ORXONOX_CONFIG_INSTALL_PATH ~/.orxonox/config) … … 132 131 SET(ORXONOX_MEDIA_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/media) 133 132 SET(ORXONOX_DOC_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/doc) 134 # Not yet used135 133 SET(ORXONOX_LOG_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/log) 136 134 SET(ORXONOX_CONFIG_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/config) -
code/branches/buildsystem3/media/CMakeLists.txt
r2673 r2685 26 26 # Specify media directory 27 27 GET_FILENAME_COMPONENT(_search_path_1 ${CMAKE_SOURCE_DIR}/../media ABSOLUTE) 28 FIND_PATH(ORXONOX_MEDIA_D IRECTORYresources.cfg28 FIND_PATH(ORXONOX_MEDIA_DEV_PATH resources.cfg 29 29 PATHS 30 30 ${CMAKE_CURRENT_SOURCE_DIR} 31 31 ${_search_path_1} 32 $ENV{ORXONOX_MEDIA_DIR}33 32 ) 34 IF(NOT ORXONOX_MEDIA_D IRECTORY)33 IF(NOT ORXONOX_MEDIA_DEV_PATH) 35 34 MESSAGE(STATUS "Warning: Media directory not found. If you want to compile while downloading the media files, you must specify the directory by Hand BEFORE compiling! Default location is orxonox_root/media") 36 35 # Temporary override to the default location. 37 SET(ORXONOX_MEDIA_D IRECTORY${CMAKE_SOURCE_DIR}/media)38 SET(ORXONOX_MEDIA_D IRECTORY${CMAKE_SOURCE_DIR}/media PARENT_SCOPE)36 SET(ORXONOX_MEDIA_DEV_PATH ${CMAKE_SOURCE_DIR}/media) 37 SET(ORXONOX_MEDIA_DEV_PATH ${CMAKE_SOURCE_DIR}/media PARENT_SCOPE) 39 38 ENDIF() 40 39 … … 50 49 51 50 INSTALL( 52 DIRECTORY ${ORXONOX_MEDIA_D IRECTORY}/51 DIRECTORY ${ORXONOX_MEDIA_DEV_PATH}/ 53 52 DESTINATION ${ORXONOX_MEDIA_INSTALL_PATH} 54 53 REGEX "\\.svn$|_svn$|backToPNG|${TCL_EXCLUDE_PATTERN}" EXCLUDE -
code/branches/buildsystem3/src/CMakeLists.txt
r2670 r2685 65 65 INCLUDE(CheckIncludeFileCXX) 66 66 CHECK_INCLUDE_FILE_CXX(iso646.h HAVE_ISO646_H) 67 68 # XCode and Visual Studio support multiple configurations. In order to tell the 69 # which one we have to define the macros separately for each configuration 70 ADD_COMPILER_FLAGS("-DCMAKE_BUILD_TYPE=Debug" Debug) 71 ADD_COMPILER_FLAGS("-DCMAKE_BIULD_TYPE=Release" Release) 72 ADD_COMPILER_FLAGS("-DCMAKE_BUILD_TYPE=RelWithDebInfo" RelWithDebInfo) 73 ADD_COMPILER_FLAGS("-DCMAKE_BUILD_TYPE=MinSizeRel" MinSizeRel) 67 74 68 75 SET(GENERATED_FILE_COMMENT -
code/branches/buildsystem3/src/OrxonoxConfig.h.in
r2673 r2685 164 164 165 165 #cmakedefine HAVE_STDDEF_H 166 /* Quite large, do not include unless necessary 166 167 #ifdef HAVE_STDDEF_H 167 168 # include <stddef.h> 168 169 #endif 170 */ 169 171 170 172 /* Visual Leak Detector looks for memory leaks */ … … 185 187 #cmakedefine USE_DEPENDENCY_PACKAGE 186 188 189 /* Using MSVC or XCode IDE */ 190 #cmakedefine CMAKE_CONFIGURATION_TYPES 191 192 /* Macros used in the next section */ 193 #define MACRO_CONCATENATE(str1, str2) str1##str2 194 #define MACRO_QUOTEME_AUX(x) #x 195 #define MACRO_QUOTEME(x) MACRO_QUOTEME_AUX(x) 196 187 197 /* Handle default ConfigValues */ 188 198 namespace orxonox 189 199 { 190 #ifdef ORXONOX_PLATFORM_WINDOWS 191 const char* const ORXONOX_MEDIA_PATH("../media"); 192 #elif defined(ORXONOX_PLATFORM_LINUX) 193 const char* const ORXONOX_MEDIA_PATH("../../share/orxonox"); 194 #else 195 /* TODO: Apple? */ 196 const char* const ORXONOX_MEDIA_PATH("../../share/orxonox"); 200 const char* const ORXONOX_MEDIA_INSTALL_PATH ("@ORXONOX_MEDIA_INSTALL_PATH@/"); 201 const char* const ORXONOX_CONFIG_INSTALL_PATH("@ORXONOX_CONFIG_INSTALL_PATH@/"); 202 const char* const ORXONOX_LOG_INSTALL_PATH ("@ORXONOX_LOG_INSTALL_PATH@/"); 203 204 const char* const ORXONOX_MEDIA_DEV_PATH ("@ORXONOX_MEDIA_DEV_PATH@/"); 205 #ifdef CMAKE_CONFIGURATION_TYPES 206 const char* const ORXONOX_CONFIG_DEV_PATH ("@ORXONOX_CONFIG_DEV_PATH@/" MACRO_QUOTEME(CMAKE_BUILD_TYPE) "/"); 207 const char* const ORXONOX_LOG_DEV_PATH ("@ORXONOX_LOG_DEV_PATH@/" MACRO_QUOTEME(CMAKE_BUILD_TYPE) "/"); 208 #else 209 const char* const ORXONOX_CONFIG_DEV_PATH ("@ORXONOX_CONFIG_DEV_PATH@/"); 210 const char* const ORXONOX_LOG_DEV_PATH ("@ORXONOX_LOG_DEV_PATH@/"); 197 211 #endif 198 212 213 /* OGRE Plugins */ 199 214 #ifdef NDEBUG 200 215 const char* const ORXONOX_OGRE_PLUGINS("@OGRE_PLUGINS_RELEASE@"); … … 214 229 } 215 230 216 217 231 #endif /* _OrxonoxConfig_H__ */ -
code/branches/buildsystem3/src/core/CMakeLists.txt
r2664 r2685 70 70 IF(GCC_NO_SYSTEM_HEADER_SUPPORT) 71 71 # Get around displaying a few hundred lines of warning code 72 SET_SOURCE_FILES_PROPERTIES(ArgumentCompletionFunctions.cc PROPERTIES COMPILE_FLAGS "-w") 72 SET_SOURCE_FILES_PROPERTIES( 73 ArgumentCompletionFunctions.cc 74 CommandLine.cc 75 ConfigFileManager.cc 76 Language.cc 77 LuaBind.cc 78 input/KeyBinder.cc 79 PROPERTIES COMPILE_FLAGS "-Wno-sign-compare") 73 80 ENDIF() 74 81 -
code/branches/buildsystem3/src/core/CommandLine.cc
r2662 r2685 29 29 #include "CommandLine.h" 30 30 31 #include <boost/filesystem.hpp> 31 32 #include "util/String.h" 32 33 #include "util/SubString.h" 34 #include "Core.h" 33 35 34 36 namespace orxonox … … 299 301 this->_parse(args); 300 302 303 std::string filename = CommandLine::getValue("optionsFile").getString(); 304 boost::filesystem::path folder(Core::getConfigPath()); 305 boost::filesystem::path filepath(folder/filename); 306 301 307 // look for additional arguments in given file or start.ini as default 302 308 // They will not overwrite the arguments given directly 303 309 std::ifstream file; 304 std::string filename = CommandLine::getValue("optionsFile").getString(); 305 file.open(filename.c_str()); 310 file.open(filepath.native_file_string().c_str()); 306 311 args.clear(); 307 312 if (file) -
code/branches/buildsystem3/src/core/ConfigFileManager.cc
r2662 r2685 30 30 31 31 #include <cassert> 32 #include <boost/filesystem.hpp> 33 32 34 #include "util/Convert.h" 33 35 #include "util/String.h" 34 36 #include "ConsoleCommand.h" 35 37 #include "ConfigValueContainer.h" 38 #include "Core.h" 36 39 37 40 namespace orxonox … … 223 226 this->clear(); 224 227 228 boost::filesystem::path filepath(Core::getConfigPath() + "/" + this->filename_); 229 225 230 // This creates the config file if it's not existing 226 231 std::ofstream createFile; 227 createFile.open( this->filename_.c_str(), std::fstream::app);232 createFile.open(filepath.native_file_string().c_str(), std::fstream::app); 228 233 createFile.close(); 229 234 230 235 // Open the file 231 236 std::ifstream file; 232 file.open( this->filename_.c_str(), std::fstream::in);237 file.open(filepath.native_file_string().c_str(), std::fstream::in); 233 238 234 239 if (!file.is_open()) … … 337 342 void ConfigFile::save() const 338 343 { 344 boost::filesystem::path filepath(Core::getConfigPath() + "/" + this->filename_); 345 339 346 std::ofstream file; 340 file.open( this->filename_.c_str(), std::fstream::out);347 file.open(filepath.native_file_string().c_str(), std::fstream::out); 341 348 file.setf(std::ios::fixed, std::ios::floatfield); 342 349 file.precision(6); -
code/branches/buildsystem3/src/core/Core.cc
r2662 r2685 37 37 #include "CoreIncludes.h" 38 38 #include "ConfigValueIncludes.h" 39 #include "LuaBind.h" 40 #include "CommandLine.h" 39 41 40 42 namespace orxonox … … 46 48 bool Core::bIsMaster_s = false; 47 49 50 bool Core::isDevBuild_s = false; 51 std::string Core::configPath_s(ORXONOX_CONFIG_INSTALL_PATH); // from OrxonoxConfig.h 52 std::string Core::logPath_s (ORXONOX_LOG_INSTALL_PATH); // from OrxonoxConfig.h 53 48 54 Core* Core::singletonRef_s = 0; 55 56 SetCommandLineArgument(mediaPath, "").information("PATH"); 49 57 50 58 /** … … 58 66 assert(Core::singletonRef_s == 0); 59 67 Core::singletonRef_s = this; 68 60 69 this->bInitializeRandomNumberGenerator_ = false; 61 62 70 this->setConfigValues(); 71 72 // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used 73 OutputHandler::getOutStream().setLogPath(Core::logPath_s); 74 75 // Possible media path override by the command line 76 if (!CommandLine::getArgument("mediaPath")->hasDefaultValue()) 77 { 78 std::string mediaPath = CommandLine::getValue("mediaPath"); 79 Core::tsetMediaPath(mediaPath); 80 } 63 81 } 64 82 … … 77 95 void Core::setConfigValues() 78 96 { 79 SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged); 80 SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged); 81 SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged); 97 #ifdef NDEBUG 98 const unsigned int defaultLevelConsole = 1; 99 const unsigned int defaultLevelLogfile = 3; 100 const unsigned int defaultLevelShell = 1; 101 #else 102 const unsigned int defaultLevelConsole = 3; 103 const unsigned int defaultLevelLogfile = 4; 104 const unsigned int defaultLevelShell = 3; 105 #endif 106 SetConfigValue(softDebugLevelConsole_, defaultLevelConsole) 107 .description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged); 108 SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile) 109 .description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged); 110 SetConfigValue(softDebugLevelShell_, defaultLevelShell) 111 .description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged); 112 82 113 SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged); 83 114 SetConfigValue(bInitializeRandomNumberGenerator_, true).description("If true, all random actions are different each time you start the game").callback(this, &Core::initializeRandomNumberGenerator); 115 116 // Media path (towards config and log path) is ini-configurable 117 const char* defaultMediaPath = ORXONOX_MEDIA_INSTALL_PATH; 118 if (Core::isDevBuild()) 119 defaultMediaPath = ORXONOX_MEDIA_DEV_PATH; 120 121 SetConfigValue(mediaPath_, defaultMediaPath) 122 .description("Relative path to the game data.").callback(this, &Core::mediaPathChanged); 123 84 124 } 85 125 … … 109 149 // Read the translation file after the language was configured 110 150 Language::getLanguage().readTranslatedLanguageFile(); 151 } 152 153 /** 154 @brief 155 Callback function if the media path has changed. 156 */ 157 void Core::mediaPathChanged() 158 { 159 if (mediaPath_ != "" && mediaPath_[mediaPath_.size() - 1] != '/') 160 { 161 ModifyConfigValue(mediaPath_, set, mediaPath_ + "/"); 162 } 163 164 if (mediaPath_ == "") 165 { 166 ModifyConfigValue(mediaPath_, set, "/"); 167 COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl; 168 } 111 169 } 112 170 … … 177 235 } 178 236 237 /** 238 @brief 239 Temporary sets the media path 240 @param path 241 The new media path 242 */ 243 void Core::_tsetMediaPath(const std::string& path) 244 { 245 if (*path.end() != '/' && *path.end() != '\\') 246 { 247 ModifyConfigValue(mediaPath_, tset, path + "/"); 248 } 249 else 250 { 251 ModifyConfigValue(mediaPath_, tset, path); 252 } 253 } 254 179 255 void Core::initializeRandomNumberGenerator() 180 256 { … … 187 263 } 188 264 } 265 266 /*static*/ void Core::setDevBuild() 267 { 268 // Be careful never to call this function before main()! 269 270 Core::isDevBuild_s = true; 271 // Constants taken from OrxonoxConfig.h 272 Core::configPath_s = ORXONOX_CONFIG_DEV_PATH; 273 Core::logPath_s = ORXONOX_LOG_DEV_PATH; 274 } 189 275 } -
code/branches/buildsystem3/src/core/Core.h
r2662 r2685 44 44 #include "util/OutputHandler.h" 45 45 46 // Only allow main to access setDevBuild, so we need a forward declaration 47 int main(int, char**); 48 46 49 namespace orxonox 47 50 { … … 49 52 class _CoreExport Core : public OrxonoxClass 50 53 { 54 friend int ::main(int, char**); // sets isDevBuild_s 55 51 56 public: 52 57 Core(); 53 58 ~Core(); 54 59 void setConfigValues(); 55 void debugLevelChanged();56 void languageChanged();57 60 58 61 static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; } … … 62 65 static const std::string& getLanguage(); 63 66 static void resetLanguage(); 67 68 static bool isDevBuild() { return Core::isDevBuild_s; } 69 70 static const std::string& getMediaPath() 71 { assert(singletonRef_s); return singletonRef_s->mediaPath_; } 72 static void tsetMediaPath(const std::string& path) 73 { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); } 74 static const std::string& getConfigPath() { return configPath_s; } 75 static const std::string& getLogPath() { return logPath_s; } 64 76 65 77 // fast access global variables. … … 79 91 void resetLanguageIntern(); 80 92 void initializeRandomNumberGenerator(); 93 void debugLevelChanged(); 94 void languageChanged(); 95 void mediaPathChanged(); 96 void _tsetMediaPath(const std::string& path); 97 98 static void setDevBuild(); 81 99 82 100 int softDebugLevel_; //!< The debug level … … 85 103 int softDebugLevelShell_; //!< The debug level for the ingame shell 86 104 std::string language_; //!< The language 87 bool bInitializeRandomNumberGenerator_; //!< If true, srand(time(0)) is called 105 bool bInitializeRandomNumberGenerator_; //!< If true, srand(time(0)) is called 106 std::string mediaPath_; //!< Path to the data/media file folder 88 107 89 108 static bool bShowsGraphics_s; //!< global variable that tells whether to show graphics … … 93 112 static bool bIsMaster_s; 94 113 114 static bool isDevBuild_s; //!< True for builds in the build directory (not installed) 115 static std::string configPath_s; //!< Path to the config file folder 116 static std::string logPath_s; //!< Path to the log file folder 117 95 118 static Core* singletonRef_s; 96 119 }; -
code/branches/buildsystem3/src/core/Language.cc
r2662 r2685 35 35 36 36 #include <fstream> 37 #include <boost/filesystem.hpp> 37 38 38 39 #include "Core.h" … … 205 206 COUT(4) << "Read default language file." << std::endl; 206 207 208 boost::filesystem::path folder(Core::getConfigPath()); 209 boost::filesystem::path filepath(folder/getFilename(this->defaultLanguage_)); 210 207 211 // This creates the file if it's not existing 208 212 std::ofstream createFile; 209 createFile.open( getFilename(this->defaultLanguage_).c_str(), std::fstream::app);213 createFile.open(filepath.native_file_string().c_str(), std::fstream::app); 210 214 createFile.close(); 211 215 212 216 // Open the file 213 217 std::ifstream file; 214 file.open( getFilename(this->defaultLanguage_).c_str(), std::fstream::in);218 file.open(filepath.native_file_string().c_str(), std::fstream::in); 215 219 216 220 if (!file.is_open()) … … 254 258 COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl; 255 259 260 boost::filesystem::path folder(Core::getConfigPath()); 261 boost::filesystem::path filepath(folder/getFilename(Core::getLanguage())); 262 256 263 // Open the file 257 264 std::ifstream file; 258 file.open( getFilename(Core::getLanguage()).c_str(), std::fstream::in);265 file.open(filepath.native_file_string().c_str(), std::fstream::in); 259 266 260 267 if (!file.is_open()) … … 308 315 COUT(4) << "Language: Write default language file." << std::endl; 309 316 317 boost::filesystem::path folder(Core::getConfigPath()); 318 boost::filesystem::path filepath(folder/getFilename(this->defaultLanguage_)); 319 310 320 // Open the file 311 321 std::ofstream file; 312 file.open( getFilename(this->defaultLanguage_).c_str(), std::fstream::out);322 file.open(filepath.native_file_string().c_str(), std::fstream::out); 313 323 314 324 if (!file.is_open()) -
code/branches/buildsystem3/src/core/LuaBind.cc
r2664 r2685 37 37 } 38 38 #include <tolua/tolua++.h> 39 39 #include <boost/filesystem.hpp> 40 41 #include "util/String.h" 42 #include "util/Debug.h" 40 43 #include "ToluaBindCore.h" 41 #include "util/String.h" 42 #include "CoreIncludes.h" 44 #include "Core.h" 43 45 44 46 namespace orxonox … … 50 52 assert(LuaBind::singletonRef_s == 0); 51 53 LuaBind::singletonRef_s = this; 54 55 this->includePath_ = Core::getMediaPath(); 52 56 53 57 luaState_ = lua_open(); … … 82 86 void LuaBind::loadFile(std::string filename, bool luaTags) 83 87 { 88 boost::filesystem::path filepath(filename); 89 84 90 output_ = ""; 85 91 std::ifstream file; 86 file.open(file name.c_str(), std::fstream::in);92 file.open(filepath.native_file_string().c_str(), std::fstream::in); 87 93 88 94 if (!file.is_open()) -
code/branches/buildsystem3/src/core/input/KeyBinder.cc
r2662 r2685 36 36 #include <fstream> 37 37 #include <string> 38 #include <boost/filesystem.hpp> 38 39 39 40 #include "util/Convert.h" … … 42 43 #include "core/CoreIncludes.h" 43 44 #include "core/ConfigFileManager.h" 45 #include "core/Core.h" 44 46 #include "InputCommands.h" 45 47 #include "InputManager.h" … … 253 255 return; 254 256 257 boost::filesystem::path folder(Core::getConfigPath()); 258 boost::filesystem::path filepath(folder/filename); 259 255 260 // get bindings from default file if filename doesn't exist. 256 261 std::ifstream infile; 257 infile.open(file name.c_str());262 infile.open(filepath.native_file_string().c_str()); 258 263 if (!infile) 259 264 { -
code/branches/buildsystem3/src/orxonox/CMakeLists.txt
r2673 r2685 25 25 PawnManager.cc 26 26 PlayerManager.cc 27 Settings.cc28 27 ) 29 28 ADD_SUBDIRECTORY(gamestates) … … 43 42 IF(GCC_NO_SYSTEM_HEADER_SUPPORT) 44 43 # Get around displaying a few hundred lines of warning code 45 SET_SOURCE_FILES_PROPERTIES(gamestates/GSGraphics.cc PROPERTIES COMPILE_FLAGS "-w") 44 SET_SOURCE_FILES_PROPERTIES( 45 gamestates/GSGraphics.cc 46 gui/GUIManager.cc 47 PROPERTIES COMPILE_FLAGS "-Wno-sign-compare" 48 ) 46 49 ENDIF() 47 50 -
code/branches/buildsystem3/src/orxonox/Main.cc
r2664 r2685 30 30 /** 31 31 @file 32 @brief Entry point of the program. Platform specific code.32 @brief Entry point of the program. 33 33 */ 34 34 … … 37 37 #include <exception> 38 38 #include <cassert> 39 #include <fstream> 39 40 40 41 #include "OrxonoxConfig.h" … … 85 86 86 87 87 //#ifdef __cplusplus88 //extern "C" {89 //#endif90 91 88 SetCommandLineArgument(settingsFile, "orxonox.ini"); 89 SetCommandLineArgument(configFileDirectory, ""); 92 90 93 91 int main(int argc, char** argv) … … 95 93 using namespace orxonox; 96 94 97 // create a signal handler (only works for linux) 95 // First, determine whether we have an installed or a binary dir run 96 // The latter occurs when simply running from the build directory 97 std::ifstream probe; 98 probe.open("orxonox_dev_build.keep_me"); 99 if (probe) 100 { 101 Core::setDevBuild(); 102 probe.close(); 103 } 104 105 // create a signal handler (only active for linux) 98 106 SignalHandler signalHandler; 99 signalHandler.doCatch(argv[0], "orxonox.log");107 signalHandler.doCatch(argv[0], Core::getLogPath() + "orxonox_crash.log"); 100 108 101 109 // Parse command line arguments … … 157 165 return 0; 158 166 } 159 160 //#ifdef __cplusplus161 //}162 //#endif -
code/branches/buildsystem3/src/orxonox/gamestates/GSGraphics.cc
r2664 r2685 61 61 #include "gui/GUIManager.h" 62 62 #include "tools/WindowEventListener.h" 63 #include "Settings.h"64 63 65 64 // for compatibility … … 138 137 // load debug overlay 139 138 COUT(3) << "Loading Debug Overlay..." << std::endl; 140 this->debugOverlay_ = new XMLFile( Settings::getDataPath() + "overlay/debug.oxo");139 this->debugOverlay_ = new XMLFile(Core::getMediaPath() + "overlay/debug.oxo"); 141 140 Loader::open(debugOverlay_); 142 141 … … 211 210 delete this->ogreRoot_; 212 211 213 //#ifdef ORXONOX_PLATFORM_WINDOWS214 212 // delete the ogre log and the logManager (since we have created it). 215 213 this->ogreLogger_->getDefaultLog()->removeListener(this); 216 214 this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog()); 217 215 delete this->ogreLogger_; 218 //#endif219 216 220 217 delete graphicsEngine_; … … 287 284 COUT(3) << "Setting up Ogre..." << std::endl; 288 285 289 // TODO: LogManager doesn't work on oli platform. The why is yet unknown. 290 //#ifdef ORXONOX_PLATFORM_WINDOWS 286 if (ogreConfigFile_ == "") 287 { 288 COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl; 289 ModifyConfigValue(ogreConfigFile_, tset, "config.cfg"); 290 } 291 if (ogreLogFile_ == "") 292 { 293 COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl; 294 ModifyConfigValue(ogreLogFile_, tset, "ogre.log"); 295 } 296 297 boost::filesystem::path ogreConfigFilepath(Core::getConfigPath() + ogreConfigFile_); 298 boost::filesystem::path ogreLogFilepath(Core::getLogPath() + ogreLogFile_); 299 291 300 // create a new logManager 301 // Ogre::Root will detect that we've already created a Log 292 302 ogreLogger_ = new Ogre::LogManager(); 293 303 COUT(4) << "Ogre LogManager created" << std::endl; … … 295 305 // create our own log that we can listen to 296 306 Ogre::Log *myLog; 297 if (this->ogreLogFile_ == "") 298 myLog = ogreLogger_->createLog("ogre.log", true, false, true); 299 else 300 myLog = ogreLogger_->createLog(this->ogreLogFile_, true, false, false); 307 myLog = ogreLogger_->createLog(ogreLogFilepath.native_file_string(), true, false, false); 301 308 COUT(4) << "Ogre Log created" << std::endl; 302 309 303 310 myLog->setLogDetail(Ogre::LL_BOREME); 304 311 myLog->addListener(this); 305 //#endif 306 307 // Root will detect that we've already created a Log 312 308 313 COUT(4) << "Creating Ogre Root..." << std::endl; 309 310 if (ogreConfigFile_ == "")311 {312 COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;313 ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");314 }315 if (ogreLogFile_ == "")316 {317 COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;318 ModifyConfigValue(ogreLogFile_, tset, "ogre.log");319 }320 314 321 315 // check for config file existence because Ogre displays (caught) exceptions if not 322 316 std::ifstream probe; 323 probe.open(ogreConfigFile _.c_str());317 probe.open(ogreConfigFilepath.native_file_string().c_str()); 324 318 if (!probe) 325 319 { 326 320 // create a zero sized file 327 321 std::ofstream creator; 328 creator.open(ogreConfigFile _.c_str());322 creator.open(ogreConfigFilepath.native_file_string().c_str()); 329 323 creator.close(); 330 324 } … … 333 327 334 328 // Leave plugins file empty. We're going to do that part manually later 335 ogreRoot_ = new Ogre::Root("", ogreConfigFile_, ogreLogFile_); 336 337 #if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.) 338 #ifndef ORXONOX_PLATFORM_WINDOWS 339 // tame the ogre ouput so we don't get all the mess in the console 340 Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog(); 341 defaultLog->setDebugOutputEnabled(false); 342 defaultLog->setLogDetail(Ogre::LL_BOREME); 343 defaultLog->addListener(this); 344 #endif 345 #endif 329 ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.native_file_string(), ogreLogFilepath.native_file_string()); 346 330 347 331 COUT(3) << "Ogre set up done." << std::endl; … … 377 361 try 378 362 { 379 cf.load( Settings::getDataPath() + resourceFile_);363 cf.load(Core::getMediaPath() + resourceFile_); 380 364 } 381 365 catch (...) … … 403 387 404 388 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( 405 std::string( Settings::getDataPath() + archName), typeName, secName);389 std::string(Core::getMediaPath() + archName), typeName, secName); 406 390 } 407 391 } -
code/branches/buildsystem3/src/orxonox/gamestates/GSLevel.cc
r2662 r2685 46 46 #include "LevelManager.h" 47 47 #include "PlayerManager.h" 48 #include "Settings.h"49 48 50 49 namespace orxonox … … 205 204 std::string levelName; 206 205 CommandLine::getValue("level", &levelName); 207 startFile_ = new XMLFile( Settings::getDataPath() + std::string("levels/") + levelName);206 startFile_ = new XMLFile(Core::getMediaPath() + std::string("levels/") + levelName); 208 207 Loader::open(startFile_); 209 208 } -
code/branches/buildsystem3/src/orxonox/gamestates/GSRoot.cc
r2664 r2685 44 44 #include "tools/Timer.h" 45 45 #include "objects/Tickable.h" 46 #include "Settings.h"47 46 48 47 #ifdef ORXONOX_PLATFORM_WINDOWS 49 # ifndef WIN32_LEAN_AND_MEAN 50 # define WIN32_LEAN_AND_MEAN 51 # endif 52 # include "windows.h" 53 54 //Get around Windows hackery 55 # ifdef max 56 # undef max 57 # endif 58 # ifdef min 59 # undef min 60 # endif 48 # include <winbase.h> 61 49 #endif 62 50 63 51 namespace orxonox 64 52 { 65 SetCommandLineArgument(dataPath, "").information("PATH");66 53 SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu"); 67 54 … … 71 58 , bPaused_(false) 72 59 , timeFactorPauseBackup_(1.0f) 73 , settings_(0)74 60 , tclBind_(0) 75 61 , tclThreadManager_(0) … … 113 99 this->luaBind_ = new LuaBind(); 114 100 115 // instantiate Settings class116 this->settings_ = new Settings();117 118 std::string dataPath = CommandLine::getValue("dataPath");119 if (dataPath != "")120 {121 if (*dataPath.end() != '/' && *dataPath.end() != '\\')122 Settings::tsetDataPath(dataPath + "/");123 else124 Settings::tsetDataPath(dataPath);125 }126 127 101 // initialise TCL 128 this->tclBind_ = new TclBind( Settings::getDataPath());102 this->tclBind_ = new TclBind(Core::getMediaPath()); 129 103 this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter()); 130 104 … … 182 156 delete this->tclBind_; 183 157 184 delete this->settings_;185 158 delete this->luaBind_; 186 159 -
code/branches/buildsystem3/src/orxonox/gamestates/GSRoot.h
r2662 r2685 81 81 bool bPaused_; 82 82 float timeFactorPauseBackup_; 83 Settings* settings_;84 83 TclBind* tclBind_; 85 84 TclThreadManager* tclThreadManager_; -
code/branches/buildsystem3/src/orxonox/gui/GUIManager.cc
r2664 r2685 36 36 #include "GUIManager.h" 37 37 38 #include <boost/filesystem.hpp> 38 39 #include <OgreRenderWindow.h> 39 40 #include <OgreRoot.h> 40 41 #include <CEGUI.h> 42 #include <CEGUIDefaultLogger.h> 41 43 #include <ogreceguirenderer/OgreCEGUIRenderer.h> 42 44 #ifdef CEGUILUA_USE_INTERNAL_LIBRARY … … 148 150 this->luaState_ = this->scriptModule_->getLuaState(); 149 151 152 // Create our own logger to specify the filepath 153 boost::filesystem::path ceguiLogFilepath(Core::getLogPath() + "cegui.log"); 154 this->ceguiLogger_ = new DefaultLogger(); 155 this->ceguiLogger_->setLogFilename(ceguiLogFilepath.native_file_string()); 156 // set the log level according to ours (translate by subtracting 1) 157 this->ceguiLogger_->setLoggingLevel( 158 (LoggingLevel)(Core::getSoftDebugLevel(OutputHandler::LD_Logfile) - 1)); 159 150 160 // create the CEGUI system singleton 151 161 this->guiSystem_ = new System(this->guiRenderer_, this->resourceProvider_, 0, this->scriptModule_); 152 153 // set the log level according to ours (translate by subtracting 1)154 Logger::getSingleton().setLoggingLevel(155 (LoggingLevel)(Core::getSoftDebugLevel(OutputHandler::LD_Logfile) - 1));156 162 157 163 // do this after 'new CEGUI::Sytem' because that creates the lua state in the first place -
code/branches/buildsystem3/src/orxonox/gui/GUIManager.h
r2664 r2685 41 41 #include <CEGUISystem.h> 42 42 #include "core/input/InputInterfaces.h" 43 44 // Forward declaration 45 namespace CEGUI { class DefaultLogger; } 43 46 44 47 // tolua_begin … … 119 122 CEGUI::ResourceProvider* resourceProvider_; 120 123 CEGUI::LuaScriptModule* scriptModule_; 124 CEGUI::DefaultLogger* ceguiLogger_; 121 125 CEGUI::System* guiSystem_; 122 126 CEGUI::Imageset* backgroundImage_; -
code/branches/buildsystem3/src/orxonox/objects/Level.cc
r2664 r2685 35 35 #include "core/XMLFile.h" 36 36 #include "core/Template.h" 37 #include "core/Core.h" 37 38 38 #include "Settings.h"39 39 #include "LevelManager.h" 40 40 #include "objects/infos/PlayerInfo.h" … … 55 55 this->xmlfilename_ = this->getFilename(); 56 56 57 if (this->xmlfilename_.length() >= Settings::getDataPath().length())58 this->xmlfilename_ = this->xmlfilename_.substr( Settings::getDataPath().length());57 if (this->xmlfilename_.length() >= Core::getMediaPath().length()) 58 this->xmlfilename_ = this->xmlfilename_.substr(Core::getMediaPath().length()); 59 59 } 60 60 … … 97 97 mask.include(Class(OverlayGroup)); // HACK to include the ChatOverlay 98 98 99 this->xmlfile_ = new XMLFile( Settings::getDataPath() + this->xmlfilename_, mask);99 this->xmlfile_ = new XMLFile(Core::getMediaPath() + this->xmlfilename_, mask); 100 100 101 101 Loader::open(this->xmlfile_); -
code/branches/buildsystem3/src/orxonox/objects/gametypes/Gametype.cc
r2662 r2685 43 43 #include "objects/worldentities/SpawnPoint.h" 44 44 #include "objects/worldentities/Camera.h" 45 #include "Settings.h"46 45 47 46 #include "network/Host.h" -
code/branches/buildsystem3/src/util/OutputBuffer.cc
r2171 r2685 68 68 OutputBuffer& OutputBuffer::operator<<(std::ostream& (*manipulator)(std::ostream&)) 69 69 { 70 71 72 70 this->stream_ << manipulator; 71 this->callListeners(); 72 return *this; 73 73 } 74 74 … … 79 79 OutputBuffer& OutputBuffer::operator<<(std::ios& (*manipulator)(std::ios&)) 80 80 { 81 82 83 81 this->stream_ << manipulator; 82 this->callListeners(); 83 return *this; 84 84 } 85 85 … … 90 90 OutputBuffer& OutputBuffer::operator<<(std::ios_base& (*manipulator)(std::ios_base&)) 91 91 { 92 93 94 92 this->stream_ << manipulator; 93 this->callListeners(); 94 return *this; 95 95 } 96 96 -
code/branches/buildsystem3/src/util/OutputHandler.cc
r2662 r2685 33 33 34 34 #include "OutputHandler.h" 35 #include <time.h> 35 36 #include <ctime> 37 #include <cstdlib> 36 38 37 39 namespace orxonox … … 41 43 @param logfilename The name of the logfile 42 44 */ 43 OutputHandler::OutputHandler(const std::string& logfilename) 44 { 45 OutputHandler::OutputHandler() 46 { 47 #ifdef ORXONOX_PLATFORM_WINDOWS 48 char* pTempDir = getenv("TEMP"); 49 this->logfilename_ = std::string(pTempDir) + "/orxonox.log"; 50 #else 51 this->logfilename_ = "/tmp/orxonox.log"; 52 #endif 53 #ifdef NDEBUG 54 this->softDebugLevel_[LD_All] = this->softDebugLevel_[LD_Logfile] = 2; 55 this->softDebugLevel_[LD_Console] = this->softDebugLevel_[LD_Shell] = 1; 56 #else 57 this->softDebugLevel_[LD_All] = this->softDebugLevel_[LD_Logfile] = 3; 58 this->softDebugLevel_[LD_Console] = this->softDebugLevel_[LD_Shell] = 2; 59 #endif 60 45 61 this->outputBuffer_ = &this->fallbackBuffer_; 46 this->softDebugLevel_[0] = this->softDebugLevel_[1] = this->softDebugLevel_[2] = this->softDebugLevel_[3] = 2;47 this->logfilename_ = logfilename;48 62 this->logfile_.open(this->logfilename_.c_str(), std::fstream::out); 49 63 … … 53 67 timeinfo = localtime(&rawtime); 54 68 55 this->logfile_ << "Started log at" << asctime(timeinfo) << std::endl;69 this->logfile_ << "Started log on " << asctime(timeinfo) << std::endl; 56 70 this->logfile_.flush(); 57 71 } … … 72 86 OutputHandler& OutputHandler::getOutStream() 73 87 { 74 static OutputHandler orxout ("orxonox.log");88 static OutputHandler orxout; 75 89 return orxout; 76 90 } … … 112 126 113 127 /** 128 @brief Sets the path where to create orxonox.log 129 @param Path string with trailing slash 130 */ 131 void OutputHandler::setLogPath(const std::string& path) 132 { 133 OutputHandler::getOutStream().logfile_.close(); 134 // store old content 135 std::ifstream old; 136 old.open(OutputHandler::getOutStream().logfilename_.c_str()); 137 OutputHandler::getOutStream().logfilename_ = path + "orxonox.log"; 138 OutputHandler::getOutStream().logfile_.open(OutputHandler::getOutStream().logfilename_.c_str(), std::fstream::out); 139 OutputHandler::getOutStream().logfile_ << old.rdbuf(); 140 old.close(); 141 OutputHandler::getOutStream().logfile_.flush(); 142 } 143 144 /** 114 145 @brief Overloaded << operator, redirects the output to the console and the logfile. 115 146 @param sb The streambuffer that should be shown in the console -
code/branches/buildsystem3/src/util/OutputHandler.h
r2662 r2685 101 101 static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); 102 102 103 static void setLogPath(const std::string& path); 104 103 105 void setOutputBuffer(OutputBuffer* buffer); 104 106 … … 142 144 143 145 private: 144 explicit OutputHandler( const std::string& logfilename);145 OutputHandler(const OutputHandler& oh); // don't copy146 explicit OutputHandler(); 147 OutputHandler(const OutputHandler& oh); 146 148 virtual ~OutputHandler(); 147 149 -
code/branches/buildsystem3/src/util/SignalHandler.cc
r2664 r2685 159 159 } 160 160 161 COUT(0) << "recieved signal " << sigName.c_str() << std::endl << "try to write backtrace to file orxonox .log" << std::endl;161 COUT(0) << "recieved signal " << sigName.c_str() << std::endl << "try to write backtrace to file orxonox_crash.log" << std::endl; 162 162 163 163 int sigPipe[2];
Note: See TracChangeset
for help on using the changeset viewer.