[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" |
---|
[6441] | 35 | |
---|
| 36 | namespace orxonox |
---|
| 37 | { |
---|
| 38 | CreateFactory(GUISheet); |
---|
| 39 | |
---|
| 40 | GUISheet::GUISheet(BaseObject* creator) |
---|
| 41 | : BaseObject(creator) |
---|
| 42 | , bShowOnLoad_(false) |
---|
| 43 | , bHidePrevious_(false) |
---|
[6737] | 44 | , bHidePreviousSet_(false) |
---|
[6441] | 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 | |
---|
[7297] | 56 | void GUISheet::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
[6441] | 57 | { |
---|
[7297] | 58 | SUPER(GUISheet, XMLPort, xmlelement, mode); |
---|
[6441] | 59 | |
---|
[7297] | 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); |
---|
[6737] | 64 | |
---|
| 65 | if (this->bShowOnLoad_) |
---|
| 66 | this->show(); |
---|
[6441] | 67 | } |
---|
| 68 | |
---|
| 69 | void GUISheet::show() |
---|
| 70 | { |
---|
[6737] | 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_); |
---|
[6441] | 76 | } |
---|
| 77 | |
---|
| 78 | void GUISheet::hide() |
---|
| 79 | { |
---|
[6737] | 80 | GUIManager::getInstance().hideGUI(this->sheetName_); |
---|
| 81 | if (!this->backgroundImage_.empty()) |
---|
| 82 | GUIManager::getInstance().setBackgroundImage(""); |
---|
[6441] | 83 | } |
---|
| 84 | |
---|
[6737] | 85 | void GUISheet::setSheetName(const std::string& name) |
---|
[6441] | 86 | { |
---|
[6737] | 87 | this->sheetName_ = name; |
---|
| 88 | GUIManager::getInstance().loadGUI(this->sheetName_); |
---|
[6441] | 89 | } |
---|
| 90 | |
---|
| 91 | void GUISheet::setPreviousHiding(bool bHide) |
---|
| 92 | { |
---|
| 93 | this->bHidePrevious_ = bHide; |
---|
[6737] | 94 | this->bHidePreviousSet_ = true; |
---|
| 95 | // Note: This call has no effect when already showing! |
---|
[6441] | 96 | } |
---|
| 97 | } |
---|