Changeset 2907 for code/branches/questsystem5/src/orxonox/overlays
- Timestamp:
- Apr 8, 2009, 12:36:08 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.cc
r2662 r2907 39 39 #include <OgreOverlayManager.h> 40 40 #include <OgrePanelOverlayElement.h> 41 #include <OgreRenderWindow.h> 42 41 43 #include "util/Convert.h" 42 44 #include "util/Exception.h" 43 45 #include "util/String.h" 44 #include "core/ Core.h"46 #include "core/GameMode.h" 45 47 #include "core/CoreIncludes.h" 46 48 #include "core/XMLPort.h" 47 49 #include "core/ConsoleCommand.h" 50 #include "GraphicsManager.h" 48 51 49 52 namespace orxonox … … 64 67 this->group_ = 0; 65 68 66 if (! Core::showsGraphics())69 if (!GameMode::showsGraphics()) 67 70 ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized"); 68 71 … … 77 80 this->overlay_->add2D(this->background_); 78 81 79 // We'll have to set the aspect ratio to a default value first.80 // GSGraphics gets informed about our construction here and can update us in the next tick.81 this->windowAspectRatio_ = 1.0;82 // Get aspect ratio from the render window. Later on, we get informed automatically 83 Ogre::RenderWindow* defaultWindow = GraphicsManager::getInstance().getRenderWindow(); 84 this->windowAspectRatio_ = (float)defaultWindow->getWidth() / defaultWindow->getHeight(); 82 85 this->sizeCorrectionChanged(); 83 86 … … 175 178 /** 176 179 @brief 177 Called by the Graphics Enginewhenever the window size changes.180 Called by the GraphicsManager whenever the window size changes. 178 181 Calculates the aspect ratio only. 179 182 */ 180 void OrxonoxOverlay::windowResized( int newWidth,int newHeight)183 void OrxonoxOverlay::windowResized(unsigned int newWidth, unsigned int newHeight) 181 184 { 182 185 this->windowAspectRatio_ = newWidth/(float)newHeight; -
code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.h
r2662 r2907 154 154 virtual void changedVisibility(); 155 155 156 inline void setOwner( ControllableEntity* owner)156 inline void setOwner(BaseObject* owner) 157 157 { 158 158 if (this->owner_ != owner) … … 162 162 } 163 163 } 164 inline ControllableEntity* getOwner() const164 inline BaseObject* getOwner() const 165 165 { return this->owner_; } 166 166 virtual void changedOwner() {} … … 200 200 201 201 private: 202 void windowResized( int newWidth,int newHeight);202 void windowResized(unsigned int newWidth, unsigned int newHeight); 203 203 204 204 static unsigned int hudOverlayCounter_s; //!< Static counter for hud elements … … 206 206 We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */ 207 207 static std::map<std::string, OrxonoxOverlay*> overlays_s; 208 ControllableEntity* owner_;208 BaseObject* owner_; 209 209 OverlayGroup* group_; 210 210 }; -
code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc
r2779 r2907 63 63 OverlayGroup::~OverlayGroup() 64 64 { 65 for (std:: map<std::string,OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)66 delete it->second;65 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 66 delete (*it); 67 67 } 68 68 … … 83 83 } 84 84 85 //! Scales every element in the map.85 //! Scales every element in the set. 86 86 void OverlayGroup::setScale(const Vector2& scale) 87 87 { 88 for (std:: map<std::string,OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)89 (*it) .second->scale(scale / this->scale_);88 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 89 (*it)->scale(scale / this->scale_); 90 90 this->scale_ = scale; 91 91 } 92 92 93 //! Scrolls every element in the map.93 //! Scrolls every element in the set. 94 94 void OverlayGroup::setScroll(const Vector2& scroll) 95 95 { 96 for (std:: map<std::string,OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)97 (*it) .second->scroll(scroll - this->scroll_);96 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 97 (*it)->scroll(scroll - this->scroll_); 98 98 this->scroll_ = scroll; 99 99 } … … 101 101 /** 102 102 @brief 103 Adds an element to the map(used when loading with XMLPort).103 Adds an element to the set (used when loading with XMLPort). 104 104 @remarks 105 105 The names of the OrxonoxOverlays have to be unique! … … 107 107 void OverlayGroup::addElement(OrxonoxOverlay* element) 108 108 { 109 this->insertElement(element, element->getName()); 110 } 111 112 /** 113 @brief 114 Adds an element to the map. 109 hudElements_.insert(element); 110 element->setVisible(this->isVisible()); 111 if (this->owner_) 112 element->setOwner(this->owner_); 113 } 114 115 /** 116 @brief 117 Removes an element from the map. 115 118 @param element 116 The element to be added. 117 @param name 118 The name of the element. 119 @remarks 120 The names of the OrxonoxOverlays have to be unique! 121 */ 122 void OverlayGroup::insertElement(OrxonoxOverlay* element, const std::string & name) 123 { 124 element->setName(name); 125 if (hudElements_.find(name) != hudElements_.end()) 126 { 127 COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl; 128 } 129 else 130 { 131 hudElements_[name] = element; 132 element->setVisible(this->isVisible()); 133 if (this->owner_) 134 element->setOwner(this->owner_); 135 } 136 } 137 138 /** 139 @brief 140 Removes an element from the map. 141 @param name 142 The name of the element that is removed. 119 The element that is to be removed. 143 120 @return 144 121 Returns true if there was such an element to remove, false if not. 145 122 */ 146 bool OverlayGroup::removeElement( const std::string & name)147 { 148 if(this->hudElements_.erase( name) == 0)123 bool OverlayGroup::removeElement(OrxonoxOverlay* element) 124 { 125 if(this->hudElements_.erase(element) == 0) 149 126 return false; 150 127 return true; … … 156 133 if (index < this->hudElements_.size()) 157 134 { 158 std:: map<std::string,OrxonoxOverlay*>::const_iterator it = hudElements_.begin();135 std::set<OrxonoxOverlay*>::const_iterator it = hudElements_.begin(); 159 136 for (unsigned int i = 0; i != index; ++it, ++i) 160 137 ; 161 return (*it) .second;138 return (*it); 162 139 } 163 140 else … … 168 145 void OverlayGroup::changedVisibility() 169 146 { 170 for (std:: map<std::string,OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)171 (*it) .second->setVisible(this->isVisible());172 } 173 174 void OverlayGroup::setOwner( ControllableEntity* owner)147 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 148 (*it)->setVisible(this->isVisible()); 149 } 150 151 void OverlayGroup::setOwner(BaseObject* owner) 175 152 { 176 153 this->owner_ = owner; 177 154 178 for (std:: map<std::string,OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)179 (*it) .second->setOwner(owner);155 for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 156 (*it)->setOwner(owner); 180 157 } 181 158 -
code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.h
r2779 r2907 37 37 #include "OrxonoxPrereqs.h" 38 38 39 #include <map> 39 #include <set> 40 #include <string> 40 41 #include <OgrePrerequisites.h> 41 42 #include "core/BaseObject.h" … … 64 65 static void scrollGroup(const std::string& name, const Vector2& scroll); 65 66 66 inline const std:: map<std::string,OrxonoxOverlay*>& getOverlays() const67 inline const std::set<OrxonoxOverlay*>& getOverlays() const 67 68 { return this->hudElements_; } 68 69 69 70 void changedVisibility(); 70 71 71 void setOwner( ControllableEntity* owner);72 inline ControllableEntity* getOwner() const72 void setOwner(BaseObject* owner); 73 inline BaseObject* getOwner() const 73 74 { return this->owner_; } 74 75 … … 86 87 87 88 void addElement(OrxonoxOverlay* element); 88 void insertElement(OrxonoxOverlay* element, const std::string & name); 89 bool removeElement(const std::string & name); 89 bool removeElement(OrxonoxOverlay* element); 90 90 OrxonoxOverlay* getElement(unsigned int index); 91 91 92 92 private: 93 std:: map<std::string,OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group.94 Vector2 scale_; 95 Vector2 scroll_; 96 ControllableEntity* owner_;//!< The owner of this OverlayGroup93 std::set<OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 94 Vector2 scale_; //!< Current scale (independent of the elements). 95 Vector2 scroll_; //!< Current scrolling offset. 96 BaseObject* owner_; //!< The owner of this OverlayGroup 97 97 }; 98 98 } -
code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.cc
r2087 r2907 42 42 #include "util/Convert.h" 43 43 #include "util/Debug.h" 44 #include "core/Clock.h" 44 45 #include "core/CoreIncludes.h" 45 46 #include "core/ConfigValueIncludes.h" … … 172 173 { 173 174 // create the corresponding input state 174 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", 40);175 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", false, false, InputStatePriority::Console); 175 176 inputState_->setKeyHandler(Shell::getInstance().getInputBuffer()); 176 177 bHidesAllInputChanged(); … … 347 348 @brief Used to control the actual scrolling and the cursor. 348 349 */ 349 void InGameConsole:: tick(float dt)350 void InGameConsole::update(const Clock& time) 350 351 { 351 352 if (this->scroll_ != 0) … … 358 359 // enlarge oldTop a little bit so that this exponential function 359 360 // reaches 0 before infinite time has passed... 360 float deltaScroll = (oldTop - 0.01) * dt* this->scrollSpeed_;361 float deltaScroll = (oldTop - 0.01) * time.getDeltaTime() * this->scrollSpeed_; 361 362 if (oldTop - deltaScroll >= 0) 362 363 { … … 373 374 // scrolling up 374 375 // note: +0.01 for the same reason as when scrolling down 375 float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * dt* this->scrollSpeed_;376 float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_; 376 377 if (oldTop - deltaScroll <= -1.2 * this->relativeHeight) 377 378 { … … 388 389 if (this->bActive_) 389 390 { 390 this->cursor_ += dt;391 this->cursor_ += time.getDeltaTime(); 391 392 if (this->cursor_ >= this->blinkTime) 392 393 { … … 409 410 @brief Resizes the console elements. Call if window size changes. 410 411 */ 411 void InGameConsole::windowResized( int newWidth,int newHeight)412 void InGameConsole::windowResized(unsigned int newWidth, unsigned int newHeight) 412 413 { 413 414 this->windowW_ = newWidth; -
code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.h
r2087 r2907 53 53 void setConfigValues(); 54 54 55 v irtual void tick(float dt);55 void update(const Clock& time); 56 56 57 57 static InGameConsole& getInstance() { assert(singletonRef_s); return *singletonRef_s; } … … 81 81 void print(const std::string& text, int index, bool alwaysShift = false); 82 82 83 void windowResized( int newWidth,int newHeight);83 void windowResized(unsigned int newWidth, unsigned int newHeight); 84 84 85 85 // config value related -
code/branches/questsystem5/src/orxonox/overlays/debug/DebugFPSText.cc
r2662 r2907 30 30 #include "DebugFPSText.h" 31 31 #include <OgreTextAreaOverlayElement.h> 32 #include "util/Convert.h" 32 33 #include "core/CoreIncludes.h" 33 #include "GraphicsEngine.h" 34 #include "util/Convert.h" 34 #include "core/Game.h" 35 35 36 36 namespace orxonox … … 51 51 SUPER(DebugFPSText, tick, dt); 52 52 53 float fps = G raphicsEngine::getInstance().getAverageFramesPerSecond();53 float fps = Game::getInstance().getAvgFPS(); 54 54 this->setCaption(convertToString(fps)); 55 55 } -
code/branches/questsystem5/src/orxonox/overlays/debug/DebugRTRText.cc
r2662 r2907 32 32 #include "core/CoreIncludes.h" 33 33 #include "util/Convert.h" 34 #include " GraphicsEngine.h"34 #include "core/Game.h" 35 35 36 36 namespace orxonox … … 51 51 SUPER(DebugRTRText, tick, dt); 52 52 53 float rtr = G raphicsEngine::getInstance().getAverageTickTime();53 float rtr = Game::getInstance().getAvgTickTime(); 54 54 this->setCaption(convertToString(rtr)); 55 55 } -
code/branches/questsystem5/src/orxonox/overlays/hud/CMakeLists.txt
r2710 r2907 7 7 ChatOverlay.cc 8 8 GametypeStatus.cc 9 PongScore.cc 9 10 ) -
code/branches/questsystem5/src/orxonox/overlays/hud/HUDRadar.cc
r2662 r2907 94 94 void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked) 95 95 { 96 if (object == (RadarViewable*)this->owner_)96 if (object == static_cast<RadarViewable*>(this->owner_)) 97 97 return; 98 98 -
code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc
r2858 r2907 410 410 this->containers_.insert(container); 411 411 this->overlays_[notification] = container; 412 this-> insertElement(container->overlay, container->name);412 this->addElement(container->overlay); 413 413 this->size_= this->size_+1; 414 414 … … 429 429 return false; 430 430 431 this->removeElement(container-> name);431 this->removeElement(container->overlay); 432 432 this->containers_.erase(container); 433 433 this->overlays_.erase(container->notification);
Note: See TracChangeset
for help on using the changeset viewer.