Mercurial > pyntnclick
comparison gamelib/state.py @ 77:bb7c8072f8c0
Some hacks to make Label work.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Mon, 23 Aug 2010 22:42:30 +0200 |
parents | 1a5fdc225939 |
children | 6bfebfbce42e |
comparison
equal
deleted
inserted
replaced
76:1a5fdc225939 | 77:bb7c8072f8c0 |
---|---|
130 | 130 |
131 def _make_description(self, text): | 131 def _make_description(self, text): |
132 if text is None: | 132 if text is None: |
133 return None | 133 return None |
134 label = Label(text) | 134 label = Label(text) |
135 label.margin = 5 | 135 # TODO: create derived label class that does this |
136 # manually recalculate size | |
137 d = 5 | |
138 w, h = label.size | |
139 label.margin = d | |
140 label.size = (w+2*d, h+2*d) | |
136 label.border_width = 1 | 141 label.border_width = 1 |
137 label.border_color = (0, 0, 0) | 142 label.border_color = (0, 0, 0) |
138 label.bg_color = (127, 127, 127) | 143 label.bg_color = (127, 127, 127) |
139 label.fg_color = (0, 0, 0) | 144 label.fg_color = (0, 0, 0) |
140 return label | 145 return label |
141 | 146 |
142 def draw_description(self, surface): | 147 def draw_description(self, surface): |
143 if self._current_description is not None: | 148 if self._current_description is not None: |
144 self._current_description.draw(surface) | 149 sub = surface.subsurface( |
150 Rect(5, 5, *self._current_description.size)) | |
151 self._current_description.draw_all(sub) | |
145 | 152 |
146 def draw_background(self, surface): | 153 def draw_background(self, surface): |
147 surface.blit(self._background, (0, 0), None, BLEND_ADD) | 154 surface.blit(self._background, (0, 0), None, BLEND_ADD) |
148 | 155 |
149 def draw_things(self, surface): | 156 def draw_things(self, surface): |