Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/Binderm_FS16/src/orxonox/overlays/GUISheet.cc @ 12037

Last change on this file since 12037 was 11150, checked in by binderm, 9 years ago

tried consoleCommand, doesn't work yet. Please have a look;)

  • 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#include "core/command/ConsoleCommandIncludes.h"
36
37namespace orxonox
38{
39
40
41    RegisterClass(GUISheet);
42
43
44    GUISheet::GUISheet(Context* context)
45        : BaseObject(context)
46        , bShowOnLoad_(false)
47        , bHidePrevious_(false)
48        , bHidePreviousSet_(false)
49    {
50        RegisterObject(GUISheet);
51
52        if (!GameMode::showsGraphics())
53            ThrowException(NoGraphics, "GUISheet construction failed: no graphics");
54    }
55
56    GUISheet::~GUISheet()
57    {
58    }
59
60    void GUISheet::XMLPort(Element& xmlelement, XMLPort::Mode mode)
61    {
62        SUPER(GUISheet, XMLPort, xmlelement, mode);
63
64        XMLPortParam(GUISheet, "showOnLoad",   setShowOnLoad,     getShowOnLoad,     xmlelement, mode);
65        XMLPortParam(GUISheet, "hidePrevious", setPreviousHiding, getPreviousHiding, xmlelement, mode);
66        XMLPortParam(GUISheet, "sheetName",    setSheetName,      getSheetName,      xmlelement, mode);
67        XMLPortParam(GUISheet, "backgroundImage",  setBackgroundImage,  getBackgroundImage,  xmlelement, mode);
68
69        if (this->bShowOnLoad_)
70            this->show();
71    }
72
73    void GUISheet::show()
74    {
75        GUIManager::getInstance().setBackgroundImage(this->backgroundImage_);
76        if (this->bHidePreviousSet_)
77            GUIManager::getInstance().showGUI(this->sheetName_, this->bHidePrevious_);
78        else
79            GUIManager::getInstance().showGUI(this->sheetName_);
80    }
81
82    void GUISheet::hide()
83    {
84        GUIManager::getInstance().hideGUI(this->sheetName_);
85        if (!this->backgroundImage_.empty())
86            GUIManager::getInstance().setBackgroundImage("");
87    }
88
89    void GUISheet::setSheetName(const std::string& name)
90    {
91        this->sheetName_ = name;
92        GUIManager::getInstance().loadGUI(this->sheetName_);
93    }
94
95    void GUISheet::setPreviousHiding(bool bHide)
96    {
97        this->bHidePrevious_ = bHide;
98        this->bHidePreviousSet_ = true;
99        // Note: This call has no effect when already showing!
100    }
101
102}
Note: See TracBrowser for help on using the repository browser.