1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #pragma once
- #include <SFML/Audio.hpp>
- #include <SFML/Graphics.hpp>
- #include <queue>
- 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<Line> m_lines;
- std::queue<Sub> m_subs;
- };
|