From 6c584d709d00ad34034a2649ceffe3dc1d9edf3f Mon Sep 17 00:00:00 2001 From: chung-nguyen Date: Sat, 8 Jul 2017 23:50:22 +0700 Subject: [PATCH 1/3] + add configure on linux * fix typo in build.xml --- .gitignore | 5 +++++ build.xml | 2 +- nbproject/private/config.properties | 1 + yguard/.gitignore | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 yguard/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c92784 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/build +/dist +/dfEditor Installer.jar +/izpack/lib +/izpack/*.jar diff --git a/build.xml b/build.xml index e46f304..9a92ee2 100644 --- a/build.xml +++ b/build.xml @@ -130,7 +130,7 @@ - + diff --git a/nbproject/private/config.properties b/nbproject/private/config.properties index e69de29..88a51cc 100644 --- a/nbproject/private/config.properties +++ b/nbproject/private/config.properties @@ -0,0 +1 @@ +platforms.JDK_1.6.home=/usr/lib/jvm/java-8-oracle \ No newline at end of file diff --git a/yguard/.gitignore b/yguard/.gitignore new file mode 100644 index 0000000..7c287c7 --- /dev/null +++ b/yguard/.gitignore @@ -0,0 +1 @@ +/renamelog.xml From 5c3b42c01afb331d5ac2fdf2038b0ec312110e9e Mon Sep 17 00:00:00 2001 From: chung-nguyen Date: Sat, 8 Jul 2017 23:50:47 +0700 Subject: [PATCH 2/3] + add sprite packer padding --- src/dfEditor/PixelPacker.java | 41 ++++++++++++++++--------- src/dfEditor/SpritesheetController.java | 4 ++- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/dfEditor/PixelPacker.java b/src/dfEditor/PixelPacker.java index 3e34a5c..58735fc 100644 --- a/src/dfEditor/PixelPacker.java +++ b/src/dfEditor/PixelPacker.java @@ -32,12 +32,19 @@ public class PixelPacker private class PixelRectPair { public Rectangle rect; + public Rectangle padRect; public int[] pixels; - public PixelRectPair(final int[] aPixels, final Rectangle aRect) + public PixelRectPair(final int[] aPixels, final Rectangle aRect, int padding) { rect = aRect; pixels = aPixels; + + padRect = new Rectangle(rect); + padRect.x -= padding; + padRect.y -= padding; + padRect.width += padding * 2; + padRect.height += padding * 2; } } @@ -63,7 +70,7 @@ public boolean packRects(final Rectangle aMasterRect, final Rectangle[] aSubRect return bSuccess; } - public BufferedImage packPixels(final BufferedImage aOrigImage, final Rectangle[] aRects, boolean bPowerOfTwo) + public BufferedImage packPixels(final BufferedImage aOrigImage, final Rectangle[] aRects, boolean bPowerOfTwo, int padding) { int[] origPixels = new int[aOrigImage.getWidth(null) * aOrigImage.getHeight(null)]; aOrigImage.getRGB( 0, @@ -92,25 +99,25 @@ public BufferedImage packPixels(final BufferedImage aOrigImage, final Rectangle[ } } - pairs[i] = new PixelRectPair(pixels, r); + pairs[i] = new PixelRectPair(pixels, r, padding); } // TODO: sprites totally enclosed by other sprites should remain enclosed // TODO: multiple images? // sort by size - for (int i=0; i Date: Sun, 9 Jul 2017 23:31:46 +0700 Subject: [PATCH 3/3] + additional properties to sprite animation frame: id, scale, opacity --- src/dfEditor/GraphicObject.java | 69 + src/dfEditor/GraphicPanel.java | 2 +- .../animation/AnimationController.form | 152 +- .../animation/AnimationController.java | 1478 +++++++++-------- .../resources/AnimationController.properties | 5 + .../commands/SetGraphicIdCommand.java | 57 + .../commands/SetGraphicOpacityCommand.java | 61 + .../commands/SetGraphicScaleCommand.java | 61 + .../commands/SetSpriteListIdCommand.java | 59 + src/dfEditor/io/AnimationSetReader.java | 18 + src/dfEditor/io/AnimationSetWriter.java | 6 + 11 files changed, 1279 insertions(+), 689 deletions(-) create mode 100644 src/dfEditor/commands/SetGraphicIdCommand.java create mode 100644 src/dfEditor/commands/SetGraphicOpacityCommand.java create mode 100644 src/dfEditor/commands/SetGraphicScaleCommand.java create mode 100644 src/dfEditor/commands/SetSpriteListIdCommand.java diff --git a/src/dfEditor/GraphicObject.java b/src/dfEditor/GraphicObject.java index 04a2986..1b8ebca 100644 --- a/src/dfEditor/GraphicObject.java +++ b/src/dfEditor/GraphicObject.java @@ -30,23 +30,35 @@ public abstract class GraphicObject extends java.util.Observable public enum Anchor { TOP_LEFT, CENTRE } protected Rectangle _rect; + protected String _id; protected boolean _bResizable; protected boolean _bSelected; protected Rectangle _bounds; protected Rectangle _savedRect; protected String _description = null; + protected String _savedId; protected float _angle; + protected float _scale; + protected float _opacity; protected float _savedAngle; + protected float _savedScale; + protected float _savedOpacity; protected Anchor _anchor; public GraphicObject(Rectangle aRect) { + _id = ""; _angle = 0; + _scale = 100; + _opacity = 255; _bResizable = false; _bSelected = false; setRect(aRect); saveRect(); saveAngle(); + saveScale(); + saveOpacity(); + saveId(); _anchor = Anchor.TOP_LEFT; _description = super.toString(); @@ -89,6 +101,36 @@ public boolean hasMoved() { return ! (_savedRect.equals(_rect)); } + + public void setScale(float scale) + { + _scale = scale; + } + + public float getScale() + { + return _scale; + } + + public void setOpacity(float opacity) + { + _opacity = opacity; + } + + public float getOpacity() + { + return _opacity; + } + + public void setId(String id) + { + _id = id; + } + + public String getId() + { + return _id; + } public void setAngle(float aAngle) { @@ -124,6 +166,18 @@ public void saveAngle() { _savedAngle = getAngle(); } + + public void saveScale() { + _savedScale = getScale(); + } + + public void saveOpacity() { + _savedOpacity = getOpacity(); + } + + public void saveId() { + _savedId = getId(); + } public Rectangle getRect() { @@ -140,6 +194,21 @@ public float getSavedAngle() return _savedAngle; } + public float getSavedScale() + { + return _savedScale; + } + + public float getSavedOpacity() + { + return _savedOpacity; + } + + public String getSavedId() + { + return _savedId; + } + public void moveFromSavedPoint(Point aDist) { Rectangle r = getRect(); diff --git a/src/dfEditor/GraphicPanel.java b/src/dfEditor/GraphicPanel.java index af63a8b..8b6ec10 100644 --- a/src/dfEditor/GraphicPanel.java +++ b/src/dfEditor/GraphicPanel.java @@ -342,7 +342,7 @@ protected void drawGraphicRotated(GraphicObject graphic, Graphics g, Point aOrig g2d.setTransform(transform); - graphic.draw(g2d, aOrigin, aZoom, aAlpha, _bAllowsEditing); + graphic.draw(g2d, aOrigin, aZoom * graphic.getScale() * 0.01f, aAlpha * (graphic.getOpacity() / 255.0f), _bAllowsEditing); g2d.setTransform(oldTransform); } diff --git a/src/dfEditor/animation/AnimationController.form b/src/dfEditor/animation/AnimationController.form index 4f24507..4fc553a 100644 --- a/src/dfEditor/animation/AnimationController.form +++ b/src/dfEditor/animation/AnimationController.form @@ -1,6 +1,6 @@ - + -
+ @@ -358,12 +358,12 @@ - + - + @@ -489,7 +489,7 @@ - + @@ -677,14 +677,14 @@ - + - + - + @@ -699,11 +699,11 @@ - + - + @@ -723,16 +723,7 @@ - - - - - - - - - @@ -750,16 +741,7 @@ - - - - - - - - - @@ -797,7 +779,7 @@ - + @@ -894,7 +876,11 @@ - + + + + + @@ -906,6 +892,8 @@ + + @@ -931,6 +919,24 @@ + + + + + + + + + + + + + + + + + + @@ -942,9 +948,9 @@ - + - + @@ -996,9 +1002,10 @@ - - - + + + + @@ -1040,12 +1047,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dfEditor/animation/AnimationController.java b/src/dfEditor/animation/AnimationController.java index 85b999f..fabff51 100644 --- a/src/dfEditor/animation/AnimationController.java +++ b/src/dfEditor/animation/AnimationController.java @@ -16,15 +16,11 @@ * You should have received a copy of the GNU General Public License * along with darkFunction Editor. If not, see . */ - - - -/* + /* * AnimationController.java * * Created on 06-Dec-2009, 23:39:51 */ - package dfEditor.animation; import dfEditor.*; @@ -42,77 +38,80 @@ import javax.swing.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; -import dfEditor.CustomComponents.*; +import dfEditor.CustomComponents.*; import javax.swing.JTextField; import javax.swing.plaf.basic.*; import java.awt.Dimension; import java.beans.PropertyVetoException; import java.awt.*; import java.awt.event.FocusListener; + /** * * @author Owner */ public class AnimationController extends dfEditorPanel implements - ListSelectionListener, - GraphicPanelChangeListener, - AnimationStripListener, - AnimationDataListener, - SpriteTreeListener, - NodeDroppedListener, - ActionListener, - InternalFrameListener -{ + ListSelectionListener, + GraphicPanelChangeListener, + AnimationStripListener, + AnimationDataListener, + SpriteTreeListener, + NodeDroppedListener, + ActionListener, + InternalFrameListener { + private BufferedImage bufferedImage = null; - private AnimationCell workingCell = null; + private AnimationCell workingCell = null; private File loadedSpritesheetFile = null; private Timer spinnerStateTimer = null; ArrayList _rotatingGraphics = null; + ArrayList _scalingGraphics = null; + ArrayList _opacityGraphics = null; + ArrayList _idGraphics = null; - /** Creates new form AnimationController */ - public AnimationController(CommandManager aCmdManager, boolean aNew, JLabel aHelpLabel, TaskChangeListener aListener, JFileChooser aChooser) - { + /** + * Creates new form AnimationController + */ + public AnimationController(CommandManager aCmdManager, boolean aNew, JLabel aHelpLabel, TaskChangeListener aListener, JFileChooser aChooser) { super(aCmdManager, aHelpLabel, aListener, aChooser); initComponents(); viewPanel.addGraphicChangeListener(this); animationStripPanel.setController(this); - + animationStripPanel.setCommandManager(aCmdManager); viewPanel.setCommandManager(aCmdManager); - animationList.addListSelectionListener(this); - + animationList.addListSelectionListener(this); + spriteList.addListSelectionListener(this); spriteList.addNodeDroppedListener(this); spriteList.setDragSource(spriteTree); - - spriteTree.addTreeListener(this); + + spriteTree.addTreeListener(this); viewPanel.addNodeDroppedListener(this); viewPanel.setDragSource(spriteTree); controlPanel.addInternalFrameListener(this); spriteListControlPanel.addInternalFrameListener(this); - + setWorkingCell(null); - if (aNew) - { + if (aNew) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { showSpritesheetChooser(); } }); } - - viewPanel.requestFocus(); - - postInit(); + + viewPanel.requestFocus(); + + postInit(); } - private void showSpritesheetChooser() - { + private void showSpritesheetChooser() { JFileChooser chooser = fileChooser; CustomFilter filter = new CustomFilter(); @@ -120,118 +119,110 @@ private void showSpritesheetChooser() chooser.resetChoosableFileFilters(); chooser.setFileFilter(filter); chooser.setDialogTitle("Select spritesheet"); - + JFrame mainFrame = dfEditorApp.getApplication().getMainFrame(); int returnVal = chooser.showOpenDialog(mainFrame); - if(returnVal == JFileChooser.APPROVE_OPTION) - { - setSpritesheetFile(chooser.getSelectedFile()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + setSpritesheetFile(chooser.getSelectedFile()); } } - private void setSpritesheetFile(File aFile) - { + private void setSpritesheetFile(File aFile) { SpritesheetReader reader = new SpritesheetReader(aFile); loadedSpritesheetFile = aFile; - - try - { + + try { String imgPath = reader.getImagePath(); - if (imgPath != null) + if (imgPath != null) { bufferedImage = ImageIO.read(new File(imgPath)); - } - catch (IOException e) - { + } + } catch (IOException e) { showParseError(); return; } DefaultTreeModel model = reader.getTreeModel(); - if (model != null) - { + if (model != null) { spriteTree.setModel(model); addAnimationButton.setEnabled(true); - } - else - { + } else { showParseError(); return; } } - - private void buildAnimatedGif(String filePath) - { + + private void buildAnimatedGif(String filePath) { Animation animation = this.getWorkingAnimation(); - - if (animation != null && animation.numCells() > 0) - { + + if (animation != null && animation.numCells() > 0) { Rectangle firstCellRect = animation.getCellAtIndex(0).getSpreadRect(); Point topLeft = new Point(firstCellRect.x, firstCellRect.y); Point bottomRight = new Point(firstCellRect.x + firstCellRect.width, firstCellRect.y + firstCellRect.height); - - for (int i=1; i bottomRight.x) + } + if (r.x + r.width > bottomRight.x) { bottomRight.x = r.x + r.width; - if (r.y + r.height > bottomRight.y) - bottomRight.y = r.y + r.height; + } + if (r.y + r.height > bottomRight.y) { + bottomRight.y = r.y + r.height; + } } - + AnimatedGifEncoder e = new AnimatedGifEncoder(); - e.setTransparent(new Color(0,0,0,0)); - e.start(filePath); + e.setTransparent(new Color(0, 0, 0, 0)); + e.start(filePath); e.setRepeat(animation.getLoops()); e.setQuality(1); e.setSize(bottomRight.x - topLeft.x, bottomRight.y - topLeft.y); - - for (int i=0; i 1; - if (!bPlayable) - { + if (!bPlayable) { animationStripPanel.stop(); } playButton.setEnabled(bPlayable); } } - public void cellRemoved(Animation aAnimation, AnimationCell aCell) - { - if (aAnimation == this.getWorkingAnimation()) - { + public void cellRemoved(Animation aAnimation, AnimationCell aCell) { + if (aAnimation == this.getWorkingAnimation()) { boolean bPlayable = aAnimation.numCells() > 1; - if (!bPlayable) - { + if (!bPlayable) { animationStripPanel.stop(); } playButton.setEnabled(bPlayable); @@ -294,25 +280,21 @@ public void cellRemoved(Animation aAnimation, AnimationCell aCell) } } - - public void cellOrderChanged(Animation aAnimation) - { - if (aAnimation == this.getWorkingAnimation()) - { - + + public void cellOrderChanged(Animation aAnimation) { + if (aAnimation == this.getWorkingAnimation()) { + } } - public AnimationCell getWorkingCell() - { + public AnimationCell getWorkingCell() { return workingCell; } - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents @@ -354,12 +336,19 @@ private void initComponents() { jPanel7 = new javax.swing.JPanel(); flipVCheckBox = new javax.swing.JCheckBox(); flipHCheckBox = new javax.swing.JCheckBox(); + idTextField = new javax.swing.JTextField(); + idLabel = new javax.swing.JLabel(); jPanel6 = new javax.swing.JPanel(); angleLabel = new javax.swing.JLabel(); angleSpinner = new javax.swing.JSpinner(new RollOverSpinModel(0, 0, 360, 1)); jPanel5 = new javax.swing.JPanel(); zOrderLabel = new javax.swing.JLabel(); zOrderSpinner = new javax.swing.JSpinner(new CustomSpinModel()); + jPanel8 = new javax.swing.JPanel(); + scaleLabel = new javax.swing.JLabel(); + scaleSpinner = new javax.swing.JSpinner(); + opacityLabel = new javax.swing.JLabel(); + opacitySpinner = new javax.swing.JSpinner(); spriteListControlPanel = new javax.swing.JInternalFrame(); jScrollPane3 = new javax.swing.JScrollPane(); spriteList = new dfEditor.SpriteList(); @@ -415,7 +404,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { removeAnimationButton.setMaximumSize(new java.awt.Dimension(100, 100)); removeAnimationButton.setMinimumSize(new java.awt.Dimension(0, 0)); removeAnimationButton.setName("removeAnimationButton"); // NOI18N - removeAnimationButton.setPreferredSize(new java.awt.Dimension(30, 30)); removeAnimationButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeAnimationButtonActionPerformed(evt); @@ -471,13 +459,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(duplicateAnimationButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(exportGifButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(28, Short.MAX_VALUE)) - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE) + .addContainerGap(27, Short.MAX_VALUE)) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(addAnimationButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -512,18 +500,20 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { } }); + animationPanel1.setLayer(playButton, javax.swing.JLayeredPane.DEFAULT_LAYER); + javax.swing.GroupLayout animationPanel1Layout = new javax.swing.GroupLayout(animationPanel1); animationPanel1.setLayout(animationPanel1Layout); animationPanel1Layout.setHorizontalGroup( animationPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, animationPanel1Layout.createSequentialGroup() - .addContainerGap(131, Short.MAX_VALUE) + .addContainerGap(133, Short.MAX_VALUE) .addComponent(playButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) ); animationPanel1Layout.setVerticalGroup( animationPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, animationPanel1Layout.createSequentialGroup() - .addContainerGap(115, Short.MAX_VALUE) + .addContainerGap(119, Short.MAX_VALUE) .addComponent(playButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) ); @@ -584,7 +574,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { removeCellButton.setMaximumSize(new java.awt.Dimension(100, 100)); removeCellButton.setMinimumSize(new java.awt.Dimension(0, 0)); removeCellButton.setName("removeCellButton"); // NOI18N - removeCellButton.setPreferredSize(new java.awt.Dimension(30, 30)); removeCellButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeCellButtonActionPerformed(evt); @@ -603,7 +592,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { animationStripPanel.setLayout(animationStripPanelLayout); animationStripPanelLayout.setHorizontalGroup( animationStripPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 430, Short.MAX_VALUE) + .addGap(0, 525, Short.MAX_VALUE) ); animationStripPanelLayout.setVerticalGroup( animationStripPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -628,12 +617,12 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) { jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(animationStripScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE) + .addComponent(animationStripScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(addCellButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(removeCellButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 63, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 177, Short.MAX_VALUE) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(delaySpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -736,7 +725,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spritePreviewPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); @@ -753,10 +742,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { zoomInButton.setFocusable(false); zoomInButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); zoomInButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); - zoomInButton.setMaximumSize(new java.awt.Dimension(34, 34)); - zoomInButton.setMinimumSize(new java.awt.Dimension(34, 34)); zoomInButton.setName("zoomInButton"); // NOI18N - zoomInButton.setPreferredSize(new java.awt.Dimension(34, 34)); zoomInButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { zoomInButtonActionPerformed(evt); @@ -771,10 +757,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { zoomOutButton.setFocusable(false); zoomOutButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); zoomOutButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); - zoomOutButton.setMaximumSize(new java.awt.Dimension(34, 34)); - zoomOutButton.setMinimumSize(new java.awt.Dimension(34, 34)); zoomOutButton.setName("zoomOutButton"); // NOI18N - zoomOutButton.setPreferredSize(new java.awt.Dimension(34, 34)); zoomOutButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { zoomOutButtonActionPerformed(evt); @@ -875,13 +858,35 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { } }); + idTextField.setText(resourceMap.getString("idTextField.text")); // NOI18N + idTextField.setToolTipText(resourceMap.getString("idTextField.toolTipText")); // NOI18N + idTextField.setEnabled(false); + idTextField.setName("idTextField"); // NOI18N + idTextField.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + idTextFieldFocusLost(evt); + } + }); + idTextField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + idTextFieldActionPerformed(evt); + } + }); + + idLabel.setText(resourceMap.getString("idLabel.text")); // NOI18N + idLabel.setName("idLabel"); // NOI18N + javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); jPanel7.setLayout(jPanel7Layout); jPanel7Layout.setHorizontalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup() .addContainerGap() - .addComponent(flipHCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(idLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(flipHCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(flipVCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) @@ -890,7 +895,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(flipVCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(flipHCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(flipHCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(idLabel)) ); jToolBar1.add(jPanel7); @@ -918,9 +925,9 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) { jPanel6Layout.setHorizontalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() - .addComponent(angleLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE) + .addComponent(angleLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(3, 3, 3) - .addComponent(angleSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(angleSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) ); jPanel6Layout.setVerticalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -953,9 +960,10 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) { jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() - .addComponent(zOrderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(2, 2, 2) - .addComponent(zOrderSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(zOrderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(3, 3, 3) + .addComponent(zOrderSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -966,10 +974,64 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) { jToolBar1.add(jPanel5); - controlPanel.getContentPane().add(jToolBar1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, 30)); + controlPanel.getContentPane().add(jToolBar1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 590, 40)); + + jPanel8.setName("jPanel8"); // NOI18N + + scaleLabel.setText(resourceMap.getString("scaleLabel.text")); // NOI18N + scaleLabel.setName("scaleLabel"); // NOI18N + + scaleSpinner.setEnabled(false); + scaleSpinner.setName("scaleSpinner"); // NOI18N + scaleSpinner.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + scaleSpinnerStateChanged(evt); + } + }); + + opacityLabel.setText(resourceMap.getString("opacityLabel.text")); // NOI18N + opacityLabel.setName("opacityLabel"); // NOI18N + + opacitySpinner.setEnabled(false); + opacitySpinner.setName("opacitySpinner"); // NOI18N + opacitySpinner.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + opacitySpinnerStateChanged(evt); + } + }); + + javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); + jPanel8.setLayout(jPanel8Layout); + jPanel8Layout.setHorizontalGroup( + jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel8Layout.createSequentialGroup() + .addContainerGap() + .addComponent(scaleLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(scaleSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(opacityLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(opacitySpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(330, Short.MAX_VALUE)) + ); + jPanel8Layout.setVerticalGroup( + jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel8Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(scaleLabel) + .addComponent(scaleSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(opacityLabel) + .addComponent(opacitySpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + controlPanel.getContentPane().add(jPanel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 40, 570, 40)); spriteListControlPanel.setClosable(true); spriteListControlPanel.setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); + spriteListControlPanel.setResizable(true); spriteListControlPanel.setTitle(resourceMap.getString("spriteListControlPanel.title")); // NOI18N spriteListControlPanel.setFocusCycleRoot(false); spriteListControlPanel.setFocusable(false); @@ -988,6 +1050,11 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) { spriteListControlPanel.getContentPane().add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 110, 110)); + viewPanel.setLayer(zoomInButton, javax.swing.JLayeredPane.DEFAULT_LAYER); + viewPanel.setLayer(zoomOutButton, javax.swing.JLayeredPane.DEFAULT_LAYER); + viewPanel.setLayer(controlPanel, javax.swing.JLayeredPane.DEFAULT_LAYER); + viewPanel.setLayer(spriteListControlPanel, javax.swing.JLayeredPane.DEFAULT_LAYER); + javax.swing.GroupLayout viewPanelLayout = new javax.swing.GroupLayout(viewPanel); viewPanel.setLayout(viewPanelLayout); viewPanelLayout.setHorizontalGroup( @@ -997,13 +1064,13 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) { .addGroup(viewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(viewPanelLayout.createSequentialGroup() .addComponent(controlPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(zoomInButton, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(zoomOutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(viewPanelLayout.createSequentialGroup() .addComponent(spriteListControlPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(438, Short.MAX_VALUE)))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) ); viewPanelLayout.setVerticalGroup( viewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -1013,9 +1080,9 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) { .addComponent(zoomOutButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(zoomInButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(viewPanelLayout.createSequentialGroup() - .addGap(12, 12, 12) + .addContainerGap() .addComponent(controlPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 126, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 103, Short.MAX_VALUE) .addComponent(spriteListControlPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); @@ -1092,7 +1159,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(modifySpriteToggle, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(viewPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 407, Short.MAX_VALUE)) + .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) @@ -1112,30 +1179,26 @@ private void zoomOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN viewPanel.setZoom(viewPanel.getZoom() - 0.5f); }//GEN-LAST:event_zoomOutButtonActionPerformed - public ArrayList addNodeToCell(CustomNode aNode, AnimationCell aCell, Point aPoint) - { + public ArrayList addNodeToCell(CustomNode aNode, AnimationCell aCell, Point aPoint) { ArrayList graphics = new ArrayList(); return this.addNodeToCell(aNode, aCell, graphics, aPoint); } - private ArrayList addNodeToCell(CustomNode aNode, AnimationCell aCell, ArrayList aGraphics, Point aPoint) - { - if (aNode == null) + private ArrayList addNodeToCell(CustomNode aNode, AnimationCell aCell, ArrayList aGraphics, Point aPoint) { + if (aNode == null) { return null; - - if (aNode.isLeaf()) - { - if (aCell != null) - { - SelectionBox spriteArea = (SelectionBox)aNode.getCustomObject(); + } + + if (aNode.isLeaf()) { + if (aCell != null) { + SelectionBox spriteArea = (SelectionBox) aNode.getCustomObject(); SpriteGraphic graphic = new SpriteGraphic(bufferedImage, aPoint, spriteArea.getRect()); graphic.setAnchor(GraphicObject.Anchor.CENTRE); aCell.addSprite(aNode, graphic); graphic.setDescription(aNode.getFullPathName()); - ((DefaultListModel)spriteList.getModel()).addElement(graphic); + ((DefaultListModel) spriteList.getModel()).addElement(graphic); - if (aCell == workingCell) - { + if (aCell == workingCell) { viewPanel.addGraphic(graphic); viewPanel.unselectAllGraphics(); viewPanel.selectGraphic(graphic); @@ -1143,71 +1206,60 @@ private ArrayList addNodeToCell(CustomNode aNode, AnimationCell a aGraphics.add(graphic); } - } - else - { - for (int i=0; i= 0) - { + if (index >= 0) { animationStripPanel.stop(); - cmdManager.execute(new RemoveAnimationCommand(animationList, (Animation)animationList.getModel().getElementAt(index))); - } + cmdManager.execute(new RemoveAnimationCommand(animationList, (Animation) animationList.getModel().getElementAt(index))); + } }//GEN-LAST:event_removeAnimationButtonActionPerformed - private Animation getWorkingAnimation() - { - DefaultMutableListModel model = (DefaultMutableListModel)animationList.getModel(); + private Animation getWorkingAnimation() { + DefaultMutableListModel model = (DefaultMutableListModel) animationList.getModel(); int index = animationList.getSelectedIndex(); - if (index >= 0) - { - return (Animation)model.get(index); + if (index >= 0) { + return (Animation) model.get(index); } return null; } @@ -1240,8 +1289,7 @@ private Animation getWorkingAnimation() private void addCellButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addCellButtonActionPerformed Animation animation = getWorkingAnimation(); - if (animation != null) - { + if (animation != null) { cmdManager.execute(new AddCellCommand(animation, this.getWorkingCell())); this.getWorkingCell().rebuild(); animationStripPanel.repaint(); @@ -1253,95 +1301,88 @@ private void removeCellButtonActionPerformed(java.awt.event.ActionEvent evt) {// //animationStripPanel.removeSelected(); Animation animation = getWorkingAnimation(); - AnimationCell cell = animationStripPanel.selectedCell(); - if (animation != null) - { + AnimationCell cell = animationStripPanel.selectedCell(); + if (animation != null) { cmdManager.execute(new RemoveCellCommand(animation, cell)); } }//GEN-LAST:event_removeCellButtonActionPerformed private void delaySpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_delaySpinnerStateChanged - JSpinner spinner = (JSpinner)evt.getSource(); + JSpinner spinner = (JSpinner) evt.getSource(); - if (workingCell != null) - { - int value = (Integer)spinner.getValue(); + if (workingCell != null) { + int value = (Integer) spinner.getValue(); workingCell.setDelay(value); spinner.setValue(workingCell.getDelay()); } }//GEN-LAST:event_delaySpinnerStateChanged private void playButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_playButtonActionPerformed - Animation animation = getWorkingAnimation(); + Animation animation = getWorkingAnimation(); - animationStripPanel.addAnimationStripListener(this); + animationStripPanel.addAnimationStripListener(this); - boolean playing = animationStripPanel.isPlaying(); + boolean playing = animationStripPanel.isPlaying(); - if (!playing) - animationStripPanel.play(); - else - animationStripPanel.stop(); + if (!playing) { + animationStripPanel.play(); + } else { + animationStripPanel.stop(); + } - removeCellButton.setEnabled(!playing); - addCellButton.setEnabled(!playing); + removeCellButton.setEnabled(!playing); + addCellButton.setEnabled(!playing); }//GEN-LAST:event_playButtonActionPerformed private void spriteTreeValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_spriteTreeValueChanged - + int numSelected = 0; - if (spriteTree.getSelectedNodes() != null) + if (spriteTree.getSelectedNodes() != null) { numSelected = spriteTree.getSelectedNodes().length; - - CustomNode node = (CustomNode)spriteTree.getLastSelectedPathComponent(); + } + + CustomNode node = (CustomNode) spriteTree.getLastSelectedPathComponent(); boolean bSelected = (node != null); - + addToFrameButton.setEnabled(bSelected); - - if (bSelected) - { - if (numSelected == 1 && node.isLeaf()) - { + + if (bSelected) { + if (numSelected == 1 && node.isLeaf()) { spritePreviewTitle.setHorizontalTextPosition(JLabel.LEADING); - SelectionBox spriteArea = (SelectionBox)node.getCustomObject(); + SelectionBox spriteArea = (SelectionBox) node.getCustomObject(); SpriteGraphic graphic = new SpriteGraphic(bufferedImage, new Point(0, 0), spriteArea.getRect()); spritePreviewPanel.setGraphic(graphic); spritePreviewTitle.setText(node.getFullPathName()); - } - else if (numSelected > 1 || !node.isLeaf()) - { + } else if (numSelected > 1 || !node.isLeaf()) { spritePreviewTitle.setHorizontalTextPosition(JLabel.CENTER); spritePreviewTitle.setText(""); spritePreviewPanel.setGraphic(null); } - } - else - { + } else { spritePreviewTitle.setText(" "); spritePreviewPanel.setGraphic(null); } - + spritePreviewPanel.repaint(); }//GEN-LAST:event_spriteTreeValueChanged private void addToFrameButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addToFrameButtonActionPerformed // get selected node - CustomNode selectedNode = (CustomNode)spriteTree.getSelectedNode(); + CustomNode selectedNode = (CustomNode) spriteTree.getSelectedNode(); - cmdManager.execute(new AddSpriteToCellCommand(selectedNode, this, new Point(0,0))); + cmdManager.execute(new AddSpriteToCellCommand(selectedNode, this, new Point(0, 0))); //addNodeToCell(selectedNode, workingCell); }//GEN-LAST:event_addToFrameButtonActionPerformed private void loopSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_loopSpinnerStateChanged - JSpinner spinner = (JSpinner)evt.getSource(); + JSpinner spinner = (JSpinner) evt.getSource(); Animation animation = getWorkingAnimation(); - if (animation != null) - { - int value = (Integer)spinner.getValue(); + if (animation != null) { + int value = (Integer) spinner.getValue(); animation.setLoops(value); spinner.setValue(animation.getLoops()); // verify } @@ -1349,211 +1390,234 @@ private void loopSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-F private void removeSpriteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeSpriteButtonActionPerformed Animation animation = getWorkingAnimation(); - AnimationCell cell = animationStripPanel.selectedCell(); + AnimationCell cell = animationStripPanel.selectedCell(); ArrayList selectedGraphics = viewPanel.selectedGraphics(); ArrayList commands = new ArrayList(); - for (int i=0; i selectedGraphics = viewPanel.selectedGraphics(); - + cmdManager.execute(new RotateGraphicListCommand(selectedGraphics, 90.0f, viewPanel)); - + this.getWorkingCell().rebuild(); repaint(); }//GEN-LAST:event_rotateCWButtonActionPerformed private void rotateACWButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rotateACWButtonActionPerformed ArrayList selectedGraphics = viewPanel.selectedGraphics(); - + cmdManager.execute(new RotateGraphicListCommand(selectedGraphics, -90.0f, viewPanel)); - + this.getWorkingCell().rebuild(); repaint();}//GEN-LAST:event_rotateACWButtonActionPerformed private void zOrderSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_zOrderSpinnerStateChanged - + ArrayList selectedGraphics = viewPanel.selectedGraphics(); AnimationCell cell = this.getWorkingCell(); - - if (cell != null && selectedGraphics != null && selectedGraphics.size() > 0) - { + + if (cell != null && selectedGraphics != null && selectedGraphics.size() > 0) { ArrayList commands = new ArrayList(); - - for (int i=0; i selected = null; - - if (aCell == getWorkingCell()) + + if (aCell == getWorkingCell()) { selected = viewPanel.selectedGraphics(); - - DefaultListModel model = (DefaultListModel)spriteList.getModel(); + } + + DefaultListModel model = (DefaultListModel) spriteList.getModel(); model.clear(); - - if (aCell != null) - { + + if (aCell != null) { ArrayList array = aCell.getGraphicList(); - for (int i=0; i commands = new ArrayList(); AnimationCell cell = this.getWorkingCell(); - - if (cell != null && _rotatingGraphics != null && _rotatingGraphics.size() > 0) - { - for (int i=0; i<_rotatingGraphics.size(); ++i) - { + + if (cell != null && _rotatingGraphics != null && _rotatingGraphics.size() > 0) { + for (int i = 0; i < _rotatingGraphics.size(); ++i) { Integer val = null; - try - { - val = (Integer)angleSpinner.getValue(); + try { + val = (Integer) angleSpinner.getValue(); + } catch (NumberFormatException exc) { } - catch (NumberFormatException exc){} - if (val != null) - { + if (val != null) { int value = val.intValue(); GraphicObject graphic = _rotatingGraphics.get(i); - if (value != graphic.getSavedAngle()) - { - commands.add(new SetGraphicAngleCommand(graphic, value, viewPanel)); + if (value != graphic.getSavedAngle()) { + commands.add(new SetGraphicAngleCommand(graphic, value, viewPanel)); + } + } + } + } + + if (cell != null && _scalingGraphics != null && _scalingGraphics.size() > 0) { + for (int i = 0; i < _scalingGraphics.size(); ++i) { + Integer val = null; + + try { + val = (Integer) scaleSpinner.getValue(); + } catch (NumberFormatException exc) { + } + + if (val != null) { + int value = val.intValue(); + GraphicObject graphic = _scalingGraphics.get(i); + + if (value != graphic.getSavedScale()) { + commands.add(new SetGraphicScaleCommand(graphic, value, viewPanel)); + } + } + } + } + + if (cell != null && _opacityGraphics != null && _opacityGraphics.size() > 0) { + for (int i = 0; i < _opacityGraphics.size(); ++i) { + Integer val = null; + + try { + val = (Integer) opacitySpinner.getValue(); + } catch (NumberFormatException exc) { + } + + if (val != null) { + int value = val.intValue(); + GraphicObject graphic = _opacityGraphics.get(i); + + if (value != graphic.getSavedOpacity()) { + commands.add(new SetGraphicOpacityCommand(graphic, value, viewPanel)); } } } } GroupedUndoableCommand groupedCommand = new GroupedUndoableCommand(commands); - if (cmdManager != null) + if (cmdManager != null) { cmdManager.execute(groupedCommand); - else + } else { groupedCommand.execute(); - - this.setModified(true); - + } + + this.setModified(true); + getWorkingCell().rebuild(); animationStripPanel.repaint(); - + _rotatingGraphics = null; + _scalingGraphics = null; + _opacityGraphics = null; + _idGraphics = null; } - + private void angleSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_angleSpinnerStateChanged - - if (spinnerStateTimer == null) - { + + if (spinnerStateTimer == null) { spinnerStateTimer = new Timer(400, this); spinnerStateTimer.setRepeats(false); spinnerStateTimer.setActionCommand(null); } - - if (!spinnerStateTimer.isRunning()) - { - spinnerStateTimer.start(); - } - else + + if (!spinnerStateTimer.isRunning()) { + spinnerStateTimer.start(); + } else { spinnerStateTimer.restart(); - + } + _rotatingGraphics = viewPanel.selectedGraphics(); - AnimationCell cell = this.getWorkingCell(); - if (cell != null && _rotatingGraphics != null && _rotatingGraphics.size() > 0) - { - for (int i=0; i<_rotatingGraphics.size(); ++i) - { + AnimationCell cell = this.getWorkingCell(); + if (cell != null && _rotatingGraphics != null && _rotatingGraphics.size() > 0) { + for (int i = 0; i < _rotatingGraphics.size(); ++i) { Integer val = null; - - try - { - val = (Integer)angleSpinner.getValue(); + + try { + val = (Integer) angleSpinner.getValue(); + } catch (NumberFormatException exc) { } - catch (NumberFormatException exc){} - - if (val != null) - { + + if (val != null) { int value = val.intValue(); GraphicObject graphic = _rotatingGraphics.get(i); - - if (value != graphic.getAngle()) - { + + if (value != graphic.getAngle()) { graphic.setAngle(value); } } @@ -1563,28 +1627,32 @@ private void angleSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN- }//GEN-LAST:event_angleSpinnerStateChanged private void flipHCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_flipHCheckBoxActionPerformed - ArrayList selectedGraphics = viewPanel.selectedGraphics(); - - if (selectedGraphics != null) + ArrayList selectedGraphics = viewPanel.selectedGraphics(); + + if (selectedGraphics != null) { cmdManager.execute(new FlipSpriteListCommand(selectedGraphics, true, viewPanel)); - + } + AnimationCell cell = this.getWorkingCell(); - if (cell != null) + if (cell != null) { cell.rebuild(); - + } + repaint(); }//GEN-LAST:event_flipHCheckBoxActionPerformed private void flipVCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_flipVCheckBoxActionPerformed - ArrayList selectedGraphics = viewPanel.selectedGraphics(); - - if (selectedGraphics != null) + ArrayList selectedGraphics = viewPanel.selectedGraphics(); + + if (selectedGraphics != null) { cmdManager.execute(new FlipSpriteListCommand(selectedGraphics, false, viewPanel)); - + } + AnimationCell cell = this.getWorkingCell(); - if (cell != null) + if (cell != null) { cell.rebuild(); - + } + repaint(); }//GEN-LAST:event_flipVCheckBoxActionPerformed @@ -1598,11 +1666,10 @@ private void spriteListToggleActionPerformed(java.awt.event.ActionEvent evt) {// private void duplicateAnimationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_duplicateAnimationButtonActionPerformed Animation currentAnimation = this.getWorkingAnimation(); - - if (currentAnimation != null) - { - Animation copy = currentAnimation.copy(); - this.addAnimation(copy); + + if (currentAnimation != null) { + Animation copy = currentAnimation.copy(); + this.addAnimation(copy); } }//GEN-LAST:event_duplicateAnimationButtonActionPerformed @@ -1610,8 +1677,104 @@ private void exportGifButtonActionPerformed(java.awt.event.ActionEvent evt) {//G saveGifAs(); }//GEN-LAST:event_exportGifButtonActionPerformed - public void saveGifAs() - { + private void scaleSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_scaleSpinnerStateChanged + if (spinnerStateTimer == null) { + spinnerStateTimer = new Timer(400, this); + spinnerStateTimer.setRepeats(false); + spinnerStateTimer.setActionCommand(null); + } + + if (!spinnerStateTimer.isRunning()) { + spinnerStateTimer.start(); + } else { + spinnerStateTimer.restart(); + } + + _scalingGraphics = viewPanel.selectedGraphics(); + AnimationCell cell = this.getWorkingCell(); + if (cell != null && _scalingGraphics != null && _scalingGraphics.size() > 0) { + for (int i = 0; i < _scalingGraphics.size(); ++i) { + Integer val = null; + + try { + val = (Integer) scaleSpinner.getValue(); + } catch (NumberFormatException exc) { + } + + if (val != null) { + int value = val.intValue(); + GraphicObject graphic = _scalingGraphics.get(i); + + if (value != graphic.getAngle()) { + graphic.setScale(value); + } + } + } + viewPanel.repaint(); + } + }//GEN-LAST:event_scaleSpinnerStateChanged + + private void opacitySpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_opacitySpinnerStateChanged + if (spinnerStateTimer == null) { + spinnerStateTimer = new Timer(400, this); + spinnerStateTimer.setRepeats(false); + spinnerStateTimer.setActionCommand(null); + } + + if (!spinnerStateTimer.isRunning()) { + spinnerStateTimer.start(); + } else { + spinnerStateTimer.restart(); + } + + _opacityGraphics = viewPanel.selectedGraphics(); + AnimationCell cell = this.getWorkingCell(); + if (cell != null && _opacityGraphics != null && _opacityGraphics.size() > 0) { + for (int i = 0; i < _opacityGraphics.size(); ++i) { + Integer val = null; + + try { + val = (Integer) opacitySpinner.getValue(); + } catch (NumberFormatException exc) { + } + + if (val != null) { + int value = val.intValue(); + GraphicObject graphic = _opacityGraphics.get(i); + + if (value != graphic.getAngle()) { + graphic.setOpacity(value); + } + } + } + viewPanel.repaint(); + } + }//GEN-LAST:event_opacitySpinnerStateChanged + + private void idTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_idTextFieldFocusLost + onIdTextFieldChanged(evt); + }//GEN-LAST:event_idTextFieldFocusLost + + private void idTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idTextFieldActionPerformed + onIdTextFieldChanged(evt); + }//GEN-LAST:event_idTextFieldActionPerformed + + private void onIdTextFieldChanged(java.awt.event.ActionEvent evt) { + ArrayList selectedGraphics = viewPanel.selectedGraphics(); + + if (selectedGraphics != null) { + cmdManager.execute(new SetSpriteListIdCommand(selectedGraphics, idTextField.getText(), viewPanel)); + } + + AnimationCell cell = this.getWorkingCell(); + if (cell != null) { + cell.rebuild(); + } + + repaint(); + } + + public void saveGifAs() { JFileChooser chooser = fileChooser; CustomFilter filter = new CustomFilter(); @@ -1622,105 +1785,94 @@ public void saveGifAs() chooser.setApproveButtonText("Export"); chooser.setDialogTitle("Export animation as GIF"); chooser.setSelectedFile(new File(this.getWorkingAnimation().getName() + "." + CustomFilter.EXT_GIF)); - + JFrame mainFrame = dfEditorApp.getApplication().getMainFrame(); - while (true) - { + while (true) { int returnVal = chooser.showSaveDialog(mainFrame); - if(returnVal == JFileChooser.APPROVE_OPTION) - { + if (returnVal == JFileChooser.APPROVE_OPTION) { java.io.File f = chooser.getSelectedFile(); - if(null == dfEditor.io.Utils.getExtension(f)) - { + if (null == dfEditor.io.Utils.getExtension(f)) { f = new java.io.File(new String(f.getAbsolutePath() + "." + filter.getExtension())); } - if (f.exists()) - { + if (f.exists()) { //Custom button text - int response = JOptionPane.showConfirmDialog (null, - "Overwrite existing file?","Confirm Overwrite", - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.WARNING_MESSAGE); - if (response == JOptionPane.CANCEL_OPTION) + int response = JOptionPane.showConfirmDialog(null, + "Overwrite existing file?", "Confirm Overwrite", + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.WARNING_MESSAGE); + if (response == JOptionPane.CANCEL_OPTION) { continue; + } } - buildAnimatedGif(f.getAbsolutePath()); + buildAnimatedGif(f.getAbsolutePath()); } break; - } + } } - - public void animatedToCell(AnimationCell aCell) - { + + public void animatedToCell(AnimationCell aCell) { animationPanel1.setCell(aCell); } - - private void setOnionSkins(boolean bOn) - { - if (!bOn) - { - viewPanel.setOnionSkins(null); + + private void setOnionSkins(boolean bOn) { + if (!bOn) { + viewPanel.setOnionSkins(null); return; } - + Animation animation = this.getWorkingAnimation(); AnimationCell[] cells = null; - - if (animation != null) - { + + if (animation != null) { int currentIndex = animation.indexOfCell(workingCell); - if (currentIndex > 0) - { + if (currentIndex > 0) { cells = new AnimationCell[currentIndex]; - for (int i=0; i list = new ArrayList(); - for (int i=0; i animations = null; - try - { + try { animations = aReader.getAnimations(spriteTree, bufferedImage); - } - catch (Exception e) - { - showParseError(); + } catch (Exception e) { + showParseError(); } - if (animations != null) - { - for (int i=0; i= 0); addCellButton.setEnabled(true); } - - private void updateControlPanel(GraphicPanel aPanel) - { + + private void updateControlPanel(GraphicPanel aPanel) { ArrayList sprites = aPanel.selectedGraphics(); boolean bEnabled = (sprites.size() > 0); - + //try { - //controlPanel.setSelected(bEnabled); // steals focus - modifySpriteToggle.setSelected(controlPanel.isVisible()); + //controlPanel.setSelected(bEnabled); // steals focus + modifySpriteToggle.setSelected(controlPanel.isVisible()); //} catch (java.beans.PropertyVetoException e) {} - + removeSpriteButton.setEnabled(bEnabled); rotateACWButton.setEnabled(bEnabled); rotateCWButton.setEnabled(bEnabled); zOrderSpinner.setEnabled(bEnabled); angleSpinner.setEnabled(bEnabled); + idTextField.setEnabled(bEnabled); + scaleSpinner.setEnabled(bEnabled); + opacitySpinner.setEnabled(bEnabled); flipVCheckBox.setEnabled(bEnabled); flipHCheckBox.setEnabled(bEnabled); - + boolean bSetZ = true; boolean bSetA = true; - + boolean bSetS = true; + boolean bSetO = true; + boolean bSetI = true; + AnimationCell cell = this.getWorkingCell(); - for (int i=0; i 0) - { - if ( cell.zOrderOfGraphic(sprites.get(i)) - != cell.zOrderOfGraphic(sprites.get(i-1))) - { - zOrderSpinner.setValue(null); - bSetZ = false; + for (int i = 0; i < sprites.size(); ++i) { + if (i > 0) { + if (cell.zOrderOfGraphic(sprites.get(i)) + != cell.zOrderOfGraphic(sprites.get(i - 1))) { + zOrderSpinner.setValue(null); + bSetZ = false; + } + + if ((int) sprites.get(i).getAngle() != (int) sprites.get(i - 1).getAngle()) { + bSetA = false; + } + + if ((int)(sprites.get(i).getScale()) != (int)(sprites.get(i - 1).getScale())) { + bSetS = false; } - if ((int)sprites.get(i).getAngle() != (int)sprites.get(i-1).getAngle()) - { - bSetA = false; + if ((int)(sprites.get(i).getOpacity()) != (int)(sprites.get(i - 1).getOpacity())) { + bSetO = false; } + + if (!sprites.get(i).getId().equals(sprites.get(i - 1).getId())) { + bSetI = false; + } } } - + //zOrderSpinner.setEnabled(bSetZ); - - for (int i=0; i aGraphics) - { + public void graphicsErased(GraphicPanel aPanel, ArrayList aGraphics) { Animation animation = getWorkingAnimation(); - AnimationCell cell = animationStripPanel.selectedCell(); - + AnimationCell cell = animationStripPanel.selectedCell(); + ArrayList commands = new ArrayList(); - for (int i=0; i 0) - { - Animation selectedAnimation = (Animation)model.get(selectedIndices[0]); + if (list == animationList) { + DefaultMutableListModel model = (DefaultMutableListModel) list.getModel(); + + if (selectedIndices.length > 0) { + Animation selectedAnimation = (Animation) model.get(selectedIndices[0]); selectedAnimation.setCurrentCellIndex(0); setWorkingCell(selectedAnimation.getCurrentCell()); animationStripPanel.setAnimation(selectedAnimation); @@ -1988,9 +2144,7 @@ public void valueChanged(ListSelectionEvent e) playButton.setEnabled(selectedAnimation.numCells() > 1); loopSpinner.setEnabled(true); loopSpinner.setValue(selectedAnimation.getLoops()); - } - else - { + } else { spriteTree.setSelectionPath(null); setWorkingCell(null); animationStripPanel.setAnimation(null); @@ -2001,40 +2155,32 @@ public void valueChanged(ListSelectionEvent e) loopSpinner.setEnabled(false); } - boolean bEnabled = (! ((DefaultMutableListModel)list.getModel()).isEmpty()) && (list.getSelectedIndex() >= 0); + boolean bEnabled = (!((DefaultMutableListModel) list.getModel()).isEmpty()) && (list.getSelectedIndex() >= 0); removeAnimationButton.setEnabled(bEnabled); duplicateAnimationButton.setEnabled(bEnabled); exportGifButton.setEnabled(bEnabled); - } - else if (list == spriteList) - { - DefaultListModel model = (DefaultListModel)spriteList.getModel(); - for (int i=0; i= max.intValue()) - { + } + if (i.intValue() >= max.intValue()) { return new Integer(i.intValue() % max.intValue()); } - + return i; } - - public Object getPreviousValue() - { + + public Object getPreviousValue() { Object o = super.getPreviousValue(); - if (o != null) + if (o != null) { return o; - - return new Integer (((Integer)this.getMaximum()).intValue() - this.getStepSize().intValue()); - + } + + return new Integer(((Integer) this.getMaximum()).intValue() - this.getStepSize().intValue()); + } } - - private class CustomSpinModel extends AbstractSpinnerModel - { + + private class CustomSpinModel extends AbstractSpinnerModel { + protected String value = ""; - public void setValue(Object o) - { - if (o != null) - value = o.toString(); - else - value = " "; - + public void setValue(Object o) { + if (o != null) { + value = o.toString(); + } else { + value = " "; + } + fireStateChanged(); } - public Object getValue() { return value; } + public Object getValue() { + return value; + } - public Object getPreviousValue() - { + public Object getPreviousValue() { Integer i = parse(); - if (i == null) return "0"; // default to 0 from indeterminate - else return "" + (i.intValue() - 1); + if (i == null) { + return "0"; // default to 0 from indeterminate + } else { + return "" + (i.intValue() - 1); + } } - public Object getNextValue() - { + public Object getNextValue() { Integer i = parse(); - if (i == null) return "0"; // default to 0 from indeterminate - else return "" + (i.intValue() + 1); + if (i == null) { + return "0"; // default to 0 from indeterminate + } else { + return "" + (i.intValue() + 1); + } } - private Integer parse() - { - try { return new Integer(value); } - catch (NumberFormatException exc) { return null; } + private Integer parse() { + try { + return new Integer(value); + } catch (NumberFormatException exc) { + return null; + } } } - - + + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton addAnimationButton; private javax.swing.JButton addCellButton; @@ -2144,6 +2309,8 @@ private Integer parse() private javax.swing.JButton exportGifButton; private javax.swing.JCheckBox flipHCheckBox; private javax.swing.JCheckBox flipVCheckBox; + private javax.swing.JLabel idLabel; + private javax.swing.JTextField idTextField; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; @@ -2152,6 +2319,7 @@ private Integer parse() private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; @@ -2160,12 +2328,16 @@ private Integer parse() private javax.swing.JSpinner loopSpinner; private javax.swing.JToggleButton modifySpriteToggle; private javax.swing.JCheckBox onionSkinsCheckBox; + private javax.swing.JLabel opacityLabel; + private javax.swing.JSpinner opacitySpinner; private javax.swing.JButton playButton; private javax.swing.JButton removeAnimationButton; private javax.swing.JButton removeCellButton; private javax.swing.JButton removeSpriteButton; private javax.swing.JButton rotateACWButton; private javax.swing.JButton rotateCWButton; + private javax.swing.JLabel scaleLabel; + private javax.swing.JSpinner scaleSpinner; private dfEditor.SpriteList spriteList; private javax.swing.JInternalFrame spriteListControlPanel; private javax.swing.JToggleButton spriteListToggle; diff --git a/src/dfEditor/animation/resources/AnimationController.properties b/src/dfEditor/animation/resources/AnimationController.properties index 7d79e0d..3112cfe 100644 --- a/src/dfEditor/animation/resources/AnimationController.properties +++ b/src/dfEditor/animation/resources/AnimationController.properties @@ -77,3 +77,8 @@ duplicateAnimationButton.icon=/dfEditor/resources/main_icons/copy.png exportGif.icon=/dfEditor/resources/main_icons/Star.png exportGifButton.toolTipText=Export GIF... exportGifButton.text=\ +idTextField.text= +idLabel.text=ID +idTextField.toolTipText= +scaleLabel.text=Scale +opacityLabel.text=Opacity diff --git a/src/dfEditor/commands/SetGraphicIdCommand.java b/src/dfEditor/commands/SetGraphicIdCommand.java new file mode 100644 index 0000000..c536f6f --- /dev/null +++ b/src/dfEditor/commands/SetGraphicIdCommand.java @@ -0,0 +1,57 @@ +/* + * Copyright 2012 Samuel Taylor + * + * This file is part of darkFunction Editor + * + * darkFunction Editor 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 3 of the License, or + * (at your option) any later version. + * + * darkFunction Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with darkFunction Editor. If not, see . + */ + +package dfEditor.commands; + +import dfEditor.*; +import dfEditor.command.UndoableCommand; + +/** + * + * @author Sam + */ +public class SetGraphicIdCommand extends UndoableCommand +{ + private String _id; + private String _oldId; + private GraphicObject _graphic; + private GraphicPanel _panel; + + public SetGraphicIdCommand(final GraphicObject aGraphic, final String id, final GraphicPanel aPanel) + { + _graphic = aGraphic; + _id = id; + _oldId = _graphic.getSavedId(); + _panel = aPanel; + } + + public boolean execute() + { + _graphic.setId(_id); + _graphic.saveId(); + + return true; + } + + public void undo() + { + _graphic.setId(_oldId); + _graphic.saveId(); + } +} diff --git a/src/dfEditor/commands/SetGraphicOpacityCommand.java b/src/dfEditor/commands/SetGraphicOpacityCommand.java new file mode 100644 index 0000000..8434188 --- /dev/null +++ b/src/dfEditor/commands/SetGraphicOpacityCommand.java @@ -0,0 +1,61 @@ +/* + * Copyright 2012 Samuel Taylor + * + * This file is part of darkFunction Editor + * + * darkFunction Editor 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 3 of the License, or + * (at your option) any later version. + * + * darkFunction Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with darkFunction Editor. If not, see . + */ + +package dfEditor.commands; + +import dfEditor.*; +import dfEditor.command.UndoableCommand; + +/** + * + * @author Sam + */ +public class SetGraphicOpacityCommand extends UndoableCommand +{ + private float _opacity; + private float _oldOpacity; + private GraphicObject _graphic; + private GraphicPanel _panel; + + public SetGraphicOpacityCommand(final GraphicObject aGraphic, final float opacity, final GraphicPanel aPanel) + { + _graphic = aGraphic; + _opacity = opacity; + _oldOpacity = _graphic.getSavedOpacity(); + _panel = aPanel; + } + + public boolean execute() + { + _graphic.setOpacity(_opacity); + _graphic.saveOpacity(); + + _panel.notifyGraphicMoved(_graphic); + + return true; + } + + public void undo() + { + _graphic.setOpacity(_oldOpacity); + _graphic.saveOpacity(); + + _panel.notifyGraphicMoved(_graphic); + } +} diff --git a/src/dfEditor/commands/SetGraphicScaleCommand.java b/src/dfEditor/commands/SetGraphicScaleCommand.java new file mode 100644 index 0000000..d48c079 --- /dev/null +++ b/src/dfEditor/commands/SetGraphicScaleCommand.java @@ -0,0 +1,61 @@ +/* + * Copyright 2012 Samuel Taylor + * + * This file is part of darkFunction Editor + * + * darkFunction Editor 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 3 of the License, or + * (at your option) any later version. + * + * darkFunction Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with darkFunction Editor. If not, see . + */ + +package dfEditor.commands; + +import dfEditor.*; +import dfEditor.command.UndoableCommand; + +/** + * + * @author Sam + */ +public class SetGraphicScaleCommand extends UndoableCommand +{ + private float _scale; + private float _oldScale; + private GraphicObject _graphic; + private GraphicPanel _panel; + + public SetGraphicScaleCommand(final GraphicObject aGraphic, final float scale, final GraphicPanel aPanel) + { + _graphic = aGraphic; + _scale = scale; + _oldScale = _graphic.getSavedScale(); + _panel = aPanel; + } + + public boolean execute() + { + _graphic.setScale(_scale); + _graphic.saveScale(); + + _panel.notifyGraphicMoved(_graphic); + + return true; + } + + public void undo() + { + _graphic.setScale(_oldScale); + _graphic.saveScale(); + + _panel.notifyGraphicMoved(_graphic); + } +} diff --git a/src/dfEditor/commands/SetSpriteListIdCommand.java b/src/dfEditor/commands/SetSpriteListIdCommand.java new file mode 100644 index 0000000..0f6128a --- /dev/null +++ b/src/dfEditor/commands/SetSpriteListIdCommand.java @@ -0,0 +1,59 @@ +/* + * Copyright 2012 Samuel Taylor + * + * This file is part of darkFunction Editor + * + * darkFunction Editor 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 3 of the License, or + * (at your option) any later version. + * + * darkFunction Editor is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with darkFunction Editor. If not, see . + */ + +package dfEditor.commands; + +import java.util.ArrayList; +import dfEditor.command.*; +import dfEditor.commands.*; +import dfEditor.*; + +public class SetSpriteListIdCommand extends UndoableCommand +{ + private ArrayList _commands = new ArrayList(); + + public SetSpriteListIdCommand(ArrayList aGraphics, String sId, final GraphicPanel aPanel) + { + if (aGraphics != null) + { + for (int i=0; i=0; --i) + _commands.get(i).undo(); + } +} + diff --git a/src/dfEditor/io/AnimationSetReader.java b/src/dfEditor/io/AnimationSetReader.java index f464618..c2c3d81 100644 --- a/src/dfEditor/io/AnimationSetReader.java +++ b/src/dfEditor/io/AnimationSetReader.java @@ -142,6 +142,10 @@ public ArrayList getAnimations(SpriteTree aSpriteTree, BufferedImage SpriteGraphic graphic = new SpriteGraphic(aImage, new Point(x, y), r); + String id = ((Element)spriteNode).getAttribute("id"); + graphic.setId(id); + graphic.saveId(); + float angle = 0; String angleString = ((Element)spriteNode).getAttribute("angle"); if (angleString != null && angleString.length() != 0) @@ -149,6 +153,20 @@ public ArrayList getAnimations(SpriteTree aSpriteTree, BufferedImage graphic.setAngle(angle); graphic.saveAngle(); + float scale = 100; + String scaleString = ((Element)spriteNode).getAttribute("scale"); + if (scaleString != null && scaleString.length() != 0) + scale = Float.parseFloat(scaleString); + graphic.setScale(scale); + graphic.saveScale(); + + float opacity = 255; + String opacityString = ((Element)spriteNode).getAttribute("opacity"); + if (opacityString != null && opacityString.length() != 0) + opacity = Float.parseFloat(opacityString); + graphic.setOpacity(opacity); + graphic.saveOpacity(); + boolean flipH = false; boolean flipV = false; diff --git a/src/dfEditor/io/AnimationSetWriter.java b/src/dfEditor/io/AnimationSetWriter.java index b797f2b..58a2942 100644 --- a/src/dfEditor/io/AnimationSetWriter.java +++ b/src/dfEditor/io/AnimationSetWriter.java @@ -102,6 +102,12 @@ private void writeAnimToXml(XmlWriter aXmlWriter, Animation aAnimation) throws I if (graphic.getAngle() != 0) aXmlWriter.writeAttribute("angle", graphic.getAngle()); + if (graphic.getScale() != 100) + aXmlWriter.writeAttribute("scale", graphic.getScale()); + if (graphic.getOpacity() != 255) + aXmlWriter.writeAttribute("opacity", graphic.getOpacity()); + if (graphic.getId().length() > 0) + aXmlWriter.writeAttribute("id", graphic.getId()); if (graphic.isFlippedV()) aXmlWriter.writeAttribute("flipV", graphic.isFlippedV() ? 1 : 0); if (graphic.isFlippedH())