comparison clients/editor/plugins/objectedit.py @ 211:f10a2e78a0e1

- updated objectedit plugin, should work much better now - removed data records from objectedit plugin (way too buggy & ugly) - removed obsolete plugin data from settings.py NOTE: - the sliders for offset manipulation don't work ATM
author chewie@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 16 Mar 2009 14:40:36 +0000
parents 28532ae6f9f6
children
comparison
equal deleted inserted replaced
210:be246fb3a0df 211:f10a2e78a0e1
20 # along with this program; if not, write to the 20 # along with this program; if not, write to the
21 # Free Software Foundation, Inc., 21 # Free Software Foundation, Inc.,
22 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 # ################################################### 23 # ###################################################
24 24
25 """ a tool for FIFEdit to edit object and instance attributes """
26
25 import fife 27 import fife
26 import plugin 28 import plugin
27 import pychan 29 import pychan
28 import pychan.widgets as widgets 30 import pychan.widgets as widgets
29 from pychan.tools import callbackWithArguments as cbwa 31 from pychan.tools import callbackWithArguments as cbwa
30 32
31 import settings as Settings 33 import settings as Settings
34 import math
32 35
33 class ObjectEdit(plugin.Plugin): 36 class ObjectEdit(plugin.Plugin):
37 """ The B{ObjectEdit} module is a plugin for FIFedit and allows to edit
38 attributes of an selected instance - like offset, instance id or rotation
39 (namespaces and object id editing is excluded)
40
41 current features:
42 - click instance and get all known data
43 - edit offsets, rotation, instance id
44 - outline highlighting of the selected object
45
46 missing features:
47 - blocking flag (flag doesn't work yet from FIFE side)
48 - static flag (flag doesn't work yet from FIFE side)
49 - object saving
50 - a lot of bug fixing concerning the rotation
51 - use sliders to allow offset changes
52 - the module should be able to use the editors global undo history
53
54 FIXME:
55 - this module owns a pointer to the mapedit module - this shouldn't be
56 necessary; a better plugin system of fifedit should only hand over the needed
57 data (selected instance)
58 - we also need to edit run.py of the editor core to make this plugin work (shouldn't be necessary, too)
59 """
34 def __init__(self, engine, mapedit): 60 def __init__(self, engine, mapedit):
35 """
36 ObjectEdit plugin for FIFEdit
37
38 Mission: provide a gui mask to edit all important object data within the editor
39 (id, offsets, rotation, blocking, static)
40
41 namespaces and object ids are excluded
42
43 Current features:
44 - click instance and get all known data
45 - edit offsets, rotation, blocking, static
46 - outline highlighting of the selected object
47 - 3 data states: current, previous and default (so there is at least a one-step-undo)
48
49 Missing features:
50 - object saving
51 - id saving (handled by Fifedit via save map, but we have to set the id from here)
52 - a lot of bug fixing concerning the rotation and the data records ^^
53 - cleanup
54
55 NOTE:
56 - this tool isn't ready for a working enviroment (yet)
57 """
58 # Fifedit plugin data 61 # Fifedit plugin data
59 self.menu_items = { 'ObjectEdit' : self.toggle_offsetedit } 62 self.menu_items = { 'ObjectEdit' : self.toggle_offsetedit }
60 63
61 self._mapedit = mapedit 64 self._mapedit = mapedit
62 65
63 # FIXME
64 # this is _very bad_ - but I need to change the current rotation code by providing 66 # this is _very bad_ - but I need to change the current rotation code by providing
65 # project specific rotation angles. FIFE later should provide a list of the loaded 67 # project specific rotation angles. FIFE later should provide a list of the loaded
66 # object rotations (they are provided by the xml files, so we just need to use them...) 68 # object rotations (they are provided by the xml files, so we just need to use them...)
67 self._mapedit._objectedit_rotations = None 69 self._mapedit._objectedit_rotations = None
68 # end FIXME 70
69 self.active = False 71 self.active = False
72 self._camera = None
73 self._layer = None
74
75 self.offset_slider = {}
76 self.offset_slider['x'] = False
77 self.offset_slider['y'] = False
70 78
71 self.imagepool = engine.getImagePool() 79 self.imagepool = engine.getImagePool()
72 self.animationpool = engine.getAnimationPool() 80 self.animationpool = engine.getAnimationPool()
73
74 self._camera = None
75 self._layer = None
76 81
77 self.guidata = {} 82 self.guidata = {}
78 self.objectdata = {} 83 self.objectdata = {}
79 84
80 self._reset() 85 self._reset()
81 self.create_gui() 86 self.create_gui()
82 87
83
84 def _reset(self): 88 def _reset(self):
85 """ 89 """
86 resets all dynamic vars, but leaves out static ones (e.g. camera, layer) 90 resets all dynamic vars, but leaves out static ones (e.g. camera, layer)
87 91
88 """ 92 """
89 self._instances = None 93 self._instances = None
90 self._image = None 94 self._image = None
95 self._image_default_x_offset = None
96 self._image_default_y_offset = None
91 self._animation = False 97 self._animation = False
92 self._rotation = None 98 self._rotation = None
93 self._avail_rotations = [] 99 self._avail_rotations = []
94 self._namespace = None 100 self._namespace = None
95 self._blocking = 0 101 self._blocking = 0
96 self._static = 0 102 self._static = 0
97 self._object_id = None 103 self._object_id = None
98 self._instance_id = None 104 self._instance_id = None
99 self._fixed_rotation = None 105 self._fixed_rotation = None
100 106
101 self.guidata['instance_id'] = 'None'
102 self.guidata['object_id'] = 'None'
103 self.guidata['x_offset'] = 0
104 self.guidata['y_offset'] = 0
105 self.guidata['instance_rotation'] = 0
106 self.guidata['namespace'] = 'None'
107 self.guidata['blocking'] = 0
108 self.guidata['static'] = 0
109
110 if self._camera is not None: 107 if self._camera is not None:
111 self.renderer.removeAllOutlines() 108 self.renderer.removeAllOutlines()
112 109
113 def create_gui(self): 110 def create_gui(self):
114 """ 111 """
115 - creates the gui skeleton by loading the xml file 112 - creates the gui skeleton by loading the xml file
116 - finds some important childs and saves their widget in the object 113 - finds some important childs and saves their widget in the object
117 """ 114 """
118 self.container = pychan.loadXML('gui/offsetedit.xml') 115 self.container = pychan.loadXML('gui/objectedit.xml')
119 self.container.mapEvents({ 116 self.container.mapEvents({
120 'x_offset_up' : cbwa(self.change_offset_x, 1), 117 'x_offset_up' : cbwa(self.change_offset_x, 1),
121 'x_offset_dn' : cbwa(self.change_offset_x, -1), 118 'x_offset_dn' : cbwa(self.change_offset_x, -1),
122 119
123 'y_offset_up' : cbwa(self.change_offset_y, 1), 120 'y_offset_up' : cbwa(self.change_offset_y, 1),
124 'y_offset_dn' : cbwa(self.change_offset_y, -1), 121 'y_offset_dn' : cbwa(self.change_offset_y, -1),
125 122
126 'use_data' : cbwa(self.use_user_data), 123 'x_offset_slider' : cbwa(self.get_slider_value, "x"),
127 'previous_data' : cbwa(self.load_previous_data), 124 'y_offset_slider' : cbwa(self.get_slider_value, "y"),
128 'default_data' : cbwa(self.load_default_data) 125
126 'use_data' : self.use_user_data,
127
129 }) 128 })
130 129
131 self._gui_anim_panel_wrapper = self.container.findChild(name="animation_panel_wrapper") 130 self._gui_anim_panel_wrapper = self.container.findChild(name="animation_panel_wrapper")
132 self._gui_anim_panel = self._gui_anim_panel_wrapper.findChild(name="animation_panel") 131 self._gui_anim_panel = self._gui_anim_panel_wrapper.findChild(name="animation_panel")
133 132
135 134
136 self._gui_rotation_dropdown = self.container.findChild(name="select_rotations") 135 self._gui_rotation_dropdown = self.container.findChild(name="select_rotations")
137 136
138 self._gui_xoffset_textfield = self.container.findChild(name="x_offset") 137 self._gui_xoffset_textfield = self.container.findChild(name="x_offset")
139 self._gui_yoffset_textfield = self.container.findChild(name="y_offset") 138 self._gui_yoffset_textfield = self.container.findChild(name="y_offset")
139
140 self._gui_instance_id_textfield = self.container.findChild(name="instance_id")
141
142 print "Steplength x slider", self.container.findChild(name="x_offset_slider").getStepLength()
143 print "Steplength y slider", self.container.findChild(name="y_offset_slider").getStepLength()
144 self.container.findChild(name="x_offset_slider").setStepLength(0.01)
145 self.container.findChild(name="y_offset_slider").setStepLength(0.01)
146 print "New steplength x slider", self.container.findChild(name="x_offset_slider").getStepLength()
147 print "New steplength y slider", self.container.findChild(name="y_offset_slider").getStepLength()
148
149 def get_slider_value(self, orientation):
150 """ get current slider value for offset manipulation """
151
152 slider_name = orientation + "_offset_slider"
153 widget = self.container.findChild(name=slider_name)
154 value = widget.getValue()
155
156 print "%s slider value: %s" % (orientation, str(value))
157
158 if value < 0:
159 self.offset_slider[orientation] = False
160 return
161
162 callback = getattr(self, "change_offset_" + orientation)
163
164 if self.offset_slider[orientation] == widget.getScaleStart():
165 self.set_default_offset(orientation)
166 self.offset_slider[orientation] = False
167 return
168 elif self.offset_slider[orientation] >= widget.getScaleEnd():
169 pass
170 elif self.offset_slider[orientation] < value:
171 callback(1)
172 elif self.offset_slider[orientation] > value :
173 callback(-1)
174
175 self.offset_slider[orientation] = value
176
177 def set_default_offset(self, axis):
178 """ set default image offset for given axis """
179 if axis == 'x':
180 self._image.setXShift(self._image_default_x_offset)
181 elif axis == 'y':
182 self._image.setYShift(self._image_default_y_offset)
140 183
141 def _get_gui_size(self): 184 def _get_gui_size(self):
142 """ 185 """
143 gets the current size of the gui window and calculates new position 186 gets the current size of the gui window and calculates new position
144 (atm top right corner) 187 (atm top right corner)
163 #self._gui_anim_panel_wrapper.resizeToContent() 206 #self._gui_anim_panel_wrapper.resizeToContent()
164 #self._gui_anim_panel_wrapper.addChild(self._gui_anim_panel) 207 #self._gui_anim_panel_wrapper.addChild(self._gui_anim_panel)
165 #self._gui_anim_panel_wrapper.resizeToContent() 208 #self._gui_anim_panel_wrapper.resizeToContent()
166 #except: 209 #except:
167 #pass 210 #pass
168 211
169 self.container.distributeInitialData({ 212 self.container.distributeInitialData({
170 'select_rotations' : self._avail_rotations, 213 'select_rotations' : self._avail_rotations,
171 'instance_id' : self.guidata['instance_id'], 214 'instance_id' : str( self._instances[0].getId() ),
172 'object_id' : self.guidata['object_id'], 215 'object_id' : str( self._object_id ),
173 'x_offset' : self.guidata['x_offset'], 216 'x_offset' : str( self._image.getXShift() ),
174 'y_offset' : self.guidata['y_offset'], 217 'y_offset' : str( self._image.getYShift() ),
175 'instance_rotation' : self.guidata['instance_rotation'], 218 'instance_rotation' : str( self._instances[0].getRotation() ),
176 'object_namespace' : self.guidata['namespace'], 219 'object_namespace' : str( self._namespace ),
177 'object_blocking' : self.guidata['blocking'], 220 'object_blocking' : str( self._blocking ),
178 'object_static' : self.guidata['static'], 221 'object_static' : str( self._static ),
179 }) 222 })
180 try: 223 try:
181 print self._avail_rotations 224 print self._avail_rotations
182 print self._fixed_rotation 225 print self._fixed_rotation
183 index = self._avail_rotations.index( str(self._fixed_rotation) ) 226 index = self._avail_rotations.index( str(self._fixed_rotation) )
222 """ 265 """
223 - callback for changing x offset 266 - callback for changing x offset
224 - changes x offset of current instance (image) 267 - changes x offset of current instance (image)
225 - updates gui 268 - updates gui
226 269
227 @param int value the modifier for the x offset 270 @type value: int
271 @param value: the modifier for the x offset
228 """ 272 """
229 if self._image is not None: 273 if self._image is not None:
230 self._image.setXShift(self._image.getXShift() + value) 274 self._image.setXShift(self._image.getXShift() + value)
231
232 self.guidata['x_offset'] = str( self._image.getXShift() )
233 self.update_gui() 275 self.update_gui()
234 276
235 def change_offset_y(self, value=1): 277 def change_offset_y(self, value=1):
236 """ 278 """
237 - callback for changing y offset 279 - callback for changing y offset
238 - changes y offset of current instance (image) 280 - changes y offset of current instance (image)
239 - updates gui 281 - updates gui
240 282
241 @param int value the modifier for the y offset 283 @type value: int
284 @param value: the modifier for the y offset
242 """ 285 """
243 if self._image is not None: 286 if self._image is not None:
244 self._image.setYShift(self._image.getYShift() + value) 287 self._image.setYShift(self._image.getYShift() + value)
245
246 self.guidata['y_offset'] = str( self._image.getYShift() )
247 self.update_gui() 288 self.update_gui()
248 289
249 def use_user_data(self): 290 def use_user_data(self):
250 """ 291 """
251 - takes the users values and applies them directly to the current ._instance 292 - takes the users values and applies them directly to the current ._instance
256 FIXME: 297 FIXME:
257 - parse user data in case user think strings are considered to be integer offset values... 298 - parse user data in case user think strings are considered to be integer offset values...
258 """ 299 """
259 xoffset = self._gui_xoffset_textfield._getText() 300 xoffset = self._gui_xoffset_textfield._getText()
260 yoffset = self._gui_yoffset_textfield._getText() 301 yoffset = self._gui_yoffset_textfield._getText()
302
303 instance_id = self._gui_instance_id_textfield._getText()
304 if instance_id is not None and instance_id is not "None":
305 existing_instances = self._mapedit._layer.getInstances(instance_id)
306 if existing_instances == ():
307 self._instances[0].setId(instance_id)
308 print "Set new instance id: ", instance_id
309 else:
310 for i in existing_instances:
311 print i
261 312
262 # workaround - dropdown list only has 2 entries, but sends 3 -> pychan bug? 313 # workaround - dropdown list only has 2 entries, but sends 3 -> pychan bug?
263 if len(self._avail_rotations) < self._gui_rotation_dropdown._getSelected(): 314 if len(self._avail_rotations) < self._gui_rotation_dropdown._getSelected():
264 index = len(self._avail_rotations) 315 index = len(self._avail_rotations)
265 else: 316 else:
282 try: 333 try:
283 self._image.setYShift( int(yoffset) ) 334 self._image.setYShift( int(yoffset) )
284 except: 335 except:
285 pass 336 pass
286 # print "y offset must be of type int!" 337 # print "y offset must be of type int!"
287 338
288 self.write_current_data()
289 self.objectdata[self._namespace][self._object_id]['previous'] = self.objectdata[self._namespace][self._object_id]['current'].copy()
290 self.update_gui() 339 self.update_gui()
291 340
292 def load_previous_data(self):
293 """
294 - writes a copy of the previous record back to the current record (aka one-step-undo)
295 - loads current data into class object
296 - updates gui
297 """
298 self.objectdata[self._namespace][self._object_id]['current'] = self.objectdata[self._namespace][self._object_id]['previous'].copy()
299 self.load_current_data()
300 self.update_gui()
301
302 def load_default_data(self):
303 """
304 - writes a copy of the default record back to the current record
305 - loads current data into class object
306 - updates gui
307 """
308 self.objectdata[self._namespace][self._object_id]['current'] = self.objectdata[self._namespace][self._object_id]['default'].copy()
309 self.load_current_data()
310 self.update_gui()
311
312 def load_current_data(self):
313 """
314 loads the current record into class object
315 """
316 self._image = self.objectdata[self._namespace][self._object_id]['current']['image']
317 self._animation = self.objectdata[self._namespace][self._object_id]['current']['animation']
318 self._rotation = self.objectdata[self._namespace][self._object_id]['current']['rotation']
319 self._fixed_rotation = self.objectdata[self._namespace][self._object_id]['current']['fixed_rotation']
320 self._avail_rotations = self.objectdata[self._namespace][self._object_id]['current']['avail_rotations']
321 self._blocking = self.objectdata[self._namespace][self._object_id]['current']['blocking']
322 self._static = self.objectdata[self._namespace][self._object_id]['current']['static']
323 self._instance_id = self.objectdata[self._namespace][self._object_id]['current']['instance_id']
324 self._image.setXShift( self.objectdata[self._namespace][self._object_id]['current']['xoffset'] )
325 self._image.setYShift( self.objectdata[self._namespace][self._object_id]['current']['yoffset'] )
326
327 self.write_current_guidata()
328
329 def write_current_data(self):
330 """
331 updates the current record
332 """
333 self.objectdata[self._namespace][self._object_id]['current']['instance'] = self._instances[0]
334 self.objectdata[self._namespace][self._object_id]['current']['image'] = self._image
335 self.objectdata[self._namespace][self._object_id]['current']['animation'] = self._animation
336 self.objectdata[self._namespace][self._object_id]['current']['rotation'] = self._rotation
337 self.objectdata[self._namespace][self._object_id]['current']['fixed_rotation'] = self._fixed_rotation
338 self.objectdata[self._namespace][self._object_id]['current']['avail_rotations'] = self._avail_rotations
339 self.objectdata[self._namespace][self._object_id]['current']['blocking'] = self._blocking
340 self.objectdata[self._namespace][self._object_id]['current']['static'] = self._static
341 self.objectdata[self._namespace][self._object_id]['current']['instance_id'] = self._instance_id
342 self.objectdata[self._namespace][self._object_id]['current']['xoffset'] = self._image.getXShift()
343 self.objectdata[self._namespace][self._object_id]['current']['yoffset'] = self._image.getYShift()
344
345 self.write_current_guidata()
346
347 def write_current_guidata(self):
348 """
349 updates the gui data with
350 """
351 self.guidata['instance_rotation'] = str( self._instances[0].getRotation() )
352 self.guidata['object_id'] = str( self._object_id )
353 self.guidata['instance_id'] = str( self._instance_id )
354 self.guidata['x_offset'] = str( self._image.getXShift() )
355 self.guidata['y_offset'] = str( self._image.getYShift() )
356 self.guidata['namespace'] = self._namespace
357 self.guidata['blocking'] = str( self._blocking )
358 self.guidata['static'] = str( self._static )
359
360 def get_instance_data(self, timestamp=None, frame=None, angle=-1, instance=None): 341 def get_instance_data(self, timestamp=None, frame=None, angle=-1, instance=None):
361 """ 342 """
362 - grabs all available data from both object and instance 343 - grabs all available data from both object and instance
363 - checks if we already hold a record (namespace + object id) 344 - checks if we already hold a record (namespace + object id)
364 345
375 356
376 object = instance.getObject() 357 object = instance.getObject()
377 self._namespace = object.getNamespace() 358 self._namespace = object.getNamespace()
378 self._object_id = object.getId() 359 self._object_id = object.getId()
379 360
380 if angle != -1: 361 self._instance_id = instance.getId()
381 del self.objectdata[self._namespace][self._object_id] 362
382 363 if self._instance_id == '':
383 if not self.objectdata.has_key(self._namespace): 364 self._instance_id = 'None'
384 self.objectdata[self._namespace] = {} 365
385 366 if angle == -1:
386 if not self.objectdata[self._namespace].has_key(self._object_id): 367 angle = int(instance.getRotation())
387 self.objectdata[self._namespace][self._object_id] = {} 368 else:
388 369 angle = int(angle)
389 # we hold 3 versions of the data: current, previous, default 370
390 # default is only set one time, current and previous are changing data 371 self._rotation = angle
391 # due to the users actions 372
392 self.objectdata[self._namespace][self._object_id]['current'] = {} 373 if object.isBlocking():
393 self.objectdata[self._namespace][self._object_id]['previous'] = {} 374 self._blocking = 1
394 375
395 self._instance_id = instance.getId() 376 if object.isStatic():
396 377 self._static = 1
397 if self._instance_id == '': 378
398 self._instance_id = 'None' 379 try:
399 380 visual = object.get2dGfxVisual()
400 if angle == -1: 381 except:
401 angle = int(instance.getRotation()) 382 print 'Fetching visual of object - failed. :/'
402 else: 383 raise
403 angle = int(angle) 384
385 # print "Camera Tilt: ", self._camera.getTilt()
386 # print "Camera Rotation: ", self._camera.getRotation()
387
388 self._fixed_rotation = int(instance.getRotation() + abs( self._camera.getTilt() ) )
389 self._fixed_rotation = visual.getClosestMatchingAngle(self._fixed_rotation)
390
391 index = visual.getStaticImageIndexByAngle(self._fixed_rotation)
392
393 if index == -1:
394 # object is an animation
395 self._animation = True
396 # no static image available, try default action
397 action = object.getDefaultAction()
398 if action:
399 animation_id = action.get2dGfxVisual().getAnimationIndexByAngle(self._fixed_rotation)
400 animation = self.animationpool.getAnimation(animation_id)
401 # if timestamp is None and frame is not None:
402 # self._image = animation.getFrame(frame)
403 # elif timestamp is not None and frame is None:
404 # self._image = animation.getFrameByTimestamp(timestamp)
405 # else:
406 self._image = animation.getFrameByTimestamp(0)
407 index = self._image.getPoolId()
408 elif index != -1:
409 # object is a static image
410 self._animation = False
411 self._image = self.imagepool.getImage(index)
412
413 if not self._animation:
414 rotation_tuple = visual.getStaticImageAngles()
415 for angle in rotation_tuple:
416 self._avail_rotations.append( str(angle) )
404 417
405 self._rotation = angle 418 self._image_default_x_offset = self._image.getXShift()
406 419 self._image_default_y_offset = self._image.getYShift()
407 if object.isBlocking():
408 self._blocking = 1
409
410 if object.isStatic():
411 self._static = 1
412
413 try:
414 visual = object.get2dGfxVisual()
415 except:
416 print 'Fetching visual of object - failed. :/'
417 raise
418
419 self._fixed_rotation = int(instance.getRotation() + abs( self._camera.getTilt() ) )
420 self._fixed_rotation = visual.getClosestMatchingAngle(self._fixed_rotation)
421
422 index = visual.getStaticImageIndexByAngle(self._fixed_rotation)
423
424 if index == -1:
425 # object is an animation
426 self._animation = True
427 # no static image available, try default action
428 action = object.getDefaultAction()
429 if action:
430 animation_id = action.get2dGfxVisual().getAnimationIndexByAngle(self._fixed_rotation)
431 animation = self.animationpool.getAnimation(animation_id)
432 if timestamp is None and frame is not None:
433 self._image = animation.getFrame(frame)
434 elif timestamp is not None and frame is None:
435 self._image = animation.getFrameByTimestamp(timestamp)
436 else:
437 self._image = animation.getFrameByTimestamp(0)
438 index = self._image.getPoolId()
439 elif index != -1:
440 # object is a static image
441 self._animation = False
442 self._image = self.imagepool.getImage(index)
443
444 if self._animation:
445 self._avail_rotations = Settings.RotAngles['animations']
446 else:
447 rotation_tuple = visual.getStaticImageAngles()
448 for angle in rotation_tuple:
449 self._avail_rotations.append( str(angle) )
450 420
451 # FIXME: see l. 40 421 # FIXME: see l. 40
452 self._mapedit._objectedit_rotations = self._avail_rotations 422 self._mapedit._objectedit_rotations = self._avail_rotations
453 # end FIXME 423 # end FIXME
454 self.write_current_data()
455
456 self.objectdata[self._namespace][self._object_id]['default'] = {}
457 self.objectdata[self._namespace][self._object_id]['default'] = self.objectdata[self._namespace][self._object_id]['current'].copy()
458 self.objectdata[self._namespace][self._object_id]['previous'] = self.objectdata[self._namespace][self._object_id]['current'].copy()
459
460 self.write_current_guidata()
461 else:
462 self.load_current_data()
463
464 def dump_objectdata(self):
465 """
466 just a useful dumper ^^
467 """
468 print "#"*4, "Dump of objectdata", "#"*4, "\n"
469 for namespace in self.objectdata:
470 print "namespace: ", namespace
471 for key in self.objectdata[namespace]:
472 print "\tkey: ", key
473 for item in self.objectdata[namespace][key]:
474 if len(item) >= 9:
475 tab = "\t"*1
476 else:
477 tab = "\t"*2
478 print "\t\t", item, " : ", tab, self.objectdata[namespace][key][item]
479 424
480 def input(self): 425 def input(self):
481 """ 426 """
482 if called _and_ the user wishes to edit offsets, 427 if called _and_ the user wishes to edit offsets,
483 gets instance data and show gui 428 gets instance data and show gui
484 429
485 (see run.py, pump() ) 430 (see run.py, pump() )
486 """ 431 """
487 if self._mapedit._instances != self._instances: 432 if self._mapedit._instances != self._instances:
488 if self.active is True: 433 if self.active is True:
434 self._reset()
489 self._instances = self._mapedit._instances 435 self._instances = self._mapedit._instances
490 436
491 if self._camera is None: 437 if self._camera is None:
492 self._camera = self._mapedit._camera 438 self._camera = self._mapedit._camera
493 self.renderer = fife.InstanceRenderer.getInstance(self._camera) 439 self.renderer = fife.InstanceRenderer.getInstance(self._camera)
495 self._layer = self._mapedit._layer 441 self._layer = self._mapedit._layer
496 442
497 if self._instances != (): 443 if self._instances != ():
498 self.highlight_selected_instance() 444 self.highlight_selected_instance()
499 self.get_instance_data() 445 self.get_instance_data()
500 446 self.update_gui()
501 if self._animation is False: 447 self.container.adaptLayout()
502 self.update_gui() 448 self.container.show()
503 self.container.adaptLayout() 449 self._get_gui_size()
504 self.container.show() 450 self.container._setPosition(self.position)
505 self._get_gui_size()
506 self.container._setPosition(self.position)
507 else:
508 self.container.hide()
509 print "Animation objects are not yet editable"
510 # self.dump_objectdata()
511 else: 451 else:
512 self._reset() 452 self._reset()
513 self.container.hide() 453 self.container.hide()