Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2320 for code/branches/overlay


Ignore:
Timestamp:
Dec 3, 2008, 3:58:01 PM (16 years ago)
Author:
bhildebr
Message:

Completed code for class Scoreboard and fixed some compiler and linker errors

Location:
code/branches/overlay/src/orxonox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/overlay/src/orxonox/CMakeLists.txt

    r2152 r2320  
    3838  overlays/stats/Stats.cc
    3939  overlays/stats/StatsTest.cc
     40  overlays/stats/CreateLines.cc
     41  overlays/stats/Scoreboard.cc
    4042
    4143  tools/BillboardSet.cc
  • code/branches/overlay/src/orxonox/OrxonoxPrereqs.h

    r2096 r2320  
    170170    class OverlayGroup;
    171171    class OverlayText;
     172    class CreateLines;
     173    class Scoreboard;
    172174
    173175    //gui
  • code/branches/overlay/src/orxonox/objects/gametypes/Gametype.cc

    r2181 r2320  
    4040#include "objects/worldentities/pawns/Spectator.h"
    4141#include "objects/worldentities/SpawnPoint.h"
     42#include "Settings.h"
    4243
    4344#include "network/Host.h"
     
    6768
    6869        // load the corresponding score board
    69         statsOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/" + this->statsOverlayName_);
     70        this->statsOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/" + this->statsOverlayName_);
    7071        Loader::open(statsOverlay_);
     72        this->setGametype(this);
    7173    }
    7274
  • code/branches/overlay/src/orxonox/objects/gametypes/Gametype.h

    r2181 r2320  
    8282                { return this->startCountdown_; }
    8383
     84            inline unsigned int getNumberOfPlayers() const
     85                { return this->players_.size(); }
     86
     87            inline std::string getPlayersName() const
     88                { return "StatsBot77"; }
     89
     90            inline unsigned int getPlayersFrags() const
     91                { return 123; }
     92
    8493        private:
    8594            void setConfigValues();
  • code/branches/overlay/src/orxonox/overlays/stats/CreateLines.cc

    r2222 r2320  
    4444
    4545    /**
    46         @brief Constructor: Creates and initializes a line.
     46        @brief Constructor: Creates a line.
    4747    */
    4848    CreateLines::CreateLines(BaseObject* creator)
     
    6363        @brief Ensures that the number of OverlayElements is equal to numberOfColumns.
    6464    */
    65     void setNumberOfColumns(unsigned int numberOfColumns) {
     65    void CreateLines::setNumberOfColumns(unsigned int numberOfColumns, unsigned int lineIndex) {
    6666
    6767        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
    6868
    69         while (textColumns_.getSize() < numberOfColumns) {
     69        while (textColumns_.size() < numberOfColumns) {
    7070
    71             tempTextArea* = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + convertToString(lineIndex)));
    72             textColumns_->add2D(tempTextArea);
     71            Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + convertToString(lineIndex)));
    7372            textColumns_.push_back(tempTextArea);
     73            this->background_->addChild(tempTextArea);
    7474
    7575        }
    7676
    77         while (textColumns_.getSize() > numberOfColumns) {
     77        while (textColumns_.size() > numberOfColumns) {
    7878
    79             ovMan->destroy(textColumns_.back());
     79            this->background_->_removeChild(textColumns_.back());
     80            ovMan->destroyOverlayElement(textColumns_.back());
    8081            textColumns_.pop_back();
    8182
     
    8485    }
    8586
    86     void alignColumn(int columnIndex, float leftOffset) {
     87    void CreateLines::alignColumn(int columnIndex, float leftOffset, float topOffset) {
    8788
    88         this->textColumns_[columnIndex]->setPosition(leftOffset,0);
     89        this->textColumns_[columnIndex]->setPosition(leftOffset, topOffset);
    8990
    9091    }
    9192
    92     void setColumnText(int columnIndex, string columnText) {
     93    void CreateLines::setColumnText(int columnIndex, std::string columnText) {
    9394
    9495        this->textColumns_[columnIndex]->setCaption(columnText);
  • code/branches/overlay/src/orxonox/overlays/stats/CreateLines.h

    r2222 r2320  
    4444
    4545    public: // functions
    46         CreateLines();
    47         ~CreateLines();
     46        CreateLines(BaseObject* creator);
     47        virtual ~CreateLines() {}
    4848
    4949        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    5050
     51        void setNumberOfColumns(unsigned int numberOfColumns, unsigned int lineIndex);
     52        void alignColumn(int columnIndex, float leftOffset, float topOffset);
     53        void setColumnText(int columnIndex, std::string columnText);
     54
    5155    private: // functions
    52         void setNumberOfColumns();
    53         void alignColumn();
    54         void setColumnText();
    5556
    5657    private: // variables
  • code/branches/overlay/src/orxonox/overlays/stats/Scoreboard.cc

    r2225 r2320  
    2626
    2727#include "OrxonoxStableHeaders.h"
    28 #include "CreateLines.h"
     28#include "Scoreboard.h"
    2929
    3030#include <string>
     
    3838#include "core/CoreIncludes.h"
    3939#include "core/ConfigValueIncludes.h"
     40#include "objects/gametypes/Gametype.h"
     41#include "CreateLines.h"
    4042
    4143namespace orxonox
     
    4446
    4547    /**
    46         @brief Constructor: Creates and initializes a line.
     48        @brief Constructor: Creates the scoreboard.
    4749    */
    4850    Scoreboard::Scoreboard(BaseObject* creator)
     
    5254    }
    5355
     56    /**
     57        @brief Prints the scoreboard on the screen.
     58    */
     59    void Scoreboard::printLines() {
     60
     61        numberOfColumns = 2;
     62        numberOfLines = this->gametype_->getNumberOfPlayers();
     63        columnIndex = 0;
     64        topOffset = 0.3;
     65        lineSpacing = 0.1;
     66
     67        for (unsigned int i = 0; i < numberOfLines; i++) {
     68
     69            leftOffset = 0.3;
     70
     71            this->createlines_->setNumberOfColumns(numberOfColumns, i);
     72
     73            columnText = this->gametype_->getPlayersName();
     74            this->createlines_->alignColumn(columnIndex, topOffset, leftOffset);
     75            this->createlines_->setColumnText(columnIndex, columnText);
     76
     77            columnIndex++;
     78            leftOffset = leftOffset + 0.4;
     79
     80            columnText = this->gametype_->getPlayersFrags();
     81            this->createlines_->alignColumn(columnIndex, topOffset, leftOffset);
     82            this->createlines_->setColumnText(columnIndex, columnText);
     83
     84            topOffset = topOffset + lineSpacing;
     85
     86        }
     87
     88    }
     89
    5490}
  • code/branches/overlay/src/orxonox/overlays/stats/Scoreboard.h

    r2225 r2320  
    4444
    4545    public: // functions
    46         Scoreboard();
    47         ~Scoreboard();
     46        Scoreboard(BaseObject* creator);
     47        ~Scoreboard() {}
     48
     49        inline void setGametype(Gametype* gt)
     50            { this->gametype_ = gt; }
     51        inline Gametype* getGametype() const
     52            { return this->gametype_; }
     53
     54        inline void setCreateLines(CreateLines* cl)
     55            { this->createlines_ = cl; }
     56        inline CreateLines* getCreateLines() const
     57            { return this->createlines_; }
    4858
    4959    private: // functions
    50        
     60        void printLines();
    5161
    5262    private: // variables
    53        
    54 
     63        unsigned int numberOfColumns;
     64        unsigned int numberOfLines;
     65        unsigned int columnIndex;
     66        float topOffset;
     67        float leftOffset;
     68        float lineSpacing;
     69        std::string columnText;
     70        Gametype* gametype_;
     71        CreateLines* createlines_;
    5572    };
    5673}
Note: See TracChangeset for help on using the changeset viewer.