Changeset 2320 for code/branches/overlay/src/orxonox
- Timestamp:
- Dec 3, 2008, 3:58:01 PM (16 years ago)
- Location:
- code/branches/overlay/src/orxonox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/overlay/src/orxonox/CMakeLists.txt
r2152 r2320 38 38 overlays/stats/Stats.cc 39 39 overlays/stats/StatsTest.cc 40 overlays/stats/CreateLines.cc 41 overlays/stats/Scoreboard.cc 40 42 41 43 tools/BillboardSet.cc -
code/branches/overlay/src/orxonox/OrxonoxPrereqs.h
r2096 r2320 170 170 class OverlayGroup; 171 171 class OverlayText; 172 class CreateLines; 173 class Scoreboard; 172 174 173 175 //gui -
code/branches/overlay/src/orxonox/objects/gametypes/Gametype.cc
r2181 r2320 40 40 #include "objects/worldentities/pawns/Spectator.h" 41 41 #include "objects/worldentities/SpawnPoint.h" 42 #include "Settings.h" 42 43 43 44 #include "network/Host.h" … … 67 68 68 69 // load the corresponding score board 69 statsOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/" + this->statsOverlayName_);70 this->statsOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/" + this->statsOverlayName_); 70 71 Loader::open(statsOverlay_); 72 this->setGametype(this); 71 73 } 72 74 -
code/branches/overlay/src/orxonox/objects/gametypes/Gametype.h
r2181 r2320 82 82 { return this->startCountdown_; } 83 83 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 84 93 private: 85 94 void setConfigValues(); -
code/branches/overlay/src/orxonox/overlays/stats/CreateLines.cc
r2222 r2320 44 44 45 45 /** 46 @brief Constructor: Creates a nd initializes aline.46 @brief Constructor: Creates a line. 47 47 */ 48 48 CreateLines::CreateLines(BaseObject* creator) … … 63 63 @brief Ensures that the number of OverlayElements is equal to numberOfColumns. 64 64 */ 65 void setNumberOfColumns(unsigned int numberOfColumns) {65 void CreateLines::setNumberOfColumns(unsigned int numberOfColumns, unsigned int lineIndex) { 66 66 67 67 Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr(); 68 68 69 while (textColumns_. getSize() < numberOfColumns) {69 while (textColumns_.size() < numberOfColumns) { 70 70 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))); 73 72 textColumns_.push_back(tempTextArea); 73 this->background_->addChild(tempTextArea); 74 74 75 75 } 76 76 77 while (textColumns_. getSize() > numberOfColumns) {77 while (textColumns_.size() > numberOfColumns) { 78 78 79 ovMan->destroy(textColumns_.back()); 79 this->background_->_removeChild(textColumns_.back()); 80 ovMan->destroyOverlayElement(textColumns_.back()); 80 81 textColumns_.pop_back(); 81 82 … … 84 85 } 85 86 86 void alignColumn(int columnIndex, float leftOffset) {87 void CreateLines::alignColumn(int columnIndex, float leftOffset, float topOffset) { 87 88 88 this->textColumns_[columnIndex]->setPosition(leftOffset, 0);89 this->textColumns_[columnIndex]->setPosition(leftOffset, topOffset); 89 90 90 91 } 91 92 92 void setColumnText(int columnIndex,string columnText) {93 void CreateLines::setColumnText(int columnIndex, std::string columnText) { 93 94 94 95 this->textColumns_[columnIndex]->setCaption(columnText); -
code/branches/overlay/src/orxonox/overlays/stats/CreateLines.h
r2222 r2320 44 44 45 45 public: // functions 46 CreateLines( );47 ~CreateLines();46 CreateLines(BaseObject* creator); 47 virtual ~CreateLines() {} 48 48 49 49 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 50 50 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 51 55 private: // functions 52 void setNumberOfColumns();53 void alignColumn();54 void setColumnText();55 56 56 57 private: // variables -
code/branches/overlay/src/orxonox/overlays/stats/Scoreboard.cc
r2225 r2320 26 26 27 27 #include "OrxonoxStableHeaders.h" 28 #include " CreateLines.h"28 #include "Scoreboard.h" 29 29 30 30 #include <string> … … 38 38 #include "core/CoreIncludes.h" 39 39 #include "core/ConfigValueIncludes.h" 40 #include "objects/gametypes/Gametype.h" 41 #include "CreateLines.h" 40 42 41 43 namespace orxonox … … 44 46 45 47 /** 46 @brief Constructor: Creates and initializes a line.48 @brief Constructor: Creates the scoreboard. 47 49 */ 48 50 Scoreboard::Scoreboard(BaseObject* creator) … … 52 54 } 53 55 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 54 90 } -
code/branches/overlay/src/orxonox/overlays/stats/Scoreboard.h
r2225 r2320 44 44 45 45 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_; } 48 58 49 59 private: // functions 50 60 void printLines(); 51 61 52 62 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_; 55 72 }; 56 73 }
Note: See TracChangeset
for help on using the changeset viewer.