- Timestamp:
- Jan 8, 2006, 4:02:30 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/graphics_engine.cc
r6222 r6441 19 19 #include "resource_manager.h" 20 20 #include "event_handler.h" 21 #include "state.h" 21 22 22 23 #include "world_entity.h" … … 298 299 this->resolutionY = height; 299 300 this->bitsPerPixel = bpp; 301 State::setResolution( width, height); 300 302 301 303 if (this->screen != NULL) -
trunk/src/util/hud.cc
r6440 r6441 18 18 #include "hud.h" 19 19 20 #include "state.h" 21 20 22 using namespace std; 21 23 … … 29 31 this->setClassID(CL_HUD, "Hud"); 30 32 31 33 //this->setSize2D( 32 34 this->energyWidget = NULL; 33 35 this->shieldWidget = NULL; 34 36 this->armorWidget = NULL; 37 this->resX = 1; 38 this->resY = 1; 35 39 } 36 40 … … 67 71 { 68 72 this->energyWidget->show(); 69 this->energyWidget->setAbsCoor2D(10,80);70 this->energyWidget->setSize2D(20,300);71 73 } 72 74 73 75 this->updateResolution(); 74 76 } 75 77 … … 94 96 } 95 97 96 void setResolution(unsigned int resX, unsigned int resY); 98 void Hud::updateResolution() 99 { 100 this->resX = State::resX(); 101 this->resY = State::resY(); 102 if (this->energyWidget != NULL) 103 { 104 this->energyWidget->setAbsCoor2D(.02 * this->resX, .4 * this->resY); 105 this->energyWidget->setSize2D(.05 * this->resX, .55 * this->resY); 106 } 107 } 108 109 110 void Hud::tick(float dt) 111 { 112 if (this->resY != State::resY() || this->resX != State::resY()) 113 this->updateResolution(); 114 } 115 116 void Hud::draw() const 117 { 118 GLGuiWidget::draw(); 119 } 120 121 -
trunk/src/util/hud.h
r6438 r6441 15 15 16 16 //! A class that renders a HUD. 17 class Hud : p rivateGLGuiWidget17 class Hud : public GLGuiWidget 18 18 { 19 19 … … 21 21 Hud(); 22 22 virtual ~Hud(); 23 23 24 24 25 void loadParams(const TiXmlElement* root); … … 32 33 void removeWeaponWidget(GLGuiWidget* widget); 33 34 34 void setResolution(unsigned int resX, unsigned int resY); 35 void tick(float dt); 36 void draw() const; 35 37 38 private: 39 void updateResolution(); 36 40 private: 37 unsigned int resX; //!< The X-Resolution needed for resizing the Hud.38 unsigned int resY; //!< The Y-Resolution needed for resizing the Hud.41 unsigned int resX; 42 unsigned int resY; 39 43 40 44 GLGuiWidget* energyWidget; -
trunk/src/util/state.cc
r6222 r6441 31 31 ObjectManager* State::objectManager = NULL; 32 32 33 unsigned int State::_resX = 1; 34 unsigned int State::_resY = 1; 35 33 36 /** 34 37 * sets camera and target of the current Camera -
trunk/src/util/state.h
r6222 r6441 39 39 static inline ObjectManager* getObjectManager() { return State::objectManager; }; 40 40 41 static inline void setResolution(unsigned int resX, unsigned int resY) { State::_resX = resX; State::_resY = resY; }; 42 static inline unsigned int resX() { return State::_resX; }; 43 static inline unsigned int resY() { return State::_resY; }; 44 41 45 ///////////////////////// 42 46 /// WORLD_ENTITY_LIST /// … … 51 55 static ObjectManager* objectManager; //!< A referenct to the current ObjectManager 52 56 57 static unsigned int _resX; //!< The X Resolution of the screen. 58 static unsigned int _resY; //!< The Y Resolution of the screen. 53 59 }; 54 60 -
trunk/src/world_entities/player.cc
r6440 r6441 38 38 39 39 this->controllable = NULL; 40 this->hud = new Hud();40 this->hud.show(); 41 41 42 42 EventHandler::getInstance()->subscribe(this, ES_GAME, SDLK_l); … … 49 49 Player::~Player () 50 50 { 51 delete this->hud;52 51 53 52 } … … 59 58 { 60 59 this->controllable = controllable; 61 this->hud ->setEnergyWidget(this->controllable->getEnergyWidget());60 this->hud.setEnergyWidget(this->controllable->getEnergyWidget()); 62 61 return true; 63 62 } … … 73 72 { 74 73 this->controllable = NULL; 75 this->hud ->setEnergyWidget(NULL);74 this->hud.setEnergyWidget(NULL); 76 75 return true; 77 76 } -
trunk/src/world_entities/player.h
r6440 r6441 9 9 #include "event_listener.h" 10 10 11 #include "util/hud.h" 12 11 13 /* Forward Declaration */ 12 14 class Playable; 13 class Hud; 15 14 16 15 17 //! Basic controllable WorldEntity … … 36 38 private: 37 39 Playable* controllable; //!< The one we controll or NULL if none 38 Hud * hud; //!< The HUD to be displayed.40 Hud hud; //!< The HUD to be displayed for this Player. 39 41 }; 40 42
Note: See TracChangeset
for help on using the changeset viewer.