[tiled] r682 - in trunk: . src/tiled/core src/tiled/mapeditor src/tiled/mapeditor/brush src/tiled/mapeditor/dialogs src/tiled/mapeditor/util src/tiled/mapeditor/widget
svn@biggeruniverse.com
svn at biggeruniverse.com
Sat Jun 24 15:34:44 PDT 2006
Author: bjorn
Date: 2006-06-24 17:34:43 -0500 (Sat, 24 Jun 2006)
New Revision: 682
Added:
trunk/src/tiled/mapeditor/util/TileRegionSelectionEvent.java
Modified:
trunk/README
trunk/TODO
trunk/src/tiled/core/MultilayerPlane.java
trunk/src/tiled/core/TileLayer.java
trunk/src/tiled/mapeditor/MapEditor.java
trunk/src/tiled/mapeditor/brush/CustomBrush.java
trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java
trunk/src/tiled/mapeditor/util/TileSelectionListener.java
trunk/src/tiled/mapeditor/widget/TabbedTilesetsPane.java
trunk/src/tiled/mapeditor/widget/TilePalettePanel.java
Log:
* Fixed behaviour related to tile instance properties in TileLayer#setTileAt and TileLayer#clone in order to reduce the huge amount of memory simple map edits were consuming (edits consume to much memory anyway, which still needs to be fixed).
* Introduced the TileRegionSelectionEvent, and used it to allow stamp brush creation from the tile palette.
* Extended roadmap to 0.7.0 with more specific remaining work.
Modified: trunk/README
===================================================================
--- trunk/README 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/README 2006-06-24 22:34:43 UTC (rev 682)
@@ -1,5 +1,5 @@
------------------------
- TILED MAP EDITOR 0.6.x
+ TILED MAP EDITOR 0.7.x
------------------------
This is Tiled, a general purpose tiled map editor. Although this release is
@@ -56,4 +56,3 @@
- GNOME and GIMP for their magnificent icons
- Nephilim for suggesting layer opacity
- Rainer Deyke for useful suggestions and many code contributions
-- My girlfriend Alexandra for her continued support
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/TODO 2006-06-24 22:34:43 UTC (rev 682)
@@ -2,12 +2,32 @@
0.7.0
* Remove copy constructors in favour of clone method (DONE)
+
* Add import/export of options (WIP)
+
+ See about reusing overwrite confirmation and default extension
+ functionality from ConfirmingFileChooser.
+
* Allow embedding of tile palette beneath the map view (WIP)
+
+ Make continuous layout and tiles per row behaviour configurable.
+
+ Fix default tabbed tilesets panel height.
+
* Replace tile button with a brush preview beneath the layer table
-* Allow creation of stamp brush from the tile palette
+
+* Allow creation of stamp brush from the tile palette (WIP)
+
+ Do not reset brush when switching tools (but do show a small tile highlight
+ while other tools than stamp brush are selected)
+
* Add support for tile instance properties (see Christian's patch) (WIP)
+ Fix big memory usage, maybe reference properties from a HashMap instead of
+ from each tile? Also check the amount of information stored for undo/redo.
+
+ Implement an effective way of displaying the presence of these properties.
+
0.8.0
* Set up a layer->map->mapview changes event trail to automatically handle
repainting changes in all views on the map.
Modified: trunk/src/tiled/core/MultilayerPlane.java
===================================================================
--- trunk/src/tiled/core/MultilayerPlane.java 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/src/tiled/core/MultilayerPlane.java 2006-06-24 22:34:43 UTC (rev 682)
@@ -13,7 +13,9 @@
package tiled.core;
import java.awt.Rectangle;
-import java.util.*;
+import java.util.Collection;
+import java.util.ListIterator;
+import java.util.Vector;
/**
* MultilayerPlane makes up the core functionality of both Maps and Brushes.
@@ -86,12 +88,12 @@
/**
* Adds a layer to the map.
*
- * @param l The {@link MapLayer} to add
+ * @param layer The {@link MapLayer} to add
* @return the layer passed to the function
*/
- public MapLayer addLayer(MapLayer l) {
- layers.add(l);
- return l;
+ public MapLayer addLayer(MapLayer layer) {
+ layers.add(layer);
+ return layer;
}
/**
@@ -122,10 +124,10 @@
/**
* Adds all the layers in a given java.util.Collection.
*
- * @param c a collection of layers to add
+ * @param layers a collection of layers to add
*/
- public void addAllLayers(Collection c) {
- layers.addAll(c);
+ public void addAllLayers(Collection layers) {
+ this.layers.addAll(layers);
}
/**
Modified: trunk/src/tiled/core/TileLayer.java
===================================================================
--- trunk/src/tiled/core/TileLayer.java 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/src/tiled/core/TileLayer.java 2006-06-24 22:34:43 UTC (rev 682)
@@ -276,12 +276,6 @@
try {
if (canEdit()) {
map[ty - bounds.y][tx - bounds.x] = ti;
-
- if (ti != null) {
- tileInstanceProperties[ty - bounds.y][tx - bounds.x] = new Properties();
- } else {
- tileInstanceProperties[ty - bounds.y][tx - bounds.x] = null;
- }
}
} catch (ArrayIndexOutOfBoundsException e) {
// Silently ignore out of bounds exception
@@ -443,10 +437,8 @@
clone.tileInstanceProperties[i] = new Properties[map[i].length];
for (int j = 0; j < map[i].length; j++) {
- if (map[i][j] != null) {
- clone.tileInstanceProperties[i][j] = new Properties();
- } else {
- clone.tileInstanceProperties[i][j] = null;
+ if (tileInstanceProperties[i][j] != null) {
+ clone.tileInstanceProperties[i][j] = new Properties(tileInstanceProperties[i][j]);
}
}
}
@@ -475,11 +467,12 @@
for (int x = Math.max(0, dx); x < maxX; x++) {
for (int y = Math.max(0, dy); y < maxY; y++) {
newMap[y][x] = getTileAt(x - dx, y - dy);
- newTileInstanceProperties[y][x] = getTileInstancePropertiesAt( x - dx, y - dy );
+ newTileInstanceProperties[y][x] = getTileInstancePropertiesAt(x - dx, y - dy);
}
}
map = newMap;
+ tileInstanceProperties = newTileInstanceProperties;
bounds.width = width;
bounds.height = height;
}
Modified: trunk/src/tiled/mapeditor/MapEditor.java
===================================================================
--- trunk/src/tiled/mapeditor/MapEditor.java 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/src/tiled/mapeditor/MapEditor.java 2006-06-24 22:34:43 UTC (rev 682)
@@ -82,7 +82,7 @@
private Cursor curMarquee;
/** Current release version. */
- public static final String version = "0.6.0";
+ public static final String version = "0.7.0 WIP";
private Map currentMap;
private MapView mapView;
@@ -1013,8 +1013,6 @@
(Math.max(limp.y, tile.y) - miny) + 1);
// Right mouse button dragged: create and set custom brush
- MultilayerPlane mlp =
- new MultilayerPlane(bounds.width, bounds.height);
TileLayer brushLayer = new TileLayer(bounds);
brushLayer.copyFrom(getCurrentLayer());
@@ -1025,8 +1023,7 @@
Resources.getString("dialog.selection.empty"),
JOptionPane.WARNING_MESSAGE);
} else {
- mlp.addLayer(brushLayer);
- setBrush(new CustomBrush(mlp));
+ setBrush(new CustomBrush(brushLayer));
}
//get rid of any visible marquee
@@ -1893,7 +1890,9 @@
sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
setBrush(sb);
- tilePaletteDialog.setMap(currentMap);
+ if (tilePaletteDialog != null) {
+ tilePaletteDialog.setMap(currentMap);
+ }
tabbedTilesetsPane.setMap(currentMap);
if (!mapLoaded) {
@@ -1966,10 +1965,6 @@
zoomNormalAction.setEnabled(mapLoaded && mapView.getZoomLevel() !=
MapView.ZOOM_NORMALSIZE);
- if (tilePaletteDialog != null) {
- tilePaletteDialog.setMap(currentMap);
- }
-
/*
if (miniMap != null && currentMap != null) {
miniMap.setView(MapView.createViewforMap(currentMap));
Modified: trunk/src/tiled/mapeditor/brush/CustomBrush.java
===================================================================
--- trunk/src/tiled/mapeditor/brush/CustomBrush.java 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/src/tiled/mapeditor/brush/CustomBrush.java 2006-06-24 22:34:43 UTC (rev 682)
@@ -5,7 +5,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* Adam Turk <aturk at biggeruniverse.com>
* Bjorn Lindeijer <b.lindeijer at xs4all.nl>
*/
@@ -26,12 +26,13 @@
*/
public class CustomBrush extends AbstractBrush
{
- public CustomBrush() {
+ public CustomBrush(MultilayerPlane mlp) {
+ addAllLayers(mlp.getLayerVector());
+ fitBoundsToLayers();
}
- public CustomBrush(MultilayerPlane m) {
- this();
- addAllLayers(m.getLayerVector());
+ public CustomBrush(TileLayer tileLayer) {
+ addLayer(tileLayer);
fitBoundsToLayers();
}
@@ -45,7 +46,7 @@
public Shape getShape() {
return getBounds();
}
-
+
/**
* Determines whether this brush is equal to another brush.
*/
@@ -64,7 +65,7 @@
}
/**
- * The custom brush will merge its internal layers onto the layers of the
+ * The custom brush will merge its internal layers onto the layers of the
* specified MultilayerPlane.
*
* @see tiled.core.TileLayer#mergeOnto(tiled.core.MapLayer)
Modified: trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java 2006-06-24 22:34:43 UTC (rev 682)
@@ -25,6 +25,8 @@
import tiled.core.TileSet;
import tiled.mapeditor.MapEditor;
import tiled.mapeditor.Resources;
+import tiled.mapeditor.brush.CustomBrush;
+import tiled.mapeditor.util.TileRegionSelectionEvent;
import tiled.mapeditor.util.TileSelectionEvent;
import tiled.mapeditor.util.TileSelectionListener;
import tiled.mapeditor.widget.TilePalettePanel;
@@ -114,6 +116,10 @@
editor.setCurrentTile(event.getTile());
}
+ public void tileRegionSelected(TileRegionSelectionEvent e) {
+ editor.setBrush(new CustomBrush(e.getTileRegion()));
+ }
+
public void valueChanged(ListSelectionEvent e) {
pc.setTileset((TileSet) sets.getSelectedValue());
}
Added: trunk/src/tiled/mapeditor/util/TileRegionSelectionEvent.java
===================================================================
--- trunk/src/tiled/mapeditor/util/TileRegionSelectionEvent.java 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/src/tiled/mapeditor/util/TileRegionSelectionEvent.java 2006-06-24 22:34:43 UTC (rev 682)
@@ -0,0 +1,36 @@
+/*
+ * Tiled Map Editor, (c) 2004-2006
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Adam Turk <aturk at biggeruniverse.com>
+ * Bjorn Lindeijer <b.lindeijer at xs4all.nl>
+ */
+
+package tiled.mapeditor.util;
+
+import java.util.EventObject;
+
+import tiled.core.TileLayer;
+
+/**
+ * An event that describes the selection of a tile region.
+ *
+ * @version $Id: TileSelectionEvent.java 680 2006-06-24 00:50:03Z bjorn $
+ */
+public class TileRegionSelectionEvent extends EventObject
+{
+ private final TileLayer tileLayer;
+
+ public TileRegionSelectionEvent(Object source, TileLayer tileLayer) {
+ super(source);
+ this.tileLayer = tileLayer;
+ }
+
+ public TileLayer getTileRegion() {
+ return tileLayer;
+ }
+}
Modified: trunk/src/tiled/mapeditor/util/TileSelectionListener.java
===================================================================
--- trunk/src/tiled/mapeditor/util/TileSelectionListener.java 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/src/tiled/mapeditor/util/TileSelectionListener.java 2006-06-24 22:34:43 UTC (rev 682)
@@ -5,7 +5,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* Adam Turk <aturk at biggeruniverse.com>
* Bjorn Lindeijer <b.lindeijer at xs4all.nl>
*/
@@ -14,8 +14,12 @@
import java.util.EventListener;
-
+/**
+ * @version $Id$
+ */
public interface TileSelectionListener extends EventListener
{
public void tileSelected(TileSelectionEvent e);
+
+ public void tileRegionSelected(TileRegionSelectionEvent e);
}
Modified: trunk/src/tiled/mapeditor/widget/TabbedTilesetsPane.java
===================================================================
--- trunk/src/tiled/mapeditor/widget/TabbedTilesetsPane.java 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/src/tiled/mapeditor/widget/TabbedTilesetsPane.java 2006-06-24 22:34:43 UTC (rev 682)
@@ -24,6 +24,8 @@
import tiled.core.Map;
import tiled.core.TileSet;
import tiled.mapeditor.MapEditor;
+import tiled.mapeditor.brush.CustomBrush;
+import tiled.mapeditor.util.TileRegionSelectionEvent;
import tiled.mapeditor.util.TileSelectionEvent;
import tiled.mapeditor.util.TileSelectionListener;
@@ -96,4 +98,12 @@
public void tileSelected(TileSelectionEvent e) {
mapEditor.setCurrentTile(e.getTile());
}
+
+ /**
+ * Creates a stamp brush from the region contents and sets this as the
+ * current brush.
+ */
+ public void tileRegionSelected(TileRegionSelectionEvent e) {
+ mapEditor.setBrush(new CustomBrush(e.getTileRegion()));
+ }
}
Modified: trunk/src/tiled/mapeditor/widget/TilePalettePanel.java
===================================================================
--- trunk/src/tiled/mapeditor/widget/TilePalettePanel.java 2006-06-24 13:50:21 UTC (rev 681)
+++ trunk/src/tiled/mapeditor/widget/TilePalettePanel.java 2006-06-24 22:34:43 UTC (rev 682)
@@ -21,7 +21,9 @@
import javax.swing.event.MouseInputAdapter;
import tiled.core.Tile;
+import tiled.core.TileLayer;
import tiled.core.TileSet;
+import tiled.mapeditor.util.TileRegionSelectionEvent;
import tiled.mapeditor.util.TileSelectionEvent;
import tiled.mapeditor.util.TileSelectionListener;
@@ -60,7 +62,7 @@
if (!select.equals(selection)) {
setSelection(select);
}
- // todo: Fire tile region selection event
+ fireTileRegionSelectionEvent(selection);
}
};
addMouseListener(mouseInputAdapter);
@@ -88,14 +90,50 @@
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == TileSelectionListener.class) {
- if (event == null) event =
- new TileSelectionEvent(this, selectedTile);
- ((TileSelectionListener)listeners[i + 1]).tileSelected(event);
+ if (event == null) {
+ event = new TileSelectionEvent(this, selectedTile);
+ }
+
+ ((TileSelectionListener) listeners[i + 1]).tileSelected(event);
}
}
}
+ private void fireTileRegionSelectionEvent(Rectangle selection) {
+ Object[] listeners = tileSelectionListeners.getListenerList();
+ TileRegionSelectionEvent event = null;
+
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == TileSelectionListener.class) {
+ if (event == null) {
+ TileLayer region = createTileLayerFromRegion(selection);
+ event = new TileRegionSelectionEvent(this, region);
+ }
+
+ ((TileSelectionListener) listeners[i + 1]).tileRegionSelected(event);
+ }
+ }
+ }
+
/**
+ * Creates a tile layer from a certain region of the tile palette.
+ * @param rect the rectangular region from which a tile layer is created
+ * @return the created tile layer
+ */
+ private TileLayer createTileLayerFromRegion(Rectangle rect) {
+ TileLayer layer = new TileLayer(rect.width + 1, rect.height + 1);
+
+ // Copy the tiles in the region to the tile layer
+ for (int y = rect.y; y <= rect.y + rect.height; y++) {
+ for (int x = rect.x; x <= rect.x + rect.width; x++) {
+ layer.setTileAt(x - rect.x, y - rect.y, getTileAt(x, y));
+ }
+ }
+
+ return layer;
+ }
+
+ /**
* Change the tileset displayed by this palette panel.
*
* @param tileset
@@ -298,7 +336,7 @@
public boolean getScrollableTracksViewportWidth() {
// todo: Update when this has become an option
- return tileset.getTilesPerRow() == 0;
+ return tileset == null || tileset.getTilesPerRow() == 0;
}
public boolean getScrollableTracksViewportHeight() {
More information about the tiled-commit
mailing list