Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2024


Ignore:
Timestamp:
Oct 28, 2008, 3:05:17 AM (15 years ago)
Author:
landauf
Message:

added spaceship

Location:
code/branches/objecthierarchy/src
Files:
4 added
18 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/core/CommandEvaluation.cc

    r1879 r2024  
    7878        if (this->bEvaluatedParams_ && this->function_)
    7979        {
    80             COUT(5) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;
     80            COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;
    8181            (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
    8282            return true;
  • code/branches/objecthierarchy/src/core/Identifier.h

    r2019 r2024  
    487487            SubclassIdentifier<T>& operator=(Identifier* identifier)
    488488            {
    489                 if (!identifier->isA(ClassIdentifier<T>::getIdentifier()))
     489                if (!identifier || !identifier->isA(ClassIdentifier<T>::getIdentifier()))
    490490                {
    491491                    COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
    492                     COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
    493                     COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
    494                     COUT(1) << "Aborting..." << std::endl;
    495                     abort();
     492                    if (identifier)
     493                    {
     494                        COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
     495                        COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
     496                    }
     497                    else
     498                    {
     499                        COUT(1) << "Error: Can't assign NULL identifier" << std::endl;
     500                    }
    496501                }
    497                 this->identifier_ = identifier;
     502                else
     503                {
     504                    this->identifier_ = identifier;
     505                }
    498506                return *this;
    499507            }
  • code/branches/objecthierarchy/src/core/Template.cc

    r2019 r2024  
    149149            return it->second;
    150150        else
     151        {
     152            COUT(2) << "Warning: Template with name " << name << " doesn't exist." << std::endl;
    151153            return 0;
     154        }
    152155    }
    153156
  • code/branches/objecthierarchy/src/orxonox/CMakeLists.txt

    r2019 r2024  
    6969
    7070  objects/worldentities/pawns/Spectator.cc
     71  objects/worldentities/pawns/Pawn.cc
     72  objects/worldentities/pawns/SpaceShip.cc
    7173
    7274  objects/controllers/Controller.cc
  • code/branches/objecthierarchy/src/orxonox/objects/Scene.cc

    r2023 r2024  
    8585    Scene::~Scene()
    8686    {
    87         if (Ogre::Root::getSingletonPtr())
     87        if (this->isInitialized())
    8888        {
    89 //            this->sceneManager_->destroySceneNode(this->rootSceneNode_->getName()); // TODO: remove getName() for newer versions of Ogre
    90             Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    91         }
    92         else if (!Core::showsGraphics())
    93         {
    94             delete this->sceneManager_;
     89            if (Ogre::Root::getSingletonPtr())
     90            {
     91//                this->sceneManager_->destroySceneNode(this->rootSceneNode_->getName()); // TODO: remove getName() for newer versions of Ogre
     92                Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
     93            }
     94            else if (!Core::showsGraphics())
     95            {
     96                delete this->sceneManager_;
     97            }
    9598        }
    9699    }
  • code/branches/objecthierarchy/src/orxonox/objects/controllers/HumanController.cc

    r2019 r2024  
    6767    {
    6868        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    69             HumanController::localController_s->controllableEntity_->moveFrontBack(value.y);
     69            HumanController::localController_s->controllableEntity_->moveFrontBack(value);
    7070    }
    7171
     
    7373    {
    7474        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    75             HumanController::localController_s->controllableEntity_->moveRightLeft(value.y);
     75            HumanController::localController_s->controllableEntity_->moveRightLeft(value);
    7676    }
    7777
     
    7979    {
    8080        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    81             HumanController::localController_s->controllableEntity_->moveUpDown(value.y);
     81            HumanController::localController_s->controllableEntity_->moveUpDown(value);
    8282    }
    8383
     
    8585    {
    8686        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    87             HumanController::localController_s->controllableEntity_->rotateYaw(value.y);
     87            HumanController::localController_s->controllableEntity_->rotateYaw(value);
    8888    }
    8989
     
    9191    {
    9292        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    93             HumanController::localController_s->controllableEntity_->rotatePitch(value.y);
     93            HumanController::localController_s->controllableEntity_->rotatePitch(value);
    9494    }
    9595
     
    9797    {
    9898        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    99             HumanController::localController_s->controllableEntity_->rotateRoll(value.y);
     99            HumanController::localController_s->controllableEntity_->rotateRoll(value);
    100100    }
    101101
  • code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.cc

    r2020 r2024  
    4848        RegisterObject(Gametype);
    4949
    50         this->defaultPawn_ = Class(Spectator);
     50        this->defaultControllableEntity_ = Class(Spectator);
     51
    5152        this->bStarted_ = false;
    5253        this->bEnded_ = false;
    5354        this->bAutoStart_ = false;
     55        this->bForceSpawn_ = false;
     56
     57        this->initialStartCountdown_ = 3;
     58        this->startCountdown_ = 0;
     59        this->bStartCountdownRunning_ = false;
    5460
    5561        COUT(0) << "created Gametype" << std::endl;
     
    5864    void Gametype::tick(float dt)
    5965    {
     66        if (this->bStartCountdownRunning_ && !this->bStarted_)
     67            this->startCountdown_ -= dt;
     68
    6069        if (!this->bStarted_)
    6170            this->checkStart();
    6271
    6372        this->assignDefaultPawnsIfNeeded();
     73        this->spawnDeadPlayersIfRequested();
    6474    }
    6575
     
    6979        this->bStarted_ = true;
    7080
    71         for (std::set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    72             this->spawnPlayer(*it);
     81        this->spawnPlayersIfRequested();
    7382    }
    7483
     
    122131    }
    123132
    124     void Gametype::playerSpawned(PlayerInfo* player)
    125     {
    126     }
    127 
    128     void Gametype::playerDied(PlayerInfo* player)
     133    void Gametype::pawnPreSpawn(Pawn* pawn)
     134    {
     135    }
     136
     137    void Gametype::pawnPostSpawn(Pawn* pawn)
     138    {
     139    }
     140
     141    void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
    129142    {
    130143    }
     
    164177                {
    165178                    // force spawn at spawnpoint with default pawn
    166                     ControllableEntity* newpawn = this->defaultPawn_.fabricate(spawn);
    167                     spawn->spawn(newpawn);
    168                     (*it)->startControl(newpawn);
     179                    ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
     180                    spawn->spawn(entity);
     181                    (*it)->startControl(entity);
    169182                }
    170183                else
     
    181194        if (!this->bStarted_)
    182195        {
    183             if (this->players_.size() > 0)
     196            if (this->bStartCountdownRunning_)
     197            {
     198                if (this->startCountdown_ <= 0)
     199                {
     200                    this->bStartCountdownRunning_ = false;
     201                    this->startCountdown_ = 0;
     202                    this->start();
     203                }
     204            }
     205            else if (this->players_.size() > 0)
    184206            {
    185207                if (this->bAutoStart_)
     
    196218                    }
    197219                    if (allplayersready)
    198                         this->start();
    199                 }
    200             }
    201         }
     220                    {
     221                        this->startCountdown_ = this->initialStartCountdown_;
     222                        this->bStartCountdownRunning_ = true;
     223                    }
     224                }
     225            }
     226        }
     227    }
     228
     229    void Gametype::spawnPlayersIfRequested()
     230    {
     231        for (std::set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     232            if ((*it)->isReadyToSpawn() || this->bForceSpawn_)
     233                this->spawnPlayer(*it);
     234    }
     235
     236    void Gametype::spawnDeadPlayersIfRequested()
     237    {
     238        for (std::set<PlayerInfo*>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     239            if (!(*it)->getControllableEntity())
     240                if ((*it)->isReadyToSpawn() || this->bForceSpawn_)
     241                    this->spawnPlayer(*it);
    202242    }
    203243
    204244    void Gametype::spawnPlayer(PlayerInfo* player)
    205245    {
    206         if (player->isReadyToSpawn())
    207         {
    208             SpawnPoint* spawnpoint = this->getBestSpawnPoint(player);
    209             if (spawnpoint)
    210             {
    211                 player->startControl(spawnpoint->spawn());
    212             }
    213             else
    214             {
    215                 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
    216                 abort();
    217             }
     246        SpawnPoint* spawnpoint = this->getBestSpawnPoint(player);
     247        if (spawnpoint)
     248        {
     249            player->startControl(spawnpoint->spawn());
     250        }
     251        else
     252        {
     253            COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
     254            abort();
    218255        }
    219256    }
  • code/branches/objecthierarchy/src/orxonox/objects/gametypes/Gametype.h

    r2019 r2024  
    5151            virtual void tick(float dt);
    5252
     53            inline bool hasStarted() const
     54                { return this->bStarted_; }
     55            inline bool hasEnded() const
     56                { return this->bEnded_; }
     57
    5358            virtual void start();
    5459            virtual void end();
     
    5863            virtual void playerSwitchedBack(PlayerInfo* player, Gametype* oldgametype);
    5964            virtual void playerChangedName(PlayerInfo* player);
    60             virtual void playerSpawned(PlayerInfo* player);
    61             virtual void playerDied(PlayerInfo* player);
     65
    6266            virtual void playerScored(PlayerInfo* player);
     67
     68            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
     69            virtual void pawnPreSpawn(Pawn* pawn);
     70            virtual void pawnPostSpawn(Pawn* pawn);
    6371
    6472            inline const std::set<PlayerInfo*>& getPlayers() const
     
    6775            inline void registerSpawnPoint(SpawnPoint* spawnpoint)
    6876                { this->spawnpoints_.insert(spawnpoint); }
     77
     78            inline bool isStartCountdownRunning() const
     79                { return this->bStartCountdownRunning_; }
     80            inline float getStartCountdown() const
     81                { return this->startCountdown_; }
    6982
    7083        private:
     
    7790            void checkStart();
    7891            void spawnPlayer(PlayerInfo* player);
     92            void spawnPlayersIfRequested();
     93            void spawnDeadPlayersIfRequested();
    7994
    8095            bool bStarted_;
    8196            bool bEnded_;
    8297            bool bAutoStart_;
     98            bool bForceSpawn_;
     99
     100            float initialStartCountdown_;
     101            float startCountdown_;
     102            bool bStartCountdownRunning_;
     103
    83104            std::set<PlayerInfo*> players_;
    84105            std::set<SpawnPoint*> spawnpoints_;
    85             SubclassIdentifier<ControllableEntity> defaultPawn_;
     106            SubclassIdentifier<ControllableEntity> defaultControllableEntity_;
    86107    };
    87108}
  • code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc

    r2019 r2024  
    121121            this->controllableEntityID_ = entity->getObjectID();
    122122            entity->setPlayer(this);
     123            this->bReadyToSpawn_ = false;
    123124        }
    124125        else
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.h

    r2019 r2024  
    5757                { return this->bDestroyWhenPlayerLeft_; }
    5858
    59             virtual void moveFrontBack(float value) {}
    60             virtual void moveRightLeft(float value) {}
    61             virtual void moveUpDown(float value) {}
     59            virtual void moveFrontBack(const Vector2& value) {}
     60            virtual void moveRightLeft(const Vector2& value) {}
     61            virtual void moveUpDown(const Vector2& value) {}
    6262
    63             virtual void rotateYaw(float value) {}
    64             virtual void rotatePitch(float value) {}
    65             virtual void rotateRoll(float value) {}
     63            virtual void rotateYaw(const Vector2& value) {}
     64            virtual void rotatePitch(const Vector2& value) {}
     65            virtual void rotateRoll(const Vector2& value) {}
    6666
    6767            virtual void fire() {}
     
    108108                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
    109109
     110            inline Camera* getCamera() const
     111                { return this->camera_; }
     112            inline OverlayGroup* getHUD() const
     113                { return this->hud_; }
     114
    110115        protected:
    111116            virtual void startLocalControl();
     
    117122            inline bool isLocallyControlled() const
    118123                { return this->bControlled_; }
     124
     125            Vector3 acceleration_;
    119126
    120127        private:
     
    136143
    137144            Vector3 velocity_;
    138             Vector3 acceleration_;
    139145
    140146            bool bControlled_;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/SpawnPoint.cc

    r2019 r2024  
    5757
    5858        XMLPortParam(SpawnPoint, "spawnclass", setSpawnClassName, getSpawnClassName, xmlelement, mode);
    59         XMLPortParam(SpawnPoint, "design", setTemplateName, getTemplateName, xmlelement, mode);
     59        XMLPortParam(SpawnPoint, "pawndesign", setTemplateName, getTemplateName, xmlelement, mode);
    6060    }
    6161
     
    7272    }
    7373
    74     ControllableEntity* SpawnPoint::spawn()
     74    Pawn* SpawnPoint::spawn()
    7575    {
    76         ControllableEntity* entity = this->spawnclass_.fabricate(this);
     76        Pawn* entity = this->spawnclass_.fabricate(this);
    7777        if (entity)
    7878        {
     79            this->getGametype()->pawnPreSpawn(entity);
    7980            this->spawn(entity);
    8081            if (this->template_)
    8182                entity->addTemplate(this->template_);
     83            entity->postSpawn();
     84            this->getGametype()->pawnPostSpawn(entity);
    8285        }
    8386        return entity;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/SpawnPoint.h

    r2019 r2024  
    3535#include "core/Template.h"
    3636#include "PositionableEntity.h"
    37 #include "ControllableEntity.h"
     37#include "objects/worldentities/pawns/Pawn.h"
    3838
    3939namespace orxonox
     
    5757                { return this->template_; }
    5858
    59             ControllableEntity* spawn();
     59            Pawn* spawn();
    6060            void spawn(ControllableEntity* entity);
    6161
     
    6969                { return this->templatename_; }
    7070
    71             SubclassIdentifier<ControllableEntity> spawnclass_;
     71            SubclassIdentifier<Pawn> spawnclass_;
    7272            std::string spawnclassname_;
    7373            Template* template_;
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2019 r2024  
    3535#include "objects/Scene.h"
    3636#include "objects/infos/PlayerInfo.h"
     37#include "objects/gametypes/Gametype.h"
    3738#include "tools/BillboardSet.h"
     39#include "overlays/OverlayText.h"
     40#include "overlays/OverlayGroup.h"
     41#include "util/Convert.h"
    3842
    3943namespace orxonox
     
    5458
    5559        this->setDestroyWhenPlayerLeft(true);
    56 
    57         // test test test
    58         if (this->getScene()->getSceneManager())
    59         {
    60             this->testmesh_ = new Mesh();
    61             this->testnode_ = this->getNode()->createChildSceneNode();
    62             this->testmesh_->setMeshSource(this->getScene()->getSceneManager(), "assff.mesh");
    63             if (this->testmesh_->getEntity())
    64                 this->testnode_->attachObject(this->testmesh_->getEntity());
    65             this->testnode_->pitch(Degree(-90));
    66             this->testnode_->roll(Degree(+90));
    67             this->testnode_->scale(10, 10, 10);
    68         }
    69         else
    70         {
    71             this->testmesh_ = 0;
    72             this->testnode_ = 0;
    73         }
    74         // test test test
    7560
    7661        this->greetingFlare_ = new BillboardSet();
     
    9378                delete this->greetingFlare_;
    9479            }
    95 
    96             // test test test
    97             {
    98                 if (this->testmesh_ && this->testnode_)
    99                     this->testnode_->detachObject(this->testmesh_->getEntity());
    100 
    101                 if (this->testmesh_)
    102                     delete this->testmesh_;
    103 
    104                 if (this->testnode_)
    105                     this->getNode()->removeAndDestroyChild(this->testnode_->getName());
    106             }
    107             // test test test
    10880        }
    10981    }
     
    130102        if (this->isLocallyControlled())
    131103        {
     104            this->updateHUD();
     105
    132106            Vector3 velocity = this->getVelocity();
    133107            velocity.normalise();
     
    159133    {
    160134        ControllableEntity::startLocalControl();
    161         if (this->isLocallyControlled())
    162             this->testmesh_->setVisible(false);
    163     }
    164 
    165     void Spectator::moveFrontBack(float value)
    166     {
    167         this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::FRONT);
    168     }
    169 
    170     void Spectator::moveRightLeft(float value)
    171     {
    172         this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::RIGHT);
    173     }
    174 
    175     void Spectator::moveUpDown(float value)
    176     {
    177         this->setVelocity(this->getVelocity() + value * this->speed_ * WorldEntity::UP);
    178     }
    179 
    180     void Spectator::rotateYaw(float value)
    181     {
    182         this->yaw_ = value;
    183     }
    184 
    185     void Spectator::rotatePitch(float value)
    186     {
    187         this->pitch_ = value;
    188     }
    189 
    190     void Spectator::rotateRoll(float value)
    191     {
    192         this->roll_ = value;
     135//        if (this->isLocallyControlled())
     136//            this->testmesh_->setVisible(false);
     137    }
     138
     139    void Spectator::moveFrontBack(const Vector2& value)
     140    {
     141        this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::FRONT);
     142    }
     143
     144    void Spectator::moveRightLeft(const Vector2& value)
     145    {
     146        this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::RIGHT);
     147    }
     148
     149    void Spectator::moveUpDown(const Vector2& value)
     150    {
     151        this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::UP);
     152    }
     153
     154    void Spectator::rotateYaw(const Vector2& value)
     155    {
     156        this->yaw_ = value.y;
     157    }
     158
     159    void Spectator::rotatePitch(const Vector2& value)
     160    {
     161        this->pitch_ = value.y;
     162    }
     163
     164    void Spectator::rotateRoll(const Vector2& value)
     165    {
     166        this->roll_ = value.y;
    193167    }
    194168
     
    209183        }
    210184    }
     185
     186    void Spectator::updateHUD()
     187    {
     188        // <hack>
     189        if (this->getHUD())
     190        {
     191            std::string text;
     192
     193            if (this->getPlayer() && this->getGametype())
     194            {
     195                if (!this->getGametype()->hasStarted() && !this->getGametype()->isStartCountdownRunning())
     196                {
     197                    if (!this->getPlayer()->isReadyToSpawn())
     198                        text = "Press [Fire] to start the match";
     199                    else
     200                        text = "Waiting for other players";
     201                }
     202                else if (!this->getGametype()->hasEnded())
     203                {
     204                    if (this->getGametype()->isStartCountdownRunning())
     205                    {
     206                        text = convertToString(ceil(this->getGametype()->getStartCountdown()));
     207                    }
     208                    else
     209                    {
     210                        text = "Press [Fire] to respawn";
     211                    }
     212                }
     213                else
     214                {
     215                    text = "Game has ended";
     216                }
     217            }
     218            else
     219            {
     220                return;
     221            }
     222
     223            std::map<std::string, OrxonoxOverlay*>::const_iterator it = this->getHUD()->getOverlays().begin();
     224            for (; it != this->getHUD()->getOverlays().end(); ++it)
     225            {
     226                if (it->second->isA(Class(OverlayText)) && it->second->getName() == "state")
     227                {
     228                    OverlayText* overlay = dynamic_cast<OverlayText*>(it->second);
     229                    if (overlay)
     230                        overlay->setCaption(text);
     231                    break;
     232                }
     233            }
     234        }
     235        // </hack>
     236    }
    211237}
  • code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.h

    r2019 r2024  
    4848            virtual void startLocalControl();
    4949
    50             virtual void moveFrontBack(float value);
    51             virtual void moveRightLeft(float value);
    52             virtual void moveUpDown(float value);
     50            virtual void moveFrontBack(const Vector2& value);
     51            virtual void moveRightLeft(const Vector2& value);
     52            virtual void moveUpDown(const Vector2& value);
    5353
    54             virtual void rotateYaw(float value);
    55             virtual void rotatePitch(float value);
    56             virtual void rotateRoll(float value);
     54            virtual void rotateYaw(const Vector2& value);
     55            virtual void rotatePitch(const Vector2& value);
     56            virtual void rotateRoll(const Vector2& value);
    5757
    5858            virtual void fire();
     
    6262            void changedGreeting();
    6363            void changedFlareVisibility();
     64            void updateHUD();
    6465
    6566            BillboardSet* greetingFlare_;
     
    7374            float pitch_;
    7475            float roll_;
    75 
    76             // test test test
    77             Mesh* testmesh_;
    78             Ogre::SceneNode* testnode_;
    79             // test test test
    8076    };
    8177}
  • code/branches/objecthierarchy/src/orxonox/overlays/OverlayGroup.cc

    r2019 r2024  
    5353    {
    5454        RegisterObject(OverlayGroup);
     55    }
     56
     57    OverlayGroup::~OverlayGroup()
     58    {
     59        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     60            delete it->second;
    5561    }
    5662
  • code/branches/objecthierarchy/src/orxonox/overlays/OverlayGroup.h

    r2019 r2024  
    5656        OverlayGroup(BaseObject* creator);
    5757        //! Empty destructor.
    58         ~OverlayGroup() { }
     58        ~OverlayGroup();
    5959
    6060        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
     
    6363        static void scaleGroup(const std::string& name, float scale);
    6464        static void scrollGroup(const std::string& name, const Vector2& scroll);
     65
     66        inline const std::map<std::string, OrxonoxOverlay*>& getOverlays() const
     67            { return this->hudElements_; }
    6568
    6669        void changedVisibility();
  • code/branches/objecthierarchy/src/orxonox/overlays/OverlayText.cc

    r2019 r2024  
    6565        }
    6666
    67         XMLPortParam(OverlayText, "font",     setFont,     getFont,     xmlElement, mode).defaultValues("Monofur");
    68         XMLPortParam(OverlayText, "colour",   setColour,   getColour,   xmlElement, mode).defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
    69         XMLPortParam(OverlayText, "caption",  setCaption,  getCaption,  xmlElement, mode).defaultValues("");
    70         XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(1.0f);
    71         XMLPortParamTemplate(OverlayText, "align", setAlignment, getAlignment, xmlElement, mode, const std::string&).defaultValues("left");
     67        XMLPortParam(OverlayText, "font",     setFont,            getFont,            xmlElement, mode).defaultValues("Monofur");
     68        XMLPortParam(OverlayText, "colour",   setColour,          getColour,          xmlElement, mode).defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
     69        XMLPortParam(OverlayText, "caption",  setCaption,         getCaption,         xmlElement, mode).defaultValues("");
     70        XMLPortParam(OverlayText, "textSize", setTextSize,        getTextSize,        xmlElement, mode).defaultValues(1.0f);
     71        XMLPortParam(OverlayText, "align",    setAlignmentString, getAlignmentString, xmlElement, mode).defaultValues("left");
    7272    }
    7373
     
    106106    }
    107107
    108     void OverlayText::setAlignment(const std::string& alignment)
     108    Ogre::TextAreaOverlayElement::Alignment OverlayText::getAlignment() const
     109    {
     110        if (this->text_)
     111            return this->text_->getAlignment();
     112        else
     113            return Ogre::TextAreaOverlayElement::Left;
     114    }
     115
     116    void OverlayText::setAlignmentString(const std::string& alignment)
    109117    {
    110118        if (alignment == "right")
     
    116124    }
    117125
    118     std::string OverlayText::getAlignment() const
     126    std::string OverlayText::getAlignmentString() const
    119127    {
    120128        if (this->text_)
  • code/branches/objecthierarchy/src/orxonox/overlays/OverlayText.h

    r2019 r2024  
    4747        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    4848
    49     protected:
    50         virtual void sizeChanged();
    51 
    5249        void setCaption(const std::string& caption);
    5350        const std::string& getCaption() const       { return this->caption_; }
     
    6057
    6158        void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment);
    62         void setAlignment(const std::string& alignment);
    63         std::string getAlignment() const;
     59        Ogre::TextAreaOverlayElement::Alignment getAlignment() const;
     60
     61    protected:
     62        virtual void sizeChanged();
     63
     64        void setAlignmentString(const std::string& alignment);
     65        std::string getAlignmentString() const;
    6466
    6567        void setTextSize(float size) { this->setSize(Vector2(size, size)); }
Note: See TracChangeset for help on using the changeset viewer.