Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6024 for code/branches/menu


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:
17 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/branches/menu

  • code/branches/menu/data/gui/layouts/MainMenu.layout

    r5781 r6024  
    66    <Property Name="FrameEnabled" Value="set:true"/>
    77    <Property Name="BackgroundEnabled" Value="set:false"/>
     8    <Property Name="InheritsAlpha" Value="False" />
    89 
    910        <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton">
  • code/branches/menu/data/gui/layouts/QuestGUI.layout

    r5781 r6024  
    66    <Property Name="FrameEnabled" Value="set:true"/>
    77    <Property Name="BackgroundEnabled" Value="set:false"/>
     8    <Property Name="InheritsAlpha" Value="False" />
    89
    910        <Window Type="TaharezLook/Titlebar" Name="orxonox/QuestGUI/Title">
  • code/branches/menu/data/gui/scripts/InitialiseGUI.lua

    r5781 r6024  
    1414
    1515loadedGUIs = {}
     16cursorVisibility = {}
     17activeSheets = {}
     18nrOfActiveSheets = 0
     19root = nil
     20bShowsCursor = false
    1621
    1722-- loads the GUI with the specified filename
     
    3540end
    3641
    37 function showGUI(filename, ptr)
    38     gui = showGUI(filename)
     42function showGUI(filename, bCursorVisible, ptr)
     43    gui = showGUI(filename, bCursorVisible)
    3944    gui.overlay = ptr
    4045end
     
    4247-- shows the specified and loads it if not loaded already
    4348-- be sure to set the global variable "filename" before calling this function
    44 function showGUI(filename)
    45     if current == nil or current.filename ~= filename then
    46         current = loadedGUIs[filename]
    47         if current == nil then
    48             current = loadGUI(filename)
    49         end
    50         system:setGUISheet(current.window)
     49function showGUI(filename, bCursorVisible)
     50--     bCursorVisibile=false
     51    if bCursorVisible == nil then
     52        cursorVisibility= true
    5153    end
    52     current:show()
     54
     55    if root == nil then
     56        root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow")
     57        root:setProperty("Alpha", "0.0")
     58        root:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
     59        system:setGUISheet(root)
     60    end
     61
     62    local currentGUI = loadedGUIs[filename]
     63    if(currentGUI == nil) then
     64        currentGUI = loadGUI(filename)
     65    end
     66
     67    if(root:isChild(currentGUI.window)) then
     68        root:removeChildWindow(currentGUI.window)
     69    end
     70    root:addChildWindow(currentGUI.window)
     71
     72    if bCursorVisible then
     73        showCursor()
     74    else
     75        hideCursor()
     76    end
     77    cursorVisibility[filename]=bCursorVisible
     78   
     79    nrOfActiveSheets = nrOfActiveSheets + 1
     80    table.insert(activeSheets, filename)
     81    activeSheets[nrOfActiveSheets] = filename
     82   
     83    currentGUI:show()
    5384    showing = true
    54     return current
    55 end
    56 
    57 function toggleGUI()
    58     if showing == true then
    59         current:hide()
    60         cursor:hide()
    61         showing = false
    62     else
    63         current:show()
    64         cursor:show()
    65         showing = true
    66     end
    67     return showing
     85    return currentGUI
    6886end
    6987
    7088function hideCursor()
    71     cursor:hide()
     89    if bShowsCursor==true then
     90        bShowsCursor=false
     91        cursor:hide()
     92    end
    7293end
    7394
    7495function showCursor()
    75     cursor:show()
     96    if bShowsCursor==false then
     97        bShowsCursor=true
     98        cursor:show()
     99    end
    76100end
    77101
    78102function hideGUI(filename)
    79     current = loadedGUIs[filename]
    80     if current ~= nil then
    81         current:hide()
    82         showing = false
     103    local currentGUI = loadedGUIs[filename]
     104    if currentGUI == nil then
     105        return
    83106    end
     107    currentGUI:hide()
     108    root:removeChildWindow(currentGUI.window)
     109    showing = false
     110    i=1
     111    while activeSheets[i] do
     112        if activeSheets[i+1] == nil then
     113            if activeSheets[i-1] ~= nil then
     114                if cursorVisibility[ activeSheets[i-1] ] == true then
     115                    showCursor()
     116                else
     117                    hideCursor()
     118                end
     119            else
     120                hideCursor()
     121            end
     122        end
     123        if activeSheets[i] == filename then
     124            table.remove( activeSheets, i )
     125            nrOfActiveSheets = nrOfActiveSheets-1
     126        else
     127            i = i+1
     128        end
     129    end
     130    cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table
    84131end
  • code/branches/menu/data/gui/scripts/MainMenu.lua

    r5781 r6024  
    5050        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    5151        orxonox.CommandExecutor:execute("startGame")
    52         toggleGUI()
     52        hideGUI(P.filename)
    5353    end
    5454end
     
    5959        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    6060        orxonox.CommandExecutor:execute("startServer")
    61         toggleGUI()
     61        hideGUI(P.filename)
    6262    end
    6363end
     
    6868        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    6969        orxonox.CommandExecutor:execute("startDedicated")
    70         toggleGUI()
     70        hideGUI(P.filename)
    7171    end
    7272end
     
    7777        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    7878        orxonox.CommandExecutor:execute("startClient")
    79         toggleGUI()
     79        hideGUI(P.filename)
     80
    8081    end
    8182end
  • code/branches/menu/src/libraries/core/CMakeLists.txt

    r5929 r6024  
    8585  TOLUA_FILES
    8686    CommandExecutor.h
     87    Game.h
    8788    Loader.h
    8889    LuaState.h
  • 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
  • code/branches/menu/src/libraries/core/GUIManager.h

    r5929 r6024  
    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, bool showCursor=true);
     71        void showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor=true);
     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
  • code/branches/menu/src/libraries/core/Game.h

    r5929 r6024  
    5858#define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \
    5959    static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
    60 
     60// tolua_begin
    6161namespace orxonox
    6262{
     63// tolua_end
    6364    class GameConfiguration;
    6465
     
    7879        You should only create this singleton once because it owns the Core class! (see remark there)
    7980    */
    80     class _CoreExport Game : public Singleton<Game>
     81// tolua_begin
     82    class _CoreExport Game
     83        : public Singleton<Game>
    8184    {
     85// tolua_end
    8286        friend class Singleton<Game>;
    8387        typedef std::vector<shared_ptr<GameState> > GameStateVector;
     
    9599        void stop();
    96100
    97         void requestState(const std::string& name);
    98         void requestStates(const std::string& names);
    99         void popState();
     101        static Game& getInstance(){ return Singleton<Game>::getInstance(); } // tolua_export
     102
     103        void requestState(const std::string& name); //tolua_export
     104        void requestStates(const std::string& names); //tolua_export
     105        void popState(); //tolua_export
    100106
    101107        const Clock& getGameClock() { return *this->gameClock_; }
     
    183189        static std::map<std::string, GameStateInfo> gameStateDeclarations_s;
    184190        static Game* singletonPtr_s;        //!< Pointer to the Singleton
    185     };
     191    }; //tolua_export
    186192
    187193    template <class T>
     
    209215        return true;
    210216    }
    211 }
     217} //tolua_export
    212218
    213219#endif /* _Game_H__ */
  • code/branches/menu/src/libraries/core/LuaState.cc

    r5929 r6024  
    164164            if (sourceFileInfo != NULL)
    165165                origin = " originating from " + sourceFileInfo_->filename;
    166             COUT(2) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
     166            COUT(1) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
    167167            // return value is nil
    168168            lua_pushnil(luaState_);
  • code/branches/menu/src/modules/overlays/GUIOverlay.cc

    r5781 r6024  
    7272            out << reinterpret_cast<long>(this);
    7373            str = out.str();
    74             GUIManager::getInstance().executeCode("showCursor()");
    75             InputManager::getInstance().enterState("guiMouseOnly");
    76             GUIManager::getInstance().executeCode("showGUI(\"" + this->guiName_ + "\", " + str + ")");
     74            COUT(1) << "GUIManager ptr: " << str << std::endl;
     75            GUIManager::getInstance().showGUIExtra(this->guiName_, str);
    7776        }
    7877        else
    7978        {
    80             GUIManager::getInstance().executeCode("hideGUI(\"" + this->guiName_ + "\")");
    81             GUIManager::getInstance().executeCode("hideCursor()");
    82             InputManager::getInstance().leaveState("guiMouseOnly");
     79            GUIManager::hideGUI(this->guiName_);
    8380        }
    8481    }
  • code/branches/menu/src/orxonox/gamestates/GSGraphics.cc

    r5929 r6024  
    6464    void GSGraphics::activate()
    6565    {
    66         // add console command to toggle GUI
    67         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI"));
     66       
    6867    }
    6968
     
    7877    }
    7978
    80     /**
    81     @brief
    82         Toggles the visibility of the current GUI
    83 
    84         This function just executes a Lua function in the main script of the GUI by accessing the GUIManager.
    85         For more details on this function check out the Lua code.
    86     */
    87     void GSGraphics::toggleGUI()
    88     {
    89         GUIManager::getInstance().executeCode("toggleGUI()");
    90     }
    91 
    9279    void GSGraphics::update(const Clock& time)
    9380    {
  • code/branches/menu/src/orxonox/gamestates/GSGraphics.h

    r5929 r6024  
    5757        void update(const Clock& time);
    5858
    59         void toggleGUI();
    60 
    6159    private:
    6260    };
  • code/branches/menu/src/orxonox/gamestates/GSLevel.cc

    r5929 r6024  
    101101        if (show)
    102102        {
    103             GUIManager::getInstance().showGUI("inGameTest");
    104             GUIManager::getInstance().executeCode("showCursor()");
    105             InputManager::getInstance().enterState("guiMouseOnly");
     103            GUIManager::showGUI("inGameTest");
    106104        }
    107105        else
    108106        {
    109             GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")");
    110             GUIManager::getInstance().executeCode("hideCursor()");
    111             InputManager::getInstance().leaveState("guiMouseOnly");
     107            GUIManager::hideGUI("inGameTest");
    112108        }
    113109    }
  • code/branches/menu/src/orxonox/gamestates/GSMainMenu.cc

    r5929 r6024  
    8282    {
    8383        // show main menu
    84         GUIManager::getInstance().showGUI("MainMenu");
     84        GUIManager::getInstance().showGUI("MainMenu", false);
    8585        GUIManager::getInstance().setCamera(this->camera_);
    8686        GraphicsManager::getInstance().setCamera(this->camera_);
     
    113113
    114114        GUIManager::getInstance().setCamera(0);
     115        GUIManager::hideGUI("MainMenu");
    115116        GraphicsManager::getInstance().setCamera(0);
    116117    }
  • code/branches/menu/src/orxonox/pickup/PickupInventory.cc

    r5781 r6024  
    8686    {
    8787        if(PickupInventory::getSingleton()->isVisible()) {
    88             GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")");
    89             GUIManager::getInstance().executeCode("hideCursor()");
    90             InputManager::getInstance().leaveState("guiMouseOnly");
    91         }
    92         else
    93         {
    94             GUIManager::getInstance().showGUI("PickupInventory");
    95             GUIManager::getInstance().executeCode("showCursor()");
    96             InputManager::getInstance().enterState("guiMouseOnly");
     88            GUIManager::hideGUI("PickupInventory");
     89        }
     90        else
     91        {
     92            GUIManager::showGUI("PickupInventory");
    9793        }
    9894        PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible());
  • code/branches/menu/src/orxonox/pickup/PickupSpawner.cc

    r5929 r6024  
    9696        //  & load the GUI itself too, along with some empty windows
    9797        //   = even less delays
    98         GUIManager::getInstance().showGUI("PickupInventory");
    99         GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")");
     98        GUIManager::showGUI("PickupInventory");
     99        GUIManager::hideGUI("PickupInventory");
    100100        PickupInventory::getSingleton();
    101101    }
Note: See TracChangeset for help on using the changeset viewer.