Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10575


Ignore:
Timestamp:
Sep 9, 2015, 2:02:01 PM (9 years ago)
Author:
landauf
Message:

create the scoreboard directly with the correct gametype. this prevents that we have to re-set the gametype (and pass it to sub-overlays).

Location:
code/branches/core7/src/orxonox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/orxonox/Level.cc

    r10573 r10575  
    122122
    123123        Gametype* rootgametype = orxonox_cast<Gametype*>(identifier->fabricate(this));
     124
    124125        rootgametype->setLevel(NULL); // avoid circular references
    125126        this->setGametype(rootgametype);
     127        rootgametype->init(); // call init() AFTER the gametype was set
    126128
    127129        if (LevelManager::exists())
  • code/branches/core7/src/orxonox/gametypes/Gametype.cc

    r10555 r10575  
    6464
    6565        this->gtinfo_ = new GametypeInfo(context);
    66         this->gtinfo_->setGametype(this);
    6766
    6867        this->defaultControllableEntity_ = Class(Spectator);
     68        this->scoreboard_ = 0;
    6969
    7070        this->bAutoStart_ = false;
     
    8181        this->setConfigValues();
    8282
     83        ModifyConsoleCommand(__CC_addBots_name).setObject(this);
     84        ModifyConsoleCommand(__CC_killBots_name).setObject(this);
     85    }
     86
     87    Gametype::~Gametype()
     88    {
     89        if (this->isInitialized())
     90        {
     91            if (this->gtinfo_)
     92                this->gtinfo_->destroy();
     93
     94            ModifyConsoleCommand(__CC_addBots_name).setObject(NULL);
     95            ModifyConsoleCommand(__CC_killBots_name).setObject(NULL);
     96        }
     97    }
     98
     99    /**
     100     * @brief Initializes sub-objects of the Gametype. This must be called after the constructor.
     101     * At this point, the context is expected to have the current gametype. This allows to pass the current gametype to the sub-objects via constructor.
     102     */
     103    void Gametype::init()
     104    {
    83105        // load the corresponding score board
    84106        if (GameMode::showsGraphics() && !this->scoreboardTemplate_.empty())
    85107        {
    86             this->scoreboard_ = new OverlayGroup(context);
     108            this->scoreboard_ = new OverlayGroup(this->getContext());
    87109            this->scoreboard_->addTemplate(this->scoreboardTemplate_);
    88             this->scoreboard_->setGametype(this);
    89         }
    90         else
    91             this->scoreboard_ = 0;
    92 
    93         ModifyConsoleCommand(__CC_addBots_name).setObject(this);
    94         ModifyConsoleCommand(__CC_killBots_name).setObject(this);
    95     }
    96 
    97     Gametype::~Gametype()
    98     {
    99         if (this->isInitialized())
    100         {
    101             if (this->gtinfo_)
    102                 this->gtinfo_->destroy();
    103 
    104             ModifyConsoleCommand(__CC_addBots_name).setObject(NULL);
    105             ModifyConsoleCommand(__CC_killBots_name).setObject(NULL);
    106110        }
    107111    }
  • code/branches/core7/src/orxonox/gametypes/Gametype.h

    r10554 r10575  
    7272            virtual ~Gametype();
    7373
     74            virtual void init();
     75
    7476            void setConfigValues();
    7577
  • code/branches/core7/src/orxonox/overlays/OverlayGroup.cc

    r10571 r10575  
    149149        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    150150            (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed
    151     }
    152 
    153     //! Changes the gametype of all elements
    154     void OverlayGroup::changedGametype()
    155     {
    156         SUPER( OverlayGroup, changedGametype );
    157 
    158         for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    159             (*it)->setGametype(this->getGametype());
    160151    }
    161152
  • code/branches/core7/src/orxonox/overlays/OverlayGroup.h

    r10555 r10575  
    6969
    7070        virtual void changedVisibility();
    71         virtual void changedGametype();
    7271
    7372        void setOwner(BaseObject* owner);
Note: See TracChangeset for help on using the changeset viewer.