Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 17, 2009, 4:37:10 PM (15 years ago)
Author:
rgrieder
Message:
  • Implemented file management via resource manager and loading of resource locations via XML. Changes made:
    • SoundManager loads via memory stream rather than via file
    • Loader uses LuaState::includeFile() to load an XML file and passes the lua tag remover function to its LuaState.
    • ConfigFileManager still loads with hard paths because the files are required before Ogre gets created
  • Renamed LuaBind to LuaState, deSingletonised it and added new features:
    • doFile(), doString(), includeFile(), includeString() where include will preparse the string with a function provided with LuaState::setIncludeParser
    • Moved lua tags replace function to Loader (since it's actually an XML related task)
    • Using data_path/lua/LuaInitScript.lua to provide the following functions
      • logMessage(level, message)
      • doFile, dofile, include (all working with relative paths but within the same resource group)
  • Modified Script class to work with LuaState and fixed its XML Loader
  • Adjusted all level and include files (both "include" and "dofile" lua commands)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource2/src/orxonox/sound/SoundBase.cc

    r5645 r5654  
    3636#include "util/Math.h"
    3737#include "core/Core.h"
     38#include "core/Resource.h"
    3839#include "orxonox/objects/worldentities/WorldEntity.h"
    3940#include "SoundManager.h"
     
    134135    }
    135136
    136     bool SoundBase::loadFile(std::string filename) {
    137         filename = Core::getDataPathString() + "/audio/" + filename;
    138 
     137    bool SoundBase::loadFile(const std::string& filename) {
    139138        if(!SoundManager::getInstance().isSoundAvailable())
    140139        {
     
    144143
    145144        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
    147159        if(this->buffer_ == AL_NONE) {
    148160            COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
Note: See TracChangeset for help on using the changeset viewer.