[Orxonox-commit 557] r3099 - in trunk/src/orxonox: . objects objects/gametypes objects/infos objects/worldentities/triggers overlays overlays/hud
landauf at orxonox.net
landauf at orxonox.net
Thu May 28 01:58:22 CEST 2009
Author: landauf
Date: 2009-05-28 01:58:22 +0200 (Thu, 28 May 2009)
New Revision: 3099
Added:
trunk/src/orxonox/objects/GametypeMessageListener.cc
trunk/src/orxonox/objects/GametypeMessageListener.h
trunk/src/orxonox/overlays/FadeoutText.cc
trunk/src/orxonox/overlays/FadeoutText.h
trunk/src/orxonox/overlays/hud/AnnounceMessage.cc
trunk/src/orxonox/overlays/hud/AnnounceMessage.h
trunk/src/orxonox/overlays/hud/DeathMessage.cc
trunk/src/orxonox/overlays/hud/DeathMessage.h
trunk/src/orxonox/overlays/hud/KillMessage.cc
trunk/src/orxonox/overlays/hud/KillMessage.h
Modified:
trunk/src/orxonox/OrxonoxPrereqs.h
trunk/src/orxonox/objects/CMakeLists.txt
trunk/src/orxonox/objects/gametypes/Asteroids.cc
trunk/src/orxonox/objects/gametypes/Gametype.cc
trunk/src/orxonox/objects/gametypes/Pong.cc
trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
trunk/src/orxonox/objects/gametypes/UnderAttack.cc
trunk/src/orxonox/objects/infos/GametypeInfo.cc
trunk/src/orxonox/objects/infos/GametypeInfo.h
trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc
trunk/src/orxonox/overlays/CMakeLists.txt
trunk/src/orxonox/overlays/OverlayText.h
trunk/src/orxonox/overlays/hud/CMakeLists.txt
Log:
Added Gameplay messages (Announces, Killmessages and Deathmessages)
Modified: trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- trunk/src/orxonox/OrxonoxPrereqs.h 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/OrxonoxPrereqs.h 2009-05-27 23:58:22 UTC (rev 3099)
@@ -267,7 +267,11 @@
class OrxonoxOverlay;
class OverlayGroup;
class OverlayText;
+ class FadeoutText;
class GametypeStatus;
+ class AnnounceMessage;
+ class KillMessage;
+ class DeathMessage;
class CreateLines;
class Scoreboard;
class Map;
Modified: trunk/src/orxonox/objects/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/objects/CMakeLists.txt 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/objects/CMakeLists.txt 2009-05-27 23:58:22 UTC (rev 3099)
@@ -2,6 +2,7 @@
EventListener.cc
EventDispatcher.cc
EventTarget.cc
+ GametypeMessageListener.cc
GlobalShader.cc
Level.cc
Radar.cc
Added: trunk/src/orxonox/objects/GametypeMessageListener.cc
===================================================================
--- trunk/src/orxonox/objects/GametypeMessageListener.cc (rev 0)
+++ trunk/src/orxonox/objects/GametypeMessageListener.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -0,0 +1,41 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "GametypeMessageListener.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ GametypeMessageListener::GametypeMessageListener()
+ {
+ RegisterRootObject(GametypeMessageListener);
+ }
+}
+
+
Property changes on: trunk/src/orxonox/objects/GametypeMessageListener.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/src/orxonox/objects/GametypeMessageListener.h
===================================================================
--- trunk/src/orxonox/objects/GametypeMessageListener.h (rev 0)
+++ trunk/src/orxonox/objects/GametypeMessageListener.h 2009-05-27 23:58:22 UTC (rev 3099)
@@ -0,0 +1,50 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _GametypeMessageListener_H__
+#define _GametypeMessageListener_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport GametypeMessageListener : virtual public OrxonoxClass
+ {
+ public:
+ GametypeMessageListener();
+ virtual ~GametypeMessageListener() {}
+
+ virtual void announcemessage(const GametypeInfo* gtinfo, const std::string& message) {}
+ virtual void killmessage(const GametypeInfo* gtinfo, const std::string& message) {}
+ virtual void deathmessage(const GametypeInfo* gtinfo, const std::string& message) {}
+ };
+}
+
+#endif /* _GametypeMessageListener_H__ */
Property changes on: trunk/src/orxonox/objects/GametypeMessageListener.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/src/orxonox/objects/gametypes/Asteroids.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/Asteroids.cc 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/objects/gametypes/Asteroids.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -56,6 +56,7 @@
if (this->time_ < 0 && !this->hasEnded() && this->timerIsActive_)
{
+ this->gtinfo_.sendAnnounceMessage("Time's up - you have lost the match!");
this->end();
}
}
@@ -64,6 +65,7 @@
{
if (victim && victim->getPlayer())
{
+ this->gtinfo_.sendAnnounceMessage("You're dead - you have lost the match!");
this->end();
}
}
@@ -72,7 +74,7 @@
{
Gametype::start();
- std::string message = "The match has started! Reach the first chekpoint within 60 seconds! But be aware, there may be pirates around...";
+ std::string message = "The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...";
COUT(0) << message << std::endl;
Host::Broadcast(message);
}
Modified: trunk/src/orxonox/objects/gametypes/Gametype.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/Gametype.cc 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/objects/gametypes/Gametype.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -235,11 +235,18 @@
it->second.killed_++;
// Reward killer
- if (killer)
+ if (killer && killer->getPlayer())
{
std::map<PlayerInfo*, Player>::iterator it = this->players_.find(killer->getPlayer());
if (it != this->players_.end())
+ {
it->second.frags_++;
+
+ if (killer->getPlayer()->getClientID() != CLIENTID_UNKNOWN)
+ this->gtinfo_.sendKillMessage("You killed " + victim->getPlayer()->getName(), killer->getPlayer()->getClientID());
+ if (victim->getPlayer()->getClientID() != CLIENTID_UNKNOWN)
+ this->gtinfo_.sendDeathMessage("You were killed by " + killer->getPlayer()->getName(), victim->getPlayer()->getClientID());
+ }
}
ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
Modified: trunk/src/orxonox/objects/gametypes/Pong.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/Pong.cc 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/objects/gametypes/Pong.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -159,6 +159,9 @@
if (this->center_)
{
this->center_->fireEvent();
+
+ if (player)
+ this->gtinfo_.sendAnnounceMessage(player->getName() + " scored");
}
if (this->ball_)
Modified: trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -30,6 +30,7 @@
#include "objects/worldentities/pawns/TeamBaseMatchBase.h"
#include "core/CoreIncludes.h"
+#include "objects/infos/PlayerInfo.h"
namespace orxonox
{
@@ -57,9 +58,15 @@
{
int teamnr = this->getTeam(originator->getPlayer());
if (teamnr == 0)
+ {
base->setState(BaseState::controlTeam1);
+ this->gtinfo_.sendAnnounceMessage("The red team captured a base");
+ }
if (teamnr == 1)
+ {
base->setState(BaseState::controlTeam2);
+ this->gtinfo_.sendAnnounceMessage("The blue team captured a base");
+ }
}
victim->setHealth(victim->getInitialHealth());
@@ -124,6 +131,9 @@
// show points or each interval of time
void TeamBaseMatch::showPoints()
{
+ if (!this->hasStarted() || this->hasEnded())
+ return;
+
COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl;
if(pointsTeam1_ >=1700 && pointsTeam1_ < 2000) COUT(0) << "Team 1 is near victory!" << std::endl;
if(pointsTeam2_ >=1700 && pointsTeam2_ < 2000) COUT(0) << "Team 2 is near victory!" << std::endl;
@@ -158,11 +168,30 @@
{
if (this->pointsTeam1_ >= 2000 || this->pointsTeam2_ >= 2000)
{
+ int winningteam = -1;
+
if (this->pointsTeam1_ > this->pointsTeam2_)
+ {
COUT(0) << "Team 1 has won the match" << std::endl;
+ winningteam = 0;
+ }
else
+ {
COUT(0) << "Team 2 has won the match" << std::endl;
+ winningteam = 1;
+ }
+ for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+ {
+ if (it->first->getClientID() == CLIENTID_UNKNOWN)
+ continue;
+
+ if (it->second == winningteam)
+ this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
+ else
+ this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
+ }
+
this->end();
this->scoreTimer_.stopTimer();
this->outputTimer_.stopTimer();
Modified: trunk/src/orxonox/objects/gametypes/UnderAttack.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/UnderAttack.cc 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/objects/gametypes/UnderAttack.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -35,6 +35,7 @@
#include "network/Host.h"
#include "objects/worldentities/pawns/Destroyer.h"
+#include "objects/infos/PlayerInfo.h"
namespace orxonox
{
@@ -72,6 +73,17 @@
COUT(0) << message << std::endl;
Host::Broadcast(message);
this->gameEnded_ = true;
+
+ for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+ {
+ if (it->first->getClientID() == CLIENTID_UNKNOWN)
+ continue;
+
+ if (it->second == 0)
+ this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
+ else
+ this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
+ }
}
}
@@ -144,14 +156,29 @@
std::string message = "Time is up! Team 1 has won!";
COUT(0) << message << std::endl;
Host::Broadcast(message);
+
+ for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
+ {
+ if (it->first->getClientID() == CLIENTID_UNKNOWN)
+ continue;
+
+ if (it->second == 1)
+ this->gtinfo_.sendAnnounceMessage("You have won the match!", it->first->getClientID());
+ else
+ this->gtinfo_.sendAnnounceMessage("You have lost the match!", it->first->getClientID());
+ }
}
//prints gametime
- if ( gameTime_ <= timesequence_)
+ if ( gameTime_ <= timesequence_ && gameTime_ > 0)
{
- std::string message = convertToString(timesequence_) + " sec left!";
+ std::string message = convertToString(timesequence_) + " seconds left!";
+/*
COUT(0) << message << std::endl;
Host::Broadcast(message);
+*/
+ this->gtinfo_.sendAnnounceMessage(message);
+
if (timesequence_ >= 30 && timesequence_ <= 60)
{
timesequence_ = timesequence_ - 10;
Modified: trunk/src/orxonox/objects/infos/GametypeInfo.cc
===================================================================
--- trunk/src/orxonox/objects/infos/GametypeInfo.cc 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/objects/infos/GametypeInfo.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -30,11 +30,19 @@
#include "GametypeInfo.h"
#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "network/NetworkFunction.h"
+#include "network/Host.h"
+#include "objects/GametypeMessageListener.h"
namespace orxonox
{
CreateUnloadableFactory(GametypeInfo);
+ registerMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage);
+ registerMemberNetworkFunction(GametypeInfo, dispatchKillMessage);
+ registerMemberNetworkFunction(GametypeInfo, dispatchDeathMessage);
+
GametypeInfo::GametypeInfo(BaseObject* creator) : Info(creator)
{
RegisterObject(GametypeInfo);
@@ -59,4 +67,64 @@
registerVariable(this->bStartCountdownRunning_, variableDirection::toclient);
registerVariable(this->hudtemplate_, variableDirection::toclient);
}
+
+ void GametypeInfo::sendAnnounceMessage(const std::string& message) const
+ {
+ if (GameMode::isMaster())
+ {
+ callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), CLIENTID_UNKNOWN, message);
+ this->dispatchAnnounceMessage(message);
+ }
+ }
+
+ void GametypeInfo::sendAnnounceMessage(const std::string& message, unsigned int clientID) const
+ {
+ if (GameMode::isMaster())
+ {
+ if (clientID == CLIENTID_SERVER)
+ this->dispatchAnnounceMessage(message);
+ else
+ callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), clientID, message);
+ }
+ }
+
+ void GametypeInfo::sendKillMessage(const std::string& message, unsigned int clientID) const
+ {
+ if (GameMode::isMaster())
+ {
+ if (clientID == CLIENTID_SERVER)
+ this->dispatchKillMessage(message);
+ else
+ callMemberNetworkFunction(GametypeInfo, dispatchKillMessage, this->getObjectID(), clientID, message);
+ }
+ }
+
+ void GametypeInfo::sendDeathMessage(const std::string& message, unsigned int clientID) const
+ {
+ if (GameMode::isMaster())
+ {
+ if (clientID == CLIENTID_SERVER)
+ this->dispatchDeathMessage(message);
+ else
+ callMemberNetworkFunction(GametypeInfo, dispatchDeathMessage, this->getObjectID(), clientID, message);
+ }
+ }
+
+ void GametypeInfo::dispatchAnnounceMessage(const std::string& message) const
+ {
+ for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
+ it->announcemessage(this, message);
+ }
+
+ void GametypeInfo::dispatchKillMessage(const std::string& message) const
+ {
+ for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
+ it->killmessage(this, message);
+ }
+
+ void GametypeInfo::dispatchDeathMessage(const std::string& message) const
+ {
+ for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
+ it->deathmessage(this, message);
+ }
}
Modified: trunk/src/orxonox/objects/infos/GametypeInfo.h
===================================================================
--- trunk/src/orxonox/objects/infos/GametypeInfo.h 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/objects/infos/GametypeInfo.h 2009-05-27 23:58:22 UTC (rev 3099)
@@ -58,6 +58,15 @@
inline const std::string& getHUDTemplate() const
{ return this->hudtemplate_; }
+ void sendAnnounceMessage(const std::string& message) const;
+ void sendAnnounceMessage(const std::string& message, unsigned int clientID) const;
+ void sendKillMessage(const std::string& message, unsigned int clientID) const;
+ void sendDeathMessage(const std::string& message, unsigned int clientID) const;
+
+ void dispatchAnnounceMessage(const std::string& message) const;
+ void dispatchKillMessage(const std::string& message) const;
+ void dispatchDeathMessage(const std::string& message) const;
+
private:
bool bStarted_;
bool bEnded_;
Modified: trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/objects/worldentities/triggers/CheckPoint.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -71,7 +71,7 @@
void CheckPoint::changedActivity()
{
SUPER(CheckPoint, changedActivity);
-
+
if (this->BaseObject::isActive())
{
this->setRadarVisibility(true);
@@ -92,15 +92,24 @@
gametype->addTime(addTime_);
this->setRadarVisibility(false);
- if (bIsTriggered && bIsFirst_)
+ if (bIsTriggered)
{
- gametype->setTimeLimit(addTime_);
- gametype->firstCheckpointReached(true);
- }
+ if (bIsFirst_)
+ {
+ gametype->setTimeLimit(addTime_);
+ gametype->firstCheckpointReached(true);
+ }
- if (bIsTriggered && bIsDestination_)
- {
- gametype->end();
+ if (bIsDestination_)
+ {
+ const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Congratulations - you have won the match!");
+ gametype->end();
+ }
+
+ if (!bIsFirst_ && !bIsDestination_)
+ {
+ const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage("Checkpoint reached");
+ }
}
}
}
Modified: trunk/src/orxonox/overlays/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/overlays/CMakeLists.txt 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/overlays/CMakeLists.txt 2009-05-27 23:58:22 UTC (rev 3099)
@@ -2,6 +2,7 @@
OrxonoxOverlay.cc
OverlayGroup.cc
OverlayText.cc
+ FadeoutText.cc
GUIOverlay.cc
)
Added: trunk/src/orxonox/overlays/FadeoutText.cc
===================================================================
--- trunk/src/orxonox/overlays/FadeoutText.cc (rev 0)
+++ trunk/src/orxonox/overlays/FadeoutText.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -0,0 +1,117 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "FadeoutText.h"
+
+#include <OgreTextAreaOverlayElement.h>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+ CreateFactory(FadeoutText);
+
+ FadeoutText::FadeoutText(BaseObject* creator) : OverlayText(creator)
+ {
+ RegisterObject(FadeoutText);
+
+ this->delay_ = 3.0f;
+ this->fadeouttime_ = 1.0f;
+
+ this->bFadingOut_ = false;
+ this->fadeouttimer_.setTimer(3.0f, false, this, createExecutor(createFunctor(&FadeoutText::fadeout)));
+ this->fadeouttimer_.stopTimer();
+
+ this->initialAlpha_ = 1.0f;
+ }
+
+ void FadeoutText::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(FadeoutText, XMLPort, xmlelement, mode);
+
+ XMLPortParam(FadeoutText, "delay", setDelay, getDelay, xmlelement, mode);
+ XMLPortParam(FadeoutText, "fadeout", setFadeouttime, getFadeouttime, xmlelement, mode);
+ }
+
+ void FadeoutText::tick(float dt)
+ {
+ if (this->bFadingOut_)
+ {
+ ColourValue colour = this->getColour();
+
+ if (colour.a > 0)
+ {
+ float alpha = colour.a;
+
+ alpha -= dt / this->fadeouttime_;
+ if (alpha < 0)
+ alpha = 0;
+ colour.a = alpha;
+
+ this->text_->setColour(colour);
+ }
+ else
+ {
+ this->text_->setCaption("");
+ this->reset();
+ }
+ }
+ }
+
+ void FadeoutText::fadeout()
+ {
+ this->bFadingOut_ = true;
+ }
+
+ void FadeoutText::reset()
+ {
+ this->bFadingOut_ = false;
+
+ ColourValue colour = this->getColour();
+ colour.a = this->initialAlpha_;
+ this->text_->setColour(colour);
+ }
+
+ void FadeoutText::changedColour()
+ {
+ OverlayText::changedColour();
+
+ this->initialAlpha_ = this->getColour().a;
+ }
+
+ void FadeoutText::changedCaption()
+ {
+ OverlayText::changedCaption();
+
+ this->reset();
+ this->fadeouttimer_.setInterval(this->delay_);
+ this->fadeouttimer_.startTimer();
+ }
+}
Property changes on: trunk/src/orxonox/overlays/FadeoutText.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/src/orxonox/overlays/FadeoutText.h
===================================================================
--- trunk/src/orxonox/overlays/FadeoutText.h (rev 0)
+++ trunk/src/orxonox/overlays/FadeoutText.h 2009-05-27 23:58:22 UTC (rev 3099)
@@ -0,0 +1,75 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _FadeoutText_H__
+#define _FadeoutText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "overlays/OverlayText.h"
+#include "objects/Tickable.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport FadeoutText : public OverlayText, public Tickable
+ {
+ public:
+ FadeoutText(BaseObject* creator);
+ virtual ~FadeoutText() {}
+
+ virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+ virtual void tick(float dt);
+
+ inline void setDelay(float delay)
+ { this->delay_ = delay; }
+ inline float getDelay() const
+ { return this->delay_; }
+
+ inline void setFadeouttime(float fadeouttime)
+ { this->fadeouttime_ = fadeouttime; }
+ inline float getFadeouttime() const
+ { return this->fadeouttime_; }
+
+ private:
+ virtual void changedColour();
+ virtual void changedCaption();
+
+ void fadeout();
+ void reset();
+
+ float delay_;
+ float fadeouttime_;
+
+ bool bFadingOut_;
+ Timer<FadeoutText> fadeouttimer_;
+
+ float initialAlpha_;
+ };
+}
+#endif /* _FadeoutText_H__ */
Property changes on: trunk/src/orxonox/overlays/FadeoutText.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/src/orxonox/overlays/OverlayText.h
===================================================================
--- trunk/src/orxonox/overlays/OverlayText.h 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/overlays/OverlayText.h 2009-05-27 23:58:22 UTC (rev 3099)
@@ -46,7 +46,7 @@
virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
- inline void setCaption(const std::string& caption) { this->text_->setCaption(caption); }
+ inline void setCaption(const std::string& caption) { this->text_->setCaption(caption); this->changedCaption(); }
inline std::string getCaption() const { return this->text_->getCaption(); }
void setFont(const std::string& font);
@@ -55,7 +55,7 @@
inline void setSpaceWidth(float width) { this->text_->setSpaceWidth(width); }
inline float getSpaceWidth() const { return this->text_->getSpaceWidth(); }
- inline void setColour(const ColourValue& colour) { this->text_->setColour(colour); }
+ inline void setColour(const ColourValue& colour) { this->text_->setColour(colour); this->changedColour(); }
inline const ColourValue& getColour() const { return this->text_->getColour(); }
inline void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); }
@@ -69,6 +69,8 @@
protected:
virtual void sizeChanged();
+ virtual void changedColour() {}
+ virtual void changedCaption() {}
Ogre::TextAreaOverlayElement* text_;
};
Added: trunk/src/orxonox/overlays/hud/AnnounceMessage.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/AnnounceMessage.cc (rev 0)
+++ trunk/src/orxonox/overlays/hud/AnnounceMessage.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -0,0 +1,61 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "AnnounceMessage.h"
+
+#include "core/CoreIncludes.h"
+#include "objects/infos/PlayerInfo.h"
+
+namespace orxonox
+{
+ CreateFactory(AnnounceMessage);
+
+ AnnounceMessage::AnnounceMessage(BaseObject* creator) : FadeoutText(creator)
+ {
+ RegisterObject(AnnounceMessage);
+
+ this->owner_ = 0;
+
+ this->setDelay(3.0f);
+ this->setFadeouttime(1.0f);
+ }
+
+ void AnnounceMessage::announcemessage(const GametypeInfo* gtinfo, const std::string& message)
+ {
+ if (this->owner_ && this->owner_->getGametypeInfo() == gtinfo)
+ this->setCaption(message);
+ }
+
+ void AnnounceMessage::changedOwner()
+ {
+ SUPER(AnnounceMessage, changedOwner);
+
+ this->owner_ = dynamic_cast<PlayerInfo*>(this->getOwner());
+ }
+}
Property changes on: trunk/src/orxonox/overlays/hud/AnnounceMessage.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/src/orxonox/overlays/hud/AnnounceMessage.h
===================================================================
--- trunk/src/orxonox/overlays/hud/AnnounceMessage.h (rev 0)
+++ trunk/src/orxonox/overlays/hud/AnnounceMessage.h 2009-05-27 23:58:22 UTC (rev 3099)
@@ -0,0 +1,53 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _AnnounceMessage_H__
+#define _AnnounceMessage_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "overlays/FadeoutText.h"
+#include "objects/GametypeMessageListener.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport AnnounceMessage : public FadeoutText, public GametypeMessageListener
+ {
+ public:
+ AnnounceMessage(BaseObject* creator);
+ virtual ~AnnounceMessage() {}
+
+ virtual void changedOwner();
+
+ void announcemessage(const GametypeInfo* gtinfo, const std::string& message);
+
+ private:
+ PlayerInfo* owner_;
+ };
+}
+#endif /* _AnnounceMessage_H__ */
Property changes on: trunk/src/orxonox/overlays/hud/AnnounceMessage.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/src/orxonox/overlays/hud/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/overlays/hud/CMakeLists.txt 2009-05-27 23:02:42 UTC (rev 3098)
+++ trunk/src/orxonox/overlays/hud/CMakeLists.txt 2009-05-27 23:58:22 UTC (rev 3099)
@@ -7,5 +7,8 @@
HUDTimer.cc
ChatOverlay.cc
GametypeStatus.cc
+ AnnounceMessage.cc
+ KillMessage.cc
+ DeathMessage.cc
PongScore.cc
)
Added: trunk/src/orxonox/overlays/hud/DeathMessage.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/DeathMessage.cc (rev 0)
+++ trunk/src/orxonox/overlays/hud/DeathMessage.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -0,0 +1,61 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "DeathMessage.h"
+
+#include "core/CoreIncludes.h"
+#include "objects/infos/PlayerInfo.h"
+
+namespace orxonox
+{
+ CreateFactory(DeathMessage);
+
+ DeathMessage::DeathMessage(BaseObject* creator) : FadeoutText(creator)
+ {
+ RegisterObject(DeathMessage);
+
+ this->owner_ = 0;
+
+ this->setDelay(2.0f);
+ this->setFadeouttime(0.5f);
+ }
+
+ void DeathMessage::deathmessage(const GametypeInfo* gtinfo, const std::string& message)
+ {
+ if (this->owner_ && this->owner_->getGametypeInfo() == gtinfo)
+ this->setCaption(message);
+ }
+
+ void DeathMessage::changedOwner()
+ {
+ SUPER(DeathMessage, changedOwner);
+
+ this->owner_ = dynamic_cast<PlayerInfo*>(this->getOwner());
+ }
+}
Property changes on: trunk/src/orxonox/overlays/hud/DeathMessage.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/src/orxonox/overlays/hud/DeathMessage.h
===================================================================
--- trunk/src/orxonox/overlays/hud/DeathMessage.h (rev 0)
+++ trunk/src/orxonox/overlays/hud/DeathMessage.h 2009-05-27 23:58:22 UTC (rev 3099)
@@ -0,0 +1,53 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _DeathMessage_H__
+#define _DeathMessage_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "overlays/FadeoutText.h"
+#include "objects/GametypeMessageListener.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport DeathMessage : public FadeoutText, public GametypeMessageListener
+ {
+ public:
+ DeathMessage(BaseObject* creator);
+ virtual ~DeathMessage() {}
+
+ virtual void changedOwner();
+
+ void deathmessage(const GametypeInfo* gtinfo, const std::string& message);
+
+ private:
+ PlayerInfo* owner_;
+ };
+}
+#endif /* _DeathMessage_H__ */
Property changes on: trunk/src/orxonox/overlays/hud/DeathMessage.h
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/src/orxonox/overlays/hud/KillMessage.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/KillMessage.cc (rev 0)
+++ trunk/src/orxonox/overlays/hud/KillMessage.cc 2009-05-27 23:58:22 UTC (rev 3099)
@@ -0,0 +1,61 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "KillMessage.h"
+
+#include "core/CoreIncludes.h"
+#include "objects/infos/PlayerInfo.h"
+
+namespace orxonox
+{
+ CreateFactory(KillMessage);
+
+ KillMessage::KillMessage(BaseObject* creator) : FadeoutText(creator)
+ {
+ RegisterObject(KillMessage);
+
+ this->owner_ = 0;
+
+ this->setDelay(2.0f);
+ this->setFadeouttime(0.5f);
+ }
+
+ void KillMessage::killmessage(const GametypeInfo* gtinfo, const std::string& message)
+ {
+ if (this->owner_ && this->owner_->getGametypeInfo() == gtinfo)
+ this->setCaption(message);
+ }
+
+ void KillMessage::changedOwner()
+ {
+ SUPER(KillMessage, changedOwner);
+
+ this->owner_ = dynamic_cast<PlayerInfo*>(this->getOwner());
+ }
+}
Property changes on: trunk/src/orxonox/overlays/hud/KillMessage.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/src/orxonox/overlays/hud/KillMessage.h
===================================================================
--- trunk/src/orxonox/overlays/hud/KillMessage.h (rev 0)
+++ trunk/src/orxonox/overlays/hud/KillMessage.h 2009-05-27 23:58:22 UTC (rev 3099)
@@ -0,0 +1,53 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _KillMessage_H__
+#define _KillMessage_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "overlays/FadeoutText.h"
+#include "objects/GametypeMessageListener.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport KillMessage : public FadeoutText, public GametypeMessageListener
+ {
+ public:
+ KillMessage(BaseObject* creator);
+ virtual ~KillMessage() {}
+
+ virtual void changedOwner();
+
+ void killmessage(const GametypeInfo* gtinfo, const std::string& message);
+
+ private:
+ PlayerInfo* owner_;
+ };
+}
+#endif /* _KillMessage_H__ */
Property changes on: trunk/src/orxonox/overlays/hud/KillMessage.h
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the Orxonox-commit
mailing list