[tiled] r601 - in trunk: . src/tiled/core src/tiled/io/xml src/tiled/mapeditor/dialogs src/tiled/mapeditor/resources src/tiled/mapeditor/util src/tiled/util
svn@biggeruniverse.com
svn at biggeruniverse.com
Sun Apr 9 06:57:48 PDT 2006
Author: aturk
Date: 2006-04-09 08:57:47 -0500 (Sun, 09 Apr 2006)
New Revision: 601
Modified:
trunk/CHANGES
trunk/SUGGESTIONS
trunk/src/tiled/core/TileSet.java
trunk/src/tiled/io/xml/XMLMapTransformer.java
trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java
trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java
trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java
trunk/src/tiled/mapeditor/dialogs/TileDialog.java
trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java
trunk/src/tiled/mapeditor/resources/gui.properties
trunk/src/tiled/mapeditor/util/PropertiesTableModel.java
trunk/src/tiled/mapeditor/util/TileDialogListRenderer.java
trunk/src/tiled/util/NumberedSet.java
Log:
Commit to merge changes between working copy and trunk
+ Added more internationalization support
+ Updated dialogs for removed features
+ Improved usability.
+ Implemented Task #119 (Default properties for tiles)
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/CHANGES 2006-04-09 13:57:47 UTC (rev 601)
@@ -4,6 +4,7 @@
* 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.
+ Fixed tile palette bug of displaying multiple tilesets over eachother
+* Improved usability
+ Rewrote main mapeditor code
* Rewrote configuration based on the Preferences class, no more tiled.conf
+ Added a navigation minimap
@@ -17,11 +18,11 @@
+ Added "stamp" tool
+ Added ability to select multiple layers from layer table
+ Added the ability to merge tile images when layers are merged
-+ Added "global properties" for tilesets (properties set for all tiles)
+* Added "global properties" for tilesets (properties set for all tiles)
+ Added preview of new tileset when creating a tileset
+ Added tile cutter GUI
-0.5.2 - TBD (+ means planned change)
+0.5.2 - (Rolled into the 0.6.0 release)
* Fixed a bug when exporting a tileset with an external image
* Fixed two cases of hanging when using the fill tool
Modified: trunk/SUGGESTIONS
===================================================================
--- trunk/SUGGESTIONS 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/SUGGESTIONS 2006-04-09 13:57:47 UTC (rev 601)
@@ -158,7 +158,7 @@
- 28 --------------------------------------------------------------------------
Suggestor: bjorn
Date: 18/02/06
-Summary: Removing of stupid features.
+Summary: Removing of stupid features. (like this suggestion)
State: Discussed and partly in progress.
Problems: * Get rid of #getNullTile in favour of actually using null. - DONE
* Dump the whole tile image checksumming stuff in favour of
@@ -170,4 +170,4 @@
* Rename HexMapView to HexagonalMapView, IsoMapView to
IsometricMapView and OrthoMapView to OrthographicMapView.
* Remove the zoom argument from all the MapView drawing methods
- and get rid of the SmoothZoomer.
\ No newline at end of file
+ and get rid of the SmoothZoomer.
Modified: trunk/src/tiled/core/TileSet.java
===================================================================
--- trunk/src/tiled/core/TileSet.java 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/core/TileSet.java 2006-04-09 13:57:47 UTC (rev 601)
@@ -45,6 +45,7 @@
private String name;
private Color transparentColor;
private Properties defaultTileProperties;
+ private Image tileSetImage;
/**
* Default constructor
@@ -53,6 +54,7 @@
tiles = new NumberedSet();
images = new NumberedSet();
tileDimensions = new Rectangle();
+ defaultTileProperties = new Properties();
}
/**
@@ -100,6 +102,8 @@
tileDimensions = new Rectangle(cutter.getDimensions());
+ tileSetImage = tilebmp;
+
BufferedImage tile;
cutter.setImage(tilebmp);
@@ -145,7 +149,7 @@
* @param i
*/
public void setTilesetImage(Image i) {
- //setImage = i;
+ tileSetImage = i;
}
/**
@@ -224,6 +228,9 @@
tileDimensions.width = t.getWidth();
}
+ //add any default properties
+ t.getProperties().putAll(defaultTileProperties);
+
tiles.put(t.getId(), t);
//System.out.println("adding tile " +t.getId());
t.setTileSet(this);
@@ -516,12 +523,11 @@
}
/**
- * @deprecated
- * @return
+ * @return boolean
*/
- public boolean usesSharedImages() {
+ public boolean isSetFromImage() {
// TODO: Currently only uses shared sets...
- return true;
+ return tileSetImage != null;
}
/**
@@ -561,4 +567,8 @@
return true;
}
+
+ public void setDefaultProperties(Properties defaultSetProperties) {
+ defaultTileProperties = defaultSetProperties;
+ }
}
Modified: trunk/src/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapTransformer.java 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/io/xml/XMLMapTransformer.java 2006-04-09 13:57:47 UTC (rev 601)
@@ -226,7 +226,7 @@
return img;
}
-
+
private TileSet unmarshalTilesetFile(InputStream in, String filename)
throws Exception
{
@@ -354,6 +354,8 @@
}
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();
@@ -377,7 +379,7 @@
set.setTransparentColor(color);
set.setTilesetImageFilename(sourcePath);
} catch (IIOException iioe) {
- warnings.push("ERROR: "+iioe.getMessage()+" ("+sourcePath+")");
+ warnings.push("ERROR: "+iioe.getLocalizedMessage()+" ("+sourcePath+")");
}
} else {
set.importTileBitmap(sourcePath, new BasicTileCutter(
@@ -766,7 +768,7 @@
public String getDescription() {
return "This is the core Tiled TMX format reader\n" +
"\n" +
- "Tiled Map Editor, (c) 2005\n" +
+ "Tiled Map Editor, (c) 2004-2006\n" +
"Adam Turk\n" +
"Bjorn Lindeijer";
}
Modified: trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java 2006-04-09 13:57:47 UTC (rev 601)
@@ -51,7 +51,7 @@
}
private void pickImage() {
- if (tileset.usesSharedImages()) {
+ if (tileset.isSetFromImage()) {
TileImageDialog d = new TileImageDialog(this, tileset);
d.setVisible(true);
if (d.getImageId() >= 0) {
@@ -75,7 +75,7 @@
image = ImageIO.read(files[i]);
// TODO: Support for a transparent color
} catch (Exception e) {
- JOptionPane.showMessageDialog(this, e.getMessage(),
+ JOptionPane.showMessageDialog(this, e.getLocalizedMessage(),
"Error!", JOptionPane.ERROR_MESSAGE);
return;
}
Modified: trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java 2006-04-09 13:57:47 UTC (rev 601)
@@ -18,6 +18,7 @@
import java.awt.image.FilteredImageSource;
import java.io.File;
import java.io.IOException;
+import java.util.Properties;
import javax.imageio.ImageIO;
import javax.swing.*;
@@ -50,11 +51,15 @@
private JLabel tilebmpFileLabel, cutterLabel;
private JCheckBox tilebmpCheck, tileAutoCheck, transCheck;
private JComboBox cutterBox;
+ private JButton previewButton;
private JButton browseButton;
private JButton propsButton;
private ColorButton colorButton;
private String path;
+
+ private Properties defaultSetProperties;
+ /* LANGUAGE PACK */
private static final String DIALOG_TITLE = Resources.getString("dialog.newtileset.title");
private static final String NAME_LABEL = Resources.getString("dialog.newtileset.name.label");
private static final String TILE_WIDTH_LABEL = Resources.getString("dialog.newtileset.tilewidth.label");
@@ -66,17 +71,22 @@
private static final String AUTO_TILES_LABEL = Resources.getString("dialog.newtileset.autotiles.label");
private static final String USE_TRANS_COLOR_LABEL = Resources.getString("dialog.newtileset.usetransparentcolor.label");
private static final String OK_BUTTON = Resources.getString("general.button.ok");
+ private static final String PREVIEW_BUTTON = Resources.getString("general.button.preview");
private static final String CANCEL_BUTTON = Resources.getString("general.button.cancel");
private static final String BROWSE_BUTTON = Resources.getString("general.button.browse");
private static final String FROM_TILESET_IMG_TITLE = Resources.getString("dialog.newtileset.fromtilesetimg.title");
private static final String IMPORT_ERROR_MSG = Resources.getString("dialog.newtileset.import.error.message");
private static final String IMG_LOAD_ERROR = Resources.getString("dialog.newtileset.imgload.error.message");
private static final String COLOR_CHOOSE_ERROR_TITLE = Resources.getString("dialog.newtileset.colorchoose.error.title");
-
+ private static final String PROPERTIES_TITLE = Resources.getString("dialog.properties.default.title");
+ private static final String PROPERTIES_BUTTON = Resources.getString("dialog.newtileset.button.properties");
+ /* -- */
+
public NewTilesetDialog(JFrame parent, Map map) {
super(parent, DIALOG_TITLE, true);
this.map = map;
path = map.getFilename();
+ defaultSetProperties = new Properties();
init();
pack();
setLocationRelativeTo(parent);
@@ -123,9 +133,10 @@
transCheck.addChangeListener(this);
JButton okButton = new JButton(OK_BUTTON);
+ previewButton = new JButton(PREVIEW_BUTTON);
JButton cancelButton = new JButton(CANCEL_BUTTON);
browseButton = new JButton(BROWSE_BUTTON);
- propsButton = new JButton("Set Default Properties...");
+ propsButton = new JButton(PROPERTIES_BUTTON);
colorButton = new ColorButton(new Color(255, 0, 255));
// Combine browse button and tile bitmap path text field
@@ -205,6 +216,8 @@
buttons.add(Box.createGlue());
buttons.add(okButton);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
+ buttons.add(previewButton);
+ buttons.add(Box.createRigidArea(new Dimension(5, 0)));
buttons.add(cancelButton);
// Top part of form
@@ -259,6 +272,12 @@
}
});
+ previewButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent actionEvent) {
+ System.out.println("TilesetPreviewDialog");
+ }
+ });
+
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
dispose();
@@ -282,6 +301,15 @@
chooseColorFromImage();
}
});
+
+ propsButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent actionEvent) {
+ PropertiesDialog lpd =
+ new PropertiesDialog(null, defaultSetProperties);
+ lpd.setTitle(PROPERTIES_TITLE);
+ lpd.getProps();
+ }
+ });
}
public TileSet create() {
@@ -301,52 +329,65 @@
}
private void createSetAndDispose() {
- newTileset = new TileSet();
+ newTileset = new TileSet();
newTileset.setName(tilesetName.getText());
-
- if (tilebmpCheck.isSelected()) {
- String file = tilebmpFile.getText();
- int spacing = tileSpacing.intValue();
- int width = tileWidth.intValue();
- int height = tileHeight.intValue();
- try {
- if (!transCheck.isSelected()) {
- newTileset.importTileBitmap(file,
- getCutter(width, height, spacing),
- tileAutoCheck.isSelected());
- } else {
- try {
- Toolkit tk = Toolkit.getDefaultToolkit();
- Image orig = ImageIO.read(new File(file));
- Image trans = tk.createImage(
- new FilteredImageSource(orig.getSource(),
- new TransparentImageFilter(
- colorButton.getColor().getRGB())));
- BufferedImage img = new BufferedImage(
- trans.getWidth(null),
- trans.getHeight(null),
- BufferedImage.TYPE_INT_ARGB);
-
- img.getGraphics().drawImage(trans, 0, 0, null);
-
- newTileset.importTileBitmap(img,
- getCutter(width, height, spacing),
- tileAutoCheck.isSelected());
-
- newTileset.setTransparentColor(
- colorButton.getColor());
-
- newTileset.setTilesetImageFilename(file);
- } catch (IOException e) {
- }
- }
- } catch (Exception e) {
- JOptionPane.showMessageDialog(this, e.getMessage(),
- IMPORT_ERROR_MSG, JOptionPane.ERROR_MESSAGE);
- newTileset = null;
- }
- }
-
+ newTileset.setDefaultProperties(defaultSetProperties);
+
+ // In the off chance that something goes wrong,
+ // keep working.
+ while(true) {
+
+ if (tilebmpCheck.isSelected()) {
+ String file = tilebmpFile.getText();
+ int spacing = tileSpacing.intValue();
+ int width = tileWidth.intValue();
+ int height = tileHeight.intValue();
+ try {
+ if (!transCheck.isSelected()) {
+ newTileset.importTileBitmap(file,
+ getCutter(width, height, spacing),
+ tileAutoCheck.isSelected());
+ } else {
+ try {
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ Image orig = ImageIO.read(new File(file));
+ Image trans = tk.createImage(
+ new FilteredImageSource(orig.getSource(),
+ new TransparentImageFilter(
+ colorButton.getColor().getRGB())));
+ BufferedImage img = new BufferedImage(
+ trans.getWidth(null),
+ trans.getHeight(null),
+ BufferedImage.TYPE_INT_ARGB);
+
+ img.getGraphics().drawImage(trans, 0, 0, null);
+
+ newTileset.importTileBitmap(img,
+ getCutter(width, height, spacing),
+ tileAutoCheck.isSelected());
+
+ newTileset.setTransparentColor(
+ colorButton.getColor());
+
+ newTileset.setTilesetImageFilename(file);
+ } catch (IOException e) {
+ JOptionPane.showMessageDialog(this, e.getLocalizedMessage(),
+ IMPORT_ERROR_MSG, JOptionPane.WARNING_MESSAGE);
+ continue;
+ }
+ }
+
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(this, e.getLocalizedMessage(),
+ IMPORT_ERROR_MSG, JOptionPane.ERROR_MESSAGE);
+ newTileset = null;
+ return;
+ }
+ }
+
+ break;
+ }
+
dispose();
}
@@ -361,7 +402,7 @@
}
} catch (IOException e) {
JOptionPane.showMessageDialog(getOwner(),
- IMG_LOAD_ERROR + e.getMessage(),
+ IMG_LOAD_ERROR + " " + e.getLocalizedMessage(),
COLOR_CHOOSE_ERROR_TITLE, JOptionPane.ERROR_MESSAGE);
}
}
@@ -389,5 +430,6 @@
colorButton.setEnabled(value && transCheck.isSelected());
cutterBox.setEnabled(value && tileAutoCheck.isSelected());
cutterLabel.setEnabled(value && tileAutoCheck.isSelected());
+ previewButton.setEnabled(value);
}
}
Modified: trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/mapeditor/dialogs/PropertiesDialog.java 2006-04-09 13:57:47 UTC (rev 601)
@@ -25,17 +25,19 @@
import tiled.mapeditor.util.PropertiesTableModel;
import tiled.mapeditor.widget.VerticalStaticJPanel;
-public class PropertiesDialog extends JDialog implements ActionListener,
- ListSelectionListener
+public class PropertiesDialog extends JDialog implements ListSelectionListener
{
private JTable tProperties;
- private JButton bOk, bCancel, bDel;
+ private JButton okButton, cancelButton, deleteButton;
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");
private static final String CANCEL_BUTTON = Resources.getString("general.button.cancel");
+
public PropertiesDialog(JFrame parent, Properties p) {
super(parent, DIALOG_TITLE, true);
@@ -51,28 +53,25 @@
JScrollPane propScrollPane = new JScrollPane(tProperties);
propScrollPane.setPreferredSize(new Dimension(200, 150));
- bOk = new JButton(OK_BUTTON);
- bCancel = new JButton(CANCEL_BUTTON);
- bDel = new JButton(Resources.getIcon("gnome-delete.png"));
-
- bOk.addActionListener(this);
- bCancel.addActionListener(this);
- bDel.addActionListener(this);
-
+ okButton = new JButton(OK_BUTTON);
+ cancelButton = new JButton(CANCEL_BUTTON);
+ deleteButton = new JButton(Resources.getIcon("gnome-delete.png"));
+ deleteButton.setToolTipText(DELETE_BUTTON);
+
JPanel user = new VerticalStaticJPanel();
user.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
user.setLayout(new BoxLayout(user, BoxLayout.X_AXIS));
user.add(Box.createGlue());
user.add(Box.createRigidArea(new Dimension(5, 0)));
- user.add(bDel);
+ user.add(deleteButton);
JPanel buttons = new VerticalStaticJPanel();
buttons.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
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(bCancel);
+ buttons.add(cancelButton);
JPanel mainPanel = new JPanel();
mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
@@ -82,7 +81,26 @@
mainPanel.add(buttons);
getContentPane().add(mainPanel);
- getRootPane().setDefaultButton(bOk);
+ getRootPane().setDefaultButton(okButton);
+
+ //create actionlisteners
+ okButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent actionEvent) {
+ buildPropertiesAndDispose();
+ }
+ });
+
+ cancelButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent actionEvent) {
+ dispose();
+ }
+ });
+
+ deleteButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent actionEvent) {
+ deleteSelected();
+ }
+ });
}
private void updateInfo() {
@@ -102,41 +120,37 @@
setVisible(true);
}
- public void actionPerformed(ActionEvent event) {
- Object source = event.getSource();
+ private void buildPropertiesAndDispose() {
+ // Copy over the new set of properties from the properties table
+ // model.
+ properties.clear();
- if (source == bOk) {
- // Copy over the new set of properties from the properties table
- // model.
- properties.clear();
+ Properties newProps = tableModel.getProperties();
+ Enumeration keys = newProps.keys();
+ while (keys.hasMoreElements()) {
+ String key = (String)keys.nextElement();
+ properties.put(key, newProps.getProperty(key));
+ }
- Properties newProps = tableModel.getProperties();
- Enumeration keys = newProps.keys();
- while (keys.hasMoreElements()) {
- String key = (String)keys.nextElement();
- properties.put(key, newProps.getProperty(key));
+ dispose();
+ }
+
+ private void deleteSelected() {
+ int total = tProperties.getSelectedRowCount();
+ Object[] keys = new Object[total];
+ int[] selRows = tProperties.getSelectedRows();
+
+ for(int i = 0; i < total; i++) {
+ keys[i] = tProperties.getValueAt(selRows[i], 0);
+ }
+
+ for (int i = 0; i < total; i++) {
+ if (keys[i] != null) {
+ tableModel.remove(keys[i]);
}
-
- dispose();
- } else if (source == bCancel) {
- dispose();
- } else if (source == bDel) {
- int total = tProperties.getSelectedRowCount();
- Object[] keys = new Object[total];
- int[] selRows = tProperties.getSelectedRows();
-
- for(int i = 0; i < total; i++) {
- keys[i] = tProperties.getValueAt(selRows[i], 0);
- }
-
- for (int i = 0; i < total; i++) {
- if (keys[i] != null) {
- tableModel.remove(keys[i]);
- }
- }
}
}
-
+
public void valueChanged(ListSelectionEvent e) {
}
}
Modified: trunk/src/tiled/mapeditor/dialogs/TileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileDialog.java 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/mapeditor/dialogs/TileDialog.java 2006-04-09 13:57:47 UTC (rev 601)
@@ -27,6 +27,7 @@
import javax.swing.event.ListSelectionListener;
import tiled.core.*;
+import tiled.mapeditor.Resources;
import tiled.mapeditor.animation.AnimationDialog;
import tiled.mapeditor.util.*;
import tiled.mapeditor.widget.*;
@@ -42,18 +43,33 @@
private Map map;
private JList tileList, imageList;
private JTable tileProperties;
- private JButton bOk, bNew, bDelete, bChangeI, bDuplicate;
- private JButton bAddImage, bDeleteImage, bDeleteAllUnusedImages;
- private JButton bAnimation;
+ private JButton okButton, newTileButton, deleteTileButton, changeImageButton, duplicateTileButton;
+ private JButton createTileButton;
+ private JButton animationButton;
private String location;
private JTextField tilesetNameEntry;
private JCheckBox externalBitmapCheck;
- //private JCheckBox sharedImagesCheck;
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");
+ private static final String CI_BUTTON = Resources.getString("dialog.tile.button.changeimage");
+ private static final String NEW_BUTTON = Resources.getString("dialog.tile.button.newtile");
+ private static final String CREATE_BUTTON = Resources.getString("dialog.tile.button.createtile");
+ private static final String DUPLICATE_BUTTON = Resources.getString("dialog.tile.button.duptile");
+ private static final String ANIMATION_BUTTON = Resources.getString("dialog.tile.button.animation");
+ private static final String PREVIEW_TAB = Resources.getString("general.button.preview");
+ private static final String TILES_TAB = Resources.getString("general.tile.tiles");
+ private static final String TILESET_TAB = Resources.getString("general.tile.tileset");
+ private static final String NAME_LABEL = Resources.getString("dialog.newtileset.name.label");
+
+ /* -- */
+
public TileDialog(Dialog parent, TileSet s, Map m) {
- super(parent, "Edit Tileset '" + s.getName() + "'", true);
+ super(parent, DIALOG_TITLE + " '" + s.getName() + "'", true);
location = "";
tileset = s; //unofficial
map = m; //also unofficial
@@ -67,17 +83,17 @@
private JPanel createTilePanel() {
// Create the buttons
- bDelete = new JButton("Delete Tile");
- bChangeI = new JButton("Change Image");
- bDuplicate = new JButton("Duplicate Tile");
- bNew = new JButton("Add Tile");
- bAnimation = new JButton("Animation");
+ deleteTileButton = new JButton(DELETE_BUTTON);
+ changeImageButton = new JButton(CI_BUTTON);
+ duplicateTileButton = new JButton(DUPLICATE_BUTTON);
+ newTileButton = new JButton(NEW_BUTTON);
+ animationButton = new JButton(ANIMATION_BUTTON);
- bDelete.addActionListener(this);
- bChangeI.addActionListener(this);
- bDuplicate.addActionListener(this);
- bNew.addActionListener(this);
- bAnimation.addActionListener(this);
+ deleteTileButton.addActionListener(this);
+ changeImageButton.addActionListener(this);
+ duplicateTileButton.addActionListener(this);
+ newTileButton.addActionListener(this);
+ animationButton.addActionListener(this);
tileList = new JList();
tileList.setCellRenderer(new TileDialogListRenderer());
@@ -113,15 +129,15 @@
JPanel buttons = new VerticalStaticJPanel();
buttons.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
- buttons.add(bNew);
+ buttons.add(newTileButton);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
- buttons.add(bDelete);
+ buttons.add(deleteTileButton);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
- buttons.add(bChangeI);
+ buttons.add(changeImageButton);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
- buttons.add(bDuplicate);
+ buttons.add(duplicateTileButton);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
- buttons.add(bAnimation);
+ buttons.add(animationButton);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
buttons.add(Box.createGlue());
@@ -137,13 +153,13 @@
mainPanel.add(splitPane, c);
c.weightx = 0; c.weighty = 0; c.gridy = 1;
mainPanel.add(buttons, c);
-
+
return mainPanel;
}
private JPanel createTilesetPanel()
{
- JLabel name_label = new JLabel("Name: ");
+ JLabel name_label = new JLabel(NAME_LABEL+" ");
tilesetNameEntry = new JTextField(32);
//sharedImagesCheck = new JCheckBox("Use shared images");
externalBitmapCheck = new JCheckBox("Use external bitmap");
@@ -176,20 +192,12 @@
sp.setPreferredSize(new Dimension(150, 150));
// Buttons
- bAddImage = new JButton("Add Image");
- bAddImage.addActionListener(this);
- bDeleteImage = new JButton("Delete Image");
- bDeleteImage.addActionListener(this);
- bDeleteAllUnusedImages = new JButton("Delete Unused Images");
- bDeleteAllUnusedImages.addActionListener(this);
+ createTileButton = new JButton(CREATE_BUTTON);
+ createTileButton.addActionListener(this);
JPanel buttons = new VerticalStaticJPanel();
buttons.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
- buttons.add(bAddImage);
- buttons.add(Box.createRigidArea(new Dimension(5, 0)));
- buttons.add(bDeleteImage);
- buttons.add(Box.createRigidArea(new Dimension(5, 0)));
- buttons.add(bDeleteAllUnusedImages);
+ buttons.add(createTileButton);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new GridBagLayout());
@@ -205,17 +213,16 @@
private void init() {
tabs = new JTabbedPane(JTabbedPane.TOP);
- tabs.addTab("Tileset", createTilesetPanel());
- tabs.addTab("Tiles", createTilePanel());
- tabs.addTab("Images", createImagePanel());
+ tabs.addTab(TILESET_TAB, createTilesetPanel());
+ tabs.addTab(TILES_TAB, createTilePanel());
+ tabs.addTab(PREVIEW_TAB, createImagePanel());
- bOk = new JButton("OK");
- bOk.addActionListener(this);
+ okButton = new JButton(OK_BUTTON);
JPanel buttons = new VerticalStaticJPanel();
buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
buttons.add(Box.createGlue());
- buttons.add(bOk);
+ buttons.add(okButton);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
@@ -225,20 +232,28 @@
mainPanel.add(buttons);
getContentPane().add(mainPanel);
- getRootPane().setDefaultButton(bOk);
+ getRootPane().setDefaultButton(okButton);
+
+ //create actionlisteners
+ okButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent actionEvent) {
+ tileset.setName(tilesetNameEntry.getText());
+ dispose();
+ }
+ });
}
private void changeImage() {
if (currentTile == null) {
return;
}
- if (tileset.usesSharedImages()) {
+
+ if (tileset.isSetFromImage()) {
TileImageDialog d = new TileImageDialog(this, tileset,
currentTile.getImageId());
d.setVisible(true);
if (d.getImageId() >= 0) {
currentTile.setImage(d.getImageId());
- currentTile.setImageOrientation(d.getImageOrientation());
}
} else {
Image img = loadImage();
@@ -266,7 +281,7 @@
}
} catch (Exception e) {
e.printStackTrace();
- JOptionPane.showMessageDialog(this, e.getMessage(),
+ JOptionPane.showMessageDialog(this, e.getLocalizedMessage(),
"Error loading image", JOptionPane.ERROR_MESSAGE);
}
}
@@ -362,37 +377,22 @@
// boolean internal = (tileset.getSource() == null);
boolean tilebmp = tileset.getTilebmpFile() != null;
boolean tileSelected = currentTile != null;
- boolean sharedImages = tileset.usesSharedImages();
- boolean atLeastOneSharedImage = sharedImages
+ boolean setImages = tileset.isSetFromImage();
+ boolean atLeastOneSharedImage = setImages
&& tileset.getTotalImages() >= 1;
- bNew.setEnabled(atLeastOneSharedImage || !tilebmp);
- bDelete.setEnabled((sharedImages || !tilebmp) && tileSelected);
- bChangeI.setEnabled((atLeastOneSharedImage || !tilebmp)
+ newTileButton.setEnabled(atLeastOneSharedImage || !tilebmp);
+ deleteTileButton.setEnabled((setImages || !tilebmp) && tileSelected);
+ changeImageButton.setEnabled((atLeastOneSharedImage || !tilebmp)
&& tileSelected);
- bDuplicate.setEnabled((sharedImages || !tilebmp) && tileSelected);
- bAnimation.setEnabled((sharedImages || !tilebmp) && tileSelected &&
+ duplicateTileButton.setEnabled((setImages || !tilebmp) && tileSelected);
+ animationButton.setEnabled((setImages || !tilebmp) && tileSelected &&
currentTile instanceof AnimatedTile);
- tileProperties.setEnabled((sharedImages || !tilebmp) && tileSelected);
+ tileProperties.setEnabled((setImages || !tilebmp) && tileSelected);
externalBitmapCheck.setEnabled(tilebmp); // Can't turn this off yet
- //sharedImagesCheck.setEnabled(!tilebmp || !sharedImages
- // || tileset.safeToDisableSharedImages());
- tabs.setEnabledAt(2, sharedImages);
- if (sharedImages) {
- bAddImage.setEnabled(!tilebmp);
- bDeleteAllUnusedImages.setEnabled(!tilebmp);
- boolean image_used = false;
- Iterator tileIterator = tileset.iterator();
-
- while (tileIterator.hasNext()) {
- Tile tile = (Tile)tileIterator.next();
- if (tile.getImageId() == currentImageIndex) {
- image_used = true;
- }
- }
- bDeleteImage.setEnabled(!tilebmp && currentImageIndex >= 0
- && !image_used);
- }
+ //setImagesCheck.setEnabled(!tilebmp || !setImages
+ // || tileset.safeToDisablesetImages());
+ tabs.setEnabledAt(2, setImages);
}
/**
@@ -420,10 +420,10 @@
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
- if (source == bOk) {
+ if (source == okButton) {
tileset.setName(tilesetNameEntry.getText());
dispose();
- } else if (source == bDelete) {
+ } else if (source == deleteTileButton) {
int answer = JOptionPane.showConfirmDialog(
this, "Delete tile?", "Are you sure?",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
@@ -434,11 +434,11 @@
}
queryTiles();
}
- } else if (source == bChangeI) {
+ } else if (source == changeImageButton) {
changeImage();
- } else if (source == bNew) {
+ } else if (source == newTileButton) {
newTile();
- } else if (source == bDuplicate) {
+ } else if (source == duplicateTileButton) {
Tile n = new Tile(currentTile);
tileset.addNewTile(n);
queryTiles();
@@ -461,18 +461,18 @@
externalBitmapCheck.setSelected(true);
}
}
- } else if (source == bAnimation) {
+ } else if (source == animationButton) {
AnimationDialog ad = new AnimationDialog(this, ((AnimatedTile)currentTile).getSprite());
ad.setVisible(true);
}
/*
- else if (source == sharedImagesCheck) {
- if (sharedImagesCheck.isSelected()) {
- tileset.enableSharedImages();
+ else if (source == setImagesCheck) {
+ if (setImagesCheck.isSelected()) {
+ tileset.enablesetImages();
updateEnabledState();
} else {
int answer = JOptionPane.YES_OPTION;
- if (!tileset.safeToDisableSharedImages()) {
+ if (!tileset.safeToDisablesetImages()) {
answer = JOptionPane.showConfirmDialog(
this, "This tileset uses features that require the "
+ "use of shared images. Disable the use of shared "
@@ -482,59 +482,28 @@
JOptionPane.QUESTION_MESSAGE);
}
if (answer == JOptionPane.YES_OPTION) {
- tileset.disableSharedImages();
+ tileset.disablesetImages();
updateEnabledState();
} else {
- sharedImagesCheck.setSelected(true);
+ setImagesCheck.setSelected(true);
}
}
}
*/
- else if (source == bAddImage) {
- Image img = loadImage();
- if (img != null) {
- tileset.addImage(img);
- }
- queryImages();
- } else if (source == bDeleteImage) {
- int answer = JOptionPane.showConfirmDialog(
- this, "Delete this image?",
- "Are you sure?",
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
- if (answer == JOptionPane.YES_OPTION) {
- Image img = (Image)imageList.getSelectedValue();
- tileset.removeImage(tileset.getIdByImage(img));
- queryImages();
- }
- } else if (source == bDeleteAllUnusedImages) {
- int answer = JOptionPane.showConfirmDialog(
- this, "Delete all unused images?",
- "Are you sure?",
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
- if (answer == JOptionPane.YES_OPTION) {
-
- Enumeration ids = tileset.getImageIds();
- while (ids.hasMoreElements()) {
- int id = Integer.parseInt((String)ids.nextElement());
- boolean image_used = false;
- Iterator tileIterator = tileset.iterator();
-
- while (tileIterator.hasNext()) {
- Tile tile = (Tile)tileIterator.next();
- if (tile.getImageId() == id) {
- image_used = true;
- }
- }
-
- if (!image_used) {
- tileset.removeImage(id);
- }
- }
-
- queryImages();
- }
+ else if (source == createTileButton) {
+ Image img = (Image)imageList.getSelectedValue();
+ Tile n = new Tile(tileset);
+
+ n.setImage(tileset.getIdByImage(img));
+ tileset.addNewTile(n);
+ queryTiles();
+ // Select the last (cloned) tile
+ tileList.setSelectedIndex(tileset.size() - 1);
+ tileList.ensureIndexIsVisible(tileset.size() - 1);
+ JOptionPane.showMessageDialog(this,
+ "Tile created with id "+n.getId(),
+ "Created Tile",
+ JOptionPane.INFORMATION_MESSAGE);
}
repaint();
Modified: trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java 2006-04-09 13:57:47 UTC (rev 601)
@@ -23,29 +23,34 @@
import javax.swing.event.ListSelectionListener;
import tiled.core.TileSet;
+import tiled.mapeditor.Resources;
import tiled.mapeditor.util.ImageCellRenderer;
import tiled.mapeditor.widget.VerticalStaticJPanel;
/**
* @version $Id$
*/
-public class TileImageDialog extends JDialog
- implements ActionListener, ListSelectionListener
+public class TileImageDialog extends JDialog implements ListSelectionListener
{
private JList imageList;
- private JButton bOk, bCancel;
- private JCheckBox horizFlipCheck, vertFlipCheck, rotateCheck;
- private int imageId, imageOrientation;
+ private JButton okButton, cancelButton;
+ private int imageId;
private final TileSet tileset;
private JLabel imageLabel;
private int[] imageIds;
+ /* LANGUAGE PACK */
+ private static final String DIALOG_TITLE = Resources.getString("dialog.tileimage.title");
+ private static final String OK_BUTTON = Resources.getString("general.button.ok");
+ private static final String CANCEL_BUTTON = Resources.getString("general.button.cancel");
+ /* -- */
+
public TileImageDialog(Dialog parent, TileSet set) {
this(parent, set, 0);
}
public TileImageDialog(Dialog parent, TileSet set, int id) {
- super(parent, "Choose Tile Image", true);
+ super(parent, DIALOG_TITLE, true);
tileset = set;
imageId = id;
@@ -70,31 +75,17 @@
JPanel image_panel = new JPanel();
image_panel.setLayout(new BoxLayout(image_panel, BoxLayout.Y_AXIS));
imageLabel = new JLabel(new ImageIcon());
- horizFlipCheck = new JCheckBox("Flip horizontally",
- (imageOrientation & 1) == 1);
- horizFlipCheck.addActionListener(this);
- vertFlipCheck = new JCheckBox("Flip vertically",
- (imageOrientation & 2) == 2);
- vertFlipCheck.addActionListener(this);
- rotateCheck = new JCheckBox("Rotate",
- (imageOrientation & 4) == 4);
- rotateCheck.addActionListener(this);
image_panel.add(imageLabel);
- image_panel.add(horizFlipCheck);
- image_panel.add(vertFlipCheck);
- image_panel.add(rotateCheck);
// buttons
- bOk = new JButton("OK");
- bOk.addActionListener(this);
- bCancel = new JButton("Cancel");
- bCancel.addActionListener(this);
+ okButton = new JButton(OK_BUTTON);
+ cancelButton = new JButton(CANCEL_BUTTON);
JPanel buttons = new VerticalStaticJPanel();
buttons.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
- buttons.add(bCancel);
- buttons.add(bOk);
+ buttons.add(cancelButton);
+ buttons.add(okButton);
// main panel
JPanel mainPanel = new JPanel();
@@ -108,7 +99,21 @@
c.gridx = 0; c.weighty = 0; c.gridy = 1; c.gridwidth = 2;
mainPanel.add(buttons, c);
getContentPane().add(mainPanel);
- getRootPane().setDefaultButton(bOk);
+ getRootPane().setDefaultButton(okButton);
+
+ //create action listeners
+ okButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent actionEvent) {
+ dispose();
+ }
+ });
+
+ cancelButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent actionEvent) {
+ imageId = -1;
+ dispose();
+ }
+ });
}
public void queryImages() {
@@ -136,31 +141,9 @@
}
private void updateEnabledState() {
- bOk.setEnabled(imageId >= 0);
+ okButton.setEnabled(imageId >= 0);
}
- public void actionPerformed(ActionEvent event) {
- Object source = event.getSource();
-
- if (source == bOk) {
- dispose();
- } else if (source == bCancel) {
- imageId = -1;
- dispose();
- } else if (source == horizFlipCheck) {
- imageOrientation ^= 1;
- updateImageLabel();
- } else if (source == vertFlipCheck) {
- imageOrientation ^= 2;
- updateImageLabel();
- } else if (source == rotateCheck) {
- imageOrientation ^= 4;
- updateImageLabel();
- }
-
- repaint();
- }
-
private void updateImageLabel() {
if (imageId >= 0) {
Image img = tileset.getImageById(imageId);
@@ -177,8 +160,4 @@
public int getImageId() {
return imageId;
}
-
- int getImageOrientation() {
- return imageOrientation;
- }
}
Modified: trunk/src/tiled/mapeditor/resources/gui.properties
===================================================================
--- trunk/src/tiled/mapeditor/resources/gui.properties 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/mapeditor/resources/gui.properties 2006-04-09 13:57:47 UTC (rev 601)
@@ -29,11 +29,21 @@
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.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.plugins.info.button=Info
dialog.plugins.remove.button=Remove
dialog.plugins.title=Available Plugins
dialog.preferences.title=Preferences
-dialog.properties.title=Properties
dialog.resizemap.currentsize.title=Current size
dialog.resizemap.height.label=Height:
dialog.resizemap.newsize.title=New size
@@ -47,15 +57,28 @@
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
+dialog.properties.title=Properties
+dialog.properties.map.title=Map Properties
+dialog.properties.default.title=Default Properties
+dialog.properties.tileset.title=Tileset Properties
+dialog.properties.layer.title=Layer Properties
+dialog.properties.column.name=Name
+dialog.properties.column.value=Value
dialog.tilepalette.title=Palette
general.button.browse=Browse...
general.button.cancel=Cancel
general.button.close=Close
general.button.ok=OK
+general.button.preview=Preview...
+general.button.delete=Delete
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
+general.tile.tile=Tile
+general.tile.tiles=Tiles
+general.tile.tileset=Tileset
+general.tile.notile=(No Tile)
general.maptype.hexagonal=Hexagonal (experimental)
general.maptype.isometric=Isometric
general.maptype.oblique=Oblique
Modified: trunk/src/tiled/mapeditor/util/PropertiesTableModel.java
===================================================================
--- trunk/src/tiled/mapeditor/util/PropertiesTableModel.java 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/mapeditor/util/PropertiesTableModel.java 2006-04-09 13:57:47 UTC (rev 601)
@@ -15,15 +15,18 @@
import java.util.Properties;
import javax.swing.table.AbstractTableModel;
+import tiled.mapeditor.Resources;
+
/**
* @version $Id$
*/
public class PropertiesTableModel extends AbstractTableModel
{
private Properties properties;
+
+ private static final String[] columnNames = { Resources.getString("dialog.properties.column.name"),
+ Resources.getString("dialog.properties.column.value") };
- private static final String[] columnNames = { "Name", "Value" };
-
public PropertiesTableModel() {
properties = new Properties();
}
Modified: trunk/src/tiled/mapeditor/util/TileDialogListRenderer.java
===================================================================
--- trunk/src/tiled/mapeditor/util/TileDialogListRenderer.java 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/mapeditor/util/TileDialogListRenderer.java 2006-04-09 13:57:47 UTC (rev 601)
@@ -19,12 +19,16 @@
import javax.swing.DefaultListCellRenderer;
import tiled.core.*;
+import tiled.mapeditor.Resources;
public class TileDialogListRenderer extends DefaultListCellRenderer
{
+ private static final String TILE = Resources.getString("general.tile.tile");
+ private static final String NOTILE = Resources.getString("general.tile.notile");
+
private double zoom = 1;
-
+
public TileDialogListRenderer() {
setOpaque(true);
}
@@ -46,10 +50,10 @@
if (scaledImage != null) {
setIcon(new ImageIcon(scaledImage));
}
- setText("Tile " + tile.getId());
+ setText(TILE + " " + tile.getId());
} else {
setIcon(null);
- setText("No tile?");
+ setText(NOTILE);
}
return this;
Modified: trunk/src/tiled/util/NumberedSet.java
===================================================================
--- trunk/src/tiled/util/NumberedSet.java 2006-04-09 11:49:52 UTC (rev 600)
+++ trunk/src/tiled/util/NumberedSet.java 2006-04-09 13:57:47 UTC (rev 601)
@@ -71,6 +71,10 @@
*/
public int put(int id, Object o) throws IllegalArgumentException {
if (id < 0) throw new IllegalArgumentException();
+
+ //make sure there is sufficient space to overlay
+ for(int i=id-data.size();i>0;i--) data.add(null);
+
data.add(id, o);
return id;
}
More information about the tiled-commit
mailing list