Fixed Preview of PlaceObject and frames on hex dump view

This commit is contained in:
Jindra Petřík
2022-11-15 09:53:35 +01:00
parent 03f1866f92
commit 4171df875e
3 changed files with 50 additions and 14 deletions

View File

@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
- [#1869] Replace references now replaces all references, not just PlaceObject
- Handle StartSound tag as CharacterIdTag
- Clearing shape export cache on changes
- Preview of PlaceObject and frames on hex dump view
## [16.3.1] - 2022-11-14
### Fixed

View File

@@ -3903,6 +3903,9 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
}
}
if (t instanceof Tag) {
t = dumpTree.getOriginalTag(t);
}
showPreview(t, dumpPreviewPanel, getFrameForTreeItem(t), getTimelinedForTreeItem(t));
}
}
@@ -3919,17 +3922,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
if (currentView == VIEW_DUMP) {
if (treeItem instanceof Tag) {
Tag t = (Tag) treeItem;
ReadOnlyTagList tags = t.getTimelined().getTags();
int frame = 0;
for (int i = 0; i < tags.size(); i++) {
if (tags.get(i) == t) {
return frame;
}
if (tags.get(i) instanceof ShowFrameTag) {
frame++;
}
}
return dumpTree.getFrameForItem(treeItem);
}
return -1;
}
@@ -3957,8 +3950,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
if (currentView == VIEW_DUMP) {
if (treeItem instanceof Tag) {
Tag t = (Tag) treeItem;
return t.getTimelined();
return dumpTree.getTimelinedForItem(treeItem);
}
return null;
}

View File

@@ -611,7 +611,50 @@ public class DumpTree extends JTree {
}
}
}
public Tag getOriginalTag(TreeItem item) {
Tag tag;
if (item instanceof Tag) {
tag = (Tag) item;
} else if (item instanceof HasSwfAndTag) {
tag = ((HasSwfAndTag) item).getTag();
} else {
return null;
}
ByteArrayRange range = tag.getOriginalRange();
if (range == null) {
return null;
}
long address = range.getPos();
return searchTimelinedForTag(item.getSwf(), address);
}
public Timelined getTimelinedForItem(TreeItem item) {
Tag original = getOriginalTag(item);
if (original == null) {
return null;
}
return original.getTimelined();
}
public int getFrameForItem(TreeItem item) {
Tag originalTag = getOriginalTag(item);
if (originalTag == null) {
return -1;
}
int frame = 0;
for (Tag t : originalTag.getTimelined().getTags()) {
if (t == originalTag) {
return frame;
}
if (t instanceof ShowFrameTag) {
frame++;
}
}
return -1;
}
public void setSelectedItem(TreeItem item) {
Tag tag;
if (item instanceof Tag) {