Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/bindermFS16/src/orxonox/overlays/GUISheet.cc @ 11238

Last change on this file since 11238 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
RevLine 
[6441]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"
[7163]34#include "core/GameMode.h"
[11150]35#include "core/command/ConsoleCommandIncludes.h"
[6441]36
37namespace orxonox
38{
[11150]39
40
[9667]41    RegisterClass(GUISheet);
[6441]42
[11150]43
[9667]44    GUISheet::GUISheet(Context* context)
45        : BaseObject(context)
[6441]46        , bShowOnLoad_(false)
47        , bHidePrevious_(false)
[6737]48        , bHidePreviousSet_(false)
[6441]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
[7401]60    void GUISheet::XMLPort(Element& xmlelement, XMLPort::Mode mode)
[6441]61    {
[7401]62        SUPER(GUISheet, XMLPort, xmlelement, mode);
[6441]63
[7401]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);
[6737]68
69        if (this->bShowOnLoad_)
70            this->show();
[6441]71    }
72
73    void GUISheet::show()
74    {
[6737]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_);
[6441]80    }
81
82    void GUISheet::hide()
83    {
[6737]84        GUIManager::getInstance().hideGUI(this->sheetName_);
85        if (!this->backgroundImage_.empty())
86            GUIManager::getInstance().setBackgroundImage("");
[6441]87    }
88
[6737]89    void GUISheet::setSheetName(const std::string& name)
[6441]90    {
[6737]91        this->sheetName_ = name;
92        GUIManager::getInstance().loadGUI(this->sheetName_);
[6441]93    }
94
95    void GUISheet::setPreviousHiding(bool bHide)
96    {
97        this->bHidePrevious_ = bHide;
[6737]98        this->bHidePreviousSet_ = true;
99        // Note: This call has no effect when already showing!
[6441]100    }
[11150]101
[6441]102}
Note: See TracBrowser for help on using the repository browser.