summary refs log tree commit diff stats
path: root/src/sign.h
blob: 8a69fd33d79034d8f8124f8993c9d0ca57c781cb (plain) (blame)
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
#ifndef SIGN_H_B0491849
#define SIGN_H_B0491849

#include <string>
#include <list>
#include <SDL_ttf.h>
#include "interpolation.h"
#include "timer.h"

class Game;

enum class SignInstructionState {
  Hidden,
  FadingIn,
  Visible,
  FadingOut
};

struct SignLine {
  std::string text;
  bool pause = false;
  int charsRevealed = 0;
};

class Sign {
public:

  explicit Sign(TTF_Font* font) : font_(font) {}

  void displayMessage(std::string text);

  void update(size_t dt, Game& game);

  SignInstructionState signDisplayState = SignInstructionState::Hidden;
  Interpolation signDisplayFade;
  std::list<SignLine> lines;
  std::list<SignLine> linesToShow;
  bool showNextArrow = false;
  int nextArrowBobPos = 0;

private:

  TTF_Font* font_;
  Timer textAdvTimer_ { 15 };
  bool nextArrowBobDown_ = true;
  Timer nextArrowBobTimer_ { 125 };
};

#endif /* end of include guard: SIGN_H_B0491849 */