mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-12 06:34:55 +00:00
Frame dependencies
Show needed characters for a frame and frames depending on a character in the "Basic tag info" box
This commit is contained in:
@@ -304,6 +304,9 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
@Internal
|
||||
private volatile Map<Integer, Set<Integer>> dependentCharacters;
|
||||
|
||||
@Internal
|
||||
private volatile Map<Integer, Set<Integer>> dependentFrames;
|
||||
|
||||
@Internal
|
||||
private volatile List<ABCContainerTag> abcList;
|
||||
|
||||
@@ -488,21 +491,21 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
Map<Integer, Set<Integer>> dep = new HashMap<>();
|
||||
for (Tag tag : getTags()) {
|
||||
if (tag instanceof CharacterTag) {
|
||||
int characterId = ((CharacterTag) tag).getCharacterId();
|
||||
Set<Integer> needed = new HashSet<>();
|
||||
tag.getNeededCharacters(needed);
|
||||
for (Integer needed1 : needed) {
|
||||
Set<Integer> s = dep.get(needed1);
|
||||
if (s == null) {
|
||||
s = new HashSet<>();
|
||||
dep.put(needed1, s);
|
||||
}
|
||||
|
||||
s.add(characterId);
|
||||
}
|
||||
}
|
||||
int characterId = ((CharacterTag) tag).getCharacterId();
|
||||
Set<Integer> needed = new HashSet<>();
|
||||
tag.getNeededCharacters(needed);
|
||||
for (Integer needed1 : needed) {
|
||||
Set<Integer> s = dep.get(needed1);
|
||||
if (s == null) {
|
||||
s = new HashSet<>();
|
||||
dep.put(needed1, s);
|
||||
}
|
||||
|
||||
s.add(characterId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependentCharacters = dep;
|
||||
}
|
||||
}
|
||||
@@ -545,6 +548,38 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
|
||||
return dependents;
|
||||
}
|
||||
|
||||
public void computeDependentFrames() {
|
||||
Map<Integer, Set<Integer>> dep = new HashMap<>();
|
||||
for (int i = 0; i < timeline.getFrameCount(); i++) {
|
||||
Frame frame = timeline.getFrame(i);
|
||||
Set<Integer> needed = new HashSet<>();
|
||||
frame.getNeededCharacters(needed);
|
||||
for (Integer needed1 : needed) {
|
||||
Set<Integer> s = dep.get(needed1);
|
||||
if (s == null) {
|
||||
s = new HashSet<>();
|
||||
dep.put(needed1, s);
|
||||
}
|
||||
|
||||
s.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
dependentFrames = dep;
|
||||
}
|
||||
|
||||
public Set<Integer> getDependentFrames(int characterId) {
|
||||
if (dependentFrames == null) {
|
||||
synchronized (this) {
|
||||
if (dependentFrames == null) {
|
||||
computeDependentFrames();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dependentFrames.get(characterId);
|
||||
}
|
||||
|
||||
public CharacterTag getCharacter(int characterId) {
|
||||
return getCharacters().get(characterId);
|
||||
@@ -1446,7 +1481,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
}
|
||||
|
||||
public void assignExportNamesToSymbols() {
|
||||
public void assignExportNamesToSymbols() {
|
||||
HashMap<Integer, String> exportNames = new HashMap<>();
|
||||
for (Tag t : getTags()) {
|
||||
if (t instanceof ExportAssetsTag) {
|
||||
|
||||
@@ -684,6 +684,11 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
|
||||
tagInfo.addInfo("general", "dependentCharacters", Helper.joinStrings(dependent, ", "));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Integer> dependent2 = swf.getDependentFrames(characterId);
|
||||
if(dependent2 != null && dependent2.size() > 0) {
|
||||
tagInfo.addInfo("general", "dependentFrames", Helper.joinStrings(dependent2, ", "));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.tags.ShowFrameTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer;
|
||||
import com.jpexs.decompiler.flash.tags.base.Exportable;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import com.jpexs.decompiler.flash.types.RGB;
|
||||
import com.jpexs.decompiler.flash.types.RGBA;
|
||||
@@ -29,6 +30,7 @@ import com.jpexs.decompiler.flash.types.SOUNDINFO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
@@ -133,4 +135,13 @@ public class Frame implements TreeItem, Exportable {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void getNeededCharacters(Set<Integer> needed) {
|
||||
for (Tag t : innerTags) {
|
||||
if(t instanceof PlaceObjectTypeTag) {
|
||||
needed.add(((PlaceObjectTypeTag)t).getCharacterId());
|
||||
}
|
||||
}
|
||||
needed.remove(-1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user