comparison gui/containergui.py @ 124:ef24560eb920

Fixed bug that dropping an item onto another would not set the drag_data to the replaced item, which caused this to be lost.
author KarstenBock@gmx.net
date Thu, 06 Oct 2011 16:08:00 +0200
parents 100a39fa64a2
children c28e29056218
comparison
equal deleted inserted replaced
123:1efe0c42927f 124:ef24560eb920
65 # get the item that the widget is 'storing' 65 # get the item that the widget is 'storing'
66 data_drag.dragged_item = drag_widget.item 66 data_drag.dragged_item = drag_widget.item
67 # get the up and down images of the widget 67 # get the up and down images of the widget
68 up_image = drag_widget.up_image 68 up_image = drag_widget.up_image
69 down_image = drag_widget.down_image 69 down_image = drag_widget.down_image
70 # set the mouse cursor to be the widget's image 70 self.setDragData(drag_widget.item, down_image, up_image,
71 self.controller.setMouseCursor(up_image.source, down_image.source) 71 self.container)
72 data_drag.dragged_image = up_image.source
73 data_drag.dragging = True
74 data_drag.dragged_widget = drag_widget
75 data_drag.source_container = self.container
76 container.take_item(self.container, drag_widget.item.slot) 72 container.take_item(self.container, drag_widget.item.slot)
77 73
78 # after dragging the 'item', set the widgets' images 74 # after dragging the 'item', set the widgets' images
79 # so that it has it's default 'empty' images 75 # so that it has it's default 'empty' images
80 drag_widget.item = None 76 drag_widget.item = None
97 ## there is an item all ready occupying the slot 93 ## there is an item all ready occupying the slot
98 replace_item = ( 94 replace_item = (
99 container.put_item(self.container, drag_item, drop_index) 95 container.put_item(self.container, drag_item, drop_index)
100 ) 96 )
101 97
102 drop_widget.item = drag_item
103 self.updateImage(drop_widget)
104 #if there was no item the stop dragging and reset cursor 98 #if there was no item the stop dragging and reset cursor
105 if replace_item == None: 99 if replace_item:
100 up_image = drop_widget.up_image
101 down_image = drop_widget.down_image
102 self.setDragData(replace_item, down_image, up_image,
103 self.container)
104 else:
106 data_drag.dragging = False 105 data_drag.dragging = False
107 #reset the mouse cursor to the normal cursor 106 #reset the mouse cursor to the normal cursor
108 self.controller.resetMouseCursor() 107 self.controller.resetMouseCursor()
108 drop_widget.item = drag_item
109 self.updateImage(drop_widget)
109 except (container.BulkLimitError): 110 except (container.BulkLimitError):
110 #Do we want to notify the player why the item can't be dropped? 111 #Do we want to notify the player why the item can't be dropped?
111 pass 112 pass
112 113
113 def showContainer(self): 114 def showContainer(self):