[tiled] r668 - in trunk: examples src/tiled/core src/tiled/mapeditor/actions src/tiled/mapeditor/animation src/tiled/mapeditor/dialogs
svn@biggeruniverse.com
svn at biggeruniverse.com
Wed Jun 21 09:17:28 PDT 2006
Author: bjorn
Date: 2006-06-21 11:17:27 -0500 (Wed, 21 Jun 2006)
New Revision: 668
Removed:
trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java
Modified:
trunk/examples/desert.tmx
trunk/src/tiled/core/MapObject.java
trunk/src/tiled/core/TileSet.java
trunk/src/tiled/mapeditor/actions/CloneLayerAction.java
trunk/src/tiled/mapeditor/animation/AnimationDialog.java
trunk/src/tiled/mapeditor/dialogs/TileDialog.java
trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java
Log:
Removed the Animation button from the TileDialog and made the New Tile button somewhat functional.
Modified: trunk/examples/desert.tmx
===================================================================
--- trunk/examples/desert.tmx 2006-06-13 13:21:57 UTC (rev 667)
+++ trunk/examples/desert.tmx 2006-06-21 16:17:27 UTC (rev 668)
@@ -1,6 +1,6 @@
-<?xml version="1.0" ?>
-<map orientation="orthogonal" width="200" height="200" tilewidth="31" tileheight="31">
- <tileset firstgid="1" name="Desert">
+<?xml version="1.0"?>
+<map version="0.99b" orientation="orthogonal" width="200" height="200" tilewidth="31" tileheight="31">
+ <tileset name="Desert" firstgid="1">
<tile id="1">
<image format="png">
<data encoding="base64">
@@ -226,12 +226,12 @@
</image>
</tile>
</tileset>
- <layer name="Layer 0">
+ <layer name="Layer 0" width="200" height="200">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAAO3d624bNxCGYUKp4cYtekbQc3n/V1kvYsI0xfOSnOHq/fFAirQHcjifV5KV5JMx5hPUuS0gPced2Dffv/onUceamt68Yz2/3dauh9TaaewV8qHLD+ZrLz+Zrxnpqa177jjO89tjx+23FWviP79y/WI/A1LjiN2fOVayoYfr4yMfLydqHWbkS8W2Emvon+ebxP1QuJ1vp4xI99qOXD6+M/c/8/2eL9Xcf+xzZl00rGNq3O7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MxgC4/ZStLzAKTZDOmxARpZQz4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAECf/wEwJboAAHECAA==
</data>
</layer>
- <layer name="Layer 1">
+ <layer name="Layer 1" width="200" height="200">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAAO3OMQEAAAgDoJWxf0Ub7NUDEpAAAAAAAAAAAAAAAACfzHUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKBY9s3jvQBxAgA=
</data>
Modified: trunk/src/tiled/core/MapObject.java
===================================================================
--- trunk/src/tiled/core/MapObject.java 2006-06-13 13:21:57 UTC (rev 667)
+++ trunk/src/tiled/core/MapObject.java 2006-06-21 16:17:27 UTC (rev 668)
@@ -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>
*/
@@ -15,13 +15,15 @@
import java.awt.Rectangle;
import java.util.Properties;
-
+/**
+ * @version $Id$
+ */
public class MapObject
{
private Sprite sprite;
private Properties properties;
- protected float map_x, map_y;
+ protected float mapX, mapY;
protected Rectangle bounds;
protected boolean bVisible = true;
protected String source, type;
@@ -32,11 +34,11 @@
}
public void setX(int x) {
- map_x = x;
+ mapX = x;
}
public void setY(int y) {
- map_y = y;
+ mapY = y;
}
public void setType(String s) {
@@ -52,16 +54,16 @@
}
public void translate(int x, int y) {
- map_x += x;
- map_y += y;
+ mapX += x;
+ mapY += y;
}
-
+
public int getX() {
- return (int)map_x;
+ return (int) mapX;
}
public int getY() {
- return (int)map_y;
+ return (int) mapY;
}
public String getType() {
@@ -77,6 +79,6 @@
}
public String toString() {
- return type + " (" + map_x + "," + map_y + ")";
+ return type + " (" + mapX + "," + mapY + ")";
}
}
Modified: trunk/src/tiled/core/TileSet.java
===================================================================
--- trunk/src/tiled/core/TileSet.java 2006-06-13 13:21:57 UTC (rev 667)
+++ trunk/src/tiled/core/TileSet.java 2006-06-21 16:17:27 UTC (rev 668)
@@ -381,10 +381,10 @@
}
/**
- * Returns the filename of the tile bitmap.
+ * Returns the filename of the tileset image.
*
- * @return the filename of the tile bitmap, or <code>null</code> if this
- * tileset doesn't reference a tile bitmap
+ * @return the filename of the tileset image, or <code>null</code> if this
+ * tileset doesn't reference a tileset image
*/
public String getTilebmpFile() {
if (tilebmpFile != null) {
Modified: trunk/src/tiled/mapeditor/actions/CloneLayerAction.java
===================================================================
--- trunk/src/tiled/mapeditor/actions/CloneLayerAction.java 2006-06-13 13:21:57 UTC (rev 667)
+++ trunk/src/tiled/mapeditor/actions/CloneLayerAction.java 2006-06-21 16:17:27 UTC (rev 668)
@@ -45,10 +45,10 @@
"action.layer.duplicate.newlayer.name");
clone.setName(MessageFormat.format(newName, new Object[]{clone.getName()}));
currentMap.addLayer(clone);
+ editor.setCurrentLayer(currentMap.getTotalLayers() - 1);
} catch (CloneNotSupportedException ex) {
ex.printStackTrace();
}
- editor.setCurrentLayer(currentMap.getTotalLayers() - 1);
}
}
}
Modified: trunk/src/tiled/mapeditor/animation/AnimationDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/animation/AnimationDialog.java 2006-06-13 13:21:57 UTC (rev 667)
+++ trunk/src/tiled/mapeditor/animation/AnimationDialog.java 2006-06-21 16:17:27 UTC (rev 668)
@@ -1,5 +1,5 @@
/*
- * Tiled Map Editor, (c) 2005
+ * 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
@@ -13,36 +13,35 @@
package tiled.mapeditor.animation;
import java.awt.*;
-import java.awt.event.*;
-import java.io.IOException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.util.Iterator;
-
import javax.swing.*;
-import tiled.core.*;
-import tiled.mapeditor.MapEditor;
+import tiled.core.Sprite;
+import tiled.core.MapObject;
import tiled.mapeditor.Resources;
/**
* This is the multi-purpose animation dialog, which can handle any
- * tiled.core.Sprite based animations. (Good for animated tiles, and
- * MapObjects)
+ * {@link Sprite} based animations. (Good for animated tiles, and
+ * {@link MapObject}s)
*
- * @see tiled.core.Sprite
+ * @see Sprite
*/
-public class AnimationDialog extends JDialog implements ActionListener {
-
+public class AnimationDialog extends JDialog implements ActionListener
+{
private static final int PLAYING = 1;
private static final int STOPPED = 0;
private Sprite currentSprite;
- private SpriteCanvas canvas = null;
+ private SpriteCanvas canvas;
private int state = STOPPED;
- private JButton playstop = null;
+ private JButton playstop;
private JComboBox keyframe;
- private JLabel lCurrentFrame = null;
- private JLabel lFrameRate = null;
- private JLabel lFrameRange = null;
+ private JLabel lCurrentFrame;
+ private JLabel lFrameRate;
+ private JLabel lFrameRange;
private Icon playIcon, stopIcon;
@@ -58,7 +57,7 @@
setLocationRelativeTo(getOwner());
}
- public JPanel makeUp(){
+ public JPanel makeUp() {
JButton b;
JLabel l;
JPanel main = new JPanel(new BorderLayout());
@@ -68,80 +67,88 @@
canvas = new SpriteCanvas(this);
- GridBagConstraints c=new GridBagConstraints();
- c.fill=GridBagConstraints.BOTH;
- c.weightx = 1; c.weighty = 1;
- c.gridx = 0; c.gridy = 0;
- c.gridheight = 1; c.gridwidth = 1;
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.BOTH;
+ c.weightx = 1;
+ c.weighty = 1;
+ c.gridx = 0;
+ c.gridy = 0;
+ c.gridheight = 1;
+ c.gridwidth = 1;
b = new JButton("", Resources.getIcon("startframe.png"));
b.setActionCommand("startframe");
- b.setMargin(new Insets(0,0,0,0));
+ b.setMargin(new Insets(0, 0, 0, 0));
b.addActionListener(this);
- buttons.add(b,c);
+ buttons.add(b, c);
c.gridx = 1;
b = new JButton("", Resources.getIcon("back.png"));
b.setActionCommand("back");
- b.setMargin(new Insets(0,0,0,0));
+ b.setMargin(new Insets(0, 0, 0, 0));
b.addActionListener(this);
- buttons.add(b,c);
+ buttons.add(b, c);
c.gridx = 2;
playstop = new JButton("", Resources.getIcon("play.png"));
playstop.setActionCommand("playstop");
- playstop.setMargin(new Insets(0,0,0,0));
+ playstop.setMargin(new Insets(0, 0, 0, 0));
playstop.addActionListener(this);
- buttons.add(playstop,c);
+ buttons.add(playstop, c);
c.gridx = 3;
b = new JButton("", Resources.getIcon("forward.png"));
b.setActionCommand("forward");
- b.setMargin(new Insets(0,0,0,0));
+ b.setMargin(new Insets(0, 0, 0, 0));
b.addActionListener(this);
- buttons.add(b,c);
+ buttons.add(b, c);
c.gridx = 4;
b = new JButton("", Resources.getIcon("lastframe.png"));
b.setActionCommand("lastframe");
- b.setMargin(new Insets(0,0,0,0));
+ b.setMargin(new Insets(0, 0, 0, 0));
b.addActionListener(this);
buttons.add(b, c);
- c.gridx = 0; c.gridy = 0; c.gridwidth = 2;
- String[] defaultArr = { "None" };
+ c.gridx = 0;
+ c.gridy = 0;
+ c.gridwidth = 2;
+ String[] defaultArr = {"None"};
keyframe = new JComboBox(defaultArr);
keyframe.addActionListener(this);
- opt.add(keyframe,c);
+ opt.add(keyframe, c);
- c.gridwidth = 1; c.gridy = 1;
+ c.gridwidth = 1;
+ c.gridy = 1;
l = new JLabel("Range:");
- opt.add(l,c);
+ opt.add(l, c);
c.gridx = 1;
lFrameRange = new JLabel("-");
- opt.add(lFrameRange,c);
+ opt.add(lFrameRange, c);
- c.gridy = 2; c.gridx = 0;
+ c.gridy = 2;
+ c.gridx = 0;
l = new JLabel("Current:");
- opt.add(l,c);
+ opt.add(l, c);
c.gridx = 1;
lCurrentFrame = new JLabel("?");
- opt.add(lCurrentFrame,c);
+ opt.add(lCurrentFrame, c);
- c.gridy = 3; c.gridx = 0;
+ c.gridy = 3;
+ c.gridx = 0;
l = new JLabel("Rate:");
- opt.add(l,c);
+ opt.add(l, c);
c.gridx = 1;
lFrameRate = new JLabel("?");
- opt.add(lFrameRate,c);
+ opt.add(lFrameRate, c);
- data.add(canvas,BorderLayout.CENTER);
- data.add(buttons,BorderLayout.SOUTH);
+ data.add(canvas, BorderLayout.CENTER);
+ data.add(buttons, BorderLayout.SOUTH);
- main.add(data,BorderLayout.CENTER);
- main.add(opt,BorderLayout.EAST);
+ main.add(data, BorderLayout.CENTER);
+ main.add(opt, BorderLayout.EAST);
return main;
}
@@ -152,8 +159,11 @@
if (state == PLAYING) {
if (currentSprite != null) {
if (currentSprite.getCurrentKey() == null) {
- JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
- state=STOPPED;
+ JOptionPane.showMessageDialog(this,
+ "There are no keys defined!",
+ "No Keys",
+ JOptionPane.ERROR_MESSAGE);
+ state = STOPPED;
return;
}
currentSprite.iterateFrame();
@@ -170,20 +180,23 @@
}
public void updateList() {
- if (currentSprite != null){
+ if (currentSprite != null) {
keyframe.removeAllItems();
- try{
+ try {
Iterator itr = currentSprite.getKeys();
- while(itr.hasNext()){
- keyframe.addItem(((Sprite.KeyFrame)itr.next()).getName());
+ while (itr.hasNext()) {
+ keyframe.addItem(((Sprite.KeyFrame) itr.next()).getName());
}
- }catch(Exception e){}
+ }
+ catch (Exception e) {
+ }
}
}
- public void updateStats(){
+ public void updateStats() {
if (currentSprite != null) {
- Sprite.KeyFrame k = currentSprite.getKey((String)keyframe.getSelectedItem());
+ Sprite.KeyFrame k =
+ currentSprite.getKey((String) keyframe.getSelectedItem());
if (k != null) {
lCurrentFrame.setText("" + currentSprite.getCurrentFrame());
lFrameRate.setText("" + k.getFrameRate());
@@ -192,71 +205,101 @@
}
public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().equalsIgnoreCase("New Key...")||e.getActionCommand().equalsIgnoreCase("Modify Key...")) {
- KeyDialog kd = new KeyDialog(this,currentSprite);
+ if (e.getActionCommand().equalsIgnoreCase("New Key...") ||
+ e.getActionCommand().equalsIgnoreCase("Modify Key...")) {
+ KeyDialog kd = new KeyDialog(this, currentSprite);
kd.doKeys();
- } else if (e.getActionCommand().equalsIgnoreCase("Delete Key")) {
+ }
+ else if (e.getActionCommand().equalsIgnoreCase("Delete Key")) {
if (currentSprite != null) {
- currentSprite.removeKey((String)keyframe.getSelectedItem());
+ currentSprite.removeKey((String) keyframe.getSelectedItem());
}
- } else if (e.getActionCommand().equalsIgnoreCase("comboBoxChanged")) {
+ }
+ else if (e.getActionCommand().equalsIgnoreCase("comboBoxChanged")) {
if (currentSprite != null) {
- currentSprite.setKeyFrameTo((String)keyframe.getSelectedItem());
+ currentSprite
+ .setKeyFrameTo((String) keyframe.getSelectedItem());
updateStats();
canvas.repaint();
}
- } else {
+ }
+ else {
handleFrames(e);
}
updateList();
updateStats();
}
- public void handleFrames(ActionEvent e){
+ public void handleFrames(ActionEvent e) {
if (currentSprite == null) {
return;
}
if (e.getActionCommand().equalsIgnoreCase("startframe")) {
- if (currentSprite.getCurrentKey()==null) {
- JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
- } else {
+ if (currentSprite.getCurrentKey() == null) {
+ JOptionPane.showMessageDialog(this,
+ "There are no keys defined!",
+ "No Keys",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ else {
currentSprite.keySetFrame(0);
canvas.repaint();
}
- } else if (e.getActionCommand().equalsIgnoreCase("back")) {
+ }
+ else if (e.getActionCommand().equalsIgnoreCase("back")) {
if (currentSprite.getCurrentKey() == null) {
- JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
- } else {
+ JOptionPane.showMessageDialog(this,
+ "There are no keys defined!",
+ "No Keys",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ else {
currentSprite.keyStepBack(1);
canvas.repaint();
}
- }else if(e.getActionCommand().equalsIgnoreCase("playstop")){
- if(currentSprite.getCurrentKey()==null){
- JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
- }else{
- if(state==PLAYING){
- state=STOPPED;
+ }
+ else if (e.getActionCommand().equalsIgnoreCase("playstop")) {
+ if (currentSprite.getCurrentKey() == null) {
+ JOptionPane.showMessageDialog(this,
+ "There are no keys defined!",
+ "No Keys",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ else {
+ if (state == PLAYING) {
+ state = STOPPED;
currentSprite.stop();
playstop.setIcon(playIcon);
- }else{
- state=PLAYING;
+ }
+ else {
+ state = PLAYING;
currentSprite.play();
playstop.setIcon(stopIcon);
}
canvas.repaint();
}
- }else if(e.getActionCommand().equalsIgnoreCase("forward")){
- if(currentSprite.getCurrentKey()==null){
- JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
- }else{
+ }
+ else if (e.getActionCommand().equalsIgnoreCase("forward")) {
+ if (currentSprite.getCurrentKey() == null) {
+ JOptionPane.showMessageDialog(this,
+ "There are no keys defined!",
+ "No Keys",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ else {
currentSprite.keyStepForward(1);
canvas.repaint();
}
- }else if(e.getActionCommand().equalsIgnoreCase("lastframe")){
- if(currentSprite.getCurrentKey()==null){
- JOptionPane.showMessageDialog(this,"There are no keys defined!","No Keys", JOptionPane.ERROR_MESSAGE);
- }else{
+ }
+ else if (e.getActionCommand().equalsIgnoreCase("lastframe")) {
+ if (currentSprite.getCurrentKey() == null) {
+ JOptionPane.showMessageDialog(this,
+ "There are no keys defined!",
+ "No Keys",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ else {
currentSprite.keyStepForward(10000);
canvas.repaint();
}
@@ -264,16 +307,15 @@
}
}
-class SpriteCanvas extends JPanel{
-
+class SpriteCanvas extends JPanel
+{
private AnimationDialog owner;
- private Image buffer = null;
- private Dimension osd;
+ private Image buffer;
+ private Dimension osd;
- SpriteCanvas(AnimationDialog o){
-
+ SpriteCanvas(AnimationDialog o) {
owner = o;
- }
+ }
/**
* Draws checkerboard background.
@@ -302,31 +344,28 @@
}
}
- public void paint(Graphics g){
+ public void paint(Graphics g) {
- if(owner!=null)
- {
- Dimension d = this.getSize();
- if(buffer == null){
- osd=d;
- buffer=createImage(d.width,d.height);
+ if (owner != null) {
+ Dimension d = getSize();
+ if (buffer == null) {
+ osd = d;
+ buffer = createImage(d.width, d.height);
}
- if(d.width!=osd.width||d.height!=osd.height){
- osd = d;
- buffer=createImage(d.width,d.height);
+ if (d.width != osd.width || d.height != osd.height) {
+ osd = d;
+ buffer = createImage(d.width, d.height);
}
paintBackground(g);
- if(buffer != null){
-
- Graphics osg = buffer.getGraphics();
-
+ if (buffer != null) {
+ Graphics osg = buffer.getGraphics();
owner.paintSprite(osg);
-
- g.drawImage(buffer,0,0,null);
- }else{
+ g.drawImage(buffer, 0, 0, null);
+ }
+ else {
owner.paintSprite(g);
}
- }
+ }
}
}
Deleted: trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java 2006-06-13 13:21:57 UTC (rev 667)
+++ trunk/src/tiled/mapeditor/dialogs/NewTileDialog.java 2006-06-21 16:17:27 UTC (rev 668)
@@ -1,105 +0,0 @@
-/*
- * Tiled Map Editor, (c) 2005
- *
- * 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.dialogs;
-
-import java.awt.Dialog;
-import java.awt.event.*;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-
-import javax.imageio.ImageIO;
-
-import javax.swing.*;
-
-import tiled.core.*;
-import tiled.mapeditor.Resources;
-
-/**
- * $Id$
- */
-public class NewTileDialog extends JDialog implements ActionListener
-{
- private TileSet tileset;
- private Tile currentTile;
- private String location;
-
- /* LANGUAGE PACK */
- private static final String DIALOG_TITLE = Resources.getString("dialog.newtile.title");
- /* -- */
-
- public NewTileDialog(Dialog parent, TileSet set) {
- super(parent, DIALOG_TITLE, true);
- tileset = set;
- location = "";
-
- init();
- pack();
- setLocationRelativeTo(getOwner());
- }
-
- private void init() {
-
- }
-
- public Tile createTile() {
- setVisible(true);
- return currentTile;
- }
-
- private void pickImage() {
- if (tileset.isSetFromImage()) {
- TileImageDialog d = new TileImageDialog(this, tileset);
- d.setVisible(true);
- if (d.getImageId() >= 0) {
- currentTile = new Tile(tileset);
- currentTile.setImage(d.getImageId());
- }
- return;
- }
-
- File[] files;
- JFileChooser ch = new JFileChooser(location);
- ch.setMultiSelectionEnabled(true);
- BufferedImage image = null;
-
- int ret = ch.showOpenDialog(this);
- if(ret == JFileChooser.APPROVE_OPTION) {
- files = ch.getSelectedFiles();
-
- for (int i = 0; i < files.length; i++) {
- try {
- image = ImageIO.read(files[i]);
- // TODO: Support for a transparent color
- } catch (IOException e) {
- JOptionPane.showMessageDialog(this, e.getLocalizedMessage(),
- "Error!", JOptionPane.ERROR_MESSAGE);
- return;
- }
-
- Tile newTile = new Tile(tileset);
- newTile.setImage(image);
- tileset.addNewTile(newTile);
- }
-
- if (files.length > 0) {
- location = files[0].getAbsolutePath();
- }
-
- }
- }
-
- public void actionPerformed(ActionEvent e) {
- // TODO Auto-generated method stub
- }
-}
Modified: trunk/src/tiled/mapeditor/dialogs/TileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileDialog.java 2006-06-13 13:21:57 UTC (rev 667)
+++ trunk/src/tiled/mapeditor/dialogs/TileDialog.java 2006-06-21 16:17:27 UTC (rev 668)
@@ -52,7 +52,7 @@
private JButton changeImageButton;
private JButton duplicateTileButton;
private JButton createTileButton;
- private JButton animationButton;
+ //private JButton animationButton;
private String location;
private JTextField tilesetNameEntry;
private JTabbedPane tabs;
@@ -68,10 +68,10 @@
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 IMAGES_TAB = "Images";
private static final String NAME_LABEL = Resources.getString("dialog.newtileset.name.label");
private static final String ERROR_LOADING_IMAGE = Resources.getString("dialog.tile.image.load.error");
- /* -- */
public TileDialog(Dialog parent, TileSet s, Map m) {
super(parent, DIALOG_TITLE + " '" + s.getName() + "'", true);
@@ -92,13 +92,13 @@
changeImageButton = new JButton(CI_BUTTON);
duplicateTileButton = new JButton(DUPLICATE_BUTTON);
newTileButton = new JButton(NEW_BUTTON);
- animationButton = new JButton(ANIMATION_BUTTON);
+ //animationButton = new JButton(ANIMATION_BUTTON);
deleteTileButton.addActionListener(this);
changeImageButton.addActionListener(this);
duplicateTileButton.addActionListener(this);
newTileButton.addActionListener(this);
- animationButton.addActionListener(this);
+ //animationButton.addActionListener(this);
tileList = new JList();
tileList.setCellRenderer(new TileDialogListRenderer());
@@ -141,9 +141,9 @@
buttons.add(changeImageButton);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
buttons.add(duplicateTileButton);
+ //buttons.add(Box.createRigidArea(new Dimension(5, 0)));
+ //buttons.add(animationButton);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
- buttons.add(animationButton);
- buttons.add(Box.createRigidArea(new Dimension(5, 0)));
buttons.add(Box.createGlue());
@@ -203,7 +203,7 @@
tabs = new JTabbedPane(JTabbedPane.TOP);
tabs.addTab(TILES_TAB, createTilePanel());
- tabs.addTab(PREVIEW_TAB, createImagePanel());
+ tabs.addTab(IMAGES_TAB, createImagePanel());
okButton = new JButton(OK_BUTTON);
@@ -238,52 +238,48 @@
return;
}
- if (tileset.isSetFromImage()) {
- TileImageDialog d = new TileImageDialog(this, tileset,
- currentTile.getImageId());
- d.setVisible(true);
- if (d.getImageId() >= 0) {
- currentTile.setImage(d.getImageId());
- }
- } else {
- Image img = loadImage();
- if (img != null) {
- currentTile.setImage(img);
- }
+ TileImageDialog d = new TileImageDialog(this, tileset,
+ currentTile.getImageId());
+ d.setVisible(true);
+ if (d.getImageId() >= 0) {
+ currentTile.setImage(d.getImageId());
}
}
- private Image loadImage() {
+ private void newTile() {
+ File[] files;
JFileChooser ch = new JFileChooser(location);
- int ret = ch.showOpenDialog(this);
+ ch.setMultiSelectionEnabled(true);
+ BufferedImage image = null;
+ int ret = ch.showOpenDialog(this);
if (ret == JFileChooser.APPROVE_OPTION) {
- File file = ch.getSelectedFile();
- try {
- BufferedImage image = ImageIO.read(file);
- if (image != null) {
- location = file.getAbsolutePath();
- return image;
- } else {
- JOptionPane.showMessageDialog(this, ERROR_LOADING_IMAGE,
- ERROR_LOADING_IMAGE, JOptionPane.ERROR_MESSAGE);
- return null;
+ files = ch.getSelectedFiles();
+
+ for (int i = 0; i < files.length; i++) {
+ try {
+ image = ImageIO.read(files[i]);
+ // TODO: Support for a transparent color
+ } catch (IOException e) {
+ JOptionPane.showMessageDialog(this, e.getLocalizedMessage(),
+ "Error!", JOptionPane.ERROR_MESSAGE);
+ return;
}
- } catch (IOException e) {
- e.printStackTrace();
- JOptionPane.showMessageDialog(this, e.getLocalizedMessage(),
- ERROR_LOADING_IMAGE, JOptionPane.ERROR_MESSAGE);
+
+ Tile newTile = new Tile(tileset);
+ newTile.setImage(tileset.addImage(image));
+ tileset.addNewTile(newTile);
}
+
+ if (files.length > 0) {
+ location = files[0].getAbsolutePath();
+ }
}
- return null;
+ queryTiles();
+ queryImages();
}
- private void newTile() {
- NewTileDialog d = new NewTileDialog(this, tileset);
- if (d.createTile() != null) queryTiles();
- }
-
public void setTileset(TileSet s) {
tileset = s;
@@ -362,25 +358,19 @@
}
private void updateEnabledState() {
- // boolean internal = (tileset.getSource() == null);
boolean tilebmp = tileset.getTilebmpFile() != null;
boolean tileSelected = currentTile != null;
- boolean setImages = tileset.isSetFromImage();
- boolean atLeastOneSharedImage = setImages
- && tileset.getTotalImages() >= 1;
+ boolean atLeastOneSharedImage = tileset.getTotalImages() >= 1;
newTileButton.setEnabled(atLeastOneSharedImage && !tilebmp);
- deleteTileButton.setEnabled(setImages && !tilebmp && tileSelected);
+ deleteTileButton.setEnabled(!tilebmp && tileSelected);
changeImageButton.setEnabled(atLeastOneSharedImage && !tilebmp
&& tileSelected);
- duplicateTileButton.setEnabled(setImages && !tilebmp && tileSelected);
- animationButton.setEnabled(setImages && !tilebmp && tileSelected &&
- currentTile instanceof AnimatedTile);
- tileProperties.setEnabled(setImages && !tilebmp && tileSelected);
+ duplicateTileButton.setEnabled(!tilebmp && tileSelected);
+ //animationButton.setEnabled(!tilebmp && tileSelected &&
+ // currentTile instanceof AnimatedTile);
+ tileProperties.setEnabled(tileSelected);
createTileButton.setEnabled(!tilebmp);
- //setImagesCheck.setEnabled(!tilebmp || !setImages
- // || tileset.safeToDisablesetImages());
- tabs.setEnabledAt(1, setImages);
}
/**
@@ -436,9 +426,9 @@
// Select the last (cloned) tile
tileList.setSelectedIndex(tileset.size() - 1);
tileList.ensureIndexIsVisible(tileset.size() - 1);
- } else if (source == animationButton) {
- AnimationDialog ad = new AnimationDialog(this, ((AnimatedTile)currentTile).getSprite());
- ad.setVisible(true);
+ //} else if (source == animationButton) {
+ // AnimationDialog ad = new AnimationDialog(this, ((AnimatedTile)currentTile).getSprite());
+ // ad.setVisible(true);
}
/*
else if (source == setImagesCheck) {
Modified: trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java 2006-06-13 13:21:57 UTC (rev 667)
+++ trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java 2006-06-21 16:17:27 UTC (rev 668)
@@ -18,6 +18,7 @@
import java.awt.event.ActionListener;
import java.util.Enumeration;
import java.util.Vector;
+import java.util.Arrays;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
@@ -28,6 +29,9 @@
import tiled.mapeditor.widget.VerticalStaticJPanel;
/**
+ * Dialog for picking a tile image. Used by the edit tileset dialog for
+ * changing the image of a tile.
+ *
* @version $Id$
*/
public class TileImageDialog extends JDialog implements ListSelectionListener
@@ -39,12 +43,10 @@
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);
}
@@ -100,14 +102,14 @@
mainPanel.add(buttons, c);
getContentPane().add(mainPanel);
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;
@@ -126,7 +128,7 @@
imageIds[i] = Integer.parseInt((String)ids.nextElement());
}
- java.util.Arrays.sort(imageIds);
+ Arrays.sort(imageIds);
for (int i = 0; i < imageIds.length; ++i) {
if (imageIds[i] == imageId) initialIndex = i;
More information about the tiled-commit
mailing list