[Orxonox-commit 5206] r9870 - in code/branches/levelMichael: data/levels src/modules/overlays src/modules/overlays/hud
jo at orxonox.net
jo at orxonox.net
Tue Dec 3 22:02:24 CET 2013
Author: jo
Date: 2013-12-03 22:02:24 +0100 (Tue, 03 Dec 2013)
New Revision: 9870
Added:
code/branches/levelMichael/src/modules/overlays/hud/CountDown.cc
code/branches/levelMichael/src/modules/overlays/hud/CountDown.h
Modified:
code/branches/levelMichael/data/levels/Spacefight.oxw
code/branches/levelMichael/data/levels/quests.oxw
code/branches/levelMichael/src/modules/overlays/OverlaysPrereqs.h
code/branches/levelMichael/src/modules/overlays/hud/CMakeLists.txt
Log:
Adding a countdown to the SpaceFight Level.
Modified: code/branches/levelMichael/data/levels/Spacefight.oxw
===================================================================
--- code/branches/levelMichael/data/levels/Spacefight.oxw 2013-12-03 20:02:04 UTC (rev 9869)
+++ code/branches/levelMichael/data/levels/Spacefight.oxw 2013-12-03 21:02:24 UTC (rev 9870)
@@ -61,6 +61,24 @@
<?lua include("includes/pickups.oxi") ?>
<Script code="showGUI NotificationLayer false true" needsGraphics="true" />
+ <OverlayGroup name="spacefightHUD" scale = "1, 1">
+ <CountDown
+ position = "0.49, 0.05"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.06
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "right"
+ counter = "10.0"
+ active = "false"
+ >
+ <events>
+ <activity>
+ <EventListener event="spawntrigger2" />
+ </activity>
+ </events>
+ </CountDown>
+ </OverlayGroup>
<!-- SPAWNTRIGGER -->
Modified: code/branches/levelMichael/data/levels/quests.oxw
===================================================================
--- code/branches/levelMichael/data/levels/quests.oxw 2013-12-03 20:02:04 UTC (rev 9869)
+++ code/branches/levelMichael/data/levels/quests.oxw 2013-12-03 21:02:24 UTC (rev 9870)
@@ -1,3 +1,4 @@
+<!-- -->
<LevelInfo
name = "Quests showcase"
description = "Level to test and showcase quests."
Modified: code/branches/levelMichael/src/modules/overlays/OverlaysPrereqs.h
===================================================================
--- code/branches/levelMichael/src/modules/overlays/OverlaysPrereqs.h 2013-12-03 20:02:04 UTC (rev 9869)
+++ code/branches/levelMichael/src/modules/overlays/OverlaysPrereqs.h 2013-12-03 21:02:24 UTC (rev 9870)
@@ -79,6 +79,7 @@
class AnnounceMessage;
class BarColour;
class ChatOverlay;
+ class CountDown;
class DeathMessage;
class GametypeFadingMessage;
class GametypeStaticMessage;
Modified: code/branches/levelMichael/src/modules/overlays/hud/CMakeLists.txt
===================================================================
--- code/branches/levelMichael/src/modules/overlays/hud/CMakeLists.txt 2013-12-03 20:02:04 UTC (rev 9869)
+++ code/branches/levelMichael/src/modules/overlays/hud/CMakeLists.txt 2013-12-03 21:02:24 UTC (rev 9870)
@@ -17,4 +17,5 @@
LastManStandingInfos.cc
PauseNotice.cc
LastTeamStandingInfos.cc
+ CountDown.cc
)
Added: code/branches/levelMichael/src/modules/overlays/hud/CountDown.cc
===================================================================
--- code/branches/levelMichael/src/modules/overlays/hud/CountDown.cc (rev 0)
+++ code/branches/levelMichael/src/modules/overlays/hud/CountDown.cc 2013-12-03 21:02:24 UTC (rev 9870)
@@ -0,0 +1,111 @@
+/*
+ * 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:
+ * Johannes Ritz
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file CountDown.cc
+ @brief Countdown HUD element, counting down from CountDown::counter_ to zero.
+
+ In use it would like this:
+ @code
+ <OverlayGroup name="spacefightHUD" scale = "1, 1">
+ <CountDown
+ position = "0.49, 0.05"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.06
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "right"
+ counter = "10.0"
+ active = "false"
+ >
+ <events>
+ <activity>
+ <EventListener event="startcounting" />
+ </activity>
+ </events>
+ </CountDown>
+ </OverlayGroup>
+ @endcode
+ The counter is triggered by an event called "startcounting" and counts from 10 to 0.
+*/
+
+#include "CountDown.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "infos/PlayerInfo.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+ RegisterClass(CountDown);
+
+ CountDown::CountDown(Context* context) : OverlayText(context)
+ {
+ RegisterObject(CountDown);
+
+ this->owner_ = 0;
+ this->hasStopped_ = false;
+ }
+
+ CountDown::~CountDown()
+ {
+ }
+
+ void CountDown::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(CountDown, XMLPort, xmlelement, mode);
+ XMLPortParam(CountDown, "counter", setCounter, getCounter, xmlelement, mode).defaultValues(10);
+ }
+
+ void CountDown::tick(float dt)
+ {
+ SUPER(CountDown, tick, dt);
+ if (this->isActive() && !this->hasStopped_)
+ {
+ if (this->counter_ <= 0)
+ {
+ this->counter_ = 0;
+ this->hasStopped_ = true;
+ this->setCaption("");
+ }
+ else
+ {
+ this->counter_ -= dt;
+ this->setCaption(multi_cast<std::string>((int)this->counter_)); //TODO: evtl. initialize with +0.5f
+ }
+ }
+ }
+
+ void CountDown::changedOwner()
+ {
+ SUPER(CountDown, changedOwner);
+
+ this->owner_ = orxonox_cast<PlayerInfo*>(this->getOwner());
+ }
+}
Added: code/branches/levelMichael/src/modules/overlays/hud/CountDown.h
===================================================================
--- code/branches/levelMichael/src/modules/overlays/hud/CountDown.h (rev 0)
+++ code/branches/levelMichael/src/modules/overlays/hud/CountDown.h 2013-12-03 21:02:24 UTC (rev 9870)
@@ -0,0 +1,62 @@
+/*
+ * 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:
+ * Johannes Ritz
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _CountDown_H__
+#define _CountDown_H__
+
+#include "overlays/OverlaysPrereqs.h"
+
+#include "tools/interfaces/TimeFactorListener.h"
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+ class _OverlaysExport CountDown : public OverlayText, public Tickable
+ {
+ public:
+ CountDown(Context* context);
+ virtual ~CountDown();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void changedOwner();
+ virtual void tick(float dt);
+
+ inline void setCounter(float value)
+ { this->counter_ = value + 0.99f; }
+ inline float getCounter() const
+ { return this->counter_; }
+ protected:
+
+ private:
+ PlayerInfo* owner_;
+ float counter_;
+ bool hasStopped_;
+ };
+}
+#endif /* _CountDown_H__ */
More information about the Orxonox-commit
mailing list