mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-07 00:57:04 +00:00
export folder name fix, swf preview fix
This commit is contained in:
@@ -1539,7 +1539,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
tim = getTimeline();
|
||||
} else {
|
||||
tim = ((Timelined) characters.get(containerId)).getTimeline();
|
||||
path = File.separator + characters.get(containerId).getExportFileName();
|
||||
path = File.separator + Helper.makeFileName(characters.get(containerId).getExportFileName());
|
||||
}
|
||||
if (frames == null) {
|
||||
int frameCnt = tim.frames.size();
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.NotIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.comparison.StrictEqualsIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.ConstructSuperIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewActivationIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewCatchIns;
|
||||
@@ -33,9 +32,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfTrueIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.LookupSwitchIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocalIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.KillIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetLexIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetScopeObjectIns;
|
||||
@@ -60,7 +57,6 @@ import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ReturnValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ReturnVoidAVM2Item;
|
||||
@@ -111,8 +107,6 @@ import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
|
||||
import com.jpexs.decompiler.graph.model.WhileItem;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -1243,7 +1237,7 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
|
||||
List<String> registerNames = new ArrayList<>();
|
||||
List<String> registerTypes = new ArrayList<>();
|
||||
registerTypes.add(pkg.equals("") ? className : pkg + "." + className);
|
||||
registerTypes.add(pkg.isEmpty() ? className : pkg + "." + className);
|
||||
registerNames.add("this");
|
||||
for (GraphTargetItem t : paramTypes) {
|
||||
registerTypes.add(t.toString());
|
||||
|
||||
@@ -221,8 +221,8 @@ public class NameAVM2Item extends AssignableAVM2Item {
|
||||
if (variableName != null && regNumber == -1 && slotNumber == -1 && ns == null) {
|
||||
throw new RuntimeException("No register or slot set for " + variableName);
|
||||
}
|
||||
if (definition && assignedValue == null) {
|
||||
return new ArrayList<GraphSourceItem>();
|
||||
if (definition && assignedValue == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
AVM2SourceGenerator g = (AVM2SourceGenerator) generator;
|
||||
Reference<Integer> ns_temp = new Reference<>(-1);
|
||||
|
||||
@@ -526,7 +526,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
/*FileAttributesTag fa = new FileAttributesTag();
|
||||
sos2.writeTag(fa);
|
||||
*/
|
||||
new SetBackgroundColorTag(null, new RGB(backgroundColor)).writeTag(sos2);
|
||||
new SetBackgroundColorTag(swf, new RGB(backgroundColor)).writeTag(sos2);
|
||||
|
||||
if (tagObj instanceof FrameNodeItem) {
|
||||
FrameNodeItem fn = (FrameNodeItem) tagObj;
|
||||
@@ -589,12 +589,12 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
mat.translateX += width / 2;
|
||||
mat.translateY += height / 2;
|
||||
}
|
||||
new PlaceObject2Tag(null, false, false, false, false, false, true, false, true, depth, chid, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
new PlaceObject2Tag(swf, false, false, false, false, false, true, false, true, depth, chid, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
} else {
|
||||
|
||||
if (tagObj instanceof DefineBitsTag) {
|
||||
@@ -663,23 +663,23 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
rec.add(tr);
|
||||
mat.translateX = x * width / cols;
|
||||
mat.translateY = y * height / rows;
|
||||
new DefineTextTag(null, 999 + f, new RECT(0, width, 0, height), new MATRIX(), rec).writeTag(sos2);
|
||||
new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1 + f, 999 + f, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
new DefineTextTag(swf, 999 + f, new RECT(0, width, 0, height), new MATRIX(), rec).writeTag(sos2);
|
||||
new PlaceObject2Tag(swf, false, false, false, true, false, true, true, false, 1 + f, 999 + f, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
x++;
|
||||
}
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
} else if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
|
||||
new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new PlaceObject2Tag(swf, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
int numFrames = 100;
|
||||
for (int ratio = 0; ratio < 65536; ratio += 65536 / numFrames) {
|
||||
new PlaceObject2Tag(null, false, false, false, true, false, true, false, true, 1, chtId, mat, null, ratio, null, 0, null).writeTag(sos2);
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new PlaceObject2Tag(swf, false, false, false, true, false, true, false, true, 1, chtId, mat, null, ratio, null, 0, null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
}
|
||||
} else if (tagObj instanceof SoundStreamHeadTypeTag) {
|
||||
for (SoundStreamBlockTag blk : soundFrames) {
|
||||
blk.writeTag(sos2);
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
}
|
||||
} else if (tagObj instanceof DefineSoundTag) {
|
||||
ExportAssetsTag ea = new ExportAssetsTag();
|
||||
@@ -708,7 +708,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
+ "Stop", swf.version, false);
|
||||
doa.setActions(actions);
|
||||
doa.writeTag(sos2);
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
|
||||
actions = ASMParser.parse(0, 0, false,
|
||||
"ConstantPool \"_root\" \"my_sound\" \"Sound\" \"my_define_sound\" \"attachSound\" \"start\"\n"
|
||||
@@ -735,7 +735,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
+ "Stop", swf.version, false);
|
||||
doa.setActions(actions);
|
||||
doa.writeTag(sos2);
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
|
||||
actions = ASMParser.parse(0, 0, false,
|
||||
"ConstantPool \"_root\" \"my_sound\" \"Sound\" \"my_define_sound\" \"attachSound\" \"onSoundComplete\" \"start\" \"execParam\"\n"
|
||||
@@ -779,22 +779,22 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
+ "Stop", swf.version, false);
|
||||
doa.setActions(actions);
|
||||
doa.writeTag(sos2);
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
|
||||
actions = ASMParser.parse(0, 0, false,
|
||||
"StopSounds\n"
|
||||
+ "Stop", swf.version, false);
|
||||
doa.setActions(actions);
|
||||
doa.writeTag(sos2);
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
if (flashPanel != null) {
|
||||
flashPanel.specialPlayback = true;
|
||||
}
|
||||
} else if (tagObj instanceof DefineVideoStreamTag) {
|
||||
|
||||
new PlaceObject2Tag(null, false, false, false, false, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
new PlaceObject2Tag(swf, false, false, false, false, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
List<VideoFrameTag> frs = new ArrayList<>(videoFrames.values());
|
||||
Collections.sort(frs, new Comparator<VideoFrameTag>() {
|
||||
@Override
|
||||
@@ -807,20 +807,20 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
for (VideoFrameTag f : frs) {
|
||||
if (!first) {
|
||||
ratio++;
|
||||
new PlaceObject2Tag(null, false, false, false, true, false, false, false, true, 1, 0, null, null, ratio, null, 0, null).writeTag(sos2);
|
||||
new PlaceObject2Tag(swf, false, false, false, true, false, false, false, true, 1, 0, null, null, ratio, null, 0, null).writeTag(sos2);
|
||||
}
|
||||
f.writeTag(sos2);
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
first = false;
|
||||
}
|
||||
} else {
|
||||
new PlaceObject2Tag(null, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
new ShowFrameTag(null).writeTag(sos2);
|
||||
new PlaceObject2Tag(swf, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
|
||||
new ShowFrameTag(swf).writeTag(sos2);
|
||||
}
|
||||
|
||||
}//not showframe
|
||||
|
||||
new EndTag(null).writeTag(sos2);
|
||||
new EndTag(swf).writeTag(sos2);
|
||||
data = baos.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
|
||||
} else {
|
||||
pathParts = new String[]{expName};
|
||||
}
|
||||
return Helper.makeFileName(pathParts[pathParts.length - 1]);
|
||||
return pathParts[pathParts.length - 1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -134,7 +134,10 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializ
|
||||
this.data = data;
|
||||
this.pos = pos;
|
||||
this.swf = swf;
|
||||
if (data == null) {//it is tag build by constructor
|
||||
if (swf == null) {
|
||||
throw new Error("swf parameter cannot be null.");
|
||||
}
|
||||
if (data == null) { // it is tag build by constructor
|
||||
this.data = new byte[0];
|
||||
modified = true;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class TagNode extends ContainerNode {
|
||||
for (TreeNode node : nodeList) {
|
||||
String name = "";
|
||||
if (node.item instanceof Exportable) {
|
||||
name = ((Exportable) node.item).getExportFileName();
|
||||
name = Helper.makeFileName(((Exportable) node.item).getExportFileName());
|
||||
} else {
|
||||
name = Helper.makeFileName(node.item.toString());
|
||||
}
|
||||
@@ -116,19 +116,21 @@ public class TagNode extends ContainerNode {
|
||||
existingNames.add(name);
|
||||
if (node.subNodes.isEmpty()) {
|
||||
if ((node.item instanceof ASMSource) && (node.export)) {
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdirs()) {
|
||||
if (!dir.exists()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean retry;
|
||||
do {
|
||||
retry = false;
|
||||
try {
|
||||
String f = outdir + name + ".as";
|
||||
int currentIndex = index.getAndIncrement();
|
||||
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdirs()) {
|
||||
if (!dir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String f = outdir + name + ".as";
|
||||
if (ev != null) {
|
||||
ev.handleEvent("exporting", "Exporting " + currentIndex + "/" + count + " " + f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user