mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 21:01:48 +01:00
31 lines
957 B
C++
31 lines
957 B
C++
#include "Text.h"
|
|
|
|
#include <iostream>
|
|
Text::Text(const std::string& text, const std::string& fontPath, int size, const Color4f& color): m_Text(text), m_FontPath(fontPath), m_Size(size), m_Color(color) {
|
|
m_Texture = new Texture(text, fontPath, size, color);
|
|
m_IsCreatedOk = m_Texture->IsCreationOk();
|
|
if(!m_IsCreatedOk) {
|
|
std::cout << "Error creating text texture, Text: " << text << std::endl;
|
|
}
|
|
}
|
|
Text::~Text() {
|
|
if(m_IsCreatedOk && m_Texture->IsCreationOk()) {
|
|
delete m_Texture;
|
|
}
|
|
}
|
|
void Text::Draw(const Vector2f& pos) const {
|
|
if(m_IsCreatedOk) {
|
|
m_Texture->Draw(pos);
|
|
} else {
|
|
std::cout << "Trying to render a Text that is not correctly made,\nText: " << m_Text << std::endl;
|
|
}
|
|
}
|
|
void Text::ChangeText(const std::string& text) {
|
|
if(m_IsCreatedOk && m_Texture->IsCreationOk()) {
|
|
delete m_Texture;
|
|
m_Texture = new Texture(text, m_FontPath, m_Size, m_Color);
|
|
} else {
|
|
std::cout << "This is wierd??: " << m_Text << std::endl;
|
|
}
|
|
}
|