Adding players is now working
This commit is contained in:
parent
afe4985bcc
commit
c75098f8ce
7
game.py
7
game.py
|
@ -28,9 +28,14 @@ class SeopardyGame(QtGui.QWidget):
|
|||
if self.gamestate.get_state() == "start":
|
||||
QtCore.QCoreApplication.postEvent(self, GameStartEvent())
|
||||
|
||||
def add_player(self):
|
||||
def add_player(self, addToGui=False):
|
||||
self.players.append(Player.gen_player(len(self.players)+1, self))
|
||||
|
||||
if addToGui:
|
||||
if len(self.players) > 1:
|
||||
self.playerBar.addStretch()
|
||||
self.playerBar.addWidget(self.players[-1])
|
||||
|
||||
def _createGui(self):
|
||||
""" Create the board from questions. """
|
||||
|
||||
|
|
13
windows.py
13
windows.py
|
@ -348,12 +348,17 @@ class PlayerStartWindow(QtGui.QDialog):
|
|||
|
||||
def event(self, e):
|
||||
if e.type() == ButtonEvent.eventType:
|
||||
if e.get_playerno() <= len(self.players)+1:
|
||||
if e.get_playerno() == len(self.players)+1:
|
||||
if e.get_playerno() <= len(self._players)+1:
|
||||
if e.get_playerno() == len(self._players)+1:
|
||||
# add a new player
|
||||
self._parent.add_player()
|
||||
self._parent.add_player(addToGui=True)
|
||||
self._guiAddPlayer(self._players[-1])
|
||||
self.playergrid.itemAtPosition(e.get_playerno()-1, 1).selectAll()
|
||||
|
||||
layoutItem = self.playerGrid.itemAtPosition(e.get_playerno(), 1)
|
||||
if layoutItem:
|
||||
widget = layoutItem.widget()
|
||||
widget.selectAll()
|
||||
widget.setFocus()
|
||||
return True
|
||||
else:
|
||||
return super(PlayerStartWindow, self).event(e)
|
||||
|
|
Loading…
Reference in New Issue