Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/overlays/hud/GametypeStatus.cc @ 7163

Last change on this file since 7163 was 7163, checked in by dafrick, 14 years ago

Merged presentation3 branch into trunk.

  • Property svn:eol-style set to native
File size: 3.3 KB
Line 
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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "GametypeStatus.h"
30
31#include "util/Convert.h"
32#include "core/ConsoleCommand.h"
33#include "core/CoreIncludes.h"
34#include "infos/GametypeInfo.h"
35#include "infos/PlayerInfo.h"
36#include "worldentities/ControllableEntity.h"
37#include "worldentities/pawns/Spectator.h"
38
39namespace orxonox
40{
41    CreateFactory(GametypeStatus);
42
43    /*static*/ bool GametypeStatus::noCaption_s = false;
44    SetConsoleCommand(GametypeStatus, setGametypeStatus, true);
45
46    GametypeStatus::GametypeStatus(BaseObject* creator) : OverlayText(creator)
47    {
48        RegisterObject(GametypeStatus);
49
50        this->owner_ = 0;
51    }
52
53    GametypeStatus::~GametypeStatus()
54    {
55    }
56
57    void GametypeStatus::tick(float dt)
58    {
59        SUPER(GametypeStatus, tick, dt);
60
61        if (this->owner_ && this->owner_->getGametypeInfo() && this->owner_->getControllableEntity())
62        {
63            const GametypeInfo* gtinfo = this->owner_->getGametypeInfo();
64            ControllableEntity* ce = this->owner_->getControllableEntity();
65
66            if(GametypeStatus::noCaption_s) // No captions are displayed.
67            {
68                this->setCaption("");
69                return;
70            }
71
72            if (!gtinfo->hasStarted() && !gtinfo->isStartCountdownRunning())
73            {
74                if (!this->owner_->isReadyToSpawn())
75                    this->setCaption("Press [Fire] to start the match");
76                else
77                    this->setCaption("Waiting for other players");
78            }
79            else if (!gtinfo->hasEnded())
80            {
81                if (gtinfo->isStartCountdownRunning())
82                    this->setCaption(multi_cast<std::string>(static_cast<int>(ceil(gtinfo->getStartCountdown()))));
83                else if (ce->isA(Class(Spectator)))
84                    this->setCaption("Press [Fire] to respawn");
85                else
86                    this->setCaption("");
87            }
88            else
89                this->setCaption("Game has ended");
90        }
91    }
92
93
94    void GametypeStatus::changedOwner()
95    {
96        SUPER(GametypeStatus, changedOwner);
97
98        this->owner_ = orxonox_cast<PlayerInfo*>(this->getOwner());
99    }
100
101    /**
102    @brief
103        Sets whether the gametype status is displayed.
104    @param bValue
105        If true captions are displayed, if false, not.
106    */
107    /*static*/ void GametypeStatus::setGametypeStatus(bool bValue)
108    {
109        GametypeStatus::noCaption_s = !bValue;
110    }
111
112}
Note: See TracBrowser for help on using the repository browser.