Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6048


Ignore:
Timestamp:
Nov 12, 2009, 11:32:41 AM (14 years ago)
Author:
scheusso
Message:

ESC handling in ingame menu: if theres already an opened GUI sheet then hide it, if not open the ingame menu
in mainmenu everything should remain the same

Location:
code/branches/menu
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/menu/data/defaultConfig/keybindings.ini

    r5929 r6048  
    2323KeyEnd=boost
    2424KeyEquals=
    25 KeyEscape="exit"
     25KeyEscape="toggleIngameGUI"
    2626KeyF="scale -1 moveUpDown"
    2727KeyF1="OverlayGroup toggleVisibility Debug"
  • code/branches/menu/data/gui/scripts/InGameMenu.lua

    r6024 r6048  
    1818-- events for ingamemenu
    1919function P.button_quit_clicked(e)
    20     orxonox.CommandExecutor:execute("hideGUI InGameMenu")
    21     orxonox.CommandExecutor:execute("exit")
     20    openDecisionPopup( "Do you really want to quit the game?", InGameMenu.callback )
    2221end
    2322
     
    3433end
    3534
     35function P.callback(doExit)
     36    if doExit then
     37        orxonox.CommandExecutor:execute("hideGUI InGameMenu")
     38        orxonox.CommandExecutor:execute("exit")
     39    end
     40end
     41
    3642return P
    3743
  • code/branches/menu/data/gui/scripts/InitialiseGUI.lua

    r6036 r6048  
    2121bHidePrevious = {}
    2222
     23-- Require all tools
     24require("GUITools")
     25
    2326-- loads the GUI with the specified filename
    2427-- be sure to set the global variable "filename" before calling this function
     
    2831    if loadedGui == nil then
    2932        loadedGuiNS = require(filename)
     33        if loadedGuiNS == nil then
     34            return
     35        end
    3036        loadedGui = loadedGuiNS:load()
    3137        loadedGUIs[filename] = loadedGui
     
    147153end
    148154
     155function keyESC()
     156    orxonox.CommandExecutor:execute("hideGUI "..activeSheets[nrOfActiveSheets])
     157end
     158
    149159function setBackground(filename)
    150160    local newroot
  • code/branches/menu/src/libraries/core/GUIManager.cc

    r6036 r6048  
    108108        , resourceProvider_(0)
    109109        , camera_(NULL)
     110        , bShowIngameGUI_(false)
    110111    {
    111112        using namespace CEGUI;
     
    251252        }
    252253    }
     254
     255    void GUIManager::toggleIngameGUI()
     256    {
     257        if ( this->bShowIngameGUI_==false )
     258        {
     259            GUIManager::showGUI("InGameMenu");
     260            this->bShowIngameGUI_ = true;
     261        }
     262        else
     263        {
     264            GUIManager::hideGUI("InGameMenu");
     265            this->bShowIngameGUI_ = false;
     266        }
     267    }
    253268   
    254     void GUIManager::setToggleMode(const bool& mode)
    255     {
    256         this->bToggleMode_ = mode;
    257         this->executeCode("setToggleMode(" + multi_cast<std::string>(mode) + ")");
     269    void GUIManager::keyESC()
     270    {
     271        if( this->showingGUIs_.size() == 0 )
     272            this->showGUI("InGameMenu");
     273        else
     274            this->executeCode("keyESC()");
    258275    }
    259276   
  • code/branches/menu/src/libraries/core/GUIManager.h

    r6032 r6048  
    7171        void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true);
    7272        static void hideGUI(const std::string& name);
    73         void setToggleMode(const bool& mode);
     73        void toggleIngameGUI();
     74        void keyESC();
    7475        void setBackground(const std::string& name);
    7576
     
    113114
    114115        static GUIManager*                   singletonPtr_s;    //!< Singleton reference to GUIManager
    115         bool                                 bToggleMode_;
     116        bool                                 bShowIngameGUI_;
    116117
    117118    };
  • code/branches/menu/src/libraries/core/Game.cc

    r6047 r6048  
    5151#include "GameMode.h"
    5252#include "GameState.h"
     53#include "GUIManager.h"
    5354
    5455namespace orxonox
     
    5758        { Game::getInstance().stop(); }
    5859    SetConsoleCommandShortcutExternAlias(stop_game, "exit");
     60    static void key_esc()
     61        { Game::getInstance().keyESC(); }
     62    SetConsoleCommandShortcutExternAlias(key_esc, "keyESC");
    5963    static void printFPS()
    6064        { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }
     
    354358    }
    355359
     360    void Game::keyESC()
     361    {
     362        if( this->getState("mainMenu") && this->getState("mainMenu")->getActivity().active==true )
     363            this->stop();
     364        else
     365            GUIManager::getInstance().keyESC();
     366    }
     367
    356368    void Game::stop()
    357369    {
  • code/branches/menu/src/libraries/core/Game.h

    r6024 r6048  
    9898        void run();
    9999        void stop();
     100        void keyESC();
    100101
    101102        static Game& getInstance(){ return Singleton<Game>::getInstance(); } // tolua_export
  • code/branches/menu/src/orxonox/gamestates/GSLevel.cc

    r6024 r6048  
    5656        , guiKeysOnlyInputState_(0)
    5757        , startFile_(0)
     58        , bShowIngameGUI_(false)
    5859    {
    5960    }
     
    7879            guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly");
    7980            guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
    80 
    81             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSLevel::showIngameGUI, this), "showIngameGUI"));
    8281        }
    8382
     
    9493            // connect the HumanPlayer to the game
    9594            PlayerManager::getInstance().clientConnected(0);
    96         }
    97     }
    98 
    99     void GSLevel::showIngameGUI(bool show)
    100     {
    101         if (show)
    102         {
    103             GUIManager::showGUI("inGameTest");
    104         }
    105         else
    106         {
    107             GUIManager::hideGUI("inGameTest");
    10895        }
    10996    }
  • code/branches/menu/src/orxonox/gamestates/GSLevel.h

    r5929 r6048  
    5252        void loadLevel();
    5353        void unloadLevel();
    54         void showIngameGUI(bool show);
    5554
    5655        InputState*              gameInputState_;          //!< input state for normal ingame playing
     
    6059        XMLFile* startFile_;
    6160        std::set<BaseObject*> staticObjects_;
     61        bool bShowIngameGUI_;
    6262    };
    6363}
Note: See TracChangeset for help on using the changeset viewer.