Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/dfEditor/animation/AnimationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ private void initComponents() {
jPanel2 = new javax.swing.JPanel();
animationPanel1 = new dfEditor.animation.AnimationPanel();
playButton = new javax.swing.JButton();
previewDelaySpinner = new javax.swing.JSpinner();
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
delaySpinner = new javax.swing.JSpinner();
Expand Down Expand Up @@ -512,18 +513,31 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});

// Set the preview delay to something sensible (default was 30 before)
previewDelaySpinner.setValue(500);
previewDelaySpinner.setMaximumSize(new java.awt.Dimension(30, 30));
previewDelaySpinner.setName("previewDelayspinner"); // NOI18N
previewDelaySpinner.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
// TODO: loopSpinnerStateChanged(evt);
}
});


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)
.addComponent(previewDelaySpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.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)
.addComponent(previewDelaySpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(playButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
);

Expand Down Expand Up @@ -1265,21 +1279,19 @@ private void delaySpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-

if (workingCell != null)
{
int value = (Integer)spinner.getValue();
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();

animationStripPanel.addAnimationStripListener(this);

boolean playing = animationStripPanel.isPlaying();

if (!playing)
animationStripPanel.play();
animationStripPanel.play((Integer) previewDelaySpinner.getValue());
else
animationStripPanel.stop();

Expand Down Expand Up @@ -2161,6 +2173,7 @@ private Integer parse()
private javax.swing.JToggleButton modifySpriteToggle;
private javax.swing.JCheckBox onionSkinsCheckBox;
private javax.swing.JButton playButton;
private javax.swing.JSpinner previewDelaySpinner;
private javax.swing.JButton removeAnimationButton;
private javax.swing.JButton removeCellButton;
private javax.swing.JButton removeSpriteButton;
Expand Down
19 changes: 11 additions & 8 deletions src/dfEditor/animation/AnimationStripPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,14 @@ private int getSelectedSlotIndex()
return -1;
}

public void play()
public void play(int timeout)
{
if (slotList.size() == 0)
return;

currentLoop = animation.getLoops();

if (timer == null)
timer = new Timer(30, this);

timer = new Timer(timeout, this);
timer.start();

currentSlotInAnimation = getSelectedSlotIndex();
Expand All @@ -358,9 +356,11 @@ public void play()

public void stop()
{
if (timer != null)
if (timer != null) {
timer.stop();

timer = null;
}

currentSlotInAnimation = -1;

repaint();
Expand Down Expand Up @@ -400,13 +400,16 @@ private void notifyTick()
{
currentSlotInAnimation = 0;
}

for (int i=0; i<stripListeners.size(); ++i)
{
stripListeners.get(i).animatedToCell(slotList.get(currentSlotInAnimation).getCell());
}
}

/**
* Triggered by timer to refresh current frame in preview.
*/
public void actionPerformed(ActionEvent e)
{
currentSlotInAnimationFramesLeft --;
Expand Down