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:
Exund
2021-11-29 17:15:56 +01:00
committed by Jindra Petřík
parent 0da5e3c124
commit 6d656228a2
6 changed files with 121 additions and 33 deletions
@@ -1120,7 +1120,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
tagTree.clearSelection();
for (TreeItem n : nodes) {
if (n instanceof ClassesListTreeModel) {
String filterText = filterField.getText();
String filterText = filterField.getText();
((ClassesListTreeModel) n).setFilter(filterText);
TagTreeModel tm = tagTree.getModel();
TreePath path = tm.getTreePath(n);
@@ -3723,6 +3723,20 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
} else {
showDetail(DETAILCARDEMPTYPANEL);
}
} else if (treeItem instanceof Frame) {
Frame frame = (Frame) treeItem;
Set<Integer> needed = new LinkedHashSet<>();
frame.getNeededCharacters(needed);
if (!needed.isEmpty()) {
TagInfo tagInfo = new TagInfo();
tagInfo.addInfo("general", "neededCharacters", Helper.joinStrings(needed, ", "));
tagInfoPanel.setTagInfos(tagInfo);
showDetail(DETAILCARDTAGINFO);
} else {
showDetail(DETAILCARDEMPTYPANEL);
}
} else {
showDetail(DETAILCARDEMPTYPANEL);
}
@@ -16,11 +16,14 @@
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.TagInfo;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -62,11 +65,25 @@ public class TagInfoPanel extends JPanel {
public void hyperlinkUpdate(HyperlinkEvent hyperLink) {
if (HyperlinkEvent.EventType.ACTIVATED.equals(hyperLink.getEventType())) {
String url = hyperLink.getDescription();
String strId = url.substring(7);
Integer id = Integer.parseInt(strId);
URI url;
try {
url = new URI(hyperLink.getDescription());
} catch (Exception ex) {
return;
}
mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentSwf().getCharacter(id));
String scheme = url.getScheme();
String strId = url.getHost();
Integer id = Integer.parseInt(strId);
SWF swf = mainPanel.getCurrentSwf();
TreeItem item = null;
if ("char".equals(scheme)) {
item = swf.getCharacter(id);
} else if ("frame".equals(scheme)) {
item = swf.getTimeline().getFrame(id);
}
mainPanel.setTagTreeSelectedNode(item);
}
}
@@ -92,16 +109,17 @@ public class TagInfoPanel extends JPanel {
} else {
result += "</tr>";
}
result += "<td width='50%' style='text-align:center;'>";
result += mainPanel.translate("tagInfo.header.name");
result += "</td>";
result += "<td width='50%' style='text-align:center;'>";
result += mainPanel.translate("tagInfo.header.value");
result += "</td>";
result += String.format(
"<td width='50%%' style='text-align:center;'>%s</td>",
mainPanel.translate("tagInfo.header.name")
);
result += String.format(
"<td width='50%%' style='text-align:center;'>%s</td>",
mainPanel.translate("tagInfo.header.value")
);
result += "</tr>";
for (TagInfo.TagInfoItem item : items) {
Boolean convertToCharacterList;
flipFlop = !flipFlop;
@@ -114,7 +132,8 @@ public class TagInfoPanel extends JPanel {
String name = item.getName();
String key = "tagInfo." + name;
convertToCharacterList = name.equals("dependentCharacters") || name.equals("neededCharacters");
boolean frameList = name.equals("dependentFrames");
boolean convertToLinkList = name.equals("dependentCharacters") || name.equals("neededCharacters") || frameList;
try {
name = mainPanel.translate(key);
@@ -130,11 +149,10 @@ public class TagInfoPanel extends JPanel {
if (value instanceof Boolean) {
boolean boolValue = (boolean) value;
value = boolValue ? AppStrings.translate("yes") : AppStrings.translate("no");
} else if (convertToCharacterList) {
String strValue = (String) value;
String[] strIds = strValue.split(", ");
} else if (convertToLinkList) {
String[] strIds = ((String) value).split(", ");
List<Integer> sortedIds = new ArrayList<>();
strValue = "";
String strValue = "";
for (String strId : strIds) {
sortedIds.add(Integer.parseInt(strId));
@@ -142,8 +160,11 @@ public class TagInfoPanel extends JPanel {
Collections.sort(sortedIds);
String scheme = frameList ? "frame" : "char";
for (int id : sortedIds) {
strValue += "<a href='jump://" + id + "'>" + id + "</a>, ";
int displayId = frameList ? id + 1 : id;
strValue += String.format("<a href='%s://%d'>%d</a>, ", scheme, id, displayId);
}
value = strValue.substring(0, strValue.length() - 2);
@@ -844,4 +844,6 @@ message.info.importSymbolClass = During importing Symbol-Class, you need to sele
This is the same filename as it is used when exported.
message.info.importXml = For XML importing, you need a XML file in special format - the format in which FFDec exports.\r\n \
The best way to create such XML file is to export XML from existing SWF first.
The best way to create such XML file is to export XML from existing SWF first.
tagInfo.dependentFrames = Dependent Frames