[Orxonox-commit 2036] r6753 - in code/trunk/src: modules/overlays orxonox/overlays

rgrieder at orxonox.net rgrieder at orxonox.net
Mon Apr 19 11:14:32 CEST 2010


Author: rgrieder
Date: 2010-04-19 11:14:32 +0200 (Mon, 19 Apr 2010)
New Revision: 6753

Modified:
   code/trunk/src/modules/overlays/GUIOverlay.cc
   code/trunk/src/modules/overlays/GUIOverlay.h
   code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
Log:
Some more hackery for the PlayerInfo<->GUIOverlay relation.
Seems to work now mostly. But I still get a segfault when I pick up the red one and the PickupInventory doesn't disappear with the "Back" button.

Modified: code/trunk/src/modules/overlays/GUIOverlay.cc
===================================================================
--- code/trunk/src/modules/overlays/GUIOverlay.cc	2010-04-19 07:37:18 UTC (rev 6752)
+++ code/trunk/src/modules/overlays/GUIOverlay.cc	2010-04-19 09:14:32 UTC (rev 6753)
@@ -63,8 +63,12 @@
         SUPER(GUIOverlay, changedVisibility);
 
         //Setting player now.
-        if( this->getOwner() )
-            GUIManager::getInstance().setPlayer(this->guiName_, (orxonox_cast<ControllableEntity*>(this->getOwner()))->getPlayer());
+        if (this->getOwner())
+        {
+            ControllableEntity* entity = orxonox_cast<ControllableEntity*>(this->getOwner());
+            if (entity)
+                GUIManager::getInstance().setPlayer(this->guiName_, entity->getPlayer());
+        }
 
         if (this->isVisible())
         {
@@ -86,6 +90,18 @@
     void GUIOverlay::setGUIName(const std::string& name)
     {
         this->guiName_ = name;
-        GUIManager::getInstance().setPlayer(name, orxonox_cast<PlayerInfo*>(this->getOwner())); //Set Player is going to be NULL, so it needs to be set in changedVisibility() as well.
+        if (this->getOwner())
+        {
+            ControllableEntity* entity = orxonox_cast<ControllableEntity*>(this->getOwner());
+            if (entity)
+                GUIManager::getInstance().setPlayer(name, entity->getPlayer()); //Set Player is going to be NULL, so it needs to be set in changedVisibility() as well.
+        }
     }
+
+    void GUIOverlay::changedOwner()
+    {
+        SUPER(GUIOverlay, changedOwner);
+        if (!this->getGUIName().empty())
+            this->setGUIName(this->getGUIName());
+    }
 }

Modified: code/trunk/src/modules/overlays/GUIOverlay.h
===================================================================
--- code/trunk/src/modules/overlays/GUIOverlay.h	2010-04-19 07:37:18 UTC (rev 6752)
+++ code/trunk/src/modules/overlays/GUIOverlay.h	2010-04-19 09:14:32 UTC (rev 6753)
@@ -49,6 +49,7 @@
             inline const std::string& getGUIName() const { return this->guiName_; }
 
             virtual void changedVisibility();
+            virtual void changedOwner();
 
         private:
             std::string guiName_;

Modified: code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
===================================================================
--- code/trunk/src/orxonox/overlays/OrxonoxOverlay.h	2010-04-19 07:37:18 UTC (rev 6752)
+++ code/trunk/src/orxonox/overlays/OrxonoxOverlay.h	2010-04-19 09:14:32 UTC (rev 6753)
@@ -41,6 +41,7 @@
 #include "util/Math.h"
 #include "util/OgreForwardRefs.h"
 #include "core/BaseObject.h"
+#include "core/Super.h"
 #include "core/WindowEventListener.h"
 
 namespace orxonox




More information about the Orxonox-commit mailing list