Added: FreeCharacter tag support, SyncFrame tag support

This commit is contained in:
Jindra Petřík
2025-08-29 09:53:41 +02:00
parent 1e9bf6be88
commit 1316c1e58b
19 changed files with 90 additions and 34 deletions

View File

@@ -16,9 +16,11 @@
*/
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.tags.FreeCharacterTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.tags.base.RemoveTag;
@@ -64,11 +66,8 @@ public class DefineBeforeUsageFixer {
int i = 0;
for (int j = 0; j < swf.getTags().size(); j++) {
Tag t2 = swf.getTags().get(j);
if ((t2 instanceof CharacterIdTag)
&& !(t2 instanceof PlaceObjectTypeTag)
&& !(t2 instanceof RemoveTag)
&& !(t2 instanceof VideoFrameTag)) {
CharacterIdTag chit = (CharacterIdTag) t2;
if (t2 instanceof CharacterModifier) {
CharacterModifier chit = (CharacterModifier) t2;
if (chit.getCharacterId() == characterId) {
swf.removeTag(j);
swf.addTag(usageIndex + i, (Tag) chit);

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.CXFORM;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -35,7 +35,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 2)
public class DefineButtonCxformTag extends Tag implements CharacterIdTag {
public class DefineButtonCxformTag extends Tag implements CharacterModifier {
public static final int ID = 23;

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.SOUNDINFO;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -35,7 +35,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 2)
public class DefineButtonSoundTag extends Tag implements CharacterIdTag {
public class DefineButtonSoundTag extends Tag implements CharacterModifier {
public static final int ID = 17;

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.ZONERECORD;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
@@ -40,7 +40,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 8)
public class DefineFontAlignZonesTag extends Tag implements CharacterIdTag {
public class DefineFontAlignZonesTag extends Tag implements CharacterModifier {
public static final int ID = 73;

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
@@ -34,7 +34,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 9)
public class DefineFontNameTag extends Tag implements CharacterIdTag {
public class DefineFontNameTag extends Tag implements CharacterModifier {
public static final int ID = 88;

View File

@@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import com.jpexs.decompiler.flash.exporters.commonshape.Point;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
import com.jpexs.decompiler.flash.tags.base.RenderContext;
@@ -46,7 +46,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 8)
public class DefineScalingGridTag extends Tag implements CharacterIdTag {
public class DefineScalingGridTag extends Tag implements CharacterModifier {
public static final int ID = 78;

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -36,7 +36,7 @@ import java.util.List;
* @author JPEXS
*/
@SWFVersion(from = 3)
public class DefineTextFormatTag extends Tag implements CharacterIdTag {
public class DefineTextFormatTag extends Tag implements CharacterModifier {
public static final int ID = 42;

View File

@@ -24,7 +24,7 @@ import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
/**
* FreeAll tag - undocumented.
* FreeAll tag - undocumented. Seems to do nothing.
*
* @author JPEXS
*/

View File

@@ -25,10 +25,11 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
/**
* FreeCharacter tag - undocumented.
* FreeCharacter tag - undocumented. Frees a character.
*
* @author JPEXS
*/
@@ -89,4 +90,13 @@ public class FreeCharacterTag extends Tag implements CharacterIdTag {
public void getNeededCharacters(Set<Integer> needed, SWF swf) {
needed.add(characterId);
}
@Override
public Map<String, String> getNameProperties() {
Map<String, String> ret = super.getNameProperties();
ret.put("chid", "" + characterId);
return ret;
}
}

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
@@ -34,7 +34,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 3)
public class NameCharacterTag extends Tag implements CharacterIdTag {
public class NameCharacterTag extends Tag implements CharacterModifier {
public static final int ID = 40;

View File

@@ -53,6 +53,8 @@ public class ShowFrameTag extends Tag {
add(SoundStreamBlockTag.ID);
add(SetTabIndexTag.ID);
add(GenCommandTag.ID);
add(FreeCharacterTag.ID);
add(SyncFrameTag.ID);
/*add(SoundStreamHeadTag.ID);
add(SoundStreamHead2Tag.ID);*/
}

View File

@@ -413,6 +413,10 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
addTagInfo(map, map2, NameCharacterTag.ID, NameCharacterTag.class, NameCharacterTag.NAME);
addTagInfo(map, map2, CharacterSetTag.ID, CharacterSetTag.class, CharacterSetTag.NAME);
addTagInfo(map, map2, SerialNumberTag.ID, SerialNumberTag.class, SerialNumberTag.NAME);
addTagInfo(map, map2, FreeCharacterTag.ID, FreeCharacterTag.class, FreeCharacterTag.NAME);
addTagInfo(map, map2, SyncFrameTag.ID, SyncFrameTag.class, SyncFrameTag.NAME);
knownTagInfosById = map;
knownTagInfosByName = map2;
}

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2010-2025 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.tags.base;
/**
* A CharacterIdTag that modifies the character somehow
* @author JPEXS
*/
public interface CharacterModifier extends CharacterIdTag {
}

View File

@@ -29,7 +29,7 @@ import java.util.Map;
*
* @author JPEXS
*/
public abstract class FontInfoTag extends Tag implements CharacterIdTag {
public abstract class FontInfoTag extends Tag implements CharacterModifier {
/**
* Font ID