def __init__(self, width, height): self.ENDCAP = -1 #pylint: disable=C0103 self.TEXT = -2 #pylint: disable=C0103 self.SWEEP = -3 #pylint: disable=C0103 capped_bar_length = width / 16 sweep_end_y = height - Widths.BORDER sweep_height = sweep_end_y - Widths.BORDER self.objects = { self.ENDCAP: LCARSCappedBar( pygame.Rect(width - Widths.BORDER - capped_bar_length, Widths.BORDER, capped_bar_length, Widths.LARGE_BAR), CapLocation.CAP_RIGHT, '', Colours.FG, Colours.BG, True) } ## The title text is to the immediate left of the endcap text_right = self.objects[self.ENDCAP].l() - Widths.BORDER self.objects[self.TEXT] = LCARSText( (text_right, Widths.BORDER + Widths.LARGE_BAR / 2), "SNACKSPACE v1.0", 80, TextAlign.XALIGN_RIGHT, Colours.FG, Colours.BG, True) ## The sweep starts at the immediate left of the text sweep_end_x = self.objects[self.TEXT].l() - Widths.BORDER sweep_width = sweep_end_x - Widths.BORDER self.objects[self.SWEEP] = LCARSSweep( pygame.Rect(Widths.BORDER, Widths.BORDER, sweep_width, sweep_height), 'TL', Widths.SMALL_BAR, Widths.LARGE_BAR, Colours.FG, Colours.BG, True)
def set_intro_text(self, text, color): """ The intro text is positioned centrally between the sweep and image """ text_y_position = (self.border.inner_y() + self.objects['titleimage'].t()) / 2 self.objects['introtext'] = LCARSText( (self.width / 2, text_y_position), text, 36, TextAlign.XALIGN_CENTRE, color, Colours.BG, True)
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 set_intro_text_2(self, text, color): """ The intro text is positioned between the image and the base """ text_y_position = (self.objects['titleimage'].b() + self.border.bottom()) / 2 text_y_position = text_y_position - 30 self.objects['introtext2'] = LCARSText( (self.width / 2, text_y_position), text, 36, TextAlign.XALIGN_CENTRE, color, Colours.BG, True)
def set_intro_text_3(self, text, color): """ The intro text is positioned between the image and the base """ text_y_position = self.objects['introtext2'].t() + 80 self.objects['introtext3'] = LCARSText( (self.width / 2, text_y_position), text, 36, TextAlign.XALIGN_CENTRE, color, Colours.BG, True)
def setText(self, text): texty = self.rect.centery textx = self.rect.right - (self.rect.h/2) self.textString = text self.text = LCARSText((textx, texty), text, self.PointSizeFromBarHeight(), TextAlign.XALIGN_RIGHT, self.bg, self.fg, True) # Swap fg/bg text colours