def __init__(self, rect, caplocation, text, fg, bg, visible): LCARSObject.__init__(self, rect, fg, bg, visible) self.textString = text if len(text) > 0: if (self.rect.h > self.rect.w): #Portrait format texty = self.rect.bottom - self.rect.w textx = self.rect.right - (self.rect.w / 10) textw = self.PointSizeFromBarWidth() else: #Landscape texty = self.rect.centery textx = self.rect.right - (self.rect.h/2) textw = self.PointSizeFromBarHeight() self.text = LCARSText((textx, texty), text, textw, TextAlign.XALIGN_RIGHT, self.bg, self.fg, True) # Swap fg/bg text colours else: self.text = None self.caps = [] if (caplocation & CapLocation.CAP_TOP): self.caps.append({'rect':pygame.Rect(0, 0, self.rect.w, self.rect.w), 'loc':CapLocation.CAP_TOP}) if (caplocation & CapLocation.CAP_LEFT): self.caps.append({'rect':pygame.Rect(0, 0, self.rect.h, self.rect.h), 'loc':CapLocation.CAP_LEFT}) if (caplocation & CapLocation.CAP_RIGHT): self.caps.append({'rect':pygame.Rect(self.rect.w - self.rect.h, 0, self.rect.h, self.rect.h), 'loc':CapLocation.CAP_RIGHT}) if (caplocation & CapLocation.CAP_BOTTOM): self.caps.append({'rect':pygame.Rect(0, self.rect.h - self.rect.w, self.rect.w, self.rect.w), 'loc':CapLocation.CAP_BOTTOM})
def __init__(self, alignpoint, text, size, xalign, fg, bg, show): (x, y) = alignpoint font_list = pygame.font.get_fonts() font_list = [ font for font in font_list if (font.find(font_search) > -1) ] self.font = pygame.font.SysFont(font_list[0], size) self.text = self.font.render(text, 1, fg, bg) # Define enclosing rectangle based on alignment point and align choice top = y - (self.text.get_height() / 2) if (xalign == TextAlign.XALIGN_CENTRE): left = x - (self.text.get_width() / 2) elif (xalign == TextAlign.XALIGN_RIGHT): left = x - self.text.get_width() elif (xalign == TextAlign.XALIGN_LEFT): left = x rect = pygame.Rect(left, top, self.text.get_width(), self.text.get_height()) LCARSObject.__init__(self, rect, fg, bg, show)
def __init__(self, enclosingrect, path, show): LCARSObject.__init__(self, enclosingrect, 0, 0, show) ## Colours do not matter self.image = pygame.image.load(path) imgrect = self.image.get_rect() self.rect.w = imgrect.w self.rect.h = imgrect.h self.rect.left = self.rect.left - (self.rect.w / 2) self.rect.bottom = self.rect.bottom - (self.rect.h / 2)
def __init__(self, rect, corner, xthick, ythick, fg, bg, show): LCARSObject.__init__(self, rect, fg, bg, show) minl = min(xthick, ythick) ycorrection = ythick - (minl * 2/3) xcorrection = xthick + (minl * 2/3) self.yrect = pygame.Rect(self.rect.left, self.rect.top + ycorrection, xthick, self.rect.h - ycorrection) self.xrect = pygame.Rect(self.rect.left + xcorrection, self.rect.top, self.rect.w - xcorrection, ythick) self.outersweepdraw = pygame.Rect(self.rect.left, self.rect.top, minl * 3, minl * 3) self.outersweepmask = pygame.Rect(self.rect.left + xthick, self.rect.top + ythick, minl * 3, minl * 3) self.innersweepdraw = pygame.Rect(self.rect.left + xthick, self.rect.top + ythick, minl, minl) self.innersweepmask = pygame.Rect(self.rect.left + xthick, self.rect.top + ythick, minl * 2, minl * 2)
def __init__(self, alignpoint, text, size, xalign, fg, bg, show): (x, y) = alignpoint font_list = pygame.font.get_fonts() font_list = [font for font in font_list if (font.find(font_search) > -1)] self.font = pygame.font.SysFont(font_list[0], size) self.text = self.font.render(text, 1, fg, bg) # Define enclosing rectangle based on alignment point and align choice top = y - (self.text.get_height() / 2) if xalign == TextAlign.XALIGN_CENTRE: left = x - (self.text.get_width() / 2) elif xalign == TextAlign.XALIGN_RIGHT: left = x - self.text.get_width() elif xalign == TextAlign.XALIGN_LEFT: left = x rect = pygame.Rect(left, top, self.text.get_width(), self.text.get_height()) LCARSObject.__init__(self, rect, fg, bg, show)
def __init__(self, rect, corner, xthick, ythick, fg, bg, show): LCARSObject.__init__(self, rect, fg, bg, show) minl = min(xthick, ythick) ycorrection = ythick - (minl * 2 / 3) xcorrection = xthick + (minl * 2 / 3) self.yrect = pygame.Rect(self.rect.left, self.rect.top + ycorrection, xthick, self.rect.h - ycorrection) self.xrect = pygame.Rect(self.rect.left + xcorrection, self.rect.top, self.rect.w - xcorrection, ythick) self.outersweepdraw = pygame.Rect(self.rect.left, self.rect.top, minl * 3, minl * 3) self.outersweepmask = pygame.Rect(self.rect.left + xthick, self.rect.top + ythick, minl * 3, minl * 3) self.innersweepdraw = pygame.Rect(self.rect.left + xthick, self.rect.top + ythick, minl, minl) self.innersweepmask = pygame.Rect(self.rect.left + xthick, self.rect.top + ythick, minl * 2, minl * 2)