various small fixes

This commit is contained in:
honfika@gmail.com
2015-04-25 20:21:10 +02:00
parent 2900dd90e0
commit e700f91bf7
8 changed files with 59 additions and 28 deletions

View File

@@ -194,7 +194,7 @@ public final class SWF implements SWFContainerItem, Timelined {
public List<Tag> tags = new ArrayList<>();
@Internal
public boolean hasEndTag;
public boolean hasEndTag = true;
/**
* ExportRectangle for the display

View File

@@ -313,18 +313,6 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli
return getTimeline().getFrameCount(); // frameCount
}
private int getRealFrameCount() {
int cnt = 1;
Timeline timeline = getTimeline();
for (int i = 1; i < timeline.getFrameCount(); i++) {
if (timeline.getFrame(i).layersChanged) {
cnt++;
}
}
return cnt;
}
@Override
public boolean isSingleFrame() {
if (!isSingleFrameInitialized) {
@@ -335,7 +323,7 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli
private synchronized void initialiteIsSingleFrame() {
if (!isSingleFrameInitialized) {
if (getRealFrameCount() > 1) {
if (getTimeline().getRealFrameCount() > 1) {
isSingleFrameInitialized = true;
return;
}

View File

@@ -159,6 +159,19 @@ public class Timeline {
return frames.size();
}
public int getRealFrameCount() {
ensureInitialized();
int cnt = 1;
for (int i = 1; i < frames.size(); i++) {
if (frames.get(i).layersChanged) {
cnt++;
}
}
return cnt;
}
public int getFrameForAction(ASMSource asm) {
Integer frame = actionFrames.get(asm);
if (frame == null) {

View File

@@ -916,7 +916,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
int msPerFrame = frameRate == 0 ? 1000 : 1000 / frameRate;
final int cnt = counter;
final boolean singleFrame = timeline.getFrameCount() <= 1 && timeline.isSingleFrame();
final boolean singleFrame = timeline.getRealFrameCount() <= 1 && timeline.isSingleFrame();
shouldDraw.set(true);
startTimer(cnt, singleFrame, msPerFrame);
}

View File

@@ -139,4 +139,16 @@ public class LoadingPanel extends JPanel {
g2.setTransform(t);
g2.drawImage(lastImage, 0, 0, this);
}
@Override
public void setVisible(boolean visible) {
if (!visible) {
if (drawTimer != null) {
drawTimer.cancel();
drawTimer = null;
}
}
super.setVisible(visible);
}
}

View File

@@ -439,9 +439,11 @@ public class Main {
} catch (OutOfMemoryError ex) {
logger.log(Level.SEVERE, null, ex);
View.showMessageDialog(null, "Cannot load SWF file. Out of memory.");
continue;
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
View.showMessageDialog(null, "Cannot load SWF file.");
continue;
}
final SWFList swfs1 = swfs;
@@ -1106,7 +1108,10 @@ public class Main {
MainPanel mainPanel = mainFrame.getPanel();
TreePath tp = View.getTreePathByPathStrings(mainPanel.tagTree, Arrays.asList(path));
mainPanel.setTagTreeSelectedNode((TreeItem) tp.getLastPathComponent());
if (tp != null) {
// the current view is the Resources view, otherwise tp is null
mainPanel.setTagTreeSelectedNode((TreeItem) tp.getLastPathComponent());
}
}
});
}

View File

@@ -538,6 +538,10 @@ public class View {
public static TreePath getTreePathByPathStrings(JTree tree, List<String> pathAsStringList) {
TreeModel model = tree.getModel();
if (model == null) {
return null;
}
Object node = model.getRoot();
if (pathAsStringList.isEmpty()) {

View File

@@ -184,21 +184,30 @@ public final class FlashPlayerPanel extends Panel implements Closeable, MediaDis
@Override
public void run() {
boolean changed = false;
try {
ShockwaveFlash flash1 = flash;
if (flash1 == null) {
return;
}
boolean isPlaying = flash.IsPlaying();
if (this.isPlaying != isPlaying) {
this.isPlaying = isPlaying;
}
boolean changed = false;
int currentFrame = flash.CurrentFrame();
if (this.currentFrame != currentFrame) {
this.currentFrame = currentFrame;
changed = true;
}
boolean isPlaying = flash1.IsPlaying();
if (this.isPlaying != isPlaying) {
this.isPlaying = isPlaying;
}
if (changed) {
fireMediaDisplayStateChanged();
int currentFrame = flash1.CurrentFrame();
if (this.currentFrame != currentFrame) {
this.currentFrame = currentFrame;
changed = true;
}
if (changed) {
fireMediaDisplayStateChanged();
}
} catch (Exception ex) {
// ignore
}
}
}, 100, 100);