about summary refs log tree commit diff stats
path: root/data/maps/the_double_sided/rooms
ModeNameSize
-rw-r--r--Brown Area.txtpb113log stats plain blame
-rw-r--r--Flipped Black Area.txtpb169log stats plain blame
-rw-r--r--Flipped Blue Area.txtpb254log stats plain blame
-rw-r--r--Flipped Green Area.txtpb150log stats plain blame
-rw-r--r--Flipped Orange Area.txtpb156log stats plain blame
-rw-r--r--Flipped Pink Area.txtpb47log stats plain blame
-rw-r--r--Flipped Purple Area.txtpb270log stats plain blame
-rw-r--r--Flipped Red Area.txtpb157log stats plain blame
-rw-r--r--Flipped Yellow Back Area.txtpb164log stats plain blame
-rw-r--r--Flipped Yellow Front Area.txtpb55log stats plain blame
-rw-r--r--Obverse Black Area.txtpb274log stats plain blame
-rw-r--r--Obverse Blue Area.txtpb47log stats plain blame
-rw-r--r--Obverse Green Area.txtpb159log stats plain blame
-rw-r--r--Obverse Orange Back Area.txtpb159log stats plain blame
-rw-r--r--Obverse Orange Front Area.txtpb154log stats plain blame
-rw-r--r--Obverse Orange Isolated Section.txtpb164log stats plain blame
-rw-r--r--Obverse Pink Area.txtpb152log stats plain blame
-rw-r--r--Obverse Purple Area.txtpb272log stats plain blame
-rw-r--r--Obverse Red Area.txtpb46log stats plain blame
-rw-r--r--Obverse Yellow Area.txtpb49log stats plain blame
-rw-r--r--Start.txtpb337log stats plain blame
e>


           








                        





                              
                        

  














                                                      


                                                                             



                                                 
 

                                                            

                     



                            



                                         

                                                                         

                                                                

                                                                



                                                            



                                                                                           












                                           
                                           
                           
                                
                                      




                                   
                           


                                                            
#ifndef MESSAGE_SYSTEM_H_DE10D011
#define MESSAGE_SYSTEM_H_DE10D011

#include <list>
#include <string_view>
#include <string>
#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<MessageLine>& 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<MessageLine> lines_;
  std::list<MessageLine> 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 */