コード例 #1
0
ファイル: scoring.py プロジェクト: zero804/kajongg
 def showMoveHelper(self, visible=None):
     """show help text In empty HandBoards"""
     if visible is None:
         visible = not self.uiTiles
     if self.__moveHelper and not isAlive(self.__moveHelper):
         return
     if visible:
         if not self.__moveHelper:
             splitter = QGraphicsRectItem(self)
             hbCenter = self.rect().center()
             splitter.setRect(hbCenter.x() * 0.5, hbCenter.y(),
                              hbCenter.x() * 1, 1)
             helpItems = [splitter]
             for name, yFactor in [(i18n('Move Exposed Tiles Here'), 0.5),
                                   (i18n('Move Concealed Tiles Here'), 1.5)
                                   ]:
                 helper = QGraphicsSimpleTextItem(name, self)
                 helper.setScale(3)
                 nameRect = QRectF()
                 nameRect.setSize(
                     helper.mapToParent(
                         helper.boundingRect()).boundingRect().size())
                 center = QPointF(hbCenter)
                 center.setY(center.y() * yFactor)
                 helper.setPos(center - nameRect.center())
                 if sceneRotation(self) == 180:
                     rotateCenter(helper, 180)
                 helpItems.append(helper)
             self.__moveHelper = self.scene().createItemGroup(helpItems)
         self.__moveHelper.setVisible(True)
     else:
         if self.__moveHelper:
             self.__moveHelper.setVisible(False)
コード例 #2
0
 def moveDict(self):
     """a dict with attributes for the new position,
     normally pos, rotation and scale"""
     sideCenter = self.board.center()
     boardPos = QPointF(
         sideCenter.x() * 1.63,
         sideCenter.y() - self.boundingRect().height() / 2.0)
     scenePos = self.board.mapToScene(boardPos)
     return {'pos': scenePos, 'rotation': sceneRotation(self.board)}
コード例 #3
0
ファイル: uitile.py プロジェクト: zero804/kajongg
 def sortKey(self, sortDir=Qt.Key_Right):
     """moving order for cursor"""
     dirs = [Qt.Key_Right, Qt.Key_Up, Qt.Key_Left, Qt.Key_Down] * 2
     sorter = dirs[dirs.index(sortDir) + sceneRotation(self.__board) // 90]
     if sorter == Qt.Key_Down:
         return self.xoffset * 100 + self.yoffset
     elif sorter == Qt.Key_Up:
         return -self.xoffset * 100 - self.yoffset
     elif sorter == Qt.Key_Left:
         return -self.yoffset * 100 - self.xoffset
     else:
         return self.yoffset * 100 + self.xoffset
コード例 #4
0
ファイル: uitile.py プロジェクト: zero804/kajongg
 def moveDict(self):
     """a dict with attributes for the new position,
     normally pos, rotation and scale"""
     assert self.board
     width = self.tileset.faceSize.width()
     height = self.tileset.faceSize.height()
     shiftZ = self.board.shiftZ(self.level)
     boardPos = QPointF(
         self.xoffset * width,
         self.yoffset * height) + shiftZ
     scenePos = self.board.mapToScene(boardPos)
     return {'pos': scenePos, 'rotation': sceneRotation(self.board), 'scale': self.board.scale()}
コード例 #5
0
    def refreshAll():
        """recompute ourself. Always do this for all for sides
        together because if two names change place we want the
        to move simultaneously"""
        sides = SideText.sideTexts
        if all(not x.needsRefresh for x in sides):
            return
        rotating = False
        for side in sides:
            side.show()
            if not side.needsRefresh:
                continue
            side.needsRefresh = False
            rotating |= sceneRotation(side) != sceneRotation(side.board)

        alreadyMoved = any(x.x() for x in sides)
        with AnimationSpeed(
                speed=Speeds.windMarker if rotating and alreadyMoved else 99):
            # first round: just place the winds. Only animate moving them
            # for later rounds.
            for side in sides:
                side.setupAnimations()
        animate()
コード例 #6
0
 def setGeometry(self):
     """move the board to the correct position and set its rect surrounding all its
     items. This is needed for enabling drops into the board.
     This is also called when the tileset or the light source for this board changes"""
     width = self.tileset.faceSize.width()
     height = self.tileset.faceSize.height()
     if not Internal.Preferences.showShadows:
         offsets = (0, 0)
     elif self.isHandBoard:
         offsets = (-self.tileset.shadowHeight() * 2, 0)
     else:
         offsets = self.tileset.shadowOffsets(
             self._lightSource,
             sceneRotation(self))
     newX = self.__xWidth * width + self.__xHeight * height + offsets[0]
     newY = self.__yWidth * width + self.__yHeight * height + offsets[1]
     QGraphicsRectItem.setPos(self, newX, newY)
コード例 #7
0
 def moveDict(self):
     """returns a dict with new property values for our sidetext
     which move it onto us"""
     if not self.board or not self.__text:
         return {}
     rotation = sceneRotation(self.board)
     position = self.board.center()
     textCenter = self.boundingRect().center()
     if rotation == 180:
         rotation = 0
         position += textCenter
     else:
         position -= textCenter
     return {
         'pos': self.board.mapToScene(position),
         'rotation': rotation,
         'scale': self.board.scale()
     }
コード例 #8
0
 def refresh(self, dummyDeferredResult=None):
     """show/hide on correct position after queued animations end"""
     board = self.board
     if not isAlive(board) or not isAlive(self):
         if isAlive(self):
             self.setVisible(False)
         return
     rect = board.tileFaceRect()
     rect.setWidth(rect.width() * board.focusRectWidth())
     self.setRect(rect)
     self.setRotation(sceneRotation(board))
     self.setScale(board.scale())
     if board.focusTile:
         board.focusTile.setFocus()
         self.setPos(board.focusTile.pos)
     game = Internal.scene.game
     self.setVisible(board.isVisible() and bool(board.focusTile)
                     and board.isEnabled() and board.hasFocus and bool(game)
                     and not game.autoPlay)
コード例 #9
0
 def rotatedLightSource(self):
     """the light source we need for the original uiTile before it is rotated"""
     lightSourceIndex = LIGHTSOURCES.index(self.lightSource)
     lightSourceIndex = (lightSourceIndex + sceneRotation(self) // 90) % 4
     return LIGHTSOURCES[lightSourceIndex]