Mercurial > sypikslang
comparison gamelib/gui.py @ 212:16ce5ed563c9
Change science buttons
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 12 May 2012 20:17:28 +0200 |
parents | 0090ecf08544 |
children | 2d72e84a765b |
comparison
equal
deleted
inserted
replaced
211:ba7c0953853b | 212:16ce5ed563c9 |
---|---|
49 rect2 = (pos[0], pos[1], self.WIDTH, self.HEIGHT) | 49 rect2 = (pos[0], pos[1], self.WIDTH, self.HEIGHT) |
50 super(IconButton, self).__init__(rect2, n, d) | 50 super(IconButton, self).__init__(rect2, n, d) |
51 | 51 |
52 | 52 |
53 class IconTextButton(TextButton): | 53 class IconTextButton(TextButton): |
54 WIDTH = 128 | 54 WIDTH = 270 |
55 HEIGHT = 64 | 55 HEIGHT = 80 |
56 | 56 |
57 TEXT_OFFSET = (50, 0) | 57 TEXT_OFFSET = (0, 60) |
58 | 58 |
59 def __init__(self, pos, name, text, font=font_auto, shadow=True): | 59 def __init__(self, pos, name, text, font=font_auto, shadow=True): |
60 rect = (pos[0], pos[1], self.WIDTH, self.HEIGHT) | 60 rect = (pos[0], pos[1], self.WIDTH, self.HEIGHT) |
61 n = self._mk_image(name, 'normal') | 61 n = self._mk_image(name, 'normal') |
62 d = self._mk_image(name, 'down') | 62 d = self._mk_image(name, 'down') |
63 text_rect = (self.TEXT_OFFSET, | 63 text_rect = (self.TEXT_OFFSET, |
64 (self.WIDTH - self.TEXT_OFFSET[0], | 64 (self.WIDTH - self.TEXT_OFFSET[0], |
65 self.HEIGHT - self.TEXT_OFFSET[1])) | 65 self.HEIGHT - self.TEXT_OFFSET[1])) |
66 super(IconTextButton, self).__init__( | 66 super(IconTextButton, self).__init__( |
67 rect, n, d, text, font, shadow, text_rect) | 67 rect, n, d, text, font, shadow, text_rect, |
68 (255, 255, 255), (128, 128, 128)) | |
68 | 69 |
69 def _mk_image(self, name, suffix): | 70 def _mk_image(self, name, suffix): |
70 bg = data.load_image('images/button_%s.png' % (suffix,)) | 71 bg = data.load_image('images/research_%s.png' % (suffix,)) |
71 try: | 72 try: |
72 icon = data.load_image('images/icons/%s_%s.png' % (name, suffix)) | 73 icon = data.load_image('images/icons/%s_%s.png' % (name, suffix)) |
73 except pygame.error: | 74 except pygame.error: |
74 icon = pygame.Surface((64, 64), pygame.SRCALPHA) | 75 icon = pygame.Surface((64, 64), pygame.SRCALPHA) |
75 drawable = ImageDrawable((0, 0, self.WIDTH, self.HEIGHT), bg.copy()) | 76 base = pygame.Surface((self.WIDTH, self.HEIGHT), pygame.SRCALPHA) |
76 drawable.image.blit(icon, (0, 0)) | 77 base.blit(bg, (self.WIDTH / 2 - 32, 0)) |
78 drawable = ImageDrawable((0, 0, self.WIDTH, self.HEIGHT), base) | |
79 # Centre icon | |
80 drawable.image.blit(icon, (self.WIDTH / 2 - 32, 0)) | |
77 return drawable | 81 return drawable |
78 | 82 |
79 | 83 |
80 class RadioButton(IconButton): | 84 class RadioButton(IconButton): |
81 SELECTED_BUTTON = None | 85 SELECTED_BUTTON = None |