Commit 3fd9abe2 authored by Aurelien Dufour's avatar Aurelien Dufour
Browse files

modification de la position des flèches sur le menuWidget + affichage du score...

modification de la position des flèches sur le menuWidget + affichage du score sur un jeu (à généraliser sur tous les jeux
parent 7a1c80a3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ class BinaryTreeToPlanarTree(LevelController):
        self.menuController.menu.displayLauncher(self.launcher)

    def launchLevel(self):
        print("yes")
        self.levelGui = BinaryTreeToPlanarTreeGui(self)
        self.levelGui.okButton.clicked.connect(self.nextLevel)
        self.levelGui.cancelButton.clicked.connect(self.sameLevel)
@@ -32,6 +31,7 @@ class BinaryTreeToPlanarTree(LevelController):
            if self.level.finished():
                self.levelGui.finish()
        else:
            self.level.error()
            self.levelGui.error(index, nodeType)


+1 −1
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ class BinaryNode(Node):
        :param node: the node we compare with
        :return: True if the nodes are the sames, False otherwise
        """
        if isinstance(node, EmptyNode) or isinstance(node, IncompleteBinaryNode):
        if isinstance(node, EmptyNode):
            return False
        elif isinstance(self, Leaf):
            if isinstance(node, Leaf):
+11 −3
Original line number Diff line number Diff line
@@ -13,13 +13,21 @@ class BinaryTreeToDyckWordGui(LevelGui):
        self.createDyckWordGroupBox()
        self.createButtons()
        self.createTreeView()
        self.createScoreLabel()

        self.layout = QHBoxLayout()
        self.layout.addWidget(self.treeView, 66)
        self.layout.addWidget(self.dyckWordGroupBox, 33)
        self.layout = QGridLayout()
        self.layout.addWidget(self.scoreLabel, 0, 1, alignment=Qt.AlignRight)
        self.layout.addWidget(self.treeView, 1, 0)
        self.layout.addWidget(self.dyckWordGroupBox, 1, 1)
        self.layout.setColumnStretch(0, 2)
        self.layout.setColumnStretch(1, 1)

        self.setLayout(self.layout)

    def createScoreLabel(self):
        self.scoreLabel = QLabel("Score : " + str(self.controller.level.score))
        self.scoreLabel.setFont(QFont("Arial", 20))

    def createDyckWordGroupBox(self):
        self.dyckWordGroupBox = QGroupBox()
        self.globalDyckWordLayout = QVBoxLayout()
+15 −7
Original line number Diff line number Diff line
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QWidget, QAction, QHBoxLayout, QMessageBox, QPushButton, QGroupBox, QVBoxLayout, QLabel, \
    QGraphicsScene
    QGraphicsScene, QGridLayout

from view.levelGui import LevelGui
from view.treeView import TreeView
@@ -12,26 +13,33 @@ class BinaryTreeToPlanarTreeGui(LevelGui):

        self.createPlanarTreeView()
        self.createTreeView()
        self.createScoreLabel()

        self.layout = QHBoxLayout()

        self.layout.addWidget(self.treeView, 50)
        self.layout.addWidget(self.planarTreeView, 50)
        self.layout = QGridLayout()
        self.layout.addWidget(self.scoreLabel, 0, 1, alignment=Qt.AlignRight)
        self.layout.addWidget(self.treeView, 1, 0)
        self.layout.addWidget(self.planarTreeView, 1, 1)

        self.setLayout(self.layout)

    def createScoreLabel(self):
        self.scoreLabel = QLabel("Score : " + str(self.controller.level.score))
        self.scoreLabel.setFont(QFont("Arial", 20))

    def changeScore(self):
        self.scoreLabel.setText("Score : " + str(self.controller.level.score))

    def createPlanarTreeView(self):
        self.planarTreeScene = QGraphicsScene()
        self.planarTreeView = TreeView(self.planarTreeScene, controller=self.controller, root=True)
        self.planarTreeView.drawTree()

    def error(self, index: int, nodeType: str):
        print(index)
        self.changeScore()
        if nodeType == "branch":
            indexList = 2 * index
        else:
            indexList = 2 * index + 1
        print(indexList)
        self.planarTreeView.buttons[indexList].error()

    def createTreeView(self):
+2 −2
Original line number Diff line number Diff line
@@ -19,11 +19,11 @@ class LevelGui(QWidget):
        self.msgBox.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint)
        self.okButton = QPushButton("Suivant")
        self.cancelButton = QPushButton("Rejouer")
        self.msgBox.setWindowTitle("Bien joué")
        self.msgBox.setText("Vous pouvez passer au niveau suivant")
        self.msgBox.setText("Bravo, vous pouvez passer au niveau suivant!")
        self.msgBox.addButton(self.cancelButton, QMessageBox.NoRole)
        self.msgBox.addButton(self.okButton, QMessageBox.YesRole)
        self.msgBox.setDefaultButton(self.okButton)

    def finish(self):
        self.msgBox.setWindowTitle(str(self.controller.level.score) + " points")
        self.msgBox.exec_()
Loading