mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-07 09:55:11 +00:00
Fixed Classnames in PlaceObject
This commit is contained in:
@@ -391,12 +391,14 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
@Internal
|
||||
private Map<Integer, String> importedTagToExportNameMapping = new HashMap<>();
|
||||
|
||||
|
||||
@Internal
|
||||
private Map<String, Integer> classToCharacter = new HashMap<>();
|
||||
|
||||
private static final DecompilerPool decompilerPool = new DecompilerPool();
|
||||
|
||||
@Internal
|
||||
private AbcIndexing abcIndex;
|
||||
|
||||
|
||||
private static AbcIndexing playerGlobalAbcIndex;
|
||||
|
||||
private static AbcIndexing airGlobalAbcIndex;
|
||||
@@ -738,6 +740,14 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
public CharacterTag getCharacter(int characterId) {
|
||||
return getCharacters().get(characterId);
|
||||
}
|
||||
|
||||
public CharacterTag getCharacterByClass(String className) {
|
||||
if (!classToCharacter.containsKey(className)) {
|
||||
return null;
|
||||
}
|
||||
int charId = classToCharacter.get(className);
|
||||
return getCharacter(charId);
|
||||
}
|
||||
|
||||
public String getExportName(int characterId) {
|
||||
CharacterTag characterTag = getCharacters().get(characterId);
|
||||
@@ -1867,6 +1877,11 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
classToCharacter.clear();
|
||||
for (int ch:classes.keySet()) {
|
||||
classToCharacter.put(classes.get(ch), ch);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -737,14 +737,14 @@ public class FrameExporter {
|
||||
continue;
|
||||
}
|
||||
DepthState layer = frameObj.layers.get(i);
|
||||
if (!timeline.swf.getCharacters().containsKey(layer.characterId)) {
|
||||
continue;
|
||||
}
|
||||
if (!layer.isVisible) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CharacterTag character = timeline.swf.getCharacter(layer.characterId);
|
||||
CharacterTag character = layer.getCharacter();
|
||||
if (character == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Matrix placeMatrix = new Matrix(layer.matrix);
|
||||
placeMatrix.scaleX /= unitDivisor;
|
||||
@@ -793,7 +793,7 @@ public class FrameExporter {
|
||||
+ ctrans.getRedMulti() + "," + ctrans.getGreenMulti() + "," + ctrans.getBlueMulti() + "," + ctrans.getAlphaMulti()
|
||||
+ "))";
|
||||
}
|
||||
result.append("\t\t\tplace(\"").append(SWF.getTypePrefix(character)).append(layer.characterId).append("\",canvas,ctx,[").append(placeMatrix.scaleX).append(",")
|
||||
result.append("\t\t\tplace(\"").append(SWF.getTypePrefix(character)).append(layer.getCharacter().getCharacterId()).append("\",canvas,ctx,[").append(placeMatrix.scaleX).append(",")
|
||||
.append(placeMatrix.rotateSkew0).append(",")
|
||||
.append(placeMatrix.rotateSkew1).append(",")
|
||||
.append(placeMatrix.scaleY).append(",")
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.tags.PlaceObject2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.PlaceObject3Tag;
|
||||
import com.jpexs.decompiler.flash.tags.PlaceObject4Tag;
|
||||
import com.jpexs.decompiler.flash.tags.PlaceObjectTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.decompiler.flash.types.CLIPACTIONS;
|
||||
import com.jpexs.decompiler.flash.types.CXFORM;
|
||||
@@ -45,6 +46,8 @@ public class DepthState {
|
||||
public MATRIX matrix;
|
||||
|
||||
public String instanceName;
|
||||
|
||||
public String className;
|
||||
|
||||
public ColorTransform colorTransForm;
|
||||
|
||||
@@ -103,6 +106,7 @@ public class DepthState {
|
||||
matrix = obj.matrix;
|
||||
instanceName = obj.instanceName;
|
||||
colorTransForm = obj.colorTransForm;
|
||||
className = obj.className;
|
||||
cacheAsBitmap = obj.cacheAsBitmap;
|
||||
blendMode = obj.blendMode;
|
||||
filters = obj.filters;
|
||||
@@ -142,10 +146,23 @@ public class DepthState {
|
||||
return new PlaceObject2Tag(swf, false, depth, characterId, matrix, cxForm, ratio, instanceName, clipDepth, clipActions);
|
||||
} else if (minPlaceObjectNum == 3) {
|
||||
CXFORMWITHALPHA cxForm = colorTransForm == null ? null : new CXFORMWITHALPHA(colorTransForm);
|
||||
return new PlaceObject3Tag(swf, false, depth, null/*todo: className*/, characterId, matrix, cxForm, ratio, instanceName, clipDepth, filters, blendMode, cacheAsBitmap ? 1 : 0, isVisible ? 1 : 0, backGroundColor, clipActions, hasImage);
|
||||
return new PlaceObject3Tag(swf, false, depth, className, characterId, matrix, cxForm, ratio, instanceName, clipDepth, filters, blendMode, cacheAsBitmap ? 1 : 0, isVisible ? 1 : 0, backGroundColor, clipActions, hasImage);
|
||||
}
|
||||
|
||||
CXFORMWITHALPHA cxForm = colorTransForm == null ? null : new CXFORMWITHALPHA(colorTransForm);
|
||||
return new PlaceObject4Tag(swf, false, depth, null/*todo: className*/, characterId, matrix, cxForm, ratio, instanceName, clipDepth, filters, blendMode, cacheAsBitmap ? 1 : 0, isVisible ? 1 : 0, backGroundColor, clipActions, null, hasImage);
|
||||
return new PlaceObject4Tag(swf, false, depth, className, characterId, matrix, cxForm, ratio, instanceName, clipDepth, filters, blendMode, cacheAsBitmap ? 1 : 0, isVisible ? 1 : 0, backGroundColor, clipActions, null, hasImage);
|
||||
}
|
||||
|
||||
public CharacterTag getCharacter() {
|
||||
if (characterId == -1) {
|
||||
|
||||
if (className != null) {
|
||||
return swf.getCharacterByClass(className);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return swf.getCharacter(characterId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -328,6 +329,18 @@ public class Timeline {
|
||||
fl.characterId = -1;
|
||||
}
|
||||
}
|
||||
String className = po.getClassName();
|
||||
if (className != null) {
|
||||
fl.className = className;
|
||||
character = swf.getCharacterByClass(className);
|
||||
if (character instanceof DefineSpriteTag) {
|
||||
if (swf.getCyclicCharacters().contains(characterId)) {
|
||||
fl.className = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (po.flagMove()) {
|
||||
MATRIX matrix2 = po.getMatrix();
|
||||
if (matrix2 != null) {
|
||||
@@ -341,6 +354,11 @@ public class Timeline {
|
||||
if (colorTransForm2 != null) {
|
||||
fl.colorTransForm = colorTransForm2;
|
||||
}
|
||||
|
||||
String className2 = po.getClassName();
|
||||
if (className2 != null) {
|
||||
fl.className = className2;
|
||||
}
|
||||
|
||||
CLIPACTIONS clipActions2 = po.getClipActions();
|
||||
if (clipActions2 != null) {
|
||||
@@ -420,14 +438,15 @@ public class Timeline {
|
||||
private synchronized void detectTweens() {
|
||||
for (int d = 1; d <= maxDepth; d++) {
|
||||
int characterId = -1;
|
||||
String charClassName = null;
|
||||
int len = 0;
|
||||
for (int f = 0; f <= frames.size(); f++) {
|
||||
DepthState ds = f >= frames.size() ? null : frames.get(f).layers.get(d);
|
||||
|
||||
if (ds != null && characterId != -1 && ds.characterId == characterId) {
|
||||
if (ds != null && (characterId != -1 || charClassName != null) && (ds.characterId == characterId && Objects.equals(ds.className, charClassName))) {
|
||||
len++;
|
||||
} else {
|
||||
if (characterId != -1) {
|
||||
if (characterId != -1 || charClassName != null) {
|
||||
int startPos = f - len;
|
||||
List<DepthState> matrices = new ArrayList<>(len);
|
||||
for (int k = 0; k < len; k++) {
|
||||
@@ -450,6 +469,7 @@ public class Timeline {
|
||||
}
|
||||
|
||||
characterId = ds == null ? -1 : ds.characterId;
|
||||
charClassName = ds == null ? null : ds.className;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -573,13 +593,12 @@ public class Timeline {
|
||||
Frame frameObj = getFrame(frame);
|
||||
for (int depth : frameObj.layers.keySet()) {
|
||||
DepthState layer = frameObj.layers.get(depth);
|
||||
if (layer.characterId != -1) {
|
||||
if (!swf.getCharacters().containsKey(layer.characterId)) {
|
||||
continue;
|
||||
}
|
||||
usedCharacters.add(layer.characterId);
|
||||
swf.getCharacter(layer.characterId).getNeededCharactersDeep(usedCharacters);
|
||||
CharacterTag ch = layer.getCharacter();
|
||||
if (ch == null) {
|
||||
continue;
|
||||
}
|
||||
usedCharacters.add(ch.getCharacterId());
|
||||
ch.getNeededCharactersDeep(usedCharacters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1035,14 +1054,14 @@ public class Timeline {
|
||||
continue;
|
||||
}
|
||||
DepthState layer = frameObj.layers.get(i);
|
||||
if (!swf.getCharacters().containsKey(layer.characterId)) {
|
||||
continue;
|
||||
}
|
||||
if (!layer.isVisible) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CharacterTag character = swf.getCharacter(layer.characterId);
|
||||
CharacterTag character = layer.getCharacter();
|
||||
if (character == null) {
|
||||
continue;
|
||||
}
|
||||
Matrix layerMatrix = new Matrix(layer.matrix);
|
||||
|
||||
Matrix mat = transformation.concatenate(layerMatrix);
|
||||
@@ -1187,14 +1206,14 @@ public class Timeline {
|
||||
continue;
|
||||
}
|
||||
DepthState layer = frameObj.layers.get(i);
|
||||
if (!swf.getCharacters().containsKey(layer.characterId)) {
|
||||
continue;
|
||||
}
|
||||
if (!layer.isVisible) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CharacterTag character = swf.getCharacter(layer.characterId);
|
||||
CharacterTag character =layer.getCharacter();
|
||||
if (character == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ColorTransform clrTrans = colorTransform;
|
||||
if (layer.colorTransForm != null && layer.blendMode <= 1) { // Normal blend mode
|
||||
@@ -1277,7 +1296,7 @@ public class Timeline {
|
||||
for (int d = maxDepth; d >= 0; d--) {
|
||||
DepthState ds = fr.layers.get(d);
|
||||
if (ds != null) {
|
||||
CharacterTag c = swf.getCharacter(ds.characterId);
|
||||
CharacterTag c = ds.getCharacter();
|
||||
if (c instanceof Timelined) {
|
||||
int frameCount = ((Timelined) c).getTimeline().frames.size();
|
||||
if (frameCount == 0) {
|
||||
@@ -1322,7 +1341,7 @@ public class Timeline {
|
||||
if (!layer.isVisible) {
|
||||
continue;
|
||||
}
|
||||
CharacterTag character = swf.getCharacter(layer.characterId);
|
||||
CharacterTag character = layer.getCharacter();
|
||||
if (character instanceof DrawableTag) {
|
||||
DrawableTag drawable = (DrawableTag) character;
|
||||
Matrix m = transformation.concatenate(new Matrix(layer.matrix));
|
||||
@@ -1383,13 +1402,13 @@ public class Timeline {
|
||||
continue;
|
||||
}
|
||||
DepthState layer = frameObj.layers.get(i);
|
||||
if (!swf.getCharacters().containsKey(layer.characterId)) {
|
||||
continue;
|
||||
}
|
||||
if (!layer.isVisible) {
|
||||
continue;
|
||||
}
|
||||
CharacterTag character = swf.getCharacter(layer.characterId);
|
||||
CharacterTag character = layer.getCharacter();
|
||||
if (character == null) {
|
||||
continue;
|
||||
}
|
||||
if (character instanceof DrawableTag) {
|
||||
DrawableTag drawable = (DrawableTag) character;
|
||||
if (!drawable.isSingleFrame()) {
|
||||
|
||||
Reference in New Issue
Block a user