Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2819


Ignore:
Timestamp:
Mar 22, 2009, 9:59:34 PM (15 years ago)
Author:
landauf
Message:

moved gametype-HUD from PlayerInfo to HumanPlayer

Location:
code/branches/miniprojects/src/orxonox/objects/infos
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.cc

    r2806 r2819  
    5454
    5555        this->humanHud_ = 0;
     56        this->gametypeHud_ = 0;
    5657
    5758        this->setConfigValues();
     
    6162    HumanPlayer::~HumanPlayer()
    6263    {
    63         if (this->BaseObject::isInitialized() && this->humanHud_)
    64             delete this->humanHud_;
     64        if (this->BaseObject::isInitialized())
     65        {
     66            if (this->humanHud_)
     67                delete this->humanHud_;
     68
     69            if (this->gametypeHud_)
     70                delete this->gametypeHud_;
     71        }
    6572    }
    6673
     
    115122
    116123            this->createController();
     124            this->updateHumanHUD();
    117125        }
    118126    }
     
    150158    }
    151159
     160    void HumanPlayer::changedGametype()
     161    {
     162        PlayerInfo::changedGametype();
     163
     164        if (this->isInitialized() && this->isLocalPlayer())
     165            if (this->getGametype()->getHUDTemplate() != "")
     166                this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());
     167    }
     168
    152169    void HumanPlayer::changedControllableEntity()
    153170    {
     
    156173        if (this->humanHud_)
    157174            this->humanHud_->setOwner(this->getControllableEntity());
     175
     176        if (this->gametypeHud_)
     177            this->gametypeHud_->setOwner(this->getControllableEntity());
    158178    }
    159179
     
    166186        }
    167187
    168         if (this->humanHudTemplate_ != "")
     188        if (this->isLocalPlayer() && this->humanHudTemplate_ != "")
    169189        {
    170190            this->humanHud_ = new OverlayGroup(this);
     
    173193        }
    174194    }
     195
     196    void HumanPlayer::updateGametypeHUD()
     197    {
     198        if (this->gametypeHud_)
     199        {
     200            delete this->gametypeHud_;
     201            this->gametypeHud_ = 0;
     202        }
     203
     204        if (this->isLocalPlayer() && this->gametypeHudTemplate_ != "")
     205        {
     206            this->gametypeHud_ = new OverlayGroup(this);
     207            this->gametypeHud_->addTemplate(this->gametypeHudTemplate_);
     208            this->gametypeHud_->setOwner(this->getControllableEntity());
     209        }
     210    }
    175211}
  • code/branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.h

    r2789 r2819  
    5151            void setClientID(unsigned int clientID);
    5252
     53            virtual void changedGametype();
    5354            virtual void changedControllableEntity();
    5455
     
    6364            inline const std::string& getHumanHUDTemplate() const
    6465                { return this->humanHudTemplate_; }
    65 
    6666            inline OverlayGroup* getHumanHUD() const
    6767                { return this->humanHud_; }
     68
     69            inline void setGametypeHUDTemplate(const std::string& name)
     70            {
     71                if (name != this->gametypeHudTemplate_)
     72                {
     73                    this->gametypeHudTemplate_ = name;
     74                    this->updateGametypeHUD();
     75                }
     76            }
     77            inline const std::string& getGametypeHUDTemplate() const
     78                { return this->gametypeHudTemplate_; }
     79            inline OverlayGroup* getGametypeHUD() const
     80                { return this->gametypeHud_; }
    6881
    6982        protected:
     
    7689
    7790            void updateHumanHUD();
     91            void updateGametypeHUD();
    7892
    7993            std::string nick_;
     
    8599            std::string humanHudTemplate_;
    86100            OverlayGroup* humanHud_;
     101            std::string gametypeHudTemplate_;
     102            OverlayGroup* gametypeHud_;
    87103    };
    88104}
  • code/branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.cc

    r2789 r2819  
    3535#include "network/ClientInformation.h"
    3636#include "objects/gametypes/Gametype.h"
    37 #include "overlays/OverlayGroup.h"
    3837
    3938namespace orxonox
     
    5150        this->controllableEntity_ = 0;
    5251        this->controllableEntityID_ = CLIENTID_UNKNOWN;
    53         this->gametypeHud_ = 0;
    5452
    5553        this->registerVariables();
     
    7068            if (this->getGametype())
    7169                this->getGametype()->playerLeft(this);
    72 
    73             if (this->BaseObject::isInitialized() && this->gametypeHud_)
    74                 delete this->gametypeHud_;
    7570        }
    7671    }
     
    109104                else
    110105                    this->getGametype()->playerEntered(this);
    111 
    112                 if (this->isLocalPlayer() && this->isHumanPlayer())
    113                     if (this->getGametype()->getHUDTemplate() != "")
    114                         this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());
    115106            }
    116107        }
     
    185176        }
    186177    }
    187 
    188     void PlayerInfo::changedControllableEntity()
    189     {
    190         if (this->gametypeHud_)
    191             this->gametypeHud_->setOwner(this->getControllableEntity());
    192     }
    193 
    194     void PlayerInfo::updateGametypeHUD()
    195     {
    196         if (this->gametypeHud_)
    197         {
    198             delete this->gametypeHud_;
    199             this->gametypeHud_ = 0;
    200         }
    201 
    202         if (this->isLocalPlayer() && this->isHumanPlayer() && this->gametypeHudTemplate_ != "")
    203         {
    204             this->gametypeHud_ = new OverlayGroup(this);
    205             this->gametypeHud_->addTemplate(this->gametypeHudTemplate_);
    206             this->gametypeHud_->setOwner(this->getControllableEntity());
    207         }
    208     }
    209178}
  • code/branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.h

    r2789 r2819  
    5050
    5151            virtual void changedController() {}
    52             virtual void changedControllableEntity();
     52            virtual void changedControllableEntity() {}
    5353
    5454            inline bool isHumanPlayer() const
     
    7777                { return this->controller_; }
    7878
    79             inline void setGametypeHUDTemplate(const std::string& name)
    80             {
    81                 if (name != this->gametypeHudTemplate_)
    82                 {
    83                     this->gametypeHudTemplate_ = name;
    84                     this->updateGametypeHUD();
    85                 }
    86             }
    87             inline const std::string& getGametypeHUDTemplate() const
    88                 { return this->gametypeHudTemplate_; }
    89 
    90             inline OverlayGroup* getGametypeHUD() const
    91                 { return this->gametypeHud_; }
    92 
    9379        protected:
    9480            void createController();
     
    10288        private:
    10389            void networkcallback_changedcontrollableentityID();
    104             void updateGametypeHUD();
    10590
    10691            bool bReadyToSpawn_;
     
    10893            ControllableEntity* controllableEntity_;
    10994            unsigned int controllableEntityID_;
    110             std::string gametypeHudTemplate_;
    111             OverlayGroup* gametypeHud_;
    11295    };
    11396}
Note: See TracChangeset for help on using the changeset viewer.