Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/lastmanstanding3/src/modules/overlays/hud/GametypeStatus.cc @ 7903

Last change on this file since 7903 was 7903, checked in by scheusso, 13 years ago

Merge branch 'jo-test' into lms3

  • Property svn:eol-style set to native
File size: 4.0 KB
RevLine 
[2428]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
[3196]31#include "util/Convert.h"
[2428]32#include "core/CoreIncludes.h"
[7284]33#include "core/command/ConsoleCommand.h"
[5735]34#include "infos/GametypeInfo.h"
35#include "infos/PlayerInfo.h"
36#include "worldentities/ControllableEntity.h"
37#include "worldentities/pawns/Spectator.h"
[7903]38//#include "gametypes/Gametype.h"
[2428]39
40namespace orxonox
41{
42    CreateFactory(GametypeStatus);
43
[7284]44    static const std::string __CC_GametypeStatus_name = "GametypeStatus";
45    static const std::string __CC_displayCaption_name = "displayCaption";
[7163]46
[7284]47    SetConsoleCommand(__CC_GametypeStatus_name, __CC_displayCaption_name, &GametypeStatus::setDisplayCaption);
48
[2428]49    GametypeStatus::GametypeStatus(BaseObject* creator) : OverlayText(creator)
50    {
51        RegisterObject(GametypeStatus);
52
[7903]53        //this->game_ = 0;
[2428]54        this->owner_ = 0;
[7284]55        this->bNoCaption_ = false;
[7903]56        //this->bForcedSpawn_ = false;
[7284]57
58        ModifyConsoleCommand(__CC_GametypeStatus_name, __CC_displayCaption_name).setObject(this);
[2428]59    }
60
61    GametypeStatus::~GametypeStatus()
62    {
[7284]63        ModifyConsoleCommand(__CC_GametypeStatus_name, __CC_displayCaption_name).setObject(0);
[2428]64    }
65
66    void GametypeStatus::tick(float dt)
67    {
68        SUPER(GametypeStatus, tick, dt);
69
[2973]70        if (this->owner_ && this->owner_->getGametypeInfo() && this->owner_->getControllableEntity())
[2428]71        {
[7903]72            //if (this->game_)
73            //    this->bForcedSpawn_ = this->game_->getForceSpawn();
74            //else
75            //    this->bForcedSpawn_ = false;
76
[2428]77            const GametypeInfo* gtinfo = this->owner_->getGametypeInfo();
[2973]78            ControllableEntity* ce = this->owner_->getControllableEntity();
[2428]79
[7284]80            if (this->bNoCaption_) // No captions are displayed.
[7163]81            {
82                this->setCaption("");
83                return;
84            }
85
[2428]86            if (!gtinfo->hasStarted() && !gtinfo->isStartCountdownRunning())
87            {
[2973]88                if (!this->owner_->isReadyToSpawn())
[2428]89                    this->setCaption("Press [Fire] to start the match");
90                else
91                    this->setCaption("Waiting for other players");
92            }
93            else if (!gtinfo->hasEnded())
94            {
95                if (gtinfo->isStartCountdownRunning())
[3300]96                    this->setCaption(multi_cast<std::string>(static_cast<int>(ceil(gtinfo->getStartCountdown()))));
[7903]97                else if (ce->isA(Class(Spectator))/*&&(!bForcedSpawn_)*/)
[2428]98                    this->setCaption("Press [Fire] to respawn");
99                else
100                    this->setCaption("");
101            }
102            else
103                this->setCaption("Game has ended");
104        }
105    }
106
107
108    void GametypeStatus::changedOwner()
109    {
110        SUPER(GametypeStatus, changedOwner);
[7903]111        //this->game_ = orxonox_cast<Gametype*>(this->getOwner());
[3325]112        this->owner_ = orxonox_cast<PlayerInfo*>(this->getOwner());
[2428]113    }
[7163]114
115    /**
116    @brief
117        Sets whether the gametype status is displayed.
118    @param bValue
119        If true captions are displayed, if false, not.
120    */
[7284]121    void GametypeStatus::setDisplayCaption(bool bValue)
[7163]122    {
[7284]123        this->bNoCaption_ = !bValue;
[7163]124    }
125
[2428]126}
Note: See TracBrowser for help on using the repository browser.