Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.