Skip to content
Snippets Groups Projects
Commit c05c1e06 authored by Yanis Dziki's avatar Yanis Dziki
Browse files

Merge branch 'master' of gitlab.ec-lyon.fr:durandu/projetcppqt

parents 543cb40b f14e2a3b
No related branches found
No related tags found
No related merge requests found
...@@ -2,5 +2,8 @@ ...@@ -2,5 +2,8 @@
Par Yanis DZIKI et Ulysse DURAND Par Yanis DZIKI et Ulysse DURAND
# Configuration
Il faut changer fichierTexte (fichier de liste des mots), width et height dans main.cpp
Vos fichiers de liste de mots doivent se trouver dans le même dossier que l'executable de l'application (qui est peut être dans le dossier build).
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#include <QQmlContext> #include <QQmlContext>
Jeu::Jeu(QQmlApplicationEngine* engine, int width, int height, QObject *parent) : QObject(parent), width(width), height(height), engine(engine) { Jeu::Jeu(QQmlApplicationEngine* engine, int width, int height, string fichierTexte, QObject *parent) : QObject(parent), width(width), height(height), engine(engine) {
brain = new Brain("./"); brain = new Brain("./");
brain->setFichierDico(fichierTexte);
} }
int Jeu::getWidth() {return width;} int Jeu::getWidth() {return width;}
...@@ -46,8 +47,6 @@ void Jeu::initGame() { ...@@ -46,8 +47,6 @@ void Jeu::initGame() {
void Jeu::startGame() { void Jeu::startGame() {
engine->rootContext()->setContextProperty("jeu", this); engine->rootContext()->setContextProperty("jeu", this);
brain->setFichierDico("words_alpha.txt");
brain->setNombreEssais(height); brain->setNombreEssais(height);
brain->setTailleMots(width); brain->setTailleMots(width);
......
...@@ -14,7 +14,7 @@ class Jeu : public QObject { ...@@ -14,7 +14,7 @@ class Jeu : public QObject {
Q_PROPERTY(QQuickItem* gameWindow READ getGameWindow NOTIFY gameWindowChanged) Q_PROPERTY(QQuickItem* gameWindow READ getGameWindow NOTIFY gameWindowChanged)
public: public:
explicit Jeu(QQmlApplicationEngine* engine, int width, int height, QObject *parent = nullptr); explicit Jeu(QQmlApplicationEngine* engine, int width, int height, string fichierTexte, QObject *parent = nullptr);
QString getMotAffiche(); QString getMotAffiche();
Q_INVOKABLE void onClavierClick(QString lettre); Q_INVOKABLE void onClavierClick(QString lettre);
Q_INVOKABLE void initGame(); Q_INVOKABLE void initGame();
...@@ -38,6 +38,7 @@ private: ...@@ -38,6 +38,7 @@ private:
int currentIndex = 0; // Pour suivre où on écrit int currentIndex = 0; // Pour suivre où on écrit
int width; int width;
int height; int height;
string fichierTexte;
}; };
#endif // JEU_H #endif // JEU_H
...@@ -15,6 +15,7 @@ int main(int argc, char *argv[]) { ...@@ -15,6 +15,7 @@ int main(int argc, char *argv[]) {
int width = 7; int width = 7;
int height = 6; int height = 6;
string fichierTexte = "words_alpha.txt";
// Charger l'interface utilisateur (QML) // Charger l'interface utilisateur (QML)
LetterModel letterModel(width, height); LetterModel letterModel(width, height);
...@@ -26,7 +27,7 @@ int main(int argc, char *argv[]) { ...@@ -26,7 +27,7 @@ int main(int argc, char *argv[]) {
QQuickItem *parentItem = rootItem; QQuickItem *parentItem = rootItem;
Jeu jeu(&engine, width, height); Jeu jeu(&engine, width, height, fichierTexte);
jeu.setLetterModel(&letterModel); jeu.setLetterModel(&letterModel);
engine.rootContext()->setContextProperty("jeu", &jeu); engine.rootContext()->setContextProperty("jeu", &jeu);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment