Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5758


Ignore:
Timestamp:
Sep 20, 2009, 11:48:52 PM (15 years ago)
Author:
dafrick
Message:

Some cleanup, documentation and adjustments in the QuestGUI.

Location:
code/trunk/src/modules/questsystem
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/questsystem/QuestGUINode.cc

    r5748 r5758  
    161161            const QuestDescription* description = this->item_->getDescription();
    162162            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)));
    164164            this->details_->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1, 0),CEGUI::UDim(0.1, 0)));
    165165            this->details_->setText(description->getTitle());
     
    214214            stream << this->details_->getName() << "/Description";
    215215            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);
    216225            window->addChildWindow(descriptionWindow);
    217226            descriptionWindow->setProperty("HorzFormatting", "WordWrapLeftAligned");
     
    225234
    226235            //! Display a list of hints if the QuestItem is a Quest.
     236            bool title = true;
    227237            if(quest != NULL)
    228238            {
     
    231241                    if(dynamic_cast<QuestHint*>((*it)->item_) != NULL) //!< If the subNode belongs to a QuestHint.
    232242                    {
     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                        }
    233257                        QuestGUINode* node = *it;
    234258                        node->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(0, 30)));
     
    255279        COUT(3) << "Open QuestItem..." << std::endl;
    256280       
    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");
    258283
    259284        if(window != NULL)
     
    269294    bool QuestGUINode::closeDetails(const CEGUI::EventArgs& e)
    270295    {       
    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_);
    273299
    274300        return true;
    275301    }
    276302
     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    */
    277311    /*static*/ CEGUI::Rect QuestGUINode::getStaticTextArea(const CEGUI::Window* window)
    278312    {
     
    282316    }
    283317
     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    */
    284326    /*static*/ int QuestGUINode::setHeight(CEGUI::Window* window)
    285327    {
    286328        //! Get the area the text is formatted and drawn into.
    287329        const CEGUI::Rect formattedArea = getStaticTextArea(window);
    288         COUT(1) << "PixelRect before setHeight(): " << formattedArea.getHeight() << "x" << formattedArea.getWidth() << std::endl; //Debug
    289330
    290331        //! Calculate the pixel height of the frame by subtracting the height of the area above from the total height of the window.
     
    293334        //! Get the formatted line count - using the formatting area obtained above.
    294335        const float lines = window->getFont()->getFormattedLineCount(window->getText(), formattedArea, CEGUI::WordWrapLeftAligned);
    295         COUT(1) << "Lines: " << lines << std::endl; //Debug
    296336
    297337        //! 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.
     
    303343        //Debug
    304344        const CEGUI::Rect newArea = getStaticTextArea(window);
    305         COUT(1) << "PixelRect after setHeight(): " << newArea.getHeight() << "x" << newArea.getWidth() << std::endl; //Debug
    306345
    307346        return static_cast<int>(height);
    308347    }
    309 
    310     //int QuestGUINode::setHeight(CEGUI::Window* window)
    311     //{
    312     //    COUT(1) << "PixelRect before setHeight(): " << window->getPixelRect().getHeight() << "x" << window->getPixelRect().getWidth() << std::endl; //Debug
    313     //    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; //Debug
    316     //    window->setHeight(CEGUI::UDim(0, height));
    317     //    COUT(1) << "PixelRect after setHeight(): " << window->getPixelRect().getHeight() << "x" << window->getPixelRect().getWidth() << std::endl; //Debug
    318     //    return height;
    319     //}
    320348
    321349    /**
  • code/trunk/src/modules/questsystem/QuestGUINode.h

    r5748 r5758  
    6464
    6565        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.
    6868
    6969            void initialize(void); //!< Initialize the object.
Note: See TracChangeset for help on using the changeset viewer.