mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-02 11:54:36 +00:00
snow placeobject tags in definesprite tags, too. allow removing placeobject tags
This commit is contained in:
@@ -304,6 +304,12 @@ public final class SWF implements TreeItem, Timelined {
|
||||
return timeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTimeline() {
|
||||
timeline = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets all tags with specified id
|
||||
*
|
||||
@@ -564,25 +570,10 @@ public final class SWF implements TreeItem, Timelined {
|
||||
sis.readUI8(); //tmpFirstByetOfFrameRate
|
||||
frameRate = sis.readUI8();
|
||||
frameCount = sis.readUI16();
|
||||
tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly, gfx);
|
||||
tags = sis.readTagList(this, this, 0, parallelRead, true, !checkOnly, gfx);
|
||||
if (!checkOnly) {
|
||||
Map<Long, Tag> tagMap = new HashMap<>();
|
||||
for (Tag tag : tags) {
|
||||
tagMap.put(tag.getPos(), tag);
|
||||
}
|
||||
|
||||
checkInvalidSprites();
|
||||
for (Tag tag : tags) {
|
||||
if (tag instanceof ShowFrameTag) {
|
||||
ShowFrameTag showFrameTag = (ShowFrameTag) tag;
|
||||
List<Long> tagPositions = sis.tagPositionsInFrames.get(tag.getPos());
|
||||
List<Tag> innerTags = new ArrayList<>();
|
||||
for (long tagPos : tagPositions) {
|
||||
innerTags.add(tagMap.get(tagPos));
|
||||
}
|
||||
showFrameTag.innerTags = innerTags;
|
||||
}
|
||||
}
|
||||
updateInnerTagsForShowFrameTags();
|
||||
updateCharacters();
|
||||
assignExportNamesToSymbols();
|
||||
assignClassesToSymbols();
|
||||
@@ -600,6 +591,49 @@ public final class SWF implements TreeItem, Timelined {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateInnerTagsForShowFrameTags() {
|
||||
Map<Long, Tag> tagMap = new HashMap<>();
|
||||
Map<Long, List<Long>> tagPositionsInFrames = new HashMap<>();
|
||||
createTagMap(tagMap, tagPositionsInFrames, tags);
|
||||
addInnerTagsForShowFrameTags(tagPositionsInFrames, tagMap, tags);
|
||||
}
|
||||
|
||||
private void createTagMap(Map<Long, Tag> tagMap, Map<Long, List<Long>> tagPositionsInFrames, List<Tag> tags) {
|
||||
List<Long> tagPositionsInFrame = new ArrayList<>();
|
||||
for (Tag tag : tags) {
|
||||
long pos = tag.getPos();
|
||||
tagMap.put(pos, tag);
|
||||
if (ShowFrameTag.isNestedTagType(tag.getId())) {
|
||||
tagPositionsInFrame.add(pos);
|
||||
} else if (tag.getId() == ShowFrameTag.ID) {
|
||||
tagPositionsInFrames.put(pos, tagPositionsInFrame);
|
||||
tagPositionsInFrame = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (tag instanceof DefineSpriteTag) {
|
||||
createTagMap(tagMap, tagPositionsInFrames, tag.getSubTags());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addInnerTagsForShowFrameTags(Map<Long, List<Long>> tagPositionsInFrames, Map<Long, Tag> tagMap, List<Tag> tags) {
|
||||
for (Tag tag : tags) {
|
||||
if (tag instanceof ShowFrameTag) {
|
||||
ShowFrameTag showFrameTag = (ShowFrameTag) tag;
|
||||
List<Long> tagPositions = tagPositionsInFrames.get(tag.getPos());
|
||||
if (tagPositions != null) {
|
||||
List<Tag> innerTags = new ArrayList<>();
|
||||
for (long tagPos : tagPositions) {
|
||||
innerTags.add(tagMap.get(tagPos));
|
||||
}
|
||||
showFrameTag.innerTags = innerTags;
|
||||
}
|
||||
} else if (tag instanceof DefineSpriteTag) {
|
||||
addInnerTagsForShowFrameTags(tagPositionsInFrames, tagMap, tag.getSubTags());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWF getSwf() {
|
||||
return this;
|
||||
@@ -2688,6 +2722,19 @@ public final class SWF implements TreeItem, Timelined {
|
||||
}
|
||||
|
||||
public void removeTag(Tag t) {
|
||||
removeTagFromTimeline(t, tags);
|
||||
if (ShowFrameTag.isNestedTagType(t.getId())) {
|
||||
List<Tag> tags;
|
||||
Timelined timelined = t.getTimelined();
|
||||
if (timelined instanceof DefineSpriteTag) {
|
||||
tags = ((DefineSpriteTag) timelined).getSubTags();
|
||||
} else {
|
||||
tags = this.tags;
|
||||
}
|
||||
tags.remove(t);
|
||||
timelined.resetTimeline();
|
||||
} else {
|
||||
removeTagFromTimeline(t, tags);
|
||||
}
|
||||
clearImageCache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,6 +201,7 @@ import com.jpexs.decompiler.flash.tags.gfx.DefineGradientMap;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.ExporterInfoTag;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.FontTextureInfo;
|
||||
import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
import com.jpexs.decompiler.flash.types.ALPHABITMAPDATA;
|
||||
import com.jpexs.decompiler.flash.types.ALPHACOLORMAPDATA;
|
||||
import com.jpexs.decompiler.flash.types.ARGB;
|
||||
@@ -269,9 +270,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -296,8 +295,6 @@ public class SWFInputStream extends InputStream {
|
||||
private long percentMax;
|
||||
private final List<byte[]> buffered = new ArrayList<>();
|
||||
private ByteArrayOutputStream buffer;
|
||||
private List<Long> tagPositionsInFrame = new ArrayList<>();
|
||||
public Map<Long, List<Long>> tagPositionsInFrames = new HashMap<>();
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
@@ -834,6 +831,7 @@ public class SWFInputStream extends InputStream {
|
||||
* of the stream. Optionally can skip AS1/2 tags when file is AS3
|
||||
*
|
||||
* @param swf
|
||||
* @param timelined
|
||||
* @param level
|
||||
* @param parallel
|
||||
* @param skipUnusualTags
|
||||
@@ -843,7 +841,7 @@ public class SWFInputStream extends InputStream {
|
||||
* @throws IOException
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public List<Tag> readTagList(SWF swf, int level, boolean parallel, boolean skipUnusualTags, boolean parseTags, boolean gfx) throws IOException, InterruptedException {
|
||||
public List<Tag> readTagList(SWF swf, Timelined timelined, int level, boolean parallel, boolean skipUnusualTags, boolean parseTags, boolean gfx) throws IOException, InterruptedException {
|
||||
ExecutorService executor = null;
|
||||
List<Future<Tag>> futureResults = new ArrayList<>();
|
||||
if (parallel) {
|
||||
@@ -864,6 +862,8 @@ public class SWFInputStream extends InputStream {
|
||||
if (tag == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
tag.setTimelined(timelined);
|
||||
if (!parallel) {
|
||||
tags.add(tag);
|
||||
}
|
||||
@@ -873,13 +873,6 @@ public class SWFInputStream extends InputStream {
|
||||
tag.previousTag = previousTag;
|
||||
previousTag = tag;
|
||||
|
||||
if (ShowFrameTag.isNestedTagType(tag.getId())) {
|
||||
tagPositionsInFrame.add(pos);
|
||||
} else if (tag.getId() == ShowFrameTag.ID) {
|
||||
tagPositionsInFrames.put(pos, tagPositionsInFrame);
|
||||
tagPositionsInFrame = new ArrayList<>();
|
||||
}
|
||||
|
||||
boolean doParse;
|
||||
if (!skipUnusualTags) {
|
||||
doParse = true;
|
||||
@@ -1233,6 +1226,7 @@ public class SWFInputStream extends InputStream {
|
||||
}
|
||||
ret.previousTag = tag.previousTag;
|
||||
ret.forceWriteAsLong = tag.forceWriteAsLong;
|
||||
ret.setTimelined(tag.getTimelined());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.tags.DefineFontNameTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import java.awt.Font;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
@@ -78,7 +79,7 @@ public class FontPanel extends javax.swing.JPanel {
|
||||
}
|
||||
|
||||
private void fontAddChars(FontTag ft, Set<Integer> selChars, String selFont) {
|
||||
FontTag f = (FontTag) mainPanel.oldTag;
|
||||
FontTag f = (FontTag) mainPanel.tagTree.getCurrentTreeItem();
|
||||
SWF swf = ft.getSwf();
|
||||
String oldchars = f.getCharacters(swf.tags);
|
||||
for (int ic : selChars) {
|
||||
@@ -571,26 +572,30 @@ public class FontPanel extends javax.swing.JPanel {
|
||||
|
||||
private void fontAddCharsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fontAddCharsButtonActionPerformed
|
||||
String newchars = fontAddCharactersField.getText();
|
||||
if (mainPanel.oldTag instanceof FontTag) {
|
||||
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
if (item instanceof FontTag) {
|
||||
Set<Integer> selChars = new TreeSet<>();
|
||||
for (int c = 0; c < newchars.length(); c++) {
|
||||
selChars.add(newchars.codePointAt(c));
|
||||
}
|
||||
fontAddChars((FontTag) mainPanel.oldTag, selChars, fontSelection.getSelectedItem().toString());
|
||||
fontAddChars((FontTag) item, selChars, fontSelection.getSelectedItem().toString());
|
||||
fontAddCharactersField.setText("");
|
||||
mainPanel.reload(true);
|
||||
}
|
||||
}//GEN-LAST:event_fontAddCharsButtonActionPerformed
|
||||
|
||||
private void fontEmbedButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fontEmbedButtonActionPerformed
|
||||
if (mainPanel.oldTag instanceof FontTag) {
|
||||
FontEmbedDialog fed = new FontEmbedDialog(fontSelection.getSelectedItem().toString(), fontAddCharactersField.getText(), ((FontTag) mainPanel.oldTag).getFontStyle());
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
if (item instanceof FontTag) {
|
||||
FontTag fontTag = (FontTag) item;
|
||||
FontEmbedDialog fed = new FontEmbedDialog(fontSelection.getSelectedItem().toString(), fontAddCharactersField.getText(), fontTag.getFontStyle());
|
||||
if (fed.display()) {
|
||||
Set<Integer> selChars = fed.getSelectedChars();
|
||||
if (!selChars.isEmpty()) {
|
||||
String selFont = fed.getSelectedFont();
|
||||
fontSelection.setSelectedItem(selFont);
|
||||
fontAddChars((FontTag) mainPanel.oldTag, selChars, selFont);
|
||||
fontAddChars(fontTag, selChars, selFont);
|
||||
fontAddCharactersField.setText("");
|
||||
mainPanel.reload(true);
|
||||
}
|
||||
@@ -599,8 +604,9 @@ public class FontPanel extends javax.swing.JPanel {
|
||||
}//GEN-LAST:event_fontEmbedButtonActionPerformed
|
||||
|
||||
private void fontSelectionItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fontSelectionItemStateChanged
|
||||
if (mainPanel.oldTag instanceof FontTag) {
|
||||
FontTag f = (FontTag) mainPanel.oldTag;
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
if (item instanceof FontTag) {
|
||||
FontTag f = (FontTag) item;
|
||||
SWF swf = f.getSwf();
|
||||
String selectedSystemFont = (String) fontSelection.getSelectedItem();
|
||||
swf.sourceFontsMap.put(f.getFontId(), selectedSystemFont);
|
||||
|
||||
@@ -237,10 +237,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
private GenericTagPanel genericTagPanel;
|
||||
private JPanel folderPreviewPanel;
|
||||
private final ImagePanel previewImagePanel;
|
||||
private final ImagePanel swfPreviewPanel;
|
||||
private boolean isWelcomeScreen = true;
|
||||
private static final String CARDFLASHPANEL = "Flash card";
|
||||
private static final String CARDSWFPREVIEWPANEL = "SWF card";
|
||||
private static final String CARDDRAWPREVIEWPANEL = "Draw card";
|
||||
private static final String CARDIMAGEPANEL = "Image card";
|
||||
private static final String CARDBINARYPANEL = "Binary card";
|
||||
@@ -285,7 +283,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
private AbortRetryIgnoreHandler errorHandler = new GuiAbortRetryIgnoreHandler();
|
||||
private CancellableWorker setSourceWorker;
|
||||
public TreeNode oldNode;
|
||||
public TreeItem oldTag;
|
||||
private File tempFile;
|
||||
private final PlayerControls imagePlayControls;
|
||||
|
||||
@@ -879,9 +876,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
|
||||
displayReplace(false);
|
||||
|
||||
swfPreviewPanel = new ImagePanel();
|
||||
displayPanel.add(swfPreviewPanel, CARDSWFPREVIEWPANEL);
|
||||
|
||||
displayPanel.add(new JPanel(), CARDEMPTYPANEL);
|
||||
CardLayout cl = (CardLayout) (displayPanel.getLayout());
|
||||
cl.show(displayPanel, CARDEMPTYPANEL);
|
||||
@@ -1080,7 +1074,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
public void closeAll() {
|
||||
swfs.clear();
|
||||
oldNode = null;
|
||||
oldTag = null;
|
||||
genericTagPanel.clear();
|
||||
if (abcPanel != null) {
|
||||
abcPanel.clearSwf();
|
||||
@@ -1105,7 +1098,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
actionPanel.clearSource();
|
||||
}
|
||||
oldNode = null;
|
||||
oldTag = null;
|
||||
genericTagPanel.clear();
|
||||
updateUi();
|
||||
refreshTree();
|
||||
@@ -1114,7 +1106,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
private void stopImagePanels() {
|
||||
imagePanel.stop();
|
||||
previewImagePanel.stop();
|
||||
swfPreviewPanel.stop();
|
||||
}
|
||||
|
||||
public void enableDrop(boolean value) {
|
||||
@@ -1636,7 +1627,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
|
||||
return treeNode.getItem().getSwf();
|
||||
}
|
||||
|
||||
|
||||
private void clearCache() {
|
||||
if (abcPanel != null) {
|
||||
abcPanel.decompiledTextArea.clearScriptCache();
|
||||
@@ -2181,8 +2172,16 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
public void refreshTree() {
|
||||
stopImagePanels();
|
||||
showCard(CARDEMPTYPANEL);
|
||||
TreeItem treeItem = tagTree.getCurrentTreeItem();
|
||||
for (SWFList sWFList : swfs) {
|
||||
for (SWF swf : sWFList.swfs) {
|
||||
swf.updateInnerTagsForShowFrameTags();
|
||||
}
|
||||
}
|
||||
View.refreshTree(tagTree, new TagTreeModel(mainFrame, swfs));
|
||||
setTreeItem(oldTag);
|
||||
if (treeItem != null) {
|
||||
setTreeItem(treeItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshDecompiled() {
|
||||
@@ -2240,12 +2239,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
case ACTION_REPLACE_BINARY:
|
||||
case ACTION_REPLACE_IMAGE:
|
||||
case ACTION_REPLACE_OTHER: {
|
||||
TreeNode treeNode = (TreeNode) tagTree.getLastSelectedPathComponent();
|
||||
if (treeNode == null) {
|
||||
TreeItem item = tagTree.getCurrentTreeItem();
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TreeItem item = treeNode.getItem();
|
||||
if (item instanceof DefineSoundTag) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
|
||||
@@ -2375,12 +2373,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
break;
|
||||
case ACTION_EDIT_GENERIC_TAG: {
|
||||
TreeNode treeNode = (TreeNode) tagTree.getLastSelectedPathComponent();
|
||||
if (treeNode == null) {
|
||||
TreeItem item = tagTree.getCurrentTreeItem();
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TreeItem item = treeNode.getItem();
|
||||
if (item instanceof Tag) {
|
||||
genericEditButton.setVisible(false);
|
||||
genericSaveButton.setVisible(true);
|
||||
@@ -2449,8 +2446,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
setEditText(false);
|
||||
break;
|
||||
case ACTION_SAVE_TEXT:
|
||||
if (oldTag instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) oldTag;
|
||||
TreeItem item = tagTree.getCurrentTreeItem();
|
||||
if (item instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) item;
|
||||
if (saveText(textTag, textValue.getText())) {
|
||||
setEditText(false);
|
||||
}
|
||||
@@ -2549,8 +2547,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
|
||||
TreeItem tagObj = treeNode.getItem();
|
||||
|
||||
oldTag = tagObj;
|
||||
|
||||
if (flashPanel != null) {
|
||||
flashPanel.specialPlayback = false;
|
||||
}
|
||||
@@ -3294,6 +3290,13 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
public void timeline() {
|
||||
final SWF swf = getCurrentSwf();
|
||||
if (swf != null) {
|
||||
TreeItem item = tagTree.getCurrentTreeItem();
|
||||
if (item instanceof DefineSpriteTag) {
|
||||
TimelineFrame tf = new TimelineFrame((DefineSpriteTag) item);
|
||||
tf.setVisible(true);
|
||||
return;
|
||||
}
|
||||
|
||||
TimelineFrame tf = new TimelineFrame(swf);
|
||||
tf.setVisible(true);
|
||||
}
|
||||
@@ -3335,6 +3338,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
return tim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTimeline() {
|
||||
tim = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RECT getRect() {
|
||||
return ((BoundedTag) tag).getRect();
|
||||
@@ -3346,6 +3354,5 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
|
||||
repPanel.setVisible(display);
|
||||
repPanel2.setVisible(display);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,4 +292,12 @@ public class TagTree extends JTree {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TreeItem getCurrentTreeItem() {
|
||||
TreeNode treeNode = (TreeNode) getLastSelectedPathComponent();
|
||||
if (treeNode == null) {
|
||||
return null;
|
||||
}
|
||||
return treeNode.getItem();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,12 @@ package com.jpexs.decompiler.flash.gui.abc;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.gui.abc.treenodes.AS3PackageNode;
|
||||
import com.jpexs.decompiler.flash.gui.abc.treenodes.TreeElement;
|
||||
import com.jpexs.decompiler.flash.treeitems.AS3PackageNodeItem;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class Tree {
|
||||
|
||||
private final TreeElement ROOT = new AS3PackageNode("", "", null, null);
|
||||
private final TreeElement ROOT = new AS3PackageNode("", "", new AS3PackageNodeItem(null, null), null);
|
||||
|
||||
public void add(String name, String path, ScriptPack item) {
|
||||
StringTokenizer st = new StringTokenizer(path, ".");
|
||||
|
||||
@@ -99,6 +99,10 @@ public class TimelineBodyPanel extends JPanel implements MouseListener {
|
||||
end_f = max_f;
|
||||
}
|
||||
|
||||
if (end_d - start_d + 1 < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean keyfound[] = new boolean[end_d - start_d + 1];
|
||||
|
||||
for (int f = start_f; f <= end_f; f++) {
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.timeline;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.gui.AppFrame;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.Image;
|
||||
@@ -32,14 +32,14 @@ public class TimelineFrame extends AppFrame {
|
||||
|
||||
public TimelinePanel timeline;
|
||||
|
||||
public TimelineFrame(SWF swf) {
|
||||
public TimelineFrame(Timelined timelined) {
|
||||
setSize(800, 600);
|
||||
View.setWindowIcon(this);
|
||||
View.centerScreen(this);
|
||||
setTitle(translate("dialog.title"));
|
||||
Container cnt = getContentPane();
|
||||
cnt.setLayout(new BorderLayout());
|
||||
cnt.add(timeline = new TimelinePanel(swf), BorderLayout.CENTER);
|
||||
cnt.add(timeline = new TimelinePanel(timelined), BorderLayout.CENTER);
|
||||
|
||||
java.util.List<Image> images = new ArrayList<>();
|
||||
images.add(View.loadImage("timeline16"));
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.timeline;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.timeline.Timeline;
|
||||
import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
@@ -44,8 +44,8 @@ public class TimelinePanel extends JPanel {
|
||||
public static Color selectedBorderColor = new Color(0xcc, 0, 0);
|
||||
public static Color backgroundColor = new Color(0xee, 0xee, 0xee);
|
||||
|
||||
public TimelinePanel(SWF swf) {
|
||||
timeline = new Timeline(swf);
|
||||
public TimelinePanel(Timelined timelined) {
|
||||
timeline = timelined.getTimeline();
|
||||
timelineBodyPanel = new TimelineBodyPanel(timeline);
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
|
||||
@@ -323,4 +323,9 @@ public class DefineButton2Tag extends ButtonTag implements Container {
|
||||
timeline.frames.add(frameHit);
|
||||
return timeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTimeline() {
|
||||
timeline = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,4 +375,8 @@ public class DefineButtonTag extends ButtonTag implements ASMSource {
|
||||
return timeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTimeline() {
|
||||
timeline = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,11 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
|
||||
return timeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTimeline() {
|
||||
timeline = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCharacterId() {
|
||||
return spriteId;
|
||||
@@ -198,7 +203,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
|
||||
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), swf.version, pos);
|
||||
spriteId = sis.readUI16();
|
||||
frameCount = sis.readUI16();
|
||||
subTags = sis.readTagList(swf, level + 1, parallel, skipUnusualTags, true, swf.gfx);
|
||||
subTags = sis.readTagList(swf, this, level + 1, parallel, skipUnusualTags, true, swf.gfx);
|
||||
}
|
||||
static int c = 0;
|
||||
|
||||
|
||||
@@ -376,7 +376,7 @@ public class DefineText2Tag extends TextTag {
|
||||
if (nextChar != null) {
|
||||
kerningAdjustment = font.getGlyphKerningAdjustment(tags, tr.glyphEntries[i].glyphIndex, font.charToGlyph(tags, nextChar));
|
||||
}
|
||||
advance = (int) Math.round(font.getDivider() * Math.round((double) textHeight * (font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0)));
|
||||
advance = (int) Math.round(font.getDivider() * Math.round(((double) textHeight * font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0)));
|
||||
} else {
|
||||
advance = (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, font.getFontStyle(), (int) (textHeight / SWF.unitDivisor), c, nextChar));
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ public class DefineTextTag extends TextTag {
|
||||
if (nextChar != null) {
|
||||
kerningAdjustment = font.getGlyphKerningAdjustment(tags, tr.glyphEntries[i].glyphIndex, font.charToGlyph(tags, nextChar));
|
||||
}
|
||||
advance = (int) Math.round(font.getDivider() * Math.round((double) textHeight * (font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0)));
|
||||
advance = (int) Math.round(font.getDivider() * Math.round(((double) textHeight * font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0)));
|
||||
} else {
|
||||
advance = (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, font.getFontStyle(), (int) (textHeight / SWF.unitDivisor), c, nextChar));
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.tags.gfx.DefineGradientMap;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.ExporterInfoTag;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.FontTextureInfo;
|
||||
import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
@@ -66,6 +67,8 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializ
|
||||
@Internal
|
||||
protected transient SWF swf;
|
||||
@Internal
|
||||
protected transient Timelined timelined;
|
||||
@Internal
|
||||
private boolean modified;
|
||||
|
||||
public String getTagName() {
|
||||
@@ -99,6 +102,14 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializ
|
||||
this.swf = swf;
|
||||
}
|
||||
|
||||
public Timelined getTimelined() {
|
||||
return timelined;
|
||||
}
|
||||
|
||||
public void setTimelined(Timelined timelined) {
|
||||
this.timelined = timelined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
||||
@@ -42,10 +42,12 @@ import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.font.LineMetrics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -112,7 +114,8 @@ public abstract class TextTag extends CharacterTag implements BoundedTag, Drawab
|
||||
List<Integer> allLeftMargins = new ArrayList<>();
|
||||
List<Integer> allLetterSpacings = new ArrayList<>();
|
||||
FontMetrics fontMetrics;
|
||||
SerializableImage bi = new SerializableImage(5, 5, SerializableImage.TYPE_INT_RGB);
|
||||
BufferedImage bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics graphics = bi.getGraphics();
|
||||
Font aFont = null;
|
||||
int currentLeftMargin;
|
||||
for (int r = 0; r < list.size(); r++) {
|
||||
@@ -132,8 +135,8 @@ public abstract class TextTag extends CharacterTag implements BoundedTag, Drawab
|
||||
if (!font.hasLayout()) {
|
||||
String fontName = FontTag.getFontNameWithFallback(font.getFontName());
|
||||
aFont = new Font(fontName, font.getFontStyle(), (int) (textHeight / SWF.unitDivisor));
|
||||
fontMetrics = bi.getGraphics().getFontMetrics(aFont);
|
||||
LineMetrics lm = fontMetrics.getLineMetrics("A", bi.getGraphics());
|
||||
fontMetrics = graphics.getFontMetrics(aFont);
|
||||
LineMetrics lm = fontMetrics.getLineMetrics("A", graphics);
|
||||
ascent = lm.getAscent();
|
||||
descent = lm.getDescent();
|
||||
leading = lm.getLeading();
|
||||
|
||||
@@ -25,4 +25,6 @@ import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
public interface Timelined extends BoundedTag {
|
||||
|
||||
public Timeline getTimeline();
|
||||
|
||||
public void resetTimeline();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.treenodes;
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -31,6 +33,9 @@ public abstract class TreeNode {
|
||||
public List<TreeNode> subNodes;
|
||||
|
||||
public TreeNode(TreeItem item) {
|
||||
if (item == null) {
|
||||
throw new Error("TreeItem should not be null.");
|
||||
}
|
||||
this.item = item;
|
||||
this.subNodes = new ArrayList<>();
|
||||
}
|
||||
@@ -41,6 +46,10 @@ public abstract class TreeNode {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (item == null) {
|
||||
Logger.getLogger(TreeNode.class.getName()).log(Level.FINE, "Tree item is null");
|
||||
return null;
|
||||
}
|
||||
return item.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class SerializableImage implements Serializable {
|
||||
private BufferedImage image;
|
||||
private transient Graphics graphics;
|
||||
|
||||
public SerializableImage() {
|
||||
private SerializableImage() {
|
||||
}
|
||||
|
||||
public SerializableImage(BufferedImage image) {
|
||||
|
||||
Reference in New Issue
Block a user