diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/CustomConfigurationKeys.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/CustomConfigurationKeys.java new file mode 100644 index 000000000..1e214f87b --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/CustomConfigurationKeys.java @@ -0,0 +1,11 @@ +package com.jpexs.decompiler.flash.configuration; + +/** + * + * @author JPEXS + */ +public class CustomConfigurationKeys { + public static final String KEY_LAST_SELECTED_PATH_RESOURCES = "lastSelectedPath.resources"; + public static final String KEY_LAST_SELECTED_PATH_TAGLIST = "lastSelectedPath.taglist"; + public static final String KEY_CHARSET = "charset"; +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificCustomConfiguration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificCustomConfiguration.java index 638e70c2e..181816496 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificCustomConfiguration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/SwfSpecificCustomConfiguration.java @@ -26,17 +26,15 @@ import java.util.Map; */ public class SwfSpecificCustomConfiguration implements Serializable { - private Map customData = new HashMap<>(); + private static final long serialVersionUID = 0x2acb421da57f5eb4L; - public static final String KEY_LAST_SELECTED_PATH_RESOURCES = "lastSelectedPath.resources"; - public static final String KEY_LAST_SELECTED_PATH_TAGLIST = "lastSelectedPath.taglist"; - public static final String KEY_CHARSET = "charset"; + private Map customData = new HashMap<>(); public String getCustomData(String key, String defaultValue) { if (customData.containsKey(key)) { return customData.get(key); } - + return defaultValue; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java index cd9cf884b..8952bdf5b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineBinaryDataTag.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.configuration.CustomConfigurationKeys; import com.jpexs.decompiler.flash.configuration.SwfSpecificCustomConfiguration; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.types.BasicType; @@ -82,7 +83,7 @@ public class DefineBinaryDataTag extends CharacterTag { if (Configuration.autoLoadEmbeddedSwfs.get()) { String path = getSwf().getShortPathTitle()+"/DefineBinaryData (" + getCharacterId() + ")"; SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(path); - String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(SwfSpecificCustomConfiguration.KEY_CHARSET, Charset.defaultCharset().name()); + String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(CustomConfigurationKeys.KEY_CHARSET, Charset.defaultCharset().name()); try { InputStream is = new ByteArrayInputStream(binaryData.getArray(), binaryData.getPos(), binaryData.getLength()); diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index ce442ed75..95fd04874 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -36,6 +36,7 @@ import com.jpexs.decompiler.flash.UrlResolver; import com.jpexs.decompiler.flash.Version; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.configuration.CustomConfigurationKeys; import com.jpexs.decompiler.flash.configuration.SwfSpecificConfiguration; import com.jpexs.decompiler.flash.configuration.SwfSpecificCustomConfiguration; import com.jpexs.decompiler.flash.console.CommandLineArgumentParser; @@ -873,7 +874,7 @@ public class Main { String fileKey = fname + "/" + streamEntry.getKey(); SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(fileKey); - String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(SwfSpecificCustomConfiguration.KEY_CHARSET, Charset.defaultCharset().name()); + String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(CustomConfigurationKeys.KEY_CHARSET, Charset.defaultCharset().name()); SWF swf = new SWF(stream, null, streamEntry.getKey(), new ProgressListener() { @Override public void progress(int p) { @@ -907,7 +908,7 @@ public class Main { String shortName = fileTitle != null ? fileTitle : file; String fileKey = shortName == null ? "" : new File(shortName).getName(); SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(fileKey); - String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(SwfSpecificCustomConfiguration.KEY_CHARSET, Charset.defaultCharset().name()); + String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(CustomConfigurationKeys.KEY_CHARSET, Charset.defaultCharset().name()); SWF swf = new SWF(is, file, fileTitle, new ProgressListener() { @Override @@ -1356,8 +1357,8 @@ public class Main { } SwfSpecificCustomConfiguration swfCustomConf = Configuration.getSwfSpecificCustomConfiguration(fswf.getShortPathTitle()); if (swfCustomConf != null) { - resourcesPathStr = swfCustomConf.getCustomData(SwfSpecificCustomConfiguration.KEY_LAST_SELECTED_PATH_RESOURCES, resourcesPathStr); - tagListPathStr = swfCustomConf.getCustomData(SwfSpecificCustomConfiguration.KEY_LAST_SELECTED_PATH_TAGLIST, null); + resourcesPathStr = swfCustomConf.getCustomData(CustomConfigurationKeys.KEY_LAST_SELECTED_PATH_RESOURCES, resourcesPathStr); + tagListPathStr = swfCustomConf.getCustomData(CustomConfigurationKeys.KEY_LAST_SELECTED_PATH_TAGLIST, null); } if (isInited()) { diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 74ed0f2fa..10a079d5f 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.DeobfuscationLevel; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.configuration.ConfigurationItem; +import com.jpexs.decompiler.flash.configuration.CustomConfigurationKeys; import com.jpexs.decompiler.flash.configuration.SwfSpecificCustomConfiguration; import com.jpexs.decompiler.flash.dumpview.DumpInfo; import com.jpexs.decompiler.flash.dumpview.DumpInfoSwfNode; @@ -4191,7 +4192,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se String path = binaryDataTag.getSwf().getShortPathTitle()+"/DefineBinaryData (" + binaryDataTag.getCharacterId() + ")"; try { SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(path); - String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(SwfSpecificCustomConfiguration.KEY_CHARSET, Charset.defaultCharset().name()); + String charset = conf == null ? Charset.defaultCharset().name() : conf.getCustomData(CustomConfigurationKeys.KEY_CHARSET, Charset.defaultCharset().name()); InputStream is = new ByteArrayInputStream(binaryDataTag.binaryData.getRangeData()); SWF bswf = new SWF(is, null, "(SWF Data)", new ProgressListener() { @Override @@ -4429,10 +4430,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (swf != null) { SwfSpecificCustomConfiguration swfCustomConf = Configuration.getOrCreateSwfSpecificCustomConfiguration(swf.getShortPathTitle()); - //swfConf.lastSelectedPath = tagTree.getSelectionPathString(); - swfCustomConf.setCustomData(SwfSpecificCustomConfiguration.KEY_LAST_SELECTED_PATH_RESOURCES, tagTree.getSelectionPathString()); - swfCustomConf.setCustomData(SwfSpecificCustomConfiguration.KEY_LAST_SELECTED_PATH_TAGLIST, tagListTree.getSelectionPathString()); - + swfCustomConf.setCustomData(CustomConfigurationKeys.KEY_LAST_SELECTED_PATH_RESOURCES, tagTree.getSelectionPathString()); + swfCustomConf.setCustomData(CustomConfigurationKeys.KEY_LAST_SELECTED_PATH_TAGLIST, tagListTree.getSelectionPathString()); } } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index 5efd306ae..c29f39d0b 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.parser.ActionParseException; import com.jpexs.decompiler.flash.action.parser.script.ActionScript2Parser; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.configuration.CustomConfigurationKeys; import com.jpexs.decompiler.flash.configuration.SwfSpecificCustomConfiguration; import com.jpexs.decompiler.flash.gui.AppDialog; import com.jpexs.decompiler.flash.gui.AppStrings; @@ -3041,7 +3042,7 @@ public class TagTreeContextMenu extends JPopupMenu { } SwfSpecificCustomConfiguration conf = Configuration.getOrCreateSwfSpecificCustomConfiguration(item.getShortPathTitle()); - conf.setCustomData(SwfSpecificCustomConfiguration.KEY_CHARSET, newCharset); + conf.setCustomData(CustomConfigurationKeys.KEY_CHARSET, newCharset); while (item.binaryData != null) { item = item.binaryData.getSwf(); }