Peoplemon  0.1.0
Peoplemon 3 game source documentation
MessagePrinter.hpp
Go to the documentation of this file.
1 #ifndef CORE_BATTLES_VIEW_MESSAGEPRINTER_HPP
2 #define CORE_BATTLES_VIEW_MESSAGEPRINTER_HPP
3 
4 #include <BLIB/Graphics/Triangle.hpp>
5 #include <BLIB/Interfaces/Menu.hpp>
6 #include <BLIB/Interfaces/Utilities/GhostWriter.hpp>
8 #include <Core/Input/Control.hpp>
11 #include <SFML/Graphics.hpp>
12 
13 namespace core
14 {
15 namespace battle
16 {
17 class BattleState;
18 
19 namespace view
20 {
27 public:
31  MessagePrinter(bl::engine::Engine& engine);
32 
38  void init(bl::rc::scene::CodeScene* scene);
39 
46  void setMessage(BattleState& state, const cmd::Message& message);
47 
54  void process(input::EntityControl ctrl, bool ignoreDebounce);
55 
59  bool messageDone() const;
60 
64  bool choseToForget() const;
65 
69  bool choseToSetName() const;
70 
74  const std::string& chosenNickname() const;
75 
79  void hide();
80 
86  void update(float dt);
87 
93  void render(bl::rc::scene::CodeScene::RenderContext& ctx);
94 
95 private:
96  enum struct State {
97  Hidden,
98  Printing,
99  ShowingNotAcked,
100  ShowingAcked,
101 
102  PrintingYesNoChoice,
103  WaitingYesNoChoice,
104  WaitingNameEntry
105  };
106 
107  bl::engine::Engine& engine;
108  State state;
109  bl::gfx::Text text;
110  bl::interface::GhostWriter writer;
111  bl::gfx::Triangle triangle;
112 
113  bl::menu::Menu menu;
114  bl::menu::TextItem::Ptr yesItem;
115  core::input::MenuDriver inputDriver;
116  bool choseYes;
118 
119  void finishPrint();
120  void makeChoice(bool forget);
121  void nameEntered();
122  void setState(State state);
123 };
124 
125 } // namespace view
126 } // namespace battle
127 } // namespace core
128 
129 #endif
bl::menu::TriggerDriver< Control::MoveUp, Control::MoveRight, Control::MoveDown, Control::MoveLeft, Control::Interact > MenuDriver
Helper typedef for Peoplemon specific menu driving.
Definition: MenuDriver.hpp:18
Core classes and functionality for both the editor and game.
std::underlying_type_t< Control::EntityControl > EntityControl
Helper typedef to avoid too much casting boilerplate.
Definition: Control.hpp:44
Stores and represents the current state of a battle. This is the base class for local and remote batt...
Definition: BattleState.hpp:18
Represents a message to be displayed. The actual message text is generated by the battle controller.
Definition: Message.hpp:26
Helper utility for printing battle messages.
const std::string & chosenNickname() const
Returns the nickname chosen by the player.
void process(input::EntityControl ctrl, bool ignoreDebounce)
Displays the full message. Call when user presses the continue button.
MessagePrinter(bl::engine::Engine &engine)
Construct a new Message Printer utility.
void update(float dt)
Updates the ghost writer.
void hide()
Hides the text once the view is fully synced.
bool messageDone() const
Returns true when the full message is on display and finishPrint() has been called.
void render(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the message.
bool choseToSetName() const
Whether or not the player chose to set a nickname.
void init(bl::rc::scene::CodeScene *scene)
Initializes the UI components and adds to scene.
bool choseToForget() const
Returns whether or not the player chose to forget a move.
void setMessage(BattleState &state, const cmd::Message &message)
Set the message to be printed.
A screen keyboard for getting arbitrary user input.