Skip to content
Snippets Groups Projects
Commit f1ec09ec authored by Breitwiller Josephine's avatar Breitwiller Josephine
Browse files

reglage finales des derniers bug, manquemant

parent 52751559
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier ...@@ -46,6 +46,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
text: "Fusionnez les nombres pour atteindre 2048!" text: "Fusionnez les nombres pour atteindre 2048!"
font.bold: true font.bold: true
font.family: gameManager.police
color:"grey" color:"grey"
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
y:145 y:145
...@@ -61,6 +62,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier ...@@ -61,6 +62,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
Text { Text {
text:"2048" text:"2048"
font.family: gameManager.police
color: "white" color: "white"
font.bold: true font.bold: true
font.pixelSize: 30 font.pixelSize: 30
...@@ -78,6 +80,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier ...@@ -78,6 +80,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
Text{ Text{
text: "MEILLEUR" text: "MEILLEUR"
font.family: gameManager.police
color:"lightgrey" color:"lightgrey"
font.pixelSize: 14 font.pixelSize: 14
font.bold: true font.bold: true
...@@ -90,6 +93,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier ...@@ -90,6 +93,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
id: bestScore id: bestScore
text:gameManager.bestScore text:gameManager.bestScore
color:"white" color:"white"
font.family: gameManager.police
font.bold: true font.bold: true
font.pixelSize: 25 font.pixelSize: 25
anchors.centerIn:parent anchors.centerIn:parent
...@@ -109,6 +113,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier ...@@ -109,6 +113,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
Text{ Text{
text: "SCORE" text: "SCORE"
color:"lightgrey" color:"lightgrey"
font.family: gameManager.police
font.pixelSize: 14 font.pixelSize: 14
font.bold: true font.bold: true
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
...@@ -119,6 +124,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier ...@@ -119,6 +124,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
Text{ Text{
id: score id: score
text:gameManager.score text:gameManager.score
font.family: gameManager.police
color:"white" color:"white"
font.bold: true font.bold: true
font.pixelSize: 25 font.pixelSize: 25
...@@ -142,6 +148,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier ...@@ -142,6 +148,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
text: "NOUVEAU " text: "NOUVEAU "
color:"white" color:"white"
font.bold: true font.bold: true
font.family: gameManager.police
} }
MouseArea{ MouseArea{
...@@ -167,6 +174,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier ...@@ -167,6 +174,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
text: "ANNULER " text: "ANNULER "
color:"white" color:"white"
font.bold: true font.bold: true
font.family: gameManager.police
} }
MouseArea{ MouseArea{
...@@ -199,22 +207,24 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier ...@@ -199,22 +207,24 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
Rectangle { Rectangle {
width: 78 width: 78
height: 78 height: 78
color: modelData == 2 ? "#EEE4DA" : property var colors: gameManager.tileColorsMap
modelData == 4 ? "#EDE0C8" : color: modelData == 2 ? colors["2"] :
modelData == 8 ? "#F2B179" : modelData == 4 ? colors["4"] :
modelData == 16 ? "#F59563" : modelData == 8 ? colors["8"] :
modelData == 32 ? "#F67C5F" : modelData == 16 ? colors["16"] :
modelData == 64 ? "#F65E3B" : modelData == 32 ? colors["32"] :
modelData == 128 ? "#EDCF72" : modelData == 64 ? colors["64"] :
modelData == 256 ? "#EDCC61" : modelData == 128 ? colors["128"] :
modelData == 512 ? "#EDC850" : modelData == 256 ? colors["256"] :
modelData == 1024 ? "#EDC53F" : modelData == 512 ? colors["512"] :
modelData == 2048 ? "#EDC22E" : "#BBADA0" modelData == 1024 ? colors["1024"] :
modelData == 2048 ? colors["2048"] : colors["autre"]
radius: 5 radius: 5
Text { Text {
text: modelData > 0 ? modelData : "" text: modelData > 0 ? modelData : ""
anchors.centerIn: parent anchors.centerIn: parent
font.bold: true font.bold: true
font.family: gameManager.police
font.pixelSize: 30 font.pixelSize: 30
color: "grey" color: "grey"
} }
...@@ -236,6 +246,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier ...@@ -236,6 +246,7 @@ FocusScope { // Permet de capter le focus pour les raccourcis clavier
text: "MENU " text: "MENU "
color:"white" color:"white"
font.bold: true font.bold: true
font.family: gameManager.police
} }
MouseArea{ MouseArea{
......
...@@ -7,6 +7,10 @@ ApplicationWindow { ...@@ -7,6 +7,10 @@ ApplicationWindow {
height: 600 height: 600
title: qsTr("Application 2048") title: qsTr("Application 2048")
StackView { StackView {
id: stackView id: stackView
anchors.fill: parent anchors.fill: parent
......
...@@ -7,6 +7,7 @@ Rectangle { ...@@ -7,6 +7,7 @@ Rectangle {
color: "#FAF8EF" color: "#FAF8EF"
Text{ Text{
text: "Menu" text: "Menu"
font.family: gameManager.police
font.bold: true font.bold: true
color:"grey" color:"grey"
font.pixelSize: 40 font.pixelSize: 40
...@@ -16,6 +17,7 @@ Rectangle { ...@@ -16,6 +17,7 @@ Rectangle {
Text{ Text{
text: "Design du jeu" text: "Design du jeu"
font.family: gameManager.police
font.bold: true font.bold: true
color:"grey" color:"grey"
font.pixelSize: 25 font.pixelSize: 25
...@@ -35,9 +37,48 @@ Rectangle { ...@@ -35,9 +37,48 @@ Rectangle {
MenuItem { MenuItem {
text: "Arial" text: "Arial"
font.family:"Arial"
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.changePolice("Helvetica")
} }
MenuItem {
text: "Helvetica"
font.family:"Helvetica"
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.changePolice("Helvetica")
}
MenuItem {
text: "Times New Roman"
font.family: "Times New Roman"
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.changePolice("Times New Roman")
}
MenuItem {
text: "Georgia"
font.family: "Georgia"
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.changePolice("Georgia")
}
MenuItem {
text: "Calibri"
font.family: "Calibri"
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.changePolice("Calibri")
}
} }
} }
...@@ -49,63 +90,90 @@ Rectangle { ...@@ -49,63 +90,90 @@ Rectangle {
Menu{ Menu{
title:"couleurs du jeu" title:"couleurs du jeu"
} font.family: gameManager.police
} MenuItem {
text: "Normal (Orange)"
font.family: gameManager.police
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.changerCouleur("normal")
Text{
text: "Fonctionnalitées"
font.bold: true
color:"grey"
font.pixelSize: 25
anchors.horizontalCenter: parent.horizontalCenter
y:300
} }
MenuItem {
text: "Rouge/Rose"
font.family: gameManager.police
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.changerCouleur("rouge")
MenuBar { }
anchors.horizontalCenter: parent.horizontalCenter MenuItem {
y:350 text: "Vert"
background: Rectangle { color: "#BBADA0"; radius: 5 } font.family: gameManager.police
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.changerCouleur("vert")
Menu{ }
title:"mode de jeu"
MenuItem { MenuItem {
text: "Grille 4x4" text: "Bleu"
font.family: gameManager.police
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.modeDeJeu(1) onTriggered: gameManager.changerCouleur("bleu")
} }
MenuItem {
text: "Violet"
font.family: gameManager.police
background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.changerCouleur("violet")
}
MenuItem { MenuItem {
text: "Grille 8x8" text: "Noir et Blanc"
background: Rectangle { color: "grey"; radius: 5 } font.family: gameManager.police
onTriggered: gameManager.modeDeJeu(2) background: Rectangle { color: "grey"; radius: 5 } // Fond et coins arrondis
onTriggered: gameManager.changerCouleur("noirblanc")
}
} }
} }
Text{
text: "Fonctionnalitées"
font.family: gameManager.police
font.bold: true
color:"grey"
font.pixelSize: 25
anchors.horizontalCenter: parent.horizontalCenter
y:300
} }
Text{ Text{
text: "accès à l'historique des parties" text: "accès à l'historique des parties"
font.family: gameManager.police
color:"grey" color:"grey"
font.pixelSize: 20 font.pixelSize: 20
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
y:390 y:350
} }
MenuBar{ MenuBar{
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
y:450 y:410
background: Rectangle { color: "#BBADA0"; radius: 5 } background: Rectangle { color: "#BBADA0"; radius: 5 }
Menu { Menu {
title: "Charger une ancienne partie" title: "Charger une ancienne partie"
font.family: gameManager.police
Repeater { Repeater {
model: gameManager.partieHistorique model: gameManager.partieHistorique
MenuItem { MenuItem {
text: modelData text: modelData
font.family: gameManager.police
background: Rectangle { color: "grey"; radius: 5 } background: Rectangle { color: "grey"; radius: 5 }
onTriggered: gameManager.chargerPartie(modelData) onTriggered: gameManager.chargerPartie(modelData)
} }
...@@ -119,12 +187,13 @@ Rectangle { ...@@ -119,12 +187,13 @@ Rectangle {
color:"#BBADA0" color:"#BBADA0"
width: 150; height: 30 width: 150; height: 30
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
y:510 y:470
radius:5 radius:5
Text{ Text{
anchors.centerIn: parent anchors.centerIn: parent
text: "Supprimer l'historique" text: "Supprimer l'historique"
font.family: gameManager.police
color:"black" color:"black"
} }
...@@ -140,12 +209,13 @@ Rectangle { ...@@ -140,12 +209,13 @@ Rectangle {
color:"blue" color:"blue"
width: 90; height: 30 width: 90; height: 30
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
y:560 y:550
radius:5 radius:5
Text{ Text{
anchors.centerIn: parent anchors.centerIn: parent
text: "Retour " text: "Retour "
font.family: gameManager.police
color:"white" color:"white"
font.bold: true font.bold: true
} }
......
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts
Popup { Popup {
id: partieNameDialogue id: partieNameDialogue
width: 250 width: 300
height: 150 height: 180
x: (400 - 300) / 2
y: (600 - 180) / 2
modal: true modal: true
focus: true
closePolicy: Popup.CloseOnEscape closePolicy: Popup.CloseOnEscape
onOpened: textInput.text = "" onOpened: textInput.text = ""
background: Rectangle {
color: "#FAF8EF"
radius: 16
border.color: "#BBADA0"
border.width: 2
}
Column { ColumnLayout {
spacing: 10 spacing: 12
width: parent.width anchors.fill: parent
padding: 10 anchors.margins: 16
Label { Label {
text: "Pour enregistrer la partie précédente, entrez un nom pour la partie.\nSi vous ne souhaitez pas enregistrer, appuyez sur Annuler." text: "Pour enregistrer la partie précédente,\nentrez un nom pour la partie. \nSi vous ne souhaitez pas enregistrer la pertie \nappuyez sur annuler."
font.family: gameManager.police
wrapMode: Text.Wrap wrapMode: Text.Wrap
width: parent.width font.pixelSize: 14
color: "#776E65"
Layout.fillWidth: true
} }
TextField { TextField {
id: textInput id: textInput
width: parent.width
placeholderText: "Ex: Partie 1" placeholderText: "Ex: Partie 1"
font.family: gameManager.police
font.pixelSize: 14
color: "#776E65"
background: Rectangle {
radius: 8
color: "white"
border.color: "#CCC0B3"
border.width: 1
}
Layout.fillWidth: true
} }
Row { RowLayout {
spacing: 10 spacing: 12
width: parent.width Layout.alignment: Qt.AlignRight
Button { Button {
text: "OK" text: "Annuler"
font.family: gameManager.police
font.pixelSize: 14
background: Rectangle {
radius: 8
color: "#EEE4DA"
}
onClicked: { onClicked: {
gameManager.restartGame(textInput.text); gameManager.restartGame("false");
partieNameDialogue.close(); partieNameDialogue.close();
} }
} }
Button { Button {
text: "Annuler" text: "OK"
font.pixelSize: 14
background: Rectangle {
radius: 8
color: "#8F7A66"
}
contentItem: Text {
text: qsTr("OK")
font.family: gameManager.police
color: "white"
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { onClicked: {
gameManager.restartGame("false"); gameManager.restartGame(textInput.text);
partieNameDialogue.close(); partieNameDialogue.close();
} }
} }
} }
} }
} }
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
GameManager::GameManager(QObject *parent) : QObject(parent), grid(4, std::vector<int>(4, 0)),m_score(0), m_gameOver(false) { GameManager::GameManager(QObject *parent) : QObject(parent), grid(4, std::vector<int>(4, 0)),m_score(0), m_gameOver(false) {
chercherBestScore(); chercherBestScore();
emit colorsChanged();
restartGame("false"); // intialisation d'une partie au démarrage
} }
void GameManager::moveLeft() { void GameManager::moveLeft() {
...@@ -556,4 +558,105 @@ void GameManager::endGame() { ...@@ -556,4 +558,105 @@ void GameManager::endGame() {
} }
//Gestion des couleurs
void GameManager::changerCouleur(QString couleur){
color = couleur;
emit colorsChanged();
}
QVariantMap GameManager::getTileColorsMap() {
QVariantMap colorMap;
if (color == "bleu") {
colorMap["2"] = "#E0F7FA";
colorMap["4"] = "#B2EBF2";
colorMap["8"] = "#81D4FA";
colorMap["16"] = "#4FC3F7";
colorMap["32"] = "#29B6F6";
colorMap["64"] = "#03A9F4";
colorMap["128"] = "#039BE5";
colorMap["256"] = "#0288D1";
colorMap["512"] = "#0277BD";
colorMap["1024"] = "#01579B";
colorMap["2048"] = "#003F72";
colorMap["autre"] = "#BBADA0";
} else if (color == "vert") {
colorMap["2"] = "#E8F5E9";
colorMap["4"] = "#C8E6C9";
colorMap["8"] = "#A5D6A7";
colorMap["16"] = "#81C784";
colorMap["32"] = "#66BB6A";
colorMap["64"] = "#4CAF50";
colorMap["128"] = "#43A047";
colorMap["256"] = "#388E3C";
colorMap["512"] = "#2E7D32";
colorMap["1024"] = "#1B5E20";
colorMap["2048"] = "#103914";
colorMap["autre"] = "#BBADA0";
} else if (color == "rouge") {
colorMap["2"] = "#FFEBEE";
colorMap["4"] = "#FFCDD2";
colorMap["8"] = "#EF9A9A";
colorMap["16"] = "#E57373";
colorMap["32"] = "#EF5350";
colorMap["64"] = "#F44336";
colorMap["128"] = "#E53935";
colorMap["256"] = "#D32F2F";
colorMap["512"] = "#C62828";
colorMap["1024"] = "#B71C1C";
colorMap["2048"] = "#8E1313";
colorMap["autre"] = "#BBADA0";
} else if (color == "violet") {
colorMap["2"] = "#F3E5F5";
colorMap["4"] = "#E1BEE7";
colorMap["8"] = "#CE93D8";
colorMap["16"] = "#BA68C8";
colorMap["32"] = "#AB47BC";
colorMap["64"] = "#9C27B0";
colorMap["128"] = "#8E24AA";
colorMap["256"] = "#7B1FA2";
colorMap["512"] = "#6A1B9A";
colorMap["1024"] = "#4A148C";
colorMap["2048"] = "#320963";
colorMap["autre"] = "#BBADA0";
} else if (color == "noirblanc") {
colorMap["2"] = "#FFFFFF";
colorMap["4"] = "#F0F0F0";
colorMap["8"] = "#D9D9D9";
colorMap["16"] = "#BFBFBF";
colorMap["32"] = "#A6A6A6";
colorMap["64"] = "#8C8C8C";
colorMap["128"] = "#737373";
colorMap["256"] = "#595959";
colorMap["512"] = "#404040";
colorMap["1024"] = "#262626";
colorMap["2048"] = "#0D0D0D";
colorMap["autre"] = "#BBADA0";
} else { // thème "normal" ou inconnu
colorMap["2"] = "#EEE4DA";
colorMap["4"] = "#EDE0C8";
colorMap["8"] = "#F2B179";
colorMap["16"] = "#F59563";
colorMap["32"] = "#F67C5F";
colorMap["64"] = "#F65E3B";
colorMap["128"] = "#EDCF72";
colorMap["256"] = "#EDCC61";
colorMap["512"] = "#EDC850";
colorMap["1024"] = "#EDC53F";
colorMap["2048"] = "#EDC22E";
colorMap["autre"] = "#BBADA0";
}
return colorMap;
}
// Changement de police
QString GameManager::getPolice(){
return police;
}
void GameManager::changePolice(QString font){
police = font;
emit policeChanged();
}
...@@ -18,7 +18,8 @@ class GameManager : public QObject ...@@ -18,7 +18,8 @@ class GameManager : public QObject
Q_PROPERTY(QStringList partieHistorique READ getPartieHistorique NOTIFY historiqueChanged) Q_PROPERTY(QStringList partieHistorique READ getPartieHistorique NOTIFY historiqueChanged)
Q_PROPERTY(int score READ getScore NOTIFY scoreChanged) Q_PROPERTY(int score READ getScore NOTIFY scoreChanged)
Q_PROPERTY(int bestScore READ getBestScore NOTIFY bestScoreChanged) Q_PROPERTY(int bestScore READ getBestScore NOTIFY bestScoreChanged)
Q_PROPERTY(QVariantMap tileColorsMap READ getTileColorsMap NOTIFY colorsChanged)
Q_PROPERTY(QString police READ getPolice NOTIFY policeChanged)
public: public:
explicit GameManager(QObject *parent = nullptr); explicit GameManager(QObject *parent = nullptr);
Q_INVOKABLE void moveLeft(); Q_INVOKABLE void moveLeft();
...@@ -29,6 +30,9 @@ public: ...@@ -29,6 +30,9 @@ public:
Q_INVOKABLE void undo(); Q_INVOKABLE void undo();
Q_INVOKABLE void chargerPartie(QString partieName); Q_INVOKABLE void chargerPartie(QString partieName);
Q_INVOKABLE void supprimerHistorique(); Q_INVOKABLE void supprimerHistorique();
Q_INVOKABLE void changerCouleur(QString couleur);
Q_INVOKABLE void changePolice(QString font);
QVariantMap getTileColorsMap();
bool isGameOver(); bool isGameOver();
QVector<int> getGridValues() const; QVector<int> getGridValues() const;
...@@ -40,10 +44,8 @@ private: ...@@ -40,10 +44,8 @@ private:
QJsonArray historyArray; QJsonArray historyArray;
int m_score; int m_score;
int m_bestScore; int m_bestScore;
QString color = "normal" ;
QMap<int, QColor> tileColors; // Dictionnaire des couleurs (couleurs sélécctionées initaliser a normal) QString police = "Arial";
Q_INVOKABLE void initializeTileColors(); // Initialisation des QMap pour les différents jeux de couleurs et intialisation aux couleur normal
Q_INVOKABLE void addRandomElement(); Q_INVOKABLE void addRandomElement();
...@@ -54,6 +56,7 @@ private: ...@@ -54,6 +56,7 @@ private:
Q_INVOKABLE int getScore() ; Q_INVOKABLE int getScore() ;
Q_INVOKABLE int getBestScore() ; Q_INVOKABLE int getBestScore() ;
Q_INVOKABLE void chercherBestScore() ; Q_INVOKABLE void chercherBestScore() ;
Q_INVOKABLE QString getPolice();
QJsonArray gridToJsonArray(); QJsonArray gridToJsonArray();
...@@ -67,6 +70,8 @@ signals: ...@@ -67,6 +70,8 @@ signals:
void historiqueChanged(); void historiqueChanged();
void scoreChanged(); void scoreChanged();
void bestScoreChanged(); void bestScoreChanged();
void colorsChanged();
void policeChanged();
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment