Additional character info tags now placed under the character in the tree

Few icons for tags (metadata,fileattributes,setbackground,place and remove tags)
This commit is contained in:
Jindra Petřík
2015-04-06 09:09:17 +02:00
parent 406fc032b2
commit 73f3bb10cc
27 changed files with 161 additions and 69 deletions

View File

@@ -352,7 +352,7 @@ public final class SWF implements SWFContainerItem, Timelined {
di.getChildInfos().clear();
}
public Map<Integer, CharacterTag> getCharacters() {
if (characters == null) {
synchronized (this) {
@@ -857,9 +857,11 @@ public final class SWF implements SWFContainerItem, Timelined {
this.tags = tags;
if (!checkOnly) {
checkInvalidSprites();
Map<Integer, CharacterTag> chars = new HashMap<>();
parseCharacters(tags, chars);
characters = chars;
assignExportNamesToSymbols();
assignClassesToSymbols();
SWFDecompilerPlugin.fireSwfParsed(this);
} else {
boolean hasNonUnknownTag = false;
@@ -950,8 +952,8 @@ public final class SWF implements SWFContainerItem, Timelined {
}
}
for (Tag t : tags) {
if (t instanceof CharacterIdTag) {
CharacterIdTag ct = (CharacterIdTag) t;
if (t instanceof CharacterTag) {
CharacterTag ct = (CharacterTag) t;
if (exportNames.containsKey(ct.getCharacterId())) {
ct.setExportName(exportNames.get(ct.getCharacterId()));
}
@@ -1939,7 +1941,7 @@ public final class SWF implements SWFContainerItem, Timelined {
cnt++;
informListeners("rename", "class " + cnt + "/" + classCount);
DoInitActionTag dia = (DoInitActionTag) t;
String exportName = dia.getExportName();
String exportName = characters.containsKey(dia.spriteId)?characters.get(dia.spriteId).getExportName():"_unk_";
final String pkgPrefix = "__Packages.";
String[] classNameParts = null;
if ((exportName != null) && exportName.startsWith(pkgPrefix)) {

View File

@@ -19,6 +19,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;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -32,7 +33,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class CSMTextSettingsTag extends Tag {
public class CSMTextSettingsTag extends Tag implements CharacterIdTag {
@SWFType(BasicType.UI16)
public int textID;
@@ -114,4 +115,9 @@ public class CSMTextSettingsTag extends Tag {
sharpness = sis.readFLOAT("sharpness"); //F32 = FLOAT
reserved2 = sis.readUI8("reserved2"); //reserved
}
@Override
public int getCharacterId() {
return textID;
}
}

View File

@@ -19,6 +19,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;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.CXFORM;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -32,7 +33,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class DefineButtonCxformTag extends Tag {
public class DefineButtonCxformTag extends Tag implements CharacterIdTag {
@SWFType(BasicType.UI16)
public int buttonId;
@@ -87,4 +88,9 @@ public class DefineButtonCxformTag extends Tag {
buttonId = sis.readUI16("buttonId");
buttonColorTransform = sis.readCXFORM("buttonColorTransform");
}
@Override
public int getCharacterId() {
return buttonId;
}
}

View File

@@ -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.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.SOUNDINFO;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -33,7 +34,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class DefineButtonSoundTag extends CharacterIdTag {
public class DefineButtonSoundTag extends CharacterTag {
@SWFType(BasicType.UI16)
public int buttonId;

View File

@@ -19,6 +19,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;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.ZONERECORD;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
@@ -31,7 +32,7 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
public class DefineFontAlignZonesTag extends Tag {
public class DefineFontAlignZonesTag extends Tag implements CharacterIdTag {
@SWFType(BasicType.UI16)
public int fontID;
@@ -97,4 +98,9 @@ public class DefineFontAlignZonesTag extends Tag {
}
return baos.toByteArray();
}
@Override
public int getCharacterId() {
return fontID;
}
}

View File

@@ -19,6 +19,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;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.LANGCODE;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
@@ -36,7 +37,7 @@ import java.util.List;
*
* @author JPEXS
*/
public class DefineFontInfo2Tag extends Tag {
public class DefineFontInfo2Tag extends Tag implements CharacterIdTag {
@SWFType(BasicType.UI16)
public int fontID;
@@ -145,4 +146,9 @@ public class DefineFontInfo2Tag extends Tag {
codeTable.add(sis.readUI16("code"));
}
}
@Override
public int getCharacterId() {
return fontID;
}
}

View File

@@ -19,6 +19,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;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -35,7 +36,7 @@ import java.util.List;
*
* @author JPEXS
*/
public class DefineFontInfoTag extends Tag {
public class DefineFontInfoTag extends Tag implements CharacterIdTag {
@SWFType(BasicType.UI16)
public int fontId;
@@ -146,4 +147,9 @@ public class DefineFontInfoTag extends Tag {
}
}
}
@Override
public int getCharacterId() {
return fontId;
}
}

View File

@@ -19,6 +19,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;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.helpers.ByteArrayRange;
@@ -26,7 +27,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class DefineFontNameTag extends Tag {
public class DefineFontNameTag extends Tag implements CharacterIdTag {
@SWFType(BasicType.UI16)
public int fontId;
@@ -79,4 +80,9 @@ public class DefineFontNameTag extends Tag {
}
return baos.toByteArray();
}
@Override
public int getCharacterId() {
return fontId;
}
}

View File

@@ -19,6 +19,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;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -30,7 +31,7 @@ import java.io.OutputStream;
/**
* @author JPEXS
*/
public class DefineScalingGridTag extends Tag {
public class DefineScalingGridTag extends Tag implements CharacterIdTag {
@SWFType(BasicType.UI16)
public int characterId;
@@ -78,4 +79,9 @@ public class DefineScalingGridTag extends Tag {
}
return baos.toByteArray();
}
@Override
public int getCharacterId() {
return characterId;
}
}

View File

@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -39,7 +40,7 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class DoInitActionTag extends CharacterIdTag implements ASMSource {
public class DoInitActionTag extends Tag implements CharacterIdTag,ASMSource {
/**
* Identifier of Sprite
@@ -193,7 +194,8 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
@Override
public String getExportFileName() {
String expName = getExportName();
CharacterTag sprite=swf.getCharacter(spriteId);
String expName = sprite!=null?sprite.getExportName():null;
if ((expName == null) || expName.isEmpty()) {
return super.getExportFileName();
}
@@ -208,7 +210,8 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
@Override
public String getName() {
String expName = getExportName();
CharacterTag sprite=swf.getCharacter(spriteId);
String expName = sprite!=null?sprite.getExportName():null;
if ((expName == null) || expName.isEmpty()) {
return super.getName();
}

View File

@@ -33,7 +33,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class RemoveObjectTag extends CharacterIdTag implements RemoveTag {
public class RemoveObjectTag extends Tag implements CharacterIdTag,RemoveTag {
/**
* ID of character to place

View File

@@ -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.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
@@ -40,7 +41,7 @@ import java.util.List;
*
* @author JPEXS
*/
public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHeadTypeTag {
public class SoundStreamHead2Tag extends CharacterTag implements SoundStreamHeadTypeTag {
@Reserved
@SWFType(value = BasicType.UB, count = 4)

View File

@@ -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.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
@@ -40,7 +41,7 @@ import java.util.List;
*
* @author JPEXS
*/
public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHeadTypeTag {
public class SoundStreamHeadTag extends CharacterTag implements SoundStreamHeadTypeTag {
@Reserved
@SWFType(value = BasicType.UB, count = 4)
@@ -261,4 +262,6 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea
final int[] rateMap = {5512, 11025, 22050, 44100};
return new SoundFormat(getSoundFormatId(), rateMap[getSoundRate()], getSoundType());
}
}

View File

@@ -24,49 +24,10 @@ import com.jpexs.helpers.ByteArrayRange;
*
* @author JPEXS
*/
public abstract class CharacterIdTag extends Tag {
public interface CharacterIdTag {
public CharacterIdTag(SWF swf, int id, String name, ByteArrayRange data) {
super(swf, id, name, data);
}
public abstract int getCharacterId();
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() {
String result = super.getExportFileName() + "_" + getCharacterId();
return result + (exportName != null ? "_" + exportName : "");
}
public String getCharacterExportFileName() {
return getCharacterId() + (exportName != null ? "_" + exportName : "");
}
public String getExportName() {
return exportName;
}
public int getCharacterId();
}

View File

@@ -17,13 +17,14 @@
package com.jpexs.decompiler.flash.tags.base;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.ByteArrayRange;
/**
*
* @author JPEXS
*/
public abstract class CharacterTag extends CharacterIdTag {
public abstract class CharacterTag extends Tag implements CharacterIdTag {
protected String className;
@@ -57,8 +58,20 @@ public abstract class CharacterTag extends CharacterIdTag {
return result + (className != null ? "_" + className : "");
}
@Override
public String getCharacterExportFileName() {
return getCharacterId() + (exportName != null ? "_" + exportName : "") + (className != null ? "_" + className : "");
}
protected String exportName;
public void setExportName(String exportName) {
if ("".equals(exportName)) {
exportName = null;
}
this.exportName = exportName;
}
public String getExportName() {
return exportName;
}
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.tags.base;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.types.CLIPACTIONS;
import com.jpexs.decompiler.flash.types.ColorTransform;
import com.jpexs.decompiler.flash.types.MATRIX;
@@ -31,7 +32,7 @@ import java.util.List;
*
* @author JPEXS
*/
public abstract class PlaceObjectTypeTag extends CharacterIdTag {
public abstract class PlaceObjectTypeTag extends Tag implements CharacterIdTag {
public PlaceObjectTypeTag(SWF swf, int id, String name, ByteArrayRange data) {
super(swf, id, name, data);

View File

@@ -360,7 +360,8 @@ public class Timeline {
for (ASMSource asm : asmSources) {
if (asm instanceof DoInitActionTag) {
DoInitActionTag initAction = (DoInitActionTag) asm;
String path = initAction.getExportName();
CharacterTag cht=swf.getCharacter(initAction.spriteId);
String path = cht!=null?cht.getExportName():"_unk_";
if (path == null || path.isEmpty()) {
path = initAction.getExportFileName();
}

View File

@@ -2733,7 +2733,10 @@ public class XFLConverter {
DefineSpriteTag sprite = (DefineSpriteTag) characters.get(chid);
if (sprite.subTags.isEmpty()) {
String data = convertActionScript(dia);
String expPath = dia.getExportName();
CharacterTag spr=dia.getSwf().getCharacter(dia.spriteId);
String expName = spr!=null?spr.getExportName():"_unk_";
String expPath = spr.getExportName();
final String prefix = "__Packages.";
if (expPath.startsWith(prefix)) {
expPath = expPath.substring(prefix.length());