# HG changeset patch # User Rizmari Versfeld # Date 1336688581 -7200 # Node ID abbceec3cc8ba9efa2f6ce2bc4ebec32b518c0b3 # Parent fb8037bc22f13f6ab56524c1fdf79e8639ca1556 added examples of nodes in main menu diff -r fb8037bc22f1 -r abbceec3cc8b data/images/icons/marinebiology_down.png Binary file data/images/icons/marinebiology_down.png has changed diff -r fb8037bc22f1 -r abbceec3cc8b data/images/icons/marinebiology_normal.png Binary file data/images/icons/marinebiology_normal.png has changed diff -r fb8037bc22f1 -r abbceec3cc8b data/images/icons/robotics_down.png Binary file data/images/icons/robotics_down.png has changed diff -r fb8037bc22f1 -r abbceec3cc8b data/images/icons/robotics_normal.png Binary file data/images/icons/robotics_normal.png has changed diff -r fb8037bc22f1 -r abbceec3cc8b data/images/icons/rocketry_down.png Binary file data/images/icons/rocketry_down.png has changed diff -r fb8037bc22f1 -r abbceec3cc8b data/images/icons/rocketry_normal.png Binary file data/images/icons/rocketry_normal.png has changed diff -r fb8037bc22f1 -r abbceec3cc8b data/images/research_down.png Binary file data/images/research_down.png has changed diff -r fb8037bc22f1 -r abbceec3cc8b data/images/research_normal.png Binary file data/images/research_normal.png has changed diff -r fb8037bc22f1 -r abbceec3cc8b gamelib/gui.py --- 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 diff -r fb8037bc22f1 -r abbceec3cc8b gamelib/mainmenu.py --- a/gamelib/mainmenu.py Thu May 10 20:56:40 2012 +0200 +++ b/gamelib/mainmenu.py Fri May 11 00:23:01 2012 +0200 @@ -15,7 +15,7 @@ from gamelib import data from gamelib.gui_base import Window -from gamelib.gui import BigButton +from gamelib.gui import BigButton, IconButton from gamelib.engine import AddWindow from gamelib.gamegui import LabWindow @@ -72,6 +72,9 @@ self.screen = screen self.background_colour = (0, 0, 0) self.background_image = image.load(data.filepath('images/temp.jpg')) + self.add_child(IconButton((0,0),'rocketry')) + self.add_child(IconButton((64,0),'marinebiology')) + self.add_child(IconButton((128,0),'robotics')) button1 = NewGameButton(self) self.add_child(button1) button2 = QuitButton()