예제 #1
0
    def createBlock(self, rect:pygame.Rect, color:tuple, fontName:str, item:Item):
        surface = pygame.Surface((rect.width, rect.height))
        colorRect = Positioning.innerRect(surface.get_rect(), Block.BORDER_SIZE)
        surface.fill(color, colorRect)

        fontRect = Positioning.innerRect(colorRect, Padding.LABEL)
        fontRect.left += Padding.BLOCK
        fontSize = FontSizer.bestFitSizeInPoints(fontName, rect.height / 4)
        font = pygame.font.Font(fontName, fontSize)
        fontSurface = font.render(item.label, True, self.fontColor)
        colorRect.left += Padding.LABEL
        colorRect.top += Padding.LABEL
        surface.blit(fontSurface, fontRect)

        return surface
예제 #2
0
    def __init__(self, parentSurface:Surface, rect:pygame.Rect,
                 fontName:str, fontColor:tuple, numLines:int,
                 borderColor:tuple, backgroundColor:tuple):
        Widget.__init__(self, parentSurface, rect, borderColor, None)
        self.backgroundColor = backgroundColor
        self.surface = self.getBackgroundSurface()

        self.fontRect = Positioning.innerRect(self.surface.get_rect(), Padding.LABEL)
        fontSize = FontSizer.bestFitSizeInPoints(fontName, self.fontRect.height / numLines)
        self._font = pygame.font.Font(fontName, fontSize)
        self._color = fontColor
        self._text = ""
        self.draw()
예제 #3
0
 def __init__(self, parentSurface:pygame.Surface, rect:pygame.Rect, skin:Skin):
     DirtySprite.__init__(self)
     self.parentSurface = parentSurface
     self.image = pygame.Surface((rect.width, rect.height))
     self.image.fill(skin.guiColor("Popup Background"))
     self.rect = rect
     self.contentRect = Positioning.innerRect(self.image.get_rect(), Padding.POPUP_WINDOW_FRAME)
     toolbarHeight = (Padding.POPUP_WINDOW_FRAME * 2) + Sizing.POPUP_WINDOW_FRAME_BUTTON
     self.contentRect = pygame.Rect(Padding.POPUP_WINDOW_FRAME,
                                    toolbarHeight,
                                    rect.width - (Padding.POPUP_WINDOW_FRAME * 2),
                                    rect.height - toolbarHeight - Padding.POPUP_WINDOW_FRAME)
     self.skin = skin
     self.visible = False
예제 #4
0
 def showSearchPopup(self):
     rect = Positioning.innerRect(self.gridSprites.rect, Padding.SEARCH_POPUP)
     searchPopup = SearchPopup(self.parentSurface, rect, self.skin)
     self.gridSprites.add(searchPopup)
     searchPopup.show()
     self.activePopup = searchPopup