Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 28, 2009, 5:58:11 PM (15 years ago)
Author:
dafrick
Message:

Implemented support for multiple simultaniously showing GUIs. What happens now, in essence, is, that every root-window of a gui, that is to be showed, is attached to a global root window, which is always displayed and therefore needs to be fully transparent (alpha = 0.0). To not inherit the transparency (and thus be fully transparent as well) each root-window of a gui must (or should) set the property 'InheritsAlpha' to false.

Location:
code/branches/ingamemenu/src/libraries/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ingamemenu/src/libraries/core/GUIManager.cc

    r5929 r6003  
    5353#include "util/Exception.h"
    5454#include "util/OrxAssert.h"
     55#include "ConsoleCommand.h"
    5556#include "Core.h"
     57#include "input/InputManager.h"
    5658#include "LuaState.h"
    5759#include "PathConfig.h"
     
    8688    GUIManager* GUIManager::singletonPtr_s = 0;
    8789
     90    SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User);
     91    SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
     92
    8893    /**
    8994    @brief
     
    204209        For more details check out loadGUI_2.lua where the function presides.
    205210    */
    206     void GUIManager::showGUI(const std::string& name)
    207     {
    208         this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_);
     211    /*static*/ void GUIManager::showGUI(const std::string& name)
     212    {
     213        std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name);
     214        if(result.second == false) //!< GUI already showing.
     215            return;
     216        if(GUIManager::getInstance().showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI.
     217        {
     218            GUIManager::getInstance().executeCode("showCursor()");
     219            InputManager::getInstance().enterState("guiMouseOnly");
     220        }
     221        GUIManager::getInstance().executeCode("showGUI(\"" + name + "\")");
     222    }
     223
     224    /**
     225    @brief
     226        Hack-ish. Needed for GUIOverlay.
     227    */
     228    void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr)
     229    {
     230        std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name);
     231        if(result.second == false) //!< GUI already showing.
     232            return;
     233        if(this->showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI.
     234        {
     235            this->executeCode("showCursor()");
     236            InputManager::getInstance().enterState("guiMouseOnly");
     237        }
     238        this->executeCode("showGUI(\"" + name + "\", " + ptr + ")");
     239    }
     240
     241    /**
     242    @brief
     243        Hides specified GUI.
     244    @param name
     245        The name of the GUI.
     246    */
     247    /*static*/ void GUIManager::hideGUI(const std::string& name)
     248    {
     249        bool present = GUIManager::getInstance().showingGUIs_.erase(name);
     250        if(!present) //!< If there was nothing to erase.
     251            return;
     252        GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")");
     253        if(GUIManager::getInstance().showingGUIs_.size() == 0)
     254        {
     255            GUIManager::getInstance().executeCode("hideCursor()");
     256            InputManager::getInstance().leaveState("guiMouseOnly");
     257        }
    209258    }
    210259
  • code/branches/ingamemenu/src/libraries/core/GUIManager.h

    r5929 r6003  
    3434
    3535#include <map>
     36#include <set>
    3637#include <string>
    3738#include <CEGUIForwardRefs.h>
     
    6566        ~GUIManager();
    6667
    67         void update(const Clock& time);
     68        void update(const Clock& time); 
    6869
    69         void showGUI(const std::string& name);
    70         void executeCode(const std::string& str);
     70        static void showGUI(const std::string& name);
     71        void showGUIExtra(const std::string& name, const std::string& ptr);
     72        static void hideGUI(const std::string& name);
    7173
    7274        void setCamera(Ogre::Camera* camera);
     
    8284    private:
    8385        GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class)
     86
     87        std::set<std::string> showingGUIs_; //!< Keeps track of all the GUIs that are currently showing.
     88
     89        void executeCode(const std::string& str);
    8490
    8591        // keyHandler functions
Note: See TracChangeset for help on using the changeset viewer.