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 | |
---|
35 | namespace orxonox |
---|
36 | { |
---|
37 | CreateFactory(GUISheet); |
---|
38 | |
---|
39 | GUISheet::GUISheet(BaseObject* creator) |
---|
40 | : BaseObject(creator) |
---|
41 | , bShowOnLoad_(false) |
---|
42 | , bShowCursor_(true) |
---|
43 | , bHidePrevious_(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, "showCursor", setCursorVisibility, getCursorVisibility, xmlElement, mode); |
---|
61 | XMLPortParam(GUISheet, "hidePrevious", setPreviousHiding, getPreviousHiding, xmlElement, mode); |
---|
62 | XMLPortParam(GUISheet, "script", setScript, getScript, xmlElement, mode); |
---|
63 | } |
---|
64 | |
---|
65 | void GUISheet::show() |
---|
66 | { |
---|
67 | GUIManager::showGUI(this->script_, this->bHidePrevious_, this->bShowCursor_); |
---|
68 | } |
---|
69 | |
---|
70 | void GUISheet::hide() |
---|
71 | { |
---|
72 | GUIManager::hideGUI(this->script_); |
---|
73 | } |
---|
74 | |
---|
75 | void GUISheet::setScript(const std::string& filename) |
---|
76 | { |
---|
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! |
---|
87 | } |
---|
88 | |
---|
89 | void GUISheet::setPreviousHiding(bool bHide) |
---|
90 | { |
---|
91 | this->bHidePrevious_ = bHide; |
---|
92 | // TODO: This call has no effect when already showing! |
---|
93 | } |
---|
94 | } |
---|