Changeset 8619 in orxonox.OLD for trunk/src/lib/gui/gl/specials
- Timestamp:
- Jun 20, 2006, 1:24:11 PM (19 years ago)
- Location:
- trunk/src/lib/gui/gl/specials
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/gl/specials/glgui_notifier.cc
r8518 r8619 25 25 26 26 /** 27 * standard constructor27 * @brief standard constructor 28 28 */ 29 29 GLGuiNotifier::GLGuiNotifier () … … 34 34 this->lineSpacing = 0; 35 35 this->linesProcessed = 0; 36 this->_fadeAge = 3.0; 37 this->setHideAge(4.0); 36 38 37 39 this->setDisplayLineCount(10); … … 57 59 } 58 60 61 /** 62 * @brief push a message onto the notifier. 63 * @param message the message to be pushed. 64 * 65 * @note it is not guaranteed, that the message is delivered instantaniously 66 * The possibility may arise, that the DisplayLines are all in use, then one 67 * has to wait until a line gets hidden, until a new one can be pushed to be 68 * displayed. 69 */ 59 70 void GLGuiNotifier::pushNotifyMessage(const std::string& message) 60 71 { 61 72 if (!this->hiddenText.empty()) 62 73 { 63 printf("%s\n", message.c_str()); 64 DisplayLine dl; 74 DisplayLine dl; // put everything in here, and then display it 75 76 // retrieve a Text. 65 77 dl.text = this->hiddenText.top(); 66 78 this->hiddenText.pop(); 79 80 // setup Text 67 81 dl.text->setBlending(1.0f); 68 82 dl.text->setText(message); 69 this->hiddenText.pop(); 83 dl.text->setVisibility(true); 84 dl.text->setRelCoor2D(this->calculateLinePosition(0)); 85 70 86 dl.age = 0.0f; 71 87 this->displayLines.push_front(dl); 72 73 dl.text->setVisibility(true);74 dl.text->setRelCoor2D(this->calculateLinePosition(0));75 88 this->repositionText(); 76 89 } 77 90 else 78 91 { 92 // push it onto the List of messages we still need. 79 93 this->inputBuffer.push_front(message); 80 //printf("grumble... must be fixed\n"); 81 } 82 } 83 84 94 } 95 } 96 97 98 /** 99 * @brief sets the Dipsplay Line Count of the Notifier. 100 * @param coun the count of displayLines. 101 */ 85 102 void GLGuiNotifier::setDisplayLineCount(unsigned int count) 86 103 { … … 96 113 } 97 114 115 void GLGuiNotifier::setFadeAge(float fadeAge) 116 { 117 this->_fadeAge = fadeAge; 118 this->_transformAge = hideAge() - this->fadeAge(); 119 } 120 121 void GLGuiNotifier::setHideAge(float hideAge) 122 { 123 this->_hideAge = hideAge; 124 this->_transformAge = this->hideAge() - fadeAge(); 125 } 126 98 127 99 128 /** … … 119 148 void GLGuiNotifier::applyTextSettings(MultiLineText* text) 120 149 { 121 text->setSize(this-> style().textSize());150 text->setSize(this->textSize()); 122 151 text->setLineWidth( 300 ); 123 text->setFont("fonts/final_frontier.ttf", (int)this-> style().textSize());124 125 text->setColor(this-> style().foregroundColor() );152 text->setFont("fonts/final_frontier.ttf", (int)this->textSize()); 153 154 text->setColor(this->foregroundColor() ); 126 155 if (text->getParent2D() != this) 127 156 text->setParent2D(this); … … 129 158 130 159 160 /** 161 * @brief ticks the entire Notifier. 162 * @param dt the time passed since the last Tick 163 */ 131 164 void GLGuiNotifier::tick(float dt) 132 165 { … … 135 168 { 136 169 (*line).age+=dt; 137 if ((*line).age > 3.0f)170 if ((*line).age > this->fadeAge()) 138 171 { 139 (*line).text->setBlending( 4.0 - (*line).age);140 if ((*line).age > 4.0f)172 (*line).text->setBlending((hideAge() - (*line).age)/_transformAge); 173 if ((*line).age > hideAge()) 141 174 { 142 175 std::list<DisplayLine>::iterator tmp = line; … … 167 200 this->beginDraw(); 168 201 169 this->back Material().select();202 this->background().select(); 170 203 this->drawRect(this->backRect()); 171 204 this->endDraw(); … … 183 216 Vector2D GLGuiNotifier::calculateLinePosition(unsigned int lineNumber) 184 217 { 185 return Vector2D(0.0f, (float)(t his->style().textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1));218 return Vector2D(0.0f, (float)(textSize() + this->lineSpacing)*(float)((int)this->bufferDisplaySize - (int)lineNumber - (int)1)); 186 219 } 187 220 -
trunk/src/lib/gui/gl/specials/glgui_notifier.h
r8518 r8619 30 30 void pushNotifyMessage(const std::string& message); 31 31 32 // BUFFERS32 /// Setup 33 33 void setDisplayLineCount(unsigned int count); 34 void setFadeAge(float fadeAge); 35 void setHideAge(float hideAge); 36 37 /** @returns the beginning of the Hiding process */ 38 inline float fadeAge() const { return _fadeAge; }; 39 /** @returns at what age elements should be fully hidden */ 40 inline float hideAge() const { return _hideAge; }; 34 41 35 42 void clear(); … … 54 61 55 62 private: 63 //! structure that defines a Displayed line. 56 64 typedef struct 57 65 { … … 59 67 MultiLineText* text; 60 68 61 } 62 DisplayLine; 69 } DisplayLine; 70 71 72 float _fadeAge; 73 float _hideAge; 74 float _transformAge; 63 75 64 76 unsigned int lineSpacing; //!< The Spacing between lines. … … 72 84 73 85 unsigned long linesProcessed; //!< How many Lines have been processed so far. 74 std::list<std::string> inputBuffer; //!< 86 std::list<std::string> inputBuffer; //!< The input buffer for lines that were not yet printet out, because there is too much input. 75 87 76 88 };
Note: See TracChangeset
for help on using the changeset viewer.