Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 10:23:58 PM (14 years ago)
Author:
rgrieder
Message:

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/LuaState.cc

    r6105 r6417  
    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 explicitely 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;
    116     }
    117 
    118     void LuaState::includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo)
     102            this->includeString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
     103        else
     104            COUT(2) << "LuaState: Cannot include file '" << filename << "'." << std::endl;
     105    }
     106
     107    void LuaState::includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
    119108    {
    120109        // Parse string with provided include parser (otherwise don't preparse at all)
     
    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;
    138     }
    139 
    140     void LuaState::doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo)
    141     {
    142         // Save the oold source file info
     123            this->doString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
     124        else
     125            COUT(2) << "LuaState: Cannot do file '" << filename << "'." << std::endl;
     126    }
     127
     128    void LuaState::doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
     129    {
     130        // Save the old source file info
    143131        shared_ptr<ResourceInfo> oldSourceFileInfo = sourceFileInfo_;
    144132        // Only override if sourceFileInfo provides useful information
     
    164152            if (sourceFileInfo != NULL)
    165153                origin = " originating from " + sourceFileInfo_->filename;
    166             COUT(2) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
     154            COUT(1) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
    167155            // return value is nil
    168156            lua_pushnil(luaState_);
     
    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;
     
    263251        }
    264252    }
     253
     254
     255    LuaFunctor::LuaFunctor(const std::string& code, LuaState* luaState)
     256    {
     257        this->code_ = code;
     258        this->lua_ = luaState;
     259    }
     260
     261    void LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
     262    {
     263        lua_->doString(this->code_);
     264    }
    265265}
Note: See TracChangeset for help on using the changeset viewer.