Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 23, 2009, 12:02:49 PM (15 years ago)
Author:
landauf
Message:

merged miniprojects branch back to trunk

Location:
code/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/objects/infos/GametypeInfo.cc

    r2662 r2826  
    5858        registerVariable(this->startCountdown_,         variableDirection::toclient);
    5959        registerVariable(this->bStartCountdownRunning_, variableDirection::toclient);
     60        registerVariable(this->hudtemplate_,            variableDirection::toclient);
    6061    }
    6162}
  • code/trunk/src/orxonox/objects/infos/GametypeInfo.h

    r2662 r2826  
    5656                { return this->startCountdown_; }
    5757
     58            inline const std::string& getHUDTemplate() const
     59                { return this->hudtemplate_; }
     60
    5861        private:
    5962            bool bStarted_;
     
    6164            bool bStartCountdownRunning_;
    6265            float startCountdown_;
     66            std::string hudtemplate_;
    6367    };
    6468}
  • code/trunk/src/orxonox/objects/infos/HumanPlayer.cc

    r2662 r2826  
    5353        this->defaultController_ = Class(HumanController);
    5454
     55        this->humanHud_ = 0;
     56        this->gametypeHud_ = 0;
     57
    5558        this->setConfigValues();
    5659        this->registerVariables();
     
    5962    HumanPlayer::~HumanPlayer()
    6063    {
     64        if (this->BaseObject::isInitialized())
     65        {
     66            if (this->humanHud_)
     67                delete this->humanHud_;
     68
     69            if (this->gametypeHud_)
     70                delete this->gametypeHud_;
     71        }
    6172    }
    6273
     
    89100    void HumanPlayer::configvaluecallback_changedHUDTemplate()
    90101    {
    91         this->changedController();
     102        this->setHumanHUDTemplate(this->hudtemplate_);
    92103    }
    93104
     
    111122
    112123            this->createController();
     124            this->updateHumanHUD();
    113125        }
    114126    }
     
    146158    }
    147159
    148     void HumanPlayer::changedController()
    149     {
    150         if (this->getController())
    151         {
    152             this->getController()->setHUDTemplate(this->hudtemplate_);
    153 
    154             if (this->getController() && this->getController()->getHUD())
    155                 this->getController()->getHUD()->setOwner(this->getControllableEntity());
     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
     169    void HumanPlayer::changedControllableEntity()
     170    {
     171        PlayerInfo::changedControllableEntity();
     172
     173        if (this->humanHud_)
     174            this->humanHud_->setOwner(this->getControllableEntity());
     175
     176        if (this->gametypeHud_)
     177            this->gametypeHud_->setOwner(this->getControllableEntity());
     178    }
     179
     180    void HumanPlayer::updateHumanHUD()
     181    {
     182        if (this->humanHud_)
     183        {
     184            delete this->humanHud_;
     185            this->humanHud_ = 0;
     186        }
     187
     188        if (this->isLocalPlayer() && this->humanHudTemplate_ != "")
     189        {
     190            this->humanHud_ = new OverlayGroup(this);
     191            this->humanHud_->addTemplate(this->humanHudTemplate_);
     192            this->humanHud_->setOwner(this->getControllableEntity());
     193        }
     194    }
     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());
    156209        }
    157210    }
  • code/trunk/src/orxonox/objects/infos/HumanPlayer.h

    r2662 r2826  
    5151            void setClientID(unsigned int clientID);
    5252
    53             virtual void changedController();
     53            virtual void changedGametype();
     54            virtual void changedControllableEntity();
     55
     56            inline void setHumanHUDTemplate(const std::string& name)
     57            {
     58                if (name != this->humanHudTemplate_)
     59                {
     60                    this->humanHudTemplate_ = name;
     61                    this->updateHumanHUD();
     62                }
     63            }
     64            inline const std::string& getHumanHUDTemplate() const
     65                { return this->humanHudTemplate_; }
     66            inline OverlayGroup* getHumanHUD() const
     67                { 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_; }
    5481
    5582        protected:
     
    6188            void networkcallback_client_initialized();
    6289
     90            void updateHumanHUD();
     91            void updateGametypeHUD();
     92
    6393            std::string nick_;
    6494            std::string synchronize_nick_;
     
    6696            bool server_initialized_;
    6797            bool client_initialized_;
     98
     99            std::string humanHudTemplate_;
     100            OverlayGroup* humanHud_;
     101            std::string gametypeHudTemplate_;
     102            OverlayGroup* gametypeHud_;
    68103    };
    69104}
  • code/trunk/src/orxonox/objects/infos/PlayerInfo.cc

    r2662 r2826  
    141141        if (this->controller_)
    142142            this->controller_->setControllableEntity(entity);
     143
     144        this->changedControllableEntity();
    143145    }
    144146
     
    155157            if (callback)
    156158                entity->removePlayer();
     159
     160            this->changedControllableEntity();
    157161        }
    158162    }
  • code/trunk/src/orxonox/objects/infos/PlayerInfo.h

    r2662 r2826  
    4949            virtual void changedGametype();
    5050
     51            virtual void changedController() {}
     52            virtual void changedControllableEntity() {}
     53
    5154            inline bool isHumanPlayer() const
    5255                { return this->bHumanPlayer_; }
     
    7376            inline Controller* getController() const
    7477                { return this->controller_; }
    75             virtual void changedController() {}
    7678
    7779        protected:
Note: See TracChangeset for help on using the changeset viewer.