Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 25, 2009, 4:52:37 PM (15 years ago)
Author:
scheusso
Message:

merged menu branch to presentation2 branch with some additional fixes and features ;)

Location:
code/branches/presentation2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2

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

    r6105 r6150  
    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"
     57#include "Core.h"
     58#include "input/InputManager.h"
    5559#include "LuaState.h"
    5660#include "PathConfig.h"
     
    8589    GUIManager* GUIManager::singletonPtr_s = 0;
    8690
     91    SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true);
     92    SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
     93
    8794    /**
    8895    @brief
     
    101108        , resourceProvider_(0)
    102109        , camera_(NULL)
     110        , bShowIngameGUI_(false)
    103111    {
    104112        using namespace CEGUI;
     
    113121        // setup scripting
    114122        luaState_.reset(new LuaState());
     123        rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua", "GUI");
     124        // This is necessary to ensure that input events also use the right resource info when triggering lua functions
     125        luaState_->setDefaultResourceInfo(this->rootFileInfo_);
    115126        scriptModule_.reset(new LuaScriptModule(luaState_->getInternalLuaState()));
    116127
     
    127138
    128139        // Initialise the basic Lua code
    129         rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua", "GUI");
    130140        this->luaState_->doFile("InitialiseGUI.lua", "GUI", false);
    131141
     
    203213        For more details check out loadGUI_2.lua where the function presides.
    204214    */
    205     void GUIManager::showGUI(const std::string& name)
    206     {
    207         this->luaState_->doString("showGUI(\"" + name + "\")", rootFileInfo_);
     215    /*static*/ void GUIManager::showGUI(const std::string& name, bool hidePrevious, bool showCursor)
     216    {
     217        std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name);
     218        if(GUIManager::getInstance().showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI.
     219        {
     220//             InputManager::getInstance().enterState("guiMouseOnly");
     221        }
     222        GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + 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 hidePrevious, bool showCursor)
     230    {
     231        std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name);
     232        if(this->showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI.
     233        {
     234//             this->executeCode("showCursor()");
     235//             InputManager::getInstance().enterState("guiMouseOnly");
     236        }
     237        this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")");
     238    }
     239
     240    /**
     241    @brief
     242        Hides specified GUI.
     243    @param name
     244        The name of the GUI.
     245    */
     246    /*static*/ void GUIManager::hideGUI(const std::string& name)
     247    {
     248        GUIManager::getInstance().showingGUIs_.erase(name);
     249        GUIManager::getInstance().executeCode("hideGUI(\"" + name + "\")");
     250        if(GUIManager::getInstance().showingGUIs_.size() == 0)
     251        {
     252//             GUIManager::getInstance().executeCode("hideCursor()");
     253//             InputManager::getInstance().leaveState("guiMouseOnly");
     254        }
     255    }
     256
     257    void GUIManager::toggleIngameGUI()
     258    {
     259        if ( this->bShowIngameGUI_==false )
     260        {
     261            GUIManager::showGUI("InGameMenu");
     262            this->bShowIngameGUI_ = true;
     263        }
     264        else
     265        {
     266            GUIManager::hideGUI("InGameMenu");
     267            this->bShowIngameGUI_ = false;
     268        }
     269    }
     270   
     271    void GUIManager::keyESC()
     272    {
     273        this->executeCode("keyESC()");
     274    }
     275   
     276    void GUIManager::setBackground(const std::string& name)
     277    {
     278        this->executeCode("setBackground(\"" + name + "\")");
    208279    }
    209280
Note: See TracChangeset for help on using the changeset viewer.