Mercurial > boomslang
comparison gamelib/gamescreen.py @ 106:da547e148532
Some (slightly) better cursor handling.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Tue, 24 Aug 2010 13:53:49 +0200 |
parents | 65976205fc2d |
children | 5213b45fcc7e |
comparison
equal
deleted
inserted
replaced
105:65976205fc2d | 106:da547e148532 |
---|---|
18 from popupmenu import PopupMenu, PopupMenuButton | 18 from popupmenu import PopupMenu, PopupMenuButton |
19 from state import initial_state, Item | 19 from state import initial_state, Item |
20 from widgets import BoomLabel | 20 from widgets import BoomLabel |
21 | 21 |
22 | 22 |
23 class InventoryView(PaletteView): | 23 class InventoryView(PaletteView, CursorWidget): |
24 | 24 |
25 sel_color = Color("yellow") | 25 sel_color = Color("yellow") |
26 sel_width = 2 | 26 sel_width = 2 |
27 | 27 |
28 def __init__(self, state, handbutton): | 28 def __init__(self, state, handbutton): |
29 CursorWidget.__init__(self) | |
29 PaletteView.__init__(self, (BUTTON_SIZE, BUTTON_SIZE), 1, 6, scrolling=True) | 30 PaletteView.__init__(self, (BUTTON_SIZE, BUTTON_SIZE), 1, 6, scrolling=True) |
30 self.state = state | 31 self.state = state |
31 self.handbutton = handbutton | 32 self.handbutton = handbutton |
32 | 33 |
33 def num_items(self): | 34 def num_items(self): |
34 return len(self.state.inventory) | 35 return len(self.state.inventory) |
35 | 36 |
36 def draw_item(self, surface, item_no, rect): | 37 def draw_item(self, surface, item_no, rect): |
37 item_image = self.state.inventory[item_no].get_inventory_image() | 38 item_image = self.state.inventory[item_no].get_inventory_image() |
38 surface.blit(item_image, rect, None, BLEND_ADD) | 39 surface.blit(item_image, rect, None, BLEND_ADD) |
40 | |
41 def draw(self, surface): | |
42 PaletteView.draw(self, surface) | |
43 CursorWidget.draw(self, surface) | |
39 | 44 |
40 def click_item(self, item_no, event): | 45 def click_item(self, item_no, event): |
41 self.state.set_tool(self.state.inventory[item_no]) | 46 self.state.set_tool(self.state.inventory[item_no]) |
42 self.handbutton.unselect() | 47 self.handbutton.unselect() |
43 | 48 |