Instance metadata get/set/remove from Commandline

This commit is contained in:
Jindra Petřík
2016-07-24 11:27:04 +02:00
parent 9fe25381c8
commit 5bc200c208
12 changed files with 861 additions and 58 deletions

View File

@@ -2507,8 +2507,7 @@ public final class SWF implements SWFContainerItem, Timelined {
for (Tag tag : getTags()) {
if (tag instanceof ImageTag) {
((ImageTag) tag).clearCache();
}
else if (tag instanceof DefineCompactedFont) {
} else if (tag instanceof DefineCompactedFont) {
((DefineCompactedFont) tag).rebuildShapeCache();
}
}
@@ -2891,15 +2890,15 @@ public final class SWF implements SWFContainerItem, Timelined {
timelined.setModified(true);
timelined.resetTimeline();
} else // timeline should be always the swf here
if (removeDependencies) {
removeTagWithDependenciesFromTimeline(tag, timelined.getTimeline());
timelined.setModified(true);
} else {
boolean modified = removeTagFromTimeline(tag, timelined.getTimeline());
if (modified) {
if (removeDependencies) {
removeTagWithDependenciesFromTimeline(tag, timelined.getTimeline());
timelined.setModified(true);
} else {
boolean modified = removeTagFromTimeline(tag, timelined.getTimeline());
if (modified) {
timelined.setModified(true);
}
}
}
}
@Override
@@ -3648,4 +3647,10 @@ public final class SWF implements SWFContainerItem, Timelined {
}
return null;
}
@Override
public void replaceTag(int index, Tag newTag) {
removeTag(index);
addTag(index, newTag);
}
}

View File

@@ -424,4 +424,10 @@ public class DefineSpriteTag extends DrawableTag implements Timelined {
public void clearReadOnlyListCache() {
readOnlyTags = null;
}
@Override
public void replaceTag(int index, Tag newTag) {
removeTag(index);
addTag(index, newTag);
}
}

View File

@@ -442,4 +442,14 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont
public Amf3Value getAmfData() {
return null;
}
@Override
public Integer getBitmapCache() {
return null;
}
@Override
public Integer getVisible() {
return null;
}
}

View File

@@ -240,12 +240,12 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
super(swf, ID, NAME, null);
}
public PlaceObject3Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List<FILTER> surfaceFilterList, int blendMode, int bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions) {
public PlaceObject3Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List<FILTER> surfaceFilterList, int blendMode, Integer bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions) {
super(swf, ID, NAME, null);
this.placeFlagHasClassName = className != null;
this.placeFlagHasFilterList = surfaceFilterList != null;
this.placeFlagHasBlendMode = blendMode >= 0;
this.placeFlagHasCacheAsBitmap = bitmapCache >= 0;
this.placeFlagHasCacheAsBitmap = bitmapCache != null;
this.placeFlagHasVisible = visible >= 0;
this.placeFlagOpaqueBackground = backgroundColor != null;
this.placeFlagHasClipActions = clipActions != null;
@@ -266,7 +266,7 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
this.clipDepth = clipDepth;
this.surfaceFilterList = surfaceFilterList;
this.blendMode = blendMode;
this.bitmapCache = bitmapCache;
this.bitmapCache = bitmapCache == null ? 0 : bitmapCache;
this.visible = visible;
this.backgroundColor = backgroundColor;
this.clipActions = clipActions;
@@ -552,6 +552,14 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
return true;
}
@Override
public Integer getVisible() {
if (placeFlagHasVisible) {
return visible;
}
return null;
}
@Override
public RGBA getBackgroundColor() {
if (placeFlagOpaqueBackground) {
@@ -622,4 +630,11 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
return null;
}
@Override
public Integer getBitmapCache() {
if (placeFlagHasCacheAsBitmap) {
return bitmapCache;
}
return null;
}
}

View File

@@ -246,13 +246,13 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
super(swf, ID, NAME, null);
}
public PlaceObject4Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List<FILTER> surfaceFilterList, int blendMode, int bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions, Amf3Value amfData) {
public PlaceObject4Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List<FILTER> surfaceFilterList, int blendMode, Integer bitmapCache, Integer visible, RGBA backgroundColor, CLIPACTIONS clipActions, Amf3Value amfData) {
super(swf, ID, NAME, null);
this.placeFlagHasClassName = className != null;
this.placeFlagHasFilterList = surfaceFilterList != null;
this.placeFlagHasBlendMode = blendMode >= 0;
this.placeFlagHasCacheAsBitmap = bitmapCache >= 0;
this.placeFlagHasVisible = visible >= 0;
this.placeFlagHasCacheAsBitmap = bitmapCache != null;
this.placeFlagHasVisible = visible != null;
this.placeFlagOpaqueBackground = backgroundColor != null;
this.placeFlagHasClipActions = clipActions != null;
this.placeFlagHasClipDepth = clipDepth >= 0;
@@ -272,8 +272,8 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
this.clipDepth = clipDepth;
this.surfaceFilterList = surfaceFilterList;
this.blendMode = blendMode;
this.bitmapCache = bitmapCache;
this.visible = visible;
this.bitmapCache = bitmapCache == null ? 0 : bitmapCache;
this.visible = visible == null ? 0 : visible;
this.backgroundColor = backgroundColor;
this.clipActions = clipActions;
this.amfData = amfData;
@@ -644,4 +644,19 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
return amfData;
}
@Override
public Integer getBitmapCache() {
if (placeFlagHasCacheAsBitmap) {
return bitmapCache;
}
return null;
}
@Override
public Integer getVisible() {
if (placeFlagHasVisible) {
return visible;
}
return null;
}
}

View File

@@ -262,4 +262,13 @@ public class PlaceObjectTag extends PlaceObjectTypeTag {
return null;
}
@Override
public Integer getBitmapCache() {
return null;
}
@Override
public Integer getVisible() {
return null;
}
}

View File

@@ -166,4 +166,10 @@ public abstract class ButtonTag extends DrawableTag implements Timelined {
@Override
public void addTag(int index, Tag tag) {
}
@Override
public void replaceTag(int index, Tag newTag) {
removeTag(index);
addTag(index, newTag);
}
}

View File

@@ -65,8 +65,12 @@ public abstract class PlaceObjectTypeTag extends Tag implements CharacterIdTag {
public abstract boolean cacheAsBitmap();
public abstract Integer getBitmapCache();
public abstract boolean isVisible();
public abstract Integer getVisible();
public abstract RGBA getBackgroundColor();
public abstract boolean flagMove();

View File

@@ -41,4 +41,6 @@ public interface Timelined extends BoundedTag {
public void addTag(Tag tag);
public void addTag(int index, Tag tag);
public void replaceTag(int index, Tag newTag);
}

View File

@@ -148,8 +148,8 @@ public class Helper {
}
/**
* Formats specified address to four numbers xxxx
* (or five numbers when showing decimal addresses)
* Formats specified address to four numbers xxxx (or five numbers when
* showing decimal addresses)
*
* @param number Address to format
* @return String representation of the address
@@ -159,8 +159,8 @@ public class Helper {
}
/**
* Formats specified address to four numbers xxxx
* (or five numbers when showing decimal addresses)
* Formats specified address to four numbers xxxx (or five numbers when
* showing decimal addresses)
*
* @param number Address to format
* @param decimal Use decimal format
@@ -648,7 +648,7 @@ public class Helper {
for (String f : file) {
try (FileInputStream fis = new FileInputStream(f)) {
byte[] buf = new byte[4096];
int cnt = 0;
int cnt;
while ((cnt = fis.read(buf)) > 0) {
baos.write(buf, 0, cnt);
}
@@ -659,6 +659,41 @@ public class Helper {
return baos.toByteArray();
}
public static byte[] readFileEx(String... file) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (String f : file) {
FileInputStream fis = null;
try {
fis = new FileInputStream(f);
byte[] buf = new byte[4096];
int cnt;
while ((cnt = fis.read(buf)) > 0) {
baos.write(buf, 0, cnt);
}
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ex) {
//ignore
}
}
}
}
return baos.toByteArray();
}
public static String readTextFileEx(String... file) throws IOException {
byte[] data = readFileEx(file);
if (data.length > 1 && data[0] == (byte) 0xef && data[1] == (byte) 0xbb && data[2] == (byte) 0xbf) {
// remove UTF-8 BOM
return new String(data, 3, data.length - 3, Utf8Helper.charset);
}
return new String(data, Utf8Helper.charset);
}
public static String readTextFile(String... file) {
byte[] data = readFile(file);
if (data.length > 1 && data[0] == (byte) 0xef && data[1] == (byte) 0xbb && data[2] == (byte) 0xbf) {
@@ -983,13 +1018,11 @@ public class Helper {
writer.appendNoHilight(" ");
}
writer.appendNoHilight(byteToHex(data[idx])).appendNoHilight(" ");
} else {
if (addChars) {
if (i > 0 && i % groupSize == 0) {
writer.appendNoHilight(" ");
}
writer.appendNoHilight(" ");
} else if (addChars) {
if (i > 0 && i % groupSize == 0) {
writer.appendNoHilight(" ");
}
writer.appendNoHilight(" ");
}
address += bytesPerRow;
}