-
Notifications
You must be signed in to change notification settings - Fork 1
/
TextBox.h
51 lines (35 loc) · 845 Bytes
/
TextBox.h
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
#pragma once
/*
Textbox containing the instruction and player interaction
*/
#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
#include <queue>
#include "EngineX/EngineX.h"
#define DEFAULT_DELAY 0.08
class TextBox
{
public:
TextBox();
~TextBox();
void Init(Engine* game, const sf::Font& font);
void handleEvent(sf::Event* event);
void update();
void draw();
// append the string to the current text
void addText(std::string str);
// add the text but each letter at a certain delay
void addTextTyped(std::string str);
// replace the current text
void setText(std::string str);
inline void turnOn() { on = true; }
inline void turnOff() { on = false; }
tgui::TextBox::Ptr box;
float delay = DEFAULT_DELAY;
eClock time;
private:
tgui::Gui gui;
bool once = false;
std::queue <char> textQ;
bool on = true;
};