Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/superorxobros/SOBHUDInfo.cc @ 12332

Last change on this file since 12332 was 11783, checked in by landauf, 7 years ago

merged Presentation_HS17_merge back to trunk

  • Property svn:eol-style set to native
File size: 3.0 KB
RevLine 
[11405]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:
[11416]23 *      Julien Kindle
[11405]24 *
25 */
26
27#include "SOBHUDInfo.h"
28
29#include "core/CoreIncludes.h"
30#include "core/XMLPort.h"
31#include "util/Convert.h"
32#include "SOB.h"
33#include <sstream>
34#include <iomanip>
35
36
37
38namespace orxonox
39{
40    RegisterClass(SOBHUDInfo);
41
42    SOBHUDInfo::SOBHUDInfo(Context* context) : OverlayText(context)
43    {
44        RegisterObject(SOBHUDInfo);
45
46        this->SOBGame = nullptr;
47       
48    }
49
50    void SOBHUDInfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
51    {
52        SUPER(SOBHUDInfo, XMLPort, xmlelement, mode);
53        XMLPortParam(SOBHUDInfo, "type",     setType,     getType,     xmlelement, mode).defaultValues(false);
54
55
56    }
57
58    void SOBHUDInfo::tick(float dt)
59    {
60        SUPER(SOBHUDInfo, tick, dt);
61
[11416]62        //If you have a look at the HUD xml file, you can see there are several elements with different types.
[11405]63        if (this->SOBGame)
64        {
65         
[11416]66          if (this->type_ == "Coins") {           
[11412]67           
[11405]68            std::stringstream ss;
69            ss << "cc x " << std::setw(2) << std::setfill('0') << SOBGame->getCoins();
70            std::string s = ss.str();
71
72            this->setCaption(s);
73           
[11412]74        }
75        if (this->type_ == "Points") {
[11405]76            std::stringstream ss;
77            ss << std::setw(6) << std::setfill('0') << SOBGame->getPoints();
78            std::string s = ss.str();
79            this->setCaption(s);
[11412]80        }
81        if (this->type_ == "Time") {
[11405]82            std::stringstream ss;
83            ss << SOBGame->getTimeLeft();
84            std::string s = ss.str();
85            this->setCaption(s);
[11412]86        }
87        if (this->type_ == "Info") {
88            std::stringstream ss;
89            ss << SOBGame->getInfoText();
90            std::string s = ss.str();
91            this->setCaption(s);
92        }
93       
[11405]94
[11412]95       
[11405]96    }
[11412]97}
[11405]98
[11416]99//No idea why, just implement this method
[11412]100void SOBHUDInfo::changedOwner()
101{
102    SUPER(SOBHUDInfo, changedOwner);
103
104    if (this->getOwner() && this->getOwner()->getGametype())
[11405]105    {
[11412]106        this->SOBGame = orxonox_cast<SOB*>(this->getOwner()->getGametype());
[11405]107    }
[11412]108    else
109    {
110        this->SOBGame = nullptr;
111    }
[11405]112}
[11412]113}
Note: See TracBrowser for help on using the repository browser.