Mercurial > boomslang
annotate gamelib/hand.py @ 47:8f1fccb8cadf
Skeletons for scenes in plot outline.
author | Simon Cross <simon@simonx> |
---|---|
date | Mon, 23 Aug 2010 11:47:03 +0200 |
parents | 79062a225703 |
children | 8771d545a493 |
rev | line source |
---|---|
36 | 1 # Button for the hand image |
2 | |
3 from albow.controls import ImageButton | |
4 from albow.resource import get_image | |
5 from albow.utils import frame_rect | |
6 from pygame.color import Color | |
7 | |
8 class HandButton(ImageButton): | |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
9 """The fancy hand button for the widget""" |
36 | 10 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
11 sel_colour = Color('red') |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
12 sel_width = 2 |
36 | 13 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
14 def __init__(self, action): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
15 # FIXME: Yes, please. |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
16 this_image = get_image('items', 'square.png') |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
17 ImageButton.__init__(self, image=this_image, action=action) |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
18 self.selected = False # Flag if we're selected |
36 | 19 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
20 def draw(self, surface): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
21 """Draw the widget""" |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
22 print 'drawing widget', self.selected |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
23 ImageButton.draw(self, surface) |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
24 if self.selected: |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
25 rect = surface.get_rect().inflate(-self.sel_width, -self.sel_width) |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
26 frame_rect(surface, self.sel_colour, rect, self.sel_width) |
36 | 27 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
28 def toggle_selected(self): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
29 self.selected = not self.selected |
36 | 30 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
31 def unselect(self): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
32 self.selected = False |
36 | 33 |