Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6032


Ignore:
Timestamp:
Nov 4, 2009, 5:30:38 PM (14 years ago)
Author:
scheusso
Message:

partially working hiding

Location:
code/branches/menu
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/menu/data/gui/layouts/MainMenu.layout

    r6024 r6032  
    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     <Property Name="InheritsAlpha" Value="False" />
    9  
     3    <Window Type="DefaultWindow" Name="orxonox/MainMenuRootWindow">
     4    <Property Name="InheritsAlpha" Value="false"/>
    105        <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton">
    116            <Property Name="UnifiedPosition" Value="{{0.11,0},{0.3,0}}"/>
  • code/branches/menu/data/gui/scripts/InitialiseGUI.lua

    r6024 r6032  
    1919root = nil
    2020bShowsCursor = false
     21bHidePrevious = {}
    2122
    2223-- loads the GUI with the specified filename
     
    3233        if table.getn(loadedGUIs) == 1 then
    3334            current = loadedGUIs[1]
    34             showing = false
    3535        end
    3636        -- hide new GUI as we do not want to show it accidentially
     
    4040end
    4141
    42 function showGUI(filename, bCursorVisible, ptr)
    43     gui = showGUI(filename, bCursorVisible)
     42function showGUI(filename, hidePrevious, bCursorVisible, ptr)
     43    gui = showGUI(filename, hidePrevious, bCursorVisible)
    4444    gui.overlay = ptr
    4545end
     
    4747-- shows the specified and loads it if not loaded already
    4848-- be sure to set the global variable "filename" before calling this function
    49 function showGUI(filename, bCursorVisible)
    50 --     bCursorVisibile=false
     49function showGUI(filename, hidePrevious, bCursorVisible)
    5150    if bCursorVisible == nil then
    52         cursorVisibility= true
     51        bCursorVisible = true
    5352    end
    5453
    5554    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)
     55        setBackground("")
    6056    end
    6157
     
    6561    end
    6662
     63    debug("test")
     64    debug(currentGUI.window:getName())
     65    debug(root:isChild(currentGUI.window))
    6766    if(root:isChild(currentGUI.window)) then
     67        debug("removing window")
    6868        root:removeChildWindow(currentGUI.window)
    6969    end
     
    7575        hideCursor()
    7676    end
    77     cursorVisibility[filename]=bCursorVisible
    7877   
     78    if find( activeSheets, filename ) ~= nil then
     79        table.remove( activeSheets, find( activeSheets, filename ) )
     80        nrOfActiveSheets = nrOfActiveSheets - 1
     81    end
    7982    nrOfActiveSheets = nrOfActiveSheets + 1
    8083    table.insert(activeSheets, filename)
    8184    activeSheets[nrOfActiveSheets] = filename
     85    bHidePrevious[filename]=hidePrevious
     86    cursorVisibility[filename] = bCursorVisible
    8287   
     88    if hidePrevious == true then
     89        for i=1,nrOfActiveSheets-1 do
     90            loadedGUIs[ activeSheets[i] ]:hide()
     91        end
     92    end
    8393    currentGUI:show()
    84     showing = true
    8594    return currentGUI
    8695end
     
    106115    end
    107116    currentGUI:hide()
     117    if bHidePrevious[filename] == true then
     118        local i = nrOfActiveSheets-1
     119        while i>0 do
     120            loadedGUIs[ activeSheets[i] ]:show()
     121            if bHidePrevious[filename]==true then
     122                break
     123            else
     124                i=i-1
     125            end
     126        end
     127    end
    108128    root:removeChildWindow(currentGUI.window)
    109     showing = false
    110     i=1
     129    local i=1
    111130    while activeSheets[i] do
    112131        if activeSheets[i+1] == nil then
     
    129148    end
    130149    cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table
     150    bHidePrevious[filename] = nil
    131151end
     152
     153function setBackground(filename)
     154    local newroot
     155    if root ~= nil then
     156        root:rename("oldRootWindow")
     157    end
     158    if filename ~= "" then
     159        newroot = winMgr:loadWindowLayout(filename .. ".layout")
     160        newroot:rename("AbsoluteRootWindow")
     161        system:setGUISheet(newroot)
     162    else
     163        newroot = winMgr:createWindow("DefaultWindow", "AbsoluteRootWindow")
     164        newroot:setProperty("Alpha", "0.0")
     165        newroot:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
     166        system:setGUISheet(newroot)
     167    end
     168    if root ~= nil then
     169        local child
     170        for i=0,root:getChildCount()-1 do
     171            child = root:getChildAtIdx(i)
     172            root:removeChildWindow(child)
     173            newroot:addChildWindow(child)
     174        end
     175        winMgr:destroyWindow(root)
     176    end
     177    newroot:show()
     178    root = newroot
     179end
     180
     181function find(table, value)
     182    local i=0
     183    while table[i] ~= nil do
     184        if table[i]==value then
     185            return i
     186        else
     187            i=i+1
     188        end
     189    end
     190    return nil
     191end
  • code/branches/menu/src/libraries/core/GUIManager.cc

    r6024 r6032  
    8989    GUIManager* GUIManager::singletonPtr_s = 0;
    9090
    91     SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, true);
     91    SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true);
    9292    SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
    9393
     
    210210        For more details check out loadGUI_2.lua where the function presides.
    211211    */
    212     /*static*/ void GUIManager::showGUI(const std::string& name, bool showCursor)
     212    /*static*/ void GUIManager::showGUI(const std::string& name, bool hidePrevious, bool showCursor)
    213213    {
    214214        std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name);
     
    220220            InputManager::getInstance().enterState("guiMouseOnly");
    221221        }
    222         GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ")");
     222        COUT(0) << "showGUI" << endl;
     223        GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ")");
    223224    }
    224225
     
    227228        Hack-ish. Needed for GUIOverlay.
    228229    */
    229     void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor)
     230    void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious, bool showCursor)
    230231    {
    231232        std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name);
     
    237238            InputManager::getInstance().enterState("guiMouseOnly");
    238239        }
    239         this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")");
     240        this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")");
    240241    }
    241242
     
    258259        }
    259260    }
     261   
     262    void GUIManager::setToggleMode(const bool& mode)
     263    {
     264        this->bToggleMode_ = mode;
     265        this->executeCode("setToggleMode(" + multi_cast<std::string>(mode) + ")");
     266    }
     267   
     268    void GUIManager::setBackground(const std::string& name)
     269    {
     270        this->executeCode("setBackground(\"" + name + "\")");
     271    }
    260272
    261273    void GUIManager::keyPressed(const KeyEvent& evt)
  • code/branches/menu/src/libraries/core/GUIManager.h

    r6024 r6032  
    6868        void update(const Clock& time);
    6969
    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);
     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);
    7272        static void hideGUI(const std::string& name);
     73        void setToggleMode(const bool& mode);
     74        void setBackground(const std::string& name);
    7375
    7476        void setCamera(Ogre::Camera* camera);
     
    111113
    112114        static GUIManager*                   singletonPtr_s;    //!< Singleton reference to GUIManager
     115        bool                                 bToggleMode_;
    113116
    114117    };
  • code/branches/menu/src/orxonox/gamestates/GSMainMenu.cc

    r6024 r6032  
    8282    {
    8383        // show main menu
    84         GUIManager::getInstance().showGUI("MainMenu", false);
     84        GUIManager::getInstance().showGUI("MainMenu", true, false);
    8585        GUIManager::getInstance().setCamera(this->camera_);
     86        GUIManager::getInstance().setBackground("MainMenuBackground");
     87//         GUIManager::getInstance().setBackground("");
    8688        GraphicsManager::getInstance().setCamera(this->camera_);
    8789
     
    113115
    114116        GUIManager::getInstance().setCamera(0);
     117        GUIManager::getInstance().setBackground("");
    115118        GUIManager::hideGUI("MainMenu");
    116119        GraphicsManager::getInstance().setCamera(0);
Note: See TracChangeset for help on using the changeset viewer.