[Orxonox-commit 6238] r10895 - in code/branches/hoverHS15: data/levels data/overlays src/modules/hover
bucyril at orxonox.net
bucyril at orxonox.net
Mon Nov 30 15:55:02 CET 2015
Author: bucyril
Date: 2015-11-30 15:55:02 +0100 (Mon, 30 Nov 2015)
New Revision: 10895
Added:
code/branches/hoverHS15/data/overlays/HoverHUD.oxo
code/branches/hoverHS15/src/modules/hover/FlagHUD.cc
code/branches/hoverHS15/src/modules/hover/FlagHUD.h
code/branches/hoverHS15/src/modules/hover/TimeHUD.cc
code/branches/hoverHS15/src/modules/hover/TimeHUD.h
Modified:
code/branches/hoverHS15/data/levels/Hover.oxw
code/branches/hoverHS15/src/modules/hover/CMakeLists.txt
code/branches/hoverHS15/src/modules/hover/Hover.cc
Log:
Added HUD and stuff
Modified: code/branches/hoverHS15/data/levels/Hover.oxw
===================================================================
--- code/branches/hoverHS15/data/levels/Hover.oxw 2015-11-30 14:47:42 UTC (rev 10894)
+++ code/branches/hoverHS15/data/levels/Hover.oxw 2015-11-30 14:55:02 UTC (rev 10895)
@@ -14,6 +14,7 @@
<?lua
include("templates/spaceshipPirate.oxt")
include("templates/spaceshipHover.oxt")
+ include("overlays/HoverHUD.oxo")
?>
<Level
Added: code/branches/hoverHS15/data/overlays/HoverHUD.oxo
===================================================================
--- code/branches/hoverHS15/data/overlays/HoverHUD.oxo (rev 0)
+++ code/branches/hoverHS15/data/overlays/HoverHUD.oxo 2015-11-30 14:55:02 UTC (rev 10895)
@@ -0,0 +1,45 @@
+<Template name="HoverHUD">
+ <OverlayGroup name="HoverHUD" scale = "1, 1">
+ </OverlayGroup>
+</Template>
+
+
+<Template name="spaceshiphoverhud">
+ <OverlayGroup name = "spaceshiphoverhud" scale = "1, 1">
+ <TimeHUD
+ name = "Timer"
+ position = "0.95, 0.02"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.05
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "right"
+ />
+
+ <FlagHUD
+ position = "0.05, 0.02"
+ size = "0.18, 0.05"
+ />
+
+ <HUDHealthBar
+ name = "HealthBar1"
+ background = "Orxonox/HealthBarBackground"
+ size = "0.35, 0.0875"
+ position = "0.0 , 0.97"
+ pickpoint = "0, 1"
+ bartexture = "healthbar_bar.png"
+ textfont = "VeraMono"
+ textusebarcolour = true
+ textsize = 0.039
+ textoffset = "0.315, 0.05"
+ textpickpoint = "0, 0"
+ textalign = "right"
+ correctaspect = false
+ textcorrectaspect = false
+ >
+ <BarColour position = 0.0 colour = "0.7,0.2,0.2" />
+ <BarColour position = 0.5 colour = "0.7,0.7,0.2" />
+ <BarColour position = 1.0 colour = "0.2,0.7,0.2" />
+ </HUDHealthBar>
+ </OverlayGroup>
+</Template>
Modified: code/branches/hoverHS15/src/modules/hover/CMakeLists.txt
===================================================================
--- code/branches/hoverHS15/src/modules/hover/CMakeLists.txt 2015-11-30 14:47:42 UTC (rev 10894)
+++ code/branches/hoverHS15/src/modules/hover/CMakeLists.txt 2015-11-30 14:55:02 UTC (rev 10895)
@@ -3,6 +3,8 @@
HoverShip.cc
HoverWall.cc
HoverOrigin.cc
+TimeHUD.cc
+FlagHUD.cc
HoverFlag.cc
)
Added: code/branches/hoverHS15/src/modules/hover/FlagHUD.cc
===================================================================
--- code/branches/hoverHS15/src/modules/hover/FlagHUD.cc (rev 0)
+++ code/branches/hoverHS15/src/modules/hover/FlagHUD.cc 2015-11-30 14:55:02 UTC (rev 10895)
@@ -0,0 +1,94 @@
+/*
+ * 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:
+ * Cyrill Burgener
+ *
+ */
+
+#include "FlagHUD.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreMaterialManager.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+ RegisterClass(FlagHUD);
+
+ FlagHUD::FlagHUD(Context* context) : OrxonoxOverlay(context)
+ {
+ RegisterObject(FlagHUD);
+
+ this->panel_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+ .createOverlayElement("Panel", "FlagHUD_Panel_" + getUniqueNumberString()));
+ this->panel_->setMaterialName("Hover/Flag");
+ this->overlay_->add2D(this->panel_);
+
+ this->flagCount_ = 5;
+ setFlagCount(5);
+ }
+
+ void FlagHUD::setFlagCount(int flagCount) {
+ this->panel_->setDimensions(
+ this->panel_->_getRelativeWidth() / ((float) flagCount_) * ((float) flagCount),
+ this->panel_->_getRelativeHeight()
+ );
+ this->panel_->setTiling(flagCount, 1.0f);
+
+ this->flagCount_ = flagCount;
+ }
+
+ /*void FlagHUD::tick(float dt)
+ {
+ SUPER(FlagHUD, tick, dt);
+
+ if (this->hoverGame)
+ {
+ setFlagCount(2);
+ }
+ }*/
+
+ void FlagHUD::changedOwner()
+ {
+ SUPER(FlagHUD, changedOwner);
+
+ if (this->getOwner() && this->getOwner()->getGametype())
+ {
+ this->hoverGame = orxonox_cast<Hover*>(this->getOwner()->getGametype());
+ }
+ else
+ {
+ this->hoverGame = 0;
+ }
+ }
+
+ FlagHUD::~FlagHUD()
+ {
+ if (this->isInitialized())
+ {
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->panel_);
+ }
+ }
+}
Added: code/branches/hoverHS15/src/modules/hover/FlagHUD.h
===================================================================
--- code/branches/hoverHS15/src/modules/hover/FlagHUD.h (rev 0)
+++ code/branches/hoverHS15/src/modules/hover/FlagHUD.h 2015-11-30 14:55:02 UTC (rev 10895)
@@ -0,0 +1,58 @@
+/*
+ * 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:
+ * Cyrill Burgener
+ *
+ */
+
+#ifndef _FlagHUD_H__
+#define _FlagHUD_H__
+
+#include "overlays/OverlaysPrereqs.h"
+
+#include "util/Math.h"
+#include "util/OgreForwardRefs.h"
+#include "core/BaseObject.h"
+#include "overlays/OrxonoxOverlay.h"
+#include "Hover.h"
+
+namespace orxonox
+{
+ class _OverlaysExport FlagHUD : public OrxonoxOverlay //, public Tickable
+ {
+ public:
+ FlagHUD(Context* context);
+ virtual ~FlagHUD();
+
+ //virtual void tick(float dt);
+ virtual void changedOwner();
+
+ virtual void setFlagCount(int flagCount);
+
+
+ private:
+ Hover* hoverGame;
+ Ogre::PanelOverlayElement* panel_;
+ int flagCount_;
+ };
+}
+#endif /* _FlagHUD_H__ */
Modified: code/branches/hoverHS15/src/modules/hover/Hover.cc
===================================================================
--- code/branches/hoverHS15/src/modules/hover/Hover.cc 2015-11-30 14:47:42 UTC (rev 10894)
+++ code/branches/hoverHS15/src/modules/hover/Hover.cc 2015-11-30 14:55:02 UTC (rev 10895)
@@ -101,7 +101,7 @@
{
RegisterObject(Hover);
- //this->setHUDTemplate("HoverHUD");
+ this->setHUDTemplate("HoverHUD");
}
Added: code/branches/hoverHS15/src/modules/hover/TimeHUD.cc
===================================================================
--- code/branches/hoverHS15/src/modules/hover/TimeHUD.cc (rev 0)
+++ code/branches/hoverHS15/src/modules/hover/TimeHUD.cc 2015-11-30 14:55:02 UTC (rev 10895)
@@ -0,0 +1,114 @@
+/*
+ * 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:
+ * Cyrill Burgener
+ *
+ */
+
+#include "TimeHUD.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+#include "Hover.h"
+
+namespace orxonox
+{
+ RegisterClass(TimeHUD);
+
+ TimeHUD::TimeHUD(Context* context) : OverlayText(context)
+ {
+ RegisterObject(TimeHUD);
+
+ this->_time = 0.0f;
+ this->_running = false;
+ this->hoverGame = 0;
+ }
+
+ void TimeHUD::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(TimeHUD, XMLPort, xmlelement, mode);
+ }
+
+ inline std::string getTimeString(float time) {
+ std::ostringstream ss;
+
+ int h = ((int) (time * 100.0f)) % 100;
+ int s = ((int) time) % 60;
+ int m = (int) (time / 60.0f);
+
+ ss << m << ":";
+
+ if(s < 10) {
+ ss << 0;
+ }
+ ss << s << ":";
+
+ if(h < 10) {
+ ss << 0;
+ }
+ ss << h << "s";
+ return ss.str();
+ }
+
+ void TimeHUD::tick(float dt)
+ {
+ SUPER(TimeHUD, tick, dt);
+
+ if(this->_running) {
+ this->_time += dt;
+ }
+ if (this->hoverGame)
+ {
+ this->setCaption(getTimeString(this->_time));
+ }
+
+ }
+
+ void TimeHUD::changedOwner()
+ {
+ SUPER(TimeHUD, changedOwner);
+
+ if (this->getOwner() && this->getOwner()->getGametype())
+ {
+ this->hoverGame = orxonox_cast<Hover*>(this->getOwner()->getGametype());
+ }
+ else
+ {
+ this->hoverGame = 0;
+ }
+ }
+
+ void TimeHUD::setRunning(bool running)
+ {
+ this->_running = running;
+ }
+
+ bool TimeHUD::isRunning() {
+ return this->_running;
+ }
+
+ void TimeHUD::reset()
+ {
+ this->_time = 0;
+ }
+}
Added: code/branches/hoverHS15/src/modules/hover/TimeHUD.h
===================================================================
--- code/branches/hoverHS15/src/modules/hover/TimeHUD.h (rev 0)
+++ code/branches/hoverHS15/src/modules/hover/TimeHUD.h 2015-11-30 14:55:02 UTC (rev 10895)
@@ -0,0 +1,56 @@
+/*
+ * 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:
+ * Cyrill Burgener
+ *
+ */
+
+#ifndef _TimeHUD_H__
+#define _TimeHUD_H__
+
+#include "hover/HoverPrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+ class _HoverExport TimeHUD : public OverlayText, public Tickable
+ {
+ public:
+ TimeHUD(Context* context);
+
+ virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void changedOwner();
+
+ virtual void setRunning(bool running);
+ virtual bool isRunning();
+ virtual void reset();
+
+ private:
+ Hover* hoverGame;
+ float _time;
+ bool _running;
+ };
+}
+#endif /* _TimeHUD_H__ */
More information about the Orxonox-commit
mailing list