small improvements

This commit is contained in:
2015-02-01 20:09:57 +01:00
parent 0f842eb178
commit ad7148f539
15 changed files with 145 additions and 86 deletions
@@ -338,7 +338,7 @@ public class AdvancedSettingsDialog extends AppDialog implements ActionListener
if (!((JTextField) c).getText().isEmpty()) {
c.requestFocusInWindow();
return;
}//else null
} // else null
}
values.put(name, value);
}
@@ -356,8 +356,10 @@ public class AdvancedSettingsDialog extends AppDialog implements ActionListener
throw new Error(ex.getMessage());
}
if (item.get() == null || !item.get().equals(value)) {
item.set(value);
modified = true;
if (item.hasValue() || value != null) {
item.set(value);
modified = true;
}
}
}
Configuration.saveConfig();
@@ -320,7 +320,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
private void showSelectedName() {
if (selectedDepth > -1 && frame > -1) {
DepthState ds = timelined.getTimeline().getFrames().get(frame).layers.get(selectedDepth);
DepthState ds = timelined.getTimeline().getFrame(frame).layers.get(selectedDepth);
if (ds != null) {
CharacterTag cht = timelined.getTimeline().swf.getCharacter(ds.characterId);
if (cht != null) {
@@ -524,7 +524,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
loaded = true;
if (drawable.getTimeline().getFrames().isEmpty()) {
if (drawable.getTimeline().getFrameCount() == 0) {
clearImagePanel();
return;
}
@@ -691,7 +691,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
gg.setTransform(AffineTransform.getTranslateInstance(0, 0));
List<DepthState> dss = new ArrayList<>();
List<Shape> os = new ArrayList<>();
DepthState ds = drawable.getTimeline().getFrames().get(frame).layers.get(selectedDepth);
DepthState ds = drawable.getTimeline().getFrame(frame).layers.get(selectedDepth);
if (ds != null) {
CharacterTag cht = swf.getCharacter(ds.characterId);
if (cht != null) {
@@ -146,7 +146,7 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
try {
PosMarkedInputStream pmi = new PosMarkedInputStream(ret.get(addr));
ReReadableInputStream is = new ReReadableInputStream(pmi);
SWF swf = new SWF(is, null, false, true);
SWF swf = new SWF(is, null, null, null, false, true);
long limit = pmi.getPos();
is.seek(0);
is = new ReReadableInputStream(new LimitedInputStream(is, limit));
+5 -9
View File
@@ -341,24 +341,21 @@ public class Main {
for (Entry<String, SeekableInputStream> streamEntry : bundle.getAll().entrySet()) {
InputStream stream = streamEntry.getValue();
stream.reset();
SWF swf = new SWF(stream, new ProgressListener() {
SWF swf = new SWF(stream, null, streamEntry.getKey(), new ProgressListener() {
@Override
public void progress(int p) {
startWork(AppStrings.translate("work.reading.swf"), p);
}
}, Configuration.parallelSpeedUp.get());
swf.fileTitle = streamEntry.getKey();
result.add(swf);
}
} else {
SWF swf = new SWF(inputStream, new ProgressListener() {
SWF swf = new SWF(inputStream, sourceInfo.getFile(), sourceInfo.getFileTitle(), new ProgressListener() {
@Override
public void progress(int p) {
startWork(AppStrings.translate("work.reading.swf"), p);
}
}, Configuration.parallelSpeedUp.get());
swf.file = sourceInfo.getFile();
swf.fileTitle = sourceInfo.getFileTitle();
result.add(swf);
}
@@ -409,8 +406,7 @@ public class Main {
public static void saveFile(SWF swf, String outfile, SaveFileMode mode) throws IOException {
if (mode == SaveFileMode.SAVEAS && !swf.swfList.isBundle) {
swf.file = outfile;
swf.fileTitle = null;
swf.setFile(outfile);
swf.swfList.sourceInfo.setFile(outfile);
}
File outfileF = new File(outfile);
@@ -625,8 +621,8 @@ public class Main {
switch (mode) {
case SAVE:
case SAVEAS:
if (swf.file != null) {
ext = Path.getExtension(swf.file);
if (swf.getFile() != null) {
ext = Path.getExtension(swf.getFile());
}
break;
case EXE:
@@ -78,11 +78,11 @@ public abstract class MainFrameMenu {
} catch (IOException ex) {
Logger.getLogger(MainFrameClassicMenu.class.getName()).log(Level.SEVERE, "Cannot save SWF", ex);
}
} else if (swf.file == null) {
} else if (swf.getFile() == null) {
saved = saveAs(swf, SaveFileMode.SAVEAS);
} else {
try {
Main.saveFile(swf, swf.file);
Main.saveFile(swf, swf.getFile());
saved = true;
} catch (IOException ex) {
Logger.getLogger(MainFrameClassicMenu.class.getName()).log(Level.SEVERE, null, ex);
@@ -149,6 +149,7 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -1450,7 +1451,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
if (!selDir.endsWith(File.separator)) {
selDir += File.separator;
}
String fileName = new File(swf.file).getName();
String fileName = new File(swf.getFile()).getName();
fileName = fileName.substring(0, fileName.length() - 4) + ".fla";
fc.setSelectedFile(new File(selDir + fileName));
List<FileFilter> flaFilters = new ArrayList<>();
@@ -1518,9 +1519,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
Helper.freeMem();
try {
if (compressed) {
swf.exportFla(errorHandler, selfile.getAbsolutePath(), new File(swf.file).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), selectedVersion);
swf.exportFla(errorHandler, selfile.getAbsolutePath(), new File(swf.getFile()).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), selectedVersion);
} else {
swf.exportXfl(errorHandler, selfile.getAbsolutePath(), new File(swf.file).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), selectedVersion);
swf.exportXfl(errorHandler, selfile.getAbsolutePath(), new File(swf.getFile()).getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), selectedVersion);
}
} catch (IOException ex) {
View.showMessageDialog(null, translate("error.export") + ": " + ex.getClass().getName() + " " + ex.getLocalizedMessage(), translate("error"), JOptionPane.ERROR_MESSAGE);
@@ -2316,14 +2317,14 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
try {
for (DefineBinaryDataTag binaryDataTag : binaryDataTags) {
try {
SWF bswf = new SWF(new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData()), new ProgressListener() {
InputStream is = new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData());
SWF bswf = new SWF(is, null, "(SWF Data)", new ProgressListener() {
@Override
public void progress(int p) {
Main.getLoadingDialog().setPercent(p);
}
}, Configuration.parallelSpeedUp.get());
bswf.fileTitle = "(SWF Data)";
binaryDataTag.innerSwf = bswf;
bswf.binaryData = binaryDataTag;
} catch (IOException ex) {
@@ -473,7 +473,7 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
tagsToRemove.add(((TagScript) tag).getTag());
} else if (tag instanceof Frame) {
Frame frameNode = (Frame) tag;
Frame frame = frameNode.timeline.getFrames().get(frameNode.frame);
Frame frame = frameNode.timeline.getFrame(frameNode.frame);
if (frame.showFrameTag != null) {
tagsToRemove.add(frame.showFrameTag);
} else {
@@ -185,7 +185,7 @@ public class TagTreeModel implements TreeModel {
Timeline timeline = swf.getTimeline();
int frameCount = timeline.getFrameCount();
for (int i = 0; i < frameCount; i++) {
frames.add(timeline.getFrames().get(i));
frames.add(timeline.getFrame(i));
}
for (int i = sounds.size() - 1; i >= 0; i--) {
@@ -414,7 +414,7 @@ public class TagTreeModel implements TreeModel {
} else if (parentNode instanceof Frame) {
return ((Frame) parentNode).innerTags.get(index);
} else if (parentNode instanceof DefineSpriteTag) {
return ((DefineSpriteTag) parentNode).getTimeline().getFrames().get(index);
return ((DefineSpriteTag) parentNode).getTimeline().getFrame(index);
} else if (parentNode instanceof DefineBinaryDataTag) {
return ((DefineBinaryDataTag) parentNode).innerSwf;
} else if (parentNode instanceof AS2Package) {
@@ -41,7 +41,7 @@ import javax.swing.JPanel;
*/
public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListener {
private final Timeline timeLine;
private final Timeline timeline;
public static final Color motionTweenColor = new Color(0x59, 0xfe, 0x7c);
@@ -85,10 +85,10 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
listeners.remove(l);
}
public TimelineBodyPanel(Timeline timeLine) {
public TimelineBodyPanel(Timeline timeline) {
this.timeLine = timeLine;
Dimension dim = new Dimension(TimelinePanel.FRAME_WIDTH * timeLine.getFrameCount() + 1, TimelinePanel.FRAME_HEIGHT * timeLine.getMaxDepth());
this.timeline = timeline;
Dimension dim = new Dimension(TimelinePanel.FRAME_WIDTH * timeline.getFrameCount() + 1, TimelinePanel.FRAME_HEIGHT * timeline.getMaxDepth());
setSize(dim);
setPreferredSize(dim);
addMouseListener(this);
@@ -111,11 +111,11 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
int end_f = (clip.x + clip.width) / TimelinePanel.FRAME_WIDTH;
int end_d = (clip.y + clip.height) / TimelinePanel.FRAME_HEIGHT;
int max_d = timeLine.getMaxDepth();
int max_d = timeline.getMaxDepth();
if (max_d < end_d) {
end_d = max_d;
}
int max_f = timeLine.getFrameCount() - 1;
int max_f = timeline.getFrameCount() - 1;
if (max_f < end_f) {
end_f = max_f;
}
@@ -128,7 +128,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
for (int f = start_f; f <= end_f; f++) {
for (int d = start_d; d <= end_d; d++) {
DepthState fl = timeLine.getFrames().get(f).layers.get(d);
DepthState fl = timeline.getFrame(f).layers.get(d);
if (fl == null) {
if ((f + 1) % 5 == 0) {
g.setColor(emptyFrameSecondColor);
@@ -143,19 +143,19 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
}
for (int f = start_f; f <= end_f; f++) {
for (int d = start_d; d <= end_d; d++) {
DepthState fl = timeLine.getFrames().get(f).layers.get(d);
DepthState fl = timeline.getFrame(f).layers.get(d);
boolean motionTween = fl == null ? false : fl.motionTween;
DepthState flNext = null;
if (f < max_f) {
flNext = timeLine.getFrames().get(f + 1).layers.get(d);
flNext = timeline.getFrame(f + 1).layers.get(d);
}
DepthState flPrev = null;
if (f > 0) {
flPrev = timeLine.getFrames().get(f - 1).layers.get(d);
flPrev = timeline.getFrame(f - 1).layers.get(d);
}
CharacterTag cht = fl == null ? null : timeLine.swf.getCharacter(fl.characterId);
CharacterTag cht = fl == null ? null : timeline.swf.getCharacter(fl.characterId);
boolean shapeTween = cht != null && (cht instanceof MorphShapeTag);
boolean motionTweenStart = (!motionTween) && (flNext != null && flNext.motionTween);
boolean motionTweenEnd = (!motionTween) && (flPrev != null && flPrev.motionTween);
@@ -180,18 +180,18 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
if (fl == null) {
if (timeLine.getDepthMaxFrame().containsKey(d) && f < timeLine.getDepthMaxFrame().get(d)) {
if (timeline.getDepthMaxFrame().containsKey(d) && f < timeline.getDepthMaxFrame().get(d)) {
int draw_f = f;
DepthState prev_ds = f < 1 ? null : timeLine.getFrames().get(f - 1).layers.get(d);
DepthState prev_ds = f < 1 ? null : timeline.getFrame(f - 1).layers.get(d);
if (f == 0 || prev_ds != null) {
draw_f = f;
keyfound[d - start_d] = true;
} else if (!keyfound[d - start_d]) {
for (; draw_f >= 0; draw_f--) {
if (timeLine.getFrames().get(draw_f).layers.get(d) != null) {
if (timeLine.getFrames().get(draw_f).layers.get(d).characterId != -1) {
if (timeline.getFrame(draw_f).layers.get(d) != null) {
if (timeline.getFrame(draw_f).layers.get(d).characterId != -1) {
break;
}
}
@@ -200,9 +200,9 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
continue;
}
int num_frames = 1;
for (int i = draw_f + 1; i < timeLine.getFrames().size(); i++) {
if (timeLine.getFrames().get(i).layers.get(d) != null) {
if (timeLine.getFrames().get(i).layers.get(d).characterId != -1) {
for (int i = draw_f + 1; i < timeline.getFrameCount(); i++) {
if (timeline.getFrame(i).layers.get(d) != null) {
if (timeline.getFrame(i).layers.get(d).characterId != -1) {
break;
}
}
@@ -241,7 +241,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
}
if (d == 0) {
if (!timeLine.getFrames().get(f).actions.isEmpty()) {
if (!timeline.getFrame(f).actions.isEmpty()) {
g.setColor(aColor);
g.setFont(getFont().deriveFont(fontSize));
int awidth = g.getFontMetrics().stringWidth("a");
@@ -257,7 +257,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
keyfound[d - start_d] = true;
} else if (!keyfound[d - start_d]) {
for (int k = f - 1; k >= 0; k--) {
fl = timeLine.getFrames().get(k).layers.get(d);
fl = timeline.getFrame(k).layers.get(d);
if (fl == null) {
break;
}
@@ -271,8 +271,8 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
continue;
}
int num_frames = 1;
for (int n = draw_f + 1; n < timeLine.getFrameCount(); n++) {
fl = timeLine.getFrames().get(n).layers.get(d);
for (int n = draw_f + 1; n < timeline.getFrameCount(); n++) {
fl = timeline.getFrame(n).layers.get(d);
if (fl == null) {
break;
}
@@ -364,10 +364,10 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
Point p = e.getPoint();
p.x = p.x / TimelinePanel.FRAME_WIDTH;
p.y = p.y / TimelinePanel.FRAME_HEIGHT;
if (p.x >= timeLine.getFrameCount()) {
p.x = timeLine.getFrameCount() - 1;
if (p.x >= timeline.getFrameCount()) {
p.x = timeline.getFrameCount() - 1;
}
int maxDepth = timeLine.getMaxDepth();
int maxDepth = timeline.getMaxDepth();
if (p.y > maxDepth) {
p.y = maxDepth;
}
@@ -402,7 +402,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
}
break;
case 39: //right
if (cursor.x < timeLine.getFrames().size() - 1) {
if (cursor.x < timeline.getFrameCount() - 1) {
frameSelect(cursor.x + 1, cursor.y);
}
break;
@@ -412,7 +412,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
}
break;
case 40: //down
if (cursor.y < timeLine.getMaxDepth()) {
if (cursor.y < timeline.getMaxDepth()) {
frameSelect(cursor.x, cursor.y + 1);
}
break;