[Orxonox-commit 1333] r6051 - code/branches/menu/src/libraries/core

rgrieder at orxonox.net rgrieder at orxonox.net
Thu Nov 12 19:41:20 CET 2009


Author: rgrieder
Date: 2009-11-12 19:41:20 +0100 (Thu, 12 Nov 2009)
New Revision: 6051

Modified:
   code/branches/menu/src/libraries/core/GUIManager.cc
   code/branches/menu/src/libraries/core/LuaState.cc
   code/branches/menu/src/libraries/core/LuaState.h
Log:
Fix for the resource group problem in the GUIManager. This should fix the lua require function (though I could not test it).

Modified: code/branches/menu/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/menu/src/libraries/core/GUIManager.cc	2009-11-12 11:48:26 UTC (rev 6050)
+++ code/branches/menu/src/libraries/core/GUIManager.cc	2009-11-12 18:41:20 UTC (rev 6051)
@@ -120,6 +120,9 @@
 
         // setup scripting
         luaState_.reset(new LuaState());
+        rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua", "GUI");
+        // This is necessary to ensure that input events also use the right resource info when triggering lua functions
+        luaState_->setDefaultResourceInfo(this->rootFileInfo_);
         scriptModule_.reset(new LuaScriptModule(luaState_->getInternalLuaState()));
 
         // Create our own logger to specify the filepath
@@ -134,7 +137,6 @@
         guiSystem_.reset(new System(guiRenderer_.get(), resourceProvider_, 0, scriptModule_.get()));
 
         // Initialise the basic lua code
-        rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua", "GUI");
         this->luaState_->doFile("InitialiseGUI.lua", "GUI", false);
 
         // Align CEGUI mouse with OIS mouse

Modified: code/branches/menu/src/libraries/core/LuaState.cc
===================================================================
--- code/branches/menu/src/libraries/core/LuaState.cc	2009-11-12 11:48:26 UTC (rev 6050)
+++ code/branches/menu/src/libraries/core/LuaState.cc	2009-11-12 18:41:20 UTC (rev 6051)
@@ -115,7 +115,7 @@
                     << (resourceGroup == "NoResourceGroupProvided" ? sourceFileInfo_->group : resourceGroup) << "': group not found." << std::endl;
     }
 
-    void LuaState::includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo)
+    void LuaState::includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
     {
         // Parse string with provided include parser (otherwise don't preparse at all)
         std::string luaInput;
@@ -137,7 +137,7 @@
                 << (resourceGroup == "NoResourceGroupProvided" ? sourceFileInfo_->group : resourceGroup) << "': group not found." << std::endl;
     }
 
-    void LuaState::doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo)
+    void LuaState::doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
     {
         // Save the oold source file info
         shared_ptr<ResourceInfo> oldSourceFileInfo = sourceFileInfo_;

Modified: code/branches/menu/src/libraries/core/LuaState.h
===================================================================
--- code/branches/menu/src/libraries/core/LuaState.h	2009-11-12 11:48:26 UTC (rev 6050)
+++ code/branches/menu/src/libraries/core/LuaState.h	2009-11-12 18:41:20 UTC (rev 6051)
@@ -56,10 +56,10 @@
         ~LuaState();
 
         void doFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
-        void doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>());
+        void doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
 
         void includeFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
-        void includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>());
+        void includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
 
         void luaPrint(const std::string& str); // tolua_export
         void luaLog(unsigned int level, const std::string& message); // tolua_export
@@ -71,6 +71,9 @@
         void setIncludeParser(std::string (*function)(const std::string&)) { includeParseFunction_ = function; }
         lua_State* getInternalLuaState() { return luaState_; }
 
+        void setDefaultResourceInfo(const shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; }
+        const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }
+
         static bool addToluaInterface(int (*function)(lua_State*), const std::string& name);
         static bool removeToluaInterface(const std::string& name);
         static void openToluaInterfaces(lua_State* state);




More information about the Orxonox-commit mailing list