Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 16, 2009, 2:11:14 AM (15 years ago)
Author:
landauf
Message:
  • Moved default-hud (chat, gamestate info) from Controller to HumanPlayer
  • Added support for a Gametype-HUD to Gametype and PlayerInfo
File:
1 edited

Legend:

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

    r2662 r2789  
    3535#include "network/ClientInformation.h"
    3636#include "objects/gametypes/Gametype.h"
     37#include "overlays/OverlayGroup.h"
    3738
    3839namespace orxonox
     
    5051        this->controllableEntity_ = 0;
    5152        this->controllableEntityID_ = CLIENTID_UNKNOWN;
     53        this->gametypeHud_ = 0;
    5254
    5355        this->registerVariables();
     
    6870            if (this->getGametype())
    6971                this->getGametype()->playerLeft(this);
     72
     73            if (this->BaseObject::isInitialized() && this->gametypeHud_)
     74                delete this->gametypeHud_;
    7075        }
    7176    }
     
    104109                else
    105110                    this->getGametype()->playerEntered(this);
     111
     112                if (this->isLocalPlayer() && this->isHumanPlayer())
     113                    if (this->getGametype()->getHUDTemplate() != "")
     114                        this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());
    106115            }
    107116        }
     
    141150        if (this->controller_)
    142151            this->controller_->setControllableEntity(entity);
     152
     153        this->changedControllableEntity();
    143154    }
    144155
     
    155166            if (callback)
    156167                entity->removePlayer();
     168
     169            this->changedControllableEntity();
    157170        }
    158171    }
     
    172185        }
    173186    }
     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    }
    174209}
Note: See TracChangeset for help on using the changeset viewer.