[11171] | 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 | * Tomer Gidron |
---|
| 24 | * |
---|
| 25 | */ |
---|
| 26 | |
---|
| 27 | #include "FlagsAndLivesHUD.h" |
---|
| 28 | #include "HoverFlag.h" |
---|
| 29 | #include "Hover.h" |
---|
| 30 | |
---|
| 31 | #include "core/CoreIncludes.h" |
---|
| 32 | #include "core/XMLPort.h" |
---|
| 33 | #include "util/Convert.h" |
---|
| 34 | |
---|
| 35 | namespace orxonox |
---|
| 36 | { |
---|
| 37 | RegisterClass(FlagsAndLivesHUD); |
---|
| 38 | |
---|
| 39 | FlagsAndLivesHUD::FlagsAndLivesHUD(Context* context) : OverlayText(context) |
---|
| 40 | { |
---|
| 41 | RegisterObject(FlagsAndLivesHUD); |
---|
| 42 | |
---|
| 43 | this->hoverGame_ = nullptr; |
---|
| 44 | this->totFlags_ = 0; |
---|
| 45 | showLives_ = false; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | void FlagsAndLivesHUD::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 49 | { |
---|
| 50 | SUPER(FlagsAndLivesHUD, XMLPort, xmlelement, mode); |
---|
| 51 | |
---|
| 52 | XMLPortParam(FlagsAndLivesHUD,"showPoints", setShowTot, getShowTot, xmlelement, mode); |
---|
| 53 | XMLPortParam(FlagsAndLivesHUD, "showLives", setShowLives, getShowLives, xmlelement, mode); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | void FlagsAndLivesHUD::tick(float dt) |
---|
| 57 | { |
---|
| 58 | SUPER(FlagsAndLivesHUD, tick, dt); |
---|
| 59 | |
---|
| 60 | const std::string& flags = multi_cast<std::string>(this->hoverGame_->getTotFlags()); |
---|
| 61 | const std::string& lives = multi_cast<std::string>(this->hoverGame_->getLives()); |
---|
| 62 | |
---|
| 63 | if(showLives_ == false){ |
---|
| 64 | setTextSize(0.04); |
---|
| 65 | setPosition(Vector2(0.18, 0.08)); |
---|
| 66 | this->setColour(ColourValue(1, 1, 1, 1)); |
---|
| 67 | this->setCaption(flags); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | else{ |
---|
| 71 | setTextSize(0.04); |
---|
| 72 | setPosition(Vector2(0.18, 0.12)); |
---|
| 73 | this->setColour(ColourValue(1, 1, 1, 1)); |
---|
| 74 | this->setCaption(lives); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | void FlagsAndLivesHUD::changedOwner() |
---|
| 80 | { |
---|
| 81 | SUPER(FlagsAndLivesHUD, changedOwner); |
---|
| 82 | |
---|
| 83 | if (this->getOwner() && this->getOwner()->getGametype()) |
---|
| 84 | { |
---|
| 85 | this->hoverGame_ = orxonox_cast<Hover*>(this->getOwner()->getGametype()); |
---|
| 86 | } |
---|
| 87 | else |
---|
| 88 | { |
---|
| 89 | this->hoverGame_ = nullptr; |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | } |
---|