/* * Copyright (C) 2022 Riyyi * * SPDX-License-Identifier: MIT */ #pragma once #include // std::uint32_t #include // std::shared_ptr #include // std::optional #include // std::vector #include "glm/ext/vector_float3.hpp" // glm::vec3 #include "ruc/singleton.h" #include "inferno/component/textareacomponent.h" #include "inferno/render/font.h" #include "inferno/render/renderer.h" namespace Inferno { using Characters = std::vector>; using CharacterQuad = std::array; class Font; class Scene; class TextAreaSystem final : public ruc::Singleton { public: TextAreaSystem(s); virtual ~TextAreaSystem(); void render(); void setScene(Scene* scene) { m_scene = scene; } private: void createLines(std::shared_ptr font, const TextAreaComponent& textarea); void createQuads(std::shared_ptr font, const TextAreaComponent& textarea); std::optional calculateCharacterQuad(std::shared_ptr c, char previous, std::shared_ptr font, float fontSize, float& advanceX, float& advanceY); Characters m_characters; Scene* m_scene { nullptr }; }; } // namespace Inferno