Example #1
0
    def __init__(self, game, gameView):
        super(GameWindow, self).__init__()

        stretchA = (1000 - 618) * (1000 - 618)
        stretchB = 1000000 - stretchA

        layout = QGridLayout(self)
        layout.setColumnStretch(0, stretchB)
        layout.setColumnStretch(1, stretchA)

        leftLayout = QGridLayout()
        leftLayout.setRowStretch(0, stretchB)
        leftLayout.setRowStretch(1, stretchA)
        rightLayout = QGridLayout()
        rightLayout.setRowStretch(0, stretchA)
        rightLayout.setRowStretch(1, stretchB)
        layout.addLayout(leftLayout, 0, 0)
        layout.addLayout(rightLayout, 0, 1)

        self.game = game
        self.game.playersUpdated.connect(self._onPlayersUpdated)

        gameView.player = game.connectionManager.player
        gameView.attackInitiated.connect(self.game._onAttackInitiated)

        self.gameView = GameViewWrapper(gameView)
        self.eventBox = EventBox()
        self.countryBox = CountryInfoBox(self)
        self.statBox = StatBox(gameView)

        self.lose = Title('YOU LOSE', 100)
        self.win = Title('YOU WIN', 100)
        self.lose.setParent(self)
        self.win.setParent(self)
        self.lose.raise_()
        self.win.raise_()
        self.lose.hide()
        self.win.hide()

        self.eventBox.setColor(QColor(Qt.black))
        self.countryBox.setColor(QColor(Qt.gray))
        self.statBox.setColor(QColor(Qt.gray))

        leftLayout.addWidget(self.gameView, 0, 0)
        leftLayout.addWidget(self.eventBox, 1, 0)
        rightLayout.addWidget(self.statBox, 0, 0)
        rightLayout.addWidget(self.countryBox, 1, 0)

        gameView.hoverCountry.connect(self.countryBox.updateCountry)
        gameView.ownerChanged.connect(self.statBox.refresh)

        game.gameEvent.connect(self.eventBox.addEvent)
        game.gameLose.connect(self._triggerLose)
        game.gameWin.connect(self._triggerWin)