annotate clients/editor/plugins/objectedit.py @ 180:66bd7f8c541e

* Updated font definition file
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 30 Jan 2009 00:58:43 +0000
parents 28532ae6f9f6
children f10a2e78a0e1
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
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 import fife
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 import plugin
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 import pychan
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 import pychan.widgets as widgets
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 from pychan.tools import callbackWithArguments as cbwa
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 import settings as Settings
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 class ObjectEdit(plugin.Plugin):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 def __init__(self, engine, mapedit):
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 ObjectEdit plugin for FIFEdit
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 Mission: provide a gui mask to edit all important object data within the editor
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 (id, offsets, rotation, blocking, static)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 namespaces and object ids are excluded
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 Current features:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 - click instance and get all known data
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 - edit offsets, rotation, blocking, static
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 - outline highlighting of the selected object
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 - 3 data states: current, previous and default (so there is at least a one-step-undo)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 Missing features:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 - object saving
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 - id saving (handled by Fifedit via save map, but we have to set the id from here)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 - a lot of bug fixing concerning the rotation and the data records ^^
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 - cleanup
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 NOTE:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 - this tool isn't ready for a working enviroment (yet)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 # Fifedit plugin data
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 self.menu_items = { 'ObjectEdit' : self.toggle_offsetedit }
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 self._mapedit = mapedit
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 # FIXME
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 # 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
65 # 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
66 # 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
67 self._mapedit._objectedit_rotations = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 # end FIXME
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 self.active = False
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 self.imagepool = engine.getImagePool()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 self.animationpool = engine.getAnimationPool()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 self._camera = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 self._layer = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 self.guidata = {}
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 self.objectdata = {}
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 self._reset()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 self.create_gui()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 def _reset(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 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
87
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 self._instances = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90 self._image = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 self._animation = False
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 self._rotation = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 self._avail_rotations = []
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
94 self._namespace = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
95 self._blocking = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
96 self._static = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
97 self._object_id = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98 self._instance_id = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 self._fixed_rotation = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 self.guidata['instance_id'] = 'None'
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102 self.guidata['object_id'] = 'None'
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 self.guidata['x_offset'] = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 self.guidata['y_offset'] = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 self.guidata['instance_rotation'] = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 self.guidata['namespace'] = 'None'
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 self.guidata['blocking'] = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108 self.guidata['static'] = 0
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 if self._camera is not None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 self.renderer.removeAllOutlines()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 def create_gui(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 - creates the gui skeleton by loading the xml file
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 - 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
117 """
179
28532ae6f9f6 Moved all editor content out of content, as chewie says it's deprecated as hell ;-)
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 178
diff changeset
118 self.container = pychan.loadXML('gui/offsetedit.xml')
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 self.container.mapEvents({
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 'x_offset_up' : cbwa(self.change_offset_x, 1),
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 'x_offset_dn' : cbwa(self.change_offset_x, -1),
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 'y_offset_up' : cbwa(self.change_offset_y, 1),
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 'y_offset_dn' : cbwa(self.change_offset_y, -1),
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 'use_data' : cbwa(self.use_user_data),
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
127 'previous_data' : cbwa(self.load_previous_data),
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 'default_data' : cbwa(self.load_default_data)
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
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 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
132 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
133
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134 self._gui_anim_panel_wrapper.removeChild(self._gui_anim_panel)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 self._gui_rotation_dropdown = self.container.findChild(name="select_rotations")
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138 self._gui_xoffset_textfield = self.container.findChild(name="x_offset")
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139 self._gui_yoffset_textfield = self.container.findChild(name="y_offset")
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141 def _get_gui_size(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 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
144 (atm top right corner)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 size = self.container._getSize()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 self.position = ((Settings.ScreenWidth - 10 - size[0]), 10)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 def update_gui(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 updates the gui widgets with current instance data
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 FIXME:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 - drop animation support or turn it into something useful
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 #if self._animation is False:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 #try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158 #self._gui_anim_panel_wrapper.removeChild(self._gui_anim_panel)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 #except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160 #pass
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161 #elif self._animation is True:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
162 #try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163 #self._gui_anim_panel_wrapper.resizeToContent()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 #self._gui_anim_panel_wrapper.addChild(self._gui_anim_panel)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165 #self._gui_anim_panel_wrapper.resizeToContent()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 #except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 #pass
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 self.container.distributeInitialData({
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 'select_rotations' : self._avail_rotations,
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171 'instance_id' : self.guidata['instance_id'],
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 'object_id' : self.guidata['object_id'],
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173 'x_offset' : self.guidata['x_offset'],
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 'y_offset' : self.guidata['y_offset'],
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 'instance_rotation' : self.guidata['instance_rotation'],
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 'object_namespace' : self.guidata['namespace'],
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177 'object_blocking' : self.guidata['blocking'],
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
178 'object_static' : self.guidata['static'],
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179 })
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180 try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181 print self._avail_rotations
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
182 print self._fixed_rotation
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 index = self._avail_rotations.index( str(self._fixed_rotation) )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 self._gui_rotation_dropdown._setSelected(index)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 # pass
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 print "Angle (", self._fixed_rotation, ") not supported by this instance"
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 def toggle_gui(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191 show / hide the gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 FIXME:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 - 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
195 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196 if self.container.isVisible():
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 self.container.hide()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 self.container.show()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 def toggle_offsetedit(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
203 - 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
204 the gui popping up all the time while mapping :-)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 - hides gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 if self.active is True:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208 self.active = False
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209 if self.container.isVisible():
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
210 self.container.hide()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
211 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 self.active = True
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
214 def highlight_selected_instance(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
215 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
216 just highlights selected instance
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
217 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
218 self.renderer.removeAllOutlines()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219 self.renderer.addOutlined(self._instances[0], 205, 205, 205, 1)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
220
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221 def change_offset_x(self, value=1):
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 - callback for changing x offset
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
224 - changes x offset of current instance (image)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
225 - updates gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
227 @param int value the modifier for the x offset
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
229 if self._image is not None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230 self._image.setXShift(self._image.getXShift() + value)
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 self.guidata['x_offset'] = str( self._image.getXShift() )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233 self.update_gui()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235 def change_offset_y(self, value=1):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
237 - callback for changing y offset
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238 - changes y offset of current instance (image)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
239 - updates gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
241 @param int value the modifier for the y offset
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
242 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
243 if self._image is not None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
244 self._image.setYShift(self._image.getYShift() + value)
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 self.guidata['y_offset'] = str( self._image.getYShift() )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
247 self.update_gui()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
248
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 def use_user_data(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251 - 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
252 - writes current data record
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253 - writes previous data record
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254 - updates gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256 FIXME:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 - 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
258 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 xoffset = self._gui_xoffset_textfield._getText()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 yoffset = self._gui_yoffset_textfield._getText()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 # 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
263 if len(self._avail_rotations) < self._gui_rotation_dropdown._getSelected():
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264 index = len(self._avail_rotations)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 index = self._gui_rotation_dropdown._getSelected()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
267
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 # 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
269 angle = int( self._avail_rotations[index] )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
270 angle = int(angle - abs( self._camera.getTilt() ) )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271 if angle == 360:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272 angle = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 self._instances[0].setRotation(angle)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 self.get_instance_data(None, None, angle)
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 try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278 self._image.setXShift( int(xoffset) )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
280 pass
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 # print "x offset must me of type int!"
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
282 try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
283 self._image.setYShift( int(yoffset) )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
284 except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
285 pass
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
286 # print "y offset must be of type int!"
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
287
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
288 self.write_current_data()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
289 self.objectdata[self._namespace][self._object_id]['previous'] = self.objectdata[self._namespace][self._object_id]['current'].copy()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
290 self.update_gui()
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 def load_previous_data(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
293 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
294 - writes a copy of the previous record back to the current record (aka one-step-undo)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
295 - loads current data into class object
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
296 - updates gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
297 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
298 self.objectdata[self._namespace][self._object_id]['current'] = self.objectdata[self._namespace][self._object_id]['previous'].copy()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
299 self.load_current_data()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
300 self.update_gui()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
301
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
302 def load_default_data(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
303 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
304 - writes a copy of the default record back to the current record
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
305 - loads current data into class object
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
306 - updates gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
307 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
308 self.objectdata[self._namespace][self._object_id]['current'] = self.objectdata[self._namespace][self._object_id]['default'].copy()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
309 self.load_current_data()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
310 self.update_gui()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
311
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
312 def load_current_data(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
313 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
314 loads the current record into class object
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
315 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
316 self._image = self.objectdata[self._namespace][self._object_id]['current']['image']
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
317 self._animation = self.objectdata[self._namespace][self._object_id]['current']['animation']
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
318 self._rotation = self.objectdata[self._namespace][self._object_id]['current']['rotation']
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
319 self._fixed_rotation = self.objectdata[self._namespace][self._object_id]['current']['fixed_rotation']
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
320 self._avail_rotations = self.objectdata[self._namespace][self._object_id]['current']['avail_rotations']
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
321 self._blocking = self.objectdata[self._namespace][self._object_id]['current']['blocking']
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
322 self._static = self.objectdata[self._namespace][self._object_id]['current']['static']
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
323 self._instance_id = self.objectdata[self._namespace][self._object_id]['current']['instance_id']
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
324 self._image.setXShift( self.objectdata[self._namespace][self._object_id]['current']['xoffset'] )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325 self._image.setYShift( self.objectdata[self._namespace][self._object_id]['current']['yoffset'] )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
326
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
327 self.write_current_guidata()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
328
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329 def write_current_data(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
330 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
331 updates the current record
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
332 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
333 self.objectdata[self._namespace][self._object_id]['current']['instance'] = self._instances[0]
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
334 self.objectdata[self._namespace][self._object_id]['current']['image'] = self._image
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
335 self.objectdata[self._namespace][self._object_id]['current']['animation'] = self._animation
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
336 self.objectdata[self._namespace][self._object_id]['current']['rotation'] = self._rotation
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
337 self.objectdata[self._namespace][self._object_id]['current']['fixed_rotation'] = self._fixed_rotation
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
338 self.objectdata[self._namespace][self._object_id]['current']['avail_rotations'] = self._avail_rotations
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
339 self.objectdata[self._namespace][self._object_id]['current']['blocking'] = self._blocking
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
340 self.objectdata[self._namespace][self._object_id]['current']['static'] = self._static
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
341 self.objectdata[self._namespace][self._object_id]['current']['instance_id'] = self._instance_id
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
342 self.objectdata[self._namespace][self._object_id]['current']['xoffset'] = self._image.getXShift()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
343 self.objectdata[self._namespace][self._object_id]['current']['yoffset'] = self._image.getYShift()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
344
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
345 self.write_current_guidata()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
346
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
347 def write_current_guidata(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
348 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
349 updates the gui data with
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 self.guidata['instance_rotation'] = str( self._instances[0].getRotation() )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
352 self.guidata['object_id'] = str( self._object_id )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
353 self.guidata['instance_id'] = str( self._instance_id )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
354 self.guidata['x_offset'] = str( self._image.getXShift() )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
355 self.guidata['y_offset'] = str( self._image.getYShift() )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
356 self.guidata['namespace'] = self._namespace
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
357 self.guidata['blocking'] = str( self._blocking )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
358 self.guidata['static'] = str( self._static )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
359
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
360 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
361 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
362 - grabs all available data from both object and instance
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
363 - checks if we already hold a record (namespace + object id)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
364
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
365 FIXME:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
366 1.) we need to fix the instance rotation / rotation issue
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
367 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
368 3.) move record code out of this method
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
369 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
370 visual = None
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
371 self._avail_rotations = []
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
372
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
373 if instance is None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
374 instance = self._instances[0]
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
375
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
376 object = instance.getObject()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
377 self._namespace = object.getNamespace()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
378 self._object_id = object.getId()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
379
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
380 if angle != -1:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
381 del self.objectdata[self._namespace][self._object_id]
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
382
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
383 if not self.objectdata.has_key(self._namespace):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
384 self.objectdata[self._namespace] = {}
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
385
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
386 if not self.objectdata[self._namespace].has_key(self._object_id):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
387 self.objectdata[self._namespace][self._object_id] = {}
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
388
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
389 # we hold 3 versions of the data: current, previous, default
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
390 # default is only set one time, current and previous are changing data
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
391 # due to the users actions
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
392 self.objectdata[self._namespace][self._object_id]['current'] = {}
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
393 self.objectdata[self._namespace][self._object_id]['previous'] = {}
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
394
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
395 self._instance_id = instance.getId()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
396
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
397 if self._instance_id == '':
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
398 self._instance_id = 'None'
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
399
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
400 if angle == -1:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
401 angle = int(instance.getRotation())
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
402 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
403 angle = int(angle)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
404
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
405 self._rotation = angle
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
406
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
407 if object.isBlocking():
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
408 self._blocking = 1
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
409
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
410 if object.isStatic():
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
411 self._static = 1
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
412
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
413 try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
414 visual = object.get2dGfxVisual()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
415 except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
416 print 'Fetching visual of object - failed. :/'
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
417 raise
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
418
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
419 self._fixed_rotation = int(instance.getRotation() + abs( self._camera.getTilt() ) )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
420 self._fixed_rotation = visual.getClosestMatchingAngle(self._fixed_rotation)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
421
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
422 index = visual.getStaticImageIndexByAngle(self._fixed_rotation)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
423
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
424 if index == -1:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
425 # object is an animation
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
426 self._animation = True
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
427 # no static image available, try default action
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
428 action = object.getDefaultAction()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
429 if action:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
430 animation_id = action.get2dGfxVisual().getAnimationIndexByAngle(self._fixed_rotation)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
431 animation = self.animationpool.getAnimation(animation_id)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
432 if timestamp is None and frame is not None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
433 self._image = animation.getFrame(frame)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
434 elif timestamp is not None and frame is None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
435 self._image = animation.getFrameByTimestamp(timestamp)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
436 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
437 self._image = animation.getFrameByTimestamp(0)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
438 index = self._image.getPoolId()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
439 elif index != -1:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
440 # object is a static image
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
441 self._animation = False
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
442 self._image = self.imagepool.getImage(index)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
443
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
444 if self._animation:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
445 self._avail_rotations = Settings.RotAngles['animations']
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
446 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
447 rotation_tuple = visual.getStaticImageAngles()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
448 for angle in rotation_tuple:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
449 self._avail_rotations.append( str(angle) )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
450
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
451 # FIXME: see l. 40
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
452 self._mapedit._objectedit_rotations = self._avail_rotations
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
453 # end FIXME
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
454 self.write_current_data()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
455
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
456 self.objectdata[self._namespace][self._object_id]['default'] = {}
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
457 self.objectdata[self._namespace][self._object_id]['default'] = self.objectdata[self._namespace][self._object_id]['current'].copy()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
458 self.objectdata[self._namespace][self._object_id]['previous'] = self.objectdata[self._namespace][self._object_id]['current'].copy()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
459
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
460 self.write_current_guidata()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
461 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
462 self.load_current_data()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
463
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
464 def dump_objectdata(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
465 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
466 just a useful dumper ^^
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
467 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
468 print "#"*4, "Dump of objectdata", "#"*4, "\n"
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
469 for namespace in self.objectdata:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
470 print "namespace: ", namespace
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
471 for key in self.objectdata[namespace]:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
472 print "\tkey: ", key
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
473 for item in self.objectdata[namespace][key]:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
474 if len(item) >= 9:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
475 tab = "\t"*1
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
476 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
477 tab = "\t"*2
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
478 print "\t\t", item, " : ", tab, self.objectdata[namespace][key][item]
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
479
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
480 def input(self):
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
481 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
482 if called _and_ the user wishes to edit offsets,
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
483 gets instance data and show gui
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
484
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
485 (see run.py, pump() )
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
486 """
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
487 if self._mapedit._instances != self._instances:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
488 if self.active is True:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
489 self._instances = self._mapedit._instances
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
490
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
491 if self._camera is None:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
492 self._camera = self._mapedit._camera
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
493 self.renderer = fife.InstanceRenderer.getInstance(self._camera)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
494
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
495 self._layer = self._mapedit._layer
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
496
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
497 if self._instances != ():
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
498 self.highlight_selected_instance()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
499 self.get_instance_data()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
500
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
501 if self._animation is False:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
502 self.update_gui()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
503 self.container.adaptLayout()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
504 self.container.show()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
505 self._get_gui_size()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
506 self.container._setPosition(self.position)
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
507 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
508 self.container.hide()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
509 print "Animation objects are not yet editable"
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
510 # self.dump_objectdata()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
511 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
512 self._reset()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
513 self.container.hide()