Index: code/branches/main_reto/src/run_manager.cc
===================================================================
--- code/branches/main_reto/src/run_manager.cc	(revision 192)
+++ code/branches/main_reto/src/run_manager.cc	(revision 267)
@@ -56,11 +56,19 @@
 #include "weapon/bullet.h"
 #include "weapon/bullet_manager.h"
-#include "weapon/weapon_manager.h"
+#include "weapon/base_weapon.h"
+
+#include "hud/hud_overlay.h"
 
 #include "run_manager.h"
+
+namespace Ogre {
+  using namespace orxonox;
+  template<> RunManager* Singleton<RunManager>::ms_Singleton = 0;
+}
 
 namespace orxonox {
   using namespace Ogre;
   using namespace weapon;
+  using namespace hud;
 
   /**
@@ -77,4 +85,13 @@
   */
 
+  RunManager* RunManager::getSingletonPtr(void)
+  {
+      return ms_Singleton;
+  }
+  RunManager& RunManager::getSingleton(void)
+  {  
+      assert( ms_Singleton );  return ( *ms_Singleton );  
+  }
+
 
   /**
@@ -88,5 +105,5 @@
   */
   RunManager::RunManager(OgreControl * ogre)
-        : ogre_(ogre), window_(ogre->getRenderWindow()), leftButtonDown_(false),
+        : ogre_(ogre), window_(ogre->getRenderWindow()), //leftButtonDown_(false),
         statsOn_(true), screenShotCounter_(0), timeUntilNextToggle_(0),
         filtering_(TFO_BILINEAR), aniso_(1), sceneDetailIndex_(0),
@@ -94,9 +111,8 @@
         debugOverlay_(0), inputManager_(0), mouse_(0), keyboard_(0), joystick_(0)
   {
-
     // SETTING UP THE SCENE
 
     // create one new SceneManger
-    sceneMgr_ = ogre_->getRoot()->createSceneManager(ST_GENERIC, "backgroundScene_");
+    sceneMgr_ = ogre_->getRoot()->createSceneManager(ST_GENERIC, "Orxonox Scene");
 
     // background scene (world objects, skybox, lights, etc.)
@@ -108,10 +124,4 @@
     // create a bullet manager
     bulletManager_ = new BulletManager(sceneMgr_);
-    WeaponManager::loadWeapons();
-
-    // TODO: Use STL to make life easier. But it works this way too..
-    /*bullets_ = new Bullet*[10];
-    bulletsIndex_ = 0;
-    bulletsSize_ = 10;*/
 
 
@@ -131,6 +141,6 @@
 
     // Construct a new spaceship and give it the node
-    playerShip_ = new OrxonoxShip(sceneMgr_, sceneMgr_->getRootSceneNode()
-      ->createChildSceneNode("ShipNode", Vector3(20, 20, 20)), bulletManager_);
+    playerShip_ = new OrxonoxShip(sceneMgr_->getRootSceneNode()
+      ->createChildSceneNode("ShipNode", Vector3(20, 20, 20)));
 
 
@@ -153,4 +163,8 @@
     createViewports();
 
+    // create HUD
+    hud_ = new HUDOverlay();
+    hud_->show();
+
 
     // Set default mipmap level (NB some APIs ignore this)
@@ -163,6 +177,7 @@
     using namespace OIS;
 
-    debugOverlay_ = OverlayManager::getSingleton()
-      .getByName("Core/DebugOverlay");
+    //debugOverlay_ = OverlayManager::getSingleton()
+    //  .getByName("Core/DebugOverlay");
+    
 
     LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
@@ -194,5 +209,5 @@
     windowResized(window_);
 
-    showDebugOverlay(true);
+    //showDebugOverlay(true);
 
     // REGISTER THIS OBJECT AS A WINDOW EVENT LISTENER IN OGRE
@@ -218,11 +233,4 @@
     if (bulletManager_)
       delete bulletManager_;
-
-    WeaponManager::destroyWeapons();
-
-    // clean up the bullet list
-    /*for (int i = 0; i < bulletsIndex_; i++)
-      delete bullets_[i];
-    delete bullets_;*/
   }
 
@@ -251,15 +259,9 @@
 
     // Update the 'HUD'
-    updateStats();
+    //updateStats();
 
     // update the bullet positions
     bulletManager_->tick(time, deltaTime);
 
-    /*for (int i = 0; i < bulletsIndex_; i++)
-    {
-      bullets_[i]->node_->translate(bullets_[i]->speed_*deltaTime);
-      bullets_[i]->node_->yaw(Degree(deltaTime*100));
-      bullets_[i]->node_->roll(Degree(deltaTime*300));
-    }*/
 
     // HUMAN INTERFACE
@@ -293,4 +295,38 @@
     // keep rendering
     return true;
+  }
+
+
+  SceneManager& RunManager::getSceneManager()
+  {
+    return *sceneMgr_;
+  }
+
+  SceneManager* RunManager::getSceneManagerPtr()
+  {
+    return sceneMgr_;
+  }
+
+  BulletManager* RunManager::getBulletManagerPtr()
+  {
+    return bulletManager_;
+  }
+
+  int RunManager::getAmmunitionID(const Ogre::String &ammoName)
+  {
+    Ogre::String ammoTypes[] = { "Energy Cell", "Barrel", "Lead Shot" };
+    int ammoTypesLength = 3;
+
+    for (int i = 0; i < ammoTypesLength; i++)
+    {
+      if (ammoTypes[i] == ammoName)
+        return i;
+    }
+    return -1;
+  }
+
+  int RunManager::getNumberOfAmmos()
+  {
+    return 3;
   }
 
@@ -367,4 +403,7 @@
       playerShip_->setYThrust(0);
 
+    if (keyboard_->isKeyDown(KC_G))
+      playerShip_->getMainWeapon()->addAction(BaseWeapon::RELOAD);
+
     if( keyboard_->isKeyDown(KC_ESCAPE) || keyboard_->isKeyDown(KC_Q) )
       return false;
@@ -373,5 +412,5 @@
     {
       statsOn_ = !statsOn_;
-      showDebugOverlay(statsOn_);
+      //showDebugOverlay(statsOn_);
       timeUntilNextToggle_ = 1;
     }
@@ -398,5 +437,5 @@
       MaterialManager::getSingleton().setDefaultAnisotropy(aniso_);
 
-      showDebugOverlay(statsOn_);
+      //showDebugOverlay(statsOn_);
       timeUntilNextToggle_ = 1;
     }
@@ -434,5 +473,10 @@
     if(displayCameraDetails)
       debugText_ = " | Speed = "
-            + StringConverter::toString(playerShip_->getSpeed());
+            + StringConverter::toString(playerShip_->getSpeed())
+            + " | Left Ammo = "
+            + StringConverter::toString(playerShip_
+            ->getMainWeapon()->getAmmoState())
+            + " | Ammo stock = "
+            + StringConverter::toString(playerShip_->getAmmoStock());
     // debugText_ = "P: " + StringConverter::toString(camera_
     //      ->getDerivedPosition()) + " " + "O: "
@@ -457,42 +501,12 @@
     const MouseState &ms = mouse_->getMouseState();
 
-    // This is a 'hack' to show some flying barrels..
-    // Usually, the Bullet created by the ship should be managed
-    // by the physics engine..
-    if (ms.buttonDown(MB_Left) && !leftButtonDown_)
-    {
-      // Prevent continuous fire for the moment.
-      leftButtonDown_ = true;
-
-      playerShip_->fire();
-      
-      // let ship fire one shot with its only weapon (Barrels..)
-      /*Bullet *tempBullet = playerShip_->fire();
-
-      // resize array if neccessary (double the size then)
-      if (bulletsIndex_ >= bulletsSize_)
-      {
-        // redimension the array
-        Bullet **tempArray = new Bullet*[2*bulletsSize_];
-        for (int i = 0; i < bulletsSize_; i++)
-          tempArray[i] = bullets_[i];
-        bulletsSize_ *= 2;
-        delete bullets_;
-        bullets_ = tempArray;
-      }
-
-      // add the bullet to the list
-      bullets_[bulletsIndex_++] = tempBullet;*/
-
-    }
-    else if (!ms.buttons)
-      leftButtonDown_ = false;
-
-    // space ship steering. This should definitely be done in the steering object
-    // Simply give it the mouse movements.
+    if (ms.buttonDown(MB_Left))
+      playerShip_->getMainWeapon()->primaryFireRequest();
+
+    if (ms.buttonDown(MB_Right))
+      playerShip_->getMainWeapon()->secondaryFireRequest();
+
     playerShip_->turnUpAndDown(Radian(ms.Y.rel * mouseSensitivity_));
     playerShip_->turnLeftAndRight(Radian(ms.X.rel * mouseSensitivity_));
-    //playerShip_->mRootNode->pitch(Degree(-ms.Y.rel * 0.13), Ogre::Node::TransformSpace::TS_LOCAL);
-    //playerShip_->mRootNode->yaw(Degree(-ms.X.rel * 0.13), Ogre::Node::TransformSpace::TS_PARENT);
 
     // keep rendering
@@ -565,5 +579,4 @@
 
 
-
   /**
   * Simple camera creator.
@@ -583,6 +596,4 @@
   /**
   * Simple viewport creator.
-  * TODO: fully understand the concept of viewports concerning orxnox.
-  * E.g. do we need splitscreen mode?
   * For now the viewport uses the entire render window and is based on the one
   * camera created so far.
