better export filename generation

This commit is contained in:
honfika
2014-08-05 21:38:48 +02:00
parent b02a343116
commit 254b13a326
7 changed files with 93 additions and 102 deletions
@@ -72,7 +72,7 @@ public class FontExporter {
if (settings.mode == FontExportMode.WOFF) {
ext = ".woff";
}
final File file = new File(outdir + File.separator + st.getCharacterExportFileName() + ext);
final File file = new File(outdir + File.separator + Helper.makeFileName(st.getCharacterExportFileName() + ext));
newfile = file;
new RetryTask(new RunnableIOEx() {
@Override
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode;
import com.jpexs.decompiler.flash.exporters.settings.ImageExportSettings;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.ImageTag;
import com.jpexs.helpers.Helper;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -60,14 +61,15 @@ public class ImageExporter {
fileFormat = "jpg";
}
final File file = new File(outdir + File.separator + ((ImageTag) t).getExportFileName2() + "." + fileFormat);
final ImageTag imageTag = (ImageTag) t;
final File file = new File(outdir + File.separator + Helper.makeFileName(imageTag.getCharacterExportFileName() + "." + fileFormat));
final List<Tag> ttags = tags;
final String ffileFormat = fileFormat;
new RetryTask(new RunnableIOEx() {
@Override
public void run() throws IOException {
ImageIO.write(((ImageTag) t).getImage().getBufferedImage(), ffileFormat.toUpperCase(Locale.ENGLISH), file);
ImageIO.write(imageTag.getImage().getBufferedImage(), ffileFormat.toUpperCase(Locale.ENGLISH), file);
}
}, handler).run();
ret.add(file);
@@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.flv.VIDEODATA;
import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
import com.jpexs.helpers.Helper;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@@ -61,7 +62,7 @@ public class MovieExporter {
for (Tag t : tags) {
if (t instanceof DefineVideoStreamTag) {
final DefineVideoStreamTag videoStream = (DefineVideoStreamTag) t;
final File file = new File(outdir + File.separator + ((DefineVideoStreamTag) t).getCharacterExportFileName() + ".flv");
final File file = new File(outdir + File.separator + Helper.makeFileName(videoStream.getCharacterExportFileName() + ".flv"));
new RetryTask(new RunnableIOEx() {
@Override
public void run() throws IOException {
@@ -65,7 +65,7 @@ public class TextExporter {
for (Tag t : tags) {
if (t instanceof TextTag) {
final TextTag textTag = (TextTag) t;
final File file = new File(outdir + File.separator + textTag.getExportFileName2()+ ".svg");
final File file = new File(outdir + File.separator + Helper.makeFileName(textTag.getCharacterExportFileName()+ ".svg"));
new RetryTask(new RunnableIOEx() {
@Override
public void run() throws IOException {
@@ -110,7 +110,7 @@ public class TextExporter {
for (Tag t : tags) {
if (t instanceof TextTag) {
final TextTag textTag = (TextTag) t;
final File file = new File(outdir + File.separator + textTag.getCharacterId() + ".txt");
final File file = new File(outdir + File.separator + Helper.makeFileName(textTag.getCharacterExportFileName() + ".txt"));
new RetryTask(new RunnableIOEx() {
@Override
public void run() throws IOException {
@@ -1134,7 +1134,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
if (dumpInfo == null) {
return null;
}
return DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf();
}
@@ -1,76 +1,79 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.tags.base;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.helpers.ByteArrayRange;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author JPEXS
*/
public abstract class CharacterIdTag extends Tag {
public CharacterIdTag(SWF swf, int id, String name, ByteArrayRange data) {
super(swf, id, name, data);
}
public abstract int getCharacterId();
/**
* List of ExportAssetsTag used for converting to String
*/
@Internal
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<>();
protected String exportName;
public void setExportName(String exportName) {
this.exportName = exportName;
}
@Override
public String getName() {
String nameAppend = "";
if (exportName != null) {
nameAppend = ": " + exportName;
}
if (getCharacterId() != -1) {
return super.getName() + " (" + getCharacterId() + nameAppend + ")";
}
if (!nameAppend.isEmpty()) {
return super.getName() + " (" + nameAppend + ")";
}
return super.getName();
}
@Override
public String getExportFileName() {
return super.getName() + "_" + getCharacterId() + (((exportName != null) && (!exportName.isEmpty())) ? "_" + exportName : "");
}
public String getCharacterExportFileName() {
return getCharacterId() + (((exportName != null) && (!exportName.isEmpty())) ? "_" + exportName : "");
}
public String getExportName() {
return exportName;
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.tags.base;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.helpers.ByteArrayRange;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author JPEXS
*/
public abstract class CharacterIdTag extends Tag {
public CharacterIdTag(SWF swf, int id, String name, ByteArrayRange data) {
super(swf, id, name, data);
}
public abstract int getCharacterId();
/**
* List of ExportAssetsTag used for converting to String
*/
@Internal
public List<ExportAssetsTag> exportAssetsTags = new ArrayList<>();
protected String exportName;
public void setExportName(String exportName) {
if ("".equals(exportName)) {
exportName = null;
}
this.exportName = exportName;
}
@Override
public String getName() {
String nameAppend = "";
if (exportName != null) {
nameAppend = ": " + exportName;
}
if (getCharacterId() != -1) {
return super.getName() + " (" + getCharacterId() + nameAppend + ")";
}
if (!nameAppend.isEmpty()) {
return super.getName() + " (" + nameAppend + ")";
}
return super.getName();
}
@Override
public String getExportFileName() {
return super.getName() + "_" + getCharacterId() + (exportName != null ? "_" + exportName : "");
}
public String getCharacterExportFileName() {
return getCharacterId() + (exportName != null ? "_" + exportName : "");
}
public String getExportName() {
return exportName;
}
}
@@ -56,24 +56,9 @@ public abstract class CharacterTag extends CharacterIdTag {
}
return tagName;
}
/*
export with classname/export namme
*/
public String getExportFileName2() {
String nameAppend = "";
if (exportName != null) {
nameAppend = ": " + exportName;
return exportName;
}
if (className != null) {
nameAppend = ": " + className;
return className;
}
if (getCharacterId() != -1) {
return getCharacterId()+"";
// return tagName + " (" + getCharacterId() + nameAppend + ")";
}
return tagName;
@Override
public String getCharacterExportFileName() {
return getCharacterId() + (exportName != null ? "_" + exportName : "") + (className != null ? "_" + className : "");
}
}