Mercurial > fife-parpg
annotate clients/editor/plugins/mapeditor.py @ 134:ade070598fd1
- added object editor plugin
NOTES:
- plugin is not ready for productive enviroments, yet
- lacks saving functionality
- some issues left, but it works better as previous versions ;-)
author | chewie@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 13 Sep 2008 23:28:52 +0000 |
parents | d5658e6c34f5 |
children | bb9902910067 |
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 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 from pychan.manager import DEFAULT_STYLE |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 DEFAULT_STYLE['default']['base_color'] = fife.Color(85,128,151) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 |
134
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
16 SCROLL_TOLERANCE = 10 |
124
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
17 SCROLL_SPEED = 1.0 |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
18 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 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
|
20 for s in states: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 globals()[s] = s |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 NOT_INITIALIZED = -9999999 |
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 EditorLogicError(Exception): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 pass |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 class MapSelection(object): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 def __init__(self, onLayerSelect, onObjectSelect): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 self._mapedit = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 self._onLayerSelect = onLayerSelect |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 self._onObjectSelect = onObjectSelect |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 def show(self, map): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 if not self._mapedit: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 self._mapedit = pychan.loadXML('content/gui/mapeditor.xml') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 self._mapedit.mapEvents({ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 'layerButton' : self._onLayerSelect, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 'objButton' : self._onObjectSelect, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 'closeButton' : self.hide |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 }) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 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
|
42 # Clear previously added children |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 fields.removeChildren(*fields.children) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 hbox = widgets.HBox() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 fields.addChild(hbox) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 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
|
47 hbox.addChild(label) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 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
|
49 hbox.addChild(field) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 self._mapedit.adaptLayout() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 self._mapedit.show() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 self._mapedit.x = 10 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 self._mapedit.y = 580 |
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 def hide(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 self._mapedit.hide() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 class Toolbar(object): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 self._toolbar = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 def show(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 if not self._toolbar: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 self._toolbar = pychan.loadXML('content/gui/tools.xml') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 evtmap = { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 'btnSelect' : self._onSelect, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 'btnMove' : self._onMove, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 'btnInsert' : self._onInsert, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 'btnDelete' : self._onDelete |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 self._toolbar.mapEvents(evtmap) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 for k in evtmap.keys(): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 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
|
76 btn.setEnterCallback(self.onBtnEnter) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 btn.setExitCallback(self.onBtnExit) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 #self._toolbar.adaptLayout() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 self._toolbar.show() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 self._toolbar.x = 10 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 self._toolbar.y = 50 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 def hide(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 self._toolbar.hide() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 def _enableBtn(self, enabled, btn): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 pass |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 def enableInsert(self, enabled): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 self._enableBtn(enabled, self._toolbar.findChild(name='btnInsert')) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
92 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 def enableDelete(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='btnDelete')) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 def enableSelect(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='btnSelect')) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 class StatusBar(object): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 def __init__(self, screenw, screenh): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 self._statusbar = pychan.loadXML('content/gui/statuspanel.xml') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 self._statusbar.show() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 height = 25 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 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
|
105 self._statusbar.size = (screenw, height) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
106 self.statustxt = '' |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 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
|
108 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 def setStatus(self, msg): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 self.statustxt = msg |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 self.lbl.text = ' ' + msg |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 self.lbl.resizeToContent() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 def showTooltip(self, elem): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
115 self.lbl.text = elem.helptext |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
116 self.lbl.resizeToContent() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 def hideTooltip(self, elem): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 self.lbl.text = self.statustxt |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 self.lbl.resizeToContent() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 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
|
124 def __init__(self, engine): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
125 self._engine = engine |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
126 eventmanager = self._engine.getEventManager() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
127 eventmanager.setNonConsumableKeys([ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
128 fife.Key.LEFT, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
129 fife.Key.RIGHT, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
130 fife.Key.UP, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
131 fife.Key.DOWN]) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
132 fife.IMouseListener.__init__(self) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
133 eventmanager.addMouseListener(self) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
134 fife.IKeyListener.__init__(self) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
135 eventmanager.addKeyListener(self) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
136 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
137 # Fifedit plugin data |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
138 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
|
139 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
147 self._ctrldown = False |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
148 self._shiftdown = False |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
149 self._altdown = False |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
150 self._dragx = NOT_INITIALIZED |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
151 self._dragy = NOT_INITIALIZED |
124
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
152 self._scrollx = 0 |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
153 self._scrolly = 0 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
154 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
155 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
|
156 self._objectselector = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
157 rb = self._engine.getRenderBackend() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
158 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
|
159 self._toolbar = Toolbar(cbwa(self._setMode, VIEWING), cbwa(self._setMode, MOVING), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
160 cbwa(self._setMode, INSERTING), cbwa(self._setMode, REMOVING), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
161 self._statusbar.showTooltip, self._statusbar.hideTooltip) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
162 self._toolbar.show() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
163 self._setMode(NOTHING_LOADED) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
164 |
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
|
165 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
|
166 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
|
167 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
168 def _assert(self, statement, msg): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
169 if not statement: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
170 print msg |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
171 raise EditorLogicError(msg) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
172 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
173 def _setMode(self, mode): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
174 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
|
175 self._statusbar.setStatus('Please load map first') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
176 return |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
177 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
|
178 self._statusbar.setStatus('Please select object first') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
179 return |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
180 self._mode = mode |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
181 print "Entered mode " + mode |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
182 self._statusbar.setStatus(mode.replace('_', ' ').capitalize()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
183 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
184 # gui for selecting a map |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
185 def _selectMap(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
186 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
|
187 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
188 def _selectDefaultCamera(self, map): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
189 self._camera = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
190 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
191 self._engine.getView().resetRenderers() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
192 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
|
193 cam.setEnabled(False) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
194 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
195 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
|
196 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
|
197 rb = self._engine.getRenderBackend() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
198 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
|
199 cam.setEnabled(True) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
200 self._camera = cam |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
201 break |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
202 if not self._camera: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
203 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
|
204 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
205 def editMap(self, mapid): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
206 self._camera = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
207 self._map = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
208 self._layer = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
209 self._object = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
210 self._selection = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
211 self._instances = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
212 self._setMode(NOTHING_LOADED) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
213 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
214 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
|
215 if not self._map.getLayers(): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
216 raise AttributeError('Editor error: map ' + self._map.getId() + ' has no layers. Cannot edit.') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
217 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
218 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
|
219 self._selectDefaultCamera(self._map) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
220 self._setMode(VIEWING) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
221 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
222 self._mapselector.show(self._map) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
223 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
224 def _selectLayer(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
225 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
|
226 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
227 def _editLayer(self, layerid): |
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 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
|
230 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
|
231 self._layer = layers[0] |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
232 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
233 def _selectObject(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
234 if not self._objectselector: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
235 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
|
236 self._objectselector.show() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
237 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
238 def _editObject(self, object): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
239 self._object = object |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
240 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
241 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
|
242 self._assert(self._camera, 'No camera bind yet, cannot select any cell') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
243 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
244 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
|
245 self._selection.z = 0 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
246 loc = fife.Location(self._layer) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
247 if preciseCoords: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
248 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
|
249 loc.setExactLayerCoordinates(self._selection) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
250 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
251 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
|
252 loc.setLayerCoordinates(self._selection) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
253 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
|
254 return loc |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
255 |
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
|
256 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
|
257 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
|
258 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
|
259 self._assert(self._camera, 'No camera assigned in _getInstancesFromPosition') |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
260 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
261 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
|
262 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
|
263 loc.setExactLayerCoordinates(position) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
264 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
|
265 loc.setLayerCoordinates(position) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
266 instances = self._camera.getMatchingInstances(loc) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
267 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
|
268 instances = [instances[0]] |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
269 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
|
270 |
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
|
271 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
|
272 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
|
273 # 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
|
274 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
|
275 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
|
276 self._undo = False |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
277 |
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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 |
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
|
284 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
|
285 print object |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
286 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
287 # 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
|
288 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
|
289 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
|
290 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
|
291 return |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
292 |
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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 |
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
|
298 def _removeInstances(self,position): |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
299 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
|
300 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
|
301 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
|
302 |
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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 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
|
310 self._layer.deleteInstance(i) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
311 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
312 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
|
313 mname = '_moveInstances' |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
314 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
|
315 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
|
316 self._assert(self._mode == MOVING, 'Mode is not MOVING in %s (is instead %s)' % (mname, str(self._mode))) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
317 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
318 loc = fife.Location(self._layer) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
319 if self._shiftdown: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
320 loc.setExactLayerCoordinates(self._selection) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
321 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
322 loc.setLayerCoordinates(self._selection) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
323 for i in self._instances: |
101
adf0f2b6d1b0
fixed rotating instances when moving them
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
50
diff
changeset
|
324 f = fife.Location(self._layer) |
adf0f2b6d1b0
fixed rotating instances when moving them
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
50
diff
changeset
|
325 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
|
326 i.setLocation(loc) |
101
adf0f2b6d1b0
fixed rotating instances when moving them
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
50
diff
changeset
|
327 i.setFacingLocation(f) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
328 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
329 def _rotateInstances(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
330 mname = '_rotateInstances' |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
331 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
|
332 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
|
333 |
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
|
334 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
|
335 # by c 09/11/08 |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
336 # FIXME: |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
337 # "hardcoded" rotation is bad for offset editing |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
338 # 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
|
339 # 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
|
340 # project specific animation angles |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
341 try: |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
342 if self._objectedit_rotations is not None: |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
343 # print "available angles: ", self._offsetedit_rotations |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
344 rotation_prev = i.getRotation() |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
345 # print "previous rotation: ", rotation_prev |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
346 length = len(self._offsetedit_rotations) |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
347 # print "length: ", length |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
348 index = self._offsetedit_rotations.index( str(rotation_prev) ) |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
349 # print "index, old: ", index |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
350 if index < length - 1: |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
351 index += 1 |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
352 elif index == length: |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
353 index = 0 |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
354 else: |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
355 index = 0 |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
356 # print "index, new: ", index |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
357 |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
358 i.setRotation( int(self._offsetedit_rotations[index]) ) |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
359 # print "new rotation: ", self._offsetedit_rotations[index] |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
360 except: |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
361 # Fallback |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
362 i.setRotation((i.getRotation() + 90) % 360) |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
363 # end FIXME |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
364 # end edit c |
ade070598fd1
- added object editor plugin
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
124
diff
changeset
|
365 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
366 ## 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
|
367 ## 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
|
368 ## 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
|
369 ## 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
|
370 ## 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
|
371 ## 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
|
372 ## 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
|
373 ## 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
|
374 # ovis = i.getObject().get2dGfxVisual() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
375 # curUsedAngle = ovis.getClosestMatchingAngle(i.getRotation()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
376 # angles = ovis.getStaticImageAngles() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
377 # if angles: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
378 # ind = list(angles).index(curUsedAngle) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
379 # if ind == (len(angles) - 1): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
380 # ind = 0 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
381 # else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
382 # ind += 1 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
383 # i.setRotation(angles[ind]) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
384 # else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
385 # 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
|
386 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
387 def changeRotation(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
388 currot = self._camera.getRotation() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
389 self._camera.setRotation((currot + 90) % 360) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
390 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
391 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
|
392 coords = self._camera.getLocationRef().getMapCoordinates() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
393 z = self._camera.getZoom() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
394 r = self._camera.getRotation() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
395 if screen_x: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
396 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
|
397 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
|
398 if screen_y: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
399 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
|
400 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
|
401 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
|
402 self._camera.refresh() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
403 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
404 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
|
405 if evt.isConsumedByWidgets(): |
9d0a21184c13
fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
406 return |
9d0a21184c13
fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
407 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
408 if self._ctrldown: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
409 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
|
410 self._dragx = evt.getX() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
411 self._dragy = evt.getY() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
412 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
413 if self._camera: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
414 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
|
415 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
|
416 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
|
417 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
|
418 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
|
419 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
|
420 self._removeInstances(self._selection) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
421 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
|
422 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
|
423 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
424 self._setMode(self._mode) # refresh status |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
425 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
426 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
|
427 if evt.isConsumedByWidgets(): |
9d0a21184c13
fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
428 return |
9d0a21184c13
fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
429 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
430 if self._ctrldown: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
431 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
|
432 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
|
433 self._dragx = evt.getX() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
434 self._dragy = evt.getY() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
435 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
436 if self._mode == INSERTING: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
437 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
|
438 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
|
439 elif self._mode == REMOVING: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
440 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
|
441 self._removeInstances(self._selection) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
442 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
|
443 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
|
444 self._moveInstances() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
445 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
446 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
|
447 if evt.isConsumedByWidgets(): |
9d0a21184c13
fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
448 return |
9d0a21184c13
fix for editor, gui event consumption was not checked properly
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
449 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
450 self._dragx = NOT_INITIALIZED |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
451 self._dragy = NOT_INITIALIZED |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
452 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
453 def mouseMoved(self, evt): |
124
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
454 if self._camera: |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
455 screen_x = self._engine.getRenderBackend().getWidth() |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
456 screen_y = self._engine.getRenderBackend().getHeight() |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
457 ratio = float(screen_x) / screen_y |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
458 |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
459 mouse_x = evt.getX() |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
460 mouse_y = evt.getY() |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
461 |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
462 self._scrollx = 0 |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
463 self._scrolly = 0 |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
464 |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
465 if mouse_y <= SCROLL_TOLERANCE: |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
466 # up |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
467 self._scrolly = SCROLL_SPEED * ratio |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
468 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
|
469 # right |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
470 self._scrollx = -SCROLL_SPEED |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
471 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
|
472 # bottom |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
473 self._scrolly = -SCROLL_SPEED * ratio |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
474 if mouse_x <= SCROLL_TOLERANCE: |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
475 # left |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
476 self._scrollx = SCROLL_SPEED |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
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 mouseEntered(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
479 pass |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
480 def mouseExited(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
481 pass |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
482 def mouseClicked(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
483 pass |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
484 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
485 def mouseWheelMovedUp(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
486 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
|
487 self._camera.setZoom(self._camera.getZoom() * 1.05) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
488 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
489 def mouseWheelMovedDown(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
490 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
|
491 self._camera.setZoom(self._camera.getZoom() / 1.05) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
492 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
493 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
494 def keyPressed(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
495 keyval = evt.getKey().getValue() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
496 keystr = evt.getKey().getAsString().lower() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
497 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
498 if keyval == fife.Key.LEFT: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
499 self._moveCamera(50, 0) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
500 elif keyval == fife.Key.RIGHT: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
501 self._moveCamera(-50, 0) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
502 elif keyval == fife.Key.UP: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
503 self._moveCamera(0, 50) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
504 elif keyval == fife.Key.DOWN: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
505 self._moveCamera(0, -50) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
506 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
|
507 self._ctrldown = True |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
508 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
|
509 self._shiftdown = True |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
510 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
|
511 self._altdown = True |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
512 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
513 elif keyval == fife.Key.INSERT: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
514 if self._mode != INSERTING: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
515 self._setMode(INSERTING) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
516 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
517 self._setMode(VIEWING) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
518 |
115
c94c76346027
* Key event fix for map editor by chewie
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
108
diff
changeset
|
519 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
|
520 if self._mode != REMOVING: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
521 self._setMode(REMOVING) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
522 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
523 self._setMode(VIEWING) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
524 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
525 elif keystr == 'm': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
526 if self._mode != MOVING: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
527 self._setMode(MOVING) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
528 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
529 self._setMode(VIEWING) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
530 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
531 elif keystr == 't': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
532 gridrenderer = self._camera.getRenderer('GridRenderer') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
533 gridrenderer.setEnabled(not gridrenderer.isEnabled()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
534 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
535 elif keystr == 'b': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
536 blockrenderer = self._camera.getRenderer('BlockingInfoRenderer') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
537 blockrenderer.setEnabled(not blockrenderer.isEnabled()) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
538 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
539 elif keystr == 'r': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
540 if self._selection: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
541 self._rotateInstances() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
542 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
543 elif keystr == 'o': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
544 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
|
545 |
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
|
546 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
|
547 self.undo() |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
548 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
549 def keyReleased(self, evt): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
550 keyval = evt.getKey().getValue() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
551 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
|
552 self._ctrldown = False |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
553 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
|
554 self._shiftdown = False |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
555 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
|
556 self._altdown = False |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
557 |
124
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
558 def pump(self): |
d5658e6c34f5
Added scrolling support the the editor client.
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
115
diff
changeset
|
559 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
|
560 self._moveCamera(self._scrollx * self._engine.getTimeManager().getTimeDelta(), self._scrolly * self._engine.getTimeManager().getTimeDelta()) |