[Orxonox-commit 7088] r11705 - in code/trunk: data/overlays src/modules/overlays src/modules/overlays/hud
landauf at orxonox.net
landauf at orxonox.net
Sat Jan 6 15:13:26 CET 2018
Author: landauf
Date: 2018-01-06 15:13:26 +0100 (Sat, 06 Jan 2018)
New Revision: 11705
Removed:
code/trunk/src/modules/overlays/hud/HUDPickupItem.cc
code/trunk/src/modules/overlays/hud/HUDPickupItem.h
Modified:
code/trunk/data/overlays/HUDPickupTemplate.oxo
code/trunk/data/overlays/HUDTemplates3.oxo
code/trunk/src/modules/overlays/OverlaysPrereqs.h
code/trunk/src/modules/overlays/hud/CMakeLists.txt
code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc
code/trunk/src/modules/overlays/hud/HUDPickupSystem.h
Log:
[HUD_HS16] removed HUDPickupItem as it is not really necessary (it's just an ogre overlay). also fixed several memory-leaks and some issues with positioning and visibility of the pickup items
Modified: code/trunk/data/overlays/HUDPickupTemplate.oxo
===================================================================
--- code/trunk/data/overlays/HUDPickupTemplate.oxo 2018-01-06 02:16:00 UTC (rev 11704)
+++ code/trunk/data/overlays/HUDPickupTemplate.oxo 2018-01-06 14:13:26 UTC (rev 11705)
@@ -186,7 +186,9 @@
<HUDPickupSystem
name = "PickupSystem"
+ background = "PickupBar"
correctaspect = true
+ size = "0.70, 0.15"
position = "0.32, 0.81"
pickpoint = "0.0, 0.0"
visible = "true"
Modified: code/trunk/data/overlays/HUDTemplates3.oxo
===================================================================
--- code/trunk/data/overlays/HUDTemplates3.oxo 2018-01-06 02:16:00 UTC (rev 11704)
+++ code/trunk/data/overlays/HUDTemplates3.oxo 2018-01-06 14:13:26 UTC (rev 11705)
@@ -186,7 +186,9 @@
<HUDPickupSystem
name = "PickupSystem"
+ background = "PickupBar"
correctaspect = true
+ size = "0.70, 0.15"
position = "0.32, 0.81"
pickpoint = "0.0, 0.0"
visible = "false"
Modified: code/trunk/src/modules/overlays/OverlaysPrereqs.h
===================================================================
--- code/trunk/src/modules/overlays/OverlaysPrereqs.h 2018-01-06 02:16:00 UTC (rev 11704)
+++ code/trunk/src/modules/overlays/OverlaysPrereqs.h 2018-01-06 14:13:26 UTC (rev 11705)
@@ -104,7 +104,6 @@
class PauseNotice;
class TeamBaseMatchScore;
class HUDPickupSystem;
- class HUDPickupItem;
// stats
class CreateLines;
Modified: code/trunk/src/modules/overlays/hud/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/overlays/hud/CMakeLists.txt 2018-01-06 02:16:00 UTC (rev 11704)
+++ code/trunk/src/modules/overlays/hud/CMakeLists.txt 2018-01-06 14:13:26 UTC (rev 11705)
@@ -13,7 +13,6 @@
HUDWeaponMode.cc
HUDWeapon.cc
HUDWeaponSystem.cc
- HUDPickupItem.cc
HUDPickupSystem.cc
ChatOverlay.cc
AnnounceMessage.cc
Deleted: code/trunk/src/modules/overlays/hud/HUDPickupItem.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDPickupItem.cc 2018-01-06 02:16:00 UTC (rev 11704)
+++ code/trunk/src/modules/overlays/hud/HUDPickupItem.cc 2018-01-06 14:13:26 UTC (rev 11705)
@@ -1,74 +0,0 @@
-/*
- * 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:
- * Patrick Wintermeyer
- * Co-authors:
- * ...
- *
- */
-
-#include "HUDPickupItem.h"
-
-#include <string>
-
-
-#include <OgreOverlayManager.h>
-#include <OgrePanelOverlayElement.h>
-
-#include "core/CoreIncludes.h"
-#include "core/class/Super.h"
-#include "util/StringUtils.h"
-#include "HUDPickupItem.h"
-
-namespace orxonox
-{
- RegisterClass(HUDPickupItem);
-
- HUDPickupItem::HUDPickupItem(Context* context) : OrxonoxOverlay(context)
- {
- RegisterObject(HUDPickupItem);
-
- std::string name = "HUDPickupItem" + getUniqueNumberString();
- overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name ));
-
- overlayElement_->setDimensions(0.075f,0.08f);
-
- }
-
- HUDPickupItem::~HUDPickupItem()
- {
- }
-
- void HUDPickupItem::initializeMaterial(const std::string& s, float x, float y)
- {
- overlayElement_->setMaterialName(s);
- overlayElement_->setPosition(x, y);
- overlayElement_->show();
- this->background_->addChild(overlayElement_);
- }
-
- void HUDPickupItem::hideMe()
- {
- //overlayElement_->hide();
- this->background_->removeChild(overlayElement_->getName());
- }
-}
Deleted: code/trunk/src/modules/overlays/hud/HUDPickupItem.h
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDPickupItem.h 2018-01-06 02:16:00 UTC (rev 11704)
+++ code/trunk/src/modules/overlays/hud/HUDPickupItem.h 2018-01-06 14:13:26 UTC (rev 11705)
@@ -1,26 +0,0 @@
-
-#ifndef _HUDPickupItem_H__
-#define _HUDPickupItem_H__
-
-#include "overlays/OverlaysPrereqs.h"
-
-#include "util/OgreForwardRefs.h"
-#include "overlays/OrxonoxOverlay.h"
-
-namespace orxonox
-{
- class _OverlaysExport HUDPickupItem : public OrxonoxOverlay
- {
- public:
- HUDPickupItem(Context* context);
- virtual ~HUDPickupItem();
-
- void initializeMaterial(const std::string& s, float x, float y);
- void hideMe();
-
- private:
- Ogre::PanelOverlayElement* overlayElement_;
- };
-}
-
-#endif
Modified: code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc 2018-01-06 02:16:00 UTC (rev 11704)
+++ code/trunk/src/modules/overlays/hud/HUDPickupSystem.cc 2018-01-06 14:13:26 UTC (rev 11705)
@@ -30,13 +30,13 @@
#include <string>
#include <OgreOverlayManager.h>
+#include <OgreOverlayElement.h>
#include <OgrePanelOverlayElement.h>
#include "core/CoreIncludes.h"
#include "core/class/Super.h"
-#include "util/StringUtils.h"
+#include "util/Convert.h"
#include "HUDPickupSystem.h"
-#include "HUDPickupItem.h"
#include "pickup/PickupManager.h"
namespace orxonox
@@ -47,15 +47,29 @@
{
RegisterObject(HUDPickupSystem);
- overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupSystem" + getUniqueNumberString()));
- overlayElement_->setMaterialName("PickupBar");
- overlayElement_->setPosition(0.0f,0.0f);
- overlayElement_->setDimensions(0.70f,0.15f);
- this->background_->addChild(overlayElement_);
+ const float offsetX = 0.02f;
+ const float offsetY = 0.05f;
+ const float x = 0.2;
+ const float y = 0.5f;
+
+ for (int index = 0; index < 10; ++index)
+ {
+ int row = index / 5;
+ int column = index % 5;
+
+ std::string name = "HUDPickupItem" + multi_cast<std::string>(index);
+ Ogre::OverlayElement* item = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name);
+
+ item->setDimensions(0.16, 0.4);
+ item->setPosition(offsetX + column*x, offsetY + row*y);
+ this->items_.push_back(item);
+ }
}
HUDPickupSystem::~HUDPickupSystem()
{
+ for (Ogre::OverlayElement* item : items_)
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(item);
}
void HUDPickupSystem::sizeChanged()
@@ -68,33 +82,23 @@
{
SUPER(HUDPickupSystem, tick, dt);
- //hide all pickup symbols in HUD and delete from local map
- for(HUDPickupItem* item : items_)
- {
- item->hideMe();
- }
-
- items_.clear();
- assert(items_.empty()); //items_ must be empty now
-
- //add to local map and place on screen
- const float offsetX = 0.345f;
- const float offsetY = 0.82f;
- const float x = 0.102f;
- const float y = 0.075f;
-
int numPickups = PickupManager::getInstance().getNumPickups();
- for (int index = 0; index < numPickups; ++index)
+ for (size_t index = 0; index < this->items_.size(); ++index)
{
- int row = index / 5;
- int column = index % 5;
+ Ogre::OverlayElement* item = this->items_[index];
- const PickupInventoryContainer* container = PickupManager::getInstance().popPickup();
-
- HUDPickupItem* item = new HUDPickupItem(this->getContext());
- item->initializeMaterial(this->getIcon(container->representationName), offsetX+column*x, offsetY+row*y);
- item->setOverlayGroup(this->getOverlayGroup());
- items_.push_back(item);
+ if (static_cast<int>(index) < numPickups)
+ {
+ const PickupInventoryContainer* container = PickupManager::getInstance().popPickup();
+ item->setMaterialName(this->getIcon(container->representationName));
+ if (!item->getParent())
+ this->background_->addChild(item);
+ }
+ else
+ {
+ if (item->getParent())
+ this->background_->removeChild(item->getName());
+ }
}
}
Modified: code/trunk/src/modules/overlays/hud/HUDPickupSystem.h
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDPickupSystem.h 2018-01-06 02:16:00 UTC (rev 11704)
+++ code/trunk/src/modules/overlays/hud/HUDPickupSystem.h 2018-01-06 14:13:26 UTC (rev 11705)
@@ -50,11 +50,9 @@
virtual void sizeChanged() override;
private:
-
std::string getIcon(std::string repName);
- std::vector<HUDPickupItem*> items_;
- Ogre::PanelOverlayElement* overlayElement_;
+ std::vector<Ogre::OverlayElement*> items_;
};
}
More information about the Orxonox-commit
mailing list