Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:36:08 AM (15 years ago)
Author:
dafrick
Message:

Merging of the current QuestSystem branch.

Location:
code/branches/questsystem5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/orxonox/objects/infos/HumanPlayer.cc

    r2662 r2907  
    3030#include "HumanPlayer.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/ConfigValueIncludes.h"
     
    4747        RegisterObject(HumanPlayer);
    4848
    49         this->server_initialized_ = Core::isMaster();
     49        this->server_initialized_ = GameMode::isMaster();
    5050        this->client_initialized_ = false;
    5151
     
    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
     
    8293            this->synchronize_nick_ = this->nick_;
    8394
    84             if (Core::isMaster())
     95            if (GameMode::isMaster())
    8596                this->setName(this->nick_);
    8697        }
     
    89100    void HumanPlayer::configvaluecallback_changedHUDTemplate()
    90101    {
    91         this->changedController();
     102        this->setHumanHUDTemplate(this->hudtemplate_);
    92103    }
    93104
     
    105116            this->client_initialized_ = true;
    106117
    107             if (!Core::isMaster())
     118            if (!GameMode::isMaster())
    108119                this->setObjectMode(objectDirection::bidirectional);
    109120            else
     
    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
     177    void HumanPlayer::updateHumanHUD()
     178    {
     179        if (this->humanHud_)
     180        {
     181            delete this->humanHud_;
     182            this->humanHud_ = 0;
     183        }
     184
     185        if (this->isLocalPlayer() && this->humanHudTemplate_ != "")
     186        {
     187            this->humanHud_ = new OverlayGroup(this);
     188            this->humanHud_->addTemplate(this->humanHudTemplate_);
     189            this->humanHud_->setOwner(this->getControllableEntity());
     190        }
     191    }
     192
     193    void HumanPlayer::updateGametypeHUD()
     194    {
     195        if (this->gametypeHud_)
     196        {
     197            delete this->gametypeHud_;
     198            this->gametypeHud_ = 0;
     199        }
     200
     201        if (this->isLocalPlayer() && this->gametypeHudTemplate_ != "")
     202        {
     203            this->gametypeHud_ = new OverlayGroup(this);
     204            this->gametypeHud_->addTemplate(this->gametypeHudTemplate_);
     205            this->gametypeHud_->setOwner(this->getGametype());
    156206        }
    157207    }
Note: See TracChangeset for help on using the changeset viewer.