Index: code/branches/dockingsystem2/src/modules/docking/Dock.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/Dock.cc	(revision 8382)
+++ code/branches/dockingsystem2/src/modules/docking/Dock.cc	(revision 8434)
@@ -34,14 +34,19 @@
 #include "Dock.h"
 
+#include "core/CoreIncludes.h"
+#include "core/LuaState.h"
+#include "core/GUIManager.h"
 #include "infos/HumanPlayer.h"
 #include "worldentities/pawns/Pawn.h"
 #include "interfaces/PlayerTrigger.h"
-#include "controllers/HumanController.h"
 #include "core/command/ConsoleCommand.h"
 
-
+#include "ToluaBindDocking.h"
 
 namespace orxonox
 {
+    // Register tolua_open function when loading the library
+    DeclareToluaInterface(Docking);
+
     CreateFactory(Dock);
 
@@ -111,10 +116,15 @@
         COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl;
 
-        if(bTriggered) {
+        if(bTriggered)
+        {
             // Add player to this Docks candidates
             candidates.insert(player);
 
+            // Show docking dialog
+            GUIManager::showGUI("DockingDialog");
             //DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
-        } else {
+        }
+        else
+        {
             // Remove player from candidates list
             candidates.erase(player);
@@ -127,7 +137,9 @@
 
 
-    void Dock::cmdDock() {
-        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
-        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) {
+    void Dock::cmdDock()
+    {
+        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
+        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it)
+        {
             if(it->dock(player))
                 break;
@@ -135,7 +147,9 @@
     }
 
-    void Dock::cmdUndock() {
-        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
-        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) {
+    void Dock::cmdUndock()
+    {
+        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
+        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it)
+        {
             if(it->undock(player))
                 break;
@@ -144,8 +158,10 @@
 
 
-    bool Dock::dock(PlayerInfo* player) {
+    bool Dock::dock(PlayerInfo* player)
+    {
         // Check if player is a candidate
-        if(candidates.find(player) == candidates.end()) {
-            COUT(0) << "Player is not a candidate!";
+        if(candidates.find(player) == candidates.end())
+        {
+            COUT(0) << "Player is not a candidate!" << std::endl;
             return false;
         }
@@ -158,7 +174,9 @@
     }
 
-    bool Dock::undock(PlayerInfo* player) {
+    bool Dock::undock(PlayerInfo* player)
+    {
         // Check if player is docked to this Dock
-        if(docked.find(player) == docked.end()) {
+        if(docked.find(player) == docked.end())
+        {
             COUT(0) << "Player is not docked to this Dock." << std::endl;
             return false;
@@ -173,5 +191,34 @@
 
 
-    bool Dock::addEffect(DockingEffect* effect) {
+    unsigned int Dock::getNumberOfActiveDocks()
+    {
+        int i = 0;
+        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
+        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it)
+        {
+            if(it->candidates.find(player) != it->candidates.end())
+                i++;
+        }
+        return i;
+    }
+
+    Dock* Dock::getActiveDockAtIndex(unsigned int index)
+    {
+        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
+        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it)
+        {
+            if(it->candidates.find(player) != it->candidates.end())
+            {
+                if(index == 0)
+                    return *it;
+                index--;
+            }
+        }
+        return NULL;
+    }
+
+
+    bool Dock::addEffect(DockingEffect* effect)
+    {
         assert(effect);
         effects.push_back(effect);
@@ -179,7 +226,9 @@
     }
 
-    const DockingEffect* Dock::getEffect(unsigned int index) const {
+    const DockingEffect* Dock::getEffect(unsigned int index) const
+    {
         int i = index;
-        for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect) {
+        for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect)
+        {
             if(i == 0)
                return *effect;
