コード例 #1
0
ファイル: playfield.py プロジェクト: ospalh/kajongg-fork
    def __init__(self, game):
        SelectRuleset.__init__(self)
        self.game = game
        Players.load()
        self.setWindowTitle(m18n('Select four players') + ' - Kajongg')
        self.names = None
        self.nameWidgets = []
        for idx, wind in enumerate(WINDS):
            cbName = QComboBox()
            cbName.manualSelect = False
            # increase width, we want to see the full window title
            cbName.setMinimumWidth(350) # is this good for all platforms?
            cbName.addItems(Players.humanNames.values())
            self.grid.addWidget(cbName, idx+1, 1)
            self.nameWidgets.append(cbName)
            self.grid.addWidget(WindLabel(wind), idx+1, 0)
            cbName.currentIndexChanged.connect(self.slotValidate)

        query = Query("select p0,p1,p2,p3 from game where seed is null and game.id = (select max(id) from game)")
        if len(query.records):
            for pidx, playerId in enumerate(query.records[0]):
                try:
                    playerName = Players.humanNames[playerId]
                    cbName = self.nameWidgets[pidx]
                    playerIdx = cbName.findText(playerName)
                    if playerIdx >= 0:
                        cbName.setCurrentIndex(playerIdx)
                except KeyError:
                    logError('database is inconsistent: player with id %d is in game but not in player' \
                               % playerId)
        self.slotValidate()
コード例 #2
0
ファイル: scoring.py プロジェクト: zero804/kajongg
    def __init__(self):
        SelectRuleset.__init__(self)
        Players.load()
        decorateWindow(self, i18n('Select four players'))
        self.names = None
        self.nameWidgets = []
        for idx, wind in enumerate(Wind.all4):
            cbName = QComboBox()
            cbName.manualSelect = False
            # increase width, we want to see the full window title
            cbName.setMinimumWidth(350)  # is this good for all platforms?
            cbName.addItems(list(Players.humanNames.values()))
            self.grid.addWidget(cbName, idx + 1, 1)
            self.nameWidgets.append(cbName)
            self.grid.addWidget(WindLabel(wind), idx + 1, 0)
            cbName.currentIndexChanged.connect(self.slotValidate)

        query = Query(
            "select p0,p1,p2,p3 from game where seed is null and game.id = (select max(id) from game)"
        )
        if len(query.records):
            with BlockSignals(self.nameWidgets):
                for cbName, playerId in zip(self.nameWidgets,
                                            query.records[0]):
                    try:
                        playerName = Players.humanNames[playerId]
                        playerIdx = cbName.findText(playerName)
                        if playerIdx >= 0:
                            cbName.setCurrentIndex(playerIdx)
                    except KeyError:
                        logError(
                            'database is inconsistent: player with id %d is in game but not in player'
                            % playerId)
        self.slotValidate()
コード例 #3
0
ファイル: humanclient.py プロジェクト: ospalh/kajongg-fork
 def newTable(self):
     """TableList uses me as a slot"""
     if Options.ruleset:
         ruleset = Options.ruleset
     elif self.hasLocalServer():
         ruleset = self.ruleset
     else:
         selectDialog = SelectRuleset(self.connection.url)
         if not selectDialog.exec_():
             return
         ruleset = selectDialog.cbRuleset.current
     deferred = self.__requestNewTableFromServer(ruleset=ruleset)
     if self.hasLocalServer():
         deferred.addCallback(self.__newLocalTable)
     self.tableList.requestedNewTable = True
コード例 #4
0
ファイル: humanclient.py プロジェクト: KDE/kajongg
 def newTable(self):
     """TableList uses me as a slot"""
     if Options.ruleset:
         ruleset = Options.ruleset
     elif self.hasLocalServer():
         ruleset = self.ruleset
     else:
         selectDialog = SelectRuleset(self.connection.url)
         if not selectDialog.exec_():
             return
         ruleset = selectDialog.cbRuleset.current
     deferred = self.__requestNewTableFromServer(ruleset=ruleset)
     if self.hasLocalServer():
         deferred.addCallback(self.__newLocalTable)
     self.tableList.requestedNewTable = True