[tiled] r606 - in trunk/src/tiled: core io io/xml mapeditor/dialogs mapeditor/plugin mapeditor/resources plugins/mappy plugins/tmw

svn@biggeruniverse.com svn at biggeruniverse.com
Mon Apr 10 19:05:20 PDT 2006


Author: aturk
Date: 2006-04-10 21:05:19 -0500 (Mon, 10 Apr 2006)
New Revision: 606

Added:
   trunk/src/tiled/io/PluginLogger.java
   trunk/src/tiled/mapeditor/dialogs/PluginLogDialog.java
Modified:
   trunk/src/tiled/core/TileSet.java
   trunk/src/tiled/io/ImageHelper.java
   trunk/src/tiled/io/MapHelper.java
   trunk/src/tiled/io/PluggableMapIO.java
   trunk/src/tiled/io/xml/XMLMapTransformer.java
   trunk/src/tiled/io/xml/XMLMapWriter.java
   trunk/src/tiled/mapeditor/dialogs/BrushDialog.java
   trunk/src/tiled/mapeditor/dialogs/ImageColorDialog.java
   trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java
   trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java
   trunk/src/tiled/mapeditor/dialogs/TileDialog.java
   trunk/src/tiled/mapeditor/plugin/TiledPlugin.java
   trunk/src/tiled/mapeditor/resources/gui.properties
   trunk/src/tiled/plugins/mappy/MappyMapReader.java
   trunk/src/tiled/plugins/mappy/MappyMapWriter.java
   trunk/src/tiled/plugins/tmw/TMWServerMapWriter.java
Log:
+ Fixed image loading bug for embedded sets
+ More internationalization support
+ Reopening brush dialog for more bursh work
+ More robust plugin logging
+ Start on tileset automatic reloading

Modified: trunk/src/tiled/core/TileSet.java
===================================================================
--- trunk/src/tiled/core/TileSet.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/core/TileSet.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -15,6 +15,7 @@
 import java.awt.*;
 import java.awt.image.BufferedImage;
 import java.io.File;
+import java.io.IOException;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.Properties;
@@ -40,8 +41,10 @@
     private String base;
     private NumberedSet tiles, images;
     private int firstGid;
+    private long tilebmpFileLastModified;
     private Rectangle tileDimensions;
-    private String externalSource, tilebmpFile;
+    private String externalSource;
+    private File tilebmpFile;
     private String name;
     private Color transparentColor;
     private Properties defaultTileProperties;
@@ -70,12 +73,9 @@
                                  boolean createTiles) throws Exception
     {
         // IOException will propagate upwards when file cannot be found
-        File imgFile = new File(imgFilename);
-        tilebmpFile = imgFile.getCanonicalPath();
-
-        System.out.println("Importing " + imgFilename + "...");
-
-        importTileBitmap(ImageIO.read(imgFile), cutter, createTiles);
+        tilebmpFile = new File(imgFilename);
+        tilebmpFileLastModified = tilebmpFile.lastModified();
+        importTileBitmap(ImageIO.read(tilebmpFile), cutter, createTiles);
     }
 
     /**
@@ -167,7 +167,8 @@
      * @param name
      */
     public void setTilesetImageFilename(String name) {
-        tilebmpFile = name;
+        tilebmpFile = new File(name);
+        tilebmpFileLastModified = tilebmpFile.lastModified();
     }
 
     /**
@@ -218,7 +219,7 @@
         }
 
         // Add any default properties
-        // todo: use parent properties instead?
+        // TODO: use parent properties instead?
         t.getProperties().putAll(defaultTileProperties);
 
         tiles.put(t.getId(), t);
@@ -367,7 +368,12 @@
      *         tileset doesn't reference a tile bitmap
      */
     public String getTilebmpFile() {
-        return tilebmpFile;
+        try {
+			return tilebmpFile.getCanonicalPath();
+		} catch (IOException e) {
+		}
+		
+		return "";
     }
 
     /**

Modified: trunk/src/tiled/io/ImageHelper.java
===================================================================
--- trunk/src/tiled/io/ImageHelper.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/io/ImageHelper.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -13,8 +13,10 @@
 package tiled.io;
 
 import java.awt.Image;
+import java.awt.MediaTracker;
 import java.awt.Toolkit;
 import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.File;
@@ -58,10 +60,11 @@
      *
      * @param imageData The byte array of the data to convert.
      * @return Image The image instance created from the byte array
+     * @throws IOException 
      * @see java.awt.Toolkit#createImage(byte[] imagedata)
      */
-    static public Image bytesToImage(byte[] imageData) {
-        return Toolkit.getDefaultToolkit().createImage(imageData);
+    static public Image bytesToImage(byte[] imageData) throws IOException {
+        return ImageIO.read(new ByteArrayInputStream(imageData));
     }
 
     /**

Modified: trunk/src/tiled/io/MapHelper.java
===================================================================
--- trunk/src/tiled/io/MapHelper.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/io/MapHelper.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -23,6 +23,7 @@
 import tiled.core.TileSet;
 import tiled.io.xml.XMLMapTransformer;
 import tiled.io.xml.XMLMapWriter;
+import tiled.mapeditor.dialogs.PluginLogDialog;
 import tiled.mapeditor.plugin.PluginClassLoader;
 import tiled.util.TiledConfiguration;
 
@@ -68,11 +69,11 @@
         }
 
         if (mw != null) {
-            Stack errors = new Stack();
-            mw.setErrorStack(errors);
+        	PluginLogger logger = new PluginLogger();
+            mw.setLogger(logger);
             mw.writeMap(currentMap, filename);
             currentMap.setFilename(filename);
-            reportPluginMessages(errors);
+            reportPluginMessages(logger);
         } else {
             throw new Exception("Unsupported map format");
         }
@@ -100,11 +101,11 @@
         }
 
         if (mw != null) {
-            Stack errors = new Stack();
-            mw.setErrorStack(errors);
+        	PluginLogger logger = new PluginLogger();
+            mw.setLogger(logger);
             mw.writeTileset(set, filename);
             set.setSource(filename);
-            reportPluginMessages(errors);
+            reportPluginMessages(logger);
         } else {
             throw new Exception("Unsupported tileset format");
         }
@@ -124,11 +125,11 @@
     	throws Exception {
     	MapWriter mw = (MapWriter)pmio;
     	
-        Stack errors = new Stack();
-        mw.setErrorStack(errors);
+    	PluginLogger logger = new PluginLogger();
+        mw.setLogger(logger);
         mw.writeMap(currentMap, filename);
         currentMap.setFilename(filename);
-        reportPluginMessages(errors);
+        reportPluginMessages(logger);
     }
     
     /**
@@ -153,11 +154,11 @@
             }
 
             if (mr != null) {
-                Stack errors = new Stack();
-                mr.setErrorStack(errors);
+            	PluginLogger logger = new PluginLogger();
+                mr.setLogger(logger);
                 ret = mr.readMap(file);
                 ret.setFilename(file);
-                reportPluginMessages(errors);
+                reportPluginMessages(logger);
             } else {
                 throw new Exception("Unsupported map format");
             }
@@ -203,11 +204,11 @@
             }
 
             if (mr != null) {
-                Stack errors = new Stack();
-                mr.setErrorStack(errors);
+            	PluginLogger logger = new PluginLogger();
+                mr.setLogger(logger);
                 ret = mr.readTileset(file);
                 ret.setSource(file);
-                reportPluginMessages(errors);
+                reportPluginMessages(logger);
             } else {
                 throw new Exception("Unsupported tileset format");
             }
@@ -237,13 +238,14 @@
      * @param s A Stack which was used by the plugin to record any messages it
      *          had for the user
      */
-    private static void reportPluginMessages(Stack s) {
+    private static void reportPluginMessages(PluginLogger logger) {
         // TODO: maybe have a nice dialog with a scrollbar, in case there are
         // a lot of messages...
         Preferences prefs = TiledConfiguration.node("io");
 
         if (prefs.getBoolean("reportWarnings", false)) {
-            if (!s.isEmpty()) {
+        	PluginLogDialog pld = new PluginLogDialog();
+            /*if (!s.isEmpty()) {
                 Iterator itr = s.iterator();
                 StringBuffer warnings = new StringBuffer();
                 while (itr.hasNext()) {
@@ -252,7 +254,7 @@
                 JOptionPane.showMessageDialog(null, warnings.toString(),
                         "Loading Messages",
                         JOptionPane.INFORMATION_MESSAGE);
-            }
+            }*/
         }
     }
 }

Modified: trunk/src/tiled/io/PluggableMapIO.java
===================================================================
--- trunk/src/tiled/io/PluggableMapIO.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/io/PluggableMapIO.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -14,6 +14,7 @@
 
 import java.util.Stack;
 
+
 /**
  * This is the interface for all Tiled I/O plugins, whether they load, save, or
  * both. The PluginClassLoader also uses this to check the supported file
@@ -55,12 +56,11 @@
     public String getPluginPackage();
     
     /**
-     * The Stack object passed by the editor when the plugin is called to load
+     * The PluginLogger object passed by the editor when the plugin is called to load
      * or save a map can be used by the plugin to notify the user of any
      * problems or messages.
      * 
-     * @param es an initialized Stack that will be used by the editor to 
-     *           print messages from the plugin 
+     * @param logger 
      */
-    public void setErrorStack(Stack es);
+    public void setLogger(PluginLogger logger);
 }

Added: trunk/src/tiled/io/PluginLogger.java
===================================================================
--- trunk/src/tiled/io/PluginLogger.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/io/PluginLogger.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -0,0 +1,35 @@
+package tiled.io;
+
+import java.util.LinkedList;
+
+
+
+public class PluginLogger {
+
+	private LinkedList messages;
+	
+	public void error(Object message) {
+		
+	}
+	
+	public void warn(Object message) {
+		
+	}
+	
+	public void info(Object message) {
+		
+	}
+	
+	public void debug(Object message) {
+		
+	}
+	
+	public boolean isEmpty() {
+		return messages.isEmpty();
+	}
+	
+	public class PluginMessage {
+		private int type;
+		private Object message;
+	};
+}

Modified: trunk/src/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapTransformer.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/io/xml/XMLMapTransformer.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -35,6 +35,7 @@
 import tiled.core.*;
 import tiled.io.ImageHelper;
 import tiled.io.MapReader;
+import tiled.io.PluginLogger;
 import tiled.mapeditor.util.TransparentImageFilter;
 import tiled.mapeditor.util.cutter.BasicTileCutter;
 import tiled.util.*;
@@ -46,10 +47,10 @@
 {
     private Map map;
     private String xmlPath;
-    private Stack warnings;
+    private PluginLogger logger;
 
     public XMLMapTransformer() {
-        warnings = new Stack();
+        logger = new PluginLogger();
     }
 
     private static String makeUrl(String filename) throws MalformedURLException {
@@ -92,7 +93,7 @@
             } else if (parameterTypes[i].getName().equalsIgnoreCase("boolean")) {
                 conformingArguments[i] = Boolean.valueOf(args[i]);
             } else {
-                warnings.push("INFO: Unsupported argument type " +
+            	logger.debug("Unsupported argument type " +
                         parameterTypes[i].getName() +
                         ", defaulting to java.lang.String");
                 conformingArguments[i] = args[i];
@@ -114,7 +115,7 @@
         } else if (o.equalsIgnoreCase("shifted")) {
             map.setOrientation(Map.MDO_SHIFTED);
         } else {
-            warnings.push("WARN: Unknown orientation '" + o + "'");
+        	logger.warn("Unknown orientation '" + o + "'");
         }
     }
 
@@ -168,7 +169,7 @@
                         reflectInvokeMethod(o,methods[j],
                                 new String [] {n.getNodeValue()});
                     } else {
-                        warnings.push("WARN: Unsupported attribute '" +
+                    	logger.warn("Unsupported attribute '" +
                                 n.getNodeName() +
                                 "' on <" + node.getNodeName() + "> tag");
                     }
@@ -202,7 +203,7 @@
                 if (n.getNodeName().equals("data")) {
                     Node cdata = n.getFirstChild();
                     if (cdata == null) {
-                        warnings.push("WARN: image <data> tag enclosed no " +
+                    	logger.warn("image <data> tag enclosed no " +
                                 "data. (empty data tag)");
                     } else {
                         String sdata = cdata.getNodeValue();
@@ -251,8 +252,7 @@
             for (int itr = 0; (tsNode = tsNodeList.item(itr)) != null; itr++) {
                 set = unmarshalTileset(tsNode);
                 if (set.getSource() != null) {
-                    warnings.push(
-                            "WARN: Recursive external Tilesets are not supported.");
+                	logger.warn("Recursive external Tilesets are not supported.");
                 }
                 set.setSource(filename);
                 // NOTE: This is a deliberate break. multiple tilesets per TSX are
@@ -262,7 +262,7 @@
 
             xmlPath = xmlPathSave;
         } catch (SAXException e) {
-            warnings.push("ERROR: Failed while loading "+filename+": "+e.getMessage());
+        	logger.error("Failed while loading "+filename+": "+e.getMessage());
             //e.printStackTrace();
         }
 
@@ -292,18 +292,18 @@
                 //just a little check for tricky people...
                 String extention = source.substring(source.lastIndexOf('.') + 1);
                 if (!extention.toLowerCase().equals("tsx")) {
-                    warnings.push("WARN: tileset files should end in .tsx! ("+source+")");
+                	logger.warn("tileset files should end in .tsx! ("+source+")");
                 }
 
                 InputStream in = new URL(makeUrl(filename)).openStream();
                 ext = unmarshalTilesetFile(in, filename);
             } catch (FileNotFoundException fnf) {
-                warnings.push("ERROR: Could not find external tileset file " +
+            	logger.error("Could not find external tileset file " +
                         filename);
             }
 
             if (ext == null) {
-                warnings.push("ERROR: tileset "+source+" was not loaded correctly!");
+            	logger.error("tileset "+source+" was not loaded correctly!");
                 ext = new TileSet();
             }
 
@@ -353,43 +353,38 @@
                             sourcePath = tilesetBaseDir + imgSource;
                         }
 
+                        logger.info("Importing "+sourcePath+"...");
+                        
+                        BufferedImage tilesetImage = ImageIO.read(new File(sourcePath));
+                        
                         if (transStr != null) {
                             // In this case, the tileset image needs special
                             // handling for transparency
                             Color color = new Color(
                                     Integer.parseInt(transStr, 16));
                             Toolkit tk = Toolkit.getDefaultToolkit();
-                            try {
-                                Image orig = ImageIO.read(new File(sourcePath));
-                                Image trans = tk.createImage(
-                                        new FilteredImageSource(orig.getSource(),
-                                            new TransparentImageFilter(
-                                                color.getRGB())));
-                                BufferedImage img = new BufferedImage(
-                                        trans.getWidth(null),
-                                        trans.getHeight(null),
-                                        BufferedImage.TYPE_INT_ARGB);
+                            Image trans = tk.createImage(
+                                    new FilteredImageSource(tilesetImage.getSource(),
+                                        new TransparentImageFilter(
+                                            color.getRGB())));
+                            BufferedImage img = new BufferedImage(
+                                    trans.getWidth(null),
+                                    trans.getHeight(null),
+                                    BufferedImage.TYPE_INT_ARGB);
 
-                                img.getGraphics().drawImage(trans, 0, 0, null);
+                            img.getGraphics().drawImage(trans, 0, 0, null);
 
-                                set.importTileBitmap(img, new BasicTileCutter(
-                                            tileWidth, tileHeight, tileSpacing, 0),
-                                        !hasTileElements);
-
-                                set.setTransparentColor(color);
-                                set.setTilesetImageFilename(sourcePath);
-                            } catch (IIOException iioe) {
-                                warnings.push("ERROR: " +
-                                        iioe.getLocalizedMessage() + " (" +
-                                        sourcePath + ")");
-                            }
-                        } else {
-                            set.importTileBitmap(sourcePath,
-                                    new BasicTileCutter(tileWidth, tileHeight,
-                                            tileSpacing, 0),
-                                    !hasTileElements);
+                            tilesetImage = img;
+                            
+                            set.setTransparentColor(color);
                         }
 
+                        set.importTileBitmap(tilesetImage, new BasicTileCutter(
+                                tileWidth, tileHeight, tileSpacing, 0),
+                            !hasTileElements);
+
+                        set.setTilesetImageFilename(sourcePath);
+                        
                     } else {
                         set.addImage(unmarshalImage(child, tilesetBaseDir),
                                 Integer.parseInt(getAttributeValue(child, "id")));
@@ -446,7 +441,8 @@
                 tile = (Tile)unmarshalClass(Tile.class, t);
             }
         } catch (Exception e) {
-            e.printStackTrace();
+        	logger.error("failed creating tile: "+e.getLocalizedMessage());
+            //e.printStackTrace();
             return tile;
         }
 
@@ -458,8 +454,9 @@
             Node child = children.item(i);
             if (child.getNodeName().equalsIgnoreCase("image")) {
                 int id = getAttribute(child, "id", -1);
+                Image img = unmarshalImage(child, baseDir);
                 if (id < 0) {
-                    id = set.addImage(unmarshalImage(child, baseDir));
+                    id = set.addImage(img);
                 }
                 tile.setImage(id);
             } else if (child.getNodeName().equalsIgnoreCase("property")) {
@@ -529,7 +526,7 @@
                 if (encoding != null && encoding.equalsIgnoreCase("base64")) {
                     Node cdata = child.getFirstChild();
                     if (cdata == null) {
-                        warnings.push("WARN: layer <data> tag enclosed no data. (empty data tag)");
+                    	logger.warn("layer <data> tag enclosed no data. (empty data tag)");
                     } else {
                         char[] enc = cdata.getNodeValue().trim().toCharArray();
                         byte[] dec = Base64.decode(enc);
@@ -783,7 +780,7 @@
         return false;
     }
 
-    public void setErrorStack(Stack es) {
-        warnings = es;
+    public void setLogger(PluginLogger logger) {
+        this.logger = logger;
     }
 }

Modified: trunk/src/tiled/io/xml/XMLMapWriter.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapWriter.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/io/xml/XMLMapWriter.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -642,6 +642,6 @@
         return false;
     }
 
-    public void setErrorStack(Stack es) {
+    public void setLogger(PluginLogger logger) {
     }
 }

Modified: trunk/src/tiled/mapeditor/dialogs/BrushDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/BrushDialog.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/mapeditor/dialogs/BrushDialog.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -54,13 +54,20 @@
     private JCheckBox cbRandomBrush;
     private IntegerSpinner affectLayers, brushSize;
     private JSlider sRandomAmount;
-    private JButton bOk, bApply, bCancel;
+    private JButton okButton, bApply, bCancel;
     private BrushBrowser brushes;
 
+    private static final String DIALOG_TITLE = Resources.getString("dialog.brush.title");
+    private static final String OK_BUTTON = Resources.getString("general.button.ok");
+    private static final String APPLY_BUTTON = Resources.getString("general.button.apply");
+    private static final String CANCEL_BUTTON = Resources.getString("general.button.cancel");
+    private static final String SHAPE_TAB = Resources.getString("dialog.brush.tab.shape");
+    private static final String CUSTOM_TAB = Resources.getString("dialog.brush.tab.custom");
+    
     public BrushDialog(MapEditor editor, JFrame parent,
                        AbstractBrush currentBrush)
     {
-        super(parent, Resources.getString("dialog.brush.title"), false);
+        super(parent, DIALOG_TITLE, false);
         myBrush = currentBrush;
         this.editor = editor;
 
@@ -182,12 +189,14 @@
     }
 
     private void init() {
-        createCustomPanel();
+    	JTabbedPane tabs = new JTabbedPane(JTabbedPane.TOP);
+        tabs.addTab(SHAPE_TAB, createShapePanel());
+        tabs.addTab(CUSTOM_TAB, createCustomPanel());
 
-        bOk = new JButton("OK");
-        bApply = new JButton("Apply");
-        bCancel = new JButton("Cancel");
-        bOk.addActionListener(this);
+        okButton = new JButton(OK_BUTTON);
+        bApply = new JButton(APPLY_BUTTON);
+        bCancel = new JButton(CANCEL_BUTTON);
+        okButton.addActionListener(this);
         bApply.addActionListener(this);
         bCancel.addActionListener(this);
         bApply.setEnabled(false);
@@ -196,7 +205,7 @@
         JPanel buttons = new VerticalStaticJPanel();
         buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
         buttons.add(Box.createGlue());
-        buttons.add(bOk);
+        buttons.add(okButton);
         buttons.add(Box.createRigidArea(new Dimension(5, 0)));
         buttons.add(bApply);
         buttons.add(Box.createRigidArea(new Dimension(5, 0)));
@@ -205,12 +214,12 @@
         JPanel mainPanel = new JPanel();
         mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
         mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-        mainPanel.add(createShapePanel());
+        mainPanel.add(tabs);
         mainPanel.add(Box.createRigidArea(new Dimension(0, 5)));
         mainPanel.add(buttons);
 
         getContentPane().add(mainPanel);
-        getRootPane().setDefaultButton(bOk);
+        getRootPane().setDefaultButton(okButton);
     }
 
     private void createFromOptions() {
@@ -257,7 +266,7 @@
     public void actionPerformed(ActionEvent e) {
         Object source = e.getSource();
 
-        if (source == bOk) {
+        if (source == okButton) {
             createFromOptions();
             editor.setBrush(myBrush);
             dispose();

Modified: trunk/src/tiled/mapeditor/dialogs/ImageColorDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/ImageColorDialog.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/mapeditor/dialogs/ImageColorDialog.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -21,21 +21,27 @@
 import java.awt.image.PixelGrabber;
 import javax.swing.*;
 
+import tiled.mapeditor.Resources;
 import tiled.mapeditor.widget.ImageViewPanel;
 import tiled.mapeditor.widget.VerticalStaticJPanel;
 
 /**
  * @version $Id$
  */
-public class ImageColorDialog extends JDialog implements ActionListener,
-        MouseListener, MouseMotionListener
+public class ImageColorDialog extends JDialog implements MouseListener, 
+		MouseMotionListener
 {
     private Image image;
-    private JButton bCancel;
+    private JButton cancelButton;
     private Color color;
     private JPanel colorPanel;
     private int[] pixels;
 
+    /* LANGUAGE PACK */
+    private static final String DIALOG_TITLE = Resources.getString("dialog.imagecolor.title");
+    private static final String CANCEL_BUTTON = Resources.getString("general.button.cancel");
+    /* -- */
+    
     public ImageColorDialog(Image i) {
         image = i;
         PixelGrabber pg = new PixelGrabber(i, 0, 0, -1, -1, true);
@@ -60,15 +66,14 @@
         imagePanel.addMouseListener(this);
         imagePanel.addMouseMotionListener(this);
 
-        setTitle("Color Chooser");
+        setTitle(DIALOG_TITLE);
 
         color = new Color(255, 103, 139);  //Evil pink
         colorPanel = new JPanel();
         colorPanel.setPreferredSize(new Dimension(25, 25));
         colorPanel.setBackground(color);
 
-        bCancel = new JButton("Cancel");
-        bCancel.addActionListener(this);
+        cancelButton = new JButton(CANCEL_BUTTON);
 
         JScrollPane imageScrollPane = new JScrollPane(imagePanel);
         imageScrollPane.setAutoscrolls(true);
@@ -88,11 +93,19 @@
         c.gridx = 1;
         buttonPanel.add(Box.createRigidArea(new Dimension(25, 5)));
         c.gridx = 2;
-        buttonPanel.add(bCancel);
+        buttonPanel.add(cancelButton);
 
         mainPanel.add(buttonPanel);
 
         setContentPane(mainPanel);
+        
+        //create actionlisteners
+        cancelButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+            	color = null;
+                dispose();
+            }
+        });
     }
 
     public Color showDialog() {
@@ -100,13 +113,6 @@
         return color;
     }
 
-    public void actionPerformed(ActionEvent e) {
-        if (e.getSource() == bCancel) {
-            color = null;
-            dispose();
-        }
-    }
-
     public void mouseClicked(MouseEvent e) {
         grabColor(e.getX(), e.getY());
         dispose();

Modified: trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -23,6 +23,7 @@
 import javax.swing.*;
 
 import tiled.core.*;
+import tiled.mapeditor.Resources;
 
 /**
  * $Id$
@@ -32,11 +33,13 @@
 	private TileSet tileset;
 	private Tile currentTile;
 	private String location;
-
-	private JButton bAddTiles, bCancel;
-
+	
+	/* LANGUAGE PACK */
+    private static final String DIALOG_TITLE = Resources.getString("dialog.newtile.title");
+    /* -- */
+    
 	public NewTileDialog(Dialog parent, TileSet set) {
-		super(parent, "New Tile", true);
+		super(parent, DIALOG_TITLE, true);
 		tileset = set;
 		location = "";
 

Added: trunk/src/tiled/mapeditor/dialogs/PluginLogDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/PluginLogDialog.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/mapeditor/dialogs/PluginLogDialog.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -0,0 +1,7 @@
+package tiled.mapeditor.dialogs;
+
+import javax.swing.JDialog;
+
+public class PluginLogDialog extends JDialog {
+
+}

Modified: trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -32,7 +32,6 @@
     private final Properties properties;
     private final PropertiesTableModel tableModel = new PropertiesTableModel();
 
-    /* LANGUAGE PACK */
     private static final String DIALOG_TITLE = Resources.getString("dialog.properties.title");
     private static final String OK_BUTTON = Resources.getString("general.button.ok");
     private static final String DELETE_BUTTON = Resources.getString("general.button.delete");

Modified: trunk/src/tiled/mapeditor/dialogs/TileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileDialog.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/mapeditor/dialogs/TileDialog.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -57,7 +57,6 @@
     private JTabbedPane tabs;
     private int currentImageIndex = -1;
 
-    /* LANGUAGE PACK */
     private static final String DIALOG_TITLE = Resources.getString("dialog.tile.title");
     private static final String OK_BUTTON = Resources.getString("general.button.ok");
     private static final String DELETE_BUTTON = Resources.getString("dialog.tile.button.deletetile");

Modified: trunk/src/tiled/mapeditor/plugin/TiledPlugin.java
===================================================================
--- trunk/src/tiled/mapeditor/plugin/TiledPlugin.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/mapeditor/plugin/TiledPlugin.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -14,11 +14,11 @@
 
 import java.io.File;
 import java.io.FileFilter;
-import java.util.Stack;
 
 import tiled.io.MapReader;
 import tiled.io.MapWriter;
 import tiled.io.PluggableMapIO;
+import tiled.io.PluginLogger;
 
 /**
  * A true "plugin" implementation that handles both reading and
@@ -114,7 +114,7 @@
     /* (non-Javadoc)
      * @see tiled.io.PluggableMapIO#setErrorStack(java.util.Stack)
      */
-    public void setErrorStack(Stack es) {
+    public void setLogger(PluginLogger logger) {
         // TODO Auto-generated method stub
     }
     

Modified: trunk/src/tiled/mapeditor/resources/gui.properties
===================================================================
--- trunk/src/tiled/mapeditor/resources/gui.properties	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/mapeditor/resources/gui.properties	2006-04-11 02:05:19 UTC (rev 606)
@@ -10,6 +10,8 @@
 action.zoom.in.name=Zoom In
 action.zoom.out.name=Zoom Out
 dialog.brush.title=Brush Options
+dialog.brush.tab.shape=Shape
+dialog.brush.tab.custom=Custom
 dialog.newmap.height.label=Height:
 dialog.newmap.mapsize.title=Map size
 dialog.newmap.maptype.label=Map type:
@@ -30,6 +32,18 @@
 dialog.newtileset.tilewidth.label=Tile width:
 dialog.newtileset.title=New Tileset
 dialog.newtileset.usetransparentcolor.label=Use transparent color
+dialog.newtileset.button.properties=Set Default Properties...
+dialog.newtile.title=New Tile
+dialog.tile.title=Edit Tileset
+dialog.tile.button.newtile=Add Tile
+dialog.tile.button.deletetile=Delete Tile
+dialog.tile.button.changeimage=Change Image
+dialog.tile.button.duptile=Duplicate Tile
+dialog.tile.button.animation=Animation
+dialog.tile.button.createtile=Create Tile
+dialog.tile.imgload.error.message=Error while loading image:
+dialog.tile.imgload.error.title=Error while loading image
+dialog.tileimage.title=Choose Tile Image
 dialog.openmap.error.title=Error while opening map file
 dialog.plugins.info.button=Info
 dialog.plugins.remove.button=Remove
@@ -65,10 +79,12 @@
 dialog.tile.title=Edit Tileset
 dialog.tileimage.title=Choose Tile Image
 dialog.tilepalette.title=Palette
+dialog.imagecolor.title=Color Chooser
 general.button.browse=Browse...
 general.button.cancel=Cancel
 general.button.close=Close
 general.button.delete=Delete
+general.button.apply=Apply
 general.button.ok=OK
 general.button.preview=Preview...
 general.file.exists.message=The file already exists. Do you wish to overwrite it?

Modified: trunk/src/tiled/plugins/mappy/MappyMapReader.java
===================================================================
--- trunk/src/tiled/plugins/mappy/MappyMapReader.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/plugins/mappy/MappyMapReader.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -15,11 +15,11 @@
 import java.io.*;
 import java.util.LinkedList;
 import java.util.Properties;
-import java.util.Stack;
 import java.util.Vector;
 import java.util.Iterator;
 
 import tiled.io.MapReader;
+import tiled.io.PluginLogger;
 import tiled.core.*;
 
 public class MappyMapReader implements MapReader
@@ -29,6 +29,8 @@
     private static final int BLKSTR_WIDTH = 32;
     private int twidth, theight;
 
+    private PluginLogger logger;
+    
     public static class BlkStr {
         public BlkStr() {
         }
@@ -91,12 +93,12 @@
      * @param filename the filename of the tileset file
      */
     public TileSet readTileset(String filename) throws Exception {
-        System.out.println("Tilesets aren't supported!");
+        logger.error("Tilesets aren't supported!");
         return null;
     }
 
     public TileSet readTileset(InputStream in) {
-        System.out.println("Tilesets aren't supported!");
+    	logger.error("Tilesets aren't supported!");
         return null;
     }
 
@@ -141,8 +143,8 @@
         return false;
     }
 
-    public void setErrorStack(Stack es) {
-        // TODO: implement setErrorStack
+    public void setLogger(PluginLogger logger) {
+        this.logger = logger;
     }
 
 
@@ -218,7 +220,7 @@
             throw new IOException("No BGFX chunk found!");
         }
 
-        System.out.println(ret.toString());
+        logger.debug(ret.toString());
         return ret;
     }
 
@@ -227,7 +229,7 @@
     }
 
     private void readBKDTChunk(Map m, InputStream in, int num) throws IOException {
-        System.out.println("Reading " + num + " blocks...");
+    	logger.debug("Reading " + num + " blocks...");
         for (int i = 0; i < num; i++) {
             blocks.add(readBLKSTR(in));
         }

Modified: trunk/src/tiled/plugins/mappy/MappyMapWriter.java
===================================================================
--- trunk/src/tiled/plugins/mappy/MappyMapWriter.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/plugins/mappy/MappyMapWriter.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -18,6 +18,7 @@
 import java.util.Stack;
 
 import tiled.io.MapWriter;
+import tiled.io.PluginLogger;
 import tiled.plugins.mappy.MappyMapReader.BlkStr;
 import tiled.core.Map;
 import tiled.core.TileSet;
@@ -96,7 +97,7 @@
         return false;
     }
 
-    public void setErrorStack(Stack es) {
+    public void setLogger(PluginLogger logger) {
         // TODO: implement setErrorStack
     }
 

Modified: trunk/src/tiled/plugins/tmw/TMWServerMapWriter.java
===================================================================
--- trunk/src/tiled/plugins/tmw/TMWServerMapWriter.java	2006-04-09 21:39:52 UTC (rev 605)
+++ trunk/src/tiled/plugins/tmw/TMWServerMapWriter.java	2006-04-11 02:05:19 UTC (rev 606)
@@ -13,9 +13,9 @@
 package tiled.plugins.tmw;
 
 import java.io.*;
-import java.util.Stack;
 
 import tiled.io.MapWriter;
+import tiled.io.PluginLogger;
 import tiled.core.*;
 
 /**
@@ -32,6 +32,8 @@
 {
     private static final int FIRST_BYTE = 0x000000FF;
 
+    private PluginLogger logger;
+    
     /**
      * Loads a map from a file.
      *
@@ -47,8 +49,8 @@
      * @param filename the filename of the tileset file
      */
     public void writeTileset(TileSet set, String filename) throws Exception {
-        System.out.println("Tilesets are not supported!");
-        System.out.println("(asked to write " + filename + ")");
+        logger.error("Tilesets are not supported!");
+        logger.error("(asked to write " + filename + ")");
     }
 
     public void writeMap(Map map, OutputStream out) throws Exception {
@@ -121,7 +123,7 @@
         return false;
     }
 
-    public void setErrorStack(Stack es) {
-        // TODO: implement setErrorStack
+    public void setLogger(PluginLogger logger) {
+        this.logger = logger;
     }
 }




More information about the tiled-commit mailing list