Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/sound5/src/modules/overlays/hud/TeamBaseMatchScore.cc @ 10255

Last change on this file since 10255 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
  • Property svn:eol-style set to native
File size: 4.2 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 "TeamBaseMatchScore.h"
30
31#include "core/CoreIncludes.h"
32#include "core/XMLPort.h"
33#include "util/Convert.h"
34#include "gametypes/TeamBaseMatch.h"
35#include "infos/PlayerInfo.h"
36
37namespace orxonox
38{
39    CreateFactory(TeamBaseMatchScore);
40
41    TeamBaseMatchScore::TeamBaseMatchScore(BaseObject* creator) : OverlayText(creator)
42    {
43        RegisterObject(TeamBaseMatchScore);
44
45        this->owner_ = 0;
46
47        this->bShowBases_ = false;
48        this->bShowScore_ = false;
49        this->bShowLeftTeam_ = false;
50        this->bShowRightTeam_ = false;
51    }
52
53    TeamBaseMatchScore::~TeamBaseMatchScore()
54    {
55    }
56
57    void TeamBaseMatchScore::XMLPort(Element& xmlelement, XMLPort::Mode mode)
58    {
59        SUPER(TeamBaseMatchScore, XMLPort, xmlelement, mode);
60
61        XMLPortParam(TeamBaseMatchScore, "showbases",     setShowBases,     getShowBases,     xmlelement, mode).defaultValues(false);
62        XMLPortParam(TeamBaseMatchScore, "showscore",     setShowScore,     getShowScore,     xmlelement, mode).defaultValues(false);
63        XMLPortParam(TeamBaseMatchScore, "showleftteam",  setShowLeftTeam,  getShowLeftTeam,  xmlelement, mode).defaultValues(false);
64        XMLPortParam(TeamBaseMatchScore, "showrightteam", setShowRightTeam, getShowRightTeam, xmlelement, mode).defaultValues(false);
65    }
66
67    void TeamBaseMatchScore::tick(float dt)
68    {
69        SUPER(TeamBaseMatchScore, tick, dt);
70
71        if (this->owner_)
72        {
73            const std::string& bases1 = '(' + multi_cast<std::string>(this->owner_->getTeamBases(0)) + ')';
74            const std::string& bases2 = '(' + multi_cast<std::string>(this->owner_->getTeamBases(1)) + ')';
75
76            const std::string& score1 = multi_cast<std::string>(this->owner_->getTeamPoints(0));
77            const std::string& score2 = multi_cast<std::string>(this->owner_->getTeamPoints(1));
78
79            std::string output1;
80            if (this->bShowLeftTeam_)
81            {
82                if (this->bShowBases_ && this->bShowScore_)
83                    output1 = bases1 + " - " + score1;
84                else if (this->bShowScore_)
85                    output1 = score1;
86                else if (this->bShowBases_)
87                    output1 = bases1;
88            }
89
90            std::string output2;
91            if (this->bShowRightTeam_)
92            {
93                if (this->bShowBases_ && this->bShowScore_)
94                    output2 = score2 + " - " + bases2;
95                else if (this->bShowScore_)
96                    output2 = score2;
97                else if (this->bShowBases_)
98                    output2 = bases2;
99            }
100
101            std::string output;
102            if (this->bShowBases_ || this->bShowScore_)
103            {
104                if (this->bShowLeftTeam_ && this->bShowRightTeam_)
105                    output = output1 + ':' + output2;
106                else if (this->bShowLeftTeam_ || this->bShowRightTeam_)
107                    output = output1 + output2;
108            }
109
110            this->setCaption(output);
111        }
112    }
113
114
115    void TeamBaseMatchScore::changedOwner()
116    {
117        SUPER(TeamBaseMatchScore, changedOwner);
118
119        if (this->getOwner() && this->getOwner()->getGametype())
120            this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype().get());
121        else
122            this->owner_ = 0;
123    }
124}
Note: See TracBrowser for help on using the repository browser.