Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestates3/src/orxonox/overlays/GUISheet.cc @ 9343

Last change on this file since 9343 was 6746, checked in by rgrieder, 15 years ago

Merged gamestates2 branch back to trunk.
This brings in some heavy changes in the GUI framework.
It should also fix problems with triggered asserts in the InputManager.

Note: PickupInventory does not seem to work —> Segfault when showing because before, the owner in GUIOverlay::setGUIName is already NULL.
I haven't tested it before, so I can't tell whether it's my changes.

  • Property svn:eol-style set to native
File size: 2.9 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
35namespace orxonox
36{
37    CreateFactory(GUISheet);
38
39    GUISheet::GUISheet(BaseObject* creator)
40        : BaseObject(creator)
41        , bShowOnLoad_(false)
42        , bHidePrevious_(false)
43        , bHidePreviousSet_(false)
44    {
45        RegisterObject(GUISheet);
46
47        if (!GameMode::showsGraphics())
48            ThrowException(NoGraphics, "GUISheet construction failed: no graphics");
49    }
50
51    GUISheet::~GUISheet()
52    {
53    }
54
55    void GUISheet::XMLPort(Element& xmlElement, XMLPort::Mode mode)
56    {
57        SUPER(GUISheet, XMLPort, xmlElement, mode);
58
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();
66    }
67
68    void GUISheet::show()
69    {
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_);
75    }
76
77    void GUISheet::hide()
78    {
79        GUIManager::getInstance().hideGUI(this->sheetName_);
80        if (!this->backgroundImage_.empty())
81            GUIManager::getInstance().setBackgroundImage("");
82    }
83
84    void GUISheet::setSheetName(const std::string& name)
85    {
86        this->sheetName_ = name;
87        GUIManager::getInstance().loadGUI(this->sheetName_);
88    }
89
90    void GUISheet::setPreviousHiding(bool bHide)
91    {
92        this->bHidePrevious_ = bHide;
93        this->bHidePreviousSet_ = true;
94        // Note: This call has no effect when already showing!
95    }
96}
Note: See TracBrowser for help on using the repository browser.