Mercurial > sypikslang
diff gamelib/gui.py @ 140:abbceec3cc8b
added examples of nodes in main menu
author | Rizmari Versfeld <rizziepit@gmail.com> |
---|---|
date | Fri, 11 May 2012 00:23:01 +0200 |
parents | ff7c953502d5 |
children | 3e02a8ccd72b |
line wrap: on
line diff
--- a/gamelib/gui.py Thu May 10 20:56:40 2012 +0200 +++ b/gamelib/gui.py Fri May 11 00:23:01 2012 +0200 @@ -1,7 +1,7 @@ from pygame import image from gamelib import data -from gamelib.gui_base import Drawable, TextButton, font_auto +from gamelib.gui_base import Drawable, TextButton, font_auto, Button class ImageDrawable(Drawable): @@ -26,3 +26,21 @@ d = ImageDrawable(rect1, self.BG_IMAGE_DOWN) rect2 = (pos[0], pos[1], self.WIDTH, self.HEIGHT) super(BigButton, self).__init__(rect2, n, d, text, font, shadow) + + +class IconButton(Button): + WIDTH = 64 + HEIGHT = 64 + BG_IMAGE_NORMAL = image.load(data.filepath('images/research_normal.png')) + BG_IMAGE_DOWN = image.load(data.filepath('images/research_down.png')) + + def __init__(self, pos, name): + rect = (pos[0], pos[1], self.WIDTH, self.HEIGHT) + n_icon = image.load(data.filepath('images/icons/%s_normal.png' % name)) + d_icon = image.load(data.filepath('images/icons/%s_down.png' % name)) + n = ImageDrawable(rect, self.BG_IMAGE_NORMAL.copy()) + n.image.blit(n_icon, (0,0)) + d = ImageDrawable(rect, self.BG_IMAGE_DOWN.copy()) + d.image.blit(d_icon, (0,0)) + rect2 = (pos[0], pos[1], self.WIDTH, self.HEIGHT) + super(IconButton, self).__init__(rect2, n, d) \ No newline at end of file