#742 Can't edit frames fixed, Container/ContainerItems refactored, build fixed on linux (Pull request #12)

This commit is contained in:
honfika@gmail.com
2014-12-07 20:53:14 +01:00
parent bc3967597c
commit a4cd36fd71
18 changed files with 115 additions and 209 deletions

View File

@@ -104,12 +104,11 @@ import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.TagStub;
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.tags.base.ImageTag;
@@ -283,7 +282,7 @@ public final class SWF implements SWFContainerItem, Timelined {
public void updateCharacters() {
characters.clear();
parseCharacters(new ArrayList<ContainerItem>(tags));
parseCharacters(tags);
}
public int getNextCharacterId() {
@@ -363,13 +362,13 @@ public final class SWF implements SWFContainerItem, Timelined {
}
}
private void parseCharacters(List<? extends ContainerItem> list) {
for (ContainerItem t : list) {
private void parseCharacters(List<Tag> list) {
for (Tag t : list) {
if (t instanceof CharacterTag) {
characters.put(((CharacterTag) t).getCharacterId(), (CharacterTag) t);
}
if (t instanceof Container) {
parseCharacters(((Container) t).getSubItems());
if (t instanceof DefineSpriteTag) {
parseCharacters(((DefineSpriteTag) t).getSubTags());
}
}
}
@@ -693,10 +692,10 @@ public final class SWF implements SWFContainerItem, Timelined {
abcList = newAbcList;
}
private static void getABCTags(List<? extends ContainerItem> list, List<ABCContainerTag> actionScripts) {
for (ContainerItem t : list) {
if (t instanceof Container) {
getABCTags(((Container) t).getSubItems(), actionScripts);
private static void getABCTags(List<Tag> list, List<ABCContainerTag> actionScripts) {
for (Tag t : list) {
if (t instanceof DefineSpriteTag) {
getABCTags(((DefineSpriteTag) t).getSubTags(), actionScripts);
}
if (t instanceof ABCContainerTag) {
actionScripts.add((ABCContainerTag) t);
@@ -1084,23 +1083,32 @@ public final class SWF implements SWFContainerItem, Timelined {
return asms;
}
private static void getASMs(String path, List<? extends ContainerItem> items, Map<String, ASMSource> asms) {
for (ContainerItem item : items) {
String subPath = path + "/" + item.toString();
if (item instanceof ASMSource) {
String npath = subPath;
int ppos = 1;
while (asms.containsKey(npath)) {
ppos++;
npath = subPath + "[" + ppos + "]";
}
asms.put(npath, (ASMSource) item);
private static void getASMs(String path, List<Tag> items, Map<String, ASMSource> asms) {
for (Tag t : items) {
String subPath = path + "/" + t.toString();
if (t instanceof ASMSource) {
addASM(asms, (ASMSource) t, subPath);
}
if (item instanceof Container) {
getASMs(subPath, ((Container) item).getSubItems(), asms);
if (t instanceof ASMSourceContainer) {
for (ASMSource asm : ((ASMSourceContainer) t).getSubItems()) {
addASM(asms, asm, subPath + "/" + asm.toString());
}
}
if (t instanceof DefineSpriteTag) {
getASMs(subPath, ((DefineSpriteTag) t).getSubTags(), asms);
}
}
}
private static void addASM(Map<String, ASMSource> asms, ASMSource asm, String path) {
String npath = path;
int ppos = 1;
while (asms.containsKey(npath)) {
ppos++;
npath = path + "[" + ppos + "]";
}
asms.put(npath, asm);
}
private final HashSet<EventListener> listeners = new HashSet<>();
@@ -1142,13 +1150,13 @@ public final class SWF implements SWFContainerItem, Timelined {
return false;
}
public static void populateVideoFrames(int streamId, List<? extends ContainerItem> tags, HashMap<Integer, VideoFrameTag> output) {
for (ContainerItem t : tags) {
public static void populateVideoFrames(int streamId, List<Tag> tags, HashMap<Integer, VideoFrameTag> output) {
for (Tag t : tags) {
if (t instanceof VideoFrameTag) {
output.put(((VideoFrameTag) t).frameNum, (VideoFrameTag) t);
}
if (t instanceof Container) {
populateVideoFrames(streamId, ((Container) t).getSubItems(), output);
if (t instanceof DefineSpriteTag) {
populateVideoFrames(streamId, ((DefineSpriteTag) t).getSubTags(), output);
}
}
}
@@ -1784,27 +1792,37 @@ public final class SWF implements SWFContainerItem, Timelined {
}
private HashMap<ASMSource, ActionList> actionsMap = new HashMap<>();
private void getVariables(List<? extends ContainerItem> objs, String path) throws InterruptedException {
private void getVariables(List<Tag> tags, String path) throws InterruptedException {
List<String> processed = new ArrayList<>();
for (ContainerItem o : objs) {
if (o instanceof ASMSource) {
String infPath = path + "/" + o.toString();
int pos = 1;
String infPath2 = infPath;
while (processed.contains(infPath2)) {
pos++;
infPath2 = infPath + "[" + pos + "]";
}
processed.add(infPath2);
informListeners("getVariables", infPath2);
getVariables(allVariableNames, allFunctions, allStrings, usageTypes, (ASMSource) o, path);
for (Tag t : tags) {
String subPath = path + "/" + t.toString();
if (t instanceof ASMSource) {
addVariable((ASMSource) t, subPath, processed);
}
if (o instanceof Container) {
getVariables(((Container) o).getSubItems(), path + "/" + o.toString());
if (t instanceof ASMSourceContainer) {
List<String> processed2 = new ArrayList<>();
for (ASMSource asm : ((ASMSourceContainer) t).getSubItems()) {
addVariable(asm, subPath + "/" + asm.toString(), processed2);
}
}
if (t instanceof DefineSpriteTag) {
getVariables(((DefineSpriteTag) t).getSubTags(), path + "/" + t.toString());
}
}
}
private void addVariable(ASMSource asm, String path, List<String> processed) throws InterruptedException {
int pos = 1;
String infPath2 = path;
while (processed.contains(infPath2)) {
pos++;
infPath2 = path + "[" + pos + "]";
}
processed.add(infPath2);
informListeners("getVariables", infPath2);
getVariables(allVariableNames, allFunctions, allStrings, usageTypes, asm, path);
}
public int deobfuscateAS3Identifiers(RenameType renameType) {
for (Tag tag : tags) {
if (tag instanceof ABCContainerTag) {

View File

@@ -21,10 +21,10 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.timeline.DepthState;
import com.jpexs.decompiler.flash.timeline.Frame;
import com.jpexs.decompiler.flash.timeline.Timeline;
@@ -52,7 +52,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class DefineButton2Tag extends ButtonTag implements Container {
public class DefineButton2Tag extends ButtonTag implements ASMSourceContainer {
/**
* ID for this character
@@ -171,16 +171,6 @@ public class DefineButton2Tag extends ButtonTag implements Container {
return actions;
}
/**
* Returns number of sub-items
*
* @return Number of sub-items
*/
@Override
public int getItemCount() {
return actions.size();
}
@Override
public void getNeededCharacters(Set<Integer> needed) {
for (BUTTONRECORD r : characters) {

View File

@@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.timeline.DepthState;
@@ -56,7 +55,7 @@ import java.util.Set;
/**
* Defines a sprite character
*/
public class DefineSpriteTag extends CharacterTag implements Container, DrawableTag, Timelined {
public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timelined {
/**
* Character ID of sprite
@@ -249,26 +248,6 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
return baos.toByteArray();
}
/**
* Returns all sub-items
*
* @return List of sub-items
*/
@Override
public List<Tag> getSubItems() {
return subTags;
}
/**
* Returns number of sub-items
*
* @return Number of sub-items
*/
@Override
public int getItemCount() {
return subTags.size();
}
@Override
public boolean hasSubTags() {
return true;

View File

@@ -21,8 +21,8 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.CLIPACTIONRECORD;
@@ -49,7 +49,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceObjectTypeTag {
public class PlaceObject2Tag extends CharacterIdTag implements ASMSourceContainer, PlaceObjectTypeTag {
/**
* @since SWF 5 Has clip actions (sprite characters only)
@@ -276,19 +276,6 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO
return new ArrayList<>();
}
/**
* Returns number of sub-items
*
* @return Number of sub-items
*/
@Override
public int getItemCount() {
if (!placeFlagHasClipActions) {
return 0;
}
return clipActions.clipActionRecords.size();
}
@Override
public void getNeededCharacters(Set<Integer> needed) {
if (placeFlagHasCharacter) {

View File

@@ -22,8 +22,8 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.CLIPACTIONRECORD;
@@ -51,7 +51,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceObjectTypeTag {
public class PlaceObject3Tag extends CharacterIdTag implements ASMSourceContainer, PlaceObjectTypeTag {
/**
* @since SWF 5 has clip actions (sprite characters only)
@@ -395,19 +395,6 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO
return new ArrayList<>();
}
/**
* Returns number of sub-items
*
* @return Number of sub-items
*/
@Override
public int getItemCount() {
if (!placeFlagHasClipActions) {
return 0;
}
return clipActions.clipActionRecords.size();
}
@Override
public void getNeededCharacters(Set<Integer> needed) {
if (placeFlagHasCharacter) {

View File

@@ -22,8 +22,8 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.CLIPACTIONRECORD;
@@ -51,7 +51,7 @@ import java.util.Set;
*
* @author JPEXS
*/
public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceObjectTypeTag {
public class PlaceObject4Tag extends CharacterIdTag implements ASMSourceContainer, PlaceObjectTypeTag {
/**
* @since SWF 5 has clip actions (sprite characters only)
@@ -398,19 +398,6 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO
return new ArrayList<>();
}
/**
* Returns number of sub-items
*
* @return Number of sub-items
*/
@Override
public int getItemCount() {
if (!placeFlagHasClipActions) {
return 0;
}
return clipActions.clipActionRecords.size();
}
@Override
public void getNeededCharacters(Set<Integer> needed) {
if (placeFlagHasCharacter) {

View File

@@ -20,7 +20,6 @@ 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.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
@@ -180,9 +179,9 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea
return streamSoundType;
}
public static void populateSoundStreamBlocks(int containerId, List<? extends ContainerItem> tags, SoundStreamHeadTypeTag head, List<SoundStreamBlockTag> output) {
public static void populateSoundStreamBlocks(int containerId, List<Tag> tags, SoundStreamHeadTypeTag head, List<SoundStreamBlockTag> output) {
boolean found = false;
for (ContainerItem t : tags) {
for (Tag t : tags) {
if (t == head) {
found = true;
head.setVirtualCharacterId(containerId);
@@ -190,7 +189,7 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea
}
if (t instanceof DefineSpriteTag) {
DefineSpriteTag sprite = (DefineSpriteTag) t;
populateSoundStreamBlocks(sprite.getCharacterId(), sprite.getSubItems(), head, output);
populateSoundStreamBlocks(sprite.getCharacterId(), sprite.getSubTags(), head, output);
}
if (!found) {
continue;

View File

@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.Exportable;
import com.jpexs.decompiler.flash.tags.base.NeedsCharacters;
import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont;
@@ -45,7 +44,7 @@ import java.util.Set;
/**
* Represents Tag inside SWF file
*/
public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializable {
public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
/**
* Identifier of tag type

View File

@@ -24,19 +24,12 @@ import java.util.List;
*
* @author JPEXS
*/
public interface Container extends TreeItem {
public interface ASMSourceContainer extends TreeItem {
/**
* Returns all sub-items
*
* @return List of sub-items
*/
public List<? extends ContainerItem> getSubItems();
/**
* Returns number of sub-items
*
* @return Number of sub-items
*/
public int getItemCount();
public List<? extends ASMSource> getSubItems();
}

View File

@@ -1,27 +0,0 @@
/*
* Copyright (C) 2010-2014 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;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
/**
* Object which contains other objects
*
* @author JPEXS
*/
public interface ContainerItem extends TreeItem {

View File

@@ -76,7 +76,7 @@ public class AS3Package extends AS3ClassTreeItem {
int res = 0;
if (child instanceof AS3Package) {
for (AS3Package pkg : subPackages.values()) {
if (pkg.equals(child)) {
if (pkg.packageName.equals(((AS3Package) child).packageName)) {
break;
}
res++;

View File

@@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.Exportable;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.Internal;
@@ -45,7 +44,7 @@ import java.util.logging.Logger;
*
* @author JPEXS
*/
public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, Serializable {
public class BUTTONCONDACTION implements ASMSource, Exportable, Serializable {
private final SWF swf;
private final Tag tag;

View File

@@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.Exportable;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.Internal;
@@ -44,7 +43,7 @@ import java.util.logging.Logger;
*
* @author JPEXS
*/
public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, Serializable {
public class CLIPACTIONRECORD implements ASMSource, Exportable, Serializable {
public static String keyToString(int key) {
if ((key < CLIPACTIONRECORD.KEYNAMES.length) && (key > 0) && (CLIPACTIONRECORD.KEYNAMES[key] != null)) {