Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/release2012/src/orxonox/overlays/GUISheet.cc @ 11843

Last change on this file since 11843 was 7401, checked in by landauf, 14 years ago

merged doc branch back to trunk

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "GUISheet.h"
30
31#include "core/CoreIncludes.h"
32#include "core/GUIManager.h"
33#include "core/XMLPort.h"
34#include "core/GameMode.h"
35
36namespace orxonox
37{
38    CreateFactory(GUISheet);
39
40    GUISheet::GUISheet(BaseObject* creator)
41        : BaseObject(creator)
42        , bShowOnLoad_(false)
43        , bHidePrevious_(false)
44        , bHidePreviousSet_(false)
45    {
46        RegisterObject(GUISheet);
47
48        if (!GameMode::showsGraphics())
49            ThrowException(NoGraphics, "GUISheet construction failed: no graphics");
50    }
51
52    GUISheet::~GUISheet()
53    {
54    }
55
56    void GUISheet::XMLPort(Element& xmlelement, XMLPort::Mode mode)
57    {
58        SUPER(GUISheet, XMLPort, xmlelement, mode);
59
60        XMLPortParam(GUISheet, "showOnLoad",   setShowOnLoad,     getShowOnLoad,     xmlelement, mode);
61        XMLPortParam(GUISheet, "hidePrevious", setPreviousHiding, getPreviousHiding, xmlelement, mode);
62        XMLPortParam(GUISheet, "sheetName",    setSheetName,      getSheetName,      xmlelement, mode);
63        XMLPortParam(GUISheet, "backgroundImage",  setBackgroundImage,  getBackgroundImage,  xmlelement, mode);
64
65        if (this->bShowOnLoad_)
66            this->show();
67    }
68
69    void GUISheet::show()
70    {
71        GUIManager::getInstance().setBackgroundImage(this->backgroundImage_);
72        if (this->bHidePreviousSet_)
73            GUIManager::getInstance().showGUI(this->sheetName_, this->bHidePrevious_);
74        else
75            GUIManager::getInstance().showGUI(this->sheetName_);
76    }
77
78    void GUISheet::hide()
79    {
80        GUIManager::getInstance().hideGUI(this->sheetName_);
81        if (!this->backgroundImage_.empty())
82            GUIManager::getInstance().setBackgroundImage("");
83    }
84
85    void GUISheet::setSheetName(const std::string& name)
86    {
87        this->sheetName_ = name;
88        GUIManager::getInstance().loadGUI(this->sheetName_);
89    }
90
91    void GUISheet::setPreviousHiding(bool bHide)
92    {
93        this->bHidePrevious_ = bHide;
94        this->bHidePreviousSet_ = true;
95        // Note: This call has no effect when already showing!
96    }
97}
Note: See TracBrowser for help on using the repository browser.