[Orxonox-commit 1040] r5760 - in code/trunk/src/modules/questsystem: . notifications

dafrick at orxonox.net dafrick at orxonox.net
Tue Sep 22 12:44:05 CEST 2009


Author: dafrick
Date: 2009-09-22 12:44:05 +0200 (Tue, 22 Sep 2009)
New Revision: 5760

Modified:
   code/trunk/src/modules/questsystem/QuestGUI.h
   code/trunk/src/modules/questsystem/QuestGUINode.cc
   code/trunk/src/modules/questsystem/QuestGUINode.h
   code/trunk/src/modules/questsystem/QuestManager.h
   code/trunk/src/modules/questsystem/notifications/NotificationManager.cc
Log:
Some cleanup und resolved TODO's in questsystem.

Modified: code/trunk/src/modules/questsystem/QuestGUI.h
===================================================================
--- code/trunk/src/modules/questsystem/QuestGUI.h	2009-09-21 19:17:02 UTC (rev 5759)
+++ code/trunk/src/modules/questsystem/QuestGUI.h	2009-09-22 10:44:05 UTC (rev 5760)
@@ -59,9 +59,14 @@
             QuestGUI(PlayerInfo* player);
             virtual ~QuestGUI();
 
+            void update(void); //!< Update the GUI.
             CEGUI::Window* getGUI(void); //!< Get the root CEGUI Window of the GUI.
-            void update(void); //!< Update the GUI.
 
+            CEGUI::Window* getWindow(void); //!< Get a CEGUI Window to use.
+            void giveWindow(CEGUI::Window* window); //!< Return a no longer needed CEGUI Window for reuse.
+
+            static QuestGUINode* findNode(CEGUI::Window* window); //!< Finde the QuestGUINode belonging to the input CEGUI Window.
+
             /**
             @brief Retreive the CEGUI WindowManager.
             @return Returns the CEGUI WindoWManager.
@@ -74,30 +79,25 @@
             */
             inline CEGUI::Window* getRootWindow(void)
                 { return this->rootWindow_; }
-
-            CEGUI::Window* getWindow(void); //!< Get a CEGUI Window to use.
-            void giveWindow(CEGUI::Window* window); //!< Return a no longer needed CEGUI Window for reuse.
-
             /**
             @brief Retreive the player.
             @return Returns the player.
             */
             inline PlayerInfo* getPlayer(void)
                 { return this->player_; }
-
-            static QuestGUINode* findNode(CEGUI::Window* window); //!< Finde the QuestGUINode belonging to the input CEGUI Window.
     
         private:
             
             int createNode(QuestGUINode* parent, QuestItem* item, int depth, int index); //!< Recursive method to create Nodes for all Quests an Hints the given Quest is a parent to.
 
             void clear(void); //!< Clear the QuestGUI.
-            
+
+            QuestGUINode* root_; //!< An empty QuestGUINode being the parent of all otherwise parent-less nodes.
+
+            CEGUI::WindowManager* windowManager_; //!< The CEGUI WindowManager.
+            CEGUI::Window* rootWindow_; //!< The root CEGUI Window of the GUI.
             PlayerInfo* player_; //!< The player that owns the GUI.
-            CEGUI::WindowManager* windowManager_; //!< The CEGUI WindowManager. //TODO: needed?
-            CEGUI::Window* rootWindow_; //!< The root CEGUI Window of the GUI.
 
-            QuestGUINode* root_; //!< An empty QuestGUINode being the parent of all otherwise parent-less nodes.
             std::map<CEGUI::Window*, QuestGUINode*> nodes_; //!< A list of all QuestGUINodes, ordered by their respective CEGUI Windows.
             std::list<CEGUI::Window*> windows_; //!< A list of windows to be used.
 

Modified: code/trunk/src/modules/questsystem/QuestGUINode.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestGUINode.cc	2009-09-21 19:17:02 UTC (rev 5759)
+++ code/trunk/src/modules/questsystem/QuestGUINode.cc	2009-09-22 10:44:05 UTC (rev 5760)
@@ -159,7 +159,7 @@
             //! Create the main window for the details.
             stream << this->window_->getName() << "/Details";
             const QuestDescription* description = this->item_->getDescription();
-            this->details_ = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow", stream.str());
+            this->details_ = this->gui_->getWindowManager()->createWindow("TaharezLook/FrameWindow", stream.str());
             this->details_->setSize(CEGUI::UVector2(CEGUI::UDim(0.7, 0),CEGUI::UDim(0.7, 0)));
             this->details_->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1, 0),CEGUI::UDim(0.1, 0)));
             this->details_->setText(description->getTitle());
@@ -170,9 +170,9 @@
 
             //! Create a ScrollablePane.
             stream << "/Scrollable";
-            CEGUI::Window* window = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/ScrollablePane", stream.str());
-            window->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -10),CEGUI::UDim(1.0, -26)));
-            window->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 5),CEGUI::UDim(0, 26)));
+            CEGUI::Window* window = this->gui_->getWindowManager()->createWindow("TaharezLook/ScrollablePane", stream.str());
+            window->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -2*QuestGUINode::BORDER_WIDTH),CEGUI::UDim(1.0, -QuestGUINode::TITLE_HEIGHT)));
+            window->setPosition(CEGUI::UVector2(CEGUI::UDim(0, QuestGUINode::BORDER_WIDTH),CEGUI::UDim(0, QuestGUINode::TITLE_HEIGHT)));
             this->details_->addChildWindow(window);
 
             int height;
@@ -184,7 +184,7 @@
             {
                 stream.str("");
                 stream << this->details_->getName() << "/Status";
-                CEGUI::Window* statusWindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str());
+                CEGUI::Window* statusWindow = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str());
                 window->addChildWindow(statusWindow);
                 std::string status = "";
                 if(quest->isActive(this->gui_->getPlayer()))
@@ -203,31 +203,36 @@
                 statusWindow->setProperty("VertFormatting", "TopAligned");
                 statusWindow->setText(status);
                 statusWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset)));
-                statusWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(1.0, 0)));
+                statusWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0, 0)));
                 height = setHeight(statusWindow);
 
                 offset += height;
             }
-
-            //! Display the Description of the QuestItem.
+            
+            //! Create title pane for the description.
             stream.str("");
             stream << this->details_->getName() << "/Description";
-            CEGUI::Window* descriptionWindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str());
             stream << "/Title";
-            CEGUI::Window* descriptionWindowTitle = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str());
+            CEGUI::Window* descriptionWindowTitle = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str());
             window->addChildWindow(descriptionWindowTitle);
             descriptionWindowTitle->setProperty("HorzFormatting", "HorzCentred");
             descriptionWindowTitle->setProperty("VertFormatting", "TopAligned");
             descriptionWindowTitle->setText("Description:");
             descriptionWindowTitle->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset)));
-            descriptionWindowTitle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(1.0, 0)));
+            descriptionWindowTitle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0, 0)));
+
             offset += setHeight(descriptionWindowTitle);
+
+            //! Display the Description of the QuestItem.
+            stream.str("");
+            stream << this->details_->getName() << "/Description";
+            CEGUI::Window* descriptionWindow = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str());
             window->addChildWindow(descriptionWindow);
             descriptionWindow->setProperty("HorzFormatting", "WordWrapLeftAligned");
             descriptionWindow->setProperty("VertFormatting", "TopAligned");
             descriptionWindow->setText(description->getDescription());
             descriptionWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset)));
-            descriptionWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(1.0, 0)));
+            descriptionWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0, 0)));
             height = setHeight(descriptionWindow);
 
             offset += height;
@@ -240,26 +245,25 @@
                 {
                     if(dynamic_cast<QuestHint*>((*it)->item_) != NULL) //!< If the subNode belongs to a QuestHint.
                     {
-                        if(title)
+                        if(title) //!< If no title pane for the QuestHints has been created, create one.
                         {
                             stream.str("");
                             stream << this->details_->getName() << "/Hints/Title";
-                            CEGUI::Window* hintsTitle = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText", stream.str());
+                            CEGUI::Window* hintsTitle = this->gui_->getWindowManager()->createWindow("TaharezLook/StaticText", stream.str());
                             window->addChildWindow(hintsTitle);
                             hintsTitle->setProperty("HorzFormatting", "HorzCentred");
                             hintsTitle->setProperty("VertFormatting", "TopAligned");
                             hintsTitle->setText("Hints:");
                             hintsTitle->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset)));
-                            hintsTitle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(1.0, 0)));
+                            hintsTitle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0, 0)));
                             offset += setHeight(hintsTitle);;
                             title = false;
                         }
                         QuestGUINode* node = *it;
-                        node->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(0, 30)));
+                        node->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(0, QuestGUINode::BUTTON_HEIGHT)));
                         node->window_->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset)));
-                        node->window_->setProperty("HorizontalAlignment", "Left"); // TODO: Get this working.
                         window->addChildWindow(node->window_);
-                        offset += 30;
+                        offset += QuestGUINode::BUTTON_HEIGHT;
                     }
                 }
             }
@@ -279,7 +283,7 @@
         COUT(3) << "Open QuestItem..." << std::endl;
         
         //CEGUI::Window* window = this->gui_->getRootWindow();
-        CEGUI::Window* window = CEGUI::WindowManager::getSingleton().getWindow("orxonox/QuestGUI/Background");
+        CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background");
 
         if(window != NULL)
             window->addChildWindow(this->getDetails());
@@ -294,7 +298,7 @@
     bool QuestGUINode::closeDetails(const CEGUI::EventArgs& e)
     {        
         //CEGUI::Window* window = this->gui_->getRootWindow();
-        CEGUI::Window* window = CEGUI::WindowManager::getSingleton().getWindow("orxonox/QuestGUI/Background");
+        CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background");
         window->removeChildWindow(this->details_);
 
         return true;
@@ -352,8 +356,8 @@
     */
     void QuestGUINode::updatePosition(void)
     {
-        this->window_->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 20*this->depth_),CEGUI::UDim(0, 30*this->index_)));
-        this->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1, -20*this->depth_-13),CEGUI::UDim(0, 30)));
+        this->window_->setPosition(CEGUI::UVector2(CEGUI::UDim(0, QuestGUINode::INDENT_WIDTH*this->depth_),CEGUI::UDim(0, QuestGUINode::BUTTON_HEIGHT*this->index_)));
+        this->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1, -QuestGUINode::INDENT_WIDTH*this->depth_-QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(0, QuestGUINode::BUTTON_HEIGHT)));
     }
 
     /**

Modified: code/trunk/src/modules/questsystem/QuestGUINode.h
===================================================================
--- code/trunk/src/modules/questsystem/QuestGUINode.h	2009-09-21 19:17:02 UTC (rev 5759)
+++ code/trunk/src/modules/questsystem/QuestGUINode.h	2009-09-22 10:44:05 UTC (rev 5760)
@@ -57,25 +57,25 @@
             */
             inline CEGUI::Window* getWindow(void)
                 { return this->window_; }
-            CEGUI::Window* getDetails(void); //!< Creates the details window.
 
             bool openDetails(const CEGUI::EventArgs& e); //!< Opens the details window for the Quest/QuestHint clicked on.
             bool closeDetails(const CEGUI::EventArgs& e); //!< Close the details window.
 
         private:
-            static CEGUI::Rect getStaticTextArea(const CEGUI::Window* window); //Helper method for setHeight(). Gets the StaticTextArea for an input CEGUI Window.
-            static int setHeight(CEGUI::Window* window); //Helper method to adjust the height of an input Window (of type StaticText) to the text it holds.
+            CEGUI::Window* getDetails(void); //!< Creates the details window.
 
             void initialize(void); //!< Initialize the object.
             void updatePosition(void); //!< Update the position list item.
             void createWindow(void); //!< Helper method to create the CEGUI Window the node.
+            static CEGUI::Rect getStaticTextArea(const CEGUI::Window* window); //Helper method for setHeight(). Gets the StaticTextArea for an input CEGUI Window.
+            static int setHeight(CEGUI::Window* window); //Helper method to adjust the height of an input Window (of type StaticText) to the text it holds.
 
             bool visible_; //!< Boolean determining the visibility of the node.
 
             QuestGUI* gui_; //!< The QuestGUI this node belongs to.
             QuestGUINode* parent_; //!< The parent node.
-            std::list<QuestGUINode*> subNodes_; //!< a list of all subnodes.
-            QuestItem* item_; //!<
+            std::list<QuestGUINode*> subNodes_; //!< A list of all subnodes.
+            QuestItem* item_; //!< QuestItem belonging to this node.
 
             int depth_; //!< The depth (resp. indentation) of this node in the list of Quests. (Irrelevant for QuestHints)
             int index_; //!< The index of this node in the list of Quests, resp. in the list of QuestHints, if the node belongs to a QuestHint, rather than a Quest.
@@ -83,6 +83,13 @@
             CEGUI::Window* window_; //!< The list window of this node.
             CEGUI::Window* details_; //!< The details window of this node.
 
+            //! Some magic numbers
+            static const int TITLE_HEIGHT = 26;
+            static const int BORDER_WIDTH = 5;
+            static const int SCROLLBAR_WIDTH = 13;
+            static const int BUTTON_HEIGHT = 30;
+            static const int INDENT_WIDTH = 20;
+
     };
 
 }

Modified: code/trunk/src/modules/questsystem/QuestManager.h
===================================================================
--- code/trunk/src/modules/questsystem/QuestManager.h	2009-09-21 19:17:02 UTC (rev 5759)
+++ code/trunk/src/modules/questsystem/QuestManager.h	2009-09-22 10:44:05 UTC (rev 5760)
@@ -64,8 +64,7 @@
 // tolua_end
 
             friend class ScopedSingleton<QuestManager, ScopeID::GSLevel>;
-            friend class QuestGUI; //TODO: better solution.
-            //friend std::map<std::string, Quest*> & QuestGUI::getQuests(void);
+            friend class QuestGUI;
 
         public:
             QuestManager();
@@ -93,7 +92,6 @@
             std::map<std::string, Quest*> questMap_; //!< All Quests registered by their id's.
             std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's.
 
-            //TODO: Call destructor of QuestGUI's on destruction of QuestManager?
             std::map<PlayerInfo*, QuestGUI*> questGUIs_; //!< All GUI's registered by the players.
 
     }; // tolua_export

Modified: code/trunk/src/modules/questsystem/notifications/NotificationManager.cc
===================================================================
--- code/trunk/src/modules/questsystem/notifications/NotificationManager.cc	2009-09-21 19:17:02 UTC (rev 5759)
+++ code/trunk/src/modules/questsystem/notifications/NotificationManager.cc	2009-09-22 10:44:05 UTC (rev 5760)
@@ -122,7 +122,7 @@
 
         this->listenerList_[listener] = index; //!< Add the NotificationListener to the list of listeners.
 
-        std::set<std::string> set = listener->getTargetsSet(); //TODO: Works this?
+        std::set<std::string> set = listener->getTargetsSet(); //TODO: Does this work?
 
         //! 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.
         if(set.find(ALL) != set.end())




More information about the Orxonox-commit mailing list