Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 23, 2009, 8:04:51 PM (15 years ago)
Author:
rgrieder
Message:

Moved GUIManager::getLevelList to LevelManager because the GUIManager has nothing to do with levels.
I also had to change the way the information flows: Instead of operation on the Lua state, you tell the LevelManager to compile the list and then get the elements one by one.
The reason for this change is simple: There is no way to know from which LuaState the call came (without making an ugly hack in Tolua itself).

Location:
code/branches/resource/src/orxonox/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/src/orxonox/gui/GUIManager.cc

    r3338 r3339  
    6161#include "ToluaBindCore.h"
    6262#include "ToluaBindOrxonox.h"
    63 #include "core/Loader.h"
    6463
    6564namespace orxonox
     
    8887
    8988    static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
     89
    9090    GUIManager* GUIManager::singletonRef_s = 0;
    9191
     
    157157        Destructor of the GUIManager
    158158
    159         Basically shuts down CEGUI and destroys the Lua engine and afterwards the interface to the Ogre engine.
     159        Basically shuts down CEGUI (member smart pointers) but first unloads our Tolua modules.
    160160    */
    161161    GUIManager::~GUIManager()
     
    174174        Calls main Lua script
    175175    @todo
    176         Replace loadGUI.lua with loadGUI_2.lua after merging this back to trunk.
    177         However CEGUI is able to execute a startup script. We could maybe put this call in this startup code.
    178 
    179176        This function calls the main Lua script for our GUI.
    180177
     
    183180    void GUIManager::loadLuaCode()
    184181    {
    185         try
    186         {
    187             // set datapath for GUI data
    188             lua_pushfstring(this->scriptModule_->getLuaState(), Core::getMediaPathString().c_str());
    189             lua_setglobal(this->scriptModule_->getLuaState(), "datapath");
    190             // call main Lua script
    191             this->scriptModule_->executeScriptFile("loadGUI_3.lua", "GUI");
    192         }
    193         catch (CEGUI::Exception& ex)
    194         {
    195 #if CEGUI_VERSION_MINOR < 6
    196             throw GeneralException(ex.getMessage().c_str());
    197 #else
    198             throw GeneralException(ex.getMessage().c_str(), ex.getLine(),
    199                 ex.getFileName().c_str(), ex.getName().c_str());
    200 #endif
    201         }
     182        // set datapath for GUI data
     183        lua_pushfstring(this->scriptModule_->getLuaState(), Core::getMediaPathString().c_str());
     184        lua_setglobal(this->scriptModule_->getLuaState(), "datapath");
     185        // call main Lua script
     186        this->scriptModule_->executeScriptFile("loadGUI_3.lua", "GUI");
    202187    }
    203188
     
    216201        assert(guiSystem_);
    217202        guiSystem_->injectTimePulse(time.getDeltaTime());
    218     }
    219 
    220     /**
    221 
    222     */
    223     void GUIManager::getLevelList()
    224     {
    225         lua_State* L = this->scriptModule_->getLuaState();
    226         lua_newtable(L);
    227 
    228         std::vector<std::string> list = Loader::getLevelList();
    229 
    230         int j = 1;
    231         for (std::vector<std::string>::iterator i = list.begin(); i != list.end(); i++)
    232         {
    233             lua_pushnumber(L,j);
    234             lua_pushstring(L,i->c_str());
    235             lua_settable(L,-3);
    236             j++;
    237         }
    238         lua_setglobal(L, "levellist");
    239203    }
    240204
  • code/branches/resource/src/orxonox/gui/GUIManager.h

    r3338 r3339  
    4747#include "core/input/InputHandler.h"
    4848
    49 // tolua_begin
    5049namespace orxonox
    5150{
     
    6160        Those input events are then injected into CEGUI in Lua.
    6261    */
    63     class _OrxonoxExport GUIManager
    64 // tolua_end
    65         : public InputHandler
    66 // tolua_begin
     62    class _OrxonoxExport GUIManager : public InputHandler
    6763    {
    68 // tolua_end
    6964    public:
    7065        GUIManager(Ogre::RenderWindow* renderWindow);
     
    7873        void setCamera(Ogre::Camera* camera);
    7974
    80         static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
     75        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; }
    8176        static GUIManager* getInstancePtr() { return singletonRef_s; }
    8277
    83         void getLevelList(); //tolua_export
    84 
    8578    private:
    86         GUIManager(const GUIManager& instance);                 //!< private constructor (this is a singleton class)
     79        GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class)
    8780
    8881        void loadLuaCode();
     
    108101        static GUIManager*       singletonRef_s;    //!< Singleton reference to GUIManager
    109102
    110     }; // tolua_export
    111 } // tolua_export
     103    };
     104}
    112105
    113106#endif /* _GUIManager_H__ */
Note: See TracChangeset for help on using the changeset viewer.