mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-17 07:38:16 +00:00
small improvements
This commit is contained in:
@@ -272,10 +272,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
public SWFList swfList;
|
||||
|
||||
@Internal
|
||||
public String file;
|
||||
private String file;
|
||||
|
||||
@Internal
|
||||
public String fileTitle;
|
||||
private String fileTitle;
|
||||
|
||||
@Internal
|
||||
private Map<Integer, CharacterTag> characters;
|
||||
@@ -673,12 +673,37 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an empty SWF
|
||||
*/
|
||||
public SWF() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct SWF from stream
|
||||
*
|
||||
* @param is Stream to read SWF from
|
||||
* @param parallelRead Use parallel threads?
|
||||
* @throws IOException
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, boolean parallelRead) throws IOException, InterruptedException {
|
||||
this(is, null, parallelRead, false);
|
||||
this(is, null, null, null, parallelRead, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct SWF from stream
|
||||
*
|
||||
* @param is Stream to read SWF from
|
||||
* @param file Path to the file
|
||||
* @param fileTitle Title of the SWF
|
||||
* @param parallelRead Use parallel threads?
|
||||
* @throws IOException
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, String file, String fileTitle, boolean parallelRead) throws IOException, InterruptedException {
|
||||
this(is, file, fileTitle, null, parallelRead, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -691,7 +716,22 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, ProgressListener listener, boolean parallelRead) throws IOException, InterruptedException {
|
||||
this(is, listener, parallelRead, false);
|
||||
this(is, null, null, listener, parallelRead, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct SWF from stream
|
||||
*
|
||||
* @param is Stream to read SWF from
|
||||
* @param file Path to the file
|
||||
* @param fileTitle Title of the SWF
|
||||
* @param listener
|
||||
* @param parallelRead Use parallel threads?
|
||||
* @throws IOException
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead) throws IOException, InterruptedException {
|
||||
this(is, file, fileTitle, listener, parallelRead, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -708,13 +748,17 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
* Construct SWF from stream
|
||||
*
|
||||
* @param is Stream to read SWF from
|
||||
* @param file Path to the file
|
||||
* @param fileTitle Title of the SWF
|
||||
* @param listener
|
||||
* @param parallelRead Use parallel threads?
|
||||
* @param checkOnly Check only file validity
|
||||
* @throws IOException
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public SWF(InputStream is, ProgressListener listener, boolean parallelRead, boolean checkOnly) throws IOException, InterruptedException {
|
||||
public SWF(InputStream is, String file, String fileTitle, ProgressListener listener, boolean parallelRead, boolean checkOnly) throws IOException, InterruptedException {
|
||||
this.file = file;
|
||||
this.fileTitle = fileTitle;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFHeader header = decompress(is, baos, true);
|
||||
gfx = header.gfx;
|
||||
@@ -777,6 +821,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title of the file
|
||||
*
|
||||
@@ -797,6 +845,11 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
return new File(title).getName();
|
||||
}
|
||||
|
||||
public void setFile(String file) {
|
||||
this.file = file;
|
||||
fileTitle = null;
|
||||
}
|
||||
|
||||
private static void getAbcTags(List<Tag> list, List<ABCContainerTag> actionScripts) {
|
||||
for (Tag t : list) {
|
||||
if (t instanceof DefineSpriteTag) {
|
||||
@@ -1516,7 +1569,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
path = File.separator + Helper.makeFileName(getCharacter(containerId).getExportFileName());
|
||||
}
|
||||
if (frames == null) {
|
||||
int frameCnt = tim.getFrames().size();
|
||||
int frameCnt = tim.getFrameCount();
|
||||
frames = new ArrayList<>();
|
||||
for (int i = 0; i < frameCnt; i++) {
|
||||
frames.add(i);
|
||||
@@ -2450,7 +2503,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
Stack<Integer> clipDepths = new Stack<>();
|
||||
for (int frame : frames) {
|
||||
sb.append("\t\tcase ").append(frame).append(":\r\n");
|
||||
Frame frameObj = timeline.getFrames().get(frame);
|
||||
Frame frameObj = timeline.getFrame(frame);
|
||||
for (int i = 1; i <= maxDepth + 1; i++) {
|
||||
while (!clipDepths.isEmpty() && clipDepths.peek() <= i) {
|
||||
clipDepths.pop();
|
||||
@@ -2664,10 +2717,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
|
||||
public static void frameToSvg(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporter exporter, ColorTransform colorTransform, int level, double zoom) throws IOException {
|
||||
if (timeline.getFrames().size() <= frame) {
|
||||
if (timeline.getFrameCount() <= frame) {
|
||||
return;
|
||||
}
|
||||
Frame frameObj = timeline.getFrames().get(frame);
|
||||
Frame frameObj = timeline.getFrame(frame);
|
||||
List<SvgClip> clips = new ArrayList<>();
|
||||
List<String> prevClips = new ArrayList<>();
|
||||
|
||||
@@ -2767,7 +2820,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
}
|
||||
|
||||
if (timeline.getFrames().isEmpty()) {
|
||||
if (timeline.getFrameCount() == 0) {
|
||||
return new SerializableImage(1, 1, SerializableImage.TYPE_INT_ARGB);
|
||||
}
|
||||
|
||||
@@ -2797,7 +2850,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
|
||||
public static void framesToImage(Timeline timeline, List<SerializableImage> ret, int startFrame, int stopFrame, RenderContext renderContext, RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform, double zoom) {
|
||||
RECT rect = displayRect;
|
||||
for (int f = 0; f < timeline.getFrames().size(); f++) {
|
||||
for (int f = 0; f < timeline.getFrameCount(); f++) {
|
||||
SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
|
||||
(int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB);
|
||||
image.fillTransparent();
|
||||
@@ -2810,10 +2863,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
|
||||
public static void frameToImage(Timeline timeline, int frame, int time, RenderContext renderContext, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
double unzoom = SWF.unitDivisor;
|
||||
if (timeline.getFrames().size() <= frame) {
|
||||
if (timeline.getFrameCount() <= frame) {
|
||||
return;
|
||||
}
|
||||
Frame frameObj = timeline.getFrames().get(frame);
|
||||
Frame frameObj = timeline.getFrame(frame);
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
g.setPaint(frameObj.backgroundColor.toColor());
|
||||
g.fill(new Rectangle(image.getWidth(), image.getHeight()));
|
||||
|
||||
@@ -1453,7 +1453,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, "Error during tag reading. ID: " + tag.getId() + " name: " + tag.getName() + " pos: " + data.getPos(), ex);
|
||||
logger.log(Level.SEVERE, "Error during tag reading. SWF: " + swf.getShortFileName() + " ID: " + tag.getId() + " name: " + tag.getName() + " pos: " + data.getPos(), ex);
|
||||
ret = new TagStub(swf, tag.getId(), "ErrorTag", data, null);
|
||||
}
|
||||
ret.forceWriteAsLong = tag.forceWriteAsLong;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SWFSearch {
|
||||
MemoryInputStream mis = (MemoryInputStream) ret.get(addr);
|
||||
mis.reset();
|
||||
PosMarkedInputStream pmi = new PosMarkedInputStream(mis);
|
||||
SWF swf = noCheck ? new SWF(pmi) : new SWF(pmi, null, false, true);
|
||||
SWF swf = noCheck ? new SWF(pmi) : new SWF(pmi, null, null, null, false, true);
|
||||
boolean valid = swf.fileSize > 0
|
||||
&& swf.version > 0
|
||||
&& (!swf.tags.isEmpty() || noCheck)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
@@ -29,6 +30,7 @@ import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -87,8 +89,8 @@ public class DefineBinaryDataTag extends CharacterTag {
|
||||
|
||||
if (Configuration.autoLoadEmbeddedSwfs.get()) {
|
||||
try {
|
||||
try {
|
||||
SWF bswf = new SWF(new ByteArrayInputStream(binaryData.getArray(), binaryData.getPos(), binaryData.getLength()), Configuration.parallelSpeedUp.get());
|
||||
InputStream is = new ByteArrayInputStream(binaryData.getArray(), binaryData.getPos(), binaryData.getLength());
|
||||
SWF bswf = new SWF(is, null, "(SWF Data)", Configuration.parallelSpeedUp.get());
|
||||
innerSwf = bswf;
|
||||
bswf.binaryData = this;
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.RenderContext;
|
||||
import com.jpexs.decompiler.flash.timeline.Frame;
|
||||
import com.jpexs.decompiler.flash.timeline.Timeline;
|
||||
import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
@@ -301,14 +300,14 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli
|
||||
@Override
|
||||
public int getNumFrames() {
|
||||
// flashplayer ignores the count stored in frameCount
|
||||
return getTimeline().getFrames().size(); // frameCount
|
||||
return getTimeline().getFrameCount(); // frameCount
|
||||
}
|
||||
|
||||
private int getRealFrameCount() {
|
||||
int cnt = 1;
|
||||
List<Frame> frames = getTimeline().getFrames();
|
||||
for (int i = 1; i < frames.size(); i++) {
|
||||
if (frames.get(i).layersChanged) {
|
||||
Timeline timeline = getTimeline();
|
||||
for (int i = 1; i < timeline.getFrameCount(); i++) {
|
||||
if (timeline.getFrame(i).layersChanged) {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,11 +95,16 @@ public class Timeline {
|
||||
}
|
||||
}
|
||||
|
||||
public List<Frame> getFrames() {
|
||||
public Iterable<Frame> getFrames() {
|
||||
ensureInitialized();
|
||||
return frames;
|
||||
}
|
||||
|
||||
public Frame getFrame(int index) {
|
||||
ensureInitialized();
|
||||
return frames.get(index);
|
||||
}
|
||||
|
||||
public void addFrame(Frame frame) {
|
||||
ensureInitialized();
|
||||
frames.add(frame);
|
||||
@@ -149,7 +154,8 @@ public class Timeline {
|
||||
}
|
||||
|
||||
public int getFrameCount() {
|
||||
return getFrames().size();
|
||||
ensureInitialized();
|
||||
return frames.size();
|
||||
}
|
||||
|
||||
public int getFrameForAction(ASMSource asm) {
|
||||
@@ -389,7 +395,7 @@ public class Timeline {
|
||||
}
|
||||
|
||||
public void getNeededCharacters(int frame, Set<Integer> usedCharacters) {
|
||||
Frame frameObj = getFrames().get(frame);
|
||||
Frame frameObj = getFrame(frame);
|
||||
for (int depth : frameObj.layers.keySet()) {
|
||||
DepthState layer = frameObj.layers.get(depth);
|
||||
if (layer.characterId != -1) {
|
||||
@@ -424,7 +430,7 @@ public class Timeline {
|
||||
}
|
||||
|
||||
public void getSounds(int frame, int time, DepthState stateUnderCursor, int mouseButton, List<Integer> sounds, List<String> soundClasses) {
|
||||
Frame fr = getFrames().get(frame);
|
||||
Frame fr = getFrame(frame);
|
||||
sounds.addAll(fr.sounds);
|
||||
soundClasses.addAll(fr.soundClasses);
|
||||
for (int d = maxDepth; d >= 0; d--) {
|
||||
@@ -455,7 +461,7 @@ public class Timeline {
|
||||
}
|
||||
|
||||
public void getObjectsOutlines(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, Matrix transformation, List<DepthState> objs, List<Shape> outlines) {
|
||||
Frame fr = getFrames().get(frame);
|
||||
Frame fr = getFrame(frame);
|
||||
Stack<Clip> clips = new Stack<>();
|
||||
for (int d = maxDepth; d >= 0; d--) {
|
||||
Clip currentClip = null;
|
||||
@@ -527,7 +533,7 @@ public class Timeline {
|
||||
}
|
||||
|
||||
public Shape getOutline(int frame, int time, int ratio, RenderContext renderContext, Matrix transformation) {
|
||||
Frame fr = getFrames().get(frame);
|
||||
Frame fr = getFrame(frame);
|
||||
Area area = new Area();
|
||||
Stack<Clip> clips = new Stack<>();
|
||||
for (int d = maxDepth; d >= 0; d--) {
|
||||
@@ -602,7 +608,7 @@ public class Timeline {
|
||||
}
|
||||
|
||||
public boolean isSingleFrame(int frame) {
|
||||
Frame frameObj = getFrames().get(frame);
|
||||
Frame frameObj = getFrame(frame);
|
||||
for (int i = 1; i <= maxDepth; i++) {
|
||||
if (!frameObj.layers.containsKey(i)) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user