Mercurial > pyntnclick
comparison gamelib/state.py @ 326:bd649aa51472
Tweak description appearance
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Sat, 28 Aug 2010 13:33:07 +0200 |
parents | 3476e8f3b100 |
children | a1ffc919d0c1 |
comparison
equal
deleted
inserted
replaced
325:05b5723aa11b | 326:bd649aa51472 |
---|---|
1 """Utilities and base classes for dealing with scenes.""" | 1 """Utilities and base classes for dealing with scenes.""" |
2 | 2 |
3 from albow.resource import get_image | 3 from albow.resource import get_image, get_font |
4 from albow.utils import frame_rect | 4 from albow.utils import frame_rect |
5 from widgets import BoomLabel | 5 from widgets import BoomLabel |
6 from pygame.rect import Rect | 6 from pygame.rect import Rect |
7 from pygame.color import Color | 7 from pygame.color import Color |
8 | 8 |
271 text = (self.state.current_thing and | 271 text = (self.state.current_thing and |
272 self.state.current_thing.get_description()) | 272 self.state.current_thing.get_description()) |
273 if text is None: | 273 if text is None: |
274 return None | 274 return None |
275 label = BoomLabel(text) | 275 label = BoomLabel(text) |
276 font = get_font(15, 'VeraBd.ttf') | |
276 label.set_margin(5) | 277 label.set_margin(5) |
277 label.border_width = 1 | 278 label.border_width = 1 |
278 label.border_color = (0, 0, 0) | 279 label.border_color = (0, 0, 0) |
279 label.bg_color = Color(127, 127, 127, 255) | 280 label.bg_color = Color(210, 210, 210, 255) |
280 label.fg_color = (0, 0, 0) | 281 label.fg_color = (0, 0, 0) |
281 return label | 282 return label |
282 | 283 |
283 def draw_description(self, surface, screen): | 284 def draw_description(self, surface, screen): |
284 description = self._get_description() | 285 description = self._get_description() |
285 if description is not None: | 286 if description is not None: |
287 w, h = description.size | |
286 sub = screen.get_root().surface.subsurface( | 288 sub = screen.get_root().surface.subsurface( |
287 Rect(5, 5, *description.size)) | 289 Rect(400-w/2, 5, w, h)) |
288 description.draw_all(sub) | 290 description.draw_all(sub) |
289 | 291 |
290 def draw_background(self, surface): | 292 def draw_background(self, surface): |
291 if self._background is not None: | 293 if self._background is not None: |
292 surface.blit(self._background, self.OFFSET, None) | 294 surface.blit(self._background, self.OFFSET, None) |