VIEW_PORT_DY = 50
def __init__(self, pos, text, fontname=None, fontsize=None,
- colour=None, unselectable_colour=None, view_port=None):
+ colour=None, unselectable_colour=None, view_port=None,
+ centre=False):
super(TextWidget, self).__init__(pos)
self.text = text
self.unselectable_colour = unselectable_colour
self.view_port = (
pygame.Rect((0, 0), view_port) if view_port is not None else None)
+ self.centre = centre
+ self.centre_pos = pos
def render_line(self, text):
colour = self.colour
self.size = self.view_port.size
else:
self.size = self.surface.get_rect().size
+ if self.centre:
+ self.pos = (self.centre_pos[0] - self.size[0] // 2,
+ self.centre_pos[1])
def prepare(self):
self.font = resources.get_font(self.fontname, self.fontsize)