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

Removed HelpText from C++. Moved helptext to base widget. Now all widgets may have a helptext.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 24 Mar 2009 16:06:02 +0000
parents 9b50a2702054
children
rev   line source
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 # MapEditor is a plugin for Fifedit. It allows for selection and visual editing of maps.
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 import math
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 import fife
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 import plugin
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 import pychan
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 import pychan.widgets as widgets
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 from pychan.tools import callbackWithArguments as cbwa
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 from selection import Selection, ClickSelection
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 from plugins.objectselector import ObjectSelector
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
13 SCROLL_TOLERANCE = 10
124
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
14 SCROLL_SPEED = 1.0
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
15
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 states = ('NOTHING_LOADED', 'VIEWING', 'INSERTING', 'REMOVING', 'MOVING')
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 for s in states:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 globals()[s] = s
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 NOT_INITIALIZED = -9999999
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21 class EditorLogicError(Exception):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 pass
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 class MapSelection(object):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 def __init__(self, onLayerSelect, onObjectSelect):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 self._mapedit = None
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 self._onLayerSelect = onLayerSelect
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 self._onObjectSelect = onObjectSelect
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 def show(self, map):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 if not self._mapedit:
179
28532ae6f9f6 Moved all editor content out of content, as chewie says it's deprecated as hell ;-)
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 177
diff changeset
32 self._mapedit = pychan.loadXML('gui/mapeditor.xml')
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 self._mapedit.mapEvents({
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 'layerButton' : self._onLayerSelect,
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 'objButton' : self._onObjectSelect,
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 'closeButton' : self.hide
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 })
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 fields = self._mapedit.findChild(name='Properties')
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 # Clear previously added children
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40 fields.removeChildren(*fields.children)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 hbox = widgets.HBox()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 fields.addChild(hbox)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 label = widgets.Label(text='ID',min_size=(80,0))
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 hbox.addChild(label)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 field = widgets.TextField(text=map.getId(),min_size=(100,0))
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 hbox.addChild(field)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 self._mapedit.adaptLayout()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 self._mapedit.show()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 self._mapedit.x = 10
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 self._mapedit.y = 580
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 def hide(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 self._mapedit.hide()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 class Toolbar(object):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 def __init__(self, onSelect, onMove, onInsert, onDelete, onBtnEnter, onBtnExit):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 self._onSelect, self._onMove, self._onInsert, self._onDelete = onSelect, onMove, onInsert, onDelete
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 self.onBtnEnter, self.onBtnExit = onBtnEnter, onBtnExit
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 self._toolbar = None
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
60
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 def show(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 if not self._toolbar:
179
28532ae6f9f6 Moved all editor content out of content, as chewie says it's deprecated as hell ;-)
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 177
diff changeset
63 self._toolbar = pychan.loadXML('gui/tools.xml')
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 evtmap = {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 'btnSelect' : self._onSelect,
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 'btnMove' : self._onMove,
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 'btnInsert' : self._onInsert,
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 'btnDelete' : self._onDelete
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70 self._toolbar.mapEvents(evtmap)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 for k in evtmap.keys():
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 btn = self._toolbar.findChild(name=k)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 btn.setEnterCallback(self.onBtnEnter)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 btn.setExitCallback(self.onBtnExit)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
75
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 #self._toolbar.adaptLayout()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 self._toolbar.show()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 self._toolbar.x = 10
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 self._toolbar.y = 50
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
80
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 def hide(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 self._toolbar.hide()
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
83
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 def _enableBtn(self, enabled, btn):
177
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
85 btn.toggled = enabled;
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
86
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
87 def enableSelect(self, enabled):
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
88 self._enableBtn(enabled, self._toolbar.findChild(name='btnSelect'))
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
89
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
90 def enableMove(self, enabled):
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
91 self._enableBtn(enabled, self._toolbar.findChild(name='btnMove'))
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
92
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 def enableInsert(self, enabled):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
94 self._enableBtn(enabled, self._toolbar.findChild(name='btnInsert'))
177
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
95
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
96 def enableDelete(self, enabled):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
97 self._enableBtn(enabled, self._toolbar.findChild(name='btnDelete'))
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98
177
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
99 def disableAll(self):
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
100 self.enableDelete(False)
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
101 self.enableSelect(False)
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
102 self.enableInsert(False)
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
103 self.enableMove(False)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
104
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 class StatusBar(object):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 def __init__(self, screenw, screenh):
179
28532ae6f9f6 Moved all editor content out of content, as chewie says it's deprecated as hell ;-)
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 177
diff changeset
107 self._statusbar = pychan.loadXML('gui/statuspanel.xml')
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108 self._statusbar.show()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 height = 25
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 self._statusbar.position = (0, screenh - height)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 self._statusbar.size = (screenw, height)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 self.statustxt = ''
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 self.lbl = self._statusbar.findChild(name='lblStatus')
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 def setStatus(self, msg):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 self.statustxt = msg
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 self.lbl.text = ' ' + msg
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 self.lbl.resizeToContent()
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
119
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 def showTooltip(self, elem):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 self.lbl.text = elem.helptext
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 self.lbl.resizeToContent()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 def hideTooltip(self, elem):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 self.lbl.text = self.statustxt
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 self.lbl.resizeToContent()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
127
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129 class MapEditor(plugin.Plugin,fife.IMouseListener, fife.IKeyListener):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130 def __init__(self, engine):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 self._engine = engine
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132 eventmanager = self._engine.getEventManager()
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 134
diff changeset
133 #eventmanager.setNonConsumableKeys([
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 134
diff changeset
134 #fife.Key.LEFT,
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 134
diff changeset
135 #fife.Key.RIGHT,
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 134
diff changeset
136 #fife.Key.UP,
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 134
diff changeset
137 #fife.Key.DOWN])
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138 fife.IMouseListener.__init__(self)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139 eventmanager.addMouseListener(self)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 fife.IKeyListener.__init__(self)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141 eventmanager.addKeyListener(self)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 # Fifedit plugin data
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144 self.menu_items = { 'Select Map' : self._selectMap }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 self._camera = None # currently selected camera
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 self._map = None # currently selected map
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 self._layer = None # currently selected layer
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 self._object = None # currently selected object
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 self._selection = None # currently selected coordinates
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 self._instances = None # currently selected instances
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 self._ctrldown = False
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 self._shiftdown = False
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 self._altdown = False
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 self._dragx = NOT_INITIALIZED
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 self._dragy = NOT_INITIALIZED
124
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
158 self._scrollx = 0
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
159 self._scrolly = 0
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
160
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161 self._mapselector = MapSelection(self._selectLayer, self._selectObject)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
162 self._objectselector = None
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163 rb = self._engine.getRenderBackend()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 self._statusbar = StatusBar(rb.getWidth(), rb.getHeight())
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165 self._toolbar = Toolbar(cbwa(self._setMode, VIEWING), cbwa(self._setMode, MOVING),
177
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
166 cbwa(self._setMode, INSERTING), cbwa(self._setMode, REMOVING),
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
167 self._statusbar.showTooltip, self._statusbar.hideTooltip)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 self._toolbar.show()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 self._setMode(NOTHING_LOADED)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
171 self._undoStack = []
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
172 self._undo = False # tracks whether current action is an undo
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
173
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 def _assert(self, statement, msg):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 if not statement:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 print msg
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177 raise EditorLogicError(msg)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
178
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179 def _setMode(self, mode):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180 if (mode != NOTHING_LOADED) and (not self._camera):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181 self._statusbar.setStatus('Please load map first')
177
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
182 self._toolbar.disableAll()
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 return
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 if (mode == INSERTING) and (not self._object):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 self._statusbar.setStatus('Please select object first')
177
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
186 mode = self._mode
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
187
177
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
188 # Update toolbox buttons
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
189 if (mode == INSERTING):
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
190 self._toolbar.enableInsert(True)
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
191 elif mode == VIEWING:
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
192 self._toolbar.enableSelect(True)
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
193 elif mode == REMOVING:
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
194 self._toolbar.enableDelete(True)
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
195 elif mode == MOVING:
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
196 self._toolbar.enableMove(True)
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
197 else:
3fb17daa1b27 * Added ToggleButton widget
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 157
diff changeset
198 self._toolbar.disableAll()
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
199
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 self._mode = mode
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 print "Entered mode " + mode
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 self._statusbar.setStatus(mode.replace('_', ' ').capitalize())
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
203
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204 # gui for selecting a map
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 def _selectMap(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 Selection([map.getId() for map in self._engine.getModel().getMaps()], self.editMap)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208 def _selectDefaultCamera(self, map):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209 self._camera = None
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
210
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
211 self._engine.getView().resetRenderers()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 for cam in self._engine.getView().getCameras():
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213 cam.setEnabled(False)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
214
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
215 for cam in self._engine.getView().getCameras():
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
216 if cam.getLocationRef().getMap().getId() == map.getId():
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
217 rb = self._engine.getRenderBackend()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
218 cam.setViewPort(fife.Rect(0, 0, rb.getScreenWidth(), rb.getScreenHeight()))
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219 cam.setEnabled(True)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
220 self._camera = cam
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221 break
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
222 if not self._camera:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
223 raise AttributeError('No cameras found associated with this map: ' + map.getId())
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
224
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
225 def editMap(self, mapid):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226 self._camera = None
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
227 self._map = None
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228 self._layer = None
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
229 self._object = None
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230 self._selection = None
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231 self._instances = None
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 self._setMode(NOTHING_LOADED)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
233
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234 self._map = self._engine.getModel().getMap(mapid)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235 if not self._map.getLayers():
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 raise AttributeError('Editor error: map ' + self._map.getId() + ' has no layers. Cannot edit.')
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
237
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238 self._layer = self._map.getLayers()[0]
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
239 self._selectDefaultCamera(self._map)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240 self._setMode(VIEWING)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
241
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
242 self._mapselector.show(self._map)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
243
182
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
244 # zero-projekt plugin
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
245 if self.layertool is not None:
bcc93e17f978 - added new plugin to FIFedit (Layertool)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
246 self.layertool.update()
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
247
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
248 def _selectLayer(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 Selection([layer.getId() for layer in self._map.getLayers()], self._editLayer)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251 def _editLayer(self, layerid):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
252 self._layer = None
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253 layers = [l for l in self._map.getLayers() if l.getId() == layerid]
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254 self._assert(len(layers) == 1, 'Layer amount != 1')
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 self._layer = layers[0]
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 def _selectObject(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 if not self._objectselector:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 self._objectselector = ObjectSelector(self._engine, self._map, self._editObject)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 self._objectselector.show()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 def _editObject(self, object):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
263 self._object = object
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265 def _selectCell(self, screenx, screeny, preciseCoords=False):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 self._assert(self._camera, 'No camera bind yet, cannot select any cell')
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
267
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 self._selection = self._camera.toMapCoordinates(fife.ScreenPoint(screenx, screeny), False)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
269 self._selection.z = 0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
270 loc = fife.Location(self._layer)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271 if preciseCoords:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272 self._selection = self._layer.getCellGrid().toExactLayerCoordinates(self._selection)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 loc.setExactLayerCoordinates(self._selection)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 else:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 self._selection = self._layer.getCellGrid().toLayerCoordinates(self._selection)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 loc.setLayerCoordinates(self._selection)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 fife.CellSelectionRenderer.getInstance(self._camera).selectLocation(loc)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278 return loc
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
280 def _getInstancesFromPosition(self, position, top_only):
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
281 self._assert(self._layer, 'No layer assigned in _getInstancesFromPosition')
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
282 self._assert(position, 'No position assigned in _getInstancesFromPosition')
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
283 self._assert(self._camera, 'No camera assigned in _getInstancesFromPosition')
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
284
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
285 loc = fife.Location(self._layer)
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
286 if type(position) == fife.ExactModelCoordinate:
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
287 loc.setExactLayerCoordinates(position)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
288 else:
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
289 loc.setLayerCoordinates(position)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
290 instances = self._camera.getMatchingInstances(loc)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
291 if top_only and (len(instances) > 0):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
292 instances = [instances[0]]
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
293 return instances
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
294
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
295 def undo(self):
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
296 if self._undoStack != []:
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
297 # execute inverse of last action
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
298 self._undo = True
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
299 self._undoStack.pop()()
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
300 self._undo = False
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
301
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
302 def _placeInstance(self,position,object):
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
303 mname = '_placeInstance'
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
304 self._assert(object, 'No object assigned in %s' % mname)
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
305 self._assert(position, 'No position assigned in %s' % mname)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
306 self._assert(self._layer, 'No layer assigned in %s' % mname)
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
307
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
308 print 'Placing instance of ' + object.getId() + ' at ' + str(position)
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
309 print object
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
310
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
311 # don't place repeat instances
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
312 for i in self._getInstancesFromPosition(position, False):
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
313 if i.getObject().getId() == object.getId():
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
314 print 'Warning: attempt to place duplicate instance of object %s. Ignoring request.' % object.getId()
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
315 return
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
316
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
317 inst = self._layer.createInstance(object, position)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
318 fife.InstanceVisual.create(inst)
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
319 if not self._undo:
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
320 self._undoStack.append(lambda: self._removeInstances(position))
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
321
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
322 def _removeInstances(self,position):
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
323 mname = '_removeInstances'
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
324 self._assert(position, 'No position assigned in %s' % mname)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325 self._assert(self._layer, 'No layer assigned in %s' % mname)
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
326
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
327 for i in self._getInstancesFromPosition(position, top_only=True):
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
328 print 'Deleting instance ' + str(i) + ' at ' + str(position)
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
329 if not self._undo:
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
330 print '>>> ' + i.getObject().getId()
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
331 print '>>> ' + str(i.getObject())
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
332 object = i.getObject()
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
333 self._undoStack.append(lambda: self._placeInstance(position,object))
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
334 self._layer.deleteInstance(i)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
335
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
336 def _moveInstances(self):
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
337 mname = '_moveInstances'
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
338 self._assert(self._selection, 'No selection assigned in %s' % mname)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
339 self._assert(self._layer, 'No layer assigned in %s' % mname)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
340 self._assert(self._mode == MOVING, 'Mode is not MOVING in %s (is instead %s)' % (mname, str(self._mode)))
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
341
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
342 loc = fife.Location(self._layer)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
343 if self._shiftdown:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
344 loc.setExactLayerCoordinates(self._selection)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
345 else:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
346 loc.setLayerCoordinates(self._selection)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
347 for i in self._instances:
101
adf0f2b6d1b0 fixed rotating instances when moving them
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 50
diff changeset
348 f = fife.Location(self._layer)
adf0f2b6d1b0 fixed rotating instances when moving them
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 50
diff changeset
349 f.setExactLayerCoordinates(i.getFacingLocation().getExactLayerCoordinates() + fife.ExactModelCoordinate(float(self._selection.x), float(self._selection.y)) - i.getLocation().getExactLayerCoordinates())
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
350 i.setLocation(loc)
101
adf0f2b6d1b0 fixed rotating instances when moving them
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 50
diff changeset
351 i.setFacingLocation(f)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
352
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
353 def _rotateInstances(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
354 mname = '_rotateInstances'
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
355 self._assert(self._selection, 'No selection assigned in %s' % mname)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
356 self._assert(self._layer, 'No layer assigned in %s' % mname)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
357
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
358 for i in self._getInstancesFromPosition(self._selection, top_only=True):
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
359 # by c 09/11/08
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
360 # FIXME:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
361 # "hardcoded" rotation is bad for offset editing
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
362 # instead we should use the angle list given from the object
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
363 # animations are an issue, as a workaround settings.py provides
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
364 # project specific animation angles
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
365 try:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
366 if self._objectedit_rotations is not None:
183
fcef34d67ad9 - fixed small but silly bug for the objectedit plugin (forgot to complete renaming)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 182
diff changeset
367 # print "available angles: ", self._objectedit_rotations
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
368 rotation_prev = i.getRotation()
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
369 # print "previous rotation: ", rotation_prev
183
fcef34d67ad9 - fixed small but silly bug for the objectedit plugin (forgot to complete renaming)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 182
diff changeset
370 length = len(self._objectedit_rotations)
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
371 # print "length: ", length
183
fcef34d67ad9 - fixed small but silly bug for the objectedit plugin (forgot to complete renaming)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 182
diff changeset
372 index = self._objectedit_rotations.index( str(rotation_prev) )
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
373 # print "index, old: ", index
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
374 if index < length - 1:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
375 index += 1
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
376 elif index == length:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
377 index = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
378 else:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
379 index = 0
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
380 # print "index, new: ", index
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
381
183
fcef34d67ad9 - fixed small but silly bug for the objectedit plugin (forgot to complete renaming)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 182
diff changeset
382 i.setRotation( int(self._objectedit_rotations[index]) )
fcef34d67ad9 - fixed small but silly bug for the objectedit plugin (forgot to complete renaming)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 182
diff changeset
383 # print "new rotation: ", self._objectedit_rotations[index]
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
384 except:
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
385 # Fallback
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
386 i.setRotation((i.getRotation() + 90) % 360)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
387
134
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
388 # end FIXME
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
389 # end edit c
ade070598fd1 - added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 124
diff changeset
390
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
391 ## Surprisingly, the following "snap-to-rotation" code is actually incorrect. Object
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
392 ## rotation is independent of the camera, whereas the choice of an actual rotation image
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
393 ## depends very much on how the camera is situated. For example, suppose an object has
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
394 ## rotations defined for 45,135,225,315. And suppose the camera position results in an
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
395 ## effective 60 degree rotation. If the object is given a rotation of 0, then the (correct)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
396 ## final rotation value of 45 (which is closest to 60 = 0 + 60) will be chosen. If we try
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
397 ## to snap to the closest value to 0 (45), then an incorrect final rotation value will be
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
398 ## chosen: 135, which is closest to 105 = 45 + 60. --jwt
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
399 # ovis = i.getObject().get2dGfxVisual()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
400 # curUsedAngle = ovis.getClosestMatchingAngle(i.getRotation())
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
401 # angles = ovis.getStaticImageAngles()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
402 # if angles:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
403 # ind = list(angles).index(curUsedAngle)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
404 # if ind == (len(angles) - 1):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
405 # ind = 0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
406 # else:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
407 # ind += 1
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
408 # i.setRotation(angles[ind])
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
409 # else:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
410 # print "rotation not supported for this instance"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
411
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
412 def changeRotation(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
413 currot = self._camera.getRotation()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
414 self._camera.setRotation((currot + 90) % 360)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
415
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
416 def _moveCamera(self, screen_x, screen_y):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
417 coords = self._camera.getLocationRef().getMapCoordinates()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
418 z = self._camera.getZoom()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
419 r = self._camera.getRotation()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
420 if screen_x:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
421 coords.x -= screen_x / z * math.cos(r / 180.0 * math.pi) / 100;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
422 coords.y -= screen_x / z * math.sin(r / 180.0 * math.pi) / 100;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
423 if screen_y:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
424 coords.x -= screen_y / z * math.sin(-r / 180.0 * math.pi) / 100;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
425 coords.y -= screen_y / z * math.cos(-r / 180.0 * math.pi) / 100;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
426 coords = self._camera.getLocationRef().setMapCoordinates(coords)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
427 self._camera.refresh()
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
428
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
429 def mousePressed(self, evt):
50
9d0a21184c13 fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
430 if evt.isConsumedByWidgets():
9d0a21184c13 fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
431 return
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
432
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
433 if self._ctrldown:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
434 if evt.getButton() == fife.MouseEvent.LEFT:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
435 self._dragx = evt.getX()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
436 self._dragy = evt.getY()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
437 else:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
438 if self._camera:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
439 self._selectCell(evt.getX(), evt.getY(), self._shiftdown)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
440 if self._mode == VIEWING:
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
441 self._instances = self._getInstancesFromPosition(self._selection, top_only=True)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
442 elif self._mode == INSERTING:
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
443 self._placeInstance(self._selection,self._object)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
444 elif self._mode == REMOVING:
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
445 self._removeInstances(self._selection)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
446 elif self._mode == MOVING:
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
447 self._instances = self._getInstancesFromPosition(self._selection, top_only=True)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
448 else:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
449 self._setMode(self._mode) # refresh status
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
450
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
451 def mouseDragged(self, evt):
50
9d0a21184c13 fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
452 if evt.isConsumedByWidgets():
9d0a21184c13 fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
453 return
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
454
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
455 if self._ctrldown:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
456 if (self._dragx != NOT_INITIALIZED) and (self._dragy != NOT_INITIALIZED):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
457 self._moveCamera(evt.getX() - self._dragx, evt.getY() - self._dragy)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
458 self._dragx = evt.getX()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
459 self._dragy = evt.getY()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
460 else:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
461 if self._mode == INSERTING:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
462 self._selectCell(evt.getX(), evt.getY())
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
463 self._placeInstance(self._selection,self._object)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
464 elif self._mode == REMOVING:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
465 self._selectCell(evt.getX(), evt.getY())
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
466 self._removeInstances(self._selection)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
467 elif self._mode == MOVING and self._instances:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
468 self._selectCell(evt.getX(), evt.getY(), self._shiftdown)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
469 self._moveInstances()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
470
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
471 def mouseReleased(self, evt):
50
9d0a21184c13 fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
472 if evt.isConsumedByWidgets():
9d0a21184c13 fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
473 return
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
474
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
475 self._dragx = NOT_INITIALIZED
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
476 self._dragy = NOT_INITIALIZED
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
477
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
478 def mouseMoved(self, evt):
124
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
479 if self._camera:
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
480 screen_x = self._engine.getRenderBackend().getWidth()
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
481 screen_y = self._engine.getRenderBackend().getHeight()
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
482 ratio = float(screen_x) / screen_y
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
483
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
484 mouse_x = evt.getX()
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
485 mouse_y = evt.getY()
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
486
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
487 self._scrollx = 0
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
488 self._scrolly = 0
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
489
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
490 if mouse_y <= SCROLL_TOLERANCE:
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
491 # up
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
492 self._scrolly = SCROLL_SPEED * ratio
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
493 if mouse_x >= screen_x - SCROLL_TOLERANCE:
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
494 # right
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
495 self._scrollx = -SCROLL_SPEED
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
496 if mouse_y >= screen_y - SCROLL_TOLERANCE:
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
497 # bottom
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
498 self._scrolly = -SCROLL_SPEED * ratio
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
499 if mouse_x <= SCROLL_TOLERANCE:
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
500 # left
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
501 self._scrollx = SCROLL_SPEED
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
502
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
503 def mouseEntered(self, evt):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
504 pass
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
505 def mouseExited(self, evt):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
506 pass
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
507 def mouseClicked(self, evt):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
508 pass
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
509
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
510 def mouseWheelMovedUp(self, evt):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
511 if self._ctrldown and self._camera:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
512 self._camera.setZoom(self._camera.getZoom() * 1.05)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
513
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
514 def mouseWheelMovedDown(self, evt):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
515 if self._ctrldown and self._camera:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
516 self._camera.setZoom(self._camera.getZoom() / 1.05)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
517
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
518
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
519 def keyPressed(self, evt):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
520 keyval = evt.getKey().getValue()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
521 keystr = evt.getKey().getAsString().lower()
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
522
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
523 if keyval == fife.Key.LEFT:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
524 self._moveCamera(50, 0)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
525 elif keyval == fife.Key.RIGHT:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
526 self._moveCamera(-50, 0)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
527 elif keyval == fife.Key.UP:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
528 self._moveCamera(0, 50)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
529 elif keyval == fife.Key.DOWN:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
530 self._moveCamera(0, -50)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
531 elif keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
532 self._ctrldown = True
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
533 elif keyval in (fife.Key.LEFT_SHIFT, fife.Key.RIGHT_SHIFT):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
534 self._shiftdown = True
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
535 elif keyval in (fife.Key.LEFT_ALT, fife.Key.RIGHT_ALT):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
536 self._altdown = True
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
537
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
538 elif keyval == fife.Key.INSERT:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
539 if self._mode != INSERTING:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
540 self._setMode(INSERTING)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
541 else:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
542 self._setMode(VIEWING)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
543
115
c94c76346027 * Key event fix for map editor by chewie
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 108
diff changeset
544 elif keyval == fife.Key.DELETE:
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
545 if self._mode != REMOVING:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
546 self._setMode(REMOVING)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
547 else:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
548 self._setMode(VIEWING)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
549
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
550 elif keystr == 'm':
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
551 if self._mode != MOVING:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
552 self._setMode(MOVING)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
553 else:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
554 self._setMode(VIEWING)
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
555
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
556 elif keystr == 't':
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
557 gridrenderer = self._camera.getRenderer('GridRenderer')
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
558 gridrenderer.setEnabled(not gridrenderer.isEnabled())
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
559
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
560 elif keystr == 'b':
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
561 blockrenderer = self._camera.getRenderer('BlockingInfoRenderer')
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
562 blockrenderer.setEnabled(not blockrenderer.isEnabled())
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
563
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
564 elif keystr == 'r':
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
565 if self._selection:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
566 self._rotateInstances()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
567
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
568 elif keystr == 'o':
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
569 self.changeRotation()
108
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
570
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
571 elif keystr == 'u':
0c017b8e4ab2 Added an undo feature to the map editor. Just press u to undo insert placement/removals.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 101
diff changeset
572 self.undo()
192
bec4b69ad83a * Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 183
diff changeset
573
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
574 def keyReleased(self, evt):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
575 keyval = evt.getKey().getValue()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
576 if keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
577 self._ctrldown = False
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
578 elif keyval in (fife.Key.LEFT_SHIFT, fife.Key.RIGHT_SHIFT):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
579 self._shiftdown = False
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
580 elif keyval in (fife.Key.LEFT_ALT, fife.Key.RIGHT_ALT):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
581 self._altdown = False
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
582
124
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
583 def pump(self):
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
584 if self._scrollx != 0 or self._scrolly != 0:
d5658e6c34f5 Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 115
diff changeset
585 self._moveCamera(self._scrollx * self._engine.getTimeManager().getTimeDelta(), self._scrolly * self._engine.getTimeManager().getTimeDelta())