-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGame.h
63 lines (50 loc) · 1.13 KB
/
Game.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
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef GAME_H
#define GAME_H
#include <QObject>
#include <QQmlEngine>
#include <QMediaPlayer>
#include <QThread>
#include <string>
#include <QTextToSpeech>
#include "DeepSpeechC.h"
enum GameState
{
INTRO,
GAME,
QUIT
};
struct Question
{
QString name;
QString img;
};
class Game : public QObject
{
Q_OBJECT
public:
explicit Game(QObject *parent = nullptr);
static Game* getGame(QQmlEngine *engine, QJSEngine *scriptEngine);
static void destroy();
public slots:
void openingMenu();
void userSpeech(QString text);
void listenFor(QString word);
void speak(QString text);
void speechDone(QTextToSpeech::State state);
signals:
void gameStart();
void showQsn(QString word, QString img);
private:
static Game* backend;
QMediaPlayer* player=nullptr;
void loadMusic(QString file);
void nextQsn(bool sayit=false);
void showNextQsn();
DeepSpeech ds;
QThread deepThread; //Run DeepSpeech in diff thread to prevent UI Lag
QString listeningFor;
GameState gameState = INTRO;
std::vector<Question> qsns;
QTextToSpeech* speech;
};
#endif // GAME_H