Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6150


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:
26 edited
26 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2

  • code/branches/presentation2/data/defaultConfig/keybindings.ini

    r6149 r6150  
    2323KeyEnd=boost
    2424KeyEquals=
    25 KeyEscape="exit"
     25KeyEscape="keyESC"
    2626KeyF="scale -1 moveUpDown"
    2727KeyF1="OverlayGroup toggleVisibility Debug"
  • code/branches/presentation2/data/gui/layouts/MainMenu.layout

    r5781 r6150  
    11<?xml version="1.0" ?>
    22<GUILayout>
    3     <Window Type="TaharezLook/StaticImage" Name="orxonox/Background">
    4     <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/>
    5     <Property Name="Image" Value="set:MainMenuBackground image:Background"/>
    6     <Property Name="FrameEnabled" Value="set:true"/>
    7     <Property Name="BackgroundEnabled" Value="set:false"/>
    8  
     3    <Window Type="DefaultWindow" Name="orxonox/MainMenuRootWindow">
     4    <Property Name="InheritsAlpha" Value="false"/>
    95        <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton">
    106            <Property Name="UnifiedPosition" Value="{{0.11,0},{0.3,0}}"/>
  • code/branches/presentation2/data/gui/layouts/QuestGUI.layout

    r5781 r6150  
    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/presentation2/data/gui/scripts/InGameMenu.lua

    r6146 r6150  
    2525    orxonox.Game:getInstance():popState()
    2626    orxonox.Game:getInstance():requestState("mainmenu")
    27     orxonox.CommandExecutor:execute("showGUI MainMenu")
    2827    orxonox.CommandExecutor:execute("hideGUI InGameMenu")
    2928end
  • code/branches/presentation2/data/gui/scripts/InitialiseGUI.lua

    r5781 r6150  
    1414
    1515loadedGUIs = {}
     16cursorVisibility = {}
     17activeSheets = {}
     18nrOfActiveSheets = 0
     19root = nil
     20bShowsCursor = false
     21bHidePrevious = {}
     22
     23-- Require all tools
     24require("GUITools")
    1625
    1726-- loads the GUI with the specified filename
     
    2231    if loadedGui == nil then
    2332        loadedGuiNS = require(filename)
     33        if loadedGuiNS == nil then
     34            return
     35        end
    2436        loadedGui = loadedGuiNS:load()
    2537        loadedGUIs[filename] = loadedGui
     
    2739        if table.getn(loadedGUIs) == 1 then
    2840            current = loadedGUIs[1]
    29             showing = false
    3041        end
    3142        -- hide new GUI as we do not want to show it accidentially
     
    3546end
    3647
    37 function showGUI(filename, ptr)
    38     gui = showGUI(filename)
     48function showGUI(filename, hidePrevious, bCursorVisible, ptr)
     49    gui = showGUI(filename, hidePrevious, bCursorVisible)
    3950    gui.overlay = ptr
    4051end
     
    4253-- shows the specified and loads it if not loaded already
    4354-- 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)
    51     end
    52     current:show()
    53     showing = true
    54     return current
    55 end
    56 
    57 function toggleGUI()
    58     if showing == true then
    59         current:hide()
     55function showGUI(filename, hidePrevious, bCursorVisible)
     56    if bCursorVisible == nil then
     57        bCursorVisible = true
     58    end
     59
     60    if root == nil then
     61        setBackground("")
     62    end
     63
     64    local currentGUI = loadedGUIs[filename]
     65    if(currentGUI == nil) then
     66        currentGUI = loadGUI(filename)
     67    end
     68
     69    if(root:isChild(currentGUI.window)) then
     70        root:removeChildWindow(currentGUI.window)
     71    end
     72    root:addChildWindow(currentGUI.window)
     73
     74    if bCursorVisible then
     75        showCursor()
     76    else
     77        hideCursor()
     78    end
     79   
     80    if find( activeSheets, filename ) ~= nil then
     81        table.remove( activeSheets, find( activeSheets, filename ) )
     82        nrOfActiveSheets = nrOfActiveSheets - 1
     83    else
     84        if nrOfActiveSheets == 0 then
     85            orxonox.InputManager:getInstance():enterState("guiMouseOnly")
     86        end
     87    end
     88    nrOfActiveSheets = nrOfActiveSheets + 1
     89    table.insert(activeSheets, filename)
     90    activeSheets[nrOfActiveSheets] = filename
     91    bHidePrevious[filename]=hidePrevious
     92    cursorVisibility[filename] = bCursorVisible
     93   
     94    if hidePrevious == true then
     95        for i=1,nrOfActiveSheets-1 do
     96            loadedGUIs[ activeSheets[i] ]:hide()
     97        end
     98    end
     99    currentGUI:show()
     100    return currentGUI
     101end
     102
     103function hideCursor()
     104    if bShowsCursor==true then
     105        bShowsCursor=false
    60106        cursor:hide()
    61         showing = false
    62     else
    63         current:show()
     107    end
     108end
     109
     110function showCursor()
     111    if bShowsCursor==false then
     112        bShowsCursor=true
    64113        cursor:show()
    65         showing = true
    66     end
    67     return showing
    68 end
    69 
    70 function hideCursor()
    71     cursor:hide()
    72 end
    73 
    74 function showCursor()
    75     cursor:show()
     114    end
    76115end
    77116
    78117function hideGUI(filename)
    79     current = loadedGUIs[filename]
    80     if current ~= nil then
    81         current:hide()
    82         showing = false
    83     end
    84 end
     118    local currentGUI = loadedGUIs[filename]
     119    if currentGUI == nil then
     120        return
     121    end
     122    currentGUI:hide()
     123    if bHidePrevious[filename] == true then
     124        local i = nrOfActiveSheets-1
     125        while i>0 do
     126            loadedGUIs[ activeSheets[i] ]:show()
     127            if bHidePrevious[filename]==true then
     128                break
     129            else
     130                i=i-1
     131            end
     132        end
     133    end
     134    root:removeChildWindow(currentGUI.window)
     135    local i=1
     136    while activeSheets[i] do
     137        if activeSheets[i+1] == nil then
     138            if activeSheets[i-1] ~= nil then
     139                if cursorVisibility[ activeSheets[i-1] ] == true then
     140                    showCursor()
     141                else
     142                    hideCursor()
     143                end
     144            else
     145                hideCursor()
     146            end
     147        end
     148        if activeSheets[i] == filename then
     149            table.remove( activeSheets, i )
     150            nrOfActiveSheets = nrOfActiveSheets-1
     151        else
     152            i = i+1
     153        end
     154    end
     155    cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table
     156    bHidePrevious[filename] = nil
     157    if nrOfActiveSheets == 0 then
     158        orxonox.InputManager:getInstance():leaveState("guiMouseOnly")
     159        hideCursor()
     160    end
     161end
     162
     163function keyESC()
     164    if nrOfActiveSheets > 0 then
     165        orxonox.CommandExecutor:execute("hideGUI "..activeSheets[nrOfActiveSheets])
     166    else
     167        showGUI("InGameMenu")
     168    end
     169end
     170
     171function setBackground(filename)
     172    local newroot
     173    if root ~= nil then
     174        root:rename("oldRootWindow")
     175    end
     176    if filename ~= "" then
     177        newroot = winMgr:loadWindowLayout(filename .. ".layout")
     178        newroot:rename("AbsoluteRootWindow")
     179        system:setGUISheet(newroot)
     180    else
     181        newroot = winMgr:createWindow("DefaultWindow", "AbsoluteRootWindow")
     182        newroot:setProperty("Alpha", "0.0")
     183        newroot:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
     184        system:setGUISheet(newroot)
     185    end
     186    if root ~= nil then
     187        local child
     188        while root:getChildCount()~=0 do
     189            debug(root:getChildCount())
     190            child = root:getChildAtIdx(0)
     191            root:removeChildWindow(child)
     192            newroot:addChildWindow(child)
     193        end
     194        winMgr:destroyWindow(root)
     195    end
     196    newroot:show()
     197    root = newroot
     198end
     199
     200function find(table, value)
     201    local i=0
     202    while table[i] ~= nil do
     203        if table[i]==value then
     204            return i
     205        else
     206            i=i+1
     207        end
     208    end
     209    return nil
     210end
  • code/branches/presentation2/data/gui/scripts/MainMenu.lua

    r5781 r6150  
    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/presentation2/src/libraries/core/CMakeLists.txt

    r6105 r6150  
    8686  TOLUA_FILES
    8787    CommandExecutor.h
     88    Game.h
    8889    Loader.h
    8990    LuaState.h
     91    input/InputManager.h
    9092  DEFINE_SYMBOL
    9193    "CORE_SHARED_BUILD"
  • 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
  • code/branches/presentation2/src/libraries/core/GUIManager.h

    r5929 r6150  
    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 hidePrevious=false, bool showCursor=true);
     71        void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true);
     72        static void hideGUI(const std::string& name);
     73        void toggleIngameGUI();
     74        void keyESC();
     75        void setBackground(const std::string& name);
    7176
    7277        void setCamera(Ogre::Camera* camera);
     
    8287    private:
    8388        GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class)
     89
     90        std::set<std::string> showingGUIs_; //!< Keeps track of all the GUIs that are currently showing.
     91
     92        void executeCode(const std::string& str);
    8493
    8594        // keyHandler functions
     
    105114
    106115        static GUIManager*                   singletonPtr_s;    //!< Singleton reference to GUIManager
     116        bool                                 bShowIngameGUI_;
    107117
    108118    };
  • code/branches/presentation2/src/libraries/core/Game.cc

    r6121 r6150  
    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; }
     
    327331    }
    328332
     333    void Game::keyESC()
     334    {
     335        if( this->getState("mainMenu") && this->getState("mainMenu")->getActivity().active==true )
     336            this->stop();
     337        else
     338            GUIManager::getInstance().keyESC();
     339    }
     340
    329341    void Game::stop()
    330342    {
     
    557569
    558570        shared_ptr<GameState> state = this->getState(name);
    559         state->activate();
     571        state->activateInternal();
    560572        if (!this->loadedStates_.empty())
    561573            this->loadedStates_.back()->activity_.topState = false;
     
    576588            if (!this->loadedStates_.empty())
    577589                this->loadedStates_.back()->activity_.topState = true;
    578             state->deactivate();
     590            state->deactivateInternal();
    579591        }
    580592        catch (...)
  • code/branches/presentation2/src/libraries/core/Game.h

    r6121 r6150  
    5959#define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \
    6060    static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
    61 
     61// tolua_begin
    6262namespace orxonox
    6363{
     64// tolua_end
     65
    6466    //! Helper object required before GameStates are being constructed
    6567    struct GameStateInfo
     
    7779        You should only create this singleton once because it owns the Core class! (see remark there)
    7880    */
    79     class _CoreExport Game : public Singleton<Game>, public OrxonoxClass
    80     {
     81// tolua_begin
     82    class _CoreExport Game
     83// tolua_end
     84        : public Singleton<Game>, public OrxonoxClass
     85    { // tolua_export
    8186        friend class Singleton<Game>;
    8287        typedef std::vector<shared_ptr<GameState> > GameStateVector;
     
    95100        void run();
    96101        void stop();
    97 
    98         void requestState(const std::string& name);
    99         void requestStates(const std::string& names);
    100         void popState();
     102        void keyESC();
     103
     104        static Game& getInstance(){ return Singleton<Game>::getInstance(); } // tolua_export
     105
     106        void requestState(const std::string& name); //tolua_export
     107        void requestStates(const std::string& names); //tolua_export
     108        void popState(); //tolua_export
    101109
    102110        const Clock& getGameClock() { return *this->gameClock_; }
     
    188196        static std::map<std::string, GameStateInfo> gameStateDeclarations_s;
    189197        static Game* singletonPtr_s;        //!< Pointer to the Singleton
    190     };
     198    }; //tolua_export
    191199
    192200    template <class T>
     
    214222        return true;
    215223    }
    216 }
     224} //tolua_export
    217225
    218226#endif /* _Game_H__ */
  • code/branches/presentation2/src/libraries/core/GameState.cc

    r5738 r6150  
    8383        this->activity_.active = false;
    8484        this->activity_.deactivating = true;
    85         this->activate();
     85        this->deactivate();
    8686        this->activity_.deactivating = false;
    8787        this->activity_.suspended = false;
  • code/branches/presentation2/src/libraries/core/LuaState.cc

    r6105 r6150  
    116116    }
    117117
    118     void LuaState::includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo)
     118    void LuaState::includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
    119119    {
    120120        // Parse string with provided include parser (otherwise don't preparse at all)
     
    138138    }
    139139
    140     void LuaState::doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo)
     140    void LuaState::doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo)
    141141    {
    142142        // Save the oold source file info
     
    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/presentation2/src/libraries/core/LuaState.h

    r5781 r6150  
    5757
    5858        void doFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
    59         void doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>());
     59        void doString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
    6060
    6161        void includeFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
    62         void includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>());
     62        void includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
    6363
    6464        void luaPrint(const std::string& str); // tolua_export
     
    7171        void setIncludeParser(std::string (*function)(const std::string&)) { includeParseFunction_ = function; }
    7272        lua_State* getInternalLuaState() { return luaState_; }
     73
     74        void setDefaultResourceInfo(const shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; }
     75        const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }
    7376
    7477        static bool addToluaInterface(int (*function)(lua_State*), const std::string& name);
  • code/branches/presentation2/src/libraries/core/input/InputManager.h

    r6084 r6150  
    4141#include "InputState.h"
    4242
     43// tolua_begin
    4344namespace orxonox
    4445{
     
    6364          If the OIS::InputManager or the Keyboard fail, an exception is thrown.
    6465    */
    65     class _CoreExport InputManager : public Singleton<InputManager>, public WindowEventListener
    66     {
     66    class _CoreExport InputManager
     67// tolua_end
     68        : public Singleton<InputManager>, public WindowEventListener
     69    { // tolua_export
    6770        friend class Singleton<InputManager>;
    6871    public:
     
    139142            False if name was not found, true otherwise.
    140143        */
    141         bool enterState(const std::string& name);
     144        bool enterState(const std::string& name); // tolua_export
    142145        /**
    143146        @brief
     
    146149            False if name was not found, true otherwise.
    147150        */
    148         bool leaveState(const std::string& name);
     151        bool leaveState(const std::string& name); // tolua_export
    149152        /**
    150153        @brief
     
    167170        OIS::InputManager* getOISInputManager() { return this->oisInputManager_; }
    168171        std::pair<int, int> getMousePosition() const;
     172       
     173        static InputManager& getInstance() { return *singletonPtr_s; } // tolua_export
    169174
    170175    private: // functions
     
    207212
    208213        static InputManager*                singletonPtr_s;        //!< Pointer reference to the singleton
    209     };
    210 }
     214    }; // tolua_export
     215} // tolua_export
    211216
    212217#endif /* _InputManager_H__ */
  • code/branches/presentation2/src/modules/overlays/GUIOverlay.cc

    r5980 r6150  
    7373            out << reinterpret_cast<long>(this);
    7474            str = out.str();
    75             GUIManager::getInstance().executeCode("showCursor()");
    76             InputManager::getInstance().enterState("guiMouseOnly");
    77             GUIManager::getInstance().executeCode("showGUI(\"" + this->guiName_ + "\", " + str + ")");
     75            COUT(1) << "GUIManager ptr: " << str << std::endl;
     76            GUIManager::getInstance().showGUIExtra(this->guiName_, str);
    7877
    7978            COUT(3) << "Showing GUI " << this->guiName_ << std::endl;
     
    8180        else
    8281        {
    83             GUIManager::getInstance().executeCode("hideGUI(\"" + this->guiName_ + "\")");
    84             GUIManager::getInstance().executeCode("hideCursor()");
    85             InputManager::getInstance().leaveState("guiMouseOnly");
     82            GUIManager::hideGUI(this->guiName_);
    8683            COUT(3) << "Hiding GUI " << this->guiName_ << std::endl;
    8784        }
  • code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc

    r6108 r6150  
    4040#include "weaponsystem/WeaponSystem.h"
    4141#include "worldentities/WorldEntity.h"
     42#include "worldentities/pawns/Pawn.h"
    4243
    4344namespace orxonox
     
    104105    void HsW01::shot()
    105106    {
     107        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
    106108        Projectile* projectile = new Projectile(this);
    107109        Model* model = new Model(projectile);
     
    111113        model->setScale(5);
    112114
    113         this->computeMuzzleParameters();
     115        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
    114116        projectile->setOrientation(this->getMuzzleOrientation());
    115117        projectile->setPosition(this->getMuzzlePosition());
  • code/branches/presentation2/src/orxonox/gamestates/GSGraphics.cc

    r5929 r6150  
    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/presentation2/src/orxonox/gamestates/GSGraphics.h

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

    r5966 r6150  
    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::getInstance().showGUI("inGameTest");
    104             GUIManager::getInstance().executeCode("showCursor()");
    105             InputManager::getInstance().enterState("guiMouseOnly");
    106         }
    107         else
    108         {
    109             GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")");
    110             GUIManager::getInstance().executeCode("hideCursor()");
    111             InputManager::getInstance().leaveState("guiMouseOnly");
    11295        }
    11396    }
  • code/branches/presentation2/src/orxonox/gamestates/GSLevel.h

    r5929 r6150  
    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}
  • code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.cc

    r6117 r6150  
    8383    {
    8484        // show main menu
    85         GUIManager::getInstance().showGUI("MainMenu");
     85        GUIManager::getInstance().showGUI("MainMenu", true, false);
    8686        GUIManager::getInstance().setCamera(this->camera_);
     87        GUIManager::getInstance().setBackground("MainMenuBackground");
     88//         GUIManager::getInstance().setBackground("");
    8789        GraphicsManager::getInstance().setCamera(this->camera_);
    8890
     
    118120
    119121        GUIManager::getInstance().setCamera(0);
     122        GUIManager::getInstance().setBackground("");
     123        GUIManager::hideGUI("MainMenu");
    120124        GraphicsManager::getInstance().setCamera(0);
    121125    }
  • code/branches/presentation2/src/orxonox/pickup/PickupInventory.cc

    r5781 r6150  
    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/presentation2/src/orxonox/pickup/PickupSpawner.cc

    r5929 r6150  
    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    }
  • code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc

    r6112 r6150  
    196196    }
    197197
    198     void WeaponMode::computeMuzzleParameters()
     198    void WeaponMode::computeMuzzleParameters(const Vector3& target)
    199199    {
    200200        if (this->weapon_)
     
    204204            Pawn* pawn = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn();
    205205            Vector3 muzzleDirection;
    206             if ( pawn->getTarget() )
    207             {
    208                 muzzleDirection = pawn->getTarget()->getWorldPosition() - this->muzzlePosition_;
    209             }
    210             else
    211                 muzzleDirection = pawn->getAimPosition() - this->muzzlePosition_;
     206            muzzleDirection = target - this->muzzlePosition_;
    212207//             COUT(0) << "muzzleDirection " << muzzleDirection << endl;
    213208            this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation();
  • code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h

    r6108 r6150  
    109109                { return this->muzzleOffset_; }
    110110
    111             void computeMuzzleParameters();
     111            void computeMuzzleParameters(const Vector3& target);
    112112            const Vector3& getMuzzlePosition() const
    113113                { return this->muzzlePosition_; }
Note: See TracChangeset for help on using the changeset viewer.