Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 4, 2009, 2:14:53 PM (15 years ago)
Author:
scheusso
Message:

merged ingamemenu branch to menu branch

Location:
code/branches/menu
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/menu

  • code/branches/menu/src/libraries/core/GUIManager.cc

    r5929 r6024  
    5050
    5151#include "util/Clock.h"
     52#include "util/Convert.h"
    5253#include "util/Debug.h"
    5354#include "util/Exception.h"
    5455#include "util/OrxAssert.h"
     56#include "ConsoleCommand.h"
    5557#include "Core.h"
     58#include "input/InputManager.h"
    5659#include "LuaState.h"
    5760#include "PathConfig.h"
     
    8689    GUIManager* GUIManager::singletonPtr_s = 0;
    8790
     91    SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, true);
     92    SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
     93
    8894    /**
    8995    @brief
     
    204210        For more details check out loadGUI_2.lua where the function presides.
    205211    */
    206     void GUIManager::showGUI(const std::string& name)
    207     {
    208         this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_);
     212    /*static*/ void GUIManager::showGUI(const std::string& name, bool showCursor)
     213    {
     214        std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name);
     215        if(result.second == false) //!< GUI already showing.
     216            return;
     217        if(GUIManager::getInstance().showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI.
     218        {
     219//             GUIManager::getInstance().executeCode("showCursor()");
     220            InputManager::getInstance().enterState("guiMouseOnly");
     221        }
     222        GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ")");
     223    }
     224
     225    /**
     226    @brief
     227        Hack-ish. Needed for GUIOverlay.
     228    */
     229    void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor)
     230    {
     231        std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name);
     232        if(result.second == false) //!< GUI already showing.
     233            return;
     234        if(this->showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI.
     235        {
     236            this->executeCode("showCursor()");
     237            InputManager::getInstance().enterState("guiMouseOnly");
     238        }
     239        this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")");
     240    }
     241
     242    /**
     243    @brief
     244        Hides specified GUI.
     245    @param name
     246        The name of the GUI.
     247    */
     248    /*static*/ void GUIManager::hideGUI(const std::string& name)
     249    {
     250        bool present = GUIManager::getInstance().showingGUIs_.erase(name);
     251        if(!present) //!< If there was nothing to erase.
     252            return;
     253        GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")");
     254        if(GUIManager::getInstance().showingGUIs_.size() == 0)
     255        {
     256            GUIManager::getInstance().executeCode("hideCursor()");
     257            InputManager::getInstance().leaveState("guiMouseOnly");
     258        }
    209259    }
    210260
Note: See TracChangeset for help on using the changeset viewer.