mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-18 01:21:56 +00:00
Saving files before refreshing line endings
This commit is contained in:
@@ -48,7 +48,7 @@ import java.util.Set;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AbcIndexing {
|
||||
public final class AbcIndexing {
|
||||
|
||||
private AbcIndexing parent = null;
|
||||
|
||||
|
||||
@@ -36,4 +36,9 @@ public class DumpInfoSpecial extends DumpInfo {
|
||||
this.specialType = specialType;
|
||||
this.specialValue = specialValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " (special: " + specialValue + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,160 +1,160 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2016 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.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.importers;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.helpers.ImageHelper;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG4Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsLossless2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsLosslessTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import com.jpexs.decompiler.flash.tags.enums.ImageFormat;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ImageImporter extends TagImporter {
|
||||
|
||||
public Tag importImage(ImageTag it, byte[] newData) throws IOException {
|
||||
return importImage(it, newData, 0);
|
||||
}
|
||||
|
||||
public Tag importImage(ImageTag it, byte[] newData, int tagType) throws IOException {
|
||||
if (newData[0] == 'B' && newData[1] == 'M') {
|
||||
BufferedImage b = ImageHelper.read(newData);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageHelper.write(b, ImageFormat.PNG, baos);
|
||||
newData = baos.toByteArray();
|
||||
}
|
||||
|
||||
if (tagType == 0) {
|
||||
if (it instanceof DefineBitsTag) {
|
||||
tagType = DefineBitsJPEG2Tag.ID;
|
||||
} else {
|
||||
tagType = it.getId();
|
||||
}
|
||||
}
|
||||
|
||||
if (it.getId() == tagType) {
|
||||
it.setImage(newData);
|
||||
} else {
|
||||
SWF swf = it.getSwf();
|
||||
ImageTag imageTag;
|
||||
ByteArrayRange range = it.getOriginalRange();
|
||||
int characterId = it.getCharacterId();
|
||||
switch (tagType) {
|
||||
case DefineBitsJPEG2Tag.ID: {
|
||||
imageTag = new DefineBitsJPEG2Tag(swf, range, characterId, newData);
|
||||
break;
|
||||
}
|
||||
case DefineBitsJPEG3Tag.ID: {
|
||||
imageTag = new DefineBitsJPEG3Tag(swf, range, characterId, newData);
|
||||
break;
|
||||
}
|
||||
case DefineBitsJPEG4Tag.ID: {
|
||||
imageTag = new DefineBitsJPEG4Tag(swf, range, characterId, newData);
|
||||
break;
|
||||
}
|
||||
case DefineBitsLosslessTag.ID: {
|
||||
DefineBitsLosslessTag losslessTag = new DefineBitsLosslessTag(swf, range, characterId);
|
||||
losslessTag.setImage(newData);
|
||||
imageTag = losslessTag;
|
||||
break;
|
||||
}
|
||||
case DefineBitsLossless2Tag.ID: {
|
||||
DefineBitsLossless2Tag lossless2Tag = new DefineBitsLossless2Tag(swf, range, characterId);
|
||||
lossless2Tag.setImage(newData);
|
||||
imageTag = lossless2Tag;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error("Unsupported image type tag.");
|
||||
}
|
||||
|
||||
imageTag.setModified(true);
|
||||
swf.replaceTag(it, imageTag);
|
||||
swf.updateCharacters();
|
||||
return imageTag;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Tag importImageAlpha(ImageTag it, byte[] newData) throws IOException {
|
||||
|
||||
try {
|
||||
BufferedImage img = ImageHelper.read(newData);
|
||||
int width = img.getWidth();
|
||||
int height = img.getHeight();
|
||||
byte[] data = new byte[width * height];
|
||||
int[] imgData = img.getRGB(0, 0, width, height, null, 0, width);
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
int alpha = (imgData[y * width + x] >> 24) & 0xff;
|
||||
data[y * width + x] = (byte) alpha;
|
||||
}
|
||||
}
|
||||
|
||||
newData = data;
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
|
||||
if (it instanceof DefineBitsJPEG3Tag) {
|
||||
((DefineBitsJPEG3Tag) it).setImageAlpha(newData);
|
||||
} else if (it instanceof DefineBitsJPEG4Tag) {
|
||||
((DefineBitsJPEG4Tag) it).setImageAlpha(newData);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void convertImage(ImageTag it, int tagType) throws IOException {
|
||||
importImage(it, Helper.readStream(it.getImageData()), tagType);
|
||||
}
|
||||
|
||||
public static int getImageTagType(String format) {
|
||||
int res = 0;
|
||||
switch (format) {
|
||||
case "lossless":
|
||||
res = DefineBitsLosslessTag.ID;
|
||||
break;
|
||||
case "lossless2":
|
||||
res = DefineBitsLossless2Tag.ID;
|
||||
break;
|
||||
case "jpeg2":
|
||||
res = DefineBitsJPEG2Tag.ID;
|
||||
break;
|
||||
case "jpeg3":
|
||||
res = DefineBitsJPEG3Tag.ID;
|
||||
break;
|
||||
case "jpeg4":
|
||||
res = DefineBitsJPEG4Tag.ID;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2016 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.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.importers;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.helpers.ImageHelper;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG4Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsLossless2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsLosslessTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import com.jpexs.decompiler.flash.tags.enums.ImageFormat;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ImageImporter extends TagImporter {
|
||||
|
||||
public Tag importImage(ImageTag it, byte[] newData) throws IOException {
|
||||
return importImage(it, newData, 0);
|
||||
}
|
||||
|
||||
public Tag importImage(ImageTag it, byte[] newData, int tagType) throws IOException {
|
||||
if (newData[0] == 'B' && newData[1] == 'M') {
|
||||
BufferedImage b = ImageHelper.read(newData);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageHelper.write(b, ImageFormat.PNG, baos);
|
||||
newData = baos.toByteArray();
|
||||
}
|
||||
|
||||
if (tagType == 0) {
|
||||
if (it instanceof DefineBitsTag) {
|
||||
tagType = DefineBitsJPEG2Tag.ID;
|
||||
} else {
|
||||
tagType = it.getId();
|
||||
}
|
||||
}
|
||||
|
||||
if (it.getId() == tagType) {
|
||||
it.setImage(newData);
|
||||
} else {
|
||||
SWF swf = it.getSwf();
|
||||
ImageTag imageTag;
|
||||
ByteArrayRange range = it.getOriginalRange();
|
||||
int characterId = it.getCharacterId();
|
||||
switch (tagType) {
|
||||
case DefineBitsJPEG2Tag.ID: {
|
||||
imageTag = new DefineBitsJPEG2Tag(swf, range, characterId, newData);
|
||||
break;
|
||||
}
|
||||
case DefineBitsJPEG3Tag.ID: {
|
||||
imageTag = new DefineBitsJPEG3Tag(swf, range, characterId, newData);
|
||||
break;
|
||||
}
|
||||
case DefineBitsJPEG4Tag.ID: {
|
||||
imageTag = new DefineBitsJPEG4Tag(swf, range, characterId, newData);
|
||||
break;
|
||||
}
|
||||
case DefineBitsLosslessTag.ID: {
|
||||
DefineBitsLosslessTag losslessTag = new DefineBitsLosslessTag(swf, range, characterId);
|
||||
losslessTag.setImage(newData);
|
||||
imageTag = losslessTag;
|
||||
break;
|
||||
}
|
||||
case DefineBitsLossless2Tag.ID: {
|
||||
DefineBitsLossless2Tag lossless2Tag = new DefineBitsLossless2Tag(swf, range, characterId);
|
||||
lossless2Tag.setImage(newData);
|
||||
imageTag = lossless2Tag;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error("Unsupported image type tag.");
|
||||
}
|
||||
|
||||
imageTag.setModified(true);
|
||||
swf.replaceTag(it, imageTag);
|
||||
swf.updateCharacters();
|
||||
return imageTag;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Tag importImageAlpha(ImageTag it, byte[] newData) throws IOException {
|
||||
|
||||
try {
|
||||
BufferedImage img = ImageHelper.read(newData);
|
||||
int width = img.getWidth();
|
||||
int height = img.getHeight();
|
||||
byte[] data = new byte[width * height];
|
||||
int[] imgData = img.getRGB(0, 0, width, height, null, 0, width);
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
int alpha = (imgData[y * width + x] >> 24) & 0xff;
|
||||
data[y * width + x] = (byte) alpha;
|
||||
}
|
||||
}
|
||||
|
||||
newData = data;
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
|
||||
if (it instanceof DefineBitsJPEG3Tag) {
|
||||
((DefineBitsJPEG3Tag) it).setImageAlpha(newData);
|
||||
} else if (it instanceof DefineBitsJPEG4Tag) {
|
||||
((DefineBitsJPEG4Tag) it).setImageAlpha(newData);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void convertImage(ImageTag it, int tagType) throws IOException {
|
||||
importImage(it, Helper.readStream(it.getImageData()), tagType);
|
||||
}
|
||||
|
||||
public static int getImageTagType(String format) {
|
||||
int res = 0;
|
||||
switch (format) {
|
||||
case "lossless":
|
||||
res = DefineBitsLosslessTag.ID;
|
||||
break;
|
||||
case "lossless2":
|
||||
res = DefineBitsLossless2Tag.ID;
|
||||
break;
|
||||
case "jpeg2":
|
||||
res = DefineBitsJPEG2Tag.ID;
|
||||
break;
|
||||
case "jpeg3":
|
||||
res = DefineBitsJPEG3Tag.ID;
|
||||
break;
|
||||
case "jpeg4":
|
||||
res = DefineBitsJPEG4Tag.ID;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1862,7 +1862,61 @@ public class Main {
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
setSessionLoaded(false);
|
||||
|
||||
//args = new String[]{"--resourcedates"};
|
||||
//args = new String[]{"-cli", "C:\\124\\123flashchat.swf"};
|
||||
//args = new String[]{"-compress", "C:\\FFDec\\5.1.0_nightly900\\as3.swf", "C:\\FFDec\\5.1.0_nightly543\\as3_4.swf", "lzma"};
|
||||
//String a = new String(Helper.readStream(ApplicationInfo.class.getResourceAsStream("/project.properties")));
|
||||
//ResourceBundle a = ResourceBundle.getBundle("jsyntaxpane/Bundle");
|
||||
//CheckResources.compareResources(System.out, "2635a809463a450d2630f6cd488d679d4a5c3e13", null);
|
||||
String nightlyVersion = "1317";
|
||||
/*args = new String[]{
|
||||
"-stat",
|
||||
"-config", "parallelSpeedUp=1,cacheOnDisk=0,autoDeobfuscate=1",
|
||||
"-format", "script:as,singlescript:0,singletext:1",
|
||||
"-exportTimeout", "3600",
|
||||
"-timeout", "60",
|
||||
"-exportFileTimeout", "1800",
|
||||
"-selectclass", "com.ludia.gameengine.F__ZN3AS32ui5flash3net12NetGroupInfo8internal41iprop_postingReceiveControlBytesPerSecondcvdEv",
|
||||
"-stdout", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/txtnb/out/{swfFile}.txt",
|
||||
"-stderr", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/txtnb/err/{swfFile}_err.txt",
|
||||
"-export", "script_as2", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/txtnb/exp", "C:\\FFDec/swf/"
|
||||
};*/
|
||||
|
||||
/*args = new String[]{
|
||||
"-config", "parallelSpeedUp=0,cacheOnDisk=0,autoDeobfuscate=1",
|
||||
"-format", "script:as,singlescript:0,singletext:1",
|
||||
"-exportTimeout", "3600",
|
||||
"-timeout", "60",
|
||||
"-stdout", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/txt/out/{swfFile}.txt",
|
||||
"-stderr", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/txt/err/{swfFile}_err.txt",
|
||||
"-selectclass", "<22>^q<>.<2E>!l<>",
|
||||
"-export", "script", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/txt/out", "C:\\FFDec/swf/06AC0000-10.swf"
|
||||
};*/
|
||||
/*args = new String[]{
|
||||
"-config", "parallelSpeedUp=0,cacheOnDisk=0,autoDeobfuscate=1",
|
||||
"-format", "script:as,singlescript:0,singletext:1",
|
||||
"-exportTimeout", "3600",
|
||||
"-timeout", "60",
|
||||
"-stdout", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/txt/out/{swfFile}.txt",
|
||||
"-stderr", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/txt/err/{swfFile}_err.txt",
|
||||
//"-selectclass", "preloader.Preloader",
|
||||
"-export", "script", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/txt/out", "C:\\FFDec/swf/Enter2.swf"
|
||||
};*/
|
||||
/*args = new String[]{
|
||||
"-remove", "C:\\FFDec/swf/06AC0000-10.swf", "C:\\FFDec/swf/06AC0000-10_2.swf", "2", "1",};
|
||||
args = new String[0];
|
||||
args = new String[]{
|
||||
"-config", "parallelSpeedUp=1",
|
||||
"-dumpSWF", "C:\\FFDec/swf/06AC0000-10.swf"};*/
|
||||
//args = new String[]{"-replace", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/as2.swf", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/as2_zg.swf", "34", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/a.txt",};
|
||||
//args = new String[]{"-replaceCharacterId", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/as2.swf", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/as2_zg.swf", "1,101,2,102,3,103",};
|
||||
//args = new String[]{"-replace", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/as2.swf", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/as2_2.swf", "1", "C:\\FFDec/8.0.1_nightly" + nightlyVersion + "/1.png", "nofill",};
|
||||
//args = new String[]{"-renameInvalidIdentifiers", "typeNumber", "C:\\111\\original.swf", "C:\\111\\renamed.swf",};
|
||||
clearTemp();
|
||||
// String pluginPath = Configuration.pluginPath.get();
|
||||
// if (pluginPath != null && !pluginPath.isEmpty()) {
|
||||
// }
|
||||
|
||||
try {
|
||||
SWFDecompilerPlugin.loadPlugins();
|
||||
|
||||
@@ -3298,10 +3298,10 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
setSourceWorker = null;
|
||||
}
|
||||
if (!Main.isInited() || !Main.isWorking() || Main.isDebugging()) {
|
||||
ABCPanel abcPanel = getABCPanel();
|
||||
CancellableWorker worker = new CancellableWorker() {
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
ABCPanel abcPanel = getABCPanel();
|
||||
abcPanel.detailPanel.methodTraitPanel.methodCodePanel.clear();
|
||||
abcPanel.setAbc(scriptLeaf.abc);
|
||||
abcPanel.decompiledTextArea.setScript(scriptLeaf, true);
|
||||
@@ -3321,7 +3321,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
try {
|
||||
get();
|
||||
} catch (CancellationException ex) {
|
||||
getABCPanel().decompiledTextArea.setText("// " + AppStrings.translate("work.canceled"));
|
||||
abcPanel.decompiledTextArea.setText("// " + AppStrings.translate("work.canceled"));
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Error", ex);
|
||||
getABCPanel().decompiledTextArea.setText("// " + AppStrings.translate("decompilationError") + ": " + ex);
|
||||
|
||||
Reference in New Issue
Block a user