Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 16, 2009, 11:47:06 AM (15 years ago)
Author:
bknecht
Message:

Ugly hack to use GUI ingame. Hack itself needs improvement AND of course it should be hackfree!

Location:
code/trunk/src/orxonox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/gamestates/GSGUI.cc

    r2087 r2790  
    5151
    5252        // show main menu
     53        guiManager_->loadScene("MainMenu");
    5354        guiManager_->showGUI("MainMenu", 0);
    5455        getParent()->getViewport()->setCamera(guiManager_->getCamera());
  • code/trunk/src/orxonox/gamestates/GSLevel.h

    r2710 r2790  
    4343        ~GSLevel();
    4444
     45        // was private before (is public now because of console command in GSStandalone)
     46        void setConfigValues();
     47
    4548    protected:
    4649        void enter(Ogre::Viewport* viewport);
     
    7174        ConsoleCommand*       ccTkeybind_;
    7275
    73     private:
    74         void setConfigValues();
    75 
    7676    };
    7777}
  • code/trunk/src/orxonox/gamestates/GSStandalone.cc

    r2087 r2790  
    3030#include "GSStandalone.h"
    3131
     32#include <OgreViewport.h>
     33#include <OgreCamera.h>
    3234#include "core/Core.h"
     35#include "core/ConsoleCommand.h"
     36#include "gui/GUIManager.h"
    3337
    3438namespace orxonox
    3539{
     40    SetConsoleCommand(GSStandalone, showGUI, true).setAsInputCommand();
     41
     42    bool GSStandalone::guiShowing_s = false;
     43
    3644    GSStandalone::GSStandalone()
    3745        : GameState<GSGraphics>("standalone")
     
    4351    }
    4452
     53    void GSStandalone::showGUI()
     54    {
     55        GSStandalone::guiShowing_s = true;
     56    }
     57
    4558    void GSStandalone::enter()
    4659    {
     
    4861
    4962        GSLevel::enter(this->getParent()->getViewport());
     63
     64        guiManager_ = getParent()->getGUIManager();
     65        // not sure if necessary
     66        // guiManager_->loadScene("IngameMenu");
    5067    }
    5168
     
    5976    void GSStandalone::ticked(const Clock& time)
    6077    {
     78        if (guiShowing_s)
     79        {
     80            guiManager_->showGUI("IngameMenu", this->getParent()->getViewport()->getCamera()->getSceneManager());
     81        }
     82        else
     83        {
     84            if (guiManager_)
     85                guiManager_->hideGUI();
     86        }
     87        // tick CEGUI
     88        guiManager_->tick(time.getDeltaTime());
     89
    6190        GSLevel::ticked(time);
    6291        this->tickChild(time);
  • code/trunk/src/orxonox/gamestates/GSStandalone.h

    r2087 r2790  
    4141        GSStandalone();
    4242        ~GSStandalone();
     43        static void showGUI();
    4344
    4445    private:
     
    4647        void leave();
    4748        void ticked(const Clock& time);
     49
     50        GUIManager*     guiManager_;
     51        static bool     guiShowing_s;
    4852    };
    4953}
  • code/trunk/src/orxonox/gui/GUIManager.cc

    r2759 r2790  
    172172
    173173                // load the background scene
    174                 loadScenes();
     174                //loadScenes();
    175175                //CEGUI::KeyEventArgs e;
    176176                //e.codepoint
     
    190190
    191191        return true;
     192    }
     193
     194    void GUIManager::loadScene(const std::string& name)
     195    {
     196        if (name.compare("IngameMenu") == 0)
     197        {
     198            try
     199            {
     200                /*this->scriptModule_ = new LuaScriptModule();
     201                this->luaState_ = this->scriptModule_->getLuaState();
     202                this->guiSystem_ = new System(this->guiRenderer_, this->resourceProvider_, 0, this->scriptModule_);
     203                tolua_Core_open(this->scriptModule_->getLuaState());
     204                tolua_Orxonox_open(this->scriptModule_->getLuaState());
     205                */
     206                this->scriptModule_->executeScriptFile("ingameGUI.lua", "GUI");
     207            }
     208            catch (CEGUI::Exception& ex)
     209            {
     210#if CEGUI_VERSION_MINOR < 6
     211                throw GeneralException(ex.getMessage().c_str());
     212#else
     213                throw GeneralException(ex.getMessage().c_str(), ex.getLine(),
     214                                       ex.getFileName().c_str(), ex.getName().c_str());
     215#endif
     216            }
     217        }
     218        else
     219        {
     220            loadScenes();
     221        }
    192222    }
    193223
     
    241271            try
    242272            {
     273                COUT (0) << "************* sceneManager: " << sceneManager << std::endl;
    243274                if (!sceneManager)
    244275                {
     
    287318            return;
    288319        //this->viewport_->setCamera(0);
    289         this->guiRenderer_->setTargetSceneManager(0);
     320        // has no effect since you cannot assign 0 as SceneManager
     321        //this->guiRenderer_->setTargetSceneManager(0);
    290322        this->state_ = Ready;
    291323        InputManager::getInstance().requestLeaveState("gui");
  • code/trunk/src/orxonox/gui/GUIManager.h

    r2710 r2790  
    7070
    7171        bool initialise(Ogre::RenderWindow* renderWindow);
     72        void loadScene(const std::string& name);
    7273        void tick(float dt)
    7374        {
Note: See TracChangeset for help on using the changeset viewer.