|
|
@ -367,9 +367,15 @@ class VictoryWindow(QtGui.QDialog):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DoubleJeopardyWindow(QtGui.QDialog):
|
|
|
|
class DoubleJeopardyWindow(QtGui.QDialog):
|
|
|
|
def __init__(self, player, parent=None):
|
|
|
|
def __init__(self, player, points, current_player=None, current_points=None, parent=None):
|
|
|
|
super(QuestionAnswerWindow, self).__init__(parent)
|
|
|
|
super(DoubleJeopardyWindow, self).__init__(parent)
|
|
|
|
self.player = player
|
|
|
|
self._player = player
|
|
|
|
|
|
|
|
self._currentPlayer = current_player
|
|
|
|
|
|
|
|
self._points = points
|
|
|
|
|
|
|
|
if current_points:
|
|
|
|
|
|
|
|
self._currentPoints = current_points
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self._currentPoints = points
|
|
|
|
|
|
|
|
|
|
|
|
self._setupGui()
|
|
|
|
self._setupGui()
|
|
|
|
|
|
|
|
|
|
|
@ -379,29 +385,72 @@ class DoubleJeopardyWindow(QtGui.QDialog):
|
|
|
|
cPos = self.rect()
|
|
|
|
cPos = self.rect()
|
|
|
|
self.move(g.width() - cPos.width(), g.height() - cPos.height())
|
|
|
|
self.move(g.width() - cPos.width(), g.height() - cPos.height())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_chosen_points(self):
|
|
|
|
|
|
|
|
return self._currentPoints
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_player(self):
|
|
|
|
|
|
|
|
return self._currentPlayer
|
|
|
|
|
|
|
|
|
|
|
|
def _setupGui(self):
|
|
|
|
def _setupGui(self):
|
|
|
|
self.layout = QtGui.QVBoxLayout()
|
|
|
|
self.layout = QtGui.QVBoxLayout()
|
|
|
|
|
|
|
|
|
|
|
|
header = QtGui.QLabel("Double Jeopardy", self)
|
|
|
|
header = QtGui.QLabel("Double Jeopardy", self)
|
|
|
|
|
|
|
|
header.setStyleSheet("QLabel { font-size: 50px; }")
|
|
|
|
self.layout.addWidget(header, alignment=QtCore.Qt.AlignCenter)
|
|
|
|
self.layout.addWidget(header, alignment=QtCore.Qt.AlignCenter)
|
|
|
|
|
|
|
|
|
|
|
|
self.pbtn = QtGui.QPushButton(self.player.name)
|
|
|
|
self.pbtn = QtGui.QPushButton("", self)
|
|
|
|
self.plabel.setStyleSheet("QLabel { font-size: 60px; }")
|
|
|
|
self._stylePlayerButton()
|
|
|
|
self.layout.addWidget(self.plabel, alignment=QtCore.Qt.AlignCenter)
|
|
|
|
self.pbtn.installEventFilter(KeyGrabber((QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Right), self))
|
|
|
|
|
|
|
|
self.layout.addWidget(self.pbtn)
|
|
|
|
|
|
|
|
|
|
|
|
btnbox = QtGui.QHBoxLayout()
|
|
|
|
self.pointsbtn = QtGui.QPushButton("% 5s" % self._currentPoints)
|
|
|
|
right = QtGui.QPushButton("Correct")
|
|
|
|
self.pointsbtn.setStyleSheet("QPushButton { font-size: 50px; border: none; }")
|
|
|
|
right.clicked.connect(lambda: self.done(self.CORRECT))
|
|
|
|
self.pointsbtn.installEventFilter(KeyGrabber((QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Right), self))
|
|
|
|
btnbox.addWidget(right)
|
|
|
|
self.layout.addWidget(self.pointsbtn, alignment=QtCore.Qt.AlignCenter)
|
|
|
|
wrong = QtGui.QPushButton("Wrong")
|
|
|
|
self.pointsbtn.setFocus()
|
|
|
|
wrong.clicked.connect(lambda: self.done(self.WRONG))
|
|
|
|
|
|
|
|
btnbox.addWidget(wrong)
|
|
|
|
start = QtGui.QPushButton("Done", self)
|
|
|
|
btnbox.addStretch()
|
|
|
|
start.clicked.connect(self.close)
|
|
|
|
oops = QtGui.QPushButton("Oops")
|
|
|
|
self.layout.addWidget(start)
|
|
|
|
oops.clicked.connect(lambda: self.done(self.OOPS))
|
|
|
|
|
|
|
|
btnbox.addWidget(oops)
|
|
|
|
|
|
|
|
self.layout.addLayout(btnbox)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.setLayout(self.layout)
|
|
|
|
self.setLayout(self.layout)
|
|
|
|
|
|
|
|
|
|
|
|
def _
|
|
|
|
def keyPressEvent(self, e):
|
|
|
|
|
|
|
|
if e.key() == QtCore.Qt.Key_Escape or e.key() == QtCore.Qt.Key_Enter:
|
|
|
|
|
|
|
|
self.close()
|
|
|
|
|
|
|
|
elif e.key() == QtCore.Qt.Key_Left or e.key() == QtCore.Qt.Key_Right:
|
|
|
|
|
|
|
|
if self.focusWidget() == self.pbtn:
|
|
|
|
|
|
|
|
if e.key() == QtCore.Qt.Key_Right:
|
|
|
|
|
|
|
|
if self._currentPlayer == None:
|
|
|
|
|
|
|
|
self._currentPlayer = self._player[0]
|
|
|
|
|
|
|
|
elif self._currentPlayer == self._player[-1]:
|
|
|
|
|
|
|
|
self._currentPlayer = None
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self._currentPlayer = self._player[self._player.index(self._currentPlayer)+1]
|
|
|
|
|
|
|
|
elif e.key() == QtCore.Qt.Key_Left:
|
|
|
|
|
|
|
|
if self._currentPlayer == None:
|
|
|
|
|
|
|
|
self._currentPlayer = self._player[-1]
|
|
|
|
|
|
|
|
elif self._currentPlayer == self._player[0]:
|
|
|
|
|
|
|
|
self._currentPlayer = None
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self._currentPlayer = self._player[self._player.index(self._currentPlayer)-1]
|
|
|
|
|
|
|
|
self._stylePlayerButton()
|
|
|
|
|
|
|
|
elif self.focusWidget() == self.pointsbtn:
|
|
|
|
|
|
|
|
if e.key() == QtCore.Qt.Key_Right and self._currentPoints < self._points*2:
|
|
|
|
|
|
|
|
self._currentPoints += 50
|
|
|
|
|
|
|
|
elif e.key() == QtCore.Qt.Key_Left and self._currentPoints > self._points/2:
|
|
|
|
|
|
|
|
self._currentPoints += -50
|
|
|
|
|
|
|
|
self.pointsbtn.setText("% 4s" % self._currentPoints)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _stylePlayerButton(self):
|
|
|
|
|
|
|
|
player = None
|
|
|
|
|
|
|
|
color = None
|
|
|
|
|
|
|
|
if self._currentPlayer == None:
|
|
|
|
|
|
|
|
player = "nobody"
|
|
|
|
|
|
|
|
color = nobodyColor
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
player = self._currentPlayer.name
|
|
|
|
|
|
|
|
color = self._currentPlayer.color
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.pbtn.setText(player)
|
|
|
|
|
|
|
|
self.pbtn.setStyleSheet("QPushButton { background-color: %s; color: white; font-size: 50px; border: none; }" % (color.name(),))
|
|
|
|