Correct adding new subtags (CharacterId tags)

This commit is contained in:
Jindra Petřík
2015-04-18 06:06:12 +02:00
parent 642b6827db
commit 76bd6e8df6
47 changed files with 275 additions and 17 deletions

View File

@@ -222,7 +222,9 @@
<zipfileset file="${app.info.temp}" fullpath="FFDec.app/Contents/Info.plist" />
<zipfileset dir="${DISTRIBUTIONDIR}" excludes="ffdec.sh" prefix="FFDec.app/Contents/Resources/" />
<zipfileset dir="${DISTRIBUTIONDIR}" includes="ffdec.sh" fullpath="FFDec.app/Contents/Resources/ffdec.sh" filemode="755" />
</zip>
</zip>
<delete file="${app.script.temp}" />
<delete file="${app.info.temp}" />
</target>
<target name="-set-gui-type">

View File

@@ -120,4 +120,9 @@ public class CSMTextSettingsTag extends Tag implements CharacterIdTag {
public int getCharacterId() {
return textID;
}
@Override
public void setCharacterId(int characterId) {
this.textID = characterId;
}
}

View File

@@ -139,4 +139,9 @@ public class DefineBinaryDataTag extends CharacterTag {
}
return false;
}
@Override
public void setCharacterId(int characterId) {
this.tag = characterId;
}
}

View File

@@ -124,4 +124,9 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
}
return baos.toByteArray();
}
@Override
public void setCharacterId(int characterId) {
this.characterID = characterId;
}
}

View File

@@ -161,4 +161,9 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
}
return baos.toByteArray();
}
@Override
public void setCharacterId(int characterId) {
this.characterID = characterId;
}
}

View File

@@ -171,4 +171,9 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
imageData = sis.readByteRangeEx(alphaDataOffset, "imageData");
bitmapAlphaData = sis.readByteRangeEx(sis.available(), "bitmapAlphaData");
}
@Override
public void setCharacterId(int characterId) {
this.characterID = characterId;
}
}

View File

@@ -277,4 +277,9 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
cachedImage = bi;
return bi;
}
@Override
public void setCharacterId(int characterId) {
this.characterID = characterId;
}
}

View File

@@ -279,4 +279,9 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
public String getImageFormat() {
return "png";
}
@Override
public void setCharacterId(int characterId) {
this.characterID = characterId;
}
}

View File

@@ -137,4 +137,9 @@ public class DefineBitsTag extends ImageTag implements TagChangedListener {
public void handleEvent(Tag tag) {
clearCache();
}
@Override
public void setCharacterId(int characterId) {
this.characterID = characterId;
}
}

View File

@@ -323,4 +323,9 @@ public class DefineButton2Tag extends ButtonTag implements ASMSourceContainer {
timeline.addFrame(frameHit);
return timeline;
}
@Override
public void setCharacterId(int characterId) {
this.buttonId = characterId;
}
}

View File

@@ -93,4 +93,9 @@ public class DefineButtonCxformTag extends Tag implements CharacterIdTag {
public int getCharacterId() {
return buttonId;
}
@Override
public void setCharacterId(int characterId) {
this.buttonId = characterId;
}
}

View File

@@ -140,4 +140,9 @@ public class DefineButtonSoundTag extends Tag implements CharacterIdTag {
buttonSoundInfo3 = sis.readSOUNDINFO("buttonSoundInfo3");
}
}
@Override
public void setCharacterId(int characterId) {
this.buttonId = characterId;
}
}

View File

@@ -413,4 +413,9 @@ public class DefineButtonTag extends ButtonTag implements ASMSource {
public Tag getSourceTag() {
return this;
}
@Override
public void setCharacterId(int characterId) {
this.buttonId = characterId;
}
}

View File

@@ -1124,4 +1124,9 @@ public class DefineEditTextTag extends TextTag {
public String toHtmlCanvas(double unitDivisor) {
return render(true, null, new Matrix(), new ColorTransform());
}
@Override
public void setCharacterId(int characterId) {
this.characterID = characterId;
}
}

View File

@@ -500,4 +500,9 @@ public class DefineFont2Tag extends FontTag {
}
return kerningAdjustment;
}
@Override
public void setCharacterId(int characterId) {
this.fontId = characterId;
}
}

View File

@@ -515,4 +515,9 @@ public class DefineFont3Tag extends FontTag {
}
return kerningAdjustment;
}
@Override
public void setCharacterId(int characterId) {
this.fontId = characterId;
}
}

View File

@@ -105,4 +105,9 @@ public class DefineFont4Tag extends CharacterTag {
}
return baos.toByteArray();
}
@Override
public void setCharacterId(int characterId) {
this.fontID = characterId;
}
}

View File

@@ -103,4 +103,9 @@ public class DefineFontAlignZonesTag extends Tag implements CharacterIdTag {
public int getCharacterId() {
return fontID;
}
@Override
public void setCharacterId(int characterId) {
this.fontID = characterId;
}
}

View File

@@ -151,4 +151,9 @@ public class DefineFontInfo2Tag extends Tag implements CharacterIdTag {
public int getCharacterId() {
return fontID;
}
@Override
public void setCharacterId(int characterId) {
this.fontID = characterId;
}
}

View File

@@ -152,4 +152,9 @@ public class DefineFontInfoTag extends Tag implements CharacterIdTag {
public int getCharacterId() {
return fontId;
}
@Override
public void setCharacterId(int characterId) {
this.fontId = characterId;
}
}

View File

@@ -85,4 +85,9 @@ public class DefineFontNameTag extends Tag implements CharacterIdTag {
public int getCharacterId() {
return fontId;
}
@Override
public void setCharacterId(int characterId) {
this.fontId = characterId;
}
}

View File

@@ -361,4 +361,9 @@ public class DefineFontTag extends FontTag {
public int getCharKerningAdjustment(char c1, char c2) {
return 0;
}
@Override
public void setCharacterId(int characterId) {
this.fontId = characterId;
}
}

View File

@@ -412,4 +412,9 @@ public class DefineMorphShape2Tag extends MorphShapeTag {
return cmse.getShapeData();
}
@Override
public void setCharacterId(int characterId) {
this.characterId = characterId;
}
}

View File

@@ -388,4 +388,9 @@ public class DefineMorphShapeTag extends MorphShapeTag {
return cmse.getShapeData();
}
@Override
public void setCharacterId(int characterId) {
this.characterId = characterId;
}
}

View File

@@ -84,4 +84,9 @@ public class DefineScalingGridTag extends Tag implements CharacterIdTag {
public int getCharacterId() {
return characterId;
}
@Override
public void setCharacterId(int characterId) {
this.characterId = characterId;
}
}

View File

@@ -148,4 +148,9 @@ public class DefineShape2Tag extends ShapeTag {
public boolean isSingleFrame() {
return true;
}
@Override
public void setCharacterId(int characterId) {
this.shapeId = characterId;
}
}

View File

@@ -148,4 +148,9 @@ public class DefineShape3Tag extends ShapeTag {
public boolean isSingleFrame() {
return true;
}
@Override
public void setCharacterId(int characterId) {
this.shapeId = characterId;
}
}

View File

@@ -172,4 +172,9 @@ public class DefineShape4Tag extends ShapeTag {
public boolean isSingleFrame() {
return true;
}
@Override
public void setCharacterId(int characterId) {
this.shapeId = characterId;
}
}

View File

@@ -146,4 +146,9 @@ public class DefineShapeTag extends ShapeTag {
public boolean isSingleFrame() {
return true;
}
@Override
public void setCharacterId(int characterId) {
this.shapeId = characterId;
}
}

View File

@@ -355,4 +355,9 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
final int[] rateMap = {5512, 11025, 22050, 44100};
return new SoundFormat(getSoundFormatId(), rateMap[getSoundRate()], getSoundType());
}
@Override
public void setCharacterId(int characterId) {
this.soundId = characterId;
}
}

View File

@@ -367,4 +367,9 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli
public String toHtmlCanvas(double unitDivisor) {
return getTimeline().toHtmlCanvas(unitDivisor, null);
}
@Override
public void setCharacterId(int characterId) {
this.spriteId = characterId;
}
}

View File

@@ -633,4 +633,9 @@ public class DefineText2Tag extends TextTag {
public String toHtmlCanvas(double unitDivisor) {
return staticTextToHtmlCanvas(unitDivisor, swf, textRecords, 2, textBounds, textMatrix, new ColorTransform());
}
@Override
public void setCharacterId(int characterId) {
this.characterID = characterId;
}
}

View File

@@ -645,4 +645,9 @@ public class DefineTextTag extends TextTag {
public String toHtmlCanvas(double unitDivisor) {
return staticTextToHtmlCanvas(unitDivisor, swf, textRecords, 1, textBounds, textMatrix, new ColorTransform());
}
@Override
public void setCharacterId(int characterId) {
this.characterID = characterId;
}
}

View File

@@ -145,4 +145,9 @@ public class DefineVideoStreamTag extends CharacterTag implements BoundedTag {
public RECT getRect(Set<BoundedTag> added) {
return new RECT(0, (int) (SWF.unitDivisor * width), 0, (int) (SWF.unitDivisor * height));
}
@Override
public void setCharacterId(int characterId) {
this.characterID = characterId;
}
}

View File

@@ -208,7 +208,7 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource {
@Override
public String getName() {
String expName = swf==null?"":swf.getExportName(spriteId);
String expName = swf == null ? "" : swf.getExportName(spriteId);
if ((expName == null) || expName.isEmpty()) {
return super.getName();
}
@@ -245,4 +245,10 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource {
public Tag getSourceTag() {
return this;
}
@Override
public void setCharacterId(int characterId) {
this.spriteId = characterId;
}
}

View File

@@ -426,4 +426,9 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont
setModified(mod);
matrix = old;
}
@Override
public void setCharacterId(int characterId) {
this.characterId = characterId;
}
}

View File

@@ -571,4 +571,9 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
setModified(mod);
matrix = old;
}
@Override
public void setCharacterId(int characterId) {
this.characterId = characterId;
}
}

View File

@@ -574,4 +574,9 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
setModified(mod);
matrix = old;
}
@Override
public void setCharacterId(int characterId) {
this.characterId = characterId;
}
}

View File

@@ -237,4 +237,9 @@ public class PlaceObjectTag extends PlaceObjectTypeTag {
setModified(mod);
matrix = old;
}
@Override
public void setCharacterId(int characterId) {
this.characterId = characterId;
}
}

View File

@@ -105,4 +105,9 @@ public class RemoveObjectTag extends RemoveTag implements CharacterIdTag {
public int getCharacterId() {
return characterId;
}
@Override
public void setCharacterId(int characterId) {
this.characterId = characterId;
}
}

View File

@@ -243,4 +243,9 @@ public class SoundStreamHead2Tag extends Tag implements SoundStreamHeadTypeTag {
String exportName = swf.getExportName(getCharacterId());
return getCharacterId() + (exportName != null ? "_" + exportName : "");
}
@Override
public void setCharacterId(int characterId) {
this.virtualCharacterId = characterId;
}
}

View File

@@ -98,6 +98,11 @@ public class SoundStreamHeadTag extends Tag implements SoundStreamHeadTypeTag {
return virtualCharacterId;
}
@Override
public void setCharacterId(int characterId) {
this.virtualCharacterId = characterId;
}
@Override
public void setVirtualCharacterId(int ch) {
virtualCharacterId = ch;

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;
@@ -31,7 +32,7 @@ import java.io.OutputStream;
*
* @author JPEXS
*/
public class VideoFrameTag extends Tag {
public class VideoFrameTag extends Tag implements CharacterIdTag {
@SWFType(BasicType.UI16)
public int streamID;
@@ -91,4 +92,14 @@ public class VideoFrameTag extends Tag {
frameNum = sis.readUI16("frameNum");
videoData = sis.readByteRangeEx(sis.available(), "videoData"); //TODO: Parse video packets
}
@Override
public int getCharacterId() {
return streamID;
}
@Override
public void setCharacterId(int characterId) {
this.streamID = characterId;
}
}

View File

@@ -23,4 +23,6 @@ package com.jpexs.decompiler.flash.tags.base;
public interface CharacterIdTag {
public int getCharacterId();
public void setCharacterId(int characterId);
}

View File

@@ -423,4 +423,9 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag {
public boolean hasLayout() {
return true;
}
@Override
public void setCharacterId(int characterId) {
this.fontId = characterId;
}
}

View File

@@ -94,6 +94,7 @@ import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.tags.base.ImageTag;
import com.jpexs.decompiler.flash.tags.base.MorphShapeTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
@@ -177,7 +178,7 @@ public class TagTree extends JTree {
// SWF was closed
value = null;
}
super.getTreeCellRendererComponent(
tree, value, sel,
expanded, leaf, row,
@@ -410,9 +411,12 @@ public class TagTree extends JTree {
ret = new ArrayList<>();
break;
case TagTreeModel.FOLDER_OTHERS:
ret = Arrays.asList(CSMTextSettingsTag.ID, DebugIDTag.ID, DefineButtonCxformTag.ID, DefineButtonSoundTag.ID,
DefineFontAlignZonesTag.ID, DefineFontInfoTag.ID, DefineFontInfo2Tag.ID, DefineFontNameTag.ID,
DefineScalingGridTag.ID, DefineSceneAndFrameLabelDataTag.ID,
ret = Arrays.asList(
//CSMTextSettingsTag.ID,
DebugIDTag.ID,
//DefineButtonCxformTag.ID, DefineButtonSoundTag.ID,
//DefineFontAlignZonesTag.ID, DefineFontInfoTag.ID, DefineFontInfo2Tag.ID, DefineFontNameTag.ID,
/*DefineScalingGridTag.ID,*/ DefineSceneAndFrameLabelDataTag.ID,
DoABCDefineTag.ID, DoABCTag.ID, DoActionTag.ID, DoInitActionTag.ID,
EnableDebuggerTag.ID, EnableDebugger2Tag.ID, EnableTelemetryTag.ID,
ExportAssetsTag.ID, FileAttributesTag.ID, ImportAssetsTag.ID, ImportAssets2Tag.ID,
@@ -424,11 +428,27 @@ public class TagTree extends JTree {
return ret;
}
public List<Integer> getSpriteNestedTagIds() {
return Arrays.asList(PlaceObjectTag.ID, PlaceObject2Tag.ID, PlaceObject3Tag.ID, PlaceObject4Tag.ID,
RemoveObjectTag.ID, RemoveObject2Tag.ID, ShowFrameTag.ID, FrameLabelTag.ID,
StartSoundTag.ID, StartSound2Tag.ID, VideoFrameTag.ID,
SoundStreamBlockTag.ID, SoundStreamHeadTag.ID, SoundStreamHead2Tag.ID);
public List<Integer> getNestedTagIds(Tag obj) {
if (obj instanceof DefineSpriteTag) {
return Arrays.asList(PlaceObjectTag.ID, PlaceObject2Tag.ID, PlaceObject3Tag.ID, PlaceObject4Tag.ID,
RemoveObjectTag.ID, RemoveObject2Tag.ID, ShowFrameTag.ID, FrameLabelTag.ID,
StartSoundTag.ID, StartSound2Tag.ID, VideoFrameTag.ID,
SoundStreamBlockTag.ID, SoundStreamHeadTag.ID, SoundStreamHead2Tag.ID,
DefineScalingGridTag.ID);
}
if (obj instanceof FontTag) {
return Arrays.asList(DefineFontNameTag.ID, DefineFontAlignZonesTag.ID, DefineFontInfoTag.ID, DefineFontInfo2Tag.ID);
}
if (obj instanceof TextTag) {
return Arrays.asList(CSMTextSettingsTag.ID);
}
if (obj instanceof DefineButtonTag) {
return Arrays.asList(DefineButtonCxformTag.ID, DefineButtonSoundTag.ID, DefineScalingGridTag.ID);
}
if (obj instanceof DefineButton2Tag) {
return Arrays.asList(DefineButtonSoundTag.ID, DefineScalingGridTag.ID);
}
return null;
}
public boolean hasExportableNodes() {
@@ -565,7 +585,7 @@ public class TagTree extends JTree {
if (!mainPanel.folderPreviewPanel.selectedItems.isEmpty()) {
return mainPanel.folderPreviewPanel.selectedItems.entrySet().iterator().next().getValue();
}
TreeItem item = (TreeItem) getLastSelectedPathComponent();
return item;
}
@@ -580,7 +600,7 @@ public class TagTree extends JTree {
TreeItem root = ttm.getRoot();
expandPath(new TreePath(new Object[]{root}));
}
public void expandFirstLevelNodes() {
TagTreeModel ttm = getModel();
TreeItem root = ttm.getRoot();

View File

@@ -324,8 +324,8 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
List<Integer> allowedTagTypes = null;
if (firstItem instanceof FolderItem) {
allowedTagTypes = tagTree.getSwfFolderItemNestedTagIds(((FolderItem) firstItem).getName(), firstItem.getSwf().gfx);
} else if (firstItem instanceof DefineSpriteTag) {
allowedTagTypes = tagTree.getSpriteNestedTagIds();
} else if (firstItem instanceof Tag) {
allowedTagTypes = tagTree.getNestedTagIds((Tag) firstItem);
}
addTagMenu.removeAll();
@@ -347,7 +347,19 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
if (isDefineSprite) {
((DefineSpriteTag) firstItem).subTags.add(t);
} else {
swf.tags.add(t);
if (firstItem instanceof Tag) {
if ((t instanceof CharacterIdTag) && (firstItem instanceof CharacterTag)) {
((CharacterIdTag) t).setCharacterId(((CharacterTag) firstItem).getCharacterId());
}
int index = swf.tags.indexOf(firstItem);
if (index > -1) {
swf.tags.add(index, t);
} else {
swf.tags.add(t);
}
} else {
swf.tags.add(t);
}
}
timelined.getTimeline().reset();
swf.updateCharacters();