#pragma once #include #include #include class Voice { public: Voice(); ~Voice(); void addLine(std::string filename, float timer, bool pitch = false); void addSubtitle(float timer, float duration, std::string text, sf::Color color = sf::Color(172, 50, 50)); void update(float dt); bool isFree() const { return m_lines.empty() && m_subs.empty(); } void clear() { while(!m_lines.empty()) m_lines.pop(); m_sound.stop(); } private: sf::Sound m_sound; sf::Text m_text; struct Line { float clock{ 0.f }; float timer; bool pitch; std::string filename; bool played{ false }; }; struct Sub { float clock{ 0.f }; float timer; float duration; sf::Color color; std::string text; };; std::queue m_lines; std::queue m_subs; };