Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //GUIBase.h
- #pragma once
- #include "stdafx.h"
- #include "Sprite.h"
- class GUIBase : public sf::Drawable {
- public:
- enum Strata { //On what depth is this drawn.
- BOTTOM,
- LOW,
- MEDIUM,
- HIGH,
- TOP,
- StrataAmount
- };
- GUIBase();
- GUIBase(sf::Vector2f p_position, sf::Texture *p_texture = nullptr, Strata p_strata = BOTTOM);
- GUIBase(float p_xPos, float p_yPos, sf::Texture *p_texture = nullptr, Strata p_strata = BOTTOM);
- virtual ~GUIBase();
- void SetPosition(float p_xPos, float p_yPos);
- void SetPosition(sf::Vector2f p_position);
- void SetStrata(Strata p_strata);
- virtual void draw(sf::RenderTarget &p_window, sf::RenderStates p_renderStates = sf::RenderStates::Default) const;
- sf::Vector2f GetPosition();
- Strata GetStrata();
- protected:
- Sprite *m_sprite;
- sf::Texture *m_texture;
- sf::Vector2f m_position;
- Strata m_strata;
- };
- //GUIBase.cpp
- #include "stdafx.h"
- #include "GUIBase.h"
- GUIBase::GUIBase()
- {
- m_texture = nullptr;
- m_position.x = 0.0f;
- m_position.y = 0.0f;
- m_strata = BOTTOM;
- }
- GUIBase::GUIBase(sf::Vector2f p_position, sf::Texture *p_texture, Strata p_strata)
- {
- m_texture = p_texture;
- m_position = p_position;
- m_strata = p_strata;
- }
- GUIBase::GUIBase(float p_xPos, float p_yPos, sf::Texture *p_texture, Strata p_strata)
- {
- m_texture = p_texture;
- m_position.x = p_xPos;
- m_position.y = p_yPos;
- m_strata = p_strata;
- }
- GUIBase::~GUIBase()
- {
- }
- void GUIBase::SetPosition(float p_xPos, float p_yPos)
- {
- m_position.x = p_xPos;
- m_position.y = p_yPos;
- }
- void GUIBase::SetPosition(sf::Vector2f p_position)
- {
- m_position = p_position;
- }
- void GUIBase::draw(sf::RenderTarget &p_window, sf::RenderStates p_renderStates) const {
- p_window.draw(*this);
- }
- void GUIBase::SetStrata(Strata p_strata)
- {
- m_strata = p_strata;
- }
- sf::Vector2f GUIBase::GetPosition()
- {
- return m_position;
- }
- GUIBase::Strata GUIBase::GetStrata()
- {
- return m_strata;
- }
Advertisement
Add Comment
Please, Sign In to add comment