[Orxonox-commit 2936] r7636 - in code/branches/lastmanstanding: data/overlays src/modules/overlays src/modules/overlays/hud src/orxonox src/orxonox/gametypes

landauf at orxonox.net landauf at orxonox.net
Thu Nov 11 01:35:49 CET 2010


Author: landauf
Date: 2010-11-11 01:35:49 +0100 (Thu, 11 Nov 2010)
New Revision: 7636

Modified:
   code/branches/lastmanstanding/data/overlays/lastmanstandinghud.oxo
   code/branches/lastmanstanding/src/modules/overlays/OverlaysPrereqs.h
   code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.cc
   code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.h
   code/branches/lastmanstanding/src/orxonox/OrxonoxPrereqs.h
   code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
   code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
Log:
compiles and works

Modified: code/branches/lastmanstanding/data/overlays/lastmanstandinghud.oxo
===================================================================
--- code/branches/lastmanstanding/data/overlays/lastmanstandinghud.oxo	2010-11-10 20:59:50 UTC (rev 7635)
+++ code/branches/lastmanstanding/data/overlays/lastmanstandinghud.oxo	2010-11-11 00:35:49 UTC (rev 7636)
@@ -1,85 +1,85 @@
-<Template name="LastmanstandingHUD">
-  <OverlayGroup name="DynamicmatcHUD" scale = "1, 1">
-   
- <GametypeStaticMessage
-   name     = "staticmessage"
-   position = "0.5, 0.01"
-   font     = "VeraMono"
-   caption  = ""
-   textsize = 0.033
-   colour   = "1.0, 1.0, 0.5, 1.0"
-   align    = "center"
-  />
-
-<GametypeFadingMessage
-     name     = "fadingmessage"
-     position = "0.5, 0.05"
-     font     = "VeraMono"
-     textsize = 0.04
-     colour   = "1.0, 1.0, 0.5, 1.0"
-     align    = "center"
-    />
-    <!--LastManStandingInfos
-     position  = "0.63, 0.05"
-     pickpoint = "0.0, 0.0"
-     font      = "ShareTechMono"
-     textsize  = 0.04
-     colour    = "0.8, 0.8, 1.0, 1.0"
-     align     = "right"
-
-     showlives     = true
-     showplayers     = false
-    /-->
-
-    <OverlayText
-     position  = "0.02, 0.02"
-     pickpoint = "0.0, 0.0"
-     font      = "ShareTechMono"
-     textsize  = 0.04
-     colour    = "1.0, 1.0, 1.0, 1.0"
-     align     = "left"
-     caption   = "Lives:   "
-    />
-
-    <OverlayText
-     position  = "0.02, 0.055"
-     pickpoint = "0.0, 0.0"
-     font      = "ShareTechMono"
-     textsize  = 0.04
-     colour    = "1.0, 1.0, 1.0, 1.0"
-     align     = "left"
-     caption   = "Players: "
-    />
-
-    <OverlayText
-     position  = "0.02, 0.07"
-     pickpoint = "0.0, 0.0"
-     font      = "ShareTechMono"
-     textsize  = 0.04
-     colour    = "1.0, 1.0, 1.0, 1.0"
-     align     = "left"
-     caption   = "__________|"
-    />
-
-    <OverlayText
-     position  = "0.022, 0.07"
-     pickpoint = "0.0, 0.0"
-     font      = "ShareTechMono"
-     textsize  = 0.04
-     colour    = "1.0, 1.0, 1.0, 1.0"
-     align     = "left"
-     caption   = "__________"
-    />
-
-    <OverlayText
-     position  = "0.1733, 0.038"
-     pickpoint = "0.0, 0.0"
-     font      = "ShareTechMono"
-     textsize  = 0.04
-     colour    = "1.0, 1.0, 1.0, 1.0"
-     align     = "left"
-     caption   = "|"
-    />
-
-  </OverlayGroup>
-</Template>
+<Template name="LastmanstandingHUD">
+  <OverlayGroup name="DynamicmatcHUD" scale = "1, 1">
+   
+ <GametypeStaticMessage
+   name     = "staticmessage"
+   position = "0.5, 0.01"
+   font     = "VeraMono"
+   caption  = ""
+   textsize = 0.033
+   colour   = "1.0, 1.0, 0.5, 1.0"
+   align    = "center"
+  />
+
+<GametypeFadingMessage
+     name     = "fadingmessage"
+     position = "0.5, 0.05"
+     font     = "VeraMono"
+     textsize = 0.04
+     colour   = "1.0, 1.0, 0.5, 1.0"
+     align    = "center"
+    />
+    <LastManStandingInfos
+     position  = "0.63, 0.05"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "0.8, 0.8, 1.0, 1.0"
+     align     = "right"
+
+     showlives     = true
+     showplayers     = false
+    />
+
+    <OverlayText
+     position  = "0.02, 0.02"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "left"
+     caption   = "Lives:   "
+    />
+
+    <OverlayText
+     position  = "0.02, 0.055"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "left"
+     caption   = "Players: "
+    />
+
+    <OverlayText
+     position  = "0.02, 0.07"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "left"
+     caption   = "__________|"
+    />
+
+    <OverlayText
+     position  = "0.022, 0.07"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "left"
+     caption   = "__________"
+    />
+
+    <OverlayText
+     position  = "0.1733, 0.038"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "left"
+     caption   = "|"
+    />
+
+  </OverlayGroup>
+</Template>

Modified: code/branches/lastmanstanding/src/modules/overlays/OverlaysPrereqs.h
===================================================================
--- code/branches/lastmanstanding/src/modules/overlays/OverlaysPrereqs.h	2010-11-10 20:59:50 UTC (rev 7635)
+++ code/branches/lastmanstanding/src/modules/overlays/OverlaysPrereqs.h	2010-11-11 00:35:49 UTC (rev 7636)
@@ -87,6 +87,7 @@
     class HUDSpeedBar;
     class HUDTimer;
     class KillMessage;
+    class LastManStandingInfos;
     class TeamBaseMatchScore;
     class UnderAttackHealthBar;
 

Modified: code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.cc
===================================================================
--- code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.cc	2010-11-10 20:59:50 UTC (rev 7635)
+++ code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.cc	2010-11-11 00:35:49 UTC (rev 7636)
@@ -42,7 +42,8 @@
     {
         RegisterObject(LastManStandingInfos);
 
-        this->owner_ = 0;
+        this->lms_ = 0;
+        this->player_ = 0;
         this->bShowLives_ = false;
         this->bShowPlayers_ = false;
     }
@@ -63,24 +64,34 @@
     {
         SUPER(LastManStandingInfos, tick, dt);
 
-        if (this->owner_)
+        if (this->player_ && this->lms_)
         {
-
-            Pawn* pawn = dynamic_cast<Pawn*>(this->getOwner()->getControllableEntity());
-            /*LastManStanding* */ owner_ = dynamic_cast<LastManStanding*>(this->getOwner()->getGametype());
-            int iLives = this->owner_->pawnGetLives(pawn);
-            const std::string& lives = multi_cast<std::string>(iLives);
-
-            const std::string& players = multi_cast<std::string>(this->owner_->playersAlive);
-
             if (this->bShowLives_)
             {
+                const std::string& lives = multi_cast<std::string>(this->lms_->playerGetLives(this->player_));
                 this->setCaption(lives);
             }
             else if(this->bShowPlayers_)
             {
+                const std::string& players = multi_cast<std::string>(this->lms_->getNumPlayersAlive());
                 this->setCaption(players);
             }
         }
+    }
+
+    void LastManStandingInfos::changedOwner()
+    {
+        SUPER(LastManStandingInfos, changedOwner);
+
+        if (this->getOwner() && this->getOwner()->getGametype())
+        {
+            this->player_ = orxonox_cast<PlayerInfo*>(this->getOwner());
+            this->lms_ = orxonox_cast<LastManStanding*>(this->getOwner()->getGametype().get());
+        }
+        else
+        {
+            this->player_ = 0;
+            this->lms_ = 0;
+        }
     }
 }

Modified: code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.h
===================================================================
--- code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.h	2010-11-10 20:59:50 UTC (rev 7635)
+++ code/branches/lastmanstanding/src/modules/overlays/hud/LastManStandingInfos.h	2010-11-11 00:35:49 UTC (rev 7636)
@@ -43,7 +43,8 @@
             virtual ~LastManStandingInfos();
 
             virtual void tick(float dt);
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void changedOwner();
 
             inline void setShowLives(bool value)
                 { this->bShowLives_ = value; }
@@ -56,7 +57,8 @@
                 { return this->bShowPlayers_; }
 
         private:
-            LastManStanding* owner_;
+            LastManStanding* lms_;
+            PlayerInfo* player_;
             bool bShowLives_;
             bool bShowPlayers_;
     };

Modified: code/branches/lastmanstanding/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/lastmanstanding/src/orxonox/OrxonoxPrereqs.h	2010-11-10 20:59:50 UTC (rev 7635)
+++ code/branches/lastmanstanding/src/orxonox/OrxonoxPrereqs.h	2010-11-11 00:35:49 UTC (rev 7636)
@@ -92,6 +92,7 @@
     class Deathmatch;
     class Dynamicmatch;
     class Gametype;
+    class LastManStanding;
     class TeamBaseMatch;
     class TeamDeathmatch;
     class UnderAttack;

Modified: code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc	2010-11-10 20:59:50 UTC (rev 7635)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc	2010-11-11 00:35:49 UTC (rev 7636)
@@ -146,23 +146,18 @@
         }
     }
 
-    int LastManStanding::pawnGetLives(Pawn* pawn)
+    int LastManStanding::playerGetLives(PlayerInfo* player)
     {
-        if(!pawn)
-            return -1;
-        PlayerInfo* player= dynamic_cast<PlayerInfo*>(pawn);
-        if(!player)
-            return -2;
-        return playerLives_[player];
-    }
-
-    const int LastManStanding::playerGetLives(PlayerInfo* player)
-    {
         if (player)
             return  playerLives_[player];
         else
             return 0;
     }
+    
+    int LastManStanding::getNumPlayersAlive() const
+    {
+        return this->playersAlive;
+    }
 
     void LastManStanding::playerEntered(PlayerInfo* player)
     {

Modified: code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h
===================================================================
--- code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h	2010-11-10 20:59:50 UTC (rev 7635)
+++ code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h	2010-11-11 00:35:49 UTC (rev 7636)
@@ -72,8 +72,8 @@
             virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0); //!< Manages each players lives.
 
             virtual void end(); //!< Sends an end message.
-            virtual int pawnGetLives(Pawn* pawn); //!< Returns amount of Lives of a certain player.
-            const int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
+            int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
+            int getNumPlayersAlive() const; //!< Returns the number of players that are still alive.
             virtual void playerEntered(PlayerInfo* player); //!< Initializes values. Manages the gametype's HUD. #Players alive via StaticMessage.
             virtual bool playerLeft(PlayerInfo* player); //!< Manages the gametype's HUD. #Players alive via StaticMessage.
             virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn); //!< Manages the gametype's HUD. player's lives via FadingMessage.




More information about the Orxonox-commit mailing list