DJ display + DJ editing
This commit is contained in:
parent
64bee1c240
commit
036edcc1cd
6
game.py
6
game.py
|
@ -210,13 +210,17 @@ class SeopardyGame(QtGui.QWidget):
|
||||||
tries = answers.get_tries()
|
tries = answers.get_tries()
|
||||||
if len(tries) > numTries:
|
if len(tries) > numTries:
|
||||||
btnstr = "...\n"
|
btnstr = "...\n"
|
||||||
|
|
||||||
|
first = True
|
||||||
for player, correct in answers.get_tries()[-numTries:]:
|
for player, correct in answers.get_tries()[-numTries:]:
|
||||||
if correct:
|
if correct:
|
||||||
btncolor = player.color
|
btncolor = player.color
|
||||||
prefix = "+"
|
prefix = "+"
|
||||||
else:
|
else:
|
||||||
prefix = "-"
|
prefix = "-"
|
||||||
btnstr += "%s%s\n" % (prefix, player.name)
|
dj = " (D)" if first and answers.get_dj_points() is not None else ""
|
||||||
|
btnstr += "%s%s%s\n" % (prefix, player.name, dj)
|
||||||
|
first = False
|
||||||
|
|
||||||
if not answers.got_answered():
|
if not answers.got_answered():
|
||||||
btnstr += "+nobody"
|
btnstr += "+nobody"
|
||||||
|
|
25
windows.py
25
windows.py
|
@ -135,6 +135,8 @@ class EditAnswersWindow(QtGui.QDialog):
|
||||||
self._players = players
|
self._players = players
|
||||||
self._answers = answers
|
self._answers = answers
|
||||||
self._nobody = not answers.got_answered()
|
self._nobody = not answers.got_answered()
|
||||||
|
self._dj_points = answers.get_dj_points()
|
||||||
|
self._in_window = False
|
||||||
if self._answers:
|
if self._answers:
|
||||||
self._tries = copy.copy(self._answers.get_tries())
|
self._tries = copy.copy(self._answers.get_tries())
|
||||||
else:
|
else:
|
||||||
|
@ -145,7 +147,8 @@ class EditAnswersWindow(QtGui.QDialog):
|
||||||
self.installEventFilter(KeyGrabber((QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Right), self))
|
self.installEventFilter(KeyGrabber((QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Right), self))
|
||||||
|
|
||||||
def get_new_answers(self):
|
def get_new_answers(self):
|
||||||
qa = QuestionAnswers(self._answers.section, self._answers.qnumber)
|
qa = QuestionAnswers(self._answers.section, self._answers.qnumber, dj_points=self._dj_points)
|
||||||
|
|
||||||
rightPlayer = None
|
rightPlayer = None
|
||||||
for player, correct in self._tries:
|
for player, correct in self._tries:
|
||||||
if correct:
|
if correct:
|
||||||
|
@ -171,7 +174,7 @@ class EditAnswersWindow(QtGui.QDialog):
|
||||||
self._resetAllButtons()
|
self._resetAllButtons()
|
||||||
self.layout.addLayout(self.answerlayout)
|
self.layout.addLayout(self.answerlayout)
|
||||||
|
|
||||||
self.xlabel = QtGui.QLabel("+/- right/wrong, d delete, a add, arrows change player")
|
self.xlabel = QtGui.QLabel("+/- right/wrong, d delete, a add, arrows change player\ne edit double jeopardy")
|
||||||
self.xlabel.setStyleSheet("QLabel { font-size: 15px; }")
|
self.xlabel.setStyleSheet("QLabel { font-size: 15px; }")
|
||||||
self.layout.addWidget(self.xlabel)
|
self.layout.addWidget(self.xlabel)
|
||||||
|
|
||||||
|
@ -180,6 +183,15 @@ class EditAnswersWindow(QtGui.QDialog):
|
||||||
def keyPressEvent(self, e):
|
def keyPressEvent(self, e):
|
||||||
if e.key() == QtCore.Qt.Key_Escape:
|
if e.key() == QtCore.Qt.Key_Escape:
|
||||||
self.close()
|
self.close()
|
||||||
|
elif e.key() == QtCore.Qt.Key_E:
|
||||||
|
# edit double jeopardy
|
||||||
|
if self._dj_points is not None and len(self._tries) > 0 and not self._in_window:
|
||||||
|
self._in_window = True
|
||||||
|
dwin = DoubleJeopardyWindow(self._players, self._answers.qnumber*100, self._tries[0][0], current_points=self._dj_points, parent=self)
|
||||||
|
dwin.exec_()
|
||||||
|
self._dj_points = dwin.get_chosen_points()
|
||||||
|
self._tries[0] = (dwin.get_player(), self._tries[0][1])
|
||||||
|
self._in_window = False
|
||||||
else:
|
else:
|
||||||
currFocus = self._getCurrFocus()
|
currFocus = self._getCurrFocus()
|
||||||
if currFocus is None and e.key() != QtCore.Qt.Key_A:
|
if currFocus is None and e.key() != QtCore.Qt.Key_A:
|
||||||
|
@ -247,15 +259,18 @@ class EditAnswersWindow(QtGui.QDialog):
|
||||||
f = self.answerlayout.takeAt(0)
|
f = self.answerlayout.takeAt(0)
|
||||||
|
|
||||||
# add buttons
|
# add buttons
|
||||||
|
first = True
|
||||||
for player, correct in self._tries:
|
for player, correct in self._tries:
|
||||||
self._addAnswerButton(player, correct)
|
self._addAnswerButton(player, correct, first)
|
||||||
|
first = False
|
||||||
|
|
||||||
# add the nobody button
|
# add the nobody button
|
||||||
self._addAnswerButton(Player("nobody", nobodyColor), self._nobody)
|
self._addAnswerButton(Player("nobody", nobodyColor), self._nobody)
|
||||||
|
|
||||||
def _addAnswerButton(self, player, correct=False):
|
def _addAnswerButton(self, player, correct=False, first=False):
|
||||||
prefix = "+" if correct else "-"
|
prefix = "+" if correct else "-"
|
||||||
btn = QtGui.QPushButton("\n%s%s\n" % (prefix, player.name), self)
|
dj = " (D)" if first and self._dj_points is not None else ""
|
||||||
|
btn = QtGui.QPushButton("\n%s%s%s\n" % (prefix, player.name, dj), self)
|
||||||
btn.setStyleSheet("QPushButton { background-color: %s; color: white; font-size: 20px; border: none; }" % (player.color.name(),))
|
btn.setStyleSheet("QPushButton { background-color: %s; color: white; font-size: 20px; border: none; }" % (player.color.name(),))
|
||||||
btn.installEventFilter(KeyGrabber((QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Right), self))
|
btn.installEventFilter(KeyGrabber((QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Right), self))
|
||||||
self.answerlayout.addWidget(btn)
|
self.answerlayout.addWidget(btn)
|
||||||
|
|
Loading…
Reference in New Issue