OpenMiner/include/gui/Text.hpp

47 lines
944 B
C++
Raw Normal View History

/*
* =====================================================================================
*
* Filename: Text.hpp
*
* Description:
*
* Created: 24/06/2018 01:48:24
*
* Author: Quentin Bazin, <quent42340@gmail.com>
*
* =====================================================================================
*/
#ifndef TEXT_HPP_
#define TEXT_HPP_
#include <string>
2018-06-26 06:38:20 +02:00
#include "Sprite.hpp"
class Text : public IDrawable, public Transformable {
public:
Text();
2018-06-26 06:38:20 +02:00
void setText(const std::string &text) { m_text = text; updateTextSprites(); }
const Vector2i &getSize() const { return m_size; }
private:
void draw(RenderTarget &target, RenderStates states) const override;
2018-06-26 06:38:20 +02:00
void updateTextSprites();
void updateCharWidth();
std::string m_text;
2018-06-26 06:38:20 +02:00
std::vector<Sprite> m_textSprites;
int m_charWidth[256];
Texture &m_texture;
VertexBuffer m_vbo;
Vector2i m_size;
};
#endif // TEXT_HPP_