Insert tag (add tag before/after another tag) (#135)

Co-authored-by: Jindra Petřík <jindra.petrik@gmail.com>
This commit is contained in:
Exund
2022-10-30 12:38:19 +01:00
committed by GitHub
parent 71b58fb0a6
commit cdbf21c536
4 changed files with 175 additions and 25 deletions

View File

@@ -3222,14 +3222,12 @@ public final class SWF implements SWFContainerItem, Timelined {
tag.setTimelined(timelined);
ReadOnlyTagList tags = timelined.getTags();
int index;
if ((tag instanceof DefineScalingGridTag) && (timelined instanceof DefineSpriteTag)) {
index = this.tags.indexOf(timelined) + 1;
} else if (frame != null) {
if (frame.showFrameTag != null) {
index = tags.indexOf(frame.showFrameTag);
index = timelined.indexOfTag(frame.showFrameTag);
} else {
index = -1;
}
@@ -3240,11 +3238,12 @@ public final class SWF implements SWFContainerItem, Timelined {
((CharacterIdTag) tag).setCharacterId(((CharacterTag) targetTreeItem).getCharacterId());
}
index = tags.indexOf((Tag) targetTreeItem); // todo: honfika: why not index + 1?
index = timelined.indexOfTag((Tag) targetTreeItem); // todo: honfika: why not index + 1?
} else {
index = -1;
if (tag instanceof CharacterTag) {
// add before the last ShowFrame tag
ReadOnlyTagList tags = timelined.getTags();
for (int i = tags.size() - 1; i >= 0; i--) {
if (tags.get(i) instanceof ShowFrameTag) {
index = i;