From c392be23c4733ae7ec4722128d3c2f2724d96e52 Mon Sep 17 00:00:00 2001 From: jbreitwi <josephine.breitwiller@etu.ec-lyon.fr> Date: Mon, 31 Mar 2025 10:39:02 +0200 Subject: [PATCH] =?UTF-8?q?menu=20mise=20=C3=A0=20jour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applicationQT2048/MenuPage.qml | 117 ++++++++++++++++++++---------- applicationQT2048/gamemanager.cpp | 15 +--- 2 files changed, 81 insertions(+), 51 deletions(-) diff --git a/applicationQT2048/MenuPage.qml b/applicationQT2048/MenuPage.qml index 5f04abc..3ac9b70 100644 --- a/applicationQT2048/MenuPage.qml +++ b/applicationQT2048/MenuPage.qml @@ -14,9 +14,19 @@ Rectangle { y:70 } + Text{ + text: "Design du jeu" + font.bold: true + color:"grey" + font.pixelSize: 25 + anchors.horizontalCenter: parent.horizontalCenter + y:120 + } + + MenuBar{ - y:220 + y:180 anchors.horizontalCenter: parent.horizontalCenter background: Rectangle { color: "#BBADA0"; radius: 5 } @@ -25,7 +35,7 @@ Rectangle { MenuItem { text: "Arial" - background: Rectangle { color: "black"; radius: 5 } // Fond et coins arrondis + background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis } } @@ -33,7 +43,7 @@ Rectangle { } MenuBar{ - y:300 + y:240 anchors.horizontalCenter: parent.horizontalCenter background: Rectangle { color: "#BBADA0"; radius: 5 } @@ -43,67 +53,94 @@ Rectangle { } - - Rectangle { - color:"red" - width: 90; height: 30 + Text{ + text: "Fonctionnalitées" + font.bold: true + color:"grey" + font.pixelSize: 25 anchors.horizontalCenter: parent.horizontalCenter - y:150 - radius:5 + y:300 + } - MenuBar{ - Menu{ - title:"mode de jeu" - MenuItem { - text: "Grille 4x4" - background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis - onTriggered: gameManager.modeDeJeu(1) - } + MenuBar { + anchors.horizontalCenter: parent.horizontalCenter + y:350 + background: Rectangle { color: "#BBADA0"; radius: 5 } - MenuItem { - text: "Grille 8x8" - background: Rectangle { color: "grey"; radius: 5 } - onTriggered: gameManager.modeDeJeu(2) - } + Menu{ + title:"mode de jeu" + MenuItem { + text: "Grille 4x4" + background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis + onTriggered: gameManager.modeDeJeu(1) + } + MenuItem { + text: "Grille 8x8" + background: Rectangle { color: "grey"; radius: 5 } + onTriggered: gameManager.modeDeJeu(2) } + } } - Rectangle { + Text{ + text: "accès à l'historique des parties" - width: 90; height: 30 + color:"grey" + font.pixelSize: 20 anchors.horizontalCenter: parent.horizontalCenter - y:250 - radius:5 + y:390 + } + MenuBar{ + anchors.horizontalCenter: parent.horizontalCenter + y:450 + background: Rectangle { color: "#BBADA0"; radius: 5 } - MenuBar { - Menu { - title: "Charger une ancienne partie" + Menu { + title: "Charger une ancienne partie" + Repeater { + model: gameManager.partieHistorique + MenuItem { + text: modelData + background: Rectangle { color: "grey"; radius: 5 } + onTriggered: gameManager.chargerPartie(modelData) + } + } + } + } - Repeater { - model: gameManager.partieHistorique - MenuItem { - text: modelData - background: Rectangle { color: "grey"; radius: 5 } - onTriggered: gameManager.chargerPartie(modelData) - } - } - } - } + Rectangle { + color:"#BBADA0" + width: 150; height: 30 + anchors.horizontalCenter: parent.horizontalCenter + y:510 + radius:5 + + Text{ + anchors.centerIn: parent + text: "Supprimer l'historique" + color:"black" + } + + MouseArea{ + anchors.fill: parent + onClicked: gameManager.supprimerHistorique() + } } + Rectangle { color:"blue" width: 90; height: 30 anchors.horizontalCenter: parent.horizontalCenter - y:510 + y:560 radius:5 Text{ diff --git a/applicationQT2048/gamemanager.cpp b/applicationQT2048/gamemanager.cpp index 317947f..9ab3ea3 100644 --- a/applicationQT2048/gamemanager.cpp +++ b/applicationQT2048/gamemanager.cpp @@ -206,15 +206,12 @@ void GameManager::restartGame(QString partieName) { //demander pour sauvergarder la partie précédente -<<<<<<< HEAD - if(partieName=="false"){ - }else{ + + if(partieName=="false"){}else{ enregistrerPartie(partieName); }; -======= - enregistrerPartie("partie1"); m_gameOver = false; ->>>>>>> e22daca7a3c09bd0a515d12093b0cbf7e3e4e152 + // Réinitialisation des variables @@ -405,19 +402,16 @@ void GameManager::chargerPartie(QString partieName){ } emit gridChanged(); // Notifiez que la grille a changé - - file.close(); + calculscore(); } int GameManager::score() const { return m_score; // Retourne le score actuel } -<<<<<<< HEAD -======= void GameManager::calculscore(){ if (m_gameOver) { // Si la partie est terminée, ne calcule pas le score return; @@ -448,4 +442,3 @@ bool GameManager::isGameOver() { } return true; // Si la grille est pleine et aucune fusion n'est possible, la partie est terminée } ->>>>>>> e22daca7a3c09bd0a515d12093b0cbf7e3e4e152 -- GitLab