Enfisk

GUIBase

Feb 20th, 2014
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.93 KB | None | 0 0
  1. //GUIBase.h
  2. #pragma once
  3. #include "stdafx.h"
  4. #include "Sprite.h"
  5.                
  6. class GUIBase : public sf::Drawable {
  7. public:
  8.     enum Strata {               //On what depth is this drawn.
  9.         BOTTOM,
  10.         LOW,
  11.         MEDIUM,
  12.         HIGH,
  13.         TOP,
  14.         StrataAmount
  15.     };
  16.  
  17.     GUIBase();
  18.     GUIBase(sf::Vector2f p_position, sf::Texture *p_texture = nullptr, Strata p_strata = BOTTOM);
  19.     GUIBase(float p_xPos, float p_yPos, sf::Texture *p_texture = nullptr, Strata p_strata = BOTTOM);
  20.     virtual ~GUIBase();
  21.  
  22.     void SetPosition(float p_xPos, float p_yPos);
  23.     void SetPosition(sf::Vector2f p_position);
  24.     void SetStrata(Strata p_strata);
  25.     virtual void draw(sf::RenderTarget &p_window, sf::RenderStates p_renderStates = sf::RenderStates::Default) const;
  26.  
  27.     sf::Vector2f GetPosition();
  28.     Strata GetStrata();
  29.  
  30. protected:
  31.     Sprite *m_sprite;
  32.     sf::Texture *m_texture;
  33.     sf::Vector2f m_position;
  34.     Strata m_strata;
  35. };
  36.  
  37.  
  38. //GUIBase.cpp
  39. #include "stdafx.h"
  40. #include "GUIBase.h"
  41.  
  42. GUIBase::GUIBase()
  43. {
  44.     m_texture = nullptr;
  45.     m_position.x = 0.0f;
  46.     m_position.y = 0.0f;
  47.     m_strata = BOTTOM;
  48. }
  49.  
  50. GUIBase::GUIBase(sf::Vector2f p_position, sf::Texture *p_texture, Strata p_strata)
  51. {
  52.     m_texture = p_texture;
  53.     m_position = p_position;
  54.     m_strata = p_strata;
  55. }
  56.  
  57. GUIBase::GUIBase(float p_xPos, float p_yPos, sf::Texture *p_texture, Strata p_strata)
  58. {
  59.     m_texture = p_texture;
  60.     m_position.x = p_xPos;
  61.     m_position.y = p_yPos;
  62.     m_strata = p_strata;
  63. }
  64.  
  65. GUIBase::~GUIBase()
  66. {
  67.  
  68. }
  69.  
  70. void GUIBase::SetPosition(float p_xPos, float p_yPos)
  71. {
  72.     m_position.x = p_xPos;
  73.     m_position.y = p_yPos;
  74. }
  75.  
  76. void GUIBase::SetPosition(sf::Vector2f p_position)
  77. {
  78.     m_position = p_position;
  79. }
  80.  
  81. void GUIBase::draw(sf::RenderTarget &p_window, sf::RenderStates p_renderStates) const {
  82.     p_window.draw(*this);
  83. }
  84.  
  85. void GUIBase::SetStrata(Strata p_strata)
  86. {
  87.     m_strata = p_strata;
  88. }
  89.  
  90. sf::Vector2f GUIBase::GetPosition()
  91. {
  92.     return m_position;
  93. }
  94.  
  95. GUIBase::Strata GUIBase::GetStrata()
  96. {
  97.     return m_strata;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment