[Orxonox-commit 4802] r9471 - code/branches/spaceNavigation/src/modules/overlays/hud

jo at orxonox.net jo at orxonox.net
Wed Nov 28 23:02:56 CET 2012


Author: jo
Date: 2012-11-28 23:02:55 +0100 (Wed, 28 Nov 2012)
New Revision: 9471

Modified:
   code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc
   code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h
Log:
I fixed the console command. A console command has to be a static function. I used the same workaround as in NewHumanController to bypass the static behaviour of the concerning functions.

Modified: code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc	2012-11-26 15:36:01 UTC (rev 9470)
+++ code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc	2012-11-28 22:02:55 UTC (rev 9471)
@@ -58,8 +58,8 @@
 namespace orxonox
 {
 
-    SetConsoleCommand("selectClosest", &HUDNavigation::selectClosestTarget);
-    SetConsoleCommand("selectNext", &HUDNavigation::selectNextTarget);
+    SetConsoleCommand("HUDNavigation","selectClosest", &HUDNavigation::selectClosestTarget).addShortcut().keybindMode(KeybindMode::OnPress);
+    SetConsoleCommand("HUDNavigation","selectNext", &HUDNavigation::selectNextTarget).addShortcut().keybindMode(KeybindMode::OnPress);
 
     static bool compareDistance(std::pair<RadarViewable*, unsigned int> a,
             std::pair<RadarViewable*, unsigned int> b)
@@ -68,6 +68,8 @@
     }
     CreateFactory ( HUDNavigation );
 
+    HUDNavigation* HUDNavigation::localHUD_s = 0;
+
     HUDNavigation::HUDNavigation(BaseObject* creator) :
         OrxonoxOverlay(creator)
     {
@@ -85,6 +87,7 @@
 
         this->closestTarget_ = true;
         this->nextTarget_ = false;
+        HUDNavigation::localHUD_s = this;
     }
 
     HUDNavigation::~HUDNavigation()
@@ -543,13 +546,19 @@
 
     void HUDNavigation::selectClosestTarget()
     {
-        this->closestTarget_ = true;
-        orxout() << "selectClosestTarget" << std::endl;
+        if(HUDNavigation::localHUD_s)
+        {
+            HUDNavigation::localHUD_s->closestTarget_ = true;
+            orxout() << "selectClosestTarget" << std::endl;
+        }
     }
 
     void HUDNavigation::selectNextTarget()
     {
-        this->nextTarget_ = true;
-        orxout() << "selectNextTarget" << std::endl;
+        if(HUDNavigation::localHUD_s)
+        {
+            HUDNavigation::localHUD_s->nextTarget_ = true;
+            orxout() << "selectNextTarget" << std::endl;
+        }
     }
 }

Modified: code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h
===================================================================
--- code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h	2012-11-26 15:36:01 UTC (rev 9470)
+++ code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h	2012-11-28 22:02:55 UTC (rev 9471)
@@ -70,8 +70,8 @@
             inline unsigned int getMarkerLimit() const
                 { return this->markerLimit_; }
 
-            void selectClosestTarget();
-            void selectNextTarget();
+            static void selectClosestTarget();
+            static void selectNextTarget();
 
         private:
             struct ObjectInfo
@@ -131,7 +131,9 @@
 
             static const float LIGHTNING_GUN_SPEED_ = 700.0f;
             static const float HSW01_SPEED_ = 2500.0f;
+            static HUDNavigation* localHUD_s; //!< This is used as a filter to only influence the local HUD.
 
+
             float currentMunitionSpeed_;
 
             unsigned int markerLimit_;




More information about the Orxonox-commit mailing list