Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 14, 2009, 10:17:35 PM (16 years ago)
Author:
rgrieder
Message:

Merged presentation branch back to trunk.

Location:
code/trunk
Files:
7 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/objects/infos/CMakeLists.txt

    r2171 r2662  
    11SET( SRC_FILES
     2  Bot.cc
    23  Info.cc
    34  PlayerInfo.cc
    45  HumanPlayer.cc
     6  GametypeInfo.cc
    57)
    68
  • code/trunk/src/orxonox/objects/infos/HumanPlayer.cc

    r2171 r2662  
    3737#include "objects/controllers/HumanController.h"
    3838#include "objects/gametypes/Gametype.h"
     39#include "overlays/OverlayGroup.h"
    3940
    4041namespace orxonox
     
    6364    {
    6465        SetConfigValue(nick_, "Player").callback(this, &HumanPlayer::configvaluecallback_changednick);
     66        SetConfigValue(hudtemplate_, "defaultHUD").callback(this, &HumanPlayer::configvaluecallback_changedHUDTemplate);
    6567    }
    6668
    6769    void HumanPlayer::registerVariables()
    6870    {
    69         REGISTERSTRING(this->synchronize_nick_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
     71        registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
    7072
    71         REGISTERDATA(this->clientID_,     direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
    72         REGISTERDATA(this->server_initialized_, direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
    73         REGISTERDATA(this->client_initialized_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
     73        registerVariable(this->clientID_,           variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
     74        registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
     75        registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
    7476    }
    7577
     
    8385                this->setName(this->nick_);
    8486        }
     87    }
     88
     89    void HumanPlayer::configvaluecallback_changedHUDTemplate()
     90    {
     91        this->changedController();
    8592    }
    8693
     
    99106
    100107            if (!Core::isMaster())
    101                 this->setObjectMode(direction::bidirectional);
     108                this->setObjectMode(objectDirection::bidirectional);
    102109            else
    103110                this->setName(this->nick_);
     
    138145        this->networkcallback_clientIDchanged();
    139146    }
     147
     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());
     156        }
     157    }
    140158}
  • code/trunk/src/orxonox/objects/infos/HumanPlayer.h

    r2171 r2662  
    3333
    3434#include "PlayerInfo.h"
    35 #include "core/Identifier.h"
    36 #include "objects/controllers/Controller.h"
    3735
    3836namespace orxonox
     
    5351            void setClientID(unsigned int clientID);
    5452
     53            virtual void changedController();
     54
    5555        protected:
    5656            void configvaluecallback_changednick();
     57            void configvaluecallback_changedHUDTemplate();
    5758            void networkcallback_changednick();
    5859            void networkcallback_clientIDchanged();
     
    6263            std::string nick_;
    6364            std::string synchronize_nick_;
     65            std::string hudtemplate_;
    6466            bool server_initialized_;
    6567            bool client_initialized_;
  • code/trunk/src/orxonox/objects/infos/Info.h

    r2171 r2662  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "network/Synchronisable.h"
     34#include "network/synchronisable/Synchronisable.h"
    3535#include "core/BaseObject.h"
    3636
  • code/trunk/src/orxonox/objects/infos/PlayerInfo.cc

    r2171 r2662  
    4646        this->bLocalPlayer_ = false;
    4747        this->bReadyToSpawn_ = false;
     48        this->bSetUnreadyAfterSpawn_ = true;
    4849        this->controller_ = 0;
    4950        this->controllableEntity_ = 0;
     
    6465                this->controller_ = 0;
    6566            }
     67
     68            if (this->getGametype())
     69                this->getGametype()->playerLeft(this);
    6670        }
    6771    }
     
    6973    void PlayerInfo::registerVariables()
    7074    {
    71         REGISTERSTRING(this->name_,                 direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
    72         REGISTERDATA  (this->controllableEntityID_, direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
    73         REGISTERDATA  (this->bReadyToSpawn_,        direction::toserver);
     75        registerVariable(this->name_,                 variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
     76        registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
     77        registerVariable(this->bReadyToSpawn_,        variableDirection::toserver);
    7478    }
    7579
    7680    void PlayerInfo::changedName()
    7781    {
     82        SUPER(PlayerInfo, changedName);
     83
    7884        if (this->isInitialized() && this->getGametype())
    7985            this->getGametype()->playerChangedName(this);
     
    109115        if (this->controllableEntity_)
    110116            this->controller_->setControllableEntity(this->controllableEntity_);
     117        this->changedController();
    111118    }
    112119
    113     void PlayerInfo::startControl(ControllableEntity* entity)
     120    void PlayerInfo::startControl(ControllableEntity* entity, bool callback)
    114121    {
     122        if (entity == this->controllableEntity_)
     123            return;
     124
    115125        if (this->controllableEntity_)
    116             this->stopControl(this->controllableEntity_);
     126            this->stopControl(this->controllableEntity_, callback);
    117127
    118128        this->controllableEntity_ = entity;
     
    122132            this->controllableEntityID_ = entity->getObjectID();
    123133            entity->setPlayer(this);
    124             this->bReadyToSpawn_ = false;
     134            this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
    125135        }
    126136        else
  • code/trunk/src/orxonox/objects/infos/PlayerInfo.h

    r2171 r2662  
    6565                { return this->bReadyToSpawn_; }
    6666
    67             void startControl(ControllableEntity* entity);
     67            void startControl(ControllableEntity* entity, bool callback = true);
    6868            void stopControl(ControllableEntity* entity, bool callback = true);
    6969
     
    7171                { return this->controllableEntity_; }
    7272
     73            inline Controller* getController() const
     74                { return this->controller_; }
     75            virtual void changedController() {}
     76
    7377        protected:
    7478            void createController();
    75             void networkcallback_changedcontrollableentityID();
    7679
    7780            bool bHumanPlayer_;
    7881            bool bLocalPlayer_;
     82            bool bSetUnreadyAfterSpawn_;
     83            SubclassIdentifier<Controller> defaultController_;
     84            unsigned int clientID_;
     85
     86        private:
     87            void networkcallback_changedcontrollableentityID();
     88
    7989            bool bReadyToSpawn_;
    80             SubclassIdentifier<Controller> defaultController_;
    8190            Controller* controller_;
    8291            ControllableEntity* controllableEntity_;
    8392            unsigned int controllableEntityID_;
    84             unsigned int clientID_;
    8593    };
    8694}
Note: See TracChangeset for help on using the changeset viewer.