comparison gamelib/gui.py @ 62:38f41d046c6f

Make button font a parameter. Tweak indication of points to be spent
author Neil Muller <drnlmuller@gmail.com>
date Tue, 08 May 2012 17:29:02 +0200
parents d82d3e54a4ef
children 7309392d9ca9
comparison
equal deleted inserted replaced
61:a253fae32a6f 62:38f41d046c6f
1 from pygame import image 1 from pygame import image
2 2
3 from gamelib import data 3 from gamelib import data
4 from gamelib.gui_base import Drawable, TextButton 4 from gamelib.gui_base import Drawable, TextButton, font_large
5 5
6 6
7 class ImageDrawable(Drawable): 7 class ImageDrawable(Drawable):
8 8
9 def __init__(self, rect, image): 9 def __init__(self, rect, image):
18 WIDTH = 128 18 WIDTH = 128
19 HEIGHT = 64 19 HEIGHT = 64
20 BG_IMAGE_NORMAL = image.load(data.filepath('images/button_normal.png')) 20 BG_IMAGE_NORMAL = image.load(data.filepath('images/button_normal.png'))
21 BG_IMAGE_DOWN = image.load(data.filepath('images/button_down.png')) 21 BG_IMAGE_DOWN = image.load(data.filepath('images/button_down.png'))
22 22
23 def __init__(self, pos, text): 23 def __init__(self, pos, text, font=font_large, shadow=True):
24 rect1 = (0, 0, self.WIDTH, self.HEIGHT) 24 rect1 = (0, 0, self.WIDTH, self.HEIGHT)
25 n = ImageDrawable(rect1, self.BG_IMAGE_NORMAL) 25 n = ImageDrawable(rect1, self.BG_IMAGE_NORMAL)
26 d = ImageDrawable(rect1, self.BG_IMAGE_DOWN) 26 d = ImageDrawable(rect1, self.BG_IMAGE_DOWN)
27 rect2 = (pos[0], pos[1], self.WIDTH, self.HEIGHT) 27 rect2 = (pos[0], pos[1], self.WIDTH, self.HEIGHT)
28 super(BigButton, self).__init__(rect2, n, d, text) 28 super(BigButton, self).__init__(rect2, n, d, text, font, shadow)