def maximize(self): """make it as big as possible within the wall""" cWall = Internal.scene.game.wall newSceneX = cWall[3].sceneBoundingRect().right() newSceneY = cWall[2].sceneBoundingRect().bottom() tileset = self.tileset xAvail = cWall[1].sceneBoundingRect().left() - newSceneX yAvail = cWall[0].sceneBoundingRect().top() - newSceneY shadowHeight = tileset.shadowHeight() shadowWidth = tileset.shadowWidth() if Internal.Preferences.showShadows: # this should use the real shadow values from the wall because the wall # tiles are smaller than those in the CourtBoard but this should be # good enough newSceneX -= shadowHeight / 2 if 'W' in self.lightSource else 0 newSceneY -= shadowWidth / 2 if 'N' in self.lightSource else 0 xAvail -= shadowHeight if 'E' in self.lightSource else 0 yAvail -= shadowWidth if 'S' in self.lightSource else 0 xNeeded = self.width * tileset.faceSize.width() yNeeded = self.height * tileset.faceSize.height() xScaleFactor = xAvail / xNeeded yScaleFactor = yAvail / yNeeded QGraphicsRectItem.setPos(self, newSceneX, newSceneY) self.setScale(min(xScaleFactor, yScaleFactor)) for uiTile in self.uiTiles: uiTile.board.placeTile(uiTile)
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)
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, self.sceneRotation()) newX = self.__xWidth * width + self.__xHeight * height + offsets[0] newY = self.__yWidth * width + self.__yHeight * height + offsets[1] QGraphicsRectItem.setPos(self, newX, newY)