Added victory window
This commit is contained in:
parent
2032b8eb1a
commit
113a0b6c4a
10
game.py
10
game.py
|
@ -3,7 +3,7 @@ from __future__ import print_function
|
||||||
from PySide import QtCore, QtGui
|
from PySide import QtCore, QtGui
|
||||||
|
|
||||||
from player import Player
|
from player import Player
|
||||||
from windows import QuestionWindow, EditAnswersWindow, PlayerStartWindow
|
from windows import QuestionWindow, EditAnswersWindow, PlayerStartWindow, VictoryWindow
|
||||||
from gamestate import QuestionAnswers
|
from gamestate import QuestionAnswers
|
||||||
|
|
||||||
class SeopardyGame(QtGui.QWidget):
|
class SeopardyGame(QtGui.QWidget):
|
||||||
|
@ -93,6 +93,8 @@ class SeopardyGame(QtGui.QWidget):
|
||||||
self._inOtherWindow = True
|
self._inOtherWindow = True
|
||||||
x.exec_()
|
x.exec_()
|
||||||
self._inOtherWindow = False
|
self._inOtherWindow = False
|
||||||
|
elif e.key() == QtCore.Qt.Key_V:
|
||||||
|
self.show_victory_window()
|
||||||
elif e.key() == QtCore.Qt.Key_E:
|
elif e.key() == QtCore.Qt.Key_E:
|
||||||
if self._inOtherWindow:
|
if self._inOtherWindow:
|
||||||
return
|
return
|
||||||
|
@ -134,6 +136,12 @@ class SeopardyGame(QtGui.QWidget):
|
||||||
self.gamestate.set_answers(section, number, newAnswers)
|
self.gamestate.set_answers(section, number, newAnswers)
|
||||||
self._restyle_button(section, number, newAnswers)
|
self._restyle_button(section, number, newAnswers)
|
||||||
|
|
||||||
|
def show_victory_window(self):
|
||||||
|
self._inOtherWindow = True
|
||||||
|
victoryWindow = VictoryWindow(self.players, self)
|
||||||
|
victoryWindow.exec_()
|
||||||
|
self._inOtherWindow = False
|
||||||
|
|
||||||
def go_to_question(self, section, number):
|
def go_to_question(self, section, number):
|
||||||
if self._inOtherWindow:
|
if self._inOtherWindow:
|
||||||
return
|
return
|
||||||
|
|
26
windows.py
26
windows.py
|
@ -338,3 +338,29 @@ class PlayerStartWindow(QtGui.QDialog):
|
||||||
self.playerGrid.addWidget(edit, row, 1)
|
self.playerGrid.addWidget(edit, row, 1)
|
||||||
|
|
||||||
|
|
||||||
|
class VictoryWindow(QtGui.QDialog):
|
||||||
|
def __init__(self, players, parent):
|
||||||
|
super(VictoryWindow, self).__init__(parent)
|
||||||
|
self._players = players
|
||||||
|
self._parent = parent
|
||||||
|
|
||||||
|
self._setupGui()
|
||||||
|
|
||||||
|
def _setupGui(self):
|
||||||
|
self.layout = QtGui.QVBoxLayout()
|
||||||
|
self.playerGrid = QtGui.QGridLayout()
|
||||||
|
|
||||||
|
winPlayers = sorted(self._players, key=lambda p: p.points, reverse=True)
|
||||||
|
for i, player in enumerate(winPlayers):
|
||||||
|
label = QtGui.QLabel(player.name, self)
|
||||||
|
fsize = 60 if i == 0 else 25
|
||||||
|
label.setStyleSheet("QLabel { font-size: %dpx; background-color: %s; color: white; }" % (fsize, player.color.name(),))
|
||||||
|
self.playerGrid.addWidget(label, i, 0)
|
||||||
|
|
||||||
|
points = QtGui.QLabel(str(player.points), self)
|
||||||
|
points.setStyleSheet("QLabel { font-size: %dpx; }" % (fsize,))
|
||||||
|
self.playerGrid.addWidget(points, i, 1, alignment=QtCore.Qt.AlignRight)
|
||||||
|
|
||||||
|
self.layout.addLayout(self.playerGrid)
|
||||||
|
|
||||||
|
self.setLayout(self.layout)
|
||||||
|
|
Loading…
Reference in New Issue