Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 16, 2010, 12:22:12 PM (14 years ago)
Author:
rgrieder
Message:

Background image of the GUI is now managed by GUIManager and kept in a very simple manner: Tell it about the image set and the image name and the it will display it in the root node.
Also split SheetManager.lua from InitialiseGUI.lua to have a separate initialisation, required by GUIManager now.
And modified GUISheet.cc/h accordingly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamestates2/src/libraries/core/GUIManager.cc

    r6736 r6737  
    4242#include <CEGUISystem.h>
    4343#include <CEGUIWindow.h>
     44#include <CEGUIWindowManager.h>
    4445#include <ogreceguirenderer/OgreCEGUIRenderer.h>
    4546
     
    147148        guiSystem_->injectMousePosition((float)mousePosition.first, (float)mousePosition.second);
    148149
    149         // Hide the mouse cursor unless playing in full screen mode
    150         if (!GraphicsManager::getInstance().isFullScreen())
    151             CEGUI::MouseCursor::getSingleton().hide();
    152 
    153         // Initialise the basic Lua code
     150        // Initialise the Lua framework and load the schemes
    154151        this->luaState_->doFile("InitialiseGUI.lua");
     152
     153        // Create the root nodes
     154        this->rootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("MenuWidgets/StaticImage", "AbsoluteRootWindow");
     155        this->rootWindow_->setProperty("FrameEnabled", "False");
     156        this->hudRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "HUDRootWindow");
     157        this->menuRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "MenuRootWindow");
     158        // And connect them
     159        CEGUI::System::getSingleton().setGUISheet(this->rootWindow_);
     160        this->rootWindow_->addChildWindow(this->hudRootWindow_);
     161        this->rootWindow_->addChildWindow(this->menuRootWindow_);
     162
     163        // Set up the sheet manager in the Lua framework
     164        this->luaState_->doFile("SheetManager.lua");
    155165    }
    156166
     
    203213    @param str
    204214        reference to string object holding the Lua code which is to be executed
    205 
    206         This function gives total access to the GUI. You can execute ANY Lua code here.
    207215    */
    208216    void GUIManager::executeCode(const std::string& str)
     
    217225    void GUIManager::loadGUI(const std::string& name)
    218226    {
    219         this->executeCode("loadGUI(\"" + name + "\")");
     227        this->executeCode("loadSheet(\"" + name + "\")");
    220228    }
    221229
     
    292300    }
    293301
    294     void GUIManager::setBackground(const std::string& name)
    295     {
    296         this->executeCode("setBackground(\"" + name + "\")");
     302    void GUIManager::setBackgroundImage(const std::string& imageSet, const std::string imageName)
     303    {
     304        if (imageSet.empty() || imageName.empty())
     305            this->setBackgroundImage("set: " + imageSet + " image: " + imageName);
     306        else
     307            this->setBackgroundImage("");
     308    }
     309
     310    void GUIManager::setBackgroundImage(const std::string& image)
     311    {
     312        if (image.empty())
     313            this->rootWindow_->setProperty("Alpha", "0.0");
     314        else
     315            this->rootWindow_->setProperty("Alpha", "1.0");
     316        this->rootWindow_->setProperty("Image", image);
    297317    }
    298318
Note: See TracChangeset for help on using the changeset viewer.