Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 23, 2009, 7:44:49 PM (14 years ago)
Author:
rgrieder
Message:

Simplified our resource system a bit by working with a single resource group on the user end.
However you can still declare resource groups for separate loading. But accessing the files will always look in all groups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/libraries/core/LuaState.cc

    r6281 r6404  
    8686    }
    8787
    88     shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
    89     {
    90         shared_ptr<ResourceInfo> sourceInfo;
    91         if (resourceGroup != "NoResourceGroupProvided")
    92             sourceInfo = Resource::getInfo(filename, resourceGroup);
    93 
    94         // Continue search if not explicitly forbidden
    95         if (bSearchOtherPaths && sourceInfo == NULL)
    96         {
    97             // Call might be relative to the file currently being processed
    98             sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename, sourceFileInfo_->group);
    99             if (sourceInfo == NULL)
    100             {
    101                 // Maybe find something in the same group but in the root path
    102                 sourceInfo = Resource::getInfo(filename, sourceFileInfo_->group);
    103             }
    104         }
     88    shared_ptr<ResourceInfo> LuaState::getFileInfo(const std::string& filename)
     89    {
     90        // Look in the current directory first
     91        shared_ptr<ResourceInfo> sourceInfo = Resource::getInfo(sourceFileInfo_->path + filename);
     92        // Continue search in root directories
     93        if (sourceInfo == NULL && !sourceFileInfo_->path.empty())
     94            sourceInfo = Resource::getInfo(filename);
    10595        return sourceInfo;
    10696    }
    10797
    108     void LuaState::includeFile(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
    109     {
    110         shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename, resourceGroup, bSearchOtherPaths);
     98    void LuaState::includeFile(const std::string& filename)
     99    {
     100        shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);
    111101        if (sourceInfo != NULL)
    112             this->includeString(Resource::open(sourceInfo->filename, sourceInfo->group)->getAsString(), sourceInfo);
    113         else
    114             COUT(2) << "LuaState: Cannot include file '" << filename << "' in resource group '"
    115                     << (resourceGroup == "NoResourceGroupProvided" ? sourceFileInfo_->group : resourceGroup) << "': group not found." << std::endl;
     102            this->includeString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
     103        else
     104            COUT(2) << "LuaState: Cannot include file '" << filename << "'." << std::endl;
    116105    }
    117106
     
    128117    }
    129118
    130     void LuaState::doFile(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
    131     {
    132         shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename, resourceGroup, bSearchOtherPaths);
     119    void LuaState::doFile(const std::string& filename)
     120    {
     121        shared_ptr<ResourceInfo> sourceInfo = this->getFileInfo(filename);
    133122        if (sourceInfo != NULL)
    134             this->doString(Resource::open(sourceInfo->filename, sourceInfo->group)->getAsString(), sourceInfo);
    135         else
    136             COUT(2) << "LuaState: Cannot do file '" << filename << "' in resource group '"
    137                 << (resourceGroup == "NoResourceGroupProvided" ? sourceFileInfo_->group : resourceGroup) << "': group not found." << std::endl;
     123            this->doString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
     124        else
     125            COUT(2) << "LuaState: Cannot do file '" << filename << "'." << std::endl;
    138126    }
    139127
     
    185173    }
    186174
    187     bool LuaState::fileExists(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths)
    188     {
    189         shared_ptr<ResourceInfo> info =  this->getFileInfo(filename, resourceGroup, bSearchOtherPaths);
     175    bool LuaState::fileExists(const std::string& filename)
     176    {
     177        shared_ptr<ResourceInfo> info = this->getFileInfo(filename);
    190178        if (info == NULL)
    191179            return false;
Note: See TracChangeset for help on using the changeset viewer.