[Orxonox-commit 3244] r7935 - in code/branches/usability: data/gui/scripts data/overlays src/modules/overlays src/modules/overlays/hud src/orxonox/gamestates

landauf at orxonox.net landauf at orxonox.net
Sun Feb 20 17:29:02 CET 2011


Author: landauf
Date: 2011-02-20 17:29:02 +0100 (Sun, 20 Feb 2011)
New Revision: 7935

Added:
   code/branches/usability/src/modules/overlays/hud/PauseNotice.cc
   code/branches/usability/src/modules/overlays/hud/PauseNotice.h
Modified:
   code/branches/usability/data/gui/scripts/InGameMenu.lua
   code/branches/usability/data/overlays/debug.oxo
   code/branches/usability/src/modules/overlays/OverlaysPrereqs.h
   code/branches/usability/src/modules/overlays/hud/CMakeLists.txt
   code/branches/usability/src/orxonox/gamestates/GSRoot.cc
   code/branches/usability/src/orxonox/gamestates/GSRoot.h
Log:
 - opening the ingame menu pauses the game, closing the ingame menu unpauses the game
 - added a text overlay to the default HUD which shows a notice if the game is paused

Modified: code/branches/usability/data/gui/scripts/InGameMenu.lua
===================================================================
--- code/branches/usability/data/gui/scripts/InGameMenu.lua	2011-02-20 16:08:36 UTC (rev 7934)
+++ code/branches/usability/data/gui/scripts/InGameMenu.lua	2011-02-20 16:29:02 UTC (rev 7935)
@@ -32,8 +32,14 @@
     if P:hasSelection() == false then
         P:setSelection(1, 1)
     end
+
+    orxonox.execute("setPause 1")
 end
 
+function P.onQuit()
+    orxonox.execute("setPause 0")
+end
+
 -- events for ingamemenu
 function P.button_quit_clicked(e)
     openDecisionPopup( "Do you really want to quit the game?", InGameMenu.callback )

Modified: code/branches/usability/data/overlays/debug.oxo
===================================================================
--- code/branches/usability/data/overlays/debug.oxo	2011-02-20 16:08:36 UTC (rev 7934)
+++ code/branches/usability/data/overlays/debug.oxo	2011-02-20 16:29:02 UTC (rev 7935)
@@ -65,6 +65,15 @@
      align    = "center"
     />
 
+    <PauseNotice
+     name     = "pausenotice"
+     position = "0.5, 0.3"
+     font     = "VeraMono"
+     textsize = 0.03
+     colour   = "1.0, 1.0, 1.0, 1.0"
+     align    = "center"
+    />
+
     <AnnounceMessage
      name     = "announcemessage"
      position = "0.5, 0.75"

Modified: code/branches/usability/src/modules/overlays/OverlaysPrereqs.h
===================================================================
--- code/branches/usability/src/modules/overlays/OverlaysPrereqs.h	2011-02-20 16:08:36 UTC (rev 7934)
+++ code/branches/usability/src/modules/overlays/OverlaysPrereqs.h	2011-02-20 16:29:02 UTC (rev 7935)
@@ -88,6 +88,7 @@
     class HUDTimer;
     class KillMessage;
     class LastManStandingInfos;
+    class PauseNotice;
     class TeamBaseMatchScore;
     class UnderAttackHealthBar;
 

Modified: code/branches/usability/src/modules/overlays/hud/CMakeLists.txt
===================================================================
--- code/branches/usability/src/modules/overlays/hud/CMakeLists.txt	2011-02-20 16:08:36 UTC (rev 7934)
+++ code/branches/usability/src/modules/overlays/hud/CMakeLists.txt	2011-02-20 16:29:02 UTC (rev 7935)
@@ -15,4 +15,5 @@
   GametypeStaticMessage.cc
   GametypeFadingMessage.cc
   LastManStandingInfos.cc
+  PauseNotice.cc
 )

Added: code/branches/usability/src/modules/overlays/hud/PauseNotice.cc
===================================================================
--- code/branches/usability/src/modules/overlays/hud/PauseNotice.cc	                        (rev 0)
+++ code/branches/usability/src/modules/overlays/hud/PauseNotice.cc	2011-02-20 16:29:02 UTC (rev 7935)
@@ -0,0 +1,59 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "PauseNotice.h"
+
+#include "core/CoreIncludes.h"
+#include "infos/PlayerInfo.h"
+
+namespace orxonox
+{
+    CreateFactory(PauseNotice);
+
+    PauseNotice::PauseNotice(BaseObject* creator) : OverlayText(creator)
+    {
+        RegisterObject(PauseNotice);
+
+        this->owner_ = 0;
+    }
+
+    void PauseNotice::changedOwner()
+    {
+        SUPER(PauseNotice, changedOwner);
+
+        this->owner_ = orxonox_cast<PlayerInfo*>(this->getOwner());
+    }
+
+    void PauseNotice::changedTimeFactor(float factor_new, float factor_old)
+    {
+        if (factor_new == 0)
+            this->setCaption("Paused");
+        else
+            this->setCaption("");
+    }
+}


Property changes on: code/branches/usability/src/modules/overlays/hud/PauseNotice.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Added: code/branches/usability/src/modules/overlays/hud/PauseNotice.h
===================================================================
--- code/branches/usability/src/modules/overlays/hud/PauseNotice.h	                        (rev 0)
+++ code/branches/usability/src/modules/overlays/hud/PauseNotice.h	2011-02-20 16:29:02 UTC (rev 7935)
@@ -0,0 +1,53 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _PauseNotice_H__
+#define _PauseNotice_H__
+
+#include "overlays/OverlaysPrereqs.h"
+
+#include "tools/interfaces/TimeFactorListener.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+    class _OverlaysExport PauseNotice : public OverlayText, public TimeFactorListener
+    {
+        public:
+            PauseNotice(BaseObject* creator);
+
+            virtual void changedOwner();
+
+        protected:
+            virtual void changedTimeFactor(float factor_new, float factor_old);
+
+        private:
+            PlayerInfo* owner_;
+    };
+}
+#endif /* _PauseNotice_H__ */


Property changes on: code/branches/usability/src/modules/overlays/hud/PauseNotice.h
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: code/branches/usability/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/branches/usability/src/orxonox/gamestates/GSRoot.cc	2011-02-20 16:08:36 UTC (rev 7934)
+++ code/branches/usability/src/orxonox/gamestates/GSRoot.cc	2011-02-20 16:29:02 UTC (rev 7935)
@@ -42,10 +42,12 @@
     DeclareGameState(GSRoot, "root", false, false);
 
     static const std::string __CC_setTimeFactor_name = "setTimeFactor";
+    static const std::string __CC_setPause_name = "setPause";
     static const std::string __CC_pause_name = "pause";
 
     SetConsoleCommand("printObjects", &GSRoot::printObjects).hide();
     SetConsoleCommand(__CC_setTimeFactor_name, &GSRoot::setTimeFactor).accessLevel(AccessLevel::Master).defaultValues(1.0);
+    SetConsoleCommand(__CC_setPause_name,      &GSRoot::setPause     ).accessLevel(AccessLevel::Master).hide();
     SetConsoleCommand(__CC_pause_name,         &GSRoot::pause        ).accessLevel(AccessLevel::Master);
 
     registerStaticNetworkFunction(&TimeFactorListener::setTimeFactor);
@@ -82,12 +84,14 @@
         TimeFactorListener::setTimeFactor(1.0f);
 
         ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(this);
+        ModifyConsoleCommand(__CC_setPause_name).setObject(this);
         ModifyConsoleCommand(__CC_pause_name).setObject(this);
     }
 
     void GSRoot::deactivate()
     {
         ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(0);
+        ModifyConsoleCommand(__CC_setPause_name).setObject(0);
         ModifyConsoleCommand(__CC_pause_name).setObject(0);
     }
 
@@ -156,6 +160,15 @@
         }
     }
 
+    void GSRoot::setPause(bool pause)
+    {
+        if (GameMode::isMaster())
+        {
+            if (pause != this->bPaused_)
+                this->pause();
+        }
+    }
+
     void GSRoot::changedTimeFactor(float factor_new, float factor_old)
     {
         if (!GameMode::isStandalone())

Modified: code/branches/usability/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/branches/usability/src/orxonox/gamestates/GSRoot.h	2011-02-20 16:08:36 UTC (rev 7934)
+++ code/branches/usability/src/orxonox/gamestates/GSRoot.h	2011-02-20 16:29:02 UTC (rev 7935)
@@ -50,6 +50,7 @@
         // this has to be public because proteced triggers a bug in msvc
         // when taking the function address.
         void setTimeFactor(float factor);
+        void setPause(bool pause);
         void pause();
 
     protected:




More information about the Orxonox-commit mailing list