#ifndef MESSAGE_SYSTEM_H_DE10D011 #define MESSAGE_SYSTEM_H_DE10D011 #include #include #include #include "system.h" #include "timer.h" class Game; enum class SpeakerType { None, Man, Woman, Boy, Girl, Nonhuman }; class MessageSystem : public System { public: static constexpr SystemKey Key = SystemKey::Message; MessageSystem(Game& game) : game_(game) {} void tick(double dt) override; // Commands void displayCutsceneBars(); void hideCutsceneBars(); void displayMessage( std::string_view msg, std::string speakerName = "", SpeakerType speakerType = SpeakerType::None); void advanceText(); // Info double getCutsceneBarsProgress() const; struct MessageLine { std::string text; int charsRevealed = 0; }; const std::list& getLines() const { return linesToShow_; } bool isMessageActive() const { return !linesToShow_.empty(); } const std::string& getSpeaker() const { return speakerName_; } bool isNextArrowShowing() const { return showNextArrow_; } int getNextArrowBob() const { return nextArrowBobPos_; } private: enum class BarsState { Closed, Opening, Open, Closing }; Game& game_; BarsState barsState_ = BarsState::Closed; double accum_ = 0.0; double length_ = 1000.0/8; SpeakerType speaker_ = SpeakerType::None; std::string speakerName_; std::list lines_; std::list linesToShow_; Timer textAdvTimer_ { 15 }; bool showNextArrow_ = false; int nextArrowBobPos_ = 0; bool nextArrowBobDown_ = true; Timer nextArrowBobTimer_ { 125 }; }; #endif /* end of include guard: MESSAGE_SYSTEM_H_DE10D011 */