Mercurial > fife-parpg
annotate clients/editor/plugins/LayerTool.py @ 337:f9aca52c7c45
VFS:
* Emit warning for upper case filenames. Fixes #122.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 24 Aug 2009 16:06:30 +0000 |
parents | e249fa887259 |
children | 7e5717105212 |
rev | line source |
---|---|
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # coding: utf-8 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 # ################################################### |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # Copyright (C) 2008 The Zero-Projekt team |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 # http://zero-projekt.net |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # info@zero-projekt.net |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # This file is part of Zero "Was vom Morgen blieb" |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # The Zero-Projekt codebase is free software; you can redistribute it and/or modify |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # it under the terms of the GNU General Public License as published by |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # the Free Software Foundation; either version 2 of the License, or |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # (at your option) any later version. |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # This program is distributed in the hope that it will be useful, |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # GNU General Public License for more details. |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # You should have received a copy of the GNU General Public License |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # along with this program; if not, write to the |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # Free Software Foundation, Inc., |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # ################################################### |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
322
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
24 """ A layertool plugin for FIFedit """ |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 import fife |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 import scripts.plugin as plugin |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 import scripts.editor |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 from scripts.events import * |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 from scripts.gui.action import Action |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 import pychan |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 import pychan.widgets as widgets |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 from pychan.tools import callbackWithArguments as cbwa |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 # default should be pychan default, highlight can be choosen (format: r,g,b) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 _DEFAULT_BACKGROUND_COLOR = pychan.internal.DEFAULT_STYLE['default']['base_color'] |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 _HIGHLIGHT_BACKGROUND_COLOR = pychan.internal.DEFAULT_STYLE['default']['selection_color'] |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 # the dynamicly created widgets have the name scheme prefix + layerid |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 _LABEL_NAME_PREFIX = "select_" |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 class LayerTool(plugin.Plugin): |
322
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
43 """ The B{LayerTool} allows to select and show / hide layers of a loaded |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
44 map as well as creating new layers or edit layer properties |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 def __init__(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 self._editor = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 self._enabled = False |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 self._mapview = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 self._showAction = None |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 self.subwrappers = [] |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
54 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
55 self._layer_wizard = None |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 #--- Plugin function ---# |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 def enable(self): |
303
a33576d94f32
- eliminated magic number
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
298
diff
changeset
|
59 """ """ |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 if self._enabled is True: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 return |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 # Fifedit plugin data |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 self._editor = scripts.editor.getEditor() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 self._showAction = Action(u"LayerTool", checkable=True) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 scripts.gui.action.activated.connect(self.toggle, sender=self._showAction) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 self._editor._toolsMenu.addAction(self._showAction) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 self.__create_gui() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 self.toggle() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 events.postMapShown.connect(self.update) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 def disable(self): |
303
a33576d94f32
- eliminated magic number
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
298
diff
changeset
|
76 """ """ |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 if self._enabled is False: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 return |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 self.container.setDocked(False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 self.container.hide() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 events.postMapShown.disconnect(self.update) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 self._editor._toolsMenu.removeAction(self._showAction) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 def isEnabled(self): |
303
a33576d94f32
- eliminated magic number
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
298
diff
changeset
|
87 """ """ |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 return self._enabled; |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 def getName(self): |
303
a33576d94f32
- eliminated magic number
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
298
diff
changeset
|
91 """ """ |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
92 return u"Layertool" |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 #--- End plugin functions ---# |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 def __create_gui(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
97 """ create the basic gui container """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 self.container = pychan.loadXML('gui/layertool.xml') |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 self.wrapper = self.container.findChild(name="layers_wrapper") |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
100 self.removeLayerButton = self.container.findChild(name="remove_layer_button") |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
101 self.createLayerButton = self.container.findChild(name="add_layer_button") |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
102 self.editLayerButton = self.container.findChild(name="edit_layer_button") |
323
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
103 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
104 self.removeLayerButton.capture(self.removeSelectedLayer) |
323
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
105 self.removeLayerButton.capture(cbwa(self._editor.getStatusBar().showTooltip, self.removeLayerButton.helptext), 'mouseEntered') |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
106 self.removeLayerButton.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited') |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
107 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
108 self.createLayerButton.capture(self.showLayerWizard) |
323
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
109 self.createLayerButton.capture(cbwa(self._editor.getStatusBar().showTooltip, self.createLayerButton.helptext), 'mouseEntered') |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
110 self.createLayerButton.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited') |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
111 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
112 self.editLayerButton.capture(self.showEditDialog) |
323
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
113 self.editLayerButton.capture(cbwa(self._editor.getStatusBar().showTooltip, self.editLayerButton.helptext), 'mouseEntered') |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
114 self.editLayerButton.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited') |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
115 |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
116 self.update(None) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 def _adjust_position(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 """ adjusts the position of the container - we don't want to |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 let the window appear at the center of the screen. |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 (new default position: left, beneath the tools window) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 self.container.position = (50, 200) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
124 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
125 def removeSelectedLayer(self): |
322
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
126 """ |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
127 |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
128 """ |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
129 if not self._mapview: return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
130 |
321
7ddec4ce99b3
Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
319
diff
changeset
|
131 if self._mapview.getMap().getNumLayers() <= 1: |
7ddec4ce99b3
Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
319
diff
changeset
|
132 print "Can't remove the last layer" |
7ddec4ce99b3
Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
319
diff
changeset
|
133 return |
7ddec4ce99b3
Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
319
diff
changeset
|
134 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
135 layer = self.getActiveLayer() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
136 if not layer: return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
137 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
138 self.select_no_layer() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
139 |
321
7ddec4ce99b3
Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
319
diff
changeset
|
140 map = self._mapview.getMap() |
7ddec4ce99b3
Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
319
diff
changeset
|
141 |
7ddec4ce99b3
Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
319
diff
changeset
|
142 # FIFE will crash if we try to delete the layer which is in use by a camera |
7ddec4ce99b3
Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
319
diff
changeset
|
143 # so we will set the camera to another layer instead |
7ddec4ce99b3
Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
319
diff
changeset
|
144 for cam in self._editor.getEngine().getView().getCameras(): |
322
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
145 if cam.getLocationRef().getMap().getId() != map.getId(): |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
146 continue |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
147 |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
148 if cam.getLocation().getLayer().getId() != layer.getId(): |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
149 continue |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
150 |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
151 for l in map.getLayers(): |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
152 if l.getId() == layer.getId(): |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
153 continue |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
154 |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
155 cam.getLocationRef().setLayer(l) |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
156 break |
321
7ddec4ce99b3
Fixed a crash when removing the layer which the editor camera uses
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
319
diff
changeset
|
157 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
158 map.deleteLayer(layer) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
159 self.update(self._mapview) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
160 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
161 def showLayerWizard(self): |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
162 if not self._mapview: return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
163 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
164 if self._layer_wizard: self._layer_wizard._widget.hide() |
323
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
165 self._layer_wizard = LayerEditor(self._editor.getEngine(), self._mapview.getMap(), callback=self._layerCreated) |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
166 |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
167 def _layerCreated(self, layer): |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
168 self.update(self._mapview) |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
169 self.select_active_layer(None, self.wrapper.findChild(name=_LABEL_NAME_PREFIX + layer.getId())) |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
170 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
171 def showEditDialog(self): |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
172 if not self._mapview: return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
173 layer = self.getActiveLayer() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
174 if not layer: return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
175 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
176 if self._layer_wizard: self._layer_wizard._widget.hide() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
177 self._layer_wizard = LayerEditor(self._editor.getEngine(), self._mapview.getMap(), layer=layer, callback=cbwa(self.update, self._mapview)) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
178 |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
179 def clear(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
180 """ remove all subwrappers """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
181 if self.subwrappers is []: return |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
182 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
183 for subwrapper in self.subwrappers: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
184 self.wrapper.removeChild(subwrapper) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
185 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
186 self.subwrappers = [] |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
187 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
188 def update(self, mapview): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
189 """ Dump new layer informations into the wrapper |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
190 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
191 We group one ToggleButton and one Label into a HBox, the main wrapper |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
192 itself is a VBox and we also capture both the Button and the Label to listen |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
193 for mouse actions |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
194 """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
195 layers = [] |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
196 self._mapview = mapview |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
197 if self._mapview is not None: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
198 layers = self._mapview.getMap().getLayers() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
199 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
200 self.clear() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
201 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
202 if len(layers) <= 0: |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
203 if not self._mapview: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
204 layerid = "No map is open" |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
205 else: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
206 layerid = "No layers" |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
207 subwrapper = pychan.widgets.HBox() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
208 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
209 layerLabel = pychan.widgets.Label() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
210 layerLabel.text = unicode(layerid) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
211 layerLabel.name = _LABEL_NAME_PREFIX + layerid |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
212 subwrapper.addChild(layerLabel) |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
213 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
214 self.wrapper.addChild(subwrapper) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
215 self.subwrappers.append(subwrapper) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
216 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
217 active_layer = self.getActiveLayer() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
218 if active_layer: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
219 active_layer = active_layer.getId() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
220 for layer in reversed(layers): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
221 layerid = layer.getId() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
222 subwrapper = pychan.widgets.HBox() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
223 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
224 toggleVisibleButton = pychan.widgets.ToggleButton(hexpand=0, up_image="gui/icons/is_visible.png", down_image="gui/icons/is_visible.png", hover_image="gui/icons/is_visible.png") |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
225 toggleVisibleButton.name = "toggle_" + layerid |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
226 if layer.areInstancesVisible(): |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
227 toggleVisibleButton.toggled = True |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
228 toggleVisibleButton.capture(self.toggle_layer_visibility) |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
229 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
230 layerLabel = pychan.widgets.Label() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
231 layerLabel.text = unicode(layerid) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
232 layerLabel.name = _LABEL_NAME_PREFIX + layerid |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
233 layerLabel.capture(self.select_active_layer,"mousePressed") |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
234 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
235 if active_layer == layerid: |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
236 layerLabel.background_color = _HIGHLIGHT_BACKGROUND_COLOR |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
237 layerLabel.foreground_color = _HIGHLIGHT_BACKGROUND_COLOR |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
238 layerLabel.base_color = _HIGHLIGHT_BACKGROUND_COLOR |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
239 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
240 subwrapper.addChild(toggleVisibleButton) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
241 subwrapper.addChild(layerLabel) |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
242 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
243 self.wrapper.addChild(subwrapper) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
244 self.subwrappers.append(subwrapper) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
245 |
316
6add14ebe9f5
Disabled recursing for some adaptLayout calls. This will make the editor more responsive
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
303
diff
changeset
|
246 self.container.adaptLayout(False) |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
247 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
248 def toggle_layer_visibility(self, event, widget): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
249 """ Callback for ToggleButtons |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
250 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
251 Toggle the chosen layer visible / invisible |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
252 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
253 NOTE: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
254 - if a layer is set to invisible, it also shouldn't be the active layer anymore |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
255 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
256 @type event: object |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
257 @param event: pychan mouse event |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
258 @type widget: object |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
259 @param widget: the pychan widget where the event occurs, transports the layer id in it's name |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
260 """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
261 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
262 layerid = widget.name[len(_LABEL_NAME_PREFIX):] |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
263 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
264 layer = self._mapview.getMap().getLayer(layerid) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
265 active_layer = self.getActiveLayer() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
266 if active_layer: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
267 active_layer = active_layer.getId() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
268 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
269 if layer.areInstancesVisible(): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
270 layer.setInstancesVisible(False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
271 else: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
272 layer.setInstancesVisible(True) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
273 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
274 if active_layer == layerid: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
275 self.select_no_layer() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
276 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
277 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
278 def select_no_layer(self): |
303
a33576d94f32
- eliminated magic number
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
298
diff
changeset
|
279 """ Resets the current active layer (widget + editor) """ |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
280 previous_active_layer = self.getActiveLayer() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
281 if previous_active_layer is not None: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
282 previous_layer_id = previous_active_layer.getId() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
283 previous_active_widget = self.container.findChild(name=_LABEL_NAME_PREFIX + previous_layer_id) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
284 previous_active_widget.background_color = _DEFAULT_BACKGROUND_COLOR |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
285 previous_active_widget.foreground_color = _DEFAULT_BACKGROUND_COLOR |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
286 previous_active_widget.base_color = _DEFAULT_BACKGROUND_COLOR |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
287 previous_active_widget.text = unicode(previous_layer_id) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
288 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
289 self._mapview.getController().selectLayer(None) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
290 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
291 def getActiveLayer(self): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
292 """ Returns the active layer """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
293 if self._mapview: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
294 return self._mapview.getController()._layer |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
295 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
296 def select_active_layer(self, event, widget): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
297 """ callback for Labels |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
298 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
299 We hand the layerid over to the mapeditor module to select a |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
300 new active layer |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
301 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
302 Additionally, we mark the active layer widget (changing base color) and reseting the previous one |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
303 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
304 @type event: object |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
305 @param event: pychan mouse event |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
306 @type widget: object |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
307 @param widget: the pychan widget where the event occurs, transports the layer id in it's name |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
308 """ |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
309 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
310 self.select_no_layer() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
311 |
303
a33576d94f32
- eliminated magic number
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
298
diff
changeset
|
312 layerid = widget.name[len(_LABEL_NAME_PREFIX):] |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
313 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
314 widget.background_color = _HIGHLIGHT_BACKGROUND_COLOR |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
315 widget.foreground_color = _HIGHLIGHT_BACKGROUND_COLOR |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
316 widget.base_color = _HIGHLIGHT_BACKGROUND_COLOR |
316
6add14ebe9f5
Disabled recursing for some adaptLayout calls. This will make the editor more responsive
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
303
diff
changeset
|
317 self.container.adaptLayout(False) |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
318 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
319 self._mapview.getController().selectLayer(layerid) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
320 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
321 def toggle(self): |
303
a33576d94f32
- eliminated magic number
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
298
diff
changeset
|
322 """ toggles the layertool visible / invisible and sets |
a33576d94f32
- eliminated magic number
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
298
diff
changeset
|
323 dock status |
a33576d94f32
- eliminated magic number
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
298
diff
changeset
|
324 """ |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
325 if self.container.isVisible() or self.container.isDocked(): |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
326 self.container.setDocked(False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
327 self.container.hide() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
328 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
329 self._showAction.setChecked(False) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
330 else: |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
331 self.container.show() |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
332 self._showAction.setChecked(True) |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
333 self._adjust_position() |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
334 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
335 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
336 class LayerEditor(object): |
322
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
337 """ The B{LayerEditor} provides a gui dialog for creating and editing layers. |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
338 |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
339 FIXME: |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
340 - gridtypes can only be square for now |
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
341 - pathing strategy |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
342 """ |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
343 def __init__(self, engine, map, callback=None, onCancel=None, layer=None): |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
344 self.engine = engine |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
345 self.model = engine.getModel() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
346 self.map = map |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
347 self.layer = layer |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
348 self.callback = callback |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
349 self.onCancel = onCancel |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
350 self._widget = pychan.loadXML('gui/layereditor.xml') |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
351 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
352 # TODO: Add access method for adopted grid types? |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
353 self._widget.findChild(name="gridBox").items = ['square']#, 'hex'] # Hex does not work? |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
354 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
355 # TODO: Ditto for pather? |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
356 self._widget.findChild(name="pathingBox").items = ['cell_edges_only', 'cell_edges_and_diagonals', 'freeform'] |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
357 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
358 if layer: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
359 cg = layer.getCellGrid() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
360 cgtype = 0 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
361 if cg.getType() == 'hex': |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
362 cgtype = 1 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
363 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
364 self._widget.distributeData({ |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
365 "layerBox" : unicode(layer.getId()), |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
366 "xScaleBox" : unicode(cg.getXScale()), |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
367 "yScaleBox" : unicode(cg.getYScale()), |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
368 "rotBox" : unicode(cg.getRotation()), |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
369 "xOffsetBox" : unicode(cg.getXShift()), |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
370 "yOffsetBox" : unicode(cg.getYShift()) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
371 }) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
372 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
373 self._widget.findChild(name="pathingBox").selected = int(layer.getPathingStrategy()) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
374 self._widget.findChild(name="gridBox").selected = int(cgtype) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
375 else: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
376 self._widget.findChild(name="pathingBox").selected = 0 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
377 self._widget.findChild(name="gridBox").selected = 0 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
378 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
379 self._widget.mapEvents({ |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
380 'okButton' : self._finished, |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
381 'cancelButton' : self._cancelled |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
382 }) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
383 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
384 self._widget.show() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
385 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
386 def _cancelled(self): |
322
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
387 """ """ |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
388 if self.onCancel: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
389 self.onCancel() |
322
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
390 self._widget.hide() |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
391 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
392 def _finished(self): |
322
3853f8659598
- small changes to code layout to make it more readable
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
321
diff
changeset
|
393 """ """ |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
394 # Collect and validate data |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
395 layerId = self._widget.collectData('layerBox') |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
396 if layerId == '': |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
397 print 'Please enter a layer id.' |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
398 return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
399 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
400 try: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
401 x_offset = float(self._widget.collectData('xOffsetBox')) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
402 y_offset = float(self._widget.collectData('yOffsetBox')) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
403 except ValueError: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
404 print 'Please enter integer or decimal values for offset.' |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
405 return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
406 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
407 try: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
408 x_scale = float(self._widget.collectData('xScaleBox')) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
409 y_scale = float(self._widget.collectData('yScaleBox')) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
410 except ValueError: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
411 print 'Please enter integer or decimal values for scale.' |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
412 return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
413 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
414 try: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
415 rotation = float(self._widget.collectData('rotBox')) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
416 except ValueError: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
417 print 'Please enter integer or decimal value for rotation.' |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
418 return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
419 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
420 grid_type = int(self._widget.collectData('gridBox')) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
421 pathing = int(self._widget.collectData('pathingBox')) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
422 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
423 if grid_type == 0: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
424 grid_type = "square" |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
425 else: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
426 grid_type = "hex" |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
427 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
428 # Set up layer |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
429 layer = self.layer |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
430 cellgrid = None |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
431 if not self.layer: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
432 # TODO: FIFE currently does not support setting layer ID and cellgrid after the layer has been created |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
433 cellgrid = self.model.getCellGrid(grid_type) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
434 if not cellgrid: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
435 print "Invalid grid type" |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
436 return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
437 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
438 cellgrid.setRotation(rotation) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
439 cellgrid.setXScale(x_scale) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
440 cellgrid.setYScale(y_scale) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
441 cellgrid.setXShift(x_offset) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
442 cellgrid.setYShift(y_offset) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
443 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
444 try: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
445 layer = self.map.createLayer(str(layerId), cellgrid) |
323
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
446 |
324
e249fa887259
* Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
323
diff
changeset
|
447 except fife.NameClash: |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
448 print 'The layer ' + str(layerId) + ' already exists!' |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
449 return |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
450 else: |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
451 cellgrid = layer.getCellGrid() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
452 cellgrid.setRotation(rotation) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
453 cellgrid.setXScale(x_scale) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
454 cellgrid.setYScale(y_scale) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
455 cellgrid.setXShift(x_offset) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
456 cellgrid.setYShift(y_offset) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
457 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
458 layer.setPathingStrategy(pathing) |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
459 |
323
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
460 self.engine.getView().resetRenderers() |
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
461 |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
462 # Hide dialog and call back |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
463 self._widget.hide() |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
464 |
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
465 if self.callback: |
323
b64ce990abb1
LayerTool:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
322
diff
changeset
|
466 pychan.tools.applyOnlySuitable(self.callback, layer=layer) |
319
62ec3b530cc6
* Improved layertool: Ability to add, remove and edit layers
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
316
diff
changeset
|
467 |