Mercurial > parpg-core
diff src/parpg/gui/containergui.py @ 137:140e5e93f026
Added ExamineContentsAction.
Added "Examine Contents" to the context menu, when the object is a container and does not have a characterstats component.
author | KarstenBock@gmx.net |
---|---|
date | Fri, 30 Sep 2011 15:31:53 +0200 |
parents | 1fd2201f5c36 |
children | b96607c8be7f |
line wrap: on
line diff
--- a/src/parpg/gui/containergui.py Fri Sep 30 15:08:53 2011 +0200 +++ b/src/parpg/gui/containergui.py Fri Sep 30 15:31:53 2011 +0200 @@ -14,7 +14,7 @@ from parpg.gui.containergui_base import ContainerGUIBase from parpg.gui import drag_drop_data as data_drag -from parpg.objects.base import Container +from parpg.components import container class ContainerGUI(ContainerGUIBase): def __init__(self, controller, title, container): @@ -24,7 +24,7 @@ @param title: The title of the window @type title: string @param container: A container to represent - @type container: Container + @type container: parpg.components.Container @return: None""" super(ContainerGUI, self).__init__(controller, "gui/container_base.xml") self.gui.findChild(name="topWindow").title = title @@ -38,15 +38,15 @@ def updateImages(self): for index, button in enumerate(self.buttons): - widget = self.gui.findChild(name=button) - widget.item = self.container.getItemAt(index) + widget = self.gui.findChild(name=button) + widget.item = container.get_item(self.container, index) self.updateImage(widget) def updateImage(self, button): if (button.item == None): image = self.empty_images[button.name] else: - image = button.item.getInventoryThumbnail() + image = button.item.image button.up_image = image button.down_image = image button.hover_image = image @@ -73,8 +73,7 @@ data_drag.dragging = True data_drag.dragged_widget = drag_widget data_drag.source_container = self.container - - self.container.takeItem(drag_widget.item) + container.take_item(self.container, drag_widget.item.slot) # after dragging the 'item', set the widgets' images # so that it has it's default 'empty' images @@ -90,16 +89,15 @@ try: drop_widget = self.gui.findChild(name = obj) drop_index = drop_widget.index - replace_item = drop_widget.item + replace_item = None if data_drag.dragging: - container = self.container drag_item = data_drag.dragged_item #this will get the replacement item and the data for drag_drop if ## there is an item all ready occupying the slot - if replace_item != None: - self.dragObject(obj) - container.placeItem(drag_item, drop_index) + replace_item = ( + container.put_item(self.container, drag_item, drop_index) + ) drop_widget.item = drag_item self.updateImage(drop_widget) @@ -108,7 +106,7 @@ data_drag.dragging = False #reset the mouse cursor to the normal cursor self.controller.resetMouseCursor() - except (Container.SlotBusy, Container.TooBig, Container.ItemSelf): + except (container.BulkLimitError): #Do we want to notify the player why the item can't be dropped? pass @@ -120,10 +118,11 @@ slot_count = 9 for counter in range(1, slot_count+1): slot_name = "Slot%i" % counter + index = counter - 1 self.empty_images[slot_name] = empty_image widget = self.gui.findChild(name=slot_name) - widget.item = self.container.items.get(counter-1) - widget.index = counter-1 + widget.item = container.get_item(self.container, index) + widget.index = index self.updateImage(widget) self.events_to_map[slot_name] = cbwa(self.dragDrop, slot_name) self.events_to_map[slot_name + "/mouseReleased"] = \