diff --git a/README.md b/README.md index b93e2196fe854de28b77f6264341a64e83b919bd..c1f6c7b3b7ed107a4373cf284fe1d935e99c3dae 100644 --- a/README.md +++ b/README.md @@ -2,5 +2,8 @@ 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). diff --git a/motus/jeu.cpp b/motus/jeu.cpp index 6b423d7b1f2c2dcc997b544007e4e07add735e6e..98f68ce7cbda369078f6393c14fe799d78238000 100644 --- a/motus/jeu.cpp +++ b/motus/jeu.cpp @@ -4,8 +4,9 @@ #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->setFichierDico(fichierTexte); } int Jeu::getWidth() {return width;} @@ -46,8 +47,6 @@ void Jeu::initGame() { void Jeu::startGame() { engine->rootContext()->setContextProperty("jeu", this); - brain->setFichierDico("words_alpha.txt"); - brain->setNombreEssais(height); brain->setTailleMots(width); diff --git a/motus/jeu.h b/motus/jeu.h index d612224a37680d62eb451c9a9d3c8f897d13725c..cc4ae5bc69b75a3e3ec9ebf35e86a5013c8150b9 100644 --- a/motus/jeu.h +++ b/motus/jeu.h @@ -14,7 +14,7 @@ class Jeu : public QObject { Q_PROPERTY(QQuickItem* gameWindow READ getGameWindow NOTIFY gameWindowChanged) 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(); Q_INVOKABLE void onClavierClick(QString lettre); Q_INVOKABLE void initGame(); @@ -38,6 +38,7 @@ private: int currentIndex = 0; // Pour suivre où on écrit int width; int height; + string fichierTexte; }; #endif // JEU_H diff --git a/motus/main.cpp b/motus/main.cpp index 2f612284d57323e28023251136b8b0c3a07bf319..bce2b0ddd5d8f6b182de042c6d5313a110f07ad2 100644 --- a/motus/main.cpp +++ b/motus/main.cpp @@ -15,6 +15,7 @@ int main(int argc, char *argv[]) { int width = 7; int height = 6; + string fichierTexte = "words_alpha.txt"; // Charger l'interface utilisateur (QML) LetterModel letterModel(width, height); @@ -26,7 +27,7 @@ int main(int argc, char *argv[]) { QQuickItem *parentItem = rootItem; - Jeu jeu(&engine, width, height); + Jeu jeu(&engine, width, height, fichierTexte); jeu.setLetterModel(&letterModel); engine.rootContext()->setContextProperty("jeu", &jeu);