diff --git a/Motus/Main.qml b/Motus/Main.qml index ff64d40b75d68f28bf2218156853ae819422a1eb..830bfd255b096718b635899eb526963d7f3b0a64 100644 --- a/Motus/Main.qml +++ b/Motus/Main.qml @@ -242,7 +242,7 @@ Window { Keys.onPressed: function(event) { // On vérifie que le jeu est en cours (ni gagné, ni perdu) - if (mot !== "" && !motusGame.loosetry && !motusGame.win && !motusGame.loosetime) { + if (mot !== "" && !motusGame.loosetry && !motusGame.win && !motusGame.loosetime && !motusGame.looseabandon) { if (/^[a-zA-Z]$/.test(event.text)) { if (indice_case < nb_lettres) { var cellIndex = current_essai * nb_lettres + indice_case; @@ -376,7 +376,7 @@ Window { MouseArea { anchors.fill: parent cursorShape: Qt.PointingHandCursor - enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.loosetime || !motusGame.debut) + enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.looseabandon || motusGame.loosetime || !motusGame.debut) onClicked: { current_essai = 0; indice_case = 0; @@ -394,6 +394,7 @@ Window { mot = motusGame.getRandomWord(nb_lettres); motusGame.setLoosetrybool(false); motusGame.setLoosetimebool(false); + motusGame.setLooseabandonbool(false); motusGame.setWinbool(false); motusGame.startTimer(); case3._textText = mot; @@ -436,7 +437,7 @@ Window { _textText: "Français" rectangleColor: "#7a7a7a" MouseArea { - enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.loosetime || !motusGame.debut) + enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.looseabandon || motusGame.loosetime || !motusGame.debut) anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { @@ -457,7 +458,7 @@ Window { _textText: "English" rectangleColor: "green" MouseArea { - enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.loosetime || !motusGame.debut) + enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.looseabandon || motusGame.loosetime || !motusGame.debut) anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { @@ -508,7 +509,7 @@ Window { model: ["4", "5", "6", "7", "8", "9", "10","11","12", "Aléatoire"] flat: true - enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.loosetime || !motusGame.debut) + enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.looseabandon || motusGame.loosetime || !motusGame.debut) // Le contenu affiché (texte sélectionné) @@ -636,7 +637,7 @@ Window { anchors.bottom: parent.bottom anchors.horizontalCenter: parent.horizontalCenter cursorShape: Qt.PointingHandCursor - enabled: !(motusGame && (motusGame.win || motusGame.loosetry || motusGame.loosetime || !motusGame.debut)) + enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.looseabandon || motusGame.loosetime || !motusGame.debut) onClicked: { updateGameStats(); statsOverlayVisible = true; @@ -700,10 +701,10 @@ Window { anchors.bottom: parent.bottom anchors.horizontalCenter: parent.horizontalCenter cursorShape: Qt.PointingHandCursor - enabled: motusGame && (motusGame.win || motusGame.loosetry || motusGame.loosetime || !motusGame.debut) + enabled: !(motusGame && (motusGame.win || motusGame.loosetry || motusGame.looseabandon || motusGame.loosetime || !motusGame.debut)) onClicked: { - motusGame.setLoosetrybool(true); - console.log("loosetry=true"); + motusGame.setLooseabandonbool(true); + console.log("looseabandon=true"); updateGameStats(); } } @@ -713,7 +714,7 @@ Window { Text { visible: motusGame && motusGame.loosetime color: "red" - text: "Temps écoulé ! Mot : " + text: "Temps écoulé ! Mot : " + mot.toUpperCase() font.pixelSize: 30 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -732,6 +733,17 @@ Window { anchors.horizontalCenter: parent.horizontalCenter } + Text { + visible: motusGame && motusGame.looseabandon + color: "red" + text: "Abandon... \n Mot : " + mot.toUpperCase() + font.pixelSize: 30 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.bold: true + anchors.horizontalCenter: parent.horizontalCenter + } + Text { text: "Gagné !" visible: motusGame && motusGame.win @@ -876,7 +888,7 @@ Window { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: { - if (mot !== "" && !motusGame.loosetry && !motusGame.win && !motusGame.loosetime) { + if (mot !== "" && !motusGame.loosetry && !motusGame.looseabandon && !motusGame.win && !motusGame.loosetime) { if (modelData === "<") { if (indice_case > 0) { indice_case--; diff --git a/Motus/motusgame.cpp b/Motus/motusgame.cpp index 6a70580a8b1c4a8f168c168d5888176d497f0f2b..89218ac3875ea5f390df225d7723269f3b181ba9 100644 --- a/Motus/motusgame.cpp +++ b/Motus/motusgame.cpp @@ -186,6 +186,10 @@ bool MotusGame::getLoosetrybool() const { return loosetry; } +bool MotusGame::getLooseabandonbool() const { + return looseabandon; +} + bool MotusGame::getWinbool() const { return win; } @@ -206,6 +210,12 @@ void MotusGame::setLoosetrybool(bool value) { emit loosetryChanged(); } +void MotusGame::setLooseabandonbool(bool value) { + looseabandon = value; + stopTimer(); + emit looseabandonChanged(); +} + void MotusGame::setWinbool(bool value) { win = value; stopTimer(); diff --git a/Motus/motusgame.h b/Motus/motusgame.h index 432a8822bc55a7b3e533c6e797641892b58306ed..1f136288a90e6e00db321fcfb33e6f44eb647794 100644 --- a/Motus/motusgame.h +++ b/Motus/motusgame.h @@ -36,6 +36,7 @@ class MotusGame : public QObject { Q_PROPERTY(int letterNumber READ getLetterNumber WRITE setLetterNumber NOTIFY letterNumberChanged) Q_PROPERTY(bool loosetry READ getLoosetrybool WRITE setLoosetrybool NOTIFY loosetryChanged) Q_PROPERTY(bool loosetime READ getLoosetimebool WRITE setLoosetimebool NOTIFY loosetimeChanged) + Q_PROPERTY(bool looseabandon READ getLooseabandonbool WRITE setLooseabandonbool NOTIFY looseabandonChanged) Q_PROPERTY(bool win READ getWinbool WRITE setWinbool NOTIFY winChanged) public: @@ -57,6 +58,8 @@ public: Q_INVOKABLE void setLoosetrybool(bool value); bool getLoosetimebool() const; Q_INVOKABLE void setLoosetimebool(bool value); + bool getLooseabandonbool() const; + Q_INVOKABLE void setLooseabandonbool(bool value); bool getWinbool() const; Q_INVOKABLE void setWinbool(bool value); @@ -84,6 +87,7 @@ private: int remainingTime = 120; bool loosetry = false; bool loosetime = false; + bool looseabandon = false; bool win = false; bool debut = false; int duree_timer = 120; @@ -99,6 +103,7 @@ signals: void letterNumberChanged(); void loosetryChanged(); void loosetimeChanged(); + void looseabandonChanged(); void winChanged(); void statsChanged(); // Signal pour informer que les statistiques ont changé void tryTotalChanged(); // Signal pour informer que le nombre d'essais a changé