allow adding new tags

This commit is contained in:
honfika@gmail.com
2014-11-05 17:10:15 +01:00
parent 3bf44354dd
commit f83ddaa9dd
30 changed files with 282 additions and 26 deletions

View File

@@ -359,6 +359,10 @@ public class Configuration {
@ConfigurationCategory("script")
public static final ConfigurationItem<Boolean> getLocalNamesFromDebugInfo = null;
@ConfigurationDefaultBoolean(false)
@ConfigurationCategory("ui")
public static final ConfigurationItem<Boolean> tagTreeShowEmptyFolders = null;
private enum OSId {
WINDOWS, OSX, UNIX

View File

@@ -65,6 +65,14 @@ public class DefineBinaryDataTag extends CharacterTag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public DefineBinaryDataTag(SWF swf) {
super(swf, ID, "DefineBinaryData", null);
}
public DefineBinaryDataTag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineBinaryData", data);
tag = sis.readUI16("tag");

View File

@@ -12,7 +12,8 @@
* 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;
@@ -68,6 +69,16 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
return null;
}
/**
* Constructor
* @param swf
*/
public DefineBitsJPEG2Tag(SWF swf) {
super(swf, ID, "DefineBitsJPEG2", null);
characterID = swf.getNextCharacterId();
imageData = new byte[0];
}
public DefineBitsJPEG2Tag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineBitsJPEG2", data);
characterID = sis.readUI16("characterID");

View File

@@ -12,7 +12,8 @@
* 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;
@@ -107,6 +108,16 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
return null;
}
/**
* Constructor
* @param swf
*/
public DefineBitsJPEG3Tag(SWF swf) {
super(swf, ID, "DefineBitsJPEG3", null);
characterID = swf.getNextCharacterId();
imageData = new byte[0];
}
public DefineBitsJPEG3Tag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineBitsJPEG3", data);
characterID = sis.readUI16("characterID");

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.AloneTag;
@@ -130,6 +132,16 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public DefineBitsJPEG4Tag(SWF swf) {
super(swf, ID, "DefineBitsJPEG4", null);
characterID = swf.getNextCharacterId();
imageData = new byte[0];
}
/**
* Constructor
*

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.AloneTag;
@@ -107,6 +109,17 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
setModified(true);
}
/**
* Constructor
* @param swf
*/
public DefineBitsLossless2Tag(SWF swf) {
super(swf, ID, "DefineBitsLossless2", null);
characterID = swf.getNextCharacterId();
bitmapWidth = 1;
bitmapHeight = 1;
}
public DefineBitsLossless2Tag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineBitsLossless2", data);
characterID = sis.readUI16("characterID");

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.AloneTag;
@@ -181,6 +183,17 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
decompressed = true;
}
/**
* Constructor
* @param swf
*/
public DefineBitsLosslessTag(SWF swf) {
super(swf, ID, "DefineBitsLossless", null);
characterID = swf.getNextCharacterId();
bitmapWidth = 1;
bitmapHeight = 1;
}
public DefineBitsLosslessTag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineBitsLossless", data);
characterID = sis.readUI16("characterID");

View File

@@ -12,7 +12,8 @@
* 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;
@@ -54,6 +55,16 @@ public class DefineBitsTag extends ImageTag {
return true;
}
/**
* Constructor
* @param swf
*/
public DefineBitsTag(SWF swf) {
super(swf, ID, "DefineBits", null);
characterID = swf.getNextCharacterId();
jpegData = new byte[0];
}
public DefineBitsTag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineBits", data);
characterID = sis.readUI16("characterID");

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
@@ -93,6 +94,14 @@ public class DefineButton2Tag extends ButtonTag implements Container {
return characters;
}
/**
* Constructor
* @param swf
*/
public DefineButton2Tag(SWF swf) {
super(swf, ID, "DefineButton2", null);
}
/**
* Constructor
*

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.DisassemblyListener;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
@@ -93,6 +94,14 @@ public class DefineButtonTag extends ButtonTag implements ASMSource {
return characters;
}
/**
* Constructor
* @param swf
*/
public DefineButtonTag(SWF swf) {
super(swf, ID, "DefineButton", null);
}
/**
* Constructor
*

View File

@@ -701,6 +701,16 @@ public class DefineEditTextTag extends TextTag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public DefineEditTextTag(SWF swf) {
super(swf, ID, "DefineEditText", null);
characterID = swf.getNextCharacterId();
bounds = new RECT();
}
/**
* Constructor
*

View File

@@ -198,6 +198,7 @@ public class DefineFont2Tag extends FontTag {
public DefineFont2Tag(SWF swf) {
super(swf, ID, "DefineFont2", null);
fontId = swf.getNextCharacterId();
languageCode = new LANGCODE();
fontName = "New font";
glyphShapeTable = new ArrayList<>();
codeTable = new ArrayList<>();

View File

@@ -118,6 +118,7 @@ public class DefineFont3Tag extends FontTag {
public DefineFont3Tag(SWF swf) {
super(swf, ID, "DefineFont3", null);
fontId = swf.getNextCharacterId();
languageCode = new LANGCODE();
fontName = "New font";
glyphShapeTable = new ArrayList<>();
codeTable = new ArrayList<>();

View File

@@ -56,6 +56,7 @@ public class DefineFont4Tag extends CharacterTag {
super(swf, ID, "DefineFont4", null);
fontID = swf.getNextCharacterId();
fontName = "New font";
fontData = new byte[0];
}
public DefineFont4Tag(SWFInputStream sis, ByteArrayRange data) throws IOException {

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
@@ -147,6 +148,15 @@ public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public DefineMorphShape2Tag(SWF swf) {
super(swf, ID, "DefineMorphShape2", null);
characterId = swf.getNextCharacterId();
}
/**
* Constructor
*

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
@@ -125,6 +126,15 @@ public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public DefineMorphShapeTag(SWF swf) {
super(swf, ID, "DefineMorphShape", null);
characterId = swf.getNextCharacterId();
}
/**
* Constructor
*

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
@@ -71,6 +73,17 @@ public class DefineShape2Tag extends ShapeTag {
return shapeBounds;
}
/**
* Constructor
* @param swf
*/
public DefineShape2Tag(SWF swf) {
super(swf, ID, "DefineShape2", null);
shapeId = swf.getNextCharacterId();
shapeBounds = new RECT();
shapes = new SHAPEWITHSTYLE();
}
public DefineShape2Tag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineShape2", data);
shapeId = sis.readUI16("shapeId");

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
@@ -71,6 +73,16 @@ public class DefineShape3Tag extends ShapeTag {
return shapeId;
}
/**
* Constructor
* @param swf
*/
public DefineShape3Tag(SWF swf) {
super(swf, ID, "DefineShape3", null);
shapeId = swf.getNextCharacterId();
shapeBounds = new RECT();
}
public DefineShape3Tag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineShape3", data);
shapeId = sis.readUI16("shapeId");

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
@@ -79,6 +81,15 @@ public class DefineShape4Tag extends ShapeTag {
return shapeBounds;
}
/**
* Constructor
* @param swf
*/
public DefineShape4Tag(SWF swf) {
super(swf, ID, "DefineShape4", null);
shapeId = swf.getNextCharacterId();
}
public DefineShape4Tag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineShape4", data);
shapeId = sis.readUI16("shapeId");

View File

@@ -12,9 +12,11 @@
* 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;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
@@ -65,6 +67,16 @@ public class DefineShapeTag extends ShapeTag {
return shapeBounds;
}
/**
* Constructor
* @param swf
*/
public DefineShapeTag(SWF swf) {
super(swf, ID, "DefineShape", null);
shapeId = swf.getNextCharacterId();
shapeBounds = new RECT();
}
public DefineShapeTag(SWFInputStream sis, ByteArrayRange data) throws IOException {
super(sis.getSwf(), ID, "DefineShape", data);
shapeId = sis.readUI16("shapeId");

View File

@@ -96,6 +96,14 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public DefineSoundTag(SWF swf) {
super(swf, ID, "DefineSound", null);
}
/**
* Constructor
*

View File

@@ -188,6 +188,16 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
return ret;
}
/**
* Constructor
* @param swf
*/
public DefineSpriteTag(SWF swf) {
super(swf, ID, "DefineSprite", null);
spriteId = swf.getNextCharacterId();
subTags = new ArrayList<>();
}
/**
* Constructor
*

View File

@@ -180,7 +180,7 @@ public class DefineText2Tag extends TextTag {
try {
TextLexer lexer = new TextLexer(new StringReader(formattedText));
ParsedSymbol s = null;
textRecords = new ArrayList<>();
List<TEXTRECORD> textRecords = new ArrayList<>();
RGBA colorA = null;
int fontId = -1;
int textHeight = -1;
@@ -473,6 +473,18 @@ public class DefineText2Tag extends TextTag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public DefineText2Tag(SWF swf) {
super(swf, ID, "DefineText2", null);
characterID = swf.getNextCharacterId();
textBounds = new RECT();
glyphBits = 0;
advanceBits = 0;
}
/**
* Constructor
*

View File

@@ -434,6 +434,18 @@ public class DefineTextTag extends TextTag {
return characterID;
}
/**
* Constructor
* @param swf
*/
public DefineTextTag(SWF swf) {
super(swf, ID, "DefineText", null);
characterID = swf.getNextCharacterId();
textBounds = new RECT();
glyphBits = 0;
advanceBits = 0;
}
public DefineTextTag(SWF swf, int characterID, RECT textBounds, MATRIX textMatrix, List<TEXTRECORD> textRecords) {
super(swf, ID, "DefineText", null);
this.characterID = characterID;

View File

@@ -12,7 +12,8 @@
* 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;
@@ -97,6 +98,14 @@ public class DefineVideoStreamTag extends CharacterTag implements BoundedTag {
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public DefineVideoStreamTag(SWF swf) {
super(swf, ID, "DefineVideoStream", null);
}
/**
* Constructor
*

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
@@ -136,6 +137,14 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public SoundStreamHead2Tag(SWF swf) {
super(swf, ID, "SoundStreamHead2", null);
}
/**
* Constructor
*

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
@@ -129,6 +130,14 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea
return baos.toByteArray();
}
/**
* Constructor
* @param swf
*/
public SoundStreamHeadTag(SWF swf) {
super(swf, ID, "SoundStreamHead", null);
}
/**
* Constructor
*

View File

@@ -596,7 +596,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
for (SWF swf : newSwfs) {
tagTree.setModel(new TagTreeModel(swfs));
tagTree.setModel(new TagTreeModel(swfs, Configuration.tagTreeShowEmptyFolders.get()));
dumpTree.setModel(new DumpTreeModel(swfs));
if (swf.isAS3) {
@@ -1882,7 +1882,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
showCard(CARDEMPTYPANEL);
TreeItem treeItem = tagTree.getCurrentTreeItem();
DumpInfo dumpInfo = (DumpInfo) dumpTree.getLastSelectedPathComponent();
View.refreshTree(tagTree, new TagTreeModel(swfs));
View.refreshTree(tagTree, new TagTreeModel(swfs, Configuration.tagTreeShowEmptyFolders.get()));
View.refreshTree(dumpTree, new DumpTreeModel(swfs));
if (treeItem != null) {
setTagTreeSelectedNode(treeItem);

View File

@@ -286,4 +286,7 @@ config.name.lastDebuggerReplaceFunction = (Internal) Last selected trace replace
config.description.lastDebuggerReplaceFunction = Function name which was last selected in replace trace function with debugger
config.name.getLocalNamesFromDebugInfo = AS3: Get local register names from debug info
config.description.getLocalNamesFromDebugInfo = If debug info present, renames local registers from _loc_x_ to real names. This can be turned off because some obfuscators use invalid register names there.
config.description.getLocalNamesFromDebugInfo = If debug info present, renames local registers from _loc_x_ to real names. This can be turned off because some obfuscators use invalid register names there.
config.name.tagTreeShowEmptyFolders = Show empty folders
config.description.tagTreeShowEmptyFolders = Show empty folders in tag tree.

View File

@@ -68,10 +68,12 @@ public class TagTreeModel implements TreeModel {
private final TagTreeRoot root = new TagTreeRoot();
private final List<SWFContainerItem> swfs;
private final Map<SWF, List<TreeItem>> swfFolders;
private final boolean addAllFolders;
public TagTreeModel(List<SWFList> swfs) {
public TagTreeModel(List<SWFList> swfs, boolean addAllFolders) {
this.swfs = new ArrayList<>();
this.swfFolders = new HashMap<>();
this.addAllFolders = addAllFolders;
for (SWFList swfList : swfs) {
if (swfList.isBundle) {
this.swfs.add(swfList);
@@ -177,43 +179,43 @@ public class TagTreeModel implements TreeModel {
nodeList.add(new HeaderItem(swf, translate("node.header")));
if (!shapes.isEmpty()) {
if (addAllFolders || !shapes.isEmpty()) {
FolderItem shapesNode = new FolderItem(translate("node.shapes"), FOLDER_SHAPES, swf, shapes);
nodeList.add(shapesNode);
}
if (!morphShapes.isEmpty()) {
if (addAllFolders || !morphShapes.isEmpty()) {
FolderItem morphShapesNode = new FolderItem(translate("node.morphshapes"), FOLDER_MORPHSHAPES, swf, morphShapes);
nodeList.add(morphShapesNode);
}
if (!sprites.isEmpty()) {
if (addAllFolders || !sprites.isEmpty()) {
FolderItem spritesNode = new FolderItem(translate("node.sprites"), FOLDER_SPRITES, swf, sprites);
nodeList.add(spritesNode);
}
if (!texts.isEmpty()) {
if (addAllFolders || !texts.isEmpty()) {
FolderItem textsNode = new FolderItem(translate("node.texts"), FOLDER_TEXTS, swf, texts);
nodeList.add(textsNode);
}
if (!images.isEmpty()) {
if (addAllFolders || !images.isEmpty()) {
FolderItem imagesNode = new FolderItem(translate("node.images"), FOLDER_IMAGES, swf, images);
nodeList.add(imagesNode);
}
if (!movies.isEmpty()) {
if (addAllFolders || !movies.isEmpty()) {
FolderItem moviesNode = new FolderItem(translate("node.movies"), FOLDER_MOVIES, swf, movies);
nodeList.add(moviesNode);
}
if (!sounds.isEmpty()) {
if (addAllFolders || !sounds.isEmpty()) {
FolderItem soundsNode = new FolderItem(translate("node.sounds"), FOLDER_SOUNDS, swf, sounds);
nodeList.add(soundsNode);
}
if (!buttons.isEmpty()) {
if (addAllFolders || !buttons.isEmpty()) {
FolderItem buttonsNode = new FolderItem(translate("node.buttons"), FOLDER_BUTTONS, swf, buttons);
nodeList.add(buttonsNode);
}
if (!fonts.isEmpty()) {
if (addAllFolders || !fonts.isEmpty()) {
FolderItem fontsNode = new FolderItem(translate("node.fonts"), FOLDER_FONTS, swf, fonts);
nodeList.add(fontsNode);
}
if (!binaryData.isEmpty()) {
if (addAllFolders || !binaryData.isEmpty()) {
FolderItem binaryDataNode = new FolderItem(translate("node.binaryData"), FOLDER_BINARY_DATA, swf, binaryData);
nodeList.add(binaryDataNode);
}