Mercurial > boomslang
comparison pyntnclick/scenewidgets.py @ 826:3a00c9337731 pyntnclick
Add centre parameter to InteractText
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Tue, 29 Jan 2013 13:33:00 +0200 |
parents | 9f542ef6e498 |
children |
comparison
equal
deleted
inserted
replaced
825:c5171ad0c3cd | 826:3a00c9337731 |
---|---|
56 class InteractText(Interact): | 56 class InteractText(Interact): |
57 """Display a text string on a transparent background. | 57 """Display a text string on a transparent background. |
58 | 58 |
59 Used so we can easily include translatable strings in the scenes""" | 59 Used so we can easily include translatable strings in the scenes""" |
60 | 60 |
61 def __init__(self, x, y, w, h, text, color, max_font_size, font=None): | 61 def __init__(self, x, y, w, h, text, color, max_font_size, font=None, |
62 centre=True): | |
62 self._text = text | 63 self._text = text |
63 self._color = convert_color(color) | 64 self._color = convert_color(color) |
64 self._max_font_size = max_font_size | 65 self._max_font_size = max_font_size |
65 self._font = font | 66 self._font = font |
67 self._centre = centre | |
66 rect = Rect((x, y), (w, h)) | 68 rect = Rect((x, y), (w, h)) |
67 super(InteractText, self).__init__(None, rect, rect) | 69 super(InteractText, self).__init__(None, rect, rect) |
68 | 70 |
69 def set_thing(self, thing): | 71 def set_thing(self, thing): |
70 font_size = self._max_font_size | 72 font_size = self._max_font_size |
71 if not self._font: | 73 if not self._font: |
72 # Pull the default font out of constants | 74 # Pull the default font out of constants |
73 self._font = thing.gd.constants.font | 75 self._font = thing.gd.constants.font |
74 bg_color = Color(0, 0, 0, 0) # transparent background | 76 bg_color = Color(0, 0, 0, 0) # transparent background |
75 self.image = render_text(self._text, self._font, font_size, | 77 self.image = render_text(self._text, self._font, font_size, |
76 self._color, bg_color, thing.resource, self.rect.size) | 78 self._color, bg_color, thing.resource, self.rect.size, |
79 self._centre) | |
77 | 80 |
78 | 81 |
79 class InteractRectUnion(Interact): | 82 class InteractRectUnion(Interact): |
80 | 83 |
81 def __init__(self, rect_list): | 84 def __init__(self, rect_list): |