Tidy up
parent
e9be3dca6d
commit
3aedc13608
|
@ -26,9 +26,6 @@ class SudokuSystem:
|
|||
row.append([])
|
||||
self.offending_cells.append(row)
|
||||
|
||||
if TESTING:
|
||||
self.generate_test_board()
|
||||
|
||||
def clear_grid(self):
|
||||
self.number_grid[:] = 0
|
||||
self.cell_status[:] = FIXED
|
||||
|
|
|
@ -109,7 +109,6 @@ class GameBoard(BoxBoard):
|
|||
self.show_playmenu(False)
|
||||
|
||||
self.gamegrid.buttonClicked.connect(self.show_number_ring)
|
||||
#self.numring.connect_button_signals(self.select_ring_number)
|
||||
self.numring.keyPressed.connect(self.select_ring_number)
|
||||
|
||||
self.gamegrid.setFocus(Qt.MouseFocusReason)
|
||||
|
@ -152,7 +151,6 @@ class GameBoard(BoxBoard):
|
|||
self.playmenu.setVisible(state)
|
||||
|
||||
def new_game(self, string):
|
||||
print('new game selected')
|
||||
self.gamegrid.generate_new_grid(menu_grap.DIFFICULTIES.index(string))
|
||||
self.show_grid(True)
|
||||
self.newGameSelected.emit(string)
|
||||
|
@ -160,8 +158,8 @@ class GameBoard(BoxBoard):
|
|||
def paint(self, painter, style, widget=None):
|
||||
super().paint(painter, style, widget)
|
||||
|
||||
painter.drawText(QRectF(0, self.height+15,self.width,15), Qt.AlignCenter,
|
||||
"Hold M to mark numbers in a cell")
|
||||
painter.drawText(QRectF(0, self.height+15, self.width, 15), Qt.AlignCenter,
|
||||
"Hold M to scribble down numbers in a cell")
|
||||
|
||||
|
||||
class MenuBoard(BoxBoard):
|
||||
|
|
|
@ -5,7 +5,7 @@ This module contains the components that make up the Sudoku Board
|
|||
import numpy as np
|
||||
from PyQt5.QtCore import (QAbstractAnimation, QPointF, Qt, QRectF, QLineF,
|
||||
QPropertyAnimation, pyqtProperty, pyqtSignal)
|
||||
from PyQt5.QtGui import QPen, QFont, QKeyEvent
|
||||
from PyQt5.QtGui import QPen, QFont
|
||||
from PyQt5.QtWidgets import QGraphicsItem, QGraphicsObject
|
||||
|
||||
from gameplay import sudoku_gameplay as sdk
|
||||
|
@ -13,6 +13,8 @@ from general.extras import bound_value
|
|||
from . import buttons
|
||||
from . import menu_graphics as menu_grap
|
||||
|
||||
SCRIBBLE_KEY = Qt.Key_M
|
||||
|
||||
|
||||
class BaseSudokuItem(QGraphicsObject):
|
||||
|
||||
|
@ -84,7 +86,6 @@ class NumberPainter(BaseSudokuItem):
|
|||
|
||||
|
||||
class SudokuGrid(BaseSudokuItem):
|
||||
# TODO: Add functions to animated the grid lines
|
||||
buttonClicked = pyqtSignal(float, float, bool)
|
||||
finishDrawing = pyqtSignal()
|
||||
puzzleFinished = pyqtSignal()
|
||||
|
@ -231,12 +232,12 @@ class SudokuGrid(BaseSudokuItem):
|
|||
|
||||
def keyPressEvent(self, event):
|
||||
if not event.isAutoRepeat():
|
||||
if (event.key() == Qt.Key_M) and not self.scribbling:
|
||||
if (event.key() == SCRIBBLE_KEY) and not self.scribbling:
|
||||
self.scribbling = True
|
||||
|
||||
def keyReleaseEvent(self, event):
|
||||
if not event.isAutoRepeat():
|
||||
if event.key() == Qt.Key_M and self.scribbling:
|
||||
if event.key() == SCRIBBLE_KEY and self.scribbling:
|
||||
self.scribbling = False
|
||||
|
||||
# Defining the length to be drawn as a pyqtProperty
|
||||
|
@ -265,8 +266,6 @@ class SudokuGrid(BaseSudokuItem):
|
|||
|
||||
|
||||
class NumberRing(BaseSudokuItem):
|
||||
# TODO: Add functions to animated the ring appearing
|
||||
# TODO: Adjust the positioning of each element
|
||||
# TODO: Make it transparent when mouse is out of range
|
||||
loseFocus = pyqtSignal()
|
||||
keyPressed = pyqtSignal(str, bool)
|
||||
|
@ -287,7 +286,6 @@ class NumberRing(BaseSudokuItem):
|
|||
btn = buttons.AnimBox(0, 0, self.cell_width,
|
||||
self.cell_height, cell_string, parent=self)
|
||||
btn.buttonClicked.connect(self.send_button_press)
|
||||
#btn.buttonClicked.connect(self.close_menu)
|
||||
self.cell_buttons.append(btn)
|
||||
|
||||
self.radius = 54
|
||||
|
@ -357,9 +355,7 @@ class NumberRing(BaseSudokuItem):
|
|||
|
||||
def keyPressEvent(self, event):
|
||||
if not event.isAutoRepeat():
|
||||
print('Pressed:', event.key())
|
||||
if (event.key() == Qt.Key_M) and not self.scribbling:
|
||||
print('Scribbling On')
|
||||
if (event.key() == SCRIBBLE_KEY) and not self.scribbling:
|
||||
self.scribbling = True
|
||||
if event.key() == 88:
|
||||
txt = 'X'
|
||||
|
@ -369,16 +365,13 @@ class NumberRing(BaseSudokuItem):
|
|||
txt = ''
|
||||
|
||||
if txt:
|
||||
print('keypress:', txt)
|
||||
self.keyPressed.emit(txt, self.scribbling)
|
||||
if not self.scribbling:
|
||||
self.clearFocus()
|
||||
|
||||
def keyReleaseEvent(self, event):
|
||||
if not event.isAutoRepeat():
|
||||
print('Released:', event.key())
|
||||
if event.key() == Qt.Key_M and self.scribbling:
|
||||
print('Scribbling Off')
|
||||
if event.key() == SCRIBBLE_KEY and self.scribbling:
|
||||
self.scribbling = False
|
||||
|
||||
# Defining the length to be drawn as a pyqtProperty
|
||||
|
@ -415,7 +408,9 @@ class PlayMenu(BaseSudokuItem):
|
|||
self.diff_select.menuClicked.connect(self.difficulty_selected)
|
||||
|
||||
def paint(self, painter, style, widget=None):
|
||||
pass
|
||||
painter.setPen(self.default_pen)
|
||||
painter.setFont(self.default_font)
|
||||
painter.drawText(self.rect, Qt.AlignHCenter, 'Select A Difficulty')
|
||||
|
||||
def boundingRect(self):
|
||||
return self.diff_select.boundingRect()
|
||||
|
|
Loading…
Reference in New Issue