annotate gamelib/hand.py @ 44:79062a225703

Correct out-by-one indentation error. :)
author Simon Cross <simon@simonx>
date Mon, 23 Aug 2010 10:35:53 +0200
parents 31a431f795e1
children 8771d545a493
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
1 # Button for the hand image
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
2
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
3 from albow.controls import ImageButton
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
4 from albow.resource import get_image
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
5 from albow.utils import frame_rect
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
6 from pygame.color import Color
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
7
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
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
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
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
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
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
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
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
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
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
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
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
31a431f795e1 Add a hand button placeholder
Neil Muller <neil@dip.sun.ac.za>
parents:
diff changeset
33