diff options
Diffstat (limited to 'src/text.cpp')
-rw-r--r-- | src/text.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/text.cpp b/src/text.cpp index fb82875..c25eeae 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -13,13 +13,15 @@ TextSystem::~TextSystem(void) } void TextSystem::configure([[maybe_unused]] entityx::EntityManager& entities, - [[maybe_unused]] entityx::EventManager& events) + entityx::EventManager& events) { + shouldUpdateVBOs = false; + + events.subscribe<ShowTextEvent>(*this); + if (FT_Init_FreeType(&freetype) != 0) { // TODO handle error } - - shouldUpdateVBOs = false; } /** @@ -42,6 +44,11 @@ void TextSystem::update([[maybe_unused]] entityx::EntityManager& entites, } } +void TextSystem::receive(const ShowTextEvent& ste) +{ + put(ste.font, ste.x, ste.y, ste.text); +} + void TextSystem::loadFont(const std::string& name, const std::string& file, int size) @@ -138,7 +145,7 @@ void TextSystem::put(const std::string& font, if (fontData.find(font) == fontData.end()) return; - y -= fontData[font].fontSize; + y += fontData[font].fontSize; auto& vector = fontData[font].text; if (auto i = std::find_if(vector.begin(), vector.end(), [&x, &y](const Text& t) { @@ -146,7 +153,8 @@ void TextSystem::put(const std::string& font, vector.erase(i); } - fontData[font].text.emplace_back(text, x, y, -9.0f); + // Invert y axis so positive grows south. + fontData[font].text.emplace_back(text, x, -y, -9.0f); shouldUpdateVBOs = true; } |