comparison gamelib/gamescreen.py @ 411:0fc208423b98

Fixed inventory drawing.
author Jeremy Thurgood <firxen@gmail.com>
date Sat, 28 Aug 2010 22:16:58 +0200
parents c7a6846262e3
children 3dab4984cbd7
comparison
equal deleted inserted replaced
410:fd1168a39700 411:0fc208423b98
31 def num_items(self): 31 def num_items(self):
32 return len(self.state.inventory) 32 return len(self.state.inventory)
33 33
34 def draw_item(self, surface, item_no, rect): 34 def draw_item(self, surface, item_no, rect):
35 item_image = self.state.inventory[item_no].get_inventory_image() 35 item_image = self.state.inventory[item_no].get_inventory_image()
36 surface.blit(item_image, rect, None, BLEND_ADD) 36 surface.blit(item_image, rect, None)
37 37
38 def click_item(self, item_no, event): 38 def click_item(self, item_no, event):
39 item = self.state.inventory[item_no] 39 item = self.state.inventory[item_no]
40 if self.item_is_selected(item_no): 40 if self.item_is_selected(item_no):
41 self.unselect() 41 self.unselect()
47 47
48 def mouse_down(self, event): 48 def mouse_down(self, event):
49 if event.button != 1: 49 if event.button != 1:
50 self.state.cancel_doodah(self.screen) 50 self.state.cancel_doodah(self.screen)
51 else: 51 else:
52 PaletteView.handle_mouse(self, event) 52 PaletteView.mouse_down(self, event)
53 53
54 def item_is_selected(self, item_no): 54 def item_is_selected(self, item_no):
55 return self.state.tool is self.state.inventory[item_no] 55 return self.state.tool is self.state.inventory[item_no]
56 56
57 def unselect(self): 57 def unselect(self):
176 class ToolBar(Row): 176 class ToolBar(Row):
177 def __init__(self, items): 177 def __init__(self, items):
178 for item in items: 178 for item in items:
179 item.height = BUTTON_SIZE 179 item.height = BUTTON_SIZE
180 Row.__init__(self, items, spacing=0, width=SCREEN[0]) 180 Row.__init__(self, items, spacing=0, width=SCREEN[0])
181 self.bg_color = (127, 127, 127) 181 self.bg_color = (31, 31, 31)
182
183 def draw(self, surface):
184 surface.fill(self.bg_color)
185 Row.draw(self, surface)
182 186
183 187
184 class GameScreen(Screen, CursorWidget): 188 class GameScreen(Screen, CursorWidget):
185 def __init__(self, shell): 189 def __init__(self, shell):
186 CursorWidget.__init__(self, self) 190 CursorWidget.__init__(self, self)