[Supertux-Commit] r5767 - in trunk/supertux-editor/supertux-editor: . LevelObjects

mmlosh at millhouse.dreamhost.com mmlosh at millhouse.dreamhost.com
Sun Sep 14 11:05:50 PDT 2008


Author: mmlosh
Date: 2008-09-14 11:05:49 -0700 (Sun, 14 Sep 2008)
New Revision: 5767

Added:
   trunk/supertux-editor/supertux-editor/LevelObjects/ILayered.cs
Modified:
   trunk/supertux-editor/supertux-editor/LayerListWidget.cs
   trunk/supertux-editor/supertux-editor/LevelObjects/Tilemap.cs
   trunk/supertux-editor/supertux-editor/LevelUtil.cs
   trunk/supertux-editor/supertux-editor/QACheck.cs
   trunk/supertux-editor/supertux-editor/SectorRenderer.cs
Log:
added interface ILayered and renamed tilemap's ZPos to Layer to match interface specification


Modified: trunk/supertux-editor/supertux-editor/LayerListWidget.cs
===================================================================
--- trunk/supertux-editor/supertux-editor/LayerListWidget.cs	2008-09-12 15:21:48 UTC (rev 5766)
+++ trunk/supertux-editor/supertux-editor/LayerListWidget.cs	2008-09-14 18:05:49 UTC (rev 5767)
@@ -66,7 +66,7 @@
 		application.LevelChanged += OnLevelChanged;
 
 		FieldOrProperty.Lookup(typeof(Tilemap).GetField("Name")).Changed += OnTilemapModified;
-		FieldOrProperty.Lookup(typeof(Tilemap).GetField("ZPos")).Changed += OnTilemapModified;
+		FieldOrProperty.Lookup(typeof(Tilemap).GetProperty("Layer")).Changed += OnTilemapModified;
 	}
 
 	private void OnTilemapModified(object Object, FieldOrProperty field, object oldValue)
@@ -74,7 +74,7 @@
 		//TODO: Is that sorting execute-once or what? (found no other working way)
 		TreeStore store = (TreeStore) Model;
 		if (store != null)
-			store.SetSortFunc( 0, compareZPos );
+			store.SetSortFunc( 0, compareLayer );
 		QueueDraw();
 	}
 
@@ -111,15 +111,15 @@
 
 	/// <summary> Get ZPos Value for object, non-tilemaps last </summary>
 	private int getZPos (object o) {
-		if(o is Tilemap) {
-			Tilemap Tilemap = (Tilemap) o;
-			return Tilemap.ZPos;
+		if(o is ILayered) {
+			ILayered ILayered = (ILayered) o;
+			return ILayered.Layer;
 		}			
 		return int.MaxValue;
 	}
 
 	/// <summary> Compare ZPos Values and return which comes first </summary>
-	public int compareZPos(TreeModel model, TreeIter tia, TreeIter tib){
+	public int compareLayer(TreeModel model, TreeIter tia, TreeIter tib){
 		object objA = model.GetValue (tia, 0);
 		object objB = model.GetValue (tib, 0);
 		int a = getZPos(objA); 
@@ -138,11 +138,11 @@
 			// if no tilemap is yet selected, select the first solid one
 			if ((application.CurrentTilemap == null) && (Tilemap.Solid)) {
 				application.CurrentTilemap = Tilemap;
-				application.EditProperties(application.CurrentTilemap, "Tilemap (" + application.CurrentTilemap.ZPos + ")");
+				application.EditProperties(application.CurrentTilemap, "Tilemap (" + application.CurrentTilemap.Layer + ")");
 			}
 
 		}
-		store.SetSortFunc( 0, compareZPos );
+		store.SetSortFunc( 0, compareLayer );
 		store.SetSortColumnId( 0, SortType.Ascending );
 		store.AppendValues(separatorObject);
 		visibility[separatorObject] = 0;
@@ -209,9 +209,9 @@
 		if(o is Tilemap) {
 			Tilemap Tilemap = (Tilemap) o;
 			if (Tilemap.Name.Length == 0) {
-				TextRenderer.Text = "Tilemap (" + Tilemap.ZPos + ")";
+				TextRenderer.Text = "Tilemap (" + Tilemap.Layer + ")";
 			} else {
-				TextRenderer.Text = Tilemap.Name + " (" + Tilemap.ZPos + ")";
+				TextRenderer.Text = Tilemap.Name + " (" + Tilemap.Layer + ")";
 			}
 		} else {
 			if (o == badguysObject)
@@ -236,7 +236,7 @@
 		if(obj is Tilemap) {
 			if(obj != application.CurrentTilemap) {
 				application.CurrentTilemap = (Tilemap) obj;
-				application.EditProperties(application.CurrentTilemap, "Tilemap (" + application.CurrentTilemap.ZPos + ")");
+				application.EditProperties(application.CurrentTilemap, "Tilemap (" + application.CurrentTilemap.Layer + ")");
 			if (obj is IPathObject)
 				application.PathToEdit = ((IPathObject) obj).Path;
 			}
@@ -324,7 +324,7 @@
 	{
 		IPathObject pathObject = (IPathObject) application.CurrentTilemap;
 		if (pathObject.Path != null) {
-			Command command = new PropertyChangeCommand("Removed path of Tilemap " + application.CurrentTilemap.Name + " (" + application.CurrentTilemap.ZPos + ")",
+			Command command = new PropertyChangeCommand("Removed path of Tilemap " + application.CurrentTilemap.Name + " (" + application.CurrentTilemap.Layer + ")",
 				FieldOrProperty.Lookup(typeof(Tilemap).GetProperty("Path")),
 				application.CurrentTilemap,
 				null);

Added: trunk/supertux-editor/supertux-editor/LevelObjects/ILayered.cs
===================================================================
--- trunk/supertux-editor/supertux-editor/LevelObjects/ILayered.cs	                        (rev 0)
+++ trunk/supertux-editor/supertux-editor/LevelObjects/ILayered.cs	2008-09-14 18:05:49 UTC (rev 5767)
@@ -0,0 +1,11 @@
+//  $Id$
+/// <summary>
+/// Interface for all objects that belongs to the LayerList => have Z-Position, now known as Layer.
+/// </summary>
+public interface ILayered
+{
+	int Layer {
+		get;
+	}
+}
+


Property changes on: trunk/supertux-editor/supertux-editor/LevelObjects/ILayered.cs
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/supertux-editor/supertux-editor/LevelObjects/Tilemap.cs
===================================================================
--- trunk/supertux-editor/supertux-editor/LevelObjects/Tilemap.cs	2008-09-12 15:21:48 UTC (rev 5766)
+++ trunk/supertux-editor/supertux-editor/LevelObjects/Tilemap.cs	2008-09-14 18:05:49 UTC (rev 5767)
@@ -9,9 +9,17 @@
 		//tilemaps are no longer created as badguys, it is looking bad
 [SupertuxObject("tilemap", "images/engine/editor/tilemap.png",
                 Target = SupertuxObjectAttribute.Usage.None)]
-public sealed class Tilemap : TileBlock, IGameObject, IPathObject {
+public sealed class Tilemap : TileBlock, IGameObject, IPathObject, ILayered {
+	private int ZPos = 0;
 	[LispChild("z-pos")]
-	public int ZPos = 0;
+	public int Layer {
+		get {
+			return ZPos;
+		}
+		set {
+			ZPos = value;
+		}
+	}
 
 //TODO: If we want to store X coordinate to level file, we must uncomment this and add support for it
 	//If you do that, please remove " else X = Y = 0;" in UpdatePos();

Modified: trunk/supertux-editor/supertux-editor/LevelUtil.cs
===================================================================
--- trunk/supertux-editor/supertux-editor/LevelUtil.cs	2008-09-12 15:21:48 UTC (rev 5766)
+++ trunk/supertux-editor/supertux-editor/LevelUtil.cs	2008-09-14 18:05:49 UTC (rev 5767)
@@ -30,20 +30,20 @@
 
 		Tilemap tilemap = new Tilemap();
 		tilemap.Resize(100, 35, 0);
-		tilemap.ZPos = -100;
+		tilemap.Layer = -100;
 		tilemap.Name = "Background";
 		sector.Add(tilemap, true);
 
 		tilemap = new Tilemap();
 		tilemap.Resize(100, 35, 0);
-		tilemap.ZPos = 0;
+		tilemap.Layer = 0;
 		tilemap.Solid = true;
 		tilemap.Name = "Interactive";
 		sector.Add(tilemap, true);
 
 		tilemap = new Tilemap();
 		tilemap.Resize(100, 35, 0);
-		tilemap.ZPos = 100;
+		tilemap.Layer = 100;
 		tilemap.Name = "Foreground";
 		sector.Add(tilemap, true);
 

Modified: trunk/supertux-editor/supertux-editor/QACheck.cs
===================================================================
--- trunk/supertux-editor/supertux-editor/QACheck.cs	2008-09-12 15:21:48 UTC (rev 5766)
+++ trunk/supertux-editor/supertux-editor/QACheck.cs	2008-09-14 18:05:49 UTC (rev 5767)
@@ -58,9 +58,9 @@
 			if (invalidtiles.Count != 0) {
 				bad = true;
 				if (String.IsNullOrEmpty(tilemap.Name))
-					sb.Append(Environment.NewLine + "Tilemap (" + tilemap.ZPos + ")");
+					sb.Append(Environment.NewLine + "Tilemap (" + tilemap.Layer + ")");
 				else
-					sb.Append(Environment.NewLine + tilemap.Name + " (" + tilemap.ZPos + ")");
+					sb.Append(Environment.NewLine + tilemap.Name + " (" + tilemap.Layer + ")");
 			}
 		}
 

Modified: trunk/supertux-editor/supertux-editor/SectorRenderer.cs
===================================================================
--- trunk/supertux-editor/supertux-editor/SectorRenderer.cs	2008-09-12 15:21:48 UTC (rev 5766)
+++ trunk/supertux-editor/supertux-editor/SectorRenderer.cs	2008-09-14 18:05:49 UTC (rev 5767)
@@ -39,7 +39,7 @@
 		foreach(Tilemap tilemap in sector.GetObjects(typeof(Tilemap))) {
 			Node node = new TilemapNode(tilemap, level.Tileset);
 			ColorNode colorNode = new ColorNode(node, new Color(1f, 1f, 1f, 1f), true);
-			layer.Add(tilemap.ZPos, colorNode);
+			layer.Add(tilemap.Layer, colorNode);
 			colors[tilemap] = colorNode;
 		}
 
@@ -77,7 +77,7 @@
 		sector.ObjectRemoved += OnObjectRemoved;
 		sector.SizeChanged += OnSizeChanged;
 		application.TilemapChanged += OnTilemapChanged;
-		FieldOrProperty.Lookup(typeof(Tilemap).GetField("ZPos")).Changed += OnTilemapZPosModified;
+		FieldOrProperty.Lookup(typeof(Tilemap).GetProperty("Layer")).Changed += OnTilemapLayerModified;
 	}
 
 	public override void Dispose()
@@ -86,7 +86,7 @@
 		sector.ObjectRemoved -= OnObjectRemoved;
 		sector.SizeChanged -= OnSizeChanged;
 		application.TilemapChanged -= OnTilemapChanged;		
-		FieldOrProperty.Lookup(typeof(Tilemap).GetField("ZPos")).Changed -= OnTilemapZPosModified;
+		FieldOrProperty.Lookup(typeof(Tilemap).GetProperty("Layer")).Changed -= OnTilemapLayerModified;
 	}
 
 	public Color GetTilemapColor(Tilemap tilemap)
@@ -147,7 +147,7 @@
 			Tilemap tilemap = (Tilemap) Object;
 			Node tnode = new TilemapNode(tilemap, level.Tileset);
 			ColorNode colorNode = new ColorNode(tnode, new Color(1f, 1f, 1f, 1f));
-			layer.Add(tilemap.ZPos, colorNode);
+			layer.Add(tilemap.Layer, colorNode);
 			LogManager.Log(LogLevel.Debug, "Adding tilemap color: {0}", Object.GetHashCode());
 			colors[tilemap] = colorNode;
 		}
@@ -168,7 +168,7 @@
 		if( Object is Tilemap ){
 			Layer layer = (Layer) SceneGraphRoot;
 			Tilemap tm = (Tilemap) Object;
-			layer.Remove(tm.ZPos, (ColorNode) colors[tm]);
+			layer.Remove(tm.Layer, (ColorNode) colors[tm]);
 			colors.Remove(tm);
 			QueueDraw();
 			return;
@@ -192,16 +192,16 @@
 	}
 
 	/// <summary> Moves tilemap from layer to layer when ZPos is changed. </summary>
-	private void OnTilemapZPosModified(object Object, FieldOrProperty field, object oldValue)
+	private void OnTilemapLayerModified(object Object, FieldOrProperty field, object oldValue)
 	{
 		if (colors.ContainsKey(Object)){	//is is our tilemap => our sector?
 			Layer layer = (Layer) SceneGraphRoot;
 			Tilemap tm = (Tilemap) Object;
 			ColorNode color = (ColorNode) colors[tm];
-			int oldZPos = (int) oldValue;
+			int oldLayer = (int) oldValue;
 
-			layer.Remove(oldZPos, color);
-			layer.Add(tm.ZPos, color);
+			layer.Remove(oldLayer, color);
+			layer.Add(tm.Layer, color);
 
 			QueueDraw();
 		}



More information about the Supertux-Commit mailing list