Mercurial > boomslang
annotate gamelib/hand.py @ 93:350ce4ebe122
Detail view without any functionality.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Tue, 24 Aug 2010 00:43:32 +0200 |
parents | c76f2fad2af5 |
children | 97322b78d1c1 |
rev | line source |
---|---|
36 | 1 # Button for the hand image |
2 | |
57
4f9d412d83db
Use hand icon from openclipart
Neil Muller <neil@dip.sun.ac.za>
parents:
49
diff
changeset
|
3 from constants import BUTTON_SIZE |
4f9d412d83db
Use hand icon from openclipart
Neil Muller <neil@dip.sun.ac.za>
parents:
49
diff
changeset
|
4 |
36 | 5 from albow.controls import ImageButton |
6 from albow.resource import get_image | |
7 from albow.utils import frame_rect | |
8 from pygame.color import Color | |
57
4f9d412d83db
Use hand icon from openclipart
Neil Muller <neil@dip.sun.ac.za>
parents:
49
diff
changeset
|
9 from pygame.rect import Rect |
36 | 10 |
84
c76f2fad2af5
Draw CursorWidget on top of StateWidget
Stefano Rivera <stefano@rivera.za.net>
parents:
70
diff
changeset
|
11 class HandButton(ImageButton): |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
12 """The fancy hand button for the widget""" |
36 | 13 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
14 sel_colour = Color('red') |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
15 sel_width = 2 |
36 | 16 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
17 def __init__(self, action): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
18 # FIXME: Yes, please. |
57
4f9d412d83db
Use hand icon from openclipart
Neil Muller <neil@dip.sun.ac.za>
parents:
49
diff
changeset
|
19 this_image = get_image('items', 'hand.png') |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
20 ImageButton.__init__(self, image=this_image, action=action) |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
21 self.selected = False # Flag if we're selected |
57
4f9d412d83db
Use hand icon from openclipart
Neil Muller <neil@dip.sun.ac.za>
parents:
49
diff
changeset
|
22 self.set_rect(Rect(0, 0, BUTTON_SIZE, BUTTON_SIZE)) |
36 | 23 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
24 def draw(self, surface): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
25 """Draw the widget""" |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
26 ImageButton.draw(self, surface) |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
27 if self.selected: |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
28 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
|
29 frame_rect(surface, self.sel_colour, rect, self.sel_width) |
36 | 30 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
31 def toggle_selected(self): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
32 self.selected = not self.selected |
36 | 33 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
34 def unselect(self): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
35 self.selected = False |
36 | 36 |