annotate clients/editor/plugins/ObjectEdit.py @ 337:f9aca52c7c45

VFS: * Emit warning for upper case filenames. Fixes #122.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 24 Aug 2009 16:06:30 +0000
parents 6add14ebe9f5
children dfd48d49c044
rev   line source
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
1 #!/usr/bin/env python
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 # coding: utf-8
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 # ###################################################
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 # Copyright (C) 2008 The Zero-Projekt team
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 # http://zero-projekt.net
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 # info@zero-projekt.net
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 # 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
8 #
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 # 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
10 # 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
11 # 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
12 # (at your option) any later version.
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 #
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 # 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
15 # 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
16 # 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
17 # GNU General Public License for more details.
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 #
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 # 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
20 # 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
21 # Free Software Foundation, Inc.,
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 # 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
23 # ###################################################
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 """ 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
26
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 import fife
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 import pychan
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 import pychan.widgets as widgets
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 from pychan.tools import callbackWithArguments as cbwa
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31
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
32 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
33
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 import scripts
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 import scripts.plugin as plugin
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 from scripts.events import *
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 from scripts.gui.action import Action
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38
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
39
22253b2c9b14 - added LightEdit 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 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
41 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
42 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
43 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
44 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
45
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 import math
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47
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
48 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
49 "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
50 "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
51 "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
52 }
22253b2c9b14 - added LightEdit 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 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
54
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 class ObjectEdit(plugin.Plugin):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 """ 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
57 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
58 (namespaces and object id editing is excluded)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 current features:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 - 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
62 - 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
63 - save offsets to object file
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 - 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
65 - 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
66
22253b2c9b14 - added LightEdit 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 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
68 - 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
69 - 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
70 angles of an animation to python)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 def __init__(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 self.active = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 self._camera = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 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
76 self._anim_timer = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 self._enabled = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 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
81 self._animationpool = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 self.guidata = {}
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 self.objectdata = {}
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 def _reset(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 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
89
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90 """
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
91 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
92 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
93 # 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
94 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
95 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
96 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
97
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
98 self._object = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 self._instances = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100 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
101 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
102 self._image_default_y_offset = None
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 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
104 self._anim_data = {}
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 self._rotation = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 self._avail_rotations = []
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 self._namespace = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108 self._blocking = 0
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 self._static = 0
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 self._object_id = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 self._instance_id = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 self._fixed_rotation = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114 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
115 self.renderer.removeAllOutlines()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 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
118 """ plugin method """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 if self._enabled is True:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 return
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 self._editor = scripts.editor.getEditor()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 self.engine = self._editor.getEngine()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 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
126 self._animationpool = self.engine.getAnimationPool()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
127
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
128 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
129 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
130
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 self._editor._toolsMenu.addAction(self._showAction)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
133 events.onInstancesSelected.connect(self.input)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 self._reset()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 self.create_gui()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138 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
139 """ plugin method """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 if self._enabled is False:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141 return
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 self._reset()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144 self.container.hide()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 self.removeAllChildren()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 events.onInstancesSelected.disconnect(self.input)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 self._editor._toolsMenu.removeAction(self._showAction)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 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
152 """ plugin method """
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 return self._enabled;
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 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
156 """ 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
157 return "Object editor v2"
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 def create_gui(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161 - 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
162 - 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
163
22253b2c9b14 - added LightEdit 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 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
165 - move all dynamic widgets to dict
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 self.container = pychan.loadXML('gui/objectedit.xml')
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 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
169 '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
170 '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
171
22253b2c9b14 - added LightEdit 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_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
173 '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
174
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
175 '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
176 '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
177
22253b2c9b14 - added LightEdit 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_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
179 '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
180 '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
181 'anim_end_pos' : self.anim_end_frame,
255
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
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 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
185 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
186
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
187 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
188 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
189 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
190 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
191
22253b2c9b14 - added LightEdit 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 = 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
193 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
194 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
195 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
196
22253b2c9b14 - added LightEdit 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 = 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
198 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
199 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
200
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
201 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
202 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
203 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
204
22253b2c9b14 - added LightEdit 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_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
206 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
207
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208 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
209
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
210 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
211 """ 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
212 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
213 """
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
214 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
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223
22253b2c9b14 - added LightEdit 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 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
225 """ 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
226 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
227 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
228 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
229
22253b2c9b14 - added LightEdit 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 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
231 """ 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
232 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
233 self._anim_data['current'] = 0
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234
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
235 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
236 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
237 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
238
22253b2c9b14 - added LightEdit 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 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
240 """ 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
241 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
242 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
243
22253b2c9b14 - added LightEdit 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 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
245 """ 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
246 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
247 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
248
22253b2c9b14 - added LightEdit 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 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
250 """ 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
251 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
252 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
253 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
254 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
255
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256 def update_gui(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 updates the gui widgets with current instance data
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 """
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
261 # 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
262 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
263 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
264 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
265
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
266 # 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
267 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
268 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
269 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
270
22253b2c9b14 - added LightEdit 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 # 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
272 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
273 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
274
22253b2c9b14 - added LightEdit 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 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
276 # 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
277 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
278 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
279 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
280
22253b2c9b14 - added LightEdit 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 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
282 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
283 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
284 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
285
22253b2c9b14 - added LightEdit 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 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
287 '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
288 '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
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
22253b2c9b14 - added LightEdit 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 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
292 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
293 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
294
22253b2c9b14 - added LightEdit 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 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
296 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
297 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
298 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
299 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
300 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
301
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
302 self.container.distributeInitialData({
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
303 'select_rotations' : self._avail_rotations,
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
304 'instance_id' : unicode( self._instances[0].getId() ),
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
305 '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
306 '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
307 'y_offset' : y_offset,
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
308 'instance_rotation' : unicode( self._instances[0].getRotation() ),
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
309 'object_namespace' : unicode( self._namespace ),
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
310 'object_blocking' : unicode( self._blocking ),
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
311 'object_static' : unicode( self._static ),
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
312 })
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
313
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
314 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
315 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
316 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
317 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
318 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
319 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
320 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
321 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
322
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
323
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
324 self.container.adaptLayout(False)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
326 def toggle_gui(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
327 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
328 show / hide the gui
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
330 if self.active is True:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
331 self.active = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
332 if self.container.isVisible() or self.container.isDocked():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
333 self.container.setDocked(False)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
334 self.container.hide()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
335 self._showAction.setChecked(False)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
336 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
337 self.active = True
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
338 self._showAction.setChecked(True)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
339
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
340 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
341 """ 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
342 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
343 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
344
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
345 def change_offset_x(self, value=1):
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
346 """
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
347 - 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
348 - 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
349 - 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
350
22253b2c9b14 - added LightEdit 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 @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
352 @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
353 """
22253b2c9b14 - added LightEdit 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 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
355 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
356 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
357
22253b2c9b14 - added LightEdit 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 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
359 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
360 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
361
22253b2c9b14 - added LightEdit 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 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
363 """
22253b2c9b14 - added LightEdit 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 - 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
365 - 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
366 - 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
367
22253b2c9b14 - added LightEdit 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 @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
369 @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
370 """
22253b2c9b14 - added LightEdit 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 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
372 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
373 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
374
22253b2c9b14 - added LightEdit 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 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
376 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
377 self.update_gui()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
378
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
379 def use_user_data(self):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
380 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
381 - 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
382 - writes current data record
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
383 - writes previous data record
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
384 - 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
385
22253b2c9b14 - added LightEdit 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 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
387 - 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
388 """
22253b2c9b14 - added LightEdit 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 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
390 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
391 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
392
22253b2c9b14 - added LightEdit 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 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
394 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
395
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
396 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
397
22253b2c9b14 - added LightEdit 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 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
399 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
400
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
401 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
402 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
403 if len(existing_instances) <= 0:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
404 self._instances[0].setId(instance_id)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
405 print "Set new instance id: ", instance_id
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
406 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
407 print "Instance ID is already in use."
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
408
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
409 # 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
410 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
411 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
412
22253b2c9b14 - added LightEdit 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 # 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
414 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
415
22253b2c9b14 - added LightEdit 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 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
417
22253b2c9b14 - added LightEdit 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 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
419 """ 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
420
22253b2c9b14 - added LightEdit 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 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
422 - 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
423
22253b2c9b14 - added LightEdit 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 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
425 - 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
426 """
22253b2c9b14 - added LightEdit 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 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
428 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
429 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
430 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
431
22253b2c9b14 - added LightEdit 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 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
433 self.tree = ET.parse(file)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
434
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
435 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
436
22253b2c9b14 - added LightEdit 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 # 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
438 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
439 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
440 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
441 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
442 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
443
22253b2c9b14 - added LightEdit 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 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
445
22253b2c9b14 - added LightEdit 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 # 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
447 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
448 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
449 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
450 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
451
22253b2c9b14 - added LightEdit 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 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
453 """ 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
454 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
455 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
456
22253b2c9b14 - added LightEdit 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 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
458 """ 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
459 index = self._gui_rotation_dropdown._getSelected()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
460 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
461
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
462 if angle == 360:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
463 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
464
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
465 return angle
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
466
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
467 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
468 """ 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
469 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
470
22253b2c9b14 - added LightEdit 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 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
472 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
473
22253b2c9b14 - added LightEdit 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_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
475 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
476
22253b2c9b14 - added LightEdit 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 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
478 """ 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
479 # 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
480 self._instances[0].setRotation(angle)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
481 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
482 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
483 # 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
484
22253b2c9b14 - added LightEdit 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 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
486 """ 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
487 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
488 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
489 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
490 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
491
22253b2c9b14 - added LightEdit 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 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
493 """ 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
494
22253b2c9b14 - added LightEdit 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 @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
496 @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
497 """
22253b2c9b14 - added LightEdit 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 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
499 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
500 animation = self._animationpool.getAnimation(animation_id)
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
501
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
502 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
503 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
504
22253b2c9b14 - added LightEdit 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 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
506 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
507 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
508 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
509 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
510 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
511
22253b2c9b14 - added LightEdit 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 = {}
22253b2c9b14 - added LightEdit 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['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
514 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
515 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
516 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
517 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
518 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
519 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
520 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
521
22253b2c9b14 - added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 298
diff changeset
522 return animation
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
523
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
524 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
525 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
526 - 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
527
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
528 FIXME:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
529 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
530 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
531 visual = None
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
532 self._avail_rotations = []
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
533
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
534 if instance is None:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
535 instance = self._instances[0]
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
536
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
537 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
538 self._object = object
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
539 self._namespace = object.getNamespace()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
540 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
541
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
542 self._instance_id = instance.getId()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
543
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
544 if self._instance_id == '':
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
545 self._instance_id = 'None'
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
546
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
547 if angle == -1:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
548 angle = int(instance.getRotation())
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
549 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
550 angle = int(angle)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
551
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
552 self._rotation = angle
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
553
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
554 if object.isBlocking():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
555 self._blocking = 1
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
556
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
557 if object.isStatic():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
558 self._static = 1
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
559
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
560 try:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
561 visual = object.get2dGfxVisual()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
562 except:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
563 print 'Fetching visual of object - failed. :/'
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
564 raise
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
565
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
566 # 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
567 # 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
568 # print "Instance rotation: ", instance.getRotation()
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
569
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
570 # 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
571 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
572 # 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
573
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
574 index = visual.getStaticImageIndexByAngle(self._fixed_rotation)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
575
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
576 if index is -1:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
577 # object is an animation
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
578 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
579 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
580
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
581 # no static image available, try default action
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
582 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
583
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
584 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
585 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
586
22253b2c9b14 - added LightEdit 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 # 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
588 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
589 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
590 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
591
22253b2c9b14 - added LightEdit 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 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
593 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
594 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
595 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
596 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
597 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
598 elif index is not -1:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
599 # object is a static image
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
600 self._animation = False
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
601 self._image = self.imagepool.getImage(index)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
602
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
603 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
604 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
605 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
606 # 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
607 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
608
22253b2c9b14 - added LightEdit 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_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
610 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
611 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
612 # 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
613 # rotations = [0,60,120,180,240,300]
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
614
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
615 # 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
616 # 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
617 # 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
618 # 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
619 # 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
620 # 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
621
22253b2c9b14 - added LightEdit 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 # 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
623 # 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
624 # 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
625 # 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
626 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
627
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
628 def input(self, instances):
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
629 """
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
630 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
631 gets instance data and show gui
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 """
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
634 if instances != self._instances:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
635 if self.active is True:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
636 self._reset()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
637 self._instances = instances
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
638
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
639 if self._camera is None:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
640 self._camera = self._editor.getActiveMapView().getCamera()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
641 self.renderer = fife.InstanceRenderer.getInstance(self._camera)
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
642
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
643 self._layer = self._editor.getActiveMapView().getController()._layer
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
644
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
645 if self._instances != ():
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
646 self.highlight_selected_instance()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
647 self.get_instance_data()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
648 self.update_gui()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
649 self.container.show()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
650 else:
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
651 self._reset()
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
652 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
653
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
654 self.container.adaptLayout(False)