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

mmlosh at millhouse.dreamhost.com mmlosh at millhouse.dreamhost.com
Sun Sep 14 11:43:35 PDT 2008


Author: mmlosh
Date: 2008-09-14 11:43:35 -0700 (Sun, 14 Sep 2008)
New Revision: 5768

Added:
   trunk/supertux-editor/supertux-editor/LevelObjects/ILayer.cs
Removed:
   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/SectorRenderer.cs
Log:
changed to LayerListWidget and SectorRenderer, so they should be capable to handle any ILayer object now..


Modified: trunk/supertux-editor/supertux-editor/LayerListWidget.cs
===================================================================
--- trunk/supertux-editor/supertux-editor/LayerListWidget.cs	2008-09-14 18:05:49 UTC (rev 5767)
+++ trunk/supertux-editor/supertux-editor/LayerListWidget.cs	2008-09-14 18:43:35 UTC (rev 5768)
@@ -65,11 +65,11 @@
 		application.TilemapChanged += OnTilemapChanged;
 		application.LevelChanged += OnLevelChanged;
 
-		FieldOrProperty.Lookup(typeof(Tilemap).GetField("Name")).Changed += OnTilemapModified;
-		FieldOrProperty.Lookup(typeof(Tilemap).GetProperty("Layer")).Changed += OnTilemapModified;
+		FieldOrProperty.Lookup(typeof(Tilemap).GetProperty("Name")).Changed += OnILayerModified;
+		FieldOrProperty.Lookup(typeof(Tilemap).GetProperty("Layer")).Changed += OnILayerModified;
 	}
 
-	private void OnTilemapModified(object Object, FieldOrProperty field, object oldValue)
+	private void OnILayerModified(object Object, FieldOrProperty field, object oldValue)
 	{
 		//TODO: Is that sorting execute-once or what? (found no other working way)
 		TreeStore store = (TreeStore) Model;
@@ -111,9 +111,9 @@
 
 	/// <summary> Get ZPos Value for object, non-tilemaps last </summary>
 	private int getZPos (object o) {
-		if(o is ILayered) {
-			ILayered ILayered = (ILayered) o;
-			return ILayered.Layer;
+		if(o is ILayer) {
+			ILayer ILayer = (ILayer) o;
+			return ILayer.Layer;
 		}			
 		return int.MaxValue;
 	}
@@ -131,16 +131,18 @@
 	{
 		visibility.Clear();
 		TreeStore store = new TreeStore(typeof(System.Object));
-		foreach(Tilemap Tilemap in sector.GetObjects(typeof(Tilemap))) {
-			store.AppendValues(Tilemap);
-			visibility[Tilemap] = application.CurrentRenderer.GetTilemapColor(Tilemap).Alpha;
+		foreach(ILayer ILayer in sector.GetObjects(typeof(ILayer))) {
+			store.AppendValues(ILayer);
+			visibility[ILayer] = application.CurrentRenderer.GetILayerColor(ILayer).Alpha;
 
-			// 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.Layer + ")");
+			if (ILayer is Tilemap) {
+				Tilemap Tilemap = (Tilemap) ILayer;
+				// 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.Layer + ")");
+				}
 			}
-
 		}
 		store.SetSortFunc( 0, compareLayer );
 		store.SetSortColumnId( 0, SortType.Ascending );
@@ -206,12 +208,12 @@
 		object o = Model.GetValue(Iter, 0);
 
 		CellRendererText TextRenderer = (CellRendererText) Renderer;
-		if(o is Tilemap) {
-			Tilemap Tilemap = (Tilemap) o;
-			if (Tilemap.Name.Length == 0) {
-				TextRenderer.Text = "Tilemap (" + Tilemap.Layer + ")";
+		if(o is ILayer) {
+			ILayer ILayer = (ILayer) o;
+			if (ILayer.Name.Length == 0) {
+				TextRenderer.Text = "Tilemap (" + ILayer.Layer + ")";
 			} else {
-				TextRenderer.Text = Tilemap.Name + " (" + Tilemap.Layer + ")";
+				TextRenderer.Text = ILayer.Name + " (" + ILayer.Layer + ")";
 			}
 		} else {
 			if (o == badguysObject)
@@ -388,8 +390,8 @@
 				newvis = 1.0f;
 			}
 
-			if (obj is Tilemap)
-				application.CurrentRenderer.SetTilemapColor((Tilemap)obj,
+			if (obj is ILayer)
+				application.CurrentRenderer.SetILayerColor((ILayer)obj,
 			                                            new Color(1, 1, 1, newvis));
 			if (obj == badguysObject)
 				application.CurrentRenderer.SetObjectsColor(new Color(1, 1, 1, newvis));

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


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

Deleted: trunk/supertux-editor/supertux-editor/LevelObjects/ILayered.cs

Modified: trunk/supertux-editor/supertux-editor/LevelObjects/Tilemap.cs
===================================================================
--- trunk/supertux-editor/supertux-editor/LevelObjects/Tilemap.cs	2008-09-14 18:05:49 UTC (rev 5767)
+++ trunk/supertux-editor/supertux-editor/LevelObjects/Tilemap.cs	2008-09-14 18:43:35 UTC (rev 5768)
@@ -9,7 +9,7 @@
 		//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, ILayered {
+public sealed class Tilemap : TileBlock, IGameObject, IPathObject, ILayer {
 	private int ZPos = 0;
 	[LispChild("z-pos")]
 	public int Layer {
@@ -35,9 +35,17 @@
 	[LispChild("solid")]
 	public bool Solid = false;
 
+	private string name = String.Empty;
 	[PropertyProperties(Tooltip = ToolTipStrings.ScriptingName)]
 	[LispChild("name", Optional = true, Default = "")]
-	public string Name = String.Empty;
+	public string Name {
+		get {
+			return name;
+		}
+		set {
+			name = value;
+		}
+	}
 
 	[LispChild("speed", Optional = true, Default = 1.0f)]
 	public float Speed = 1.0f;

Modified: trunk/supertux-editor/supertux-editor/SectorRenderer.cs
===================================================================
--- trunk/supertux-editor/supertux-editor/SectorRenderer.cs	2008-09-14 18:05:49 UTC (rev 5767)
+++ trunk/supertux-editor/supertux-editor/SectorRenderer.cs	2008-09-14 18:43:35 UTC (rev 5768)
@@ -89,23 +89,23 @@
 		FieldOrProperty.Lookup(typeof(Tilemap).GetProperty("Layer")).Changed -= OnTilemapLayerModified;
 	}
 
-	public Color GetTilemapColor(Tilemap tilemap)
+	public Color GetILayerColor(ILayer ILayer)
 	{
-		return ((ColorNode) colors[tilemap]).Color;
+		return ((ColorNode) colors[ILayer]).Color;
 	}
 
 	/// <summary>
-	///		Change color of a tilemap. Useful to hide tilemaps (but they are still drawn that way...)
+	///		Change color of any ILayer . Useful to hide any ILayer objects (they are not drawn, because ColorNodes are set do not-draw-when-transparent)
 	/// </summary>
 	/// <remarks>
-	///		Used to hide tilemaps in <see cref="LayerListWidget.OnVisibilityChange"/>.
+	///		Used to hide ILayer in <see cref="LayerListWidget.OnVisibilityChange"/>.
 	/// </remarks>
-	/// <param name="tilemap">The tilemap to change color of.</param>
+	/// <param name="ILayer">The ILayer to change color of.</param>
 	/// <param name="color">The new color.</param>
-	public void SetTilemapColor(Tilemap tilemap, Color color)
+	public void SetILayerColor(ILayer ILayer, Color color)
 	{
-		LogManager.Log(LogLevel.Debug, "Set color of tilemap {0}", tilemap.GetHashCode());
-		ColorNode colorNode = (ColorNode) colors[tilemap];
+		LogManager.Log(LogLevel.Debug, "Set color of ILayer {0}", ILayer.GetHashCode());
+		ColorNode colorNode = (ColorNode) colors[ILayer];
 		colorNode.Color = color;
 		QueueDraw();
 	}



More information about the Supertux-Commit mailing list