Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
1 result

Target

Select target project
  • sdelplan/application-2048
1 result
Select Git revision
  • main
1 result
Show changes
Commits on Source (2)
......@@ -21,7 +21,7 @@ qt_add_qml_module(appapplicationQT2048
SOURCES gamemanager.h gamemanager.cpp
SOURCES gamemanager.h gamemanager.cpp
QML_FILES Main.qml
QML_FILES popupDialogue.qml
QML_FILES PopupDialogue.qml
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
......
......@@ -5,6 +5,8 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
id: gamePage
focus: true // Active le focus pour capter les événements clavier
Rectangle {
width: 400
height: 600
......@@ -34,7 +36,11 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
}
PopupDialogue{
id : popup
x : 100
y : 200
}
Text {
......@@ -142,7 +148,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
id: buttonMouseArea
anchors.fill: parent
onClicked: gameManager.restartGame()
onClicked: popup.open()
}
}
......
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick
import QtQuick.Controls
ApplicationWindow {
visible: true
......
import QtQuick
import QtQuick.Controls
Popup {
id: partieNameDialogue
width: 250
height: 150
modal: true
closePolicy: Popup.CloseOnEscape
onOpened: textInput.text = ""
Column {
spacing: 10
width: parent.width
padding: 10
Label {
text: "Pour enregistrer la partie précédente, entrez un nom pour la partie.\nSi vous ne souhaitez pas enregistrer, appuyez sur Annuler."
wrapMode: Text.Wrap
width: parent.width
}
TextField {
id: textInput
width: parent.width
placeholderText: "Ex: Partie 1"
}
Row {
spacing: 10
width: parent.width
Button {
text: "OK"
onClicked: {
gameManager.restartGame(textInput.text);
partieNameDialogue.close();
}
}
Button {
text: "Annuler"
onClicked: {
gameManager.restartGame("false");
partieNameDialogue.close();
}
}
}
}
}
#include "gamemanager.h"
#include "random"
#include <QFileInfo>
#include <QDebug>
GameManager::GameManager(QObject *parent) : QObject(parent), grid(4, std::vector<int>(4, 0)),m_score(0), m_gameOver(false) {
......@@ -203,12 +202,19 @@ void GameManager::moveDown() {
}
void GameManager::restartGame() {
void GameManager::restartGame(QString partieName) {
//demander pour sauvergarder la partie précédente
<<<<<<< HEAD
if(partieName=="false"){
}else{
enregistrerPartie(partieName);
};
=======
enregistrerPartie("partie1");
m_gameOver = false;
>>>>>>> e22daca7a3c09bd0a515d12093b0cbf7e3e4e152
// Réinitialisation des variables
......@@ -408,6 +414,10 @@ 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;
......@@ -438,3 +448,4 @@ bool GameManager::isGameOver() {
}
return true; // Si la grille est pleine et aucune fusion n'est possible, la partie est terminée
}
>>>>>>> e22daca7a3c09bd0a515d12093b0cbf7e3e4e152
......@@ -24,7 +24,7 @@ public:
Q_INVOKABLE void moveRight();
Q_INVOKABLE void moveUp();
Q_INVOKABLE void moveDown();
Q_INVOKABLE void restartGame();
Q_INVOKABLE void restartGame(QString partieName);
Q_INVOKABLE void undo();
Q_INVOKABLE void chargerPartie(QString partieName);
bool isGameOver();
......
import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs
Dialog {
id: partieNameDialogue
title: "Pour enregistrer la partie précédente entrez un nom pour la partie. Si vous ne souhaitez pas enregistrer cette partie appuyer sur Cancel."
modal: true
standardButtons: Dialog.Ok | Dialog.Cancel
Column {
spacing: 10
width: parent.width
TextField {
id: textInput
width: parent.width
placeholderText: "Ex: Partie 1"
}
}
onAccepted: {
gameManager.recupererNomPartie(textInput.text);
}
}