[tiled] r614 - in trunk: . src/tiled/core src/tiled/io/xml src/tiled/mapeditor src/tiled/mapeditor/actions src/tiled/mapeditor/brush src/tiled/mapeditor/dialogs src/tiled/mapeditor/selection src/tiled/mapeditor/util/cutter src/tiled/mapeditor/widget src/tiled/util

svn@biggeruniverse.com svn at biggeruniverse.com
Sun Apr 23 23:59:45 PDT 2006


Author: aturk
Date: 2006-04-24 01:59:44 -0500 (Mon, 24 Apr 2006)
New Revision: 614

Added:
   trunk/src/tiled/util/TiledProperty.java
Modified:
   trunk/CHANGES
   trunk/src/tiled/core/Map.java
   trunk/src/tiled/core/MapLayer.java
   trunk/src/tiled/core/MultilayerPlane.java
   trunk/src/tiled/core/TileSet.java
   trunk/src/tiled/io/xml/XMLMapWriter.java
   trunk/src/tiled/mapeditor/MapEditor.java
   trunk/src/tiled/mapeditor/actions/MergeAllLayersAction.java
   trunk/src/tiled/mapeditor/brush/Brush.java
   trunk/src/tiled/mapeditor/brush/CustomBrush.java
   trunk/src/tiled/mapeditor/dialogs/BrushDialog.java
   trunk/src/tiled/mapeditor/dialogs/SearchDialog.java
   trunk/src/tiled/mapeditor/selection/SelectionLayer.java
   trunk/src/tiled/mapeditor/util/cutter/BasicTileCutter.java
   trunk/src/tiled/mapeditor/widget/BrushBrowser.java
   trunk/src/tiled/util/TileMergeHelper.java
Log:
+ Added some functionality to visualize brush size
+ Added TiledProperty - architectural fluff for now, but will be useful in the near future.
+ Fixed layer merging so undo/redo is functional for these operations
+ Changed accessibility of bounds for MapLayer
+ Fixed merging tiles when layers are merged

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/CHANGES	2006-04-24 06:59:44 UTC (rev 614)
@@ -1,7 +1,6 @@
 UNDONE
 + Fixed memory problems when loading several maps with many tilesets in a row
 + Added ability to select multiple layers from layer table
-+ Added the ability to merge tile images when layers are merged
 + Added preview of new tileset when creating a tileset
 + Added tile cutter GUI
 + Added more useful visual feedback for some brushes
@@ -23,8 +22,9 @@
 * Added more error-checking to XMLMapTransformer, the default map reader
 * Added support for "tile cutters"
 * Added global properties for tilesets (properties set for all tiles)
+* Added the ability to merge tile images when layers are merged
 * Fixed tileset dialog so that it is now possible to change the tile height to
-  something else than the tile height used by the map.
+  something other than the tile height used by the map.
 * Fixed a bug when exporting a tileset with an external image
 * Fixed two cases of hanging when using the fill tool
 * Fixed tile palette bug of not accounting for gaps in tile ids (old bug)
@@ -32,6 +32,7 @@
 * Fixed NPE when saving a map with no extension - default to .tmx
 * Fixed the zooming so that it keeps the center in place
 * Fixed exiting even when a request to save the changes failed
+* Fixed layer merging so that undo/redo of operation is functional
 * Rewrote configuration based on the Preferences class, no more tiled.conf
 * Cleaned up TileSet (removed checksumming and rotation/orienation code)
 

Modified: trunk/src/tiled/core/Map.java
===================================================================
--- trunk/src/tiled/core/Map.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/core/Map.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -127,7 +127,7 @@
      * @return The new TileLayer instance.
      */
     public MapLayer addLayer() {
-        MapLayer layer = new TileLayer(this, widthInTiles, heightInTiles);
+        MapLayer layer = new TileLayer(this, bounds.width, bounds.height);
         layer.setName("Layer " + super.getTotalLayers());
         super.addLayer(layer);
         fireMapChanged();
@@ -289,6 +289,8 @@
 
     /**
      * Sets a new tile width.
+     * 
+     * @param width 
      */
     public void setTileWidth(int width) {
         tileWidth = width;
@@ -297,6 +299,8 @@
 
     /**
      * Sets a new tile height.
+     * 
+     * @param height 
      */
     public void setTileHeight(int height) {
         tileHeight = height;
@@ -328,6 +332,8 @@
 
     /**
      * Returns a vector with the currently loaded tilesets.
+     * 
+     * @return Vector
      */
     public Vector getTilesets() {
         return tilesets;
@@ -336,6 +342,9 @@
     /**
      * Get the tile set that matches the given global tile id, only to be used
      * when loading a map.
+     * 
+     * @param gid 
+     * @return TileSet
      */
     public TileSet findTileSetForTileGID(int gid) {
         Iterator itr = tilesets.iterator();
@@ -351,16 +360,20 @@
 
     /**
      * Returns width of map in tiles.
+     * 
+     * @return int
      */
     public int getWidth() {
-        return widthInTiles;
+        return bounds.width;
     }
 
     /**
      * Returns height of map in tiles.
+     * 
+     * @return int
      */
     public int getHeight() {
-        return heightInTiles;
+        return bounds.height;
     }
 
     /**
@@ -387,7 +400,7 @@
      *         <code>false</code> otherwise
      */
     public boolean contains(int x, int y) {
-        return x >= 0 && y >= 0 && x < widthInTiles && y < heightInTiles;
+        return x >= 0 && y >= 0 && x < bounds.width && y < bounds.height;
     }
 
     /**
@@ -457,7 +470,7 @@
      * @return string describing map
      */
     public String toString() {
-        return "Map[" + widthInTiles + "x" + heightInTiles + "x" +
+        return "Map[" + bounds.width + "x" + bounds.height + "x" +
             getTotalLayers() + "][" + tileWidth + "x" +
             tileHeight + "]";
     }

Modified: trunk/src/tiled/core/MapLayer.java
===================================================================
--- trunk/src/tiled/core/MapLayer.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/core/MapLayer.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -65,10 +65,10 @@
     }
 
     public MapLayer(MapLayer ml) {
-        this(ml.getBounds());
+        this(ml.bounds);
         name = ml.getName();
 
-        // TODO: Copy properties
+        properties = new Properties(ml.getProperties());
     }
 
     /**
@@ -110,7 +110,7 @@
      * @param bounds
      */
     public void setBounds(Rectangle bounds) {
-        this.bounds = bounds;
+        this.bounds = new Rectangle(bounds);
     }
 
     /**
@@ -200,12 +200,11 @@
 
     /**
      * Returns layer bounds in tiles.
-     *
-     * @return a java.awt.Rectangle object with the bounds in tiles of the
-     *         layer
+     * 
+     * @param r 
      */
-    public Rectangle getBounds() {
-        return bounds;
+    public void getBounds(Rectangle r) {
+        r.setBounds(bounds);
     }
 
     /**

Modified: trunk/src/tiled/core/MultilayerPlane.java
===================================================================
--- trunk/src/tiled/core/MultilayerPlane.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/core/MultilayerPlane.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -24,13 +24,14 @@
 public class MultilayerPlane
 {
     private Vector layers;
-    protected int widthInTiles, heightInTiles;
+    protected Rectangle bounds;          //in tiles
 
     /**
      * Default constructor.
      */
     public MultilayerPlane() {
         layers = new Vector();
+        bounds = new Rectangle();
     }
 
     /**
@@ -41,8 +42,8 @@
      */
     public MultilayerPlane(int width, int height) {
         this();
-        widthInTiles = width;
-        heightInTiles = height;
+        bounds.width = width;
+        bounds.height = height;
     }
 
     /**
@@ -61,24 +62,25 @@
         int width = 0;
         int height = 0;
 
+        Rectangle layerBounds = new Rectangle();
+        
         for (int i = 0; i < layers.size(); i++) {
-            Rectangle layerBounds = getLayer(i).getBounds();
+            getLayer(i).getBounds(layerBounds);
             if (width < layerBounds.width) width = layerBounds.width;
             if (height < layerBounds.height) height = layerBounds.height;
         }
 
-        widthInTiles = width;
-        heightInTiles = height;
+        bounds.width = width;
+        bounds.height = height;
     }
 
     /**
      * Returns a <code>Rectangle</code> representing the maximum bounds in
      * tiles.
      *
-     * @return a Rectangle
      */
-    public Rectangle getBounds() {
-        return new Rectangle(0, 0, widthInTiles, heightInTiles);
+    public void getBounds(Rectangle r) {
+    	r.setBounds(bounds);
     }
 
     /**
@@ -103,7 +105,8 @@
     }
 
     /**
-     * Add a layer at the specified index, which should be a valid.
+     * Add a layer at the specified index, which should be within 
+     * the valid range.
      *
      * @param index the position at which to add the layer
      * @param layer the layer to add
@@ -112,6 +115,10 @@
         layers.add(index, layer);
     }
 
+    private void setLayer(int index, MapLayer layer) {
+    	layers.set(index, layer);
+    }
+    
     /**
      * Adds all the layers in a given java.util.Collection.
      *
@@ -199,8 +206,15 @@
         if (index - 1 < 0) {
             throw new RuntimeException("Can't merge down bottom layer.");
         }
-
-        getLayer(index).mergeOnto(getLayer(index - 1));
+        
+        //TODO we're not accounting for different types of layers!!!
+        
+        TileLayer ntl = new TileLayer((TileLayer)getLayer(index - 1));
+        ntl.copyFrom(getLayer(index - 1));
+        getLayer(index).mergeOnto(ntl);
+        setLayer(index - 1, ntl);
+        
+        //getLayer(index).mergeOnto(getLayer(index - 1));
         removeLayer(index);
     }
 
@@ -244,13 +258,13 @@
         ListIterator itr = getLayers();
         while (itr.hasNext()) {
             MapLayer l = (MapLayer)itr.next();
-            if (l.getBounds().equals(getBounds())) {
+            if (l.bounds.equals(bounds)) {
                 l.resize(width, height, dx, dy);
             }
         }
 
-        widthInTiles = width;
-        heightInTiles = height;
+        bounds.width = width;
+        bounds.height = height;
     }
 
     /**
@@ -262,6 +276,6 @@
      *         <code>false</code> otherwise
      */
     public boolean inBounds(int x, int y) {
-        return x >= 0 && y >= 0 && x < widthInTiles && y < heightInTiles;
+        return x >= 0 && y >= 0 && x < bounds.width && y < bounds.height;
     }
 }

Modified: trunk/src/tiled/core/TileSet.java
===================================================================
--- trunk/src/tiled/core/TileSet.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/core/TileSet.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -42,6 +42,7 @@
     private NumberedSet tiles, images;
     private int firstGid;
     private long tilebmpFileLastModified;
+    private TileCutter myCutter;
     private Rectangle tileDimensions;
     private String externalSource;
     private File tilebmpFile;
@@ -99,6 +100,8 @@
         assert (tilebmp != null);
         assert (cutter != null);
 
+        myCutter = cutter;
+        
         tileDimensions = new Rectangle(cutter.getDimensions());
         tileSetImage = tilebmp;
 
@@ -141,6 +144,13 @@
         }*/
     }
 
+    public void checkUpdate() {
+    	
+    	if(tilebmpFile != null && tilebmpFile.lastModified() > tilebmpFileLastModified) {
+    		
+    	}
+    }
+    
     /**
      * Sets the URI path of the external source of this tile set. By setting
      * this, the set is implied to be external in all other operations.

Modified: trunk/src/tiled/io/xml/XMLMapWriter.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapWriter.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/io/xml/XMLMapWriter.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -324,7 +324,8 @@
                     prefs.getBoolean("layerCompression", true) &&
                             encodeLayerData;
 
-            Rectangle bounds = l.getBounds();
+            Rectangle bounds = new Rectangle();
+            l.getBounds(bounds);
 
             if (l.getClass() == SelectionLayer.class) {
                 w.startElement("selection");
@@ -515,7 +516,8 @@
         throws IOException
     {
         try {
-            Rectangle b = o.getBounds();
+            Rectangle b = new Rectangle();
+            o.getBounds(b);
             w.startElement("object");
             w.writeAttribute("x", m.getX() + b.x);
             w.writeAttribute("y", m.getY() + b.y);

Modified: trunk/src/tiled/mapeditor/MapEditor.java
===================================================================
--- trunk/src/tiled/mapeditor/MapEditor.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/mapeditor/MapEditor.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -946,11 +946,11 @@
             Point limp = mouseInitialPressLocation;
             int minx = Math.min(limp.x, tile.x);
             int miny = Math.min(limp.y, tile.y);
-            Rectangle oldArea = null;
+            /*Rectangle oldArea = null;
 
             if (currentBrush instanceof CustomBrush) {
                 oldArea = currentBrush.getBounds();
-            }
+            }*/
 
             Rectangle bounds = new Rectangle(
                     minx, miny,
@@ -977,18 +977,23 @@
 
         updateCursorHighlight(tile);
     }
-
+    
     private void updateCursorHighlight(Point tile) {
         if (prefs.getBoolean("cursorhighlight", true)) {
-            Rectangle redraw = cursorHighlight.getBounds();
+            Rectangle redraw = new Rectangle();
+            Rectangle brushRedraw = new Rectangle();
+            	
+            cursorHighlight.getBounds(redraw);
+            currentBrush.getBounds(brushRedraw);
+            brushRedraw.x = tile.x-brushRedraw.width/2;
+            brushRedraw.y = tile.y-brushRedraw.height/2;
 
-            if (redraw.x != tile.x || redraw.y != tile.y) {
-                Rectangle r1 = new Rectangle(tile.x, tile.y, 1, 1);
-                Rectangle r2 = new Rectangle(redraw.x, redraw.y, 1, 1);
-                cursorHighlight.setOffset(tile.x, tile.y);
-                mapView.repaintRegion(r1);
-                mapView.repaintRegion(r2);
+            if (!redraw.equals(brushRedraw)) {
+            	mapView.repaintRegion(redraw);
+            	cursorHighlight.setOffset(brushRedraw.x, brushRedraw.y);
+            	mapView.repaintRegion(brushRedraw);
             }
+            
         }
     }
 
@@ -1358,7 +1363,9 @@
                 }
                 marqueeSelection = new SelectionLayer(
                         currentMap.getWidth(), currentMap.getHeight());
-                marqueeSelection.selectRegion(marqueeSelection.getBounds());
+                Rectangle r = new Rectangle();
+                marqueeSelection.getBounds(r);
+                marqueeSelection.selectRegion(r);
                 currentMap.addLayerSpecial(marqueeSelection);
             }
         }

Modified: trunk/src/tiled/mapeditor/actions/MergeAllLayersAction.java
===================================================================
--- trunk/src/tiled/mapeditor/actions/MergeAllLayersAction.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/mapeditor/actions/MergeAllLayersAction.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -46,10 +46,9 @@
             TileLayer newLayer = tmh.merge(0, len, true);
             map.removeAllLayers();
             map.addLayer(newLayer);
+            newLayer.setName("Merged Layer");
             map.addTileset(tmh.getSet());
         } else {
-            // todo: The merging should be done to a new layer. Currently the
-            // todo: merge is done in-place, causing undo not to work properly.
             while (map.getTotalLayers() > 1) {
                 map.mergeLayerDown(map.getTotalLayers() - 1);
             }

Modified: trunk/src/tiled/mapeditor/brush/Brush.java
===================================================================
--- trunk/src/tiled/mapeditor/brush/Brush.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/mapeditor/brush/Brush.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -23,14 +23,18 @@
 {
     /**
      * Returns the number of layers affected by this brush.
+     * 
+     * @return int
      */
     public int getAffectedLayers();
 
     /**
      * Returns the bounds of this brush. This is used for determining the area
      * to redraw when the brush moves.
+     * 
+     * @param r 
      */
-    public Rectangle getBounds();
+    public void getBounds(Rectangle r);
 
     /**
      * Called before painting operation starts. This is when the mouse is
@@ -56,6 +60,7 @@
      *
      * @return the rectangular region affected by the painting, used to
      *         determine which area to redraw.
+     * @throws Exception 
      */
     public Rectangle doPaint(int x, int y) throws Exception;
 
@@ -72,6 +77,7 @@
      * @param g2d The graphics context to draw to.
      * @param x The x-coord to draw the preview at
      * @param y The y-coord to draw the preview at
+     * @param mv 
      */
     public void drawPreview(Graphics2D g2d, int x, int y, MapView mv);
 
@@ -79,11 +85,15 @@
      * Draws a preview of the editing operation when applicable.
      *
      * @param g2d The graphics context to draw to.
+     * @param mv 
      */
     public void drawPreview(Graphics2D g2d, MapView mv);
 
     /**
      * Returns wether this brush equals another brush.
+     * 
+     * @param brush 
+     * @return boolean
      */
     public boolean equals(Brush brush);
 }

Modified: trunk/src/tiled/mapeditor/brush/CustomBrush.java
===================================================================
--- trunk/src/tiled/mapeditor/brush/CustomBrush.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/mapeditor/brush/CustomBrush.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -69,7 +69,6 @@
     public Rectangle doPaint(int x, int y) throws Exception
     {
         int layer = initLayer;
-        Rectangle bounds = getBounds();
         int centerx = x - bounds.width / 2;
         int centery = y - bounds.height / 2;
 

Modified: trunk/src/tiled/mapeditor/dialogs/BrushDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/BrushDialog.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/mapeditor/dialogs/BrushDialog.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -96,7 +96,9 @@
         // Brush size
         brushSize = new IntegerSpinner(1, 1);
         if (myBrush != null) {
-            brushSize.setValue(myBrush.getBounds().width);
+        	Rectangle r = new Rectangle();
+        	myBrush.getBounds(r);
+            brushSize.setValue(r.width);
         }
         brushSize.addChangeListener(this);
         brushSize.setToolTipText("Sets the size of the brush in tiles");
@@ -311,7 +313,9 @@
         if (evt.getPropertyName().equals("selectedbrush")) {
             Brush b = brushes.getSelectedBrush();
             if (b != null) {
-                brushSize.setValue(b.getBounds().width);
+            	Rectangle r = new Rectangle();
+            	b.getBounds(r);
+                brushSize.setValue(r.width);
             }
         }
 

Modified: trunk/src/tiled/mapeditor/dialogs/SearchDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/SearchDialog.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/mapeditor/dialogs/SearchDialog.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -158,11 +158,12 @@
             }
 
             sl = new SelectionLayer(map.getWidth(), map.getHeight());
+            Rectangle bounds = new Rectangle();
             final Iterator itr = map.getLayers();
             while (itr.hasNext()) {
                 MapLayer layer = (MapLayer) itr.next();
                 if (layer instanceof TileLayer) {
-                    Rectangle bounds = layer.getBounds();
+                    layer.getBounds(bounds);
                     for (int y = 0; y < bounds.height; y++) {
                         for (int x = 0; x < bounds.width; x++) {
                             if (((TileLayer)layer).getTileAt(x,y) == searchCBox.getSelectedItem()) {
@@ -225,8 +226,8 @@
         }
 
         sl = new SelectionLayer(map.getWidth(), map.getHeight());
+        Rectangle bounds = new Rectangle();
 
-
         int startx = currentMatch == null ? 0 : currentMatch.x;
         int starty = currentMatch == null ? 0 : currentMatch.y;
 
@@ -237,7 +238,7 @@
                     MapLayer layer = (MapLayer) itr.next();
 
                     if (layer instanceof TileLayer) {
-                        Rectangle bounds = layer.getBounds();
+                        layer.getBounds(bounds);
 
                         if (((TileLayer)layer).getTileAt(x,y) == searchCBox.getSelectedItem()) {
                             if (currentMatch != null) {

Modified: trunk/src/tiled/mapeditor/selection/SelectionLayer.java
===================================================================
--- trunk/src/tiled/mapeditor/selection/SelectionLayer.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/mapeditor/selection/SelectionLayer.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -173,11 +173,10 @@
      * Inverts the selected area.
      */
     public void invert() {
-        Rectangle bounded = getBounds();
-        selection.exclusiveOr(new Area(bounded));
+        selection.exclusiveOr(new Area(bounds));
 
-        for (int i = bounded.y; i < bounded.y + bounded.height; i++) {
-            for (int j = bounded.x; j < bounded.x + bounded.width; j++) {
+        for (int i = bounds.y; i < bounds.y + bounds.height; i++) {
+            for (int j = bounds.x; j < bounds.x + bounds.width; j++) {
                 if (selection.contains(j, i)) {
                     setTileAt(j, i, selTile);
                 } else {

Modified: trunk/src/tiled/mapeditor/util/cutter/BasicTileCutter.java
===================================================================
--- trunk/src/tiled/mapeditor/util/cutter/BasicTileCutter.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/mapeditor/util/cutter/BasicTileCutter.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -49,7 +49,9 @@
         this.image = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_ARGB);
         //FIXME: although faster, the following doesn't seem to handle alpha on some platforms...
         //GraphicsConfiguration config =
-        //    GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
+            //GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
+
+        
         //Image tilesetImage = config.createCompatibleImage(tileWidth, tileHeight);
         //Graphics tg = tilesetImage.getGraphics();
         Graphics2D tg = this.image.createGraphics();

Modified: trunk/src/tiled/mapeditor/widget/BrushBrowser.java
===================================================================
--- trunk/src/tiled/mapeditor/widget/BrushBrowser.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/mapeditor/widget/BrushBrowser.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -99,11 +99,12 @@
         g.setColor(Color.black);
 
         // Draw the brushes
+        Rectangle bb = new Rectangle();
         Iterator itr = brushes.iterator();
         int x = 0, y = 0;
         while (itr.hasNext()) {
             Brush b = (Brush)itr.next();
-            Rectangle bb = b.getBounds();
+            b.getBounds(bb);
             b.drawPreview((Graphics2D) g, null);
             //        x + (maxWidth / 2 - bb.width / 2),
             //        y + (maxWidth / 2 - bb.width / 2));

Modified: trunk/src/tiled/util/TileMergeHelper.java
===================================================================
--- trunk/src/tiled/util/TileMergeHelper.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/util/TileMergeHelper.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -18,6 +18,7 @@
 import java.awt.GraphicsConfiguration;
 import java.awt.Image;
 import java.awt.Graphics;
+import java.awt.Rectangle;
 
 import tiled.core.Map;
 import tiled.core.TileSet;
@@ -42,12 +43,12 @@
     }
 
     public TileLayer merge(int start, int len, boolean all) {
-        int w = myMap.getBounds().width;
-        int h = myMap.getBounds().height;
-        mergedLayer = new TileLayer(w, h);
+    	Rectangle r = new Rectangle();
+        myMap.getBounds(r);
+        mergedLayer = new TileLayer(r);
 
-        for (int i = 0; i < h; i++) {
-            for (int j = 0; j < w; j++) {
+        for (int i = 0; i < r.height; i++) {
+            for (int j = 0; j < r.width; j++) {
                 mergedLayer.setTileAt(j, i, createCell(j, i, start, len, all));
             }
         }
@@ -77,20 +78,19 @@
         c.setTile(tile);
 
         //GENERATE MERGED TILE IMAGE
+        //FIXME: although faster, the following doesn't seem to handle alpha on some platforms...
         GraphicsConfiguration config =
             GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
         Image tileImg = config.createCompatibleImage(c.getWidth(), c.getHeight());
         c.render(tileImg.getGraphics());
         tile.setImage(tileImg);
-        //int image_id = myTs.addImage(tileImg);
-        //tile.setAppearance(image_id, 0);
 
         myTs.addTile(tile);
 
         return tile;
     }
 
-    private static class Cell {
+    private class Cell {
         private Vector sandwich;
         private Tile myTile;
 
@@ -121,7 +121,7 @@
             Iterator itr = sandwich.iterator();
             while (itr.hasNext()) {
                 Tile t = (Tile)itr.next();
-                if (t != null) t.draw(g, 0, 0, 1.0f);
+                if (t != null) t.draw(g, 0, getHeight(), 1.0f);
             }
         }
 
@@ -135,6 +135,8 @@
                     return false;
                 } else if (m != null && t != null && t != m) {
                     return false;
+                } else if ((m != null && t == null) || (m == null && t != null)) {
+                	return false;
                 }
             }
             return true;

Added: trunk/src/tiled/util/TiledProperty.java
===================================================================
--- trunk/src/tiled/util/TiledProperty.java	2006-04-23 21:38:06 UTC (rev 613)
+++ trunk/src/tiled/util/TiledProperty.java	2006-04-24 06:59:44 UTC (rev 614)
@@ -0,0 +1,24 @@
+package tiled.util;
+
+public class TiledProperty {
+
+	private String value,
+					min,
+					max,
+					type;
+	
+	public TiledProperty() {
+	}
+	
+	public TiledProperty(String value, String min, String max, String type) {
+		set(value, min, max, type);
+	}
+	
+	public void set(String value, String min, String max, String type) {
+		this.value = value;
+		this.min   = min;
+		this.max   = max;
+		this.type  = type;
+	}
+	
+}




More information about the tiled-commit mailing list