changeset 322:3853f8659598

- small changes to code layout to make it more readable - minor fixes to docstrings
author chewie@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 17 Aug 2009 08:16:30 +0000
parents 7ddec4ce99b3
children b64ce990abb1
files clients/editor/plugins/LayerTool.py
diffstat 1 files changed, 26 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/clients/editor/plugins/LayerTool.py	Sun Aug 16 21:35:15 2009 +0000
+++ b/clients/editor/plugins/LayerTool.py	Mon Aug 17 08:16:30 2009 +0000
@@ -21,7 +21,7 @@
 # 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 # ###################################################
 
-""" An advanced layer tool for FIFedit """
+""" A layertool plugin for FIFedit """
 
 import fife
 import scripts.plugin as plugin
@@ -40,16 +40,8 @@
 _LABEL_NAME_PREFIX = "select_"
 
 class LayerTool(plugin.Plugin):
-	""" The B{LayerTool} is an advanced method to view
-	and change layer informations.
-	
-	While the original FIFedit tool only allows to select
-	layers, this one will provide the following functionality:
-	
-		- toggle layer visibility
-		- select layer
-		- list layers
-		
+	""" The B{LayerTool} allows to select and show / hide layers of a loaded
+		map as well as creating new layers or edit layer properties
 	"""
 	def __init__(self):	
 		self._editor = None
@@ -121,6 +113,9 @@
 		self.container.position = (50, 200)
 		
 	def removeSelectedLayer(self):
+		"""
+		
+		"""
 		if not self._mapview: return
 		
 		if self._mapview.getMap().getNumLayers() <= 1:
@@ -137,12 +132,18 @@
 		# FIFE will crash if we try to delete the layer which is in use by a camera
 		# so we will set the camera to another layer instead
 		for cam in self._editor.getEngine().getView().getCameras():
-			if cam.getLocationRef().getMap().getId() == map.getId():
-				if cam.getLocation().getLayer().getId() == layer.getId():
-					for l in map.getLayers():
-						if l.getId() == layer.getId(): continue
-						cam.getLocationRef().setLayer(l)
-						break
+			if cam.getLocationRef().getMap().getId() != map.getId():
+				continue
+				
+			if cam.getLocation().getLayer().getId() != layer.getId():
+				continue
+				
+			for l in map.getLayers():
+				if l.getId() == layer.getId(): 
+					continue
+				
+				cam.getLocationRef().setLayer(l)
+				break
 		
 		map.deleteLayer(layer)
 		self.update(self._mapview)
@@ -319,8 +320,11 @@
 
 
 class LayerEditor(object):
-	"""
-	LayerEditor provides a gui dialog for creating and editing layers.
+	""" The B{LayerEditor} provides a gui dialog for creating and editing layers.
+	
+		FIXME:
+			- gridtypes can only be square for now
+			- pathing strategy 
 	"""
 	def __init__(self, engine, map, callback=None, onCancel=None, layer=None):
 		self.engine = engine
@@ -366,12 +370,13 @@
 		self._widget.show()
 		
 	def _cancelled(self):
+		""" """
 		if self.onCancel:
 			self.onCancel()
-		self._widget.hide()
-		
+		self._widget.hide()		
 
 	def _finished(self):
+		""" """
 		# Collect and validate data
 		layerId = self._widget.collectData('layerBox')
 		if layerId == '':