Index: code/branches/fabienHS15/src/modules/overlays/hud/HUDWeapon.cc
===================================================================
--- code/branches/fabienHS15/src/modules/overlays/hud/HUDWeapon.cc	(revision 10715)
+++ code/branches/fabienHS15/src/modules/overlays/hud/HUDWeapon.cc	(revision 10721)
@@ -21,9 +21,7 @@
  *
  *   Author:
- *      Yuning Chai
- *      Felix Schulthess
+ *      Fabien Vultier
  *   Co-authors:
- *      Reto Grieder
- *      Wolfgang Roenninger
+ *      ...
  *
  */
@@ -48,4 +46,10 @@
         RegisterObject(HUDWeapon);
 
+        weaponModeHUDActualSize_ = Vector2(0.0f,0.0f);
+
+        weaponModes_ = NULL;
+        weaponIndex_ = 0;
+        hudWeaponModes_.clear();
+
         overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDWeapon" + getUniqueNumberString()));
         overlayElement_->setMaterialName("Orxonox/WSHUD_Weapon");
@@ -75,4 +79,9 @@
     {
         SUPER(HUDWeapon, tick, dt);
+
+        if (!weapon_)
+        {
+            // TODO: destroy this HUD id the Weapon does no more exist. (Wehen the weak pointer is NULL)
+        }
     }    
 
@@ -82,5 +91,12 @@
 
         positionHUDChilds();
-    }     
+    }
+
+    void HUDWeapon::sizeChanged()
+    {
+        OrxonoxOverlay::sizeChanged();
+
+        positionHUDChilds();
+    }
 
     void HUDWeapon::changedOwner()
@@ -131,17 +147,32 @@
         weaponModes_ = weapon_->getAllWeaponmodes();
 
+        updateSize();
         createHUDChilds();
-        positionHUDChilds();        
+        positionHUDChilds();
     }  
 
     void HUDWeapon::createHUDChilds()
     {
+        if (weaponModes_ == NULL)
+        {
+            return;
+        }
+
+        int positionIndex = 0;
+
         for (std::multimap<unsigned int, WeaponMode*>::iterator it = weaponModes_->begin(); it != weaponModes_->end(); ++it)
         {
             HUDWeaponMode* hudWeaponMode = new HUDWeaponMode(this->getContext());
             hudWeaponMode->setOwner(owner_);
+            hudWeaponMode->setOverlayGroup(this->getOverlayGroup());
             hudWeaponMode->setWeaponMode(it->second);
+            hudWeaponMode->setWeaponIndex(this->weaponIndex_);                    
+            hudWeaponMode->setAspectCorrection(false);
+            hudWeaponMode->setPickPoint(Vector2(0.0f,0.0f));
+
             hudWeaponModes_.push_back(hudWeaponMode);
-        }    
+
+            ++ positionIndex;
+        }
     }      
 
@@ -152,14 +183,11 @@
         for (std::vector<WeakPtr<HUDWeaponMode> >::iterator it = hudWeaponModes_.begin(); it != hudWeaponModes_.end(); ++it)
         {
-            (*it)->setOverlayGroup(this->getOverlayGroup());            
-            (*it)->setAspectCorrection(this->getAspectCorrection());
-            (*it)->setPosition(this->getPosition() + Vector2(0.0f,0.025f*positionIndex));
-            (*it)->setSize(Vector2(0.15f,0.025f));
-            (*it)->setPickPoint(Vector2(0.0f,0.0f));
-
-            ++ positionIndex;        
-        }
-
-        overlayElement_->setDimensions(1.0f,0.25f*hudWeaponModes_.size());
+            (*it)->setWeaponModeIndex(positionIndex);
+            (*it)->setWeaponIndex(this->weaponIndex_);
+            (*it)->setWeaponModeHUDActualSize(this->weaponModeHUDActualSize_);
+            (*it)->positionHUDChilds();
+
+            ++ positionIndex;
+        }
     }  
 
@@ -173,3 +201,20 @@
         hudWeaponModes_.clear();
     }
+
+    void HUDWeapon::updateSize()
+    {
+        if (weaponModes_ != NULL)
+        {
+            this->setSize(Vector2(weaponModeHUDActualSize_.x,weaponModeHUDActualSize_.y*weaponModes_->size()));
+            updatePosition();
+        }        
+    }
+
+    void HUDWeapon::updatePosition()
+    {
+        if (weaponModes_ != NULL)
+        {
+            this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,0.0f));
+        }        
+    }       
 }
Index: code/branches/fabienHS15/src/modules/overlays/hud/HUDWeapon.h
===================================================================
--- code/branches/fabienHS15/src/modules/overlays/hud/HUDWeapon.h	(revision 10715)
+++ code/branches/fabienHS15/src/modules/overlays/hud/HUDWeapon.h	(revision 10721)
@@ -65,13 +65,29 @@
         virtual void changedVisibility();
         virtual void changedName();
-        virtual void positionChanged(); 
+        virtual void positionChanged();
+        virtual void sizeChanged();
 
         virtual void setWeapon(Weapon* weapon);
 
+        inline void setWeaponModeHUDActualSize(Vector2 vector)
+            { weaponModeHUDActualSize_ = vector;
+              this->updateSize();
+            }
+        inline Vector2 getWeaponModeHUDActualSize() const
+            { return weaponModeHUDActualSize_; }
+        inline void setWeaponIndex(int index)
+            { weaponIndex_ = index;
+              this->updatePosition();
+            }
+
+        virtual void positionHUDChilds();
+
     private:
         virtual void createHUDChilds();
-        virtual void positionHUDChilds();
-        virtual void destroyHUDChilds();        
+        
+        virtual void destroyHUDChilds();
         virtual void updateWeaponModeList();
+        virtual void updateSize();
+        virtual void updatePosition();
 
         WeakPtr<Pawn> owner_;
@@ -81,5 +97,8 @@
         std::vector<WeakPtr<HUDWeaponMode> > hudWeaponModes_;
 
-        Ogre::PanelOverlayElement* overlayElement_;        
+        Ogre::PanelOverlayElement* overlayElement_;
+
+        Vector2 weaponModeHUDActualSize_;
+        int weaponIndex_;
     };
 }
Index: code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.cc
===================================================================
--- code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.cc	(revision 10715)
+++ code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.cc	(revision 10721)
@@ -49,4 +49,7 @@
         RegisterObject(HUDWeaponMode);
 
+        weaponIndex_ = 0;
+        weaponModeIndex_ = 0;
+
         overlayElementIcon_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDWeaponMode" + getUniqueNumberString()));
         overlayElementIcon_->setPosition(0.0f,0.0f);
@@ -80,9 +83,8 @@
         textOverlayLeft_->setPickPoint(Vector2(0.0f,0.0f));
         textOverlayLeft_->setVisible(true);
-        textOverlayLeft_->setAlignment(OverlayText::Left);
+        textOverlayLeft_->setAlignment(OverlayText::Center);
         textOverlayLeft_->setTextSize(0.02f);
         textOverlayLeft_->setColour(ColourValue(0.21,0.70,0.21,1.0));
-        textOverlayLeft_->setPosition(getPosition());
-        textOverlayLeft_->setAspectCorrection(this->getAspectCorrection());
+        textOverlayLeft_->setAspectCorrection(false);
         
         this->textOverlayRight_ = new OverlayText(this->getContext());
@@ -91,9 +93,8 @@
         textOverlayRight_->setPickPoint(Vector2(0.0f,0.0f));
         textOverlayRight_->setVisible(true);
-        textOverlayRight_->setAlignment(OverlayText::Left);
+        textOverlayRight_->setAlignment(OverlayText::Center);
         textOverlayRight_->setTextSize(0.02f);
         textOverlayRight_->setColour(ColourValue(0.21,0.70,0.21,1.0));
-        textOverlayRight_->setPosition(getPosition());
-        textOverlayRight_->setAspectCorrection(this->getAspectCorrection());        
+        textOverlayRight_->setAspectCorrection(false);
 
         materialNameState_ = "Orxonox/WSHUD_Reloading";
@@ -106,6 +107,11 @@
         if (this->isInitialized())
         {
-            //this->textOverlay_->destroy();            
-        }
+            //this->textOverlay_->destroy();
+        }
+    }
+
+    void HUDWeaponMode::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(HUDWeaponMode, XMLPort, xmlelement, mode);
     }
 
@@ -183,5 +189,12 @@
 
         positionHUDChilds();
-    }    
+    }
+
+    void HUDWeaponMode::sizeChanged()
+    {
+        OrxonoxOverlay::sizeChanged();
+
+        positionHUDChilds();
+    }
 
     void HUDWeaponMode::changedOwner()
@@ -190,6 +203,4 @@
 
         this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
-
-        //updateWeaponsList();
     }
 
@@ -206,5 +217,6 @@
         SUPER(HUDWeaponMode, changedVisibility);
 
-        //this->textOverlay_->setVisible(this->isVisible());
+        this->textOverlayLeft_->setVisible(this->isVisible());
+        this->textOverlayRight_->setVisible(this->isVisible());
     }
 
@@ -248,11 +260,32 @@
                 overlayElementMunition_->setMaterialName("Orxonox/WSHUD_MunitionSeparate");
             }
-        }      
+        }
     }
 
     void HUDWeaponMode::positionHUDChilds()
     {
-        textOverlayLeft_->setPosition(getPosition() + Vector2(0.06f,0.0f));
-        textOverlayRight_->setPosition(getPosition() + Vector2(0.105f,0.0f));
-    }  
+        Vector2 size = Vector2(getSize().x*45.0f/150.0f, getSize().y);
+        Vector2 offset1 = Vector2(getSize().x*82.5f/150.0f, 0.0f);
+        Vector2 offset2 = Vector2(getSize().x*127.5f/150.0f, 0.0f);
+
+        textOverlayLeft_->setPosition(getPosition() + offset1);
+        textOverlayRight_->setPosition(getPosition() + offset2);
+
+        textOverlayLeft_->setSize(size);
+        textOverlayRight_->setSize(size);
+
+        textOverlayLeft_->setTextSize(getSize().y);
+        textOverlayRight_->setTextSize(getSize().y);
+    }
+
+    void HUDWeaponMode::updateSize()
+    {
+        this->setSize(weaponModeHUDActualSize_);
+        updatePosition();
+    }
+
+    void HUDWeaponMode::updatePosition()
+    {
+        this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,weaponModeHUDActualSize_.y*weaponModeIndex_));
+    }      
 }
Index: code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.h
===================================================================
--- code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.h	(revision 10715)
+++ code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.h	(revision 10721)
@@ -1,2 +1,3 @@
+
 /*
  *   ORXONOX - the hottest 3D action shooter ever to exist
@@ -58,4 +59,5 @@
 
         virtual void tick(float dt);
+        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
         virtual void changedOwner();
         virtual void changedOverlayGroup();
@@ -63,9 +65,28 @@
         virtual void changedName();
         virtual void positionChanged();
+        virtual void sizeChanged();
 
         virtual void setWeaponMode(WeaponMode* weaponMode);
 
+        inline void setWeaponModeHUDActualSize(Vector2 vector)
+            { weaponModeHUDActualSize_ = vector;
+              this->updateSize();
+            }
+        inline Vector2 getWeaponModeHUDActualSize() const
+            { return weaponModeHUDActualSize_; }
+        inline void setWeaponIndex(int index)
+            { weaponIndex_ = index;
+              this->updatePosition();
+            }
+        inline void setWeaponModeIndex(int index)
+            { weaponModeIndex_ = index;
+              this->updatePosition();
+            }
+
+        virtual void positionHUDChilds();
+
     private:
-        virtual void positionHUDChilds();
+        virtual void updateSize();
+        virtual void updatePosition();
 
         WeakPtr<Pawn> owner_;
@@ -81,4 +102,8 @@
         StrongPtr<OverlayText> textOverlayLeft_;
         StrongPtr<OverlayText> textOverlayRight_;
+
+        Vector2 weaponModeHUDActualSize_;
+        int weaponIndex_;
+        int weaponModeIndex_;
     };
 }
Index: code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponSystem.cc
===================================================================
--- code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponSystem.cc	(revision 10715)
+++ code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponSystem.cc	(revision 10721)
@@ -51,4 +51,7 @@
         RegisterObject(HUDWeaponSystem);
 
+        weaponModeHUDSize_ = Vector2(0.0f,0.0f);
+        weaponModeHUDActualSize_ = Vector2(0.0f,0.0f);        
+
         weapons_.clear();
         hudWeapons_.clear();
@@ -67,6 +70,5 @@
         SUPER(HUDWeaponSystem, XMLPort, xmlelement, mode);
 
-        /*XMLPortParam(HUDWeaponSystem, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlelement, mode);
-        XMLPortParam(HUDWeaponSystem, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlelement, mode);*/
+        XMLPortParam(HUDWeaponSystem, "weaponModeHUDSize", setWeaponModeHUDSize, getWeaponModeHUDSize, xmlelement, mode);
     }
 
@@ -86,5 +88,14 @@
 
         positionHUDChilds();
-    }  
+    }
+
+    void HUDWeaponSystem::sizeChanged()
+    {
+        OrxonoxOverlay::sizeChanged();
+
+        weaponModeHUDActualSize_ = this->getActualSize();
+
+        positionHUDChilds();
+    }
 
     void HUDWeaponSystem::changedOwner()
@@ -142,16 +153,24 @@
 
         createHUDChilds();
-        positionHUDChilds();        
+        positionHUDChilds();
     }
 
     void HUDWeaponSystem::createHUDChilds()
     {
+        int positionIndex = 0;
+
         for (std::vector<WeakPtr<Weapon> >::iterator it = weapons_.begin(); it != weapons_.end(); ++it)
         {
-            HUDWeapon* hudWeapon = new HUDWeapon(this->getContext());            
+            HUDWeapon* hudWeapon = new HUDWeapon(this->getContext());
             hudWeapon->setOwner(owner_);
+            hudWeapon->setOverlayGroup(this->getOverlayGroup());
             hudWeapon->setWeapon(*it);
+            hudWeapon->setAspectCorrection(false);
+            hudWeapon->setPickPoint(Vector2(0.0f,0.0f));
+
             hudWeapons_.push_back(hudWeapon);
-        }       
+
+            ++ positionIndex;
+        }
     }      
 
@@ -159,15 +178,15 @@
     {
         int positionIndex = 0;
+        //this->setSize(weaponModeHUDSize_);
+        // this->weaponModeHUDActualSize_ = this->getActualSize();
 
         for (std::vector<WeakPtr<HUDWeapon> >::iterator it = hudWeapons_.begin(); it != hudWeapons_.end(); ++it)
         {
-            (*it)->setOverlayGroup(this->getOverlayGroup());            
-            (*it)->setAspectCorrection(this->getAspectCorrection());
-            (*it)->setPosition(this->getPosition() + Vector2(0.15f*positionIndex,0.0f));            
-            (*it)->setSize(Vector2(0.15f,0.10f));
-            (*it)->setPickPoint(Vector2(0.0f,0.0f));
+            (*it)->setWeaponIndex(positionIndex);
+            (*it)->setWeaponModeHUDActualSize(this->weaponModeHUDActualSize_);
+            (*it)->positionHUDChilds();           
 
             ++ positionIndex;
-        }        
+        }
     }  
 
@@ -180,4 +199,4 @@
 
         hudWeapons_.clear();     
-    }     
+    }
 }
Index: code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponSystem.h
===================================================================
--- code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponSystem.h	(revision 10715)
+++ code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponSystem.h	(revision 10721)
@@ -63,6 +63,13 @@
         virtual void changedVisibility();
         virtual void changedName();
-        virtual void positionChanged();     
-
+        virtual void positionChanged();
+        virtual void sizeChanged();
+    protected:
+        inline void setWeaponModeHUDSize(Vector2 vector)
+            { weaponModeHUDSize_ = vector;
+                this->setSize(weaponModeHUDSize_);
+            }
+        inline Vector2 getWeaponModeHUDSize() const
+            { return weaponModeHUDSize_; }
     private:
         virtual void updateWeaponList();
@@ -75,4 +82,7 @@
         std::vector<WeakPtr<Weapon> > weapons_;
         std::vector<WeakPtr<HUDWeapon> > hudWeapons_;
+
+        Vector2 weaponModeHUDSize_;
+        Vector2 weaponModeHUDActualSize_;
     };
 }
