[Orxonox-commit 5306] r9969 - code/trunk/src/orxonox/gametypes

jo at orxonox.net jo at orxonox.net
Sat Jan 4 14:14:06 CET 2014


Author: jo
Date: 2014-01-04 14:14:06 +0100 (Sat, 04 Jan 2014)
New Revision: 9969

Modified:
   code/trunk/src/orxonox/gametypes/Gametype.cc
   code/trunk/src/orxonox/gametypes/Gametype.h
Log:
Automatically show the menu for gametypes that call Gametype::end() - after a 3 second delay.

Modified: code/trunk/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.cc	2014-01-03 23:59:12 UTC (rev 9968)
+++ code/trunk/src/orxonox/gametypes/Gametype.cc	2014-01-04 13:14:06 UTC (rev 9969)
@@ -34,6 +34,7 @@
 #include "core/config/ConfigValueIncludes.h"
 #include "core/GameMode.h"
 #include "core/command/ConsoleCommand.h"
+#include "gamestates/GSLevel.h"
 
 #include "infos/PlayerInfo.h"
 #include "infos/Bot.h"
@@ -60,6 +61,7 @@
 
         this->bAutoStart_ = false;
         this->bForceSpawn_ = false;
+        this->bAutoEnd_ = true;
         this->numberOfBots_ = 0;
 
         this->timeLimit_ = 0;
@@ -103,6 +105,7 @@
         SetConfigValue(initialStartCountdown_, 3.0f);
         SetConfigValue(bAutoStart_, false);
         SetConfigValue(bForceSpawn_, false);
+        SetConfigValue(bAutoEnd_, true);
         SetConfigValue(numberOfBots_, 0);
         SetConfigValue(scoreboardTemplate_, "defaultScoreboard");
     }
@@ -143,15 +146,15 @@
     void Gametype::start()
     {
         this->addBots(this->numberOfBots_);
-
         this->gtinfo_->start();
-
         this->spawnPlayersIfRequested();
     }
 
     void Gametype::end()
     {
         this->gtinfo_->end();
+        if (this->bAutoEnd_)
+            this->showMenuTimer_.setTimer(2.5f, true, createExecutor(createFunctor(&Gametype::showMenu, this)));
 
         for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
         {
@@ -514,4 +517,9 @@
         this->timeLimit_ = t;
         this->time_ = t;
     }
+
+    void Gametype::showMenu()
+    {
+    	GSLevel::startMainMenu();
+    }
 }

Modified: code/trunk/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.h	2014-01-03 23:59:12 UTC (rev 9968)
+++ code/trunk/src/orxonox/gametypes/Gametype.h	2014-01-04 13:14:06 UTC (rev 9969)
@@ -39,6 +39,7 @@
 #include "core/class/SubclassIdentifier.h"
 #include "tools/interfaces/Tickable.h"
 #include "infos/GametypeInfo.h"
+#include "tools/Timer.h"
 
 namespace orxonox
 {
@@ -157,9 +158,9 @@
             */
             inline unsigned int getNumberOfPlayers() const
                 { return this->players_.size(); }
+            void showMenu();
 
 
-
         protected:
             virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
 
@@ -174,6 +175,7 @@
 
             bool bAutoStart_;
             bool bForceSpawn_;
+            bool bAutoEnd_;
 
             float time_;
             float timeLimit_;
@@ -196,7 +198,7 @@
             ConsoleCommand* dedicatedAddBots_;
             ConsoleCommand* dedicatedKillBots_;
             /* HACK HACK HACK */
-
+            Timer showMenuTimer_;
     };
 }
 




More information about the Orxonox-commit mailing list