Changeset 5774
- Timestamp:
- Sep 23, 2009, 11:31:02 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 127 deleted
- 35 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/bin/CMakeLists.txt
r5695 r5774 26 26 27 27 # Create run scripts for Windows to manually add the DLL path when executing 28 SET(RUN_SCRIPTS run standalone client1 client2 server dedicated)28 SET(RUN_SCRIPTS run) 29 29 IF(WIN32) 30 30 FOREACH(_script ${RUN_SCRIPTS}) -
code/trunk/cmake/CompilerConfig.cmake
r5695 r5774 34 34 MESSAGE(STATUS "Warning: Your compiler is not officially supported.") 35 35 ENDIF() 36 37 SET(COMPILER_CONFIG_USER_SCRIPT "" CACHE FILEPATH38 "Specify a CMake script if you wish to write your own compiler config.39 See CompilerConfigGCC.cmake or CompilerConfigMSVC.cmake for examples.")40 IF(COMPILER_CONFIG_USER_SCRIPT)41 IF(EXISTS ${CMAKE_MODULE_PATH}/${COMPILER_CONFIG_USER_SCRIPT})42 INCLUDE(${CMAKE_MODULE_PATH}/${COMPILER_CONFIG_USER_SCRIPT})43 ENDIF()44 ENDIF(COMPILER_CONFIG_USER_SCRIPT) -
code/trunk/cmake/LibraryConfig.cmake
r5695 r5774 48 48 # Scripts for specific library and CMake config 49 49 INCLUDE(LibraryConfigTardis) 50 INCLUDE(LibraryConfigApple)51 50 52 51 IF(DEPENDENCY_PACKAGE_ENABLE) … … 71 70 ENDIF(DEPENDENCY_PACKAGE_ENABLE) 72 71 73 # User script74 SET(LIBRARY_CONFIG_USER_SCRIPT "" CACHE FILEPATH75 "Specify a CMake script if you wish to write your own library path config.76 See LibraryConfigTardis.cmake for an example.")77 IF(LIBRARY_CONFIG_USER_SCRIPT)78 IF(EXISTS ${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})79 INCLUDE(${CMAKE_MODULE_PATH}/${LIBRARY_CONFIG_USER_SCRIPT})80 ENDIF()81 ENDIF(LIBRARY_CONFIG_USER_SCRIPT)82 83 84 72 ############### Library finding ################# 85 73 # Performs the search and sets the variables # 86 74 87 75 FIND_PACKAGE(OGRE 1.4 REQUIRED) 88 FIND_PACKAGE(ENet 1.1 REQUIRED)89 FIND_PACKAGE(Ogg REQUIRED)90 FIND_PACKAGE(Vorbis REQUIRED)91 FIND_PACKAGE(ALUT REQUIRED)92 FIND_PACKAGE(ZLIB REQUIRED)93 IF(WIN32)94 FIND_PACKAGE(DirectX REQUIRED)95 ENDIF(WIN32)96 97 ##### CEGUI #####98 # We make use of the CEGUI script module called CEGUILua.99 # However there is a small issue with that: We use Tolua, a C++ binding100 # generator ourselves. And we also have to use our bindings in the same101 # lua state is CEGUILua's. Unfortunately this implies that both lua runtime102 # version are equal or else you get segmentation faults.103 # In order to match the Lua versions we decided to ship CEGUILua in our104 # repository, mainly because there is no way to determine which version of105 # Lua CEGUILua was linked against (you'd have to specify yourself) and secondly106 # because we can then choose the Lua version. Future plans might involve only107 # accepting Lua 5.1.108 109 # Insert all internally supported CEGUILua versions here110 SET(CEGUILUA_INTERNAL_SUPPORT 0.5.0 0.6.0 0.6.1 0.6.2)111 OPTION(CEGUILUA_USE_EXTERNAL_LIBRARY "Force the use of external CEGUILua library" OFF)112 FIND_PACKAGE(CEGUI 0.5 REQUIRED)113 114 76 ##### Lua ##### 115 77 IF(CEGUILUA_USE_EXTERNAL_LIBRARY) … … 124 86 ENDIF() 125 87 FIND_PACKAGE(Lua ${LUA_VERSION_REQUEST} EXACT REQUIRED) 126 127 ##### OpenAL #####128 FIND_PACKAGE(OpenAL REQUIRED)129 # Also use parent include dir (without AL/) for ALUT130 IF(OPENAL_INCLUDE_DIR MATCHES "/AL$")131 GET_FILENAME_COMPONENT(ALT_OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} PATH)132 ENDIF()133 SET(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR} ${ALT_OPENAL_INCLUDE_DIR})134 # Notfiy user135 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)136 # Hide variables created by the script137 MARK_AS_ADVANCED(OPENAL_INCLUDE_DIR OPENAL_LIBRARY)138 139 ##### Tcl #####140 # We only require Tcl, so avoid confusing user about other Tcl stuff by141 # applying a little workaround142 SET(Tclsh_FIND_QUIETLY TRUE)143 FIND_PACKAGE(TCL QUIET)144 # Display messages separately145 SET(TCL_FIND_QUIETLY FALSE)146 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)147 88 148 89 ##### Boost ##### … … 161 102 IF(WIN32) 162 103 OPTION(LINK_BOOST_DYNAMIC "Link Boost dynamically on Windows" TRUE) 163 OPTION(LINK_CEGUI_DYNAMIC "Link CEGUI dynamicylly on Windows" TRUE)164 OPTION(LINK_ENET_DYNAMIC "Link ENet dynamically on Windows" TRUE)165 104 OPTION(LINK_OGRE_DYNAMIC "Link OGRE dynamically on Windows" TRUE) 166 OPTION(LINK_TCL_DYNAMIC "Link TCL dynamically on Windows" TRUE)167 OPTION(LINK_ZLIB_DYNAMIC "Link ZLib dynamically on Windows" TRUE)168 105 COMPARE_VERSION_STRINGS("${LUA_VERSION}" "5.1" _version_comparison) 169 106 IF(_version_comparison LESS 0) … … 175 112 IF(DEPENDENCY_PACKAGE_ENABLE) 176 113 MARK_AS_ADVANCED( 177 LINK_BOOST_DYNAMIC LINK_CEGUI_DYNAMIC LINK_ENET_DYNAMIC178 LINK_OGRE_DYNAMIC LINK_TCL_DYNAMIC LINK_ZLIB_DYNAMIC114 LINK_BOOST_DYNAMIC 115 LINK_OGRE_DYNAMIC 179 116 LINK_LUA_DYNAMIC 180 117 ) 181 118 ENDIF() 182 119 ENDIF(WIN32) 183 184 185 ################# OGRE Plugins ##################186 187 # More plugins: Plugin_BSPSceneManager, Plugin_OctreeSceneManager188 SET(OGRE_PLUGINS_INT Plugin_ParticleFX)189 IF(WIN32)190 # CG program manager is probably DirectX related (not available under unix)191 LIST(APPEND OGRE_PLUGINS_INT Plugin_CgProgramManager)192 ENDIF(WIN32)193 SET(OGRE_PLUGINS ${OGRE_PLUGINS_INT} CACHE STRING194 "Specify which OGRE plugins to load. Existance check is performed.")195 196 # Check the plugins and determine the plugin folder197 # You can give a hint by setting the environment variable ENV{OGRE_PLUGIN_DIR}198 INCLUDE(CheckOGREPlugins)199 CHECK_OGRE_PLUGINS(${OGRE_PLUGINS})200 -
code/trunk/cmake/LibraryConfigTardis.cmake
r5698 r5774 44 44 SET(BOOST_INCLUDEDIR "/usr/pack/boost-1.36.0-sd/include/boost-1_36") 45 45 SET(BOOST_LIBRARYDIR "/usr/pack/boost-1.36.0-sd/i686-debian-linux4.0/lib") 46 SET(ENV{CEGUIDIR} "/usr/pack/cegui-0.6.2-sd;/usr/pack/cegui-0.6.2-sd/i686-debian-linux4.0")47 SET(ENV{ENETDIR} "/usr/pack/enet-1.2-sd;/usr/pack/enet-1.2-sd/i686-debian-linux4.0")48 SET(ENV{ALUTDIR} "/usr/pack/openal-0.0.8-cl;/usr/pack/openal-0.0.8-cl/i686-debian-linux3.1")49 SET(ENV{OGGDIR} "/usr/pack/oggvorbis-1.0-ds;/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0")50 SET(ENV{VORBISDIR} "/usr/pack/oggvorbis-1.0-ds;/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0")51 46 SET(ENV{LUA_DIR} "/usr/pack/lua-5.1.4-sd;/usr/pack/lua-5.1.4-sd/i686-debian-linux4.0") 52 47 SET(ENV{OGRE_HOME} "/usr/pack/ogre-1.4.9-sd;/usr/pack/ogre-1.4.9-sd/i686-debian-linux4.0") 53 SET(ENV{OPENALDIR} "/usr/pack/openal-0.0.8-cl;/usr/pack/openal-0.0.8-cl/i686-debian-linux3.1")54 #SET(TCL_INCLUDE_PATH "/usr/pack/tcltk-8.4.9.linux-mo/include")55 48 ENDIF(TARDIS) -
code/trunk/cmake/PackageConfig.cmake
r5770 r5774 57 57 58 58 # Include paths and other special treatments 59 SET(ENV{ALUTDIR} ${DEP_INCLUDE_DIR}/freealut)60 59 SET(ENV{BOOST_ROOT} ${DEP_INCLUDE_DIR}/boost) 61 SET(ENV{CEGUIDIR} ${DEP_INCLUDE_DIR}/cegui)62 SET(ENV{DXSDK_DIR} ${DEP_INCLUDE_DIR}/directx)63 SET(ENV{ENETDIR} ${DEP_INCLUDE_DIR}/enet)64 60 SET(ENV{LUA_DIR} ${DEP_INCLUDE_DIR}/lua) 65 SET(ENV{OGGDIR} ${DEP_INCLUDE_DIR}/libogg)66 SET(ENV{VORBISDIR} ${DEP_INCLUDE_DIR}/libvorbis)67 61 SET(ENV{OGRE_HOME} ${DEP_INCLUDE_DIR}/ogre) 68 SET(ENV{OGRE_PLUGIN_DIR} ${DEP_BINARY_DIR})69 SET(ENV{OPENALDIR} ${DEP_INCLUDE_DIR}/openal)70 LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/tcl/include)71 LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/zlib/include)72 62 73 63 ### INSTALL ### 74 75 # Tcl script library76 INSTALL(77 DIRECTORY ${DEP_LIBRARY_DIR}/tcl/78 DESTINATION lib/tcl79 )80 64 81 65 # On Windows, DLLs have to be in the executable folder, install them -
code/trunk/cmake/PackageConfigMSVC.cmake
r5695 r5774 52 52 SET(CMAKE_LIBRARY_PATH ${DEP_LIBRARY_DIR}) 53 53 54 # Certain find scripts don't behave as ecpected to we have55 # to specify the libraries ourselves.56 SET(TCL_LIBRARY ${DEP_LIBRARY_DIR}/tcl85.lib CACHE FILEPATH "")57 SET(ZLIB_LIBRARY ${DEP_LIBRARY_DIR}/zdll.lib CACHE FILEPATH "")58 59 54 # Visual Leak Detector 60 55 SET(VLD_INCLUDE_DIR ${DEP_INCLUDE_DIR}/vld CACHE PATH "") -
code/trunk/cmake/PackageConfigMinGW.cmake
r5695 r5774 45 45 SET(CMAKE_LIBRARY_PATH ${DEP_LIBRARY_DIR} ${DEP_BINARY_DIR}) 46 46 47 # Certain find scripts don't behave as ecpected to we have48 # to specify the libraries ourselves.49 SET(TCL_LIBRARY ${DEP_BINARY_DIR}/tcl85.dll CACHE FILEPATH "")50 SET(ZLIB_LIBRARY ${DEP_BINARY_DIR}/zlib1.dll CACHE FILEPATH "")51 52 47 ENDIF(MINGW) -
code/trunk/data/CMakeLists.txt
r5700 r5774 30 30 SET(DATA_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE) 31 31 32 # Specify data directory33 GET_FILENAME_COMPONENT(_search_path_1 ${CMAKE_SOURCE_DIR}/../data_extern ABSOLUTE)34 FIND_PATH(EXTERNAL_DATA_DIRECTORY resources.oxr35 PATHS36 ${CMAKE_SOURCE_DIR}/data_extern37 ${_search_path_1}38 NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH39 )40 41 IF(NOT EXTERNAL_DATA_DIRECTORY)42 MESSAGE(STATUS "Warning: External data directory not found. If you want to compile while downloading the data files, you will have to recompile about four files afterwards and relink everything.")43 MESSAGE(STATUS "You can specify your own folder with the EXTERNAL_DATA_DIRECTORY variable. Default location for the path is orxonox_root/data_extern")44 # Temporary override to the default location.45 SET(EXTERNAL_DATA_DIRECTORY ${CMAKE_SOURCE_DIR}/data_extern)46 ENDIF()47 48 49 32 ################ Installation ################# 50 33 51 # Internal directory52 34 INSTALL( 53 35 DIRECTORY ${DATA_DIRECTORY}/ 54 36 DESTINATION ${DATA_INSTALL_DIRECTORY} 55 REGEX "\\.svn$|_svn$|CMakeLists.txt |InstallScript.cmake" EXCLUDE37 REGEX "\\.svn$|_svn$|CMakeLists.txt" EXCLUDE 56 38 ) 57 # External directory58 INSTALL(59 DIRECTORY ${EXTERNAL_DATA_DIRECTORY}/60 DESTINATION ${DATA_INSTALL_DIRECTORY}61 REGEX "\\.svn$|_svn$|resources\\.oxr" EXCLUDE62 )63 # Configure the install scripts (variables not available during installation)64 CONFIGURE_FILE(DataInstallScript.cmake ${CMAKE_CURRENT_BINARY_DIR}/DataInstallScript.cmake @ONLY)65 # Join both resources.oxr files66 INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/DataInstallScript.cmake) -
code/trunk/src/CMakeLists.txt
r5753 r5774 38 38 # If no defines are specified, these libs get linked statically 39 39 ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC) 40 ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 LINK_ENET_DYNAMIC)41 40 ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" WIN32 LINK_LUA_DYNAMIC) 42 ADD_COMPILER_FLAGS("-DOIS_DYNAMIC_LIB")43 ADD_COMPILER_FLAGS("-DZLIB_DLL" WIN32 LINK_ZLIB_DYNAMIC)44 41 # If no defines are specified, these libs get linked dynamically 45 ADD_COMPILER_FLAGS("-DCEGUI_STATIC" WIN32 NOT LINK_CEGUI_DYNAMIC)46 42 ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB" WIN32 NOT LINK_OGRE_DYNAMIC) 47 ADD_COMPILER_FLAGS("-DSTATIC_BUILD" WIN32 NOT LINK_TCL_DYNAMIC)48 49 # Use TinyXML++50 ADD_COMPILER_FLAGS("-DTIXML_USE_TICPP")51 43 52 44 ############## Include Directories ############## … … 56 48 # External 57 49 ${OGRE_INCLUDE_DIR} 58 ${CEGUI_INCLUDE_DIR}59 ${ENET_INCLUDE_DIR}60 50 ${Boost_INCLUDE_DIRS} 61 ${OPENAL_INCLUDE_DIRS}62 ${ALUT_INCLUDE_DIR}63 ${VORBIS_INCLUDE_DIR}64 ${OGG_INCLUDE_DIR}65 51 ${LUA_INCLUDE_DIR} 66 ${TCL_INCLUDE_PATH}67 ${DIRECTX_INCLUDE_DIR}68 ${ZLIB_INCLUDE_DIR}69 52 ${VLD_INCLUDE_DIR} 70 53 … … 72 55 # relative to "external" to avoid conflicts 73 56 ${CMAKE_CURRENT_SOURCE_DIR}/external 74 # Include directories needed even if only included by Orxonox75 ${CMAKE_CURRENT_SOURCE_DIR}/external/bullet76 ${CMAKE_CURRENT_SOURCE_DIR}/external/ois77 57 78 58 # OrxonoxConfig.h 79 59 ${CMAKE_CURRENT_BINARY_DIR} 80 60 ) 81 82 IF(CEGUILUA_USE_INTERNAL_LIBRARY)83 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/external/ceguilua/ceguilua-${CEGUI_VERSION})84 ENDIF()85 61 86 62 ################### Tolua Bind ################## -
code/trunk/src/SpecialConfig.h.in
r5695 r5774 44 44 45 45 /** 46 @def CEGUILUA_USE_INTERNAL_LIBRARY47 Set whether we must suffix "ceguilua/" for the CEGUILua.h include48 */49 #cmakedefine CEGUILUA_USE_INTERNAL_LIBRARY50 51 /**52 46 @def DEPENDENCY_PACKAGE_ENABLE 53 47 Defined if a precompiled depdency package was used. We then copy all libraries … … 90 84 // DEVELOPMENT RUN PATHS 91 85 const char dataDevDirectory[] = "@DATA_DIRECTORY@"; 92 const char externalDataDevDirectory[] = "@EXTERNAL_DATA_DIRECTORY@";93 86 #ifdef CMAKE_CONFIGURATION_TYPES 94 87 const char moduleDevDirectory[] = "@CMAKE_MODULE_OUTPUT_DIRECTORY@/" BOOST_PP_STRINGIZE(CMAKE_BUILD_TYPE); … … 107 100 // Module extension 108 101 const char moduleExtension[] = "@ORXONOX_MODULE_EXTENSION@"; 109 110 // OGRE PLUGINS111 #ifdef NDEBUG112 const char ogrePlugins[] = "@OGRE_PLUGINS_RELEASE@";113 # ifdef DEPENDENCY_PACKAGE_ENABLE114 const char ogrePluginsDirectory[] = ".";115 # else116 const char ogrePluginsDirectory[] = "@OGRE_PLUGINS_FOLDER_RELEASE@";117 # endif118 #else119 const char ogrePlugins[] = "@OGRE_PLUGINS_DEBUG@";120 # ifdef DEPENDENCY_PACKAGE_ENABLE121 const char ogrePluginsDirectory[] = ".";122 # else123 const char ogrePluginsDirectory[] = "@OGRE_PLUGINS_FOLDER_DEBUG@";124 # endif125 #endif126 102 } } 127 103 -
code/trunk/src/external/CMakeLists.txt
r5738 r5774 21 21 22 22 ADD_SUBDIRECTORY(tolua) 23 24 # Include CEGUILua if not requested otherwise25 IF(CEGUILUA_USE_INTERNAL_LIBRARY)26 IF(NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ceguilua/ceguilua-${CEGUI_VERSION})27 MESSAGE(FATAL_ERROR "CEGUILua version not found in src folder. Update list of supported versions in LibraryConfig.cmake!")28 ENDIF()29 30 ADD_SUBDIRECTORY(ceguilua)31 SET(CEGUILUA_LIBRARY ${CEGUILUA_LIBRARY} PARENT_SCOPE)32 ENDIF()33 34 ADD_SUBDIRECTORY(bullet)35 ADD_SUBDIRECTORY(cpptcl)36 ADD_SUBDIRECTORY(ogreceguirenderer)37 ADD_SUBDIRECTORY(ois)38 ADD_SUBDIRECTORY(tinyxml) -
code/trunk/src/libraries/CMakeLists.txt
r5752 r5774 26 26 27 27 ADD_SUBDIRECTORY(core) 28 ADD_SUBDIRECTORY(network)29 ADD_SUBDIRECTORY(tools)30 28 ADD_SUBDIRECTORY(util) -
code/trunk/src/libraries/core/BaseObject.cc
r5738 r5774 33 33 34 34 #include "BaseObject.h" 35 36 #include <tinyxml/tinyxml.h>37 38 #include "util/StringUtils.h"39 35 #include "CoreIncludes.h" 40 #include "Event.h"41 #include "EventIncludes.h"42 #include "Functor.h"43 #include "Iterator.h"44 #include "Template.h"45 #include "XMLFile.h"46 #include "XMLNameListener.h"47 #include "XMLPort.h"48 36 49 37 namespace orxonox … … 59 47 60 48 this->bInitialized_ = true; 61 62 this->bActive_ = true;63 this->bVisible_ = true;64 this->oldGametype_ = 0;65 66 this->lastLoadedXMLElement_ = 0;67 68 this->functorSetMainState_ = 0;69 this->functorGetMainState_ = 0;70 71 this->setCreator(creator);72 if (this->creator_)73 {74 this->setFile(this->creator_->getFile());75 this->setNamespace(this->creator_->getNamespace());76 this->setScene(this->creator_->getScene());77 this->setGametype(this->creator_->getGametype());78 }79 else80 {81 this->file_ = 0;82 this->namespace_ = 0;83 this->scene_ = 0;84 this->gametype_ = 0;85 }86 49 } 87 50 … … 93 56 if (this->isInitialized()) 94 57 { 95 for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)96 (*it)->unregisterEventListener(this);97 98 for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)99 it->first->removeEvent(this);100 101 if (this->functorSetMainState_)102 delete this->functorSetMainState_;103 if (this->functorGetMainState_)104 delete this->functorGetMainState_;105 58 } 106 59 } 107 108 /**109 @brief XML loading and saving.110 @param xmlelement The XML-element111 @param loading Loading (true) or saving (false)112 @return The XML-element113 */114 void BaseObject::XMLPort(Element& xmlelement, XMLPort::Mode mode)115 {116 XMLPortParam(BaseObject, "name", setXMLName, getName, xmlelement, mode);117 XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode);118 XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode);119 XMLPortParam(BaseObject, "mainstate", setMainStateName, getMainStateName, xmlelement, mode);120 121 XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*);122 123 Element* events = xmlelement.FirstChildElement("events", false);124 125 if (events)126 {127 std::list<std::string> eventnames;128 129 if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject)130 {131 for (ticpp::Iterator<ticpp::Element> child = events->FirstChildElement(false); child != child.end(); child++)132 eventnames.push_back(child->Value());133 }134 else if (mode == XMLPort::SaveObject)135 {136 for (std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->getIdentifier()->getXMLPortEventMapBegin(); it != this->getIdentifier()->getXMLPortEventMapEnd(); ++it)137 eventnames.push_back(it->first);138 }139 140 for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it)141 {142 std::string sectionname = (*it);143 ExecutorMember<BaseObject>* loadexecutor = createExecutor(createFunctor(&BaseObject::addEvent), std::string( "BaseObject" ) + "::" + "addEvent");144 ExecutorMember<BaseObject>* saveexecutor = createExecutor(createFunctor(&BaseObject::getEvent), std::string( "BaseObject" ) + "::" + "getEvent");145 loadexecutor->setDefaultValue(1, sectionname);146 147 XMLPortClassObjectContainer<BaseObject, BaseObject>* container = 0;148 container = (XMLPortClassObjectContainer<BaseObject, BaseObject>*)(this->getIdentifier()->getXMLPortEventContainer(sectionname));149 if (!container)150 {151 container = new XMLPortClassObjectContainer<BaseObject, BaseObject>(sectionname, this->getIdentifier(), loadexecutor, saveexecutor, false, true);152 this->getIdentifier()->addXMLPortEventContainer(sectionname, container);153 }154 container->port(this, *events, mode);155 }156 }157 }158 159 /**160 @brief Loads the name of the object through XML and calls all XMLNameListener.161 @param name The name of the object162 */163 void BaseObject::setXMLName(const std::string& name)164 {165 this->setName(name);166 167 for (ObjectList<XMLNameListener>::iterator it = ObjectList<XMLNameListener>::begin(); it != ObjectList<XMLNameListener>::end(); ++it)168 it->loadedNewXMLName(this);169 }170 171 /**172 @brief Returns the levelfile that loaded this object.173 @return The levelfile174 */175 const std::string& BaseObject::getFilename() const176 {177 if (this->file_)178 return this->file_->getFilename();179 else180 return BLANKSTRING;181 }182 183 /**184 @brief Adds a Template to the object.185 @param name The name of the Template186 */187 void BaseObject::addTemplate(const std::string& name)188 {189 Template* temp = Template::getTemplate(name);190 if (temp)191 this->addTemplate(temp);192 else193 COUT(1) << "Error: \"" << name << "\" is not a valid Template name (in class: " << this->getIdentifier()->getName() << ", name: " << this->getName() << ")." << std::endl;194 }195 196 /**197 @brief Adds a Template to the object.198 @param temp The Template199 */200 void BaseObject::addTemplate(Template* temp)201 {202 this->templates_.insert(temp);203 temp->applyOn(this);204 }205 206 /**207 @brief Returns the Template with the given index.208 @param index The index209 */210 Template* BaseObject::getTemplate(unsigned int index) const211 {212 unsigned int i = 0;213 for (std::set<Template*>::const_iterator it = this->templates_.begin(); it != this->templates_.end(); ++it)214 {215 if (i == index)216 return (*it);217 i++;218 }219 return 0;220 }221 222 void BaseObject::addEvent(BaseObject* event, const std::string& sectionname)223 {224 event->registerEventListener(this, sectionname);225 this->events_.push_back(event);226 }227 228 void BaseObject::removeEvent(BaseObject* event)229 {230 this->events_.remove(event);231 }232 233 BaseObject* BaseObject::getEvent(unsigned int index) const234 {235 unsigned int i = 0;236 for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)237 {238 if (i == index)239 return (*it);240 ++i;241 }242 return 0;243 }244 245 void BaseObject::addEventContainer(const std::string& sectionname, EventContainer* container)246 {247 std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.find(sectionname);248 if (it != this->eventContainers_.end())249 {250 COUT(2) << "Warning: Overwriting EventContainer in class " << this->getIdentifier()->getName() << "." << std::endl;251 delete (it->second);252 }253 254 this->eventContainers_[sectionname] = container;255 }256 257 EventContainer* BaseObject::getEventContainer(const std::string& sectionname) const258 {259 std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.find(sectionname);260 if (it != this->eventContainers_.end())261 return ((*it).second);262 else263 return 0;264 }265 266 void BaseObject::fireEvent()267 {268 this->fireEvent(true);269 this->fireEvent(false);270 }271 272 void BaseObject::fireEvent(bool activate)273 {274 this->fireEvent(activate, this);275 }276 277 void BaseObject::fireEvent(bool activate, BaseObject* originator)278 {279 Event event(activate, originator);280 281 for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)282 {283 event.sectionname_ = it->second;284 it->first->processEvent(event);285 }286 }287 288 void BaseObject::fireEvent(Event& event)289 {290 for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)291 it->first->processEvent(event);292 }293 294 void BaseObject::processEvent(Event& event)295 {296 ORXONOX_SET_EVENT(BaseObject, "activity", setActive, event);297 ORXONOX_SET_EVENT(BaseObject, "visibility", setVisible, event);298 }299 300 void BaseObject::setMainStateName(const std::string& name)301 {302 if (this->mainStateName_ != name)303 {304 this->mainStateName_ = name;305 if (this->functorSetMainState_)306 delete this->functorSetMainState_;307 if (this->functorGetMainState_)308 delete this->functorGetMainState_;309 this->changedMainState();310 if (!this->functorSetMainState_)311 COUT(2) << "Warning: \"" << name << "\" is not a valid MainState." << std::endl;312 }313 }314 315 void BaseObject::setMainState(bool state)316 {317 if (this->functorSetMainState_)318 (*this->functorSetMainState_)(state);319 else320 COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl;321 }322 323 bool BaseObject::getMainState() const324 {325 if (this->functorGetMainState_)326 {327 (*this->functorGetMainState_)();328 return this->functorGetMainState_->getReturnvalue();329 }330 else331 {332 COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl;333 return false;334 }335 }336 337 void BaseObject::changedMainState()338 {339 SetMainState(BaseObject, "activity", setActive, isActive);340 SetMainState(BaseObject, "visibility", setVisible, isVisible);341 }342 60 } -
code/trunk/src/libraries/core/BaseObject.h
r5738 r5774 37 37 #define _BaseObject_H__ 38 38 39 #define SetMainState(classname, statename, setfunction, getfunction) \40 if (this->getMainStateName() == statename) \41 { \42 this->functorSetMainState_ = createFunctor(&classname::setfunction)->setObject(this); \43 this->functorGetMainState_ = createFunctor(&classname::getfunction)->setObject(this); \44 }45 46 47 39 #include "CorePrereqs.h" 48 49 #include <map>50 #include <list>51 52 #include "util/mbool.h"53 40 #include "OrxonoxClass.h" 54 #include "Super.h"55 41 56 42 namespace orxonox 57 43 { 58 class Scene;59 class Gametype;60 61 44 //! The BaseObject is the parent of all classes representing an instance in the game. 62 45 class _CoreExport BaseObject : virtual public OrxonoxClass 63 46 { 64 template <class T> friend class XMLPortClassParamContainer;65 66 47 public: 67 48 BaseObject(BaseObject* creator); 68 49 virtual ~BaseObject(); 69 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);70 50 71 51 /** @brief Returns if the object was initialized (passed the object registration). @return True was the object is initialized */ 72 52 inline bool isInitialized() const { return this->bInitialized_; } 73 53 74 /** @brief Sets the name of the object. @param name The name */75 inline void setName(const std::string& name) { this->oldName_ = this->name_; this->name_ = name; this->changedName(); }76 /** @brief Returns the name of the object. */77 inline const std::string& getName() const { return this->name_; }78 /** @brief Returns the old name of the object. */79 inline const std::string& getOldName() const { return this->oldName_; }80 /** @brief This function gets called if the name of the object changes. */81 virtual void changedName() {}82 83 /** @brief Sets the state of the objects activity. @param bActive True = active */84 inline void setActive(bool bActive)85 {86 if (this->bActive_ != bActive)87 {88 this->bActive_ = bActive;89 this->changedActivity();90 }91 }92 /** @brief Returns the state of the objects activity. @return The state of the activity */93 inline const mbool& isActive() const { return this->bActive_; }94 /** @brief This function gets called if the activity of the object changes. */95 virtual void changedActivity() {}96 97 /** @brief Sets the state of the objects visibility. @param bVisible True = visible */98 inline void setVisible(bool bVisible)99 {100 if (this->bVisible_ != bVisible)101 {102 this->bVisible_ = bVisible;103 this->changedVisibility();104 }105 }106 /** @brief Returns the state of the objects visibility. @return The state of the visibility */107 inline const mbool& isVisible() const { return this->bVisible_; }108 /** @brief This function gets called if the visibility of the object changes. */109 virtual void changedVisibility() {}110 111 void setMainState(bool state);112 bool getMainState() const;113 114 void setMainStateName(const std::string& name);115 inline const std::string& getMainStateName() const { return this->mainStateName_; }116 virtual void changedMainState();117 118 /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */119 inline void setFile(const XMLFile* file) { this->file_ = file; }120 /** @brief Returns a pointer to the XMLFile that loaded this object. @return The XMLFile */121 inline const XMLFile* getFile() const { return this->file_; }122 const std::string& getFilename() const;123 124 void addTemplate(const std::string& name);125 void addTemplate(Template* temp);126 /** @brief Returns the set of all aplied templates. */127 inline const std::set<Template*>& getTemplates() const128 { return this->templates_; }129 130 virtual inline void setNamespace(Namespace* ns) { this->namespace_ = ns; }131 inline Namespace* getNamespace() const { return this->namespace_; }132 133 54 inline void setCreator(BaseObject* creator) { this->creator_ = creator; } 134 55 inline BaseObject* getCreator() const { return this->creator_; } 135 56 136 inline void setScene(Scene* scene) { this->scene_ = scene; }137 inline Scene* getScene() const { return this->scene_; }138 139 inline void setGametype(Gametype* gametype)140 {141 if (gametype != this->gametype_)142 {143 this->oldGametype_ = this->gametype_;144 this->gametype_ = gametype;145 this->changedGametype();146 }147 }148 inline Gametype* getGametype() const { return this->gametype_; }149 inline Gametype* getOldGametype() const { return this->oldGametype_; }150 virtual void changedGametype() {}151 152 void fireEvent();153 void fireEvent(bool activate);154 void fireEvent(bool activate, BaseObject* originator);155 void fireEvent(Event& event);156 157 virtual void processEvent(Event& event);158 159 inline void registerEventListener(BaseObject* object, const std::string& sectionname)160 { this->eventListeners_[object] = sectionname; }161 inline void unregisterEventListener(BaseObject* object)162 { this->eventListeners_.erase(object); }163 164 void addEvent(BaseObject* event, const std::string& sectionname);165 void removeEvent(BaseObject* event);166 BaseObject* getEvent(unsigned int index) const;167 168 void addEventContainer(const std::string& sectionname, EventContainer* container);169 EventContainer* getEventContainer(const std::string& sectionname) const;170 171 /** @brief Sets the indentation of the debug output in the Loader. @param indentation The indentation */172 inline void setLoaderIndentation(const std::string& indentation) { this->loaderIndentation_ = indentation; }173 /** @brief Returns the indentation of the debug output in the Loader. @return The indentation */174 inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; }175 176 protected:177 std::string name_; //!< The name of the object178 std::string oldName_; //!< The old name of the object179 mbool bActive_; //!< True = the object is active180 mbool bVisible_; //!< True = the object is visible181 std::string mainStateName_;182 Functor* functorSetMainState_;183 Functor* functorGetMainState_;184 185 57 private: 186 void setXMLName(const std::string& name);187 Template* getTemplate(unsigned int index) const;188 189 58 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 190 const XMLFile* file_; //!< The XMLFile that loaded this object191 Element* lastLoadedXMLElement_; //!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map192 std::map<std::string, std::string> xmlAttributes_; //!< Lowercase XML attributes193 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader194 Namespace* namespace_;195 59 BaseObject* creator_; 196 Scene* scene_;197 Gametype* gametype_;198 Gametype* oldGametype_;199 std::set<Template*> templates_;200 std::map<BaseObject*, std::string> eventListeners_;201 std::list<BaseObject*> events_;202 std::map<std::string, EventContainer*> eventContainers_;203 60 }; 204 205 SUPER_FUNCTION(0, BaseObject, XMLPort, false);206 SUPER_FUNCTION(2, BaseObject, changedActivity, false);207 SUPER_FUNCTION(3, BaseObject, changedVisibility, false);208 SUPER_FUNCTION(4, BaseObject, processEvent, false);209 SUPER_FUNCTION(6, BaseObject, changedMainState, false);210 SUPER_FUNCTION(9, BaseObject, changedName, false);211 SUPER_FUNCTION(10, BaseObject, changedGametype, false);212 61 } 213 62 -
code/trunk/src/libraries/core/CMakeLists.txt
r5738 r5774 25 25 DynLib.cc 26 26 DynLibManager.cc 27 Event.cc28 27 Game.cc 29 GameMode.cc30 28 GameState.cc 31 GraphicsManager.cc32 GUIManager.cc33 29 Language.cc 34 30 LuaState.cc 35 MemoryArchive.cc36 31 ObjectListBase.cc 37 32 OrxonoxClass.cc 38 Resource.cc39 WindowEventListener.cc40 33 41 34 # command 42 ArgumentCompletionFunctions.cc43 CommandEvaluation.cc44 CommandExecutor.cc45 35 CommandLine.cc 46 ConsoleCommand.cc47 ConsoleCommandCompilation.cc48 36 Executor.cc 49 37 … … 55 43 # level 56 44 BaseObject.cc 57 ClassTreeMask.cc58 Loader.cc59 Namespace.cc60 NamespaceNode.cc61 Template.cc62 XMLPort.cc63 XMLNameListener.cc64 45 65 # shell66 IRC.cc67 Shell.cc68 TclBind.cc69 TclThreadManager.cc70 71 46 # multithreading 72 47 Thread.cc 73 48 ThreadPool.cc 74 49 ) 75 ADD_SUBDIRECTORY(input)76 50 77 51 ORXONOX_ADD_LIBRARY(core 78 52 FIND_HEADER_FILES 79 53 TOLUA_FILES 80 CommandExecutor.h81 Loader.h82 54 LuaState.h 83 55 DEFINE_SYMBOL … … 91 63 ${Boost_THREAD_LIBRARY} 92 64 ${Boost_DATE_TIME_LIBRARY} # Thread dependency 93 ${CEGUI_LIBRARY}94 ${CEGUILUA_LIBRARY}95 65 ${LUA_LIBRARIES} 96 cpptcl_orxonox97 ogreceguirenderer_orxonox98 ois_orxonox99 tinyxml++_orxonox100 66 tolua++_orxonox 101 67 util -
code/trunk/src/libraries/core/ClassFactory.h
r5738 r5774 55 55 { 56 56 public: 57 static bool create(const std::string& name , bool bLoadable = true);57 static bool create(const std::string& name); 58 58 BaseObject* fabricate(BaseObject* creator); 59 59 … … 73 73 */ 74 74 template <class T> 75 bool ClassFactory<T>::create(const std::string& name , bool bLoadable)75 bool ClassFactory<T>::create(const std::string& name) 76 76 { 77 77 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl; 78 78 ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>); 79 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);80 79 Factory::add(name, ClassIdentifier<T>::getIdentifier()); 81 80 -
code/trunk/src/libraries/core/Clock.h
r5738 r5774 31 31 32 32 #include "CorePrereqs.h" 33 #include "util/OgreForwardRefs.h" 33 34 namespace Ogre { class Timer; } 34 35 35 36 namespace orxonox -
code/trunk/src/libraries/core/ConfigFileManager.cc
r5738 r5774 34 34 #include "util/Math.h" 35 35 #include "util/StringUtils.h" 36 #include "ConsoleCommand.h"37 36 #include "ConfigValueContainer.h" 38 37 #include "Core.h" … … 40 39 namespace orxonox 41 40 { 42 SetConsoleCommandShortcutExtern(config).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());43 SetConsoleCommandShortcutExtern(tconfig).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());44 SetConsoleCommandShortcutExtern(reloadConfig);45 SetConsoleCommandShortcutExtern(cleanConfig);46 SetConsoleCommandShortcutExtern(loadSettings).argumentCompleter(0, autocompletion::files());47 48 41 bool config(const std::string& classname, const std::string& varname, const std::string& value) 49 42 { -
code/trunk/src/libraries/core/Core.cc
r5759 r5774 63 63 #include "util/SignalHandler.h" 64 64 #include "Clock.h" 65 #include "CommandExecutor.h"66 65 #include "CommandLine.h" 67 66 #include "ConfigFileManager.h" … … 70 69 #include "DynLibManager.h" 71 70 #include "Factory.h" 72 #include "GameMode.h"73 #include "GraphicsManager.h"74 #include "GUIManager.h"75 71 #include "Identifier.h" 76 72 #include "Language.h" 77 73 #include "LuaState.h" 78 #include "Shell.h"79 #include "TclBind.h"80 #include "TclThreadManager.h"81 #include "input/InputManager.h"82 74 83 75 // Boost 1.36 has some issues with deprecated functions that have been omitted … … 117 109 RegisterRootObject(CoreConfiguration); 118 110 this->setConfigValues(); 119 120 // External data directory only exists for dev runs121 if (Core::isDevelopmentRun())122 {123 // Possible data path override by the command line124 if (!CommandLine::getArgument("externalDataPath")->hasDefaultValue())125 tsetExternalDataPath(CommandLine::getValue("externalDataPath"));126 }127 111 } 128 112 … … 194 178 } 195 179 196 /**197 @brief198 Temporary sets the external data path199 @param path200 The new data path201 */202 void tsetExternalDataPath(const std::string& path)203 {204 externalDataPath_ = boost::filesystem::path(path);205 }206 207 180 void initializeRandomNumberGenerator() 208 181 { … … 228 201 boost::filesystem::path modulePath_; //!< Path to the modules 229 202 boost::filesystem::path dataPath_; //!< Path to the data file folder 230 boost::filesystem::path externalDataPath_; //!< Path to the external data file folder231 203 boost::filesystem::path configPath_; //!< Path to the config file folder 232 204 boost::filesystem::path logPath_; //!< Path to the log file folder … … 237 209 // Cleanup guard for identifier destruction (incl. XMLPort, configValues, consoleCommands) 238 210 : identifierDestroyer_(Identifier::destroyAllIdentifiers) 239 // Cleanup guard for external console commands that don't belong to an Identifier240 , consoleCommandDestroyer_(CommandExecutor::destroyExternalCommands)241 211 , configuration_(new CoreConfiguration()) // Don't yet create config values! 242 212 , bDevRun_(false) 243 , bGraphicsLoaded_(false)244 213 { 245 214 // Set the hard coded fixed paths … … 339 308 // possibility to configure everything below here 340 309 this->configuration_->initialise(); 341 342 // Load OGRE excluding the renderer and the render window343 this->graphicsManager_.reset(new GraphicsManager(false));344 345 // initialise Tcl346 this->tclBind_.reset(new TclBind(Core::getDataPathString()));347 this->tclThreadManager_.reset(new TclThreadManager(tclBind_->getTclInterpreter()));348 349 // create a shell350 this->shell_.reset(new Shell());351 310 } 352 311 … … 357 316 Core::~Core() 358 317 { 359 }360 361 void Core::loadGraphics()362 {363 // Any exception should trigger this, even in upgradeToGraphics (see its remarks)364 Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics);365 366 // Upgrade OGRE to receive a render window367 graphicsManager_->upgradeToGraphics();368 369 // Calls the InputManager which sets up the input devices.370 inputManager_.reset(new InputManager());371 372 // load the CEGUI interface373 guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow(),374 inputManager_->getMousePosition(), graphicsManager_->isFullScreen()));375 376 unloader.Dismiss();377 378 bGraphicsLoaded_ = true;379 }380 381 void Core::unloadGraphics()382 {383 this->guiManager_.reset();;384 this->inputManager_.reset();;385 this->graphicsManager_.reset();386 387 // Load Ogre::Root again, but without the render system388 try389 { this->graphicsManager_.reset(new GraphicsManager(false)); }390 catch (...)391 {392 COUT(0) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << std::endl393 << "Another exception might be being handled which may lead to undefined behaviour!" << std::endl394 << "Terminating the program." << std::endl;395 abort();396 }397 398 bGraphicsLoaded_ = false;399 318 } 400 319 … … 457 376 } 458 377 459 /*static*/ void Core::tsetExternalDataPath(const std::string& path)460 {461 getInstance().configuration_->tsetExternalDataPath(path);462 }463 464 378 /*static*/ const boost::filesystem::path& Core::getDataPath() 465 379 { … … 469 383 { 470 384 return getInstance().configuration_->dataPath_.string() + '/'; 471 }472 473 /*static*/ const boost::filesystem::path& Core::getExternalDataPath()474 {475 return getInstance().configuration_->externalDataPath_;476 }477 /*static*/ std::string Core::getExternalDataPathString()478 {479 return getInstance().configuration_->externalDataPath_.string() + '/';480 385 } 481 386 … … 659 564 { 660 565 configuration_->dataPath_ = specialConfig::dataDevDirectory; 661 configuration_->externalDataPath_ = specialConfig::externalDataDevDirectory;662 566 configuration_->configPath_ = specialConfig::configDevDirectory; 663 567 configuration_->logPath_ = specialConfig::logDevDirectory; … … 725 629 void Core::preUpdate(const Clock& time) 726 630 { 727 if (this->bGraphicsLoaded_)728 {729 // process input events730 this->inputManager_->update(time);731 // process gui events732 this->guiManager_->update(time);733 }734 // process thread commands735 this->tclThreadManager_->update(time);736 631 } 737 632 738 633 void Core::postUpdate(const Clock& time) 739 634 { 740 if (this->bGraphicsLoaded_)741 {742 // Render (doesn't throw)743 this->graphicsManager_->update(time);744 }745 635 } 746 636 } -
code/trunk/src/libraries/core/Core.h
r5738 r5774 85 85 static void resetLanguage(); 86 86 87 static void tsetExternalDataPath(const std::string& path);88 87 //! Returns the path to the data files as boost::filesystem::path 89 88 static const boost::filesystem::path& getDataPath(); 90 //! Returns the path to the external data files as boost::filesystem::path91 static const boost::filesystem::path& getExternalDataPath();92 89 //! Returns the path to the config files as boost::filesystem::path 93 90 static const boost::filesystem::path& getConfigPath(); … … 98 95 //! Returns the path to the data files as std::string 99 96 static std::string getDataPathString(); 100 //! Returns the path to the external data files as std::string101 static std::string getExternalDataPathString();102 97 //! Returns the path to the config files as std::string 103 98 static std::string getConfigPathString(); … … 115 110 void postUpdate(const Clock& time); 116 111 117 void loadGraphics();118 void unloadGraphics();119 120 112 void setFixedPaths(); 121 113 void setConfigurablePaths(); … … 126 118 scoped_ptr<SignalHandler> signalHandler_; 127 119 SimpleScopeGuard identifierDestroyer_; 128 SimpleScopeGuard consoleCommandDestroyer_;129 120 scoped_ptr<ConfigFileManager> configFileManager_; 130 121 scoped_ptr<Language> languageInstance_; 131 122 scoped_ptr<CoreConfiguration> configuration_; 132 scoped_ptr<TclBind> tclBind_;133 scoped_ptr<TclThreadManager> tclThreadManager_;134 scoped_ptr<Shell> shell_;135 // graphical136 scoped_ptr<GraphicsManager> graphicsManager_; //!< Interface to OGRE137 scoped_ptr<InputManager> inputManager_; //!< Interface to OIS138 scoped_ptr<GUIManager> guiManager_; //!< Interface to GUI139 123 140 124 bool bDevRun_; //!< True for runs in the build directory (not installed) 141 bool bGraphicsLoaded_;142 125 143 126 static Core* singletonPtr_s; -
code/trunk/src/libraries/core/CoreIncludes.h
r5738 r5774 80 80 */ 81 81 #define CreateFactory(ClassName) \ 82 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, true) 83 84 /** 85 @brief Creates the entry in the Factory for classes which should not be loaded through XML. 86 @param ClassName The name of the class 87 */ 88 #define CreateUnloadableFactory(ClassName) \ 89 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, false) 82 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName) 90 83 91 84 /** -
code/trunk/src/libraries/core/CorePrecompiledHeaders.h
r5749 r5774 70 70 #ifdef ORXONOX_COMPILER_MSVC 71 71 72 #include <ois/OISKeyboard.h> // 1573 #include <ois/OISMouse.h> // 1574 #include <ois/OISJoyStick.h> // 1575 76 72 #include "util/SubString.h" // 14 77 73 -
code/trunk/src/libraries/core/Factory.cc
r5738 r5774 55 55 56 56 /** 57 @brief Returns the Identifier with a given network ID.58 @param id The network ID of the wanted Identifier59 @return The Identifier60 */61 Identifier* Factory::getIdentifier(const uint32_t id)62 {63 std::map<uint32_t, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);64 if (it != getFactoryPointer()->identifierNetworkIDMap_.end())65 return it->second;66 else67 return 0;68 }69 70 /**71 57 @brief Adds a new Identifier to both maps. 72 58 @param name The name of the identifier … … 76 62 { 77 63 getFactoryPointer()->identifierStringMap_[name] = identifier; 78 getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;79 }80 81 /**82 @brief Removes the entry with the old network ID and adds a new one.83 @param identifier The identifier to change84 @param oldID The old networkID85 @param newID The new networkID86 */87 void Factory::changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID)88 {89 // getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);90 getFactoryPointer()->identifierNetworkIDMap_[newID] = identifier;91 }92 93 /**94 @brief Cleans the NetworkID map (needed on clients for correct initialization)95 */96 void Factory::cleanNetworkIDs()97 {98 getFactoryPointer()->identifierNetworkIDMap_.clear();99 64 } 100 65 -
code/trunk/src/libraries/core/Factory.h
r5738 r5774 62 62 static Identifier* getIdentifier(const uint32_t id); 63 63 static void add(const std::string& name, Identifier* identifier); 64 static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID);65 static void cleanNetworkIDs();66 64 static void createClassHierarchy(); 67 65 … … 84 82 85 83 std::map<std::string, Identifier*> identifierStringMap_; //!< The map, mapping the name with the Identifier 86 std::map<uint32_t, Identifier*> identifierNetworkIDMap_; //!< The map, mapping the network ID with the Identifier87 84 }; 88 85 -
code/trunk/src/libraries/core/Game.cc
r5747 r5774 45 45 #include "Clock.h" 46 46 #include "CommandLine.h" 47 #include "ConsoleCommand.h"48 47 #include "Core.h" 49 48 #include "CoreIncludes.h" 50 49 #include "ConfigValueIncludes.h" 51 #include "GameMode.h"52 50 #include "GameState.h" 53 51 54 52 namespace orxonox 55 53 { 56 static void stop_game()57 { Game::getInstance().stop(); }58 SetConsoleCommandShortcutExternAlias(stop_game, "exit");59 60 54 std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s; 61 55 Game* Game::singletonPtr_s = 0; … … 506 500 void Game::loadGraphics() 507 501 { 508 if (!GameMode::bShowsGraphics_s)509 {510 core_->loadGraphics();511 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);512 GameMode::bShowsGraphics_s = true;513 514 // Construct all the GameStates that require graphics515 for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();516 it != gameStateDeclarations_s.end(); ++it)517 {518 if (it->second.bGraphicsMode)519 {520 // Game state loading failure is serious --> don't catch521 shared_ptr<GameState> gameState = GameStateFactory::fabricate(it->second);522 if (!constructedStates_.insert(std::make_pair(523 it->second.stateName, gameState)).second)524 assert(false); // GameState was already created!525 }526 }527 graphicsUnloader.Dismiss();528 }529 502 } 530 503 531 504 void Game::unloadGraphics() 532 505 { 533 if (GameMode::bShowsGraphics_s)534 {535 // Destroy all the GameStates that require graphics536 for (GameStateMap::iterator it = constructedStates_.begin(); it != constructedStates_.end();)537 {538 if (it->second->getInfo().bGraphicsMode)539 constructedStates_.erase(it++);540 else541 ++it;542 }543 544 core_->unloadGraphics();545 GameMode::bShowsGraphics_s = false;546 }547 506 } 548 507 … … 563 522 // If state requires graphics, load it 564 523 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics); 565 if (gameStateDeclarations_s[name].bGraphicsMode && !GameMode::showsGraphics())524 if (gameStateDeclarations_s[name].bGraphicsMode) 566 525 this->loadGraphics(); 567 526 else -
code/trunk/src/libraries/core/Identifier.cc
r5738 r5774 38 38 #include "util/StringUtils.h" 39 39 #include "ConfigValueContainer.h" 40 #include "ConsoleCommand.h"41 40 #include "Factory.h" 42 #include "XMLPort.h"43 41 44 42 namespace orxonox … … 61 59 this->bSetName_ = false; 62 60 this->factory_ = 0; 63 this->bLoadable_ = true;64 61 65 62 this->bHasConfigValues_ = false; 66 this->bHasConsoleCommands_ = false;67 63 68 64 this->children_ = new std::set<const Identifier*>(); 69 65 this->directChildren_ = new std::set<const Identifier*>(); 70 71 // Default network ID is the class ID72 this->networkID_ = this->classID_;73 66 } 74 67 … … 85 78 delete this->factory_; 86 79 87 for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)88 delete (it->second);89 80 for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it) 90 delete (it->second);91 for (std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it)92 delete (it->second);93 for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)94 81 delete (it->second); 95 82 } … … 188 175 // Tell the parent we're one of it's direct children 189 176 (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this); 190 191 // Create the super-function dependencies192 (*it)->createSuperFunctionCaller();193 177 } 194 178 } … … 240 224 241 225 /** 242 @brief Sets the network ID to a new value and changes the entry in the Factory.243 @param id The new network ID244 */245 void Identifier::setNetworkID(uint32_t id)246 {247 Factory::changeNetworkID(this, this->networkID_, id);248 this->networkID_ = id;249 }250 251 /**252 226 @brief Returns true, if the Identifier is at least of the given type. 253 227 @param identifier The identifier to compare with … … 371 345 372 346 /** 373 @brief Adds a new console command of this class.374 @param executor The executor of the command375 @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command376 @return The executor of the command377 */378 ConsoleCommand& Identifier::addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut)379 {380 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(command->getName());381 if (it != this->consoleCommands_.end())382 {383 COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << "." << std::endl;384 delete (it->second);385 }386 387 this->bHasConsoleCommands_ = true;388 this->consoleCommands_[command->getName()] = command;389 this->consoleCommands_LC_[getLowercase(command->getName())] = command;390 391 if (bCreateShortcut)392 CommandExecutor::addConsoleCommandShortcut(command);393 394 return (*command);395 }396 397 /**398 @brief Returns the executor of a console command with given name.399 @brief name The name of the requested console command400 @return The executor of the requested console command401 */402 ConsoleCommand* Identifier::getConsoleCommand(const std::string& name) const403 {404 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name);405 if (it != this->consoleCommands_.end())406 return (*it).second;407 else408 return 0;409 }410 411 /**412 @brief Returns the executor of a console command with given name in lowercase.413 @brief name The name of the requested console command in lowercae414 @return The executor of the requested console command415 */416 ConsoleCommand* Identifier::getLowercaseConsoleCommand(const std::string& name) const417 {418 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name);419 if (it != this->consoleCommands_LC_.end())420 return (*it).second;421 else422 return 0;423 }424 425 /**426 @brief Returns a XMLPortParamContainer that loads a parameter of this class.427 @param paramname The name of the parameter428 @return The container429 */430 XMLPortParamContainer* Identifier::getXMLPortParamContainer(const std::string& paramname)431 {432 std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);433 if (it != this->xmlportParamContainers_.end())434 return ((*it).second);435 else436 return 0;437 }438 439 /**440 @brief Adds a new XMLPortParamContainer that loads a parameter of this class.441 @param paramname The name of the parameter442 @param container The container443 */444 void Identifier::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)445 {446 std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);447 if (it != this->xmlportParamContainers_.end())448 {449 COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << "." << std::endl;450 delete (it->second);451 }452 453 this->xmlportParamContainers_[paramname] = container;454 }455 456 /**457 @brief Returns a XMLPortObjectContainer that attaches an object to this class.458 @param sectionname The name of the section that contains the attachable objects459 @return The container460 */461 XMLPortObjectContainer* Identifier::getXMLPortObjectContainer(const std::string& sectionname)462 {463 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);464 if (it != this->xmlportObjectContainers_.end())465 return ((*it).second);466 else467 return 0;468 }469 470 /**471 @brief Adds a new XMLPortObjectContainer that attaches an object to this class.472 @param sectionname The name of the section that contains the attachable objects473 @param container The container474 */475 void Identifier::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)476 {477 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);478 if (it != this->xmlportObjectContainers_.end())479 {480 COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << "." << std::endl;481 delete (it->second);482 }483 484 this->xmlportObjectContainers_[sectionname] = container;485 }486 487 /**488 @brief Returns a XMLPortEventContainer that attaches an event to this class.489 @param sectionname The name of the section that contains the event490 @return The container491 */492 XMLPortObjectContainer* Identifier::getXMLPortEventContainer(const std::string& eventname)493 {494 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);495 if (it != this->xmlportEventContainers_.end())496 return ((*it).second);497 else498 return 0;499 }500 501 /**502 @brief Adds a new XMLPortEventContainer that attaches an event to this class.503 @param sectionname The name of the section that contains the event504 @param container The container505 */506 void Identifier::addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container)507 {508 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);509 if (it != this->xmlportEventContainers_.end())510 {511 COUT(2) << "Warning: Overwriting XMLPortEventContainer in class " << this->getName() << "." << std::endl;512 delete (it->second);513 }514 515 this->xmlportEventContainers_[eventname] = container;516 }517 518 /**519 347 @brief Lists the names of all Identifiers in a std::set<const Identifier*>. 520 348 @param out The outstream -
code/trunk/src/libraries/core/Identifier.h
r5738 r5774 66 66 #include "ObjectList.h" 67 67 #include "ObjectListBase.h" 68 #include "Super.h"69 68 70 69 namespace orxonox … … 107 106 bool isDirectParentOf(const Identifier* identifier) const; 108 107 109 /** @brief Returns true if the class can be loaded through XML. */110 inline bool isLoadable() const { return this->bLoadable_; }111 /** @brief Set the class to be loadable through XML or not. */112 inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; }113 114 108 /** @brief Returns the list of all existing objects of this class. @return The list */ 115 109 inline ObjectListBase* getObjects() const … … 181 175 182 176 183 /** @brief Returns the map that stores all console commands. @return The const_iterator */184 inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandMap() const { return this->consoleCommands_; }185 /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */186 inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapBegin() const { return this->consoleCommands_.begin(); }187 /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */188 inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapEnd() const { return this->consoleCommands_.end(); }189 190 /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */191 inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandMap() const { return this->consoleCommands_LC_; }192 /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */193 inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapBegin() const { return this->consoleCommands_LC_.begin(); }194 /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */195 inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); }196 197 /** @brief Returns the map that stores all XMLPort params. @return The const_iterator */198 inline const std::map<std::string, XMLPortParamContainer*>& getXMLPortParamMap() const { return this->xmlportParamContainers_; }199 /** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort params. @return The const_iterator */200 inline std::map<std::string, XMLPortParamContainer*>::const_iterator getXMLPortParamMapBegin() const { return this->xmlportParamContainers_.begin(); }201 /** @brief Returns a const_iterator to the end of the map that stores all XMLPort params. @return The const_iterator */202 inline std::map<std::string, XMLPortParamContainer*>::const_iterator getXMLPortParamMapEnd() const { return this->xmlportParamContainers_.end(); }203 204 /** @brief Returns the map that stores all XMLPort objects. @return The const_iterator */205 inline const std::map<std::string, XMLPortObjectContainer*>& getXMLPortObjectMap() const { return this->xmlportObjectContainers_; }206 /** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort objects. @return The const_iterator */207 inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapBegin() const { return this->xmlportObjectContainers_.begin(); }208 /** @brief Returns a const_iterator to the end of the map that stores all XMLPort objects. @return The const_iterator */209 inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapEnd() const { return this->xmlportObjectContainers_.end(); }210 211 /** @brief Returns the map that stores all XMLPort events. @return The const_iterator */212 inline const std::map<std::string, XMLPortObjectContainer*>& getXMLPortEventMap() const { return this->xmlportEventContainers_; }213 /** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort events. @return The const_iterator */214 inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapBegin() const { return this->xmlportEventContainers_.begin(); }215 /** @brief Returns a const_iterator to the end of the map that stores all XMLPort events. @return The const_iterator */216 inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapEnd() const { return this->xmlportEventContainers_.end(); }217 218 177 /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */ 219 178 inline bool hasConfigValues() const { return this->bHasConfigValues_; } 220 /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */221 inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }222 179 223 180 /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */ 224 181 inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); } 225 226 /** @brief Returns the network ID to identify a class through the network. @return the network ID */227 inline const uint32_t getNetworkID() const { return this->networkID_; }228 229 /** @brief Sets the network ID to a new value. @param id The new value */230 void setNetworkID(uint32_t id);231 182 232 183 /** @brief Returns the unique ID of the class */ … … 236 187 ConfigValueContainer* getConfigValueContainer(const std::string& varname); 237 188 ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname); 238 239 void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);240 XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);241 242 void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);243 XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);244 245 void addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container);246 XMLPortObjectContainer* getXMLPortEventContainer(const std::string& eventname);247 248 ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);249 ConsoleCommand* getConsoleCommand(const std::string& name) const;250 ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;251 189 252 190 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass); … … 260 198 261 199 static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal); 262 virtual void createSuperFunctionCaller() const = 0;263 200 264 201 /** @brief Returns the map that stores all Identifiers. @return The map */ … … 305 242 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) 306 243 bool bSetName_; //!< True if the name is set 307 bool bLoadable_; //!< False = it's not permitted to load the object through XML308 244 std::string name_; //!< The name of the class the Identifier belongs to 309 245 BaseFactory* factory_; //!< The Factory, able to create new objects of the given class (if available) 310 246 static int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading) 311 uint32_t networkID_; //!< The network ID to identify a class through the network312 247 const unsigned int classID_; //!< Uniquely identifies a class (might not be the same as the networkID_) 313 248 static unsigned int classIDCounter_s; //!< Static counter for the unique classIDs … … 316 251 std::map<std::string, ConfigValueContainer*> configValues_; //!< A map to link the string of configurable variables with their ConfigValueContainer 317 252 std::map<std::string, ConfigValueContainer*> configValues_LC_; //!< A map to link the string of configurable variables with their ConfigValueContainer 318 319 bool bHasConsoleCommands_; //!< True if this class has at least one assigned console command320 std::map<std::string, ConsoleCommand*> consoleCommands_; //!< All console commands of this class321 std::map<std::string, ConsoleCommand*> consoleCommands_LC_; //!< All console commands of this class with their names in lowercase322 323 std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_; //!< All loadable parameters324 std::map<std::string, XMLPortObjectContainer*> xmlportObjectContainers_; //!< All attachable objects325 std::map<std::string, XMLPortObjectContainer*> xmlportEventContainers_; //!< All events326 253 }; 327 254 … … 344 271 class ClassIdentifier : public Identifier 345 272 { 346 #define SUPER_INTRUSIVE_DECLARATION_INCLUDE347 #include "Super.h"348 349 273 public: 350 274 static ClassIdentifier<T> *getIdentifier(); … … 360 284 ClassIdentifier() 361 285 { 362 SuperFunctionInitialization<0, T>::initialize(this);363 286 } 364 287 ~ClassIdentifier() 365 288 { 366 SuperFunctionDestruction<0, T>::destroy(this);367 289 } 368 290 … … 630 552 { return this->identifier_; } 631 553 632 // /** @brief Returns true, if the assigned identifier is at least of the given type. @param identifier The identifier to compare with */633 // inline bool isA(const Identifier* identifier) const634 // { return this->identifier_->isA(identifier); }635 //636 // /** @brief Returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */637 // inline bool isExactlyA(const Identifier* identifier) const638 // { return this->identifier_->isExactlyA(identifier); }639 //640 // /** @brief Returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */641 // inline bool isChildOf(const Identifier* identifier) const642 // { return this->identifier_->isChildOf(identifier); }643 //644 // /** @brief Returns true, if the assigned identifier is a direct child of the given identifier. @param identifier The identifier to compare with */645 // inline bool isDirectChildOf(const Identifier* identifier) const646 // { return this->identifier_->isDirectChildOf(identifier); }647 //648 // /** @brief Returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */649 // inline bool isParentOf(const Identifier* identifier) const650 // { return this->identifier_->isParentOf(identifier); }651 //652 // /** @brief Returns true, if the assigned identifier is a direct parent of the given identifier. @param identifier The identifier to compare with */653 // inline bool isDirectParentOf(const Identifier* identifier) const654 // { return this->identifier_->isDirectParentOf(identifier); }655 656 554 private: 657 555 Identifier* identifier_; //!< The assigned identifier -
code/trunk/src/libraries/core/LuaState.cc
r5759 r5774 30 30 #include "LuaState.h" 31 31 32 #include <boost/filesystem.hpp> 32 33 #include <tolua/tolua++.h> 33 34 extern "C" { … … 38 39 #include "util/Debug.h" 39 40 #include "Core.h" 40 #include "Resource.h"41 41 #include "ToluaBindCore.h" 42 42 … … 71 71 // Create dummy file info 72 72 sourceFileInfo_.reset(new ResourceInfo()); 73 sourceFileInfo_->group = "General";74 sourceFileInfo_->size = 0;75 73 76 74 // Push 'this' pointer … … 87 85 } 88 86 89 shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename, const std::string& resourceGroup,bool bSearchOtherPaths)87 shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename, bool bSearchOtherPaths) 90 88 { 91 89 shared_ptr<ResourceInfo> sourceInfo; 92 if (resourceGroup != "NoResourceGroupProvided") 93 sourceInfo = Resource::getInfo(filename, resourceGroup); 90 sourceInfo = this->getFileInfo(filename); 94 91 95 92 // Continue search if not explicitely forbidden … … 97 94 { 98 95 // Call might be relative to the file currently being processed 99 sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename, sourceFileInfo_->group);96 sourceInfo = this->getFileInfo(sourceFileInfo_->path + filename); 100 97 if (sourceInfo == NULL) 101 98 { 102 99 // Maybe find something in the same group but in the root path 103 sourceInfo = Resource::getInfo(filename, sourceFileInfo_->group);100 sourceInfo = this->getFileInfo(filename); 104 101 } 105 102 } … … 107 104 } 108 105 109 void LuaState::includeFile(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths) 110 { 111 shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename, resourceGroup, bSearchOtherPaths); 106 shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename) 107 { 108 boost::filesystem::path filepath = Core::getDataPath() / "lua" / filename; 109 if (boost::filesystem::exists(filepath)) 110 { 111 shared_ptr<ResourceInfo> info(new ResourceInfo()); 112 info->filename = filepath.string(); 113 info->path = filepath.branch_path().string(); 114 info->basename = filepath.leaf(); 115 return info; 116 } 117 else 118 return shared_ptr<ResourceInfo>(); 119 } 120 121 std::string LuaState::loadFile(const std::string& filename) 122 { 123 std::ifstream file(filename.c_str()); 124 std::ostringstream oss; 125 oss << file.rdbuf(); 126 return oss.str(); 127 } 128 129 void LuaState::includeFile(const std::string& filename, bool bSearchOtherPaths) 130 { 131 shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename, bSearchOtherPaths); 112 132 if (sourceInfo != NULL) 113 this->includeString(Resource::open(sourceInfo->filename, sourceInfo->group)->getAsString(), sourceInfo); 114 else 115 COUT(2) << "LuaState: Cannot include file '" << filename << "' in resource group '" 116 << (resourceGroup == "NoResourceGroupProvided" ? sourceFileInfo_->group : resourceGroup) << "': group not found." << std::endl; 133 this->includeString(this->loadFile(sourceInfo->filename), sourceInfo); 134 else 135 COUT(2) << "LuaState: Cannot include file '" << filename << std::endl; 117 136 } 118 137 … … 129 148 } 130 149 131 void LuaState::doFile(const std::string& filename, const std::string& resourceGroup,bool bSearchOtherPaths)132 { 133 shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename, resourceGroup,bSearchOtherPaths);150 void LuaState::doFile(const std::string& filename, bool bSearchOtherPaths) 151 { 152 shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename, bSearchOtherPaths); 134 153 if (sourceInfo != NULL) 135 this->doString(Resource::open(sourceInfo->filename, sourceInfo->group)->getAsString(), sourceInfo); 136 else 137 COUT(2) << "LuaState: Cannot do file '" << filename << "' in resource group '" 138 << (resourceGroup == "NoResourceGroupProvided" ? sourceFileInfo_->group : resourceGroup) << "': group not found." << std::endl; 154 this->doString(this->loadFile(sourceInfo->filename), sourceInfo); 155 else 156 COUT(2) << "LuaState: Cannot do file '" << filename << std::endl; 139 157 } 140 158 … … 186 204 } 187 205 188 bool LuaState::fileExists(const std::string& filename, const std::string& resourceGroup,bool bSearchOtherPaths)189 { 190 shared_ptr<ResourceInfo> info = this->getFileInfo(filename, resourceGroup,bSearchOtherPaths);206 bool LuaState::fileExists(const std::string& filename, bool bSearchOtherPaths) 207 { 208 shared_ptr<ResourceInfo> info = this->getFileInfo(filename, bSearchOtherPaths); 191 209 if (info == NULL) 192 210 return false; -
code/trunk/src/libraries/core/LuaState.h
r5738 r5774 45 45 namespace orxonox 46 46 { 47 //! Stores basic information about a File 48 struct ResourceInfo 49 { 50 //! The file's fully qualified name 51 std::string filename; 52 //! Path name; separated by '/' and ending with '/' 53 std::string path; 54 //! Base filename 55 std::string basename; 56 }; 57 47 58 /** 48 59 @brief … … 56 67 ~LuaState(); 57 68 58 void doFile(const std::string& filename, const std::string& resourceGroup = "General",bool bSearchOtherPaths = true); // tolua_export69 void doFile(const std::string& filename, bool bSearchOtherPaths = true); // tolua_export 59 70 void doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>()); 60 71 61 void includeFile(const std::string& filename, const std::string& resourceGroup = "General",bool bSearchOtherPaths = true); // tolua_export72 void includeFile(const std::string& filename, bool bSearchOtherPaths = true); // tolua_export 62 73 void includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>()); 63 74 64 75 void luaPrint(const std::string& str); // tolua_export 65 76 void luaLog(unsigned int level, const std::string& message); // tolua_export 66 bool fileExists(const std::string& filename, const std::string& resourceGroup = "General",bool bSearchOtherPaths = true); // tolua_export77 bool fileExists(const std::string& filename, bool bSearchOtherPaths = true); // tolua_export 67 78 68 79 const std::stringstream& getOutput() const { return output_; } … … 78 89 79 90 private: 80 shared_ptr<ResourceInfo> getFileInfo(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths); 91 shared_ptr<ResourceInfo> getFileInfo(const std::string& filename, bool bSearchOtherPaths); 92 shared_ptr<ResourceInfo> getFileInfo(const std::string& filename); 93 std::string loadFile(const std::string& filename); 81 94 82 95 #if LUA_VERSION_NUM != 501 -
code/trunk/src/libraries/util/CMakeLists.txt
r5749 r5774 19 19 20 20 SET_SOURCE_FILES(UTIL_SRC_FILES 21 Clipboard.cc22 21 CRC32.cc 23 22 Exception.cc -
code/trunk/src/libraries/util/Exception.cc
r5747 r5774 34 34 35 35 #include "Exception.h" 36 #include <CEGUIExceptions.h>37 36 38 37 namespace orxonox … … 106 105 return ex.what(); 107 106 } 108 catch (const CEGUI::Exception& ex)109 {110 #if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6111 return GeneralException(ex.getMessage().c_str()).getDescription();112 #else113 return GeneralException(ex.getMessage().c_str(), ex.getLine(),114 ex.getFileName().c_str(), ex.getName().c_str()).getDescription();115 #endif116 }117 107 catch (...) 118 108 { -
code/trunk/src/modules/CMakeLists.txt
r5752 r5774 26 26 27 27 ################ Sub Directories ################ 28 29 ADD_SUBDIRECTORY(gamestates)30 ADD_SUBDIRECTORY(objects)31 ADD_SUBDIRECTORY(overlays)32 ADD_SUBDIRECTORY(pong)33 ADD_SUBDIRECTORY(questsystem)34 ADD_SUBDIRECTORY(weapons) -
code/trunk/src/orxonox/CMakeLists.txt
r5752 r5774 26 26 SET_SOURCE_FILES(ORXONOX_SRC_FILES 27 27 Main.cc 28 29 CameraManager.cc 30 LevelManager.cc 31 PawnManager.cc 32 PlayerManager.cc 33 34 Level.cc 35 Radar.cc 36 Scene.cc 28 GSRoot.cc 37 29 ) 38 39 ADD_SUBDIRECTORY(collisionshapes)40 ADD_SUBDIRECTORY(controllers)41 ADD_SUBDIRECTORY(gametypes)42 ADD_SUBDIRECTORY(graphics)43 ADD_SUBDIRECTORY(infos)44 ADD_SUBDIRECTORY(interfaces)45 ADD_SUBDIRECTORY(items)46 ADD_SUBDIRECTORY(overlays)47 ADD_SUBDIRECTORY(pickup)48 ADD_SUBDIRECTORY(sound)49 ADD_SUBDIRECTORY(weaponsystem)50 ADD_SUBDIRECTORY(worldentities)51 30 52 31 ORXONOX_ADD_LIBRARY(orxonox 53 32 FIND_HEADER_FILES 54 TOLUA_FILES55 LevelManager.h56 pickup/BaseItem.h57 pickup/PickupInventory.h58 33 DEFINE_SYMBOL 59 34 "ORXONOX_SHARED_BUILD" 60 PCH_FILE61 OrxonoxPrecompiledHeaders.h62 35 LINK_LIBRARIES 63 ${Boost_FILESYSTEM_LIBRARY}64 ${Boost_SYSTEM_LIBRARY} # Filesystem dependency65 ${Boost_THREAD_LIBRARY}66 ${Boost_DATE_TIME_LIBRARY} # Thread dependency67 ${OGRE_LIBRARY}68 ${OPENAL_LIBRARY}69 ${ALUT_LIBRARY}70 ${VORBISFILE_LIBRARY}71 ${VORBIS_LIBRARY}72 ${OGG_LIBRARY}73 tinyxml++_orxonox74 36 tolua++_orxonox 75 bullet_orxonox76 37 util 77 38 core 78 network79 tools80 39 SOURCE_FILES ${ORXONOX_SRC_FILES} 81 40 ) -
code/trunk/src/orxonox/GSRoot.cc
r5758 r5774 30 30 31 31 #include "core/Clock.h" 32 #include "core/ConsoleCommand.h"33 32 #include "core/Game.h" 34 #include "core/GameMode.h"35 #include "network/NetworkFunction.h"36 #include "tools/Timer.h"37 #include "tools/interfaces/TimeFactorListener.h"38 #include "tools/interfaces/Tickable.h"39 #include "LevelManager.h"40 33 41 34 namespace orxonox … … 45 38 GSRoot::GSRoot(const GameStateInfo& info) 46 39 : GameState(info) 47 , timeFactor_(1.0f)48 , bPaused_(false)49 , timeFactorPauseBackup_(1.0f)50 40 { 51 this->ccSetTimeFactor_ = 0;52 this->ccPause_ = 0;53 41 } 54 42 55 43 GSRoot::~GSRoot() 56 44 { 57 NetworkFunctionBase::destroyAllNetworkFunctions();58 45 } 59 46 60 47 void GSRoot::activate() 61 48 { 62 // reset game speed to normal63 this->timeFactor_ = 1.0f;64 65 {66 // time factor console command67 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::setTimeFactor);68 functor->setObject(this);69 this->ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor");70 CommandExecutor::addConsoleCommandShortcut(this->ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);71 }72 73 {74 // time factor console command75 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::pause);76 functor->setObject(this);77 this->ccPause_ = createConsoleCommand(functor, "pause");78 CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);79 }80 81 // create the LevelManager82 this->levelManager_ = new LevelManager();83 49 } 84 50 85 51 void GSRoot::deactivate() 86 52 { 87 /*88 if (this->ccSetTimeFactor_)89 {90 delete this->ccSetTimeFactor_;91 this->ccSetTimeFactor_ = 0;92 }93 94 if (this->ccPause_)95 {96 delete this->ccPause_;97 this->ccPause_ = 0;98 }99 */100 101 delete this->levelManager_;102 53 } 103 54 104 55 void GSRoot::update(const Clock& time) 105 56 { 106 if (this->getActivity().topState)107 {108 // This state can not 'survive' on its own.109 // Load a user interface therefore110 Game::getInstance().requestState("ioConsole");111 }112 113 for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)114 it->tick(time);115 116 /*** HACK *** HACK ***/117 // Call the Tickable objects118 float leveldt = time.getDeltaTime();119 if (leveldt > 1.0f)120 {121 // just loaded122 leveldt = 0.0f;123 }124 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)125 it->tick(leveldt * this->timeFactor_);126 /*** HACK *** HACK ***/127 }128 129 /**130 @brief131 Changes the speed of Orxonox132 @remark133 This function is a hack when placed here!134 Timefactor should be related to the scene (level or so), not the game135 */136 void GSRoot::setTimeFactor(float factor)137 {138 if (GameMode::isMaster())139 {140 if (!this->bPaused_)141 {142 TimeFactorListener::timefactor_s = factor;143 144 for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it)145 it->changedTimeFactor(factor, this->timeFactor_);146 147 this->timeFactor_ = factor;148 }149 else150 this->timeFactorPauseBackup_ = factor;151 }152 }153 154 void GSRoot::pause()155 {156 if (GameMode::isMaster())157 {158 if (!this->bPaused_)159 {160 this->timeFactorPauseBackup_ = this->timeFactor_;161 this->setTimeFactor(0.0f);162 this->bPaused_ = true;163 }164 else165 {166 this->bPaused_ = false;167 this->setTimeFactor(this->timeFactorPauseBackup_);168 }169 }170 57 } 171 58 } -
code/trunk/src/orxonox/GSRoot.h
r5758 r5774 30 30 #define _GSRoot_H__ 31 31 32 #include " gamestates/GameStatesPrereqs.h"32 #include "OrxonoxPrereqs.h" 33 33 #include "core/GameState.h" 34 34 35 35 namespace orxonox 36 36 { 37 class _ GameStatesExport GSRoot : public GameState37 class _OrxonoxExport GSRoot : public GameState 38 38 { 39 39 public: … … 45 45 void update(const Clock& time); 46 46 47 // this has to be public because proteced triggers a bug in msvc48 // when taking the function address.49 void setTimeFactor(float factor);50 void pause();51 float getTimeFactor() { return this->timeFactor_; }52 53 47 private: 54 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal.55 bool bPaused_;56 float timeFactorPauseBackup_;57 58 LevelManager* levelManager_; //!< global level manager59 60 // console commands61 ConsoleCommand* ccSetTimeFactor_;62 ConsoleCommand* ccPause_;63 48 }; 64 49 } -
code/trunk/src/orxonox/Main.cc
r5695 r5774 41 41 #include "core/Game.h" 42 42 #include "core/LuaState.h" 43 #include "ToluaBindOrxonox.h"44 43 #include "Main.h" 45 46 SetCommandLineSwitch(console).information("Start in console mode (text IO only)");47 // Shortcuts for easy direct loading48 SetCommandLineSwitch(server).information("Start in server mode");49 SetCommandLineSwitch(client).information("Start in client mode");50 SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");51 SetCommandLineSwitch(standalone).information("Start in standalone mode");52 53 DeclareToluaInterface(Orxonox);54 44 55 45 namespace orxonox … … 65 55 game->setStateHierarchy( 66 56 "root" 67 " graphics"68 " mainMenu"69 " standalone"70 " level"71 " server"72 " level"73 " client"74 " level"75 " dedicated"76 " level"77 " ioConsole"78 57 ); 79 58 80 59 game->requestState("root"); 81 82 // Some development hacks (not really, but in the future, this calls won't make sense anymore)83 if (CommandLine::getValue("standalone").getBool())84 Game::getInstance().requestStates("graphics, standalone, level");85 else if (CommandLine::getValue("server").getBool())86 Game::getInstance().requestStates("graphics, server, level");87 else if (CommandLine::getValue("client").getBool())88 Game::getInstance().requestStates("graphics, client, level");89 else if (CommandLine::getValue("dedicated").getBool())90 Game::getInstance().requestStates("dedicated, level");91 else if (CommandLine::getValue("console").getBool())92 Game::getInstance().requestStates("ioConsole");93 else94 Game::getInstance().requestStates("graphics, mainMenu");95 60 96 61 game->run(); -
code/trunk/src/orxonox/OrxonoxPrereqs.h
r5738 r5774 36 36 37 37 #include "OrxonoxConfig.h" 38 39 #include "tools/ToolsPrereqs.h"40 38 41 39 //-----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.