about summary refs log tree commit diff stats
path: root/data/maps/the_perceptive
ModeNameSize
-rw-r--r--metadata.txtpb31log stats plain blame
d---------rooms43log stats plain
anetane/blame/src/message_system.h?id=dab96b810691c26e29fef92d88c828a311be3e9d'>^
871943d ^








ec51170 ^





19be2ac ^
ec51170 ^

138e0a8 ^














c85f91c ^


f7875a6 ^



871943d ^
ec51170 ^

871943d ^

ec51170 ^



138e0a8 ^



871943d ^

bd1a668 ^

f7875a6 ^

ea78916 ^



ec51170 ^



138e0a8 ^












871943d ^
f7875a6 ^
ec51170 ^
871943d ^
ea78916 ^




ec51170 ^
138e0a8 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104


                                 


                      
                   
                  


           








                        





                              
                        

  














                                                      


                                                                             



                                                 
 

                                                            

                     



                            



                                         

                                                                         

                                                                

                                                                



                                                            



                                                                                           












                                           
                                           
                           
                                
                                      




                                   
                           


                                                            
#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 */