Changeset 5758 for code/trunk/src/modules/questsystem
- Timestamp:
- Sep 20, 2009, 11:48:52 PM (15 years ago)
- Location:
- code/trunk/src/modules/questsystem
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/questsystem/QuestGUINode.cc
r5748 r5758 161 161 const QuestDescription* description = this->item_->getDescription(); 162 162 this->details_ = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow", stream.str()); 163 this->details_->setSize(CEGUI::UVector2(CEGUI::UDim(0. 8, 0),CEGUI::UDim(0.8, 0)));163 this->details_->setSize(CEGUI::UVector2(CEGUI::UDim(0.7, 0),CEGUI::UDim(0.7, 0))); 164 164 this->details_->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1, 0),CEGUI::UDim(0.1, 0))); 165 165 this->details_->setText(description->getTitle()); … … 214 214 stream << this->details_->getName() << "/Description"; 215 215 CEGUI::Window* descriptionWindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str()); 216 stream << "/Title"; 217 CEGUI::Window* descriptionWindowTitle = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str()); 218 window->addChildWindow(descriptionWindowTitle); 219 descriptionWindowTitle->setProperty("HorzFormatting", "HorzCentred"); 220 descriptionWindowTitle->setProperty("VertFormatting", "TopAligned"); 221 descriptionWindowTitle->setText("Description:"); 222 descriptionWindowTitle->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset))); 223 descriptionWindowTitle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(1.0, 0))); 224 offset += setHeight(descriptionWindowTitle); 216 225 window->addChildWindow(descriptionWindow); 217 226 descriptionWindow->setProperty("HorzFormatting", "WordWrapLeftAligned"); … … 225 234 226 235 //! Display a list of hints if the QuestItem is a Quest. 236 bool title = true; 227 237 if(quest != NULL) 228 238 { … … 231 241 if(dynamic_cast<QuestHint*>((*it)->item_) != NULL) //!< If the subNode belongs to a QuestHint. 232 242 { 243 if(title) 244 { 245 stream.str(""); 246 stream << this->details_->getName() << "/Hints/Title"; 247 CEGUI::Window* hintsTitle = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str()); 248 window->addChildWindow(hintsTitle); 249 hintsTitle->setProperty("HorzFormatting", "HorzCentred"); 250 hintsTitle->setProperty("VertFormatting", "TopAligned"); 251 hintsTitle->setText("Hints:"); 252 hintsTitle->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset))); 253 hintsTitle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(1.0, 0))); 254 offset += setHeight(hintsTitle);; 255 title = false; 256 } 233 257 QuestGUINode* node = *it; 234 258 node->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(0, 30))); … … 255 279 COUT(3) << "Open QuestItem..." << std::endl; 256 280 257 CEGUI::Window* window = this->gui_->getRootWindow(); 281 //CEGUI::Window* window = this->gui_->getRootWindow(); 282 CEGUI::Window* window = CEGUI::WindowManager::getSingleton().getWindow("orxonox/QuestGUI/Background"); 258 283 259 284 if(window != NULL) … … 269 294 bool QuestGUINode::closeDetails(const CEGUI::EventArgs& e) 270 295 { 271 CEGUI::Window* questsList = this->gui_->getRootWindow(); 272 questsList->removeChildWindow(this->details_); 296 //CEGUI::Window* window = this->gui_->getRootWindow(); 297 CEGUI::Window* window = CEGUI::WindowManager::getSingleton().getWindow("orxonox/QuestGUI/Background"); 298 window->removeChildWindow(this->details_); 273 299 274 300 return true; 275 301 } 276 302 303 /** 304 @brief 305 Helper method for setHeight(). Gets the StaticTextArea for an input CEGUI Window. 306 @param window 307 The CEGUI window. 308 @return 309 Returns a CEGUI Rect. 310 */ 277 311 /*static*/ CEGUI::Rect QuestGUINode::getStaticTextArea(const CEGUI::Window* window) 278 312 { … … 282 316 } 283 317 318 /** 319 @brief 320 Helper method to adjust the height of an input Window (of type StaticText) to the text it holds. 321 @param window 322 The CEGUI Window (of type StaticText) for which the height is to be adjusted to the text. 323 @return 324 Returns the set height. 325 */ 284 326 /*static*/ int QuestGUINode::setHeight(CEGUI::Window* window) 285 327 { 286 328 //! Get the area the text is formatted and drawn into. 287 329 const CEGUI::Rect formattedArea = getStaticTextArea(window); 288 COUT(1) << "PixelRect before setHeight(): " << formattedArea.getHeight() << "x" << formattedArea.getWidth() << std::endl; //Debug289 330 290 331 //! Calculate the pixel height of the frame by subtracting the height of the area above from the total height of the window. … … 293 334 //! Get the formatted line count - using the formatting area obtained above. 294 335 const float lines = window->getFont()->getFormattedLineCount(window->getText(), formattedArea, CEGUI::WordWrapLeftAligned); 295 COUT(1) << "Lines: " << lines << std::endl; //Debug296 336 297 337 //! Calculate pixel height of window, which is the number of formatted lines multiplied by the spacing of the font, plus the pixel height of the frame. … … 303 343 //Debug 304 344 const CEGUI::Rect newArea = getStaticTextArea(window); 305 COUT(1) << "PixelRect after setHeight(): " << newArea.getHeight() << "x" << newArea.getWidth() << std::endl; //Debug306 345 307 346 return static_cast<int>(height); 308 347 } 309 310 //int QuestGUINode::setHeight(CEGUI::Window* window)311 //{312 // COUT(1) << "PixelRect before setHeight(): " << window->getPixelRect().getHeight() << "x" << window->getPixelRect().getWidth() << std::endl; //Debug313 // int lines = window->getFont()->getFormattedLineCount(window->getText(), window->getPixelRect(), CEGUI::WordWrapLeftAligned);314 // int height = 2*lines*window->getFont()->getLineSpacing();315 // COUT(1) << "Lines: " << lines << ", LineSpacing: " << window->getFont()->getLineSpacing() << std::endl; //Debug316 // window->setHeight(CEGUI::UDim(0, height));317 // COUT(1) << "PixelRect after setHeight(): " << window->getPixelRect().getHeight() << "x" << window->getPixelRect().getWidth() << std::endl; //Debug318 // return height;319 //}320 348 321 349 /** -
code/trunk/src/modules/questsystem/QuestGUINode.h
r5748 r5758 64 64 65 65 private: 66 static CEGUI::Rect getStaticTextArea(const CEGUI::Window* window); 67 static int setHeight(CEGUI::Window* window); 66 static CEGUI::Rect getStaticTextArea(const CEGUI::Window* window); //Helper method for setHeight(). Gets the StaticTextArea for an input CEGUI Window. 67 static int setHeight(CEGUI::Window* window); //Helper method to adjust the height of an input Window (of type StaticText) to the text it holds. 68 68 69 69 void initialize(void); //!< Initialize the object.
Note: See TracChangeset
for help on using the changeset viewer.