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.

Location:
code/branches/gamestates2/src/orxonox/overlays
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamestates2/src/orxonox/overlays/GUISheet.cc

    r6722 r6737  
    4040        : BaseObject(creator)
    4141        , bShowOnLoad_(false)
    42         , bShowCursor_(true)
    4342        , bHidePrevious_(false)
     43        , bHidePreviousSet_(false)
    4444    {
    4545        RegisterObject(GUISheet);
     
    5757        SUPER(GUISheet, XMLPort, xmlElement, mode);
    5858
    59         XMLPortParam(GUISheet, "showOnLoad",   setShowOnLoad,       getShowOnLoad,       xmlElement, mode);
    60         XMLPortParam(GUISheet, "showCursor",   setCursorVisibility, getCursorVisibility, xmlElement, mode);
    61         XMLPortParam(GUISheet, "hidePrevious", setPreviousHiding,   getPreviousHiding,   xmlElement, mode);
    62         XMLPortParam(GUISheet, "script",       setScript,           getScript,           xmlElement, mode);
     59        XMLPortParam(GUISheet, "showOnLoad",   setShowOnLoad,     getShowOnLoad,     xmlElement, mode);
     60        XMLPortParam(GUISheet, "hidePrevious", setPreviousHiding, getPreviousHiding, xmlElement, mode);
     61        XMLPortParam(GUISheet, "sheetName",    setSheetName,      getSheetName,      xmlElement, mode);
     62        XMLPortParam(GUISheet, "backgroundImage",  setBackgroundImage,  getBackgroundImage,  xmlElement, mode);
     63
     64        if (this->bShowOnLoad_)
     65            this->show();
    6366    }
    6467
    6568    void GUISheet::show()
    6669    {
    67         GUIManager::showGUI(this->script_, this->bHidePrevious_);
     70        GUIManager::getInstance().setBackgroundImage(this->backgroundImage_);
     71        if (this->bHidePreviousSet_)
     72            GUIManager::getInstance().showGUI(this->sheetName_, this->bHidePrevious_);
     73        else
     74            GUIManager::getInstance().showGUI(this->sheetName_);
    6875    }
    6976
    7077    void GUISheet::hide()
    7178    {
    72         GUIManager::hideGUI(this->script_);
     79        GUIManager::getInstance().hideGUI(this->sheetName_);
     80        if (!this->backgroundImage_.empty())
     81            GUIManager::getInstance().setBackgroundImage("");
    7382    }
    7483
    75     void GUISheet::setScript(const std::string& filename)
     84    void GUISheet::setSheetName(const std::string& name)
    7685    {
    77         this->script_ = filename;
    78         GUIManager::getInstance().loadGUI(this->script_);
    79         if (this->bShowOnLoad_)
    80             this->show();
    81     }
    82 
    83     void GUISheet::setCursorVisibility(bool bShow)
    84     {
    85         this->bShowCursor_ = bShow;
    86         // TODO: This call has no effect when already showing!
     86        this->sheetName_ = name;
     87        GUIManager::getInstance().loadGUI(this->sheetName_);
    8788    }
    8889
     
    9091    {
    9192        this->bHidePrevious_ = bHide;
    92         // TODO: This call has no effect when already showing!
     93        this->bHidePreviousSet_ = true;
     94        // Note: This call has no effect when already showing!
    9395    }
    9496}
  • code/branches/gamestates2/src/orxonox/overlays/GUISheet.h

    r6595 r6737  
    4949        void hide();
    5050
    51         void setScript(const std::string& filename);
    52         inline const std::string& getScript() const
    53             { return this->script_; }
     51        void setSheetName(const std::string& name);
     52        inline const std::string& getSheetName() const
     53            { return this->sheetName_; }
    5454
    5555        inline void setShowOnLoad(bool bShow)
     
    5858            { return this->bShowOnLoad_; }
    5959
    60         void setCursorVisibility(bool bShow);
    61         inline bool getCursorVisibility() const
    62             { return this->bShowCursor_; }
    63 
    6460        void setPreviousHiding(bool bHide);
    6561        inline bool getPreviousHiding() const
    6662            { return this->bHidePrevious_; }
    6763
     64        void setBackgroundImage(const std::string& image)
     65            { this->backgroundImage_ = image; }
     66        inline const std::string& getBackgroundImage() const
     67            { return this->backgroundImage_; }
     68
    6869    private:
    69         std::string script_;
     70        std::string sheetName_;
    7071        bool bShowOnLoad_;
    71         bool bShowCursor_;
    7272        bool bHidePrevious_;
     73        bool bHidePreviousSet_;
     74        std::string backgroundImage_;
    7375  };
    7476}
Note: See TracChangeset for help on using the changeset viewer.