Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 22, 2009, 12:44:05 PM (15 years ago)
Author:
dafrick
Message:

Some cleanup und resolved TODO's in questsystem.

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

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/questsystem/QuestGUI.h

    r5748 r5760  
    6060            virtual ~QuestGUI();
    6161
     62            void update(void); //!< Update the GUI.
    6263            CEGUI::Window* getGUI(void); //!< Get the root CEGUI Window of the GUI.
    63             void update(void); //!< Update the GUI.
     64
     65            CEGUI::Window* getWindow(void); //!< Get a CEGUI Window to use.
     66            void giveWindow(CEGUI::Window* window); //!< Return a no longer needed CEGUI Window for reuse.
     67
     68            static QuestGUINode* findNode(CEGUI::Window* window); //!< Finde the QuestGUINode belonging to the input CEGUI Window.
    6469
    6570            /**
     
    7580            inline CEGUI::Window* getRootWindow(void)
    7681                { return this->rootWindow_; }
    77 
    78             CEGUI::Window* getWindow(void); //!< Get a CEGUI Window to use.
    79             void giveWindow(CEGUI::Window* window); //!< Return a no longer needed CEGUI Window for reuse.
    80 
    8182            /**
    8283            @brief Retreive the player.
     
    8586            inline PlayerInfo* getPlayer(void)
    8687                { return this->player_; }
    87 
    88             static QuestGUINode* findNode(CEGUI::Window* window); //!< Finde the QuestGUINode belonging to the input CEGUI Window.
    8988   
    9089        private:
     
    9392
    9493            void clear(void); //!< Clear the QuestGUI.
    95            
    96             PlayerInfo* player_; //!< The player that owns the GUI.
    97             CEGUI::WindowManager* windowManager_; //!< The CEGUI WindowManager. //TODO: needed?
    98             CEGUI::Window* rootWindow_; //!< The root CEGUI Window of the GUI.
    9994
    10095            QuestGUINode* root_; //!< An empty QuestGUINode being the parent of all otherwise parent-less nodes.
     96
     97            CEGUI::WindowManager* windowManager_; //!< The CEGUI WindowManager.
     98            CEGUI::Window* rootWindow_; //!< The root CEGUI Window of the GUI.
     99            PlayerInfo* player_; //!< The player that owns the GUI.
     100
    101101            std::map<CEGUI::Window*, QuestGUINode*> nodes_; //!< A list of all QuestGUINodes, ordered by their respective CEGUI Windows.
    102102            std::list<CEGUI::Window*> windows_; //!< A list of windows to be used.
  • code/trunk/src/modules/questsystem/QuestGUINode.cc

    r5758 r5760  
    160160            stream << this->window_->getName() << "/Details";
    161161            const QuestDescription* description = this->item_->getDescription();
    162             this->details_ = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow", stream.str());
     162            this->details_ = this->gui_->getWindowManager()->createWindow("TaharezLook/FrameWindow", stream.str());
    163163            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)));
     
    171171            //! Create a ScrollablePane.
    172172            stream << "/Scrollable";
    173             CEGUI::Window* window = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/ScrollablePane", stream.str());
    174             window->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -10),CEGUI::UDim(1.0, -26)));
    175             window->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 5),CEGUI::UDim(0, 26)));
     173            CEGUI::Window* window = this->gui_->getWindowManager()->createWindow("TaharezLook/ScrollablePane", stream.str());
     174            window->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -2*QuestGUINode::BORDER_WIDTH),CEGUI::UDim(1.0, -QuestGUINode::TITLE_HEIGHT)));
     175            window->setPosition(CEGUI::UVector2(CEGUI::UDim(0, QuestGUINode::BORDER_WIDTH),CEGUI::UDim(0, QuestGUINode::TITLE_HEIGHT)));
    176176            this->details_->addChildWindow(window);
    177177
     
    185185                stream.str("");
    186186                stream << this->details_->getName() << "/Status";
    187                 CEGUI::Window* statusWindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str());
     187                CEGUI::Window* statusWindow = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str());
    188188                window->addChildWindow(statusWindow);
    189189                std::string status = "";
     
    204204                statusWindow->setText(status);
    205205                statusWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset)));
    206                 statusWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(1.0, 0)));
     206                statusWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0, 0)));
    207207                height = setHeight(statusWindow);
    208208
    209209                offset += height;
    210210            }
    211 
    212             //! Display the Description of the QuestItem.
     211           
     212            //! Create title pane for the description.
    213213            stream.str("");
    214214            stream << this->details_->getName() << "/Description";
    215             CEGUI::Window* descriptionWindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str());
    216215            stream << "/Title";
    217             CEGUI::Window* descriptionWindowTitle = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str());
     216            CEGUI::Window* descriptionWindowTitle = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str());
    218217            window->addChildWindow(descriptionWindowTitle);
    219218            descriptionWindowTitle->setProperty("HorzFormatting", "HorzCentred");
     
    221220            descriptionWindowTitle->setText("Description:");
    222221            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)));
     222            descriptionWindowTitle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0, 0)));
     223
    224224            offset += setHeight(descriptionWindowTitle);
     225
     226            //! Display the Description of the QuestItem.
     227            stream.str("");
     228            stream << this->details_->getName() << "/Description";
     229            CEGUI::Window* descriptionWindow = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str());
    225230            window->addChildWindow(descriptionWindow);
    226231            descriptionWindow->setProperty("HorzFormatting", "WordWrapLeftAligned");
     
    228233            descriptionWindow->setText(description->getDescription());
    229234            descriptionWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset)));
    230             descriptionWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(1.0, 0)));
     235            descriptionWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0, 0)));
    231236            height = setHeight(descriptionWindow);
    232237
     
    241246                    if(dynamic_cast<QuestHint*>((*it)->item_) != NULL) //!< If the subNode belongs to a QuestHint.
    242247                    {
    243                         if(title)
     248                        if(title) //!< If no title pane for the QuestHints has been created, create one.
    244249                        {
    245250                            stream.str("");
    246251                            stream << this->details_->getName() << "/Hints/Title";
    247                             CEGUI::Window* hintsTitle = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str());
     252                            CEGUI::Window* hintsTitle = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str());
    248253                            window->addChildWindow(hintsTitle);
    249254                            hintsTitle->setProperty("HorzFormatting", "HorzCentred");
     
    251256                            hintsTitle->setText("Hints:");
    252257                            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)));
     258                            hintsTitle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0, 0)));
    254259                            offset += setHeight(hintsTitle);;
    255260                            title = false;
    256261                        }
    257262                        QuestGUINode* node = *it;
    258                         node->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(0, 30)));
     263                        node->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(0, QuestGUINode::BUTTON_HEIGHT)));
    259264                        node->window_->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset)));
    260                         node->window_->setProperty("HorizontalAlignment", "Left"); // TODO: Get this working.
    261265                        window->addChildWindow(node->window_);
    262                         offset += 30;
     266                        offset += QuestGUINode::BUTTON_HEIGHT;
    263267                    }
    264268                }
     
    280284       
    281285        //CEGUI::Window* window = this->gui_->getRootWindow();
    282         CEGUI::Window* window = CEGUI::WindowManager::getSingleton().getWindow("orxonox/QuestGUI/Background");
     286        CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background");
    283287
    284288        if(window != NULL)
     
    295299    {       
    296300        //CEGUI::Window* window = this->gui_->getRootWindow();
    297         CEGUI::Window* window = CEGUI::WindowManager::getSingleton().getWindow("orxonox/QuestGUI/Background");
     301        CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background");
    298302        window->removeChildWindow(this->details_);
    299303
     
    353357    void QuestGUINode::updatePosition(void)
    354358    {
    355         this->window_->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 20*this->depth_),CEGUI::UDim(0, 30*this->index_)));
    356         this->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1, -20*this->depth_-13),CEGUI::UDim(0, 30)));
     359        this->window_->setPosition(CEGUI::UVector2(CEGUI::UDim(0, QuestGUINode::INDENT_WIDTH*this->depth_),CEGUI::UDim(0, QuestGUINode::BUTTON_HEIGHT*this->index_)));
     360        this->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1, -QuestGUINode::INDENT_WIDTH*this->depth_-QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(0, QuestGUINode::BUTTON_HEIGHT)));
    357361    }
    358362
  • code/trunk/src/modules/questsystem/QuestGUINode.h

    r5758 r5760  
    5858            inline CEGUI::Window* getWindow(void)
    5959                { return this->window_; }
    60             CEGUI::Window* getDetails(void); //!< Creates the details window.
    6160
    6261            bool openDetails(const CEGUI::EventArgs& e); //!< Opens the details window for the Quest/QuestHint clicked on.
     
    6463
    6564        private:
    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.
     65            CEGUI::Window* getDetails(void); //!< Creates the details window.
    6866
    6967            void initialize(void); //!< Initialize the object.
    7068            void updatePosition(void); //!< Update the position list item.
    7169            void createWindow(void); //!< Helper method to create the CEGUI Window the node.
     70            static CEGUI::Rect getStaticTextArea(const CEGUI::Window* window); //Helper method for setHeight(). Gets the StaticTextArea for an input CEGUI Window.
     71            static int setHeight(CEGUI::Window* window); //Helper method to adjust the height of an input Window (of type StaticText) to the text it holds.
    7272
    7373            bool visible_; //!< Boolean determining the visibility of the node.
     
    7575            QuestGUI* gui_; //!< The QuestGUI this node belongs to.
    7676            QuestGUINode* parent_; //!< The parent node.
    77             std::list<QuestGUINode*> subNodes_; //!< a list of all subnodes.
    78             QuestItem* item_; //!<
     77            std::list<QuestGUINode*> subNodes_; //!< A list of all subnodes.
     78            QuestItem* item_; //!< QuestItem belonging to this node.
    7979
    8080            int depth_; //!< The depth (resp. indentation) of this node in the list of Quests. (Irrelevant for QuestHints)
     
    8484            CEGUI::Window* details_; //!< The details window of this node.
    8585
     86            //! Some magic numbers
     87            static const int TITLE_HEIGHT = 26;
     88            static const int BORDER_WIDTH = 5;
     89            static const int SCROLLBAR_WIDTH = 13;
     90            static const int BUTTON_HEIGHT = 30;
     91            static const int INDENT_WIDTH = 20;
     92
    8693    };
    8794
  • code/trunk/src/modules/questsystem/QuestManager.h

    r5748 r5760  
    6565
    6666            friend class ScopedSingleton<QuestManager, ScopeID::GSLevel>;
    67             friend class QuestGUI; //TODO: better solution.
    68             //friend std::map<std::string, Quest*> & QuestGUI::getQuests(void);
     67            friend class QuestGUI;
    6968
    7069        public:
     
    9493            std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's.
    9594
    96             //TODO: Call destructor of QuestGUI's on destruction of QuestManager?
    9795            std::map<PlayerInfo*, QuestGUI*> questGUIs_; //!< All GUI's registered by the players.
    9896
  • code/trunk/src/modules/questsystem/notifications/NotificationManager.cc

    r5748 r5760  
    123123        this->listenerList_[listener] = index; //!< Add the NotificationListener to the list of listeners.
    124124
    125         std::set<std::string> set = listener->getTargetsSet(); //TODO: Works this?
     125        std::set<std::string> set = listener->getTargetsSet(); //TODO: Does this work?
    126126
    127127        //! If all senders are the target of the listener, then the list of notification for that specific listener is te same as the list of all Notifications.
Note: See TracChangeset for help on using the changeset viewer.