[Orxonox-commit 6624] r11264 - code/branches/HUD_HS16/src/modules/overlays/hud

patricwi at orxonox.net patricwi at orxonox.net
Fri Nov 4 13:08:00 CET 2016


Author: patricwi
Date: 2016-11-04 13:08:00 +0100 (Fri, 04 Nov 2016)
New Revision: 11264

Added:
   code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc
   code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h
Log:
added new files HUDPickupItem

Added: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc	                        (rev 0)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc	2016-11-04 12:08:00 UTC (rev 11264)
@@ -0,0 +1,216 @@
+/*
+ *   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 "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+#include "core/class/Super.h"
+
+namespace orxonox
+{
+    RegisterClass(HUDPickupItem);
+
+    HUDPickupItem::HUDPickupItem(Context* context) : OrxonoxOverlay(context)
+    {
+        RegisterObject(HUDPickupItem);
+
+        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDPickupItem" + getUniqueNumberString()));
+        overlayElement_->setMaterialName("Orxonox/WSHUD_Weapon");   //TODO be switched
+        overlayElement_->setPosition(0.0f,0.0f);
+        overlayElement_->setDimensions(1.0f,1.0f);
+        this->background_->addChild(overlayElement_);
+    }
+
+    HUDPickupItem::~HUDPickupItem()
+    {
+        if (this->isInitialized())
+        {
+            destroyHUDChilds();
+        }
+    }
+
+    // void HUDWeapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    // {
+    //     SUPER(HUDWeapon, XMLPort, xmlelement, mode);
+
+    //     XMLPortParam(HUDWeapons, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlelement, mode);
+    //     XMLPortParam(HUDWeapons, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlelement, mode);
+    // }
+
+    // void HUDWeapon::tick(float dt)
+    // {
+    //     SUPER(HUDWeapon, tick, dt);
+
+    //     if (!weapon_)
+    //     {
+    //         // TODO: destroy this HUD id the Weapon does no more exist. (Wehen the weak pointer is null)
+    //     }
+    // }    
+
+    // void HUDWeapon::positionChanged()
+    // {
+    //     OrxonoxOverlay::positionChanged();
+
+    //     positionHUDChilds();
+    // }
+
+    // void HUDWeapon::sizeChanged()
+    // {
+    //     OrxonoxOverlay::sizeChanged();
+
+    //     positionHUDChilds();
+    // }
+
+    // void HUDWeapon::changedOwner()
+    // {
+    //     SUPER(HUDWeapon, changedOwner);
+
+    //     this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
+
+    //     updateWeaponModeList();
+    // }
+
+    // void HUDWeapon::changedOverlayGroup()
+    // {
+    //     SUPER(HUDWeapon, changedOverlayGroup);
+    // }   
+
+    // void HUDWeapon::changedVisibility()
+    // {
+    //     SUPER(HUDWeapon, changedVisibility);
+
+    //     bool visible = this->isVisible();
+
+    //     for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_)
+    //     {
+    //         hudWeaponMode->changedVisibility(); //inform all Child Overlays that our visibility has changed
+    //         hudWeaponMode->setVisible(visible);
+    //     }
+    // }
+
+    // void HUDWeapon::changedName()
+    // {
+    //     SUPER(HUDWeapon, changedName);
+    // }
+
+    // void HUDWeapon::setWeapon(Weapon* weapon)
+    // {
+    //     weapon_ = weapon;
+
+    //     if (!weapon_)
+    //     {
+    //         return;
+    //     }
+
+    //     updateWeaponModeList();
+    // }
+
+    // void HUDWeapon::updateWeaponModeList()
+    // {
+    //     if (owner_ == nullptr || weapon_ == nullptr)
+    //     {
+    //         return;
+    //     }
+            
+    //     destroyHUDChilds();
+
+    //     updateSize();
+    //     createHUDChilds();
+    //     positionHUDChilds();
+    // }  
+
+    // void HUDWeapon::createHUDChilds()
+    // {
+    //     if (weapon_ == nullptr)
+    //     {
+    //         return;
+    //     }
+
+    //     int positionIndex = 0;
+
+    //     for (const auto& mapEntry : weapon_->getAllWeaponmodes())
+    //     {
+    //         HUDWeaponMode* hudWeaponMode = new HUDWeaponMode(this->getContext());
+    //         hudWeaponMode->setOwner(owner_);
+    //         hudWeaponMode->setOverlayGroup(this->getOverlayGroup());
+    //         hudWeaponMode->setVisible(this->isVisible());
+    //         hudWeaponMode->setWeaponMode(mapEntry.second);
+    //         hudWeaponMode->setWeaponIndex(this->weaponIndex_);                    
+    //         hudWeaponMode->setAspectCorrection(false);
+    //         hudWeaponMode->setPickPoint(Vector2(0.0f,0.0f));
+
+    //         hudWeaponModes_.push_back(hudWeaponMode);
+
+    //         ++ positionIndex;
+    //     }
+    // }      
+
+    // void HUDWeapon::positionHUDChilds()
+    // {
+    //     int positionIndex = 0;
+
+    //     for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_)
+    //     {
+    //         hudWeaponMode->setPositionOffset(this->positionOffset_);
+    //         hudWeaponMode->setWeaponModeIndex(positionIndex);
+    //         hudWeaponMode->setWeaponIndex(this->weaponIndex_);
+    //         hudWeaponMode->setWeaponModeHUDActualSize(this->weaponModeHUDActualSize_);
+
+    //         ++ positionIndex;
+    //     }
+    // }  
+
+    // void HUDWeapon::destroyHUDChilds()
+    // {
+    //     for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_)
+    //     {
+    //         hudWeaponMode->destroy();
+    //     } 
+
+    //     hudWeaponModes_.clear();
+    // }
+
+    // void HUDWeapon::updateSize()
+    // {
+    //     if (weapon_ != nullptr)
+    //     {
+    //         this->setSize(Vector2(weaponModeHUDActualSize_.x,weaponModeHUDActualSize_.y*weapon_->getAllWeaponmodes().size()));
+    //         updatePosition();
+    //     }        
+    // }
+
+    // void HUDWeapon::updatePosition()
+    // {
+    //     if (weapon_ != nullptr)
+    //     {
+    //         this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,0.0f) + this->positionOffset_);
+    //     }        
+    // }       
+}

Added: code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h
===================================================================
--- code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h	                        (rev 0)
+++ code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h	2016-11-04 12:08:00 UTC (rev 11264)
@@ -0,0 +1,56 @@
+
+#ifndef _HUDPickupItem_H__
+#define _HUDPickupItem_H__
+
+#include "overlays/OverlaysPrereqs.h"
+
+#include <map>
+#include <vector>
+#include <string>
+
+#include <OgreOverlayManager.h>
+#include <OgrePanelOverlayElement.h> 
+
+#include "overlays/OrxonoxOverlay.h"
+#include "tools/interfaces/Tickable.h"
+#include "worldentities/pawns/Pawn.h"
+#include "overlays/OverlayGroup.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponMode.h"
+#include "HUDWeaponMode.h"
+
+namespace orxonox
+{
+    class _OverlaysExport HUDPickupItem : public OrxonoxOverlay, public Tickable
+    {
+    public:
+        HUDPickupItem(Context* context);
+        virtual ~HUDPickupItem();
+
+        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+        virtual void tick(float dt) override;
+        virtual void changedOwner() override;
+        virtual void changedOverlayGroup() override;
+        virtual void changedVisibility() override;
+        virtual void changedName() override;
+        virtual void positionChanged() override;
+        virtual void sizeChanged() override;
+
+        void setPickup(Pickup* pickup);     
+
+    private:
+        // void createHUDChilds();
+        // void positionHUDChilds();
+        // void destroyHUDChilds();
+        // void updateWeaponModeList();
+        // void updateSize();
+        // void updatePosition();
+
+        WeakPtr<Pawn> owner_;
+        WeakPtr<Pickup> pickup_;
+
+        Ogre::PanelOverlayElement* overlayElement_;
+    };
+}
+
+#endif /* _HUDWeapon_H__ */
\ No newline at end of file




More information about the Orxonox-commit mailing list