[tiled] r597 - in trunk/src/tiled: core mapeditor mapeditor/dialogs mapeditor/resources mapeditor/util mapeditor/util/cutter
svn@biggeruniverse.com
svn at biggeruniverse.com
Mon Apr 3 22:01:29 PDT 2006
Author: aturk
Date: 2006-04-04 00:01:28 -0500 (Tue, 04 Apr 2006)
New Revision: 597
Modified:
trunk/src/tiled/core/TileSet.java
trunk/src/tiled/mapeditor/MapEditor.java
trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java
trunk/src/tiled/mapeditor/resources/gui.properties
trunk/src/tiled/mapeditor/util/TiledFileFilter.java
trunk/src/tiled/mapeditor/util/cutter/BasicTileCutter.java
trunk/src/tiled/mapeditor/util/cutter/BorderTileCutter.java
trunk/src/tiled/mapeditor/util/cutter/TileCutter.java
Log:
+ Found a further case that "Save As" should handle
+ Fixed a bug I created (when saving as with .tmx/.tmx.gz)
+ Added some internationalization.
Modified: trunk/src/tiled/core/TileSet.java
===================================================================
--- trunk/src/tiled/core/TileSet.java 2006-04-01 17:41:46 UTC (rev 596)
+++ trunk/src/tiled/core/TileSet.java 2006-04-04 05:01:28 UTC (rev 597)
@@ -18,6 +18,7 @@
import java.io.IOException;
import java.util.Enumeration;
import java.util.Iterator;
+import java.util.Properties;
import java.util.Vector;
import javax.imageio.ImageIO;
@@ -43,7 +44,8 @@
private String externalSource, tilebmpFile;
private String name;
private Color transparentColor;
-
+ private Properties defaultTileProperties;
+
/**
* Default constructor
*/
@@ -78,9 +80,7 @@
}
/**
- * Creates a tileset from a buffered image. This is a linear cutter that
- * goes left to right, top to bottom when cutting. It can optionally create
- * tiled.core.Tile objects that reference the images as it is cutting them.
+ * Creates a tileset from a buffered image. Tiles are cut by the passed cutter.
*
* @param tilebmp the image to be used
* @param cutter
Modified: trunk/src/tiled/mapeditor/MapEditor.java
===================================================================
--- trunk/src/tiled/mapeditor/MapEditor.java 2006-04-01 17:41:46 UTC (rev 596)
+++ trunk/src/tiled/mapeditor/MapEditor.java 2006-04-04 05:01:28 UTC (rev 597)
@@ -1719,7 +1719,7 @@
if (filename != null) {
title += currentMap.getFilename();
} else {
- title += "Untitled";
+ title += Resources.getString("general.file.untitled");
}
if (unsavedChanges()) {
title += "*";
@@ -1758,6 +1758,16 @@
* an error occured
*/
public boolean loadMap(String file) {
+
+ File exist = new File(file);
+ if (!exist.exists()) {
+ JOptionPane.showMessageDialog(appFrame,
+ Resources.getString("general.file.notexists.message"),
+ Resources.getString("dialog.openmap.error.title"),
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
try {
Map m = MapHelper.loadMap(file);
@@ -1769,15 +1779,16 @@
return true;
} else {
JOptionPane.showMessageDialog(appFrame,
- "Unsupported map format", "Error while loading map",
+ "Unsupported map format",
+ Resources.getString("dialog.openmap.error.title"),
JOptionPane.ERROR_MESSAGE);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(appFrame,
"Error while loading " + file + ": " +
- e.getMessage() + (e.getCause() != null ? "\nCause: " +
- e.getCause().getMessage() : ""),
- "Error while loading map",
+ e.getLocalizedMessage() + (e.getCause() != null ? "\nCause: " +
+ e.getCause().getLocalizedMessage() : ""),
+ Resources.getString("dialog.openmap.error.title"),
JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
@@ -1798,11 +1809,10 @@
public void saveMap(String filename, boolean bSaveAs) {
TiledFileFilter saver = new TiledFileFilter(TiledFileFilter.FILTER_EXT);
- boolean saveOk = false;
JFileChooser ch = null;
try {
- while(!saveOk) {
+ while(true) {
if (bSaveAs || filename == null) {
if(ch == null) {
@@ -1835,6 +1845,11 @@
return;
}
+ // Don't let users be tricky (no foo. files)
+ if(filename.substring(filename.lastIndexOf('.')+1).length() == 0) {
+ filename = filename.substring(0,filename.lastIndexOf('.'));
+ }
+
// Make sure that the file has an extension. If not, append extension
// chosen from dropdown.
// NOTE: we can't know anything more than the filename has at least
@@ -1842,9 +1857,11 @@
if (filename.lastIndexOf('.') == -1) {
if(saver.getType() == TiledFileFilter.FILTER_EXT) {
//impossible to tell
- JOptionPane.showMessageDialog(appFrame, "Save failed, unknown type");
+ JOptionPane.showMessageDialog(appFrame, Resources.getString("dialog.saveas.unknown-type.message"));
continue;
}
+
+ //we will also be lazy about picking a valid extention...
filename = filename.concat("."+saver.getFirstExtention());
}
}
@@ -1854,8 +1871,8 @@
File exist = new File(filename);
if (exist.exists() && bSaveAs) {
int result = JOptionPane.showConfirmDialog(appFrame,
- "The file already exists. Are you sure you want to " +
- "overwrite it?", "Overwrite file?",
+ Resources.getString("general.file.exists.message"),
+ Resources.getString("general.file.exists.title"),
JOptionPane.YES_NO_OPTION);
if (result != JOptionPane.OK_OPTION) {
continue;
@@ -1870,8 +1887,7 @@
// If they don't, ask the user if they want to shoot themselves in the foot
if(!saver.accept(exist)) {
int result = JOptionPane.showConfirmDialog(appFrame,
- "The file extension does not match the plugin."+
- " Do you wish to continue?",
+ Resources.getString("dialog.saveas.confirm.mismatch"),
"Force save?",
JOptionPane.YES_NO_OPTION);
if (result != JOptionPane.OK_OPTION) {
@@ -1882,17 +1898,20 @@
MapHelper.saveMap(currentMap, saver.getPlugin(), filename);
}
+ // If we make it to the bottom, the user and Tiled have agreed on something,
+ // and the file was saved successfully. Update UI.
currentMap.setFilename(filename);
updateRecent(filename);
undoStack.commitSave();
updateTitle();
- saveOk = true;
+ break;
}
} catch (Exception e) {
- e.printStackTrace();
+ //e.printStackTrace();
JOptionPane.showMessageDialog(appFrame,
- "Error while attempting to save " + filename + ": " + e.toString(),
- "Error while saving map",
+ Resources.getString("dialog.saveas.error.message") +
+ " " + filename + ": " + e.getLocalizedMessage(),
+ Resources.getString("dialog.saveas.error.title"),
JOptionPane.ERROR_MESSAGE);
}
}
Modified: trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java 2006-04-01 17:41:46 UTC (rev 596)
+++ trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java 2006-04-04 05:01:28 UTC (rev 597)
@@ -57,7 +57,6 @@
if (d.getImageId() >= 0) {
currentTile = new Tile(tileset);
currentTile.setImage(d.getImageId());
- currentTile.setImageOrientation(d.getImageOrientation());
}
return;
}
Modified: trunk/src/tiled/mapeditor/resources/gui.properties
===================================================================
--- trunk/src/tiled/mapeditor/resources/gui.properties 2006-04-01 17:41:46 UTC (rev 596)
+++ trunk/src/tiled/mapeditor/resources/gui.properties 2006-04-04 05:01:28 UTC (rev 597)
@@ -23,8 +23,15 @@
dialog.resizemap.width.label=Width:
dialog.resizemap.x.label=X:
dialog.resizemap.y.label=Y:
+dialog.openmap.error.title=Error while opening map file
+dialog.saveas.confirm.mismatch=The file extension does not match the plugin. Do you wish to continue?
+dialog.saveas.error.message=Error while attempting to save
+dialog.saveas.unknown-type.message=Save failed, unknown type
+dialog.saveas.error.title=Error while saving map
general.button.browse=Browse...
general.button.cancel=Cancel
general.button.ok=OK
+general.file.exists.title=Overwrite file?
general.file.exists.message=The file already exists. Do you wish to overwrite it?
+general.file.notexists.message=File does not exist
general.file.untitled=Untitled
Modified: trunk/src/tiled/mapeditor/util/TiledFileFilter.java
===================================================================
--- trunk/src/tiled/mapeditor/util/TiledFileFilter.java 2006-04-01 17:41:46 UTC (rev 596)
+++ trunk/src/tiled/mapeditor/util/TiledFileFilter.java 2006-04-04 05:01:28 UTC (rev 597)
@@ -18,6 +18,7 @@
import javax.swing.filechooser.FileFilter;
import tiled.io.PluggableMapIO;
+import tiled.io.xml.XMLMapWriter;
/**
* @version $Id$
@@ -41,6 +42,7 @@
exts.add("tmx");
exts.add("tmx.gz");
exts.add("tsx");
+ pmio = new XMLMapWriter();
}
public TiledFileFilter(int filter) {
@@ -52,11 +54,13 @@
desc = "Tiled Maps files ";
exts.add("tmx");
exts.add("tmx.gz");
+ pmio = new XMLMapWriter();
}
if ((filter & FILTER_TSX) != 0) {
desc += "Tiled Tileset files";
exts.add("tsx");
+ if(pmio == null) pmio = new XMLMapWriter();
}
if(filter == FILTER_EXT) {
Modified: trunk/src/tiled/mapeditor/util/cutter/BasicTileCutter.java
===================================================================
--- trunk/src/tiled/mapeditor/util/cutter/BasicTileCutter.java 2006-04-01 17:41:46 UTC (rev 596)
+++ trunk/src/tiled/mapeditor/util/cutter/BasicTileCutter.java 2006-04-04 05:01:28 UTC (rev 597)
@@ -37,6 +37,10 @@
nextY = offset + frame;
}
+ public String getName() {
+ return "Basic";
+ }
+
public void setImage(Image image) {
int iw = image.getWidth(null);
int ih = image.getHeight(null);
Modified: trunk/src/tiled/mapeditor/util/cutter/BorderTileCutter.java
===================================================================
--- trunk/src/tiled/mapeditor/util/cutter/BorderTileCutter.java 2006-04-01 17:41:46 UTC (rev 596)
+++ trunk/src/tiled/mapeditor/util/cutter/BorderTileCutter.java 2006-04-04 05:01:28 UTC (rev 597)
@@ -20,6 +20,10 @@
*/
public class BorderTileCutter implements TileCutter
{
+
+ public String getName() {
+ return "Border";
+ }
public void setImage(Image image) {
// TODO Auto-generated method stub
Modified: trunk/src/tiled/mapeditor/util/cutter/TileCutter.java
===================================================================
--- trunk/src/tiled/mapeditor/util/cutter/TileCutter.java 2006-04-01 17:41:46 UTC (rev 596)
+++ trunk/src/tiled/mapeditor/util/cutter/TileCutter.java 2006-04-04 05:01:28 UTC (rev 597)
@@ -23,4 +23,5 @@
public void setImage(Image image);
public Image getNextTile() throws Exception;
public Dimension getDimensions();
+ public String getName();
}
More information about the tiled-commit
mailing list