annotate clients/editor/plugins/ObjectEdit.py @ 356:ab41334e8a57

Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378] Added layer transparency support Added layer transparency to map editor
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 24 Sep 2009 18:24:47 +0000
parents dfd48d49c044
children ad5818097cd6
rev   line source
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 # coding: utf-8
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 # ###################################################
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 # Copyright (C) 2008 The Zero-Projekt team
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 # http://zero-projekt.net
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 # info@zero-projekt.net
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 # This file is part of Zero "Was vom Morgen blieb"
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 #
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 # The Zero-Projekt codebase is free software; you can redistribute it and/or modify
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 # it under the terms of the GNU General Public License as published by
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 # the Free Software Foundation; either version 2 of the License, or
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 # (at your option) any later version.
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 #
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 # This program is distributed in the hope that it will be useful,
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 # GNU General Public License for more details.
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 #
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 # You should have received a copy of the GNU General Public License
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 # along with this program; if not, write to the
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 # Free Software Foundation, Inc.,
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 # ###################################################
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 """ a tool for FIFEdit to edit object and instance attributes """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 import fife
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 import pychan
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 import pychan.widgets as widgets
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 from pychan.tools import callbackWithArguments as cbwa
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
31 from fife_timer import Timer
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
32
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 import scripts
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 import scripts.plugin as plugin
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 from scripts.events import *
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 from scripts.gui.action import Action
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
38
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
39 import os
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
40 try:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
41 import xml.etree.cElementTree as ET
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
42 except:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
43 import xml.etree.ElementTree as ET
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
44
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 import math
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
47 WHITE = {
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
48 "r" : 205,
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
49 "g" : 205,
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
50 "b" : 205
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
51 }
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
52 OUTLINE_SIZE = 1
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
53
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 class ObjectEdit(plugin.Plugin):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 """ The B{ObjectEdit} module is a plugin for FIFedit and allows to edit
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
56 attributes of an selected instance - like offset, instance id or rotation
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 (namespaces and object id editing is excluded)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 current features:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 - click instance and get all known data
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
61 - edit offsets, rotation, instance id
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
62 - save offsets to object file
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 - outline highlighting of the selected object
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
64 - animation viewer
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
65
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
66 FIXME:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
67 - add static and blocking flag to save routine
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
68 - fix animation rotation (FIFE has no method yet to export all
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
69 angles of an animation to python)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 def __init__(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 self.active = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 self._camera = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 self._layer = None
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
75 self._anim_timer = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 self._enabled = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 self.imagepool = None
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
80 self._animationpool = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 self.guidata = {}
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 self.objectdata = {}
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 def _reset(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 resets all dynamic vars, but leaves out static ones (e.g. camera, layer)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 """
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
90 if self._anim_timer:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
91 self._anim_timer.stop()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
92 # reset the ToggleButton
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
93 if self._gui_anim_playback._isToggled():
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
94 self._gui_anim_playback._setToggled(0)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
95 self._anim_timer = None
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
96
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
97 self._object = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98 self._instances = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 self._image = None
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
100 self._image_default_x_offset = None
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
101 self._image_default_y_offset = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102 self._animation = False
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
103 self._anim_data = {}
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 self._rotation = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 self._avail_rotations = []
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 self._namespace = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 self._blocking = 0
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108 self._static = 0
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 self._object_id = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 self._instance_id = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 self._fixed_rotation = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 if self._camera is not None:
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
114 self.renderer.removeAllOutlines()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 def enable(self):
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
117 """ plugin method """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 if self._enabled is True:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 return
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 self._editor = scripts.editor.getEditor()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 self.engine = self._editor.getEngine()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 self.imagepool = self.engine.getImagePool()
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
125 self._animationpool = self.engine.getAnimationPool()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
127 self._showAction = Action(unicode(self.getName(),"utf-8"), checkable=True)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 scripts.gui.action.activated.connect(self.toggle_gui, sender=self._showAction)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130 self._editor._toolsMenu.addAction(self._showAction)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132 events.onInstancesSelected.connect(self.input)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
133
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134 self._reset()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 self.create_gui()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137 def disable(self):
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
138 """ plugin method """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139 if self._enabled is False:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 return
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 self._reset()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 self.container.hide()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144 self.removeAllChildren()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 events.onInstancesSelected.disconnect(self.input)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 self._editor._toolsMenu.removeAction(self._showAction)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 def isEnabled(self):
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
151 """ plugin method """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 return self._enabled;
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 def getName(self):
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
155 """ plugin method """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
156 return "Object editor v2"
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158 def create_gui(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160 - creates the gui skeleton by loading the xml file
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161 - finds some important childs and saves their widget in the object
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
162
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
163 FIXME:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
164 - move all dynamic widgets to dict
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 self.container = pychan.loadXML('gui/objectedit.xml')
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 self.container.mapEvents({
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
168 'x_offset_up' : cbwa(self.change_offset_x, 1),
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
169 'x_offset_dn' : cbwa(self.change_offset_x, -1),
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
170
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
171 'y_offset_up' : cbwa(self.change_offset_y, 1),
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
172 'y_offset_dn' : cbwa(self.change_offset_y, -1),
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
174 'use_data' : self.use_user_data,
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
175 'change_data' : self.save_user_data,
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
176
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
177 'anim_left' : self.previous_anim_frame,
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
178 'anim_right' : self.next_anim_frame,
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
179 'anim_start_pos' : self.anim_start_frame,
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
180 'anim_end_pos' : self.anim_end_frame,
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181 })
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
182
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 self._gui_anim_panel_wrapper = self.container.findChild(name="animation_panel_wrapper")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 self._gui_anim_panel = self._gui_anim_panel_wrapper.findChild(name="animation_panel")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
186 self._gui_rotation_dropdown = self.container.findChild(name="select_rotations")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
187 self._gui_rotation_dropdown.capture(self.gui_rotate_instance,"mouseWheelMovedUp")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
188 self._gui_rotation_dropdown.capture(self.gui_rotate_instance,"mouseWheelMovedDown")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
189 self._gui_rotation_dropdown.capture(self.gui_rotate_instance,"action")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
190
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
191 self._gui_anim_actions_dropdown = self._gui_anim_panel_wrapper.findChild(name="select_actions")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
192 self._gui_anim_actions_dropdown.capture(self.eval_gui_anim_action,"mouseWheelMovedUp")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
193 self._gui_anim_actions_dropdown.capture(self.eval_gui_anim_action,"mouseWheelMovedDown")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
194 self._gui_anim_actions_dropdown.capture(self.eval_gui_anim_action,"action")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
195
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
196 self._gui_anim_playback = self._gui_anim_panel_wrapper.findChild(name="anim_playback")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
197 self._gui_anim_playback.capture(self.anim_playback, "mousePressed")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
198 self._gui_anim_loop = self._gui_anim_panel_wrapper.findChild(name="anim_loop")
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
200 self._gui_current_frame = self._gui_anim_panel_wrapper.findChild(name="anim_current_frame")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
201 self._gui_current_frame.capture(self.previous_anim_frame,"mouseWheelMovedUp")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
202 self._gui_current_frame.capture(self.next_anim_frame,"mouseWheelMovedDown")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
203
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
204 self._gui_xoffset_textfield = self.container.findChild(name="x_offset")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
205 self._gui_yoffset_textfield = self.container.findChild(name="y_offset")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
206
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 self._gui_instance_id_textfield = self.container.findChild(name="instance_id")
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
209 def anim_playback(self, widget):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
210 """ start / stop playback of an animation due to status of a gui ToggleButton
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
211 Sets also two ivars of timer object (active & loop)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 """
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
213 if widget._isToggled():
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
214 self._anim_timer.stop()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
215 self._anim_timer.active = False
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
216 else:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
217 frame_delay = self._anim_data['obj'].getFrameDuration(self._anim_data['current'])
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
218 self._anim_timer = Timer(delay=frame_delay,callback=self.next_anim_frame)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
219 self._anim_timer.active = True
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
220 self._anim_timer.loop = self._gui_anim_loop._isMarked()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
221 self._anim_timer.start()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
222
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
223 def previous_anim_frame(self):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
224 """ show previous anim frame """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
225 if self._anim_data['current'] > 0:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
226 self._anim_data['current'] -= 1
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
227 self.update_gui()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
228
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
229 def next_anim_frame(self):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
230 """ show next anim frame and reset animation frame to 0 if playback looping is active"""
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
231 if self._anim_timer.loop and (self._anim_data['current'] == self._anim_data['frames']):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
232 self._anim_data['current'] = 0
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
234 if self._anim_data['current'] < self._anim_data['frames']:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
235 self._anim_data['current'] += 1
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
236 self.update_gui()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
237
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
238 def anim_start_frame(self):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
239 """ set start frame of animation """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
240 self._anim_data['current'] = 0
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
241 self.update_gui()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
242
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
243 def anim_end_frame(self):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
244 """ set end frame of animation """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
245 self._anim_data['current'] = self._anim_data['frames']
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
246 self.update_gui()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
247
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
248 def set_default_offset(self, axis):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
249 """ set default image offset for given axis """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
250 if axis == 'x':
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
251 self.set_offset(x=self._image_default_x_offset)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
252 elif axis == 'y':
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
253 self.set_offset(y=self._image_default_y_offset)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
254
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 def update_gui(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 updates the gui widgets with current instance data
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 """
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
260 # show the image we retrieved from an animated object
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
261 if self._animation:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
262 if not self._gui_anim_panel_wrapper.findChild(name="animation_panel"):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
263 self._gui_anim_panel_wrapper.addChild(self._gui_anim_panel)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
265 # get current selected image and update the icon widget
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
266 dur = 0
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
267 for i in range(self._anim_data['frames']):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
268 dur += self._anim_data['obj'].getFrameDuration(i)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
269
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
270 # set new duration for the playback timer
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
271 if self._anim_timer:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
272 frame_delay = self._anim_data['obj'].getFrameDuration(self._anim_data['current'])
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
273
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
274 if i == self._anim_data['current']:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
275 # set new duration for the playback timer
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
276 if self._anim_timer and self._anim_timer.active:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
277 self._anim_timer.setPeriod(self._anim_data['obj'].getFrameDuration(self._anim_data['current']))
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
278 break
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
279
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
280 image = self._anim_data['obj'].getFrameByTimestamp(dur)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
281 self.container.findChild(name="animTest").image = image.getResourceFile()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
282 self.container.findChild(name="animTest").size= (250,250)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
283 self.container.findChild(name="animTest").min_size= (250,250)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
284
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
285 self.container.distributeInitialData({
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
286 'anim_current_frame' : unicode(str(self._anim_data['current'])),
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
287 'anim_rotation' : unicode(str(self._anim_data['obj'].getDirection())),
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
288 })
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
289
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
290 else:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
291 if self._gui_anim_panel_wrapper.findChild(name="animation_panel"):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
292 self._gui_anim_panel_wrapper.removeChild(self._gui_anim_panel)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
293
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
294 if self._image is not None:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
295 x_offset = unicode( self._image.getXShift() )
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
296 y_offset = unicode( self._image.getYShift() )
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
297 else:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
298 x_offset = unicode( 0 )
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
299 y_offset = unicode( 0 )
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
300
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
301 self.container.distributeInitialData({
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
302 'select_rotations' : self._avail_rotations,
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
303 'instance_id' : unicode( self._instances[0].getId() ),
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
304 'object_id' : unicode( self._object_id ),
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
305 'x_offset' : x_offset,
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
306 'y_offset' : y_offset,
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
307 'instance_rotation' : unicode( self._instances[0].getRotation() ),
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
308 'object_namespace' : unicode( self._namespace ),
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
309 'object_blocking' : unicode( self._blocking ),
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
310 'object_static' : unicode( self._static ),
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
311 })
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
312
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
313 if not self._animation:
308
af0b233e246f - added a workaround for the rotation issue of groundtiles in rio de hola maps
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 307
diff changeset
314 if self._fixed_rotation in self._avail_rotations:
af0b233e246f - added a workaround for the rotation issue of groundtiles in rio de hola maps
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 307
diff changeset
315 index = self._avail_rotations.index( self._fixed_rotation )
af0b233e246f - added a workaround for the rotation issue of groundtiles in rio de hola maps
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 307
diff changeset
316 self._gui_rotation_dropdown._setSelected(index)
af0b233e246f - added a workaround for the rotation issue of groundtiles in rio de hola maps
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 307
diff changeset
317 else:
af0b233e246f - added a workaround for the rotation issue of groundtiles in rio de hola maps
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 307
diff changeset
318 print "Internal FIFE rotation: ", self._instances[0].getRotation()
af0b233e246f - added a workaround for the rotation issue of groundtiles in rio de hola maps
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 307
diff changeset
319 print "Fixed rotation (cam rot) ", self._fixed_rotation + int(abs(self._camera.getRotation()))
af0b233e246f - added a workaround for the rotation issue of groundtiles in rio de hola maps
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 307
diff changeset
320 print "Collected rots from object ", self._avail_rotations
af0b233e246f - added a workaround for the rotation issue of groundtiles in rio de hola maps
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 307
diff changeset
321
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
322
316
6add14ebe9f5 Disabled recursing for some adaptLayout calls. This will make the editor more responsive
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 308
diff changeset
323 self.container.adaptLayout(False)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
324
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325 def toggle_gui(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
326 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
327 show / hide the gui
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
328 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329 if self.active is True:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
330 self.active = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
331 if self.container.isVisible() or self.container.isDocked():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
332 self.container.setDocked(False)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
333 self.container.hide()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
334 self._showAction.setChecked(False)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
335 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
336 self.active = True
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
337 self._showAction.setChecked(True)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
338
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
339 def highlight_selected_instance(self):
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
340 """ highlights selected instance """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
341 self.renderer.removeAllOutlines()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
342 self.renderer.addOutlined(self._instances[0], WHITE["r"], WHITE["g"], WHITE["b"], OUTLINE_SIZE)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
343
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
344 def change_offset_x(self, value=1):
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
345 """
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
346 - callback for changing x offset
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
347 - changes x offset of current instance (image)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
348 - updates gui
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
349
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
350 @type value: int
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
351 @param value: the modifier for the x offset
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
352 """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
353 if self._animation:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
354 print "Offset changes of animations are not supported yet"
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
355 return
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
356
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
357 if self._image is not None:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
358 self._image.setXShift(self._image.getXShift() + value)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
359 self.update_gui()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
360
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
361 def change_offset_y(self, value=1):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
362 """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
363 - callback for changing y offset
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
364 - changes y offset of current instance (image)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
365 - updates gui
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
366
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
367 @type value: int
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
368 @param value: the modifier for the y offset
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
369 """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
370 if self._animation:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
371 print "Offset changes of animations are not supported yet"
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
372 return
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
373
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
374 if self._image is not None:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
375 self._image.setYShift(self._image.getYShift() + value)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
376 self.update_gui()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
377
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
378 def use_user_data(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
379 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
380 - takes the users values and applies them directly to the current ._instance
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
381 - writes current data record
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
382 - writes previous data record
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
383 - updates gui
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
384
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
385 FIXME:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
386 - parse user data in case user think strings are considered to be integer offset values...
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
387 """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
388 if self._animation:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
389 print "Editing animated instances is not supported yet"
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
390 return
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
391
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
392 xoffset = self._gui_xoffset_textfield._getText()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
393 yoffset = self._gui_yoffset_textfield._getText()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
394
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
395 instance_id = str(self._gui_instance_id_textfield._getText())
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
396
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
397 if instance_id == "":
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
398 instance_id = "None"
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
399
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
400 if instance_id is not None and instance_id is not "None":
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
401 existing_instances = self._editor.getActiveMapView().getController()._layer.getInstances(instance_id)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
402 if len(existing_instances) <= 0:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
403 self._instances[0].setId(instance_id)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
404 print "Set new instance id: ", instance_id
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
405 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
406 print "Instance ID is already in use."
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
407
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
408 # update rotation
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
409 angle = self.eval_gui_rotation()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
410 self.set_rotation(angle)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
411
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
412 # update offsets
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
413 self.set_offset(int(xoffset), int(yoffset))
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
414
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
415 self.update_gui()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
416
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
417 def save_user_data(self):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
418 """ saves the current object to its xml file
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
419
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
420 NOTE:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
421 - animations can't be saved for now
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
422
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
423 FIXME:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
424 - add missing object attributes to saving routine
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
425 """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
426 if self._object is None:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
427 return
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
428 if self._animation:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
429 return
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
430
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
431 file = self._object.getResourceFile()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
432 self.tree = ET.parse(file)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
433
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
434 img_lst = self.tree.findall("image")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
435
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
436 # apply changes to the XML structure due to current user settings in the gui
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
437 for img_tag in img_lst:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
438 if img_tag.attrib["direction"] == self._avail_rotations[self._gui_rotation_dropdown._getSelected()]:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
439 img_tag.attrib["x_offset"] = self._gui_xoffset_textfield._getText()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
440 img_tag.attrib["y_offset"] = self._gui_yoffset_textfield._getText()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
441 break
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
442
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
443 xmlcontent = ET.tostring(self.tree.getroot())
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
444
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
445 # save xml data beneath the <?fife type="object"?> definition into the object file
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
446 tmp = open(file, 'w')
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
447 tmp.write('<?fife type="object"?>\n')
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
448 tmp.write(xmlcontent + "\n")
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
449 tmp.close()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
450
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
451 def gui_rotate_instance(self):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
452 """ rotate an instance due to selected angle """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
453 angle = self.eval_gui_rotation()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
454 self.set_rotation(angle)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
455
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
456 def eval_gui_rotation(self):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
457 """ prepare rotation from gui and apply it to the current selected instance """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
458 index = self._gui_rotation_dropdown._getSelected()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
459 angle = int( self._avail_rotations[index] )
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
460
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
461 if angle == 360:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
462 angle = 0
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
463
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
464 return angle
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
465
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
466 def eval_gui_anim_action(self):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
467 """ check the selected action of an animation and update the gui accordingly """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
468 if not self._anim_data['actions']: return
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
469
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
470 index = self._gui_anim_actions_dropdown._getSelected()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
471 action = self._anim_data['actions'][index]
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
472
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
473 self.update_anim_data(action)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
474 self.update_gui()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
475
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
476 def set_rotation(self, angle):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
477 """ set the rotation of the current instance """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
478 # print "...setting instance rotation from %s to %s" % (self._rotation, angle)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
479 self._instances[0].setRotation(angle)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
480 self.get_instance_data(None, None, angle)
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
481 self.update_gui()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
482 # print "...new internal FIFE rotation ", int(self._instances[0].getRotation())
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
483
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
484 def set_offset(self, x=None, y=None):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
485 """ set x/y offset of current selected instance """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
486 if x is not None:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
487 self._image.setXShift(x)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
488 if y is not None:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
489 self._image.setYShift(y)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
490
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
491 def update_anim_data(self, action=None):
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
492 """ update animation data for the current selected instance from FIFE's data structure
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
493
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
494 @type animation FIFE animation
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
495 @return animation current selected animation
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
496 """
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
497 if action:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
498 animation_id = action.get2dGfxVisual().getAnimationIndexByAngle(self._fixed_rotation)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
499 animation = self._animationpool.getAnimation(animation_id)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
500
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
501 action_ids = []
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
502 actions = []
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
503
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
504 try:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
505 action_ids = self._object.getActionIds()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
506 for id in action_ids:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
507 actions.append(self._object.getAction(id))
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
508 except:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
509 pass
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
510
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
511 self._anim_data = {}
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
512 self._anim_data['obj'] = animation
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
513 self._anim_data['id'] = animation_id
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
514 self._anim_data['frames'] = animation.getNumFrames()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
515 self._anim_data['current'] = 0
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
516 self._anim_data['actions'] = actions
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
517 self._anim_data['action_ids'] = action_ids
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
518 self._anim_data['default_action'] = self._object.getDefaultAction()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
519 self._anim_data['action'] = action
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
520
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
521 return animation
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
522
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
523 def get_instance_data(self, timestamp=None, frame=None, angle=-1, instance=None):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
524 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
525 - grabs all available data from both object and instance
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
526
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
527 FIXME:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
528 1.) we need to fix the instance rotation / rotation issue
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
529 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
530 visual = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
531 self._avail_rotations = []
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
532
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
533 if instance is None:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
534 instance = self._instances[0]
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
535
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
536 object = instance.getObject()
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
537 self._object = object
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
538 self._namespace = object.getNamespace()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
539 self._object_id = object.getId()
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
540
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
541 self._instance_id = instance.getId()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
542
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
543 if self._instance_id == '':
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
544 self._instance_id = 'None'
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
545
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
546 if angle == -1:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
547 angle = int(instance.getRotation())
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
548 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
549 angle = int(angle)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
550
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
551 self._rotation = angle
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
552
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
553 if object.isBlocking():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
554 self._blocking = 1
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
555
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
556 if object.isStatic():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
557 self._static = 1
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
558
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
559 try:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
560 visual = object.get2dGfxVisual()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
561 except:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
562 print 'Fetching visual of object - failed. :/'
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
563 raise
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
564
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
565 # print "Camera tilt: ", self._camera.getTilt()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
566 # print "Camera rotation: ", self._camera.getRotation()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
567 # print "Instance rotation: ", instance.getRotation()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
568
308
af0b233e246f - added a workaround for the rotation issue of groundtiles in rio de hola maps
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 307
diff changeset
569 # self._fixed_rotation = int(instance.getRotation() + abs( self._camera.getRotation() ) )
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
570 self._fixed_rotation = instance.getRotation()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
571 # self._fixed_rotation = visual.getClosestMatchingAngle(self._fixed_rotation)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
572
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
573 index = visual.getStaticImageIndexByAngle(self._fixed_rotation)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
574
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
575 if index is -1:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
576 # object is an animation
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
577 self._animation = True
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
578 self._image = None
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
579
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
580 # no static image available, try default action
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
581 action = object.getDefaultAction()
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
582
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
583 if action:
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
584 animation = self.update_anim_data(action)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
585
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
586 # update gui
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
587 if animation:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
588 self._gui_anim_actions_dropdown._setItems(self._anim_data['action_ids'])
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
589 self._gui_anim_actions_dropdown._setSelected(0)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
590
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
591 if timestamp is None and frame is not None:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
592 self._image = animation.getFrame(frame)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
593 elif timestamp is not None and frame is None:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
594 self._image = animation.getFrameByTimestamp(timestamp)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
595 else:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
596 self._image = animation.getFrameByTimestamp(0)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
597 elif index is not -1:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
598 # object is a static image
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
599 self._animation = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
600 self._image = self.imagepool.getImage(index)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
601
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
602 if not self._animation:
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
603 rotations = visual.getStaticImageAngles()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
604 for angle in rotations:
308
af0b233e246f - added a workaround for the rotation issue of groundtiles in rio de hola maps
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 307
diff changeset
605 # angle += int(abs( self._camera.getRotation() ))
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
606 self._avail_rotations.append(angle)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
607
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
608 self._image_default_x_offset = self._image.getXShift()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
609 self._image_default_y_offset = self._image.getYShift()
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
610 else:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
611 # these doesn't work correctly
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
612 # rotations = [0,60,120,180,240,300]
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
613
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
614 # testbench to get valid angles
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
615 # angle = 0
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
616 # rotations = []
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
617 # while angle != 360:
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
618 # angle += 10
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
619 # rotations.append(angle)
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
620
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
621 # estimated angles (for hex!) to make things work - use testbench to test
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
622 # various angles and note down the working ones (watch instance
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
623 # rotation and the animation rotations shown in the gui; valid
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
624 # angles are given once the rotations are in sync
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
625 self._avail_rotations = [9,69,139,169,249,319]
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
626
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
627 def input(self, instances):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
628 """
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
629 if called _and_ the user wishes to edit offsets,
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
630 gets instance data and show gui
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
631
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
632 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
633 if instances != self._instances:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
634 if self.active is True:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
635 self._reset()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
636 self._instances = instances
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
637
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
638 if self._camera is None:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
639 self._camera = self._editor.getActiveMapView().getCamera()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
640 self.renderer = fife.InstanceRenderer.getInstance(self._camera)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
641
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
642 self._layer = self._editor.getActiveMapView().getController()._layer
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
643
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
644 if self._instances != ():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
645 self.highlight_selected_instance()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
646 self.get_instance_data()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
647 self.update_gui()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
648 self.container.show()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
649 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
650 self._reset()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
651 self.container.hide()
307
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
652
316
6add14ebe9f5 Disabled recursing for some adaptLayout calls. This will make the editor more responsive
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 308
diff changeset
653 self.container.adaptLayout(False)