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