comparison gamelib/menu.py @ 450:ece69836f00a

Image buttons for game over screen
author Neil Muller <neil@dip.sun.ac.za>
date Sun, 29 Aug 2010 00:50:25 +0200
parents a6de33fecb97
children 0ce08d5e2acb
comparison
equal deleted inserted replaced
449:a30f91ee5b33 450:ece69836f00a
6 from albow.controls import Image, Button, Label 6 from albow.controls import Image, Button, Label
7 from albow.layout import Column 7 from albow.layout import Column
8 from albow.resource import get_image 8 from albow.resource import get_image
9 from pygame import Rect 9 from pygame import Rect
10 10
11 class SplashButton(Image): 11 from gamelib.widgets import BoomImageButton
12 """The fancy hand button for the widget"""
13 12
14 def __init__(self, filename, x, y, action, enable=None):
15 this_image = get_image('splash', filename)
16 Image.__init__(self, image=this_image)
17 self.action = action
18 self.set_rect(Rect((x, y), this_image.get_size()))
19 self.enable = enable
20 13
21 def draw(self, surface): 14 class SplashButton(BoomImageButton):
22 if self.is_enabled():
23 surface.blit(self.get_image(), self.get_rect())
24 15
25 def mouse_down(self, event): 16 FOLDER = 'splash'
26 if self.is_enabled():
27 self.action()
28
29 def is_enabled(self):
30 if self.enable:
31 return self.enable()
32 return True
33 17
34 18
35 class MenuScreen(Screen): 19 class MenuScreen(Screen):
36 def __init__(self, shell): 20 def __init__(self, shell):
37 Screen.__init__(self, shell) 21 Screen.__init__(self, shell)