Mercurial > boomslang
view gamelib/hand.py @ 71:99c5506de7ea
Start of interact handling.
author | Simon Cross <hodgestar+bzr@gmail.com> |
---|---|
date | Mon, 23 Aug 2010 21:04:43 +0200 |
parents | 213e47dea4d0 |
children | c76f2fad2af5 |
line wrap: on
line source
# Button for the hand image from constants import BUTTON_SIZE from cursor import CursorWidget from albow.controls import ImageButton from albow.resource import get_image from albow.utils import frame_rect from pygame.color import Color from pygame.rect import Rect class HandButton(ImageButton, CursorWidget): """The fancy hand button for the widget""" sel_colour = Color('red') sel_width = 2 def __init__(self, action): # FIXME: Yes, please. this_image = get_image('items', 'hand.png') ImageButton.__init__(self, image=this_image, action=action) self.selected = False # Flag if we're selected self.set_rect(Rect(0, 0, BUTTON_SIZE, BUTTON_SIZE)) def draw(self, surface): """Draw the widget""" ImageButton.draw(self, surface) if self.selected: rect = surface.get_rect().inflate(-self.sel_width, -self.sel_width) frame_rect(surface, self.sel_colour, rect, self.sel_width) def toggle_selected(self): self.selected = not self.selected def unselect(self): self.selected = False