Add Text rendering and Hull / Fuel Meters

This commit is contained in:
Bram Verhulst
2024-05-16 02:04:36 +02:00
parent 600050c198
commit 8866f33c09
18 changed files with 286 additions and 118 deletions

View File

@@ -1,7 +1,7 @@
#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_Color(color) {
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) {
@@ -14,5 +14,17 @@ Text::~Text() {
}
}
void Text::Draw(const Vector2f& pos) const {
m_Texture->Draw(pos);
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;
}
}