Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5660 for code


Ignore:
Timestamp:
Aug 18, 2009, 12:06:41 PM (15 years ago)
Author:
rgrieder
Message:

Added bLuaSupport_ to XMLFile so we can load the resource locations without lua. And therefore LuaState can access its init script via resources.
Also fixed a problem in the LevelManager with level loading.

Location:
code/branches/resource2/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource2/src/core/GraphicsManager.cc

    r5658 r5660  
    103103        // Load resources
    104104        resources_.reset(new XMLFile("resources.oxr", "dataRoot"));
     105        resources_->setLuaSupport(false);
    105106        Loader::open(resources_.get());
    106107
     
    110111            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(Core::getExternalDataPathString(), "FileSystem", "externalDataRoot", false);
    111112            extResources_.reset(new XMLFile("resources.oxr", "externalDataRoot"));
     113            extResources_->setLuaSupport(false);
    112114            Loader::open(extResources_.get());
    113115        }
  • code/branches/resource2/src/core/Loader.cc

    r5654 r5660  
    122122        Loader::currentMask_s = file->getMask() * mask;
    123123
    124         // Use the LuaState to replace the XML tags (calls our function)
    125         scoped_ptr<LuaState> luaState(new LuaState());
    126         luaState->setIncludeParser(&Loader::replaceLuaTags);
    127         luaState->includeFile(file->getFilename(), file->getResourceGroup(), false);
    128         //luaState->doString(luaInput);
     124        std::string xmlInput;
     125        if (file->getLuaSupport())
     126        {
     127            // Use the LuaState to replace the XML tags (calls our function)
     128            scoped_ptr<LuaState> luaState(new LuaState());
     129            luaState->setIncludeParser(&Loader::replaceLuaTags);
     130            luaState->includeFile(file->getFilename(), file->getResourceGroup(), false);
     131            xmlInput = luaState->getOutput().str();
     132        }
     133        else
     134        {
     135            shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename(), file->getResourceGroup());
     136            if (info == NULL)
     137            {
     138                COUT(1) << "Error: Could not find XML file '" << file->getFilename() << "'." << std::endl;
     139                return false;
     140            }
     141            xmlInput = Resource::open(file->getFilename(), file->getResourceGroup())->getAsString();
     142        }
    129143
    130144        try
     
    134148
    135149            ticpp::Document xmlfile(file->getFilename());
    136             xmlfile.Parse(luaState->getOutput().str(), true);
     150            xmlfile.Parse(xmlInput, true);
    137151
    138152            ticpp::Element rootElement;
  • code/branches/resource2/src/core/LuaState.cc

    r5655 r5660  
    7979
    8080        // Parse init script
    81         // Note: We have to use a hard coded path because the script is required for the resource loading
    82         this->doString("dofile(\"" + Core::getDataPathString() + "lua/LuaStateInit.lua\")");
     81        this->doFile("LuaStateInit.lua");
    8382    }
    8483
  • code/branches/resource2/src/core/XMLFile.h

    r5653 r5660  
    5050            { }
    5151
     52            void setLuaSupport(bool val) { bLuaSupport_ = val; }
     53
    5254            const std::string& getFilename() const { return this->filename_; }
    5355            const std::string& getResourceGroup() const { return this->group_; }
    5456            const ClassTreeMask& getMask() const { return this->mask_; }
     57            bool getLuaSupport() const { return this->bLuaSupport_; }
    5558
    5659        private:
     
    5861            std::string group_;
    5962            ClassTreeMask mask_;
     63            bool bLuaSupport_;
    6064    };
    6165}
  • code/branches/resource2/src/orxonox/LevelManager.cc

    r5659 r5660  
    142142                it = availableLevels_.erase(it);
    143143            else
     144            {
     145                size_t pos = it->find(".oxw");
     146                *it = it->substr(0, pos);
    144147                ++it;
     148            }
    145149    }
    146150}
Note: See TracChangeset for help on using the changeset viewer.