annotate clients/editor/plugins/objectedit.py @ 238:d76169461729

Removed HelpText from C++. Moved helptext to base widget. Now all widgets may have a helptext.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 24 Mar 2009 16:06:02 +0000
parents f10a2e78a0e1
children
rev   line source
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 #!/usr/bin/env python
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 # coding: utf-8
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 # ###################################################
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 # Copyright (C) 2008 The Zero-Projekt team
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 # http://zero-projekt.net
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 # info@zero-projekt.net
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 # This file is part of Zero "Was vom Morgen blieb"
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 #
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 # The Zero-Projekt codebase is free software; you can redistribute it and/or modify
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 # it under the terms of the GNU General Public License as published by
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 # the Free Software Foundation; either version 2 of the License, or
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 # (at your option) any later version.
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 #
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 # This program is distributed in the hope that it will be useful,
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 # GNU General Public License for more details.
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 #
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 # along with this program; if not, write to the
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21 # Free Software Foundation, Inc.,
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23 # ###################################################
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
25 """ a tool for FIFEdit to edit object and instance attributes """
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
26
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 import fife
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 import plugin
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 import pychan
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 import pychan.widgets as widgets
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 from pychan.tools import callbackWithArguments as cbwa
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 import settings as Settings
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
34 import math
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 class ObjectEdit(plugin.Plugin):
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
37 """ The B{ObjectEdit} module is a plugin for FIFedit and allows to edit
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
38 attributes of an selected instance - like offset, instance id or rotation
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
39 (namespaces and object id editing is excluded)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
40
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
41 current features:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
42 - click instance and get all known data
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
43 - edit offsets, rotation, instance id
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
44 - outline highlighting of the selected object
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
46 missing features:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
47 - blocking flag (flag doesn't work yet from FIFE side)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
48 - static flag (flag doesn't work yet from FIFE side)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
49 - object saving
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
50 - a lot of bug fixing concerning the rotation
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
51 - use sliders to allow offset changes
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
52 - the module should be able to use the editors global undo history
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
53
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
54 FIXME:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
55 - this module owns a pointer to the mapedit module - this shouldn't be
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
56 necessary; a better plugin system of fifedit should only hand over the needed
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
57 data (selected instance)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
58 - we also need to edit run.py of the editor core to make this plugin work (shouldn't be necessary, too)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
59 """
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
60 def __init__(self, engine, mapedit):
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 # Fifedit plugin data
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 self.menu_items = { 'ObjectEdit' : self.toggle_offsetedit }
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 self._mapedit = mapedit
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 # this is _very bad_ - but I need to change the current rotation code by providing
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 # project specific rotation angles. FIFE later should provide a list of the loaded
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 # object rotations (they are provided by the xml files, so we just need to use them...)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 self._mapedit._objectedit_rotations = None
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
70
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 self.active = False
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
72 self._camera = None
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
73 self._layer = None
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
74
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
75 self.offset_slider = {}
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
76 self.offset_slider['x'] = False
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
77 self.offset_slider['y'] = False
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 self.imagepool = engine.getImagePool()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 self.animationpool = engine.getAnimationPool()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 self.guidata = {}
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 self.objectdata = {}
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 self._reset()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 self.create_gui()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 def _reset(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90 resets all dynamic vars, but leaves out static ones (e.g. camera, layer)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 self._instances = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
94 self._image = None
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
95 self._image_default_x_offset = None
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
96 self._image_default_y_offset = None
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
97 self._animation = False
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98 self._rotation = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 self._avail_rotations = []
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100 self._namespace = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 self._blocking = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102 self._static = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 self._object_id = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 self._instance_id = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 self._fixed_rotation = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 if self._camera is not None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108 self.renderer.removeAllOutlines()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 def create_gui(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 - creates the gui skeleton by loading the xml file
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 - finds some important childs and saves their widget in the object
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114 """
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
115 self.container = pychan.loadXML('gui/objectedit.xml')
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 self.container.mapEvents({
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 'x_offset_up' : cbwa(self.change_offset_x, 1),
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 'x_offset_dn' : cbwa(self.change_offset_x, -1),
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 'y_offset_up' : cbwa(self.change_offset_y, 1),
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 'y_offset_dn' : cbwa(self.change_offset_y, -1),
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
123 'x_offset_slider' : cbwa(self.get_slider_value, "x"),
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
124 'y_offset_slider' : cbwa(self.get_slider_value, "y"),
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
125
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
126 'use_data' : self.use_user_data,
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
127
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 })
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130 self._gui_anim_panel_wrapper = self.container.findChild(name="animation_panel_wrapper")
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 self._gui_anim_panel = self._gui_anim_panel_wrapper.findChild(name="animation_panel")
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
133 self._gui_anim_panel_wrapper.removeChild(self._gui_anim_panel)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 self._gui_rotation_dropdown = self.container.findChild(name="select_rotations")
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137 self._gui_xoffset_textfield = self.container.findChild(name="x_offset")
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138 self._gui_yoffset_textfield = self.container.findChild(name="y_offset")
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
139
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
140 self._gui_instance_id_textfield = self.container.findChild(name="instance_id")
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
141
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
142 print "Steplength x slider", self.container.findChild(name="x_offset_slider").getStepLength()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
143 print "Steplength y slider", self.container.findChild(name="y_offset_slider").getStepLength()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
144 self.container.findChild(name="x_offset_slider").setStepLength(0.01)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
145 self.container.findChild(name="y_offset_slider").setStepLength(0.01)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
146 print "New steplength x slider", self.container.findChild(name="x_offset_slider").getStepLength()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
147 print "New steplength y slider", self.container.findChild(name="y_offset_slider").getStepLength()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
148
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
149 def get_slider_value(self, orientation):
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
150 """ get current slider value for offset manipulation """
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
151
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
152 slider_name = orientation + "_offset_slider"
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
153 widget = self.container.findChild(name=slider_name)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
154 value = widget.getValue()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
155
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
156 print "%s slider value: %s" % (orientation, str(value))
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
157
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
158 if value < 0:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
159 self.offset_slider[orientation] = False
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
160 return
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
161
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
162 callback = getattr(self, "change_offset_" + orientation)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
163
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
164 if self.offset_slider[orientation] == widget.getScaleStart():
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
165 self.set_default_offset(orientation)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
166 self.offset_slider[orientation] = False
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
167 return
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
168 elif self.offset_slider[orientation] >= widget.getScaleEnd():
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
169 pass
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
170 elif self.offset_slider[orientation] < value:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
171 callback(1)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
172 elif self.offset_slider[orientation] > value :
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
173 callback(-1)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
174
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
175 self.offset_slider[orientation] = value
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
176
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
177 def set_default_offset(self, axis):
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
178 """ set default image offset for given axis """
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
179 if axis == 'x':
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
180 self._image.setXShift(self._image_default_x_offset)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
181 elif axis == 'y':
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
182 self._image.setYShift(self._image_default_y_offset)
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 def _get_gui_size(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 gets the current size of the gui window and calculates new position
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 (atm top right corner)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
188 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189 size = self.container._getSize()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 self.position = ((Settings.ScreenWidth - 10 - size[0]), 10)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 def update_gui(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 updates the gui widgets with current instance data
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
195
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196 FIXME:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 - drop animation support or turn it into something useful
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 #if self._animation is False:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 #try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 #self._gui_anim_panel_wrapper.removeChild(self._gui_anim_panel)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 #except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
203 #pass
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204 #elif self._animation is True:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 #try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 #self._gui_anim_panel_wrapper.resizeToContent()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 #self._gui_anim_panel_wrapper.addChild(self._gui_anim_panel)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208 #self._gui_anim_panel_wrapper.resizeToContent()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209 #except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
210 #pass
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
211
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 self.container.distributeInitialData({
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213 'select_rotations' : self._avail_rotations,
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
214 'instance_id' : str( self._instances[0].getId() ),
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
215 'object_id' : str( self._object_id ),
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
216 'x_offset' : str( self._image.getXShift() ),
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
217 'y_offset' : str( self._image.getYShift() ),
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
218 'instance_rotation' : str( self._instances[0].getRotation() ),
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
219 'object_namespace' : str( self._namespace ),
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
220 'object_blocking' : str( self._blocking ),
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
221 'object_static' : str( self._static ),
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
222 })
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
223 try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
224 print self._avail_rotations
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
225 print self._fixed_rotation
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226 index = self._avail_rotations.index( str(self._fixed_rotation) )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
227 self._gui_rotation_dropdown._setSelected(index)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228 except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
229 # pass
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230 print "Angle (", self._fixed_rotation, ") not supported by this instance"
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 def toggle_gui(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234 show / hide the gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 FIXME:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
237 - ATM not in use, needs some additional code when showing / hiding the gui (see input() )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
239 if self.container.isVisible():
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240 self.container.hide()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
241 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
242 self.container.show()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
243
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
244 def toggle_offsetedit(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
245 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
246 - toggles the object editor activ / inactiv - just in case the user don't want to have
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
247 the gui popping up all the time while mapping :-)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
248 - hides gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250 if self.active is True:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251 self.active = False
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
252 if self.container.isVisible():
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253 self.container.hide()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 self.active = True
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 def highlight_selected_instance(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 just highlights selected instance
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261 self.renderer.removeAllOutlines()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 self.renderer.addOutlined(self._instances[0], 205, 205, 205, 1)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
263
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264 def change_offset_x(self, value=1):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 - callback for changing x offset
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
267 - changes x offset of current instance (image)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 - updates gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
269
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
270 @type value: int
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
271 @param value: the modifier for the x offset
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 if self._image is not None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 self._image.setXShift(self._image.getXShift() + value)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 self.update_gui()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 def change_offset_y(self, value=1):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 - callback for changing y offset
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
280 - changes y offset of current instance (image)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 - updates gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
282
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
283 @type value: int
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
284 @param value: the modifier for the y offset
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
285 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
286 if self._image is not None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
287 self._image.setYShift(self._image.getYShift() + value)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
288 self.update_gui()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
289
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
290 def use_user_data(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
291 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
292 - takes the users values and applies them directly to the current ._instance
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
293 - writes current data record
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
294 - writes previous data record
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
295 - updates gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
296
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
297 FIXME:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
298 - parse user data in case user think strings are considered to be integer offset values...
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
299 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
300 xoffset = self._gui_xoffset_textfield._getText()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
301 yoffset = self._gui_yoffset_textfield._getText()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
302
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
303 instance_id = self._gui_instance_id_textfield._getText()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
304 if instance_id is not None and instance_id is not "None":
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
305 existing_instances = self._mapedit._layer.getInstances(instance_id)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
306 if existing_instances == ():
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
307 self._instances[0].setId(instance_id)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
308 print "Set new instance id: ", instance_id
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
309 else:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
310 for i in existing_instances:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
311 print i
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
312
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
313 # workaround - dropdown list only has 2 entries, but sends 3 -> pychan bug?
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
314 if len(self._avail_rotations) < self._gui_rotation_dropdown._getSelected():
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
315 index = len(self._avail_rotations)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
316 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
317 index = self._gui_rotation_dropdown._getSelected()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
318
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
319 # strange, but this helps to rotate the image correctly to the value the user selected
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
320 angle = int( self._avail_rotations[index] )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
321 angle = int(angle - abs( self._camera.getTilt() ) )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
322 if angle == 360:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
323 angle = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
324
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325 self._instances[0].setRotation(angle)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
326 self.get_instance_data(None, None, angle)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
327
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
328 try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329 self._image.setXShift( int(xoffset) )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
330 except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
331 pass
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
332 # print "x offset must me of type int!"
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
333 try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
334 self._image.setYShift( int(yoffset) )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
335 except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
336 pass
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
337 # print "y offset must be of type int!"
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
338
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
339 self.update_gui()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
340
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
341 def get_instance_data(self, timestamp=None, frame=None, angle=-1, instance=None):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
342 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
343 - grabs all available data from both object and instance
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
344 - checks if we already hold a record (namespace + object id)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
345
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
346 FIXME:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
347 1.) we need to fix the instance rotation / rotation issue
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
348 2.) use correct instance rotations to store data for _each_ available rotation
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
349 3.) move record code out of this method
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
350 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
351 visual = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
352 self._avail_rotations = []
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
353
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
354 if instance is None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
355 instance = self._instances[0]
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
356
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
357 object = instance.getObject()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
358 self._namespace = object.getNamespace()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
359 self._object_id = object.getId()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
360
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
361 self._instance_id = instance.getId()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
362
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
363 if self._instance_id == '':
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
364 self._instance_id = 'None'
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
365
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
366 if angle == -1:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
367 angle = int(instance.getRotation())
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
368 else:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
369 angle = int(angle)
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
370
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
371 self._rotation = angle
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
372
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
373 if object.isBlocking():
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
374 self._blocking = 1
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
375
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
376 if object.isStatic():
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
377 self._static = 1
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
378
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
379 try:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
380 visual = object.get2dGfxVisual()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
381 except:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
382 print 'Fetching visual of object - failed. :/'
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
383 raise
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
384
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
385 # print "Camera Tilt: ", self._camera.getTilt()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
386 # print "Camera Rotation: ", self._camera.getRotation()
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
387
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
388 self._fixed_rotation = int(instance.getRotation() + abs( self._camera.getTilt() ) )
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
389 self._fixed_rotation = visual.getClosestMatchingAngle(self._fixed_rotation)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
390
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
391 index = visual.getStaticImageIndexByAngle(self._fixed_rotation)
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
392
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
393 if index == -1:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
394 # object is an animation
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
395 self._animation = True
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
396 # no static image available, try default action
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
397 action = object.getDefaultAction()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
398 if action:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
399 animation_id = action.get2dGfxVisual().getAnimationIndexByAngle(self._fixed_rotation)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
400 animation = self.animationpool.getAnimation(animation_id)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
401 # if timestamp is None and frame is not None:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
402 # self._image = animation.getFrame(frame)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
403 # elif timestamp is not None and frame is None:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
404 # self._image = animation.getFrameByTimestamp(timestamp)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
405 # else:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
406 self._image = animation.getFrameByTimestamp(0)
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
407 index = self._image.getPoolId()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
408 elif index != -1:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
409 # object is a static image
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
410 self._animation = False
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
411 self._image = self.imagepool.getImage(index)
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
412
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
413 if not self._animation:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
414 rotation_tuple = visual.getStaticImageAngles()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
415 for angle in rotation_tuple:
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
416 self._avail_rotations.append( str(angle) )
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
417
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
418 self._image_default_x_offset = self._image.getXShift()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
419 self._image_default_y_offset = self._image.getYShift()
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
420
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
421 # FIXME: see l. 40
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
422 self._mapedit._objectedit_rotations = self._avail_rotations
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
423 # end FIXME
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
424
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
425 def input(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
426 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
427 if called _and_ the user wishes to edit offsets,
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
428 gets instance data and show gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
429
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
430 (see run.py, pump() )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
431 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
432 if self._mapedit._instances != self._instances:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
433 if self.active is True:
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
434 self._reset()
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
435 self._instances = self._mapedit._instances
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
436
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
437 if self._camera is None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
438 self._camera = self._mapedit._camera
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
439 self.renderer = fife.InstanceRenderer.getInstance(self._camera)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
440
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
441 self._layer = self._mapedit._layer
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
442
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
443 if self._instances != ():
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
444 self.highlight_selected_instance()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
445 self.get_instance_data()
211
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
446 self.update_gui()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
447 self.container.adaptLayout()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
448 self.container.show()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
449 self._get_gui_size()
f10a2e78a0e1 - updated objectedit plugin, should work much better now
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
450 self.container._setPosition(self.position)
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
451 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
452 self._reset()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
453 self.container.hide()