Mercurial > pyntnclick
comparison pyntnclick/gamescreen.py @ 650:7cc0da0a4633 pyntnclick
Hook in the (still pretty useless) inventory widget.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 12 Feb 2012 12:33:04 +0200 |
parents | 96daa4119745 |
children | 122204fb6eb1 |
comparison
equal
deleted
inserted
replaced
649:e59b119bb0f9 | 650:7cc0da0a4633 |
---|---|
26 | 26 |
27 sel_color = Color("yellow") | 27 sel_color = Color("yellow") |
28 sel_width = 2 | 28 sel_width = 2 |
29 | 29 |
30 def __init__(self, gd, screen): | 30 def __init__(self, gd, screen): |
31 super(InventoryView, self).__init__(Rect((0, 0) + screen.surface_size), | 31 rect = Rect((0, screen.surface_size[1] - gd.constants.button_size), |
32 gd) | 32 (screen.surface_size[0], gd.constants.button_size)) |
33 super(InventoryView, self).__init__(rect, gd) | |
33 self.screen = screen | 34 self.screen = screen |
34 self.game = screen.game | 35 self.game = screen.game |
35 self.state_widget = screen.state_widget | 36 self.state_widget = screen.state_widget |
37 self.add_callback(MOUSEBUTTONDOWN, self.mouse_down) | |
36 | 38 |
37 def num_items(self): | 39 def num_items(self): |
38 return len(self.game.inventory) | 40 return len(self.game.inventory) |
39 | 41 |
40 def draw_item(self, surface, item_no, rect): | 42 def draw_item(self, surface, item_no, rect): |
49 result = item.interact(self.game.tool) | 51 result = item.interact(self.game.tool) |
50 handle_result(result, self.state_widget) | 52 handle_result(result, self.state_widget) |
51 else: | 53 else: |
52 self.game.set_tool(self.game.inventory[item_no]) | 54 self.game.set_tool(self.game.inventory[item_no]) |
53 | 55 |
54 def mouse_down(self, event): | 56 def mouse_down(self, event, widget): |
55 if event.button != 1: | 57 if event.button != 1: |
56 self.game.cancel_doodah(self.screen) | 58 return self.game.cancel_doodah(self.screen) |
57 else: | 59 print "CLICKED!", self.game.inventory, event |
58 PaletteView.mouse_down(self, event) | |
59 | 60 |
60 def item_is_selected(self, item_no): | 61 def item_is_selected(self, item_no): |
61 return self.game.tool is self.game.inventory[item_no] | 62 return self.game.tool is self.game.inventory[item_no] |
62 | 63 |
63 def unselect(self): | 64 def unselect(self): |
249 # action=self.popup_menu.show_menu) | 250 # action=self.popup_menu.show_menu) |
250 | 251 |
251 # XXX: self.handbutton = HandButton(action=self.hand_pressed) | 252 # XXX: self.handbutton = HandButton(action=self.hand_pressed) |
252 | 253 |
253 self.inventory = InventoryView(self.gd, self) | 254 self.inventory = InventoryView(self.gd, self) |
255 self.container.add(self.inventory) | |
254 | 256 |
255 # XXX: self.toolbar = ToolBar([ | 257 # XXX: self.toolbar = ToolBar([ |
256 # self.menubutton, | 258 # self.menubutton, |
257 # self.handbutton, | 259 # self.handbutton, |
258 # self.inventory, | 260 # self.inventory, |