#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 }; struct MessageLine { std::string text; int charsRevealed = 0; bool pause = false; bool isChoice = false; int choicePos[2] = {-1, -1}; bool bulleted = false; }; 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(); // Adds text to the message queue. Separate lines with \n. // \f is a special character -- put it after a \n to indicate that a button // press is required to advance text. void displayMessage( std::string_view msg, std::string speakerName = "", SpeakerType speakerType = SpeakerType::None); void showChoice(std::string choice1, std::string choice2); void advanceText(); void selectFirstChoice(); void selectSecondChoice(); // Info double getCutsceneBarsProgress() const; 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_; } bool isChoiceActive() const { return isMessageActive() && linesToShow_.back().isChoice; } int getChoiceSelection() const { return choiceSelection_; } 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 }; int choiceSelection_ = 0; }; #endif /* end of include guard: MESSAGE_SYSTEM_H_DE10D011 */