Changeset 5654 for code/branches/resource2/src/orxonox
- Timestamp:
- Aug 17, 2009, 4:37:10 PM (15 years ago)
- Location:
- code/branches/resource2/src/orxonox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource2/src/orxonox/gamestates/GSGraphics.cc
r5645 r5654 96 96 // load debug overlay 97 97 COUT(3) << "Loading Debug Overlay..." << std::endl; 98 this->debugOverlay_ = new XMLFile( Core::getDataPathString() + "overlay/debug.oxo");98 this->debugOverlay_ = new XMLFile("debug.oxo"); 99 99 Loader::open(debugOverlay_); 100 100 -
code/branches/resource2/src/orxonox/gamestates/GSLevel.cc
r5645 r5654 246 246 // call the loader 247 247 COUT(0) << "Loading level..." << std::endl; 248 startFile_s = new XMLFile( Core::getDataPathString() + "levels" + '/' +LevelManager::getInstance().getDefaultLevel());248 startFile_s = new XMLFile(LevelManager::getInstance().getDefaultLevel()); 249 249 Loader::open(startFile_s); 250 250 } -
code/branches/resource2/src/orxonox/gamestates/GSRoot.cc
r3370 r5654 33 33 #include "core/Game.h" 34 34 #include "core/GameMode.h" 35 #include "core/Lua Bind.h"35 #include "core/LuaState.h" 36 36 #include "network/NetworkFunction.h" 37 #include "ToluaBindCore.h"38 37 #include "ToluaBindOrxonox.h" 39 38 #include "tools/Timer.h" … … 56 55 57 56 // Tell LuaBind about all tolua interfaces 58 LuaBind::getInstance().addToluaInterface(&tolua_Core_open, "Core"); 59 LuaBind::getInstance().addToluaInterface(&tolua_Orxonox_open, "Orxonox"); 57 LuaState::addToluaInterface(&tolua_Orxonox_open, "Orxonox"); 60 58 } 61 59 … … 86 84 } 87 85 88 // create the globalLevelManager86 // create the LevelManager 89 87 this->levelManager_ = new LevelManager(); 90 88 } -
code/branches/resource2/src/orxonox/objects/Level.cc
r5653 r5654 53 53 this->registerVariables(); 54 54 this->xmlfilename_ = this->getFilename(); 55 56 if (this->xmlfilename_.length() >= Core::getDataPathString().length())57 this->xmlfilename_ = this->xmlfilename_.substr(Core::getDataPathString().length());58 55 } 59 56 -
code/branches/resource2/src/orxonox/objects/Script.cc
r3196 r5654 29 29 #include "Script.h" 30 30 31 #include <tinyxml/ticpp.h>32 31 #include "core/CoreIncludes.h" 33 #include "core/LuaBind.h" 32 #include "core/LuaState.h" 33 #include "core/XMLPort.h" 34 34 35 35 namespace orxonox 36 36 { 37 CreateFactory(Script);37 CreateFactory(Script); 38 38 39 Script::Script(BaseObject* creator) : BaseObject(creator)40 {41 RegisterObject(Script);39 Script::Script(BaseObject* creator) : BaseObject(creator) 40 { 41 RegisterObject(Script); 42 42 43 code_ = ""; 44 } 43 // Get a new LuaState 44 luaState_ = new LuaState(); 45 } 45 46 46 Script::~Script() 47 { 48 } 47 Script::~Script() 48 { 49 if (this->isInitialized()) 50 delete luaState_; 51 } 49 52 50 /** 51 @brief XML loading and saving. 52 @param xmlelement The XML-element 53 @param loading Loading (true) or saving (false) 54 */ 55 void Script::XMLPort(Element& xmlelement, XMLPort::Mode mode) 56 { 57 BaseObject::XMLPort(xmlelement, mode); 53 void Script::XMLPort(Element& xmlelement, XMLPort::Mode mode) 54 { 55 BaseObject::XMLPort(xmlelement, mode); 58 56 59 code_ = xmlelement.GetText(false);60 }57 XMLPortParam(Script, "code", setCode, getCode, xmlelement, mode); 58 } 61 59 62 void Script::execute() 63 { 64 LuaBind& lua = LuaBind::getInstance(); 65 lua.loadString(this->code_); 66 lua.run(); 67 } 60 void Script::execute() 61 { 62 luaState_->doString(code_); 63 } 68 64 } -
code/branches/resource2/src/orxonox/objects/Script.h
r3196 r5654 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport Script : public BaseObject40 {39 class _OrxonoxExport Script : public BaseObject 40 { 41 41 public: 42 Script(BaseObject* creator); 43 ~Script(); 44 void XMLPort(Element& xmlelement, XMLPort::Mode mode); 45 void execute(); 42 Script(BaseObject* creator); 43 ~Script(); 44 void XMLPort(Element& xmlelement, XMLPort::Mode mode); 45 void execute(); 46 47 void setCode(const std::string& code) { code_ = code; } 48 const std::string& getCode() const { return code_; } 46 49 47 50 private: 48 std::string code_; 49 }; 51 std::string code_; 52 LuaState* luaState_; 53 }; 50 54 } 51 55 -
code/branches/resource2/src/orxonox/sound/SoundBase.cc
r5645 r5654 36 36 #include "util/Math.h" 37 37 #include "core/Core.h" 38 #include "core/Resource.h" 38 39 #include "orxonox/objects/worldentities/WorldEntity.h" 39 40 #include "SoundManager.h" … … 134 135 } 135 136 136 bool SoundBase::loadFile(std::string filename) { 137 filename = Core::getDataPathString() + "/audio/" + filename; 138 137 bool SoundBase::loadFile(const std::string& filename) { 139 138 if(!SoundManager::getInstance().isSoundAvailable()) 140 139 { … … 144 143 145 144 COUT(3) << "Sound: OpenAL ALUT: loading file " << filename << std::endl; 146 this->buffer_ = alutCreateBufferFromFile(filename.c_str()); 145 // Get DataStream from the resources 146 shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(filename); 147 if (fileInfo == NULL) { 148 COUT(2) << "Warning: Sound file '" << filename << "' not found" << std::endl; 149 return false; 150 } 151 DataStreamPtr stream = Resource::open(filename); 152 // Read everything into a temporary buffer 153 char* buffer = new char[fileInfo->size]; 154 stream->read(buffer, fileInfo->size); 155 156 this->buffer_ = alutCreateBufferFromFileImage(buffer, fileInfo->size); 157 delete[] buffer; 158 147 159 if(this->buffer_ == AL_NONE) { 148 160 COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl; -
code/branches/resource2/src/orxonox/sound/SoundBase.h
r3196 r5654 55 55 bool isStopped(); 56 56 57 bool loadFile( std::stringfilename);57 bool loadFile(const std::string& filename); 58 58 59 59 private:
Note: See TracChangeset
for help on using the changeset viewer.