Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6023


Ignore:
Timestamp:
Nov 4, 2009, 1:59:39 PM (15 years ago)
Author:
scheusso
Message:

clean cursor handling in GUIManager/lua code
change in output level of lua error messages

Location:
code/branches/ingamemenu
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ingamemenu/data/gui/scripts/InitialiseGUI.lua

    r6003 r6023  
    1414
    1515loadedGUIs = {}
    16 root = nil;
     16cursorVisibility = {}
     17activeSheets = {}
     18nrOfActiveSheets = 0
     19root = nil
     20bShowsCursor = false
    1721
    1822-- loads the GUI with the specified filename
     
    3640end
    3741
    38 function showGUI(filename, ptr)
    39     gui = showGUI(filename)
     42function showGUI(filename, bCursorVisible, ptr)
     43    gui = showGUI(filename, bCursorVisible)
    4044    gui.overlay = ptr
    4145end
     
    4347-- shows the specified and loads it if not loaded already
    4448-- be sure to set the global variable "filename" before calling this function
    45 function showGUI(filename)
     49function showGUI(filename, bCursorVisible)
     50--     bCursorVisibile=false
     51    if bCursorVisible == nil then
     52        cursorVisibility= true
     53    end
     54
    4655    if root == nil then
    4756        root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow")
     
    6170    root:addChildWindow(currentGUI.window)
    6271
     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   
    6383    currentGUI:show()
    6484    showing = true
     
    6787
    6888function hideCursor()
    69     cursor:hide()
     89    if bShowsCursor==true then
     90        bShowsCursor=false
     91        cursor:hide()
     92    end
    7093end
    7194
    7295function showCursor()
    73     cursor:show()
     96    if bShowsCursor==false then
     97        bShowsCursor=true
     98        cursor:show()
     99    end
    74100end
    75101
    76102function hideGUI(filename)
    77103    local currentGUI = loadedGUIs[filename]
    78     if currentGUI ~= nil then
    79         currentGUI:hide()
    80         root:removeChildWindow(currentGUI.window)
    81         showing = false
     104    if currentGUI == nil then
     105        return
    82106    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
    83131end
  • code/branches/ingamemenu/src/libraries/core/GUIManager.cc

    r6020 r6023  
    5050
    5151#include "util/Clock.h"
     52#include "util/Convert.h"
    5253#include "util/Debug.h"
    5354#include "util/Exception.h"
     
    8889    GUIManager* GUIManager::singletonPtr_s = 0;
    8990
    90     SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User);
     91    SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, true);
    9192    SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
    9293
     
    209210        For more details check out loadGUI_2.lua where the function presides.
    210211    */
    211     /*static*/ void GUIManager::showGUI(const std::string& name)
     212    /*static*/ void GUIManager::showGUI(const std::string& name, bool showCursor)
    212213    {
    213214        std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name);
     
    216217        if(GUIManager::getInstance().showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI.
    217218        {
    218             GUIManager::getInstance().executeCode("showCursor()");
     219//             GUIManager::getInstance().executeCode("showCursor()");
    219220            InputManager::getInstance().enterState("guiMouseOnly");
    220221        }
    221         GUIManager::getInstance().executeCode("showGUI(\"" + name + "\")");
     222        GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ")");
    222223    }
    223224
     
    226227        Hack-ish. Needed for GUIOverlay.
    227228    */
    228     void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr)
     229    void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor)
    229230    {
    230231        std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name);
     
    236237            InputManager::getInstance().enterState("guiMouseOnly");
    237238        }
    238         this->executeCode("showGUI(\"" + name + "\", " + ptr + ")");
     239        this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")");
    239240    }
    240241
     
    258259    }
    259260
    260     /*static*/ void GUIManager::hideCursor()
    261     {
    262         GUIManager::getInstance().executeCode("hideCursor()");
    263     }
    264 
    265261    void GUIManager::keyPressed(const KeyEvent& evt)
    266262    {
  • code/branches/ingamemenu/src/libraries/core/GUIManager.h

    r6020 r6023  
    6868        void update(const Clock& time);
    6969
    70         static void showGUI(const std::string& name);
    71         void showGUIExtra(const std::string& name, const std::string& ptr);
     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);
    7272        static void hideGUI(const std::string& name);
    73         static void hideCursor();
    7473
    7574        void setCamera(Ogre::Camera* camera);
  • code/branches/ingamemenu/src/libraries/core/LuaState.cc

    r5929 r6023  
    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/ingamemenu/src/orxonox/gamestates/GSMainMenu.cc

    r6020 r6023  
    8282    {
    8383        // show main menu
    84         GUIManager::showGUI("MainMenu");
    85         GUIManager::hideCursor();
     84        GUIManager::getInstance().showGUI("MainMenu", false);
    8685        GUIManager::getInstance().setCamera(this->camera_);
    8786        GraphicsManager::getInstance().setCamera(this->camera_);
     
    112111
    113112        InputManager::getInstance().leaveState("mainMenu");
    114         GUIManager::hideGUI("MainMenu");
    115113
    116114        GUIManager::getInstance().setCamera(0);
     115        GUIManager::hideGUI("MainMenu");
    117116        GraphicsManager::getInstance().setCamera(0);
    118117    }
Note: See TracChangeset for help on using the changeset viewer.