mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 13:10:46 +00:00
Button mouse move and click handling stub (still a lot of work to do)
Transparent checkboard under background color.
This commit is contained in:
@@ -126,6 +126,7 @@ import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Shape;
|
||||
@@ -2261,7 +2262,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static SerializableImage frameToImageGet(Timeline timeline, int frame, RECT displayRect, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
|
||||
public static SerializableImage frameToImageGet(Timeline timeline, int frame,Point mousePos,int mouseButton, RECT displayRect, Matrix transformation, ColorTransform colorTransform) {
|
||||
String key = "frame_" + frame + "_" + timeline.id + "_" + timeline.swf.hashCode();
|
||||
SerializableImage image = getFromCache(key);
|
||||
if (image != null) {
|
||||
@@ -2278,12 +2279,12 @@ public final class SWF implements TreeItem, Timelined {
|
||||
image.fillTransparent();
|
||||
Matrix m = new Matrix();
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
frameToImage(timeline, frame, image, m, colorTransform);
|
||||
frameToImage(timeline, frame, mousePos,mouseButton,image, m, colorTransform);
|
||||
putToCache(key, image);
|
||||
return image;
|
||||
}
|
||||
|
||||
public static void framesToImage(Timeline timeline, List<SerializableImage> ret, int startFrame, int stopFrame, RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
|
||||
public static void framesToImage(Timeline timeline, List<SerializableImage> ret, int startFrame, int stopFrame, Point mousePos,int mouseButton,RECT displayRect, int totalFrameCount, Stack<Integer> visited, Matrix transformation, ColorTransform colorTransform) {
|
||||
RECT rect = displayRect;
|
||||
for (int f = 0; f < timeline.frames.size(); f++) {
|
||||
SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1,
|
||||
@@ -2291,7 +2292,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
image.fillTransparent();
|
||||
Matrix m = new Matrix();
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
frameToImage(timeline, f, image, m, colorTransform);
|
||||
frameToImage(timeline, f, mousePos,mouseButton,image, m, colorTransform);
|
||||
ret.add(image);
|
||||
}
|
||||
}
|
||||
@@ -2308,7 +2309,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
|
||||
}
|
||||
|
||||
public static void frameToImage(Timeline timeline, int frame, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public static void frameToImage(Timeline timeline, int frame,Point mousePos,int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
float unzoom = (float) SWF.unitDivisor;
|
||||
Frame frameObj = timeline.frames.get(frame);
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
@@ -2330,13 +2331,13 @@ public final class SWF implements TreeItem, Timelined {
|
||||
continue;
|
||||
}
|
||||
DepthState layer = frameObj.layers.get(i);
|
||||
if (!timeline.characters.containsKey(layer.characterId)) {
|
||||
if (!timeline.swf.characters.containsKey(layer.characterId)) {
|
||||
continue;
|
||||
}
|
||||
if (!layer.isVisible) {
|
||||
continue;
|
||||
}
|
||||
CharacterTag character = timeline.characters.get(layer.characterId);
|
||||
CharacterTag character = timeline.swf.characters.get(layer.characterId);
|
||||
Matrix mat = new Matrix(layer.matrix);
|
||||
mat = mat.preConcatenate(transformation);
|
||||
|
||||
@@ -2397,7 +2398,7 @@ public final class SWF implements TreeItem, Timelined {
|
||||
m.translate(-rect.xMin, -rect.yMin);
|
||||
drawMatrix.translate(rect.xMin, rect.yMin);
|
||||
|
||||
drawable.toImage(dframe, layer.ratio, img, m, clrTrans);
|
||||
drawable.toImage(dframe, layer.ratio,mousePos,mouseButton, img, m, clrTrans);
|
||||
} else if (drawable instanceof FontTag) {
|
||||
// only DefineFont tags
|
||||
FontTag fontTag = (FontTag) drawable;
|
||||
|
||||
@@ -20,18 +20,48 @@ import com.jpexs.decompiler.flash.AppStrings;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.gui.player.FlashDisplay;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MorphShapeTag;
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
import com.jpexs.decompiler.flash.timeline.Frame;
|
||||
import com.jpexs.decompiler.flash.timeline.Timeline;
|
||||
import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Paint;
|
||||
import java.awt.PaintContext;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Shape;
|
||||
import java.awt.TexturePaint;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import javax.swing.ImageIcon;
|
||||
@@ -55,6 +85,10 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
private int frame = -1;
|
||||
private SWF swf;
|
||||
private boolean loaded;
|
||||
private Point mousePos = null;
|
||||
private int mouseButton;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setBackground(Color bg) {
|
||||
@@ -64,13 +98,49 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
super.setBackground(bg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addMouseListener(MouseListener l) {
|
||||
label.addMouseListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeMouseListener(MouseListener l) {
|
||||
label.removeMouseListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addMouseMotionListener(MouseMotionListener l) {
|
||||
label.addMouseMotionListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeMouseMotionListener(MouseMotionListener l) {
|
||||
label.removeMouseMotionListener(l);
|
||||
}
|
||||
|
||||
public ImagePanel() {
|
||||
super(new BorderLayout());
|
||||
label.setHorizontalAlignment(JLabel.CENTER);
|
||||
label.setOpaque(true);
|
||||
setOpaque(true);
|
||||
setBackground(View.DEFAULT_BACKGROUND_COLOR);
|
||||
add(label, BorderLayout.CENTER);
|
||||
|
||||
|
||||
|
||||
JPanel labelPan = new JPanel(new GridBagLayout()){
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
Graphics2D g2d=(Graphics2D)g;
|
||||
g2d.setPaint(View.transparentPaint);
|
||||
g2d.fill(new Rectangle(0,0,getWidth(),getHeight()));
|
||||
g2d.setComposite(AlphaComposite.SrcOver);
|
||||
g2d.setPaint(View.swfBackgroundColor);
|
||||
g2d.fill(new Rectangle(0,0,getWidth(),getHeight()));
|
||||
}
|
||||
|
||||
};
|
||||
labelPan.add(label,new GridBagConstraints());
|
||||
add(labelPan,BorderLayout.CENTER);
|
||||
|
||||
JPanel bottomPanel = new JPanel(new BorderLayout());
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
@@ -81,11 +151,47 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
buttonsPanel.add(selectColorButton);
|
||||
bottomPanel.add(buttonsPanel, BorderLayout.EAST);
|
||||
add(bottomPanel, BorderLayout.SOUTH);
|
||||
label.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
mousePos = e.getPoint();
|
||||
drawFrame();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
mousePos = null;
|
||||
drawFrame();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
mouseButton = e.getButton();
|
||||
drawFrame();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
mouseButton = 0;
|
||||
drawFrame();
|
||||
}
|
||||
|
||||
});
|
||||
label.addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand() == ACTION_SELECT_BKCOLOR) {
|
||||
if (e.getActionCommand().equals(ACTION_SELECT_BKCOLOR)) {
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -123,7 +229,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
return;
|
||||
}
|
||||
frame = 0;
|
||||
if (drawable.getNumFrames() == 1) {
|
||||
/*if (drawable.getNumFrames() == 1) {
|
||||
Matrix mat = new Matrix();
|
||||
mat.translateX = swf.displayRect.Xmin;
|
||||
mat.translateY = swf.displayRect.Ymin;
|
||||
@@ -145,7 +251,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
image.fillTransparent();
|
||||
Matrix m = new Matrix();
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
drawable.toImage(0, 0, image, m, new ColorTransform());
|
||||
drawable.toImage(0, 0, mousePos,mouseButton,image, m, new ColorTransform());
|
||||
img = image;
|
||||
} else if (drawable instanceof FontTag) {
|
||||
// only DefineFont tags
|
||||
@@ -158,7 +264,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
setImage(img);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
play();
|
||||
}
|
||||
|
||||
@@ -208,8 +314,8 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
}
|
||||
}
|
||||
|
||||
private static SerializableImage getFrame(SWF swf, int frame, DrawableTag drawable) {
|
||||
String key = "drawable_" + frame + "_" + drawable.hashCode();
|
||||
private static SerializableImage getFrame(SWF swf, int frame, DrawableTag drawable,Point mousePos, int mouseButton) {
|
||||
String key = "drawable_" + frame + "_" + drawable.hashCode()+"_"+mouseButton+"_"+(mousePos==null?"out":"over");
|
||||
SerializableImage img = SWF.getFromCache(key);
|
||||
if (img == null) {
|
||||
if (drawable instanceof BoundedTag) {
|
||||
@@ -231,7 +337,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
Matrix m = new Matrix();
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
m.scale(scale);
|
||||
drawable.toImage(frame, frame, image, m, new ColorTransform());
|
||||
drawable.toImage(frame, frame,mousePos,mouseButton, image, m, new ColorTransform());
|
||||
img = image;
|
||||
} else if (drawable instanceof FontTag) {
|
||||
// only DefineFont tags
|
||||
@@ -250,7 +356,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
Matrix mat = new Matrix();
|
||||
mat.translateX = swf.displayRect.Xmin;
|
||||
mat.translateY = swf.displayRect.Ymin;
|
||||
ImageIcon icon = new ImageIcon(getFrame(swf, frame, drawable).getBufferedImage());
|
||||
ImageIcon icon = new ImageIcon(getFrame(swf, frame, drawable,mousePos,mouseButton).getBufferedImage());
|
||||
label.setIcon(icon);
|
||||
}
|
||||
|
||||
@@ -265,7 +371,6 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
public void play() {
|
||||
pause();
|
||||
if (drawable.getNumFrames() > 1) {
|
||||
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
@@ -273,6 +378,8 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis
|
||||
nextFrame();
|
||||
}
|
||||
}, 0, 1000 / frameRate);
|
||||
}else{
|
||||
drawFrame();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2490,7 +2490,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
totalFrameCount = ((DefineSpriteTag) fn.getParent()).frameCount;
|
||||
timeline = ((DefineSpriteTag) fn.getParent()).getTimeline();
|
||||
}
|
||||
previewImagePanel.setImage(SWF.frameToImageGet(timeline, fn.getFrame() - 1, rect, new Stack<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor), new ColorTransform()));
|
||||
previewImagePanel.setImage(SWF.frameToImageGet(timeline, fn.getFrame() - 1, null,0,rect, Matrix.getScaleInstance(1 / SWF.unitDivisor), new ColorTransform()));
|
||||
} else if (((tagObj instanceof FrameNodeItem) && ((FrameNodeItem) tagObj).isDisplayed()) || ((tagObj instanceof CharacterTag) || (tagObj instanceof FontTag)) && (tagObj instanceof Tag)) {
|
||||
((CardLayout) viewerCards.getLayout()).show(viewerCards, FLASH_VIEWER_CARD);
|
||||
createAndShowTempSwf(tagObj);
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
@@ -36,6 +37,7 @@ import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
@@ -167,7 +169,7 @@ public class PreviewImage extends JPanel {
|
||||
} else if (treeItem instanceof FrameNodeItem) {
|
||||
FrameNodeItem fn = (FrameNodeItem) treeItem;
|
||||
RECT rect = swf.displayRect;
|
||||
imgSrc = SWF.frameToImageGet(swf.getTimeline(), fn.getFrame() - 1, rect, new Stack<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor), new ColorTransform());
|
||||
imgSrc = SWF.frameToImageGet(swf.getTimeline(), fn.getFrame() - 1, null,0,rect, Matrix.getScaleInstance(1 / SWF.unitDivisor), new ColorTransform());
|
||||
width = (imgSrc.getWidth());
|
||||
height = (imgSrc.getHeight());
|
||||
} else if (treeItem instanceof ImageTag) {
|
||||
@@ -218,7 +220,7 @@ public class PreviewImage extends JPanel {
|
||||
image.fillTransparent();
|
||||
if (imgSrc == null) {
|
||||
DrawableTag drawable = (DrawableTag) treeItem;
|
||||
drawable.toImage(0, 0, image, m, new ColorTransform());
|
||||
drawable.toImage(0, 0,null,0, image, m, new ColorTransform());
|
||||
} else {
|
||||
Graphics2D g = (Graphics2D) image.getGraphics();
|
||||
g.setTransform(m.toTransform());
|
||||
@@ -248,7 +250,12 @@ public class PreviewImage extends JPanel {
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2d=(Graphics2D)g;
|
||||
g2d.setPaint(View.transparentPaint);
|
||||
g2d.fill(new Rectangle(0,0,getWidth(),getHeight()));
|
||||
g2d.setComposite(AlphaComposite.SrcOver);
|
||||
g2d.setPaint(View.swfBackgroundColor);
|
||||
g2d.fill(new Rectangle(0,0,getWidth(),getHeight()));
|
||||
if (image != null) {
|
||||
int x = (getWidth() / 2) - (image.getWidth(this) / 2);
|
||||
int y = (getHeight() / 2) - (image.getHeight(this) / 2);
|
||||
|
||||
@@ -24,6 +24,10 @@ import com.jpexs.decompiler.flash.gui.player.PlayerControls;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
@@ -45,7 +49,7 @@ public class SWFPreviewPanel extends JPanel implements FlashDisplay {
|
||||
int frame = 1;
|
||||
List<SerializableImage> frameImages;
|
||||
JLabel buffering = new JLabel(AppStrings.translate("work.buffering") + "...");
|
||||
|
||||
|
||||
public SWFPreviewPanel() {
|
||||
pan = new ImagePanel();
|
||||
pan.setBackground(View.swfBackgroundColor);
|
||||
@@ -58,7 +62,7 @@ public class SWFPreviewPanel extends JPanel implements FlashDisplay {
|
||||
//prevLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
|
||||
add(prevLabel, BorderLayout.NORTH);
|
||||
//add(buffering, BorderLayout.SOUTH);
|
||||
add(new PlayerControls(this), BorderLayout.SOUTH);
|
||||
add(new PlayerControls(this), BorderLayout.SOUTH);
|
||||
}
|
||||
private SWF swf;
|
||||
|
||||
@@ -71,7 +75,8 @@ public class SWFPreviewPanel extends JPanel implements FlashDisplay {
|
||||
@Override
|
||||
public void run() {
|
||||
buffering.setVisible(true);
|
||||
SWF.framesToImage(swf.getTimeline(), frameImages, 0, swf.frameCount - 1, swf.displayRect, swf.frameCount, new Stack<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor), new ColorTransform());
|
||||
//TODO: handle mouse move and clicks
|
||||
SWF.framesToImage(swf.getTimeline(), frameImages, 0, swf.frameCount - 1,null,0, swf.displayRect, swf.frameCount, new Stack<Integer>(), Matrix.getScaleInstance(1 / SWF.unitDivisor), new ColorTransform());
|
||||
buffering.setVisible(false);
|
||||
}
|
||||
}.start();
|
||||
|
||||
@@ -20,14 +20,18 @@ import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.TexturePaint;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
@@ -76,6 +80,24 @@ public class View {
|
||||
public static final Color DEFAULT_BACKGROUND_COLOR = new Color(217, 231, 250);
|
||||
public static Color swfBackgroundColor = DEFAULT_BACKGROUND_COLOR;
|
||||
|
||||
|
||||
private static final BufferedImage transparentTexture;
|
||||
public static final TexturePaint transparentPaint;
|
||||
|
||||
private static final Color transparentColor1 = new Color(0x99,0x99,0x99);
|
||||
private static final Color transparentColor2 = new Color(0x66,0x66,0x66);
|
||||
|
||||
static{
|
||||
transparentTexture = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g=transparentTexture.getGraphics();
|
||||
g.setColor(transparentColor1);
|
||||
g.fillRect(0, 0, 16, 16);
|
||||
g.setColor(transparentColor2);
|
||||
g.fillRect(0, 0, 8, 8);
|
||||
g.fillRect(8, 8, 8, 8);
|
||||
transparentPaint = new TexturePaint(View.transparentTexture, new Rectangle(0,0,transparentTexture.getWidth(),transparentTexture.getHeight()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets windows Look and Feel
|
||||
*/
|
||||
|
||||
@@ -245,9 +245,16 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
RECT displayRect = getRect();
|
||||
SWF.frameToImage(getTimeline(), frame, image, transformation, colorTransform);
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
Timeline tim = getTimeline();
|
||||
//TODO: handle exact position
|
||||
frame = 0;
|
||||
if (mouseButton > 0 && tim.frames.size() > 1) {
|
||||
frame = 1;
|
||||
} else if (mousePos != null && tim.frames.size() > 2) {
|
||||
frame = 2;
|
||||
}
|
||||
SWF.frameToImage(tim, frame, mousePos, mouseButton, image, transformation, colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -269,22 +276,50 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
|
||||
timeline = new Timeline(swf, new ArrayList<Tag>(), buttonId, getRect());
|
||||
|
||||
int maxDepth = 0;
|
||||
Frame fr = new Frame();
|
||||
Frame frameUp = null;
|
||||
Frame frameDown = null;
|
||||
Frame frameOver = null;
|
||||
for (BUTTONRECORD r : this.characters) {
|
||||
|
||||
Frame frame = new Frame(timeline);
|
||||
if (r.buttonStateUp) {
|
||||
DepthState layer = new DepthState();
|
||||
layer.colorTransForm = r.colorTransform;
|
||||
layer.blendMode = r.blendMode;
|
||||
layer.filters = r.filterList;
|
||||
layer.matrix = r.placeMatrix;
|
||||
layer.characterId = r.characterId;
|
||||
if (r.placeDepth > maxDepth) {
|
||||
maxDepth = r.placeDepth;
|
||||
if (frameUp == null) {
|
||||
frameUp = frame;
|
||||
}
|
||||
fr.layers.put(r.placeDepth, layer);
|
||||
frame = frameUp;
|
||||
|
||||
} else if (r.buttonStateDown) {
|
||||
if (frameDown == null) {
|
||||
frameDown = frame;
|
||||
}
|
||||
frame = frameDown;
|
||||
} else if (r.buttonStateOver) {
|
||||
if (frameOver == null) {
|
||||
frameOver = frame;
|
||||
}
|
||||
frame = frameOver;
|
||||
}
|
||||
DepthState layer = new DepthState(swf,frame);
|
||||
layer.colorTransForm = r.colorTransform;
|
||||
layer.blendMode = r.blendMode;
|
||||
layer.filters = r.filterList;
|
||||
layer.matrix = r.placeMatrix;
|
||||
layer.characterId = r.characterId;
|
||||
if (r.placeDepth > maxDepth) {
|
||||
maxDepth = r.placeDepth;
|
||||
}
|
||||
frame.layers.put(r.placeDepth, layer);
|
||||
|
||||
}
|
||||
if (frameUp != null) {
|
||||
timeline.frames.add(frameUp);
|
||||
}
|
||||
if (frameDown != null) {
|
||||
timeline.frames.add(frameDown);
|
||||
}
|
||||
if (frameOver != null) {
|
||||
timeline.frames.add(frameOver);
|
||||
}
|
||||
timeline.frames.add(fr);
|
||||
return timeline;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,8 +267,16 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
SWF.frameToImage(getTimeline(), frame, image, transformation, colorTransform);
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
Timeline tim = getTimeline();
|
||||
//TODO: handle exact position
|
||||
frame = 0;
|
||||
if (mouseButton > 0 && tim.frames.size() > 1) {
|
||||
frame = 1;
|
||||
} else if (mousePos != null && tim.frames.size() > 2) {
|
||||
frame = 2;
|
||||
}
|
||||
SWF.frameToImage(tim, frame, mousePos,mouseButton, image, transformation, colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -317,22 +325,49 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
|
||||
}
|
||||
}
|
||||
int maxDepth = 0;
|
||||
Frame fr = new Frame();
|
||||
Frame frameUp = null;
|
||||
Frame frameDown = null;
|
||||
Frame frameOver = null;
|
||||
for (BUTTONRECORD r : this.characters) {
|
||||
if (r.buttonStateUp) {
|
||||
DepthState layer = new DepthState();
|
||||
layer.colorTransForm = clrTrans;
|
||||
layer.blendMode = r.blendMode;
|
||||
layer.filters = r.filterList;
|
||||
layer.matrix = r.placeMatrix;
|
||||
layer.characterId = r.characterId;
|
||||
if (r.placeDepth > maxDepth) {
|
||||
maxDepth = r.placeDepth;
|
||||
|
||||
Frame frame = new Frame(timeline);
|
||||
if (r.buttonStateUp) {
|
||||
if(frameUp==null){
|
||||
frameUp = frame;
|
||||
}
|
||||
fr.layers.put(r.placeDepth, layer);
|
||||
frame = frameUp;
|
||||
|
||||
}else if (r.buttonStateDown) {
|
||||
if(frameDown==null){
|
||||
frameDown = frame;
|
||||
}
|
||||
frame = frameDown;
|
||||
}else if (r.buttonStateOver) {
|
||||
if(frameOver==null){
|
||||
frameOver = frame;
|
||||
}
|
||||
frame = frameOver;
|
||||
}
|
||||
|
||||
|
||||
DepthState layer = new DepthState(swf,frame);
|
||||
layer.colorTransForm = clrTrans;
|
||||
layer.blendMode = r.blendMode;
|
||||
layer.filters = r.filterList;
|
||||
layer.matrix = r.placeMatrix;
|
||||
layer.characterId = r.characterId;
|
||||
if (r.placeDepth > maxDepth) {
|
||||
maxDepth = r.placeDepth;
|
||||
}
|
||||
|
||||
frame.layers.put(r.placeDepth, layer);
|
||||
}
|
||||
if(frameUp!=null){
|
||||
timeline.frames.add(frameUp);
|
||||
}
|
||||
if(frameDown!=null){
|
||||
timeline.frames.add(frameDown);
|
||||
}
|
||||
timeline.frames.add(fr);
|
||||
return timeline;
|
||||
}
|
||||
|
||||
|
||||
@@ -758,7 +758,7 @@ public class DefineEditTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
if (border) {
|
||||
// border is always black, fill color is always white?
|
||||
RGB borderColor = new RGBA(Color.black);
|
||||
|
||||
@@ -314,7 +314,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
SHAPEWITHSTYLE shape = getShapeAtRatio(ratio);
|
||||
// shapeNum: 4
|
||||
// todo: Currently the generated image is not cached, because the cache
|
||||
|
||||
@@ -297,7 +297,7 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
SHAPEWITHSTYLE shape = getShapeAtRatio(ratio);
|
||||
// shapeNum: 3
|
||||
// todo: Currently the generated image is not cached, because the cache
|
||||
|
||||
@@ -70,7 +70,7 @@ public class DefineShape2Tag extends CharacterTag implements ShapeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation, colorTransform);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class DefineShape3Tag extends CharacterTag implements ShapeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation, colorTransform);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class DefineShape4Tag extends CharacterTag implements ShapeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation, colorTransform);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class DefineShapeTag extends CharacterTag implements ShapeTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
BitmapExporter.exportTo(swf, getShapes(), null, image, transformation, colorTransform);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ import com.jpexs.decompiler.flash.tags.base.Container;
|
||||
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
import com.jpexs.decompiler.flash.timeline.Frame;
|
||||
import com.jpexs.decompiler.flash.timeline.Timeline;
|
||||
import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
@@ -266,8 +268,8 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
SWF.frameToImage(getTimeline(), frame, image, transformation, colorTransform);
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
SWF.frameToImage(getTimeline(), frame, mousePos, mouseButton, image, transformation, colorTransform);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -487,7 +487,7 @@ public class DefineText2Tag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
staticTextToImage(swf, textRecords, 2, image, getTextMatrix(), transformation, colorTransform);
|
||||
}
|
||||
|
||||
|
||||
@@ -503,7 +503,7 @@ public class DefineTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
staticTextToImage(swf, textRecords, 1, image, getTextMatrix(), transformation, colorTransform);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.jpexs.helpers.SerializableImage;
|
||||
*/
|
||||
public interface DrawableTag {
|
||||
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform);
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform);
|
||||
|
||||
public Point getImagePos(int frame);
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toImage(int frame, int ratio, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
public void toImage(int frame, int ratio, java.awt.Point mousePos,int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
throw new Error("this overload of toImage call is not supported on FontTag");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,17 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.timeline;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.exporters.Matrix;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
|
||||
import com.jpexs.decompiler.flash.types.CLIPACTIONS;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.MATRIX;
|
||||
import com.jpexs.decompiler.flash.types.RGBA;
|
||||
import com.jpexs.decompiler.flash.types.filters.FILTER;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,12 +50,16 @@ public class DepthState {
|
||||
public boolean key = false;
|
||||
public int clipDepth = -1;
|
||||
public int time = 0;
|
||||
|
||||
public DepthState() {
|
||||
|
||||
private SWF swf;
|
||||
private Frame frame;
|
||||
public DepthState(SWF swf,Frame frame) {
|
||||
this.swf = swf;
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
public DepthState(DepthState obj) {
|
||||
swf = obj.swf;
|
||||
frame = obj.frame;
|
||||
characterId = obj.characterId;
|
||||
matrix = obj.matrix;
|
||||
instanceName = obj.instanceName;
|
||||
@@ -64,4 +74,12 @@ public class DepthState {
|
||||
clipDepth = obj.clipDepth;
|
||||
time = obj.time + 1;
|
||||
}
|
||||
|
||||
public void drawTo(SerializableImage img, Point mousePos, int mouseButton){
|
||||
CharacterTag c=swf.characters.get(characterId);
|
||||
if(c instanceof DrawableTag){
|
||||
DrawableTag d = (DrawableTag)c;
|
||||
d.toImage(time, ratio,mousePos, mouseButton,img, new Matrix(matrix), colorTransForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,15 @@ public class Frame {
|
||||
public Map<Integer, DepthState> layers = new HashMap<>();
|
||||
public DoActionTag action;
|
||||
public RGB backgroundColor = new RGBA(0, 0, 0, 0);
|
||||
|
||||
public Frame() {
|
||||
|
||||
public Timeline timeline;
|
||||
|
||||
public Frame(Timeline timeline) {
|
||||
this.timeline = timeline;
|
||||
}
|
||||
|
||||
public Frame(Frame obj) {
|
||||
layers = new HashMap<>();
|
||||
timeline = obj.timeline;
|
||||
for (int depth : obj.layers.keySet()) {
|
||||
layers.put(depth, new DepthState(obj.layers.get(depth)));
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.tags.DoActionTag;
|
||||
import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag;
|
||||
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.RemoveTag;
|
||||
import com.jpexs.decompiler.flash.types.CLIPACTIONS;
|
||||
@@ -31,11 +30,12 @@ import com.jpexs.decompiler.flash.types.MATRIX;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.decompiler.flash.types.filters.FILTER;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -45,12 +45,9 @@ public class Timeline {
|
||||
|
||||
public List<Frame> frames = new ArrayList<>();
|
||||
public int id;
|
||||
public Map<Integer, CharacterTag> characters = new HashMap<>();
|
||||
public SWF swf;
|
||||
public RECT displayRect;
|
||||
|
||||
public Timeline() {
|
||||
}
|
||||
|
||||
public int getMaxDepth() {
|
||||
int max_depth = 0;
|
||||
@@ -76,13 +73,7 @@ public class Timeline {
|
||||
this.id = id;
|
||||
this.swf = swf;
|
||||
this.displayRect = displayRect;
|
||||
Frame frame = new Frame();
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof CharacterTag) {
|
||||
CharacterTag c = (CharacterTag) t;
|
||||
characters.put(c.getCharacterId(), c);
|
||||
}
|
||||
}
|
||||
Frame frame = new Frame(this);
|
||||
for (Tag t : tags) {
|
||||
if (t instanceof SetBackgroundColorTag) {
|
||||
frame.backgroundColor = ((SetBackgroundColorTag) t).backgroundColor;
|
||||
@@ -91,7 +82,7 @@ public class Timeline {
|
||||
PlaceObjectTypeTag po = (PlaceObjectTypeTag) t;
|
||||
int depth = po.getDepth();
|
||||
if (!frame.layers.containsKey(depth)) {
|
||||
frame.layers.put(depth, new DepthState());
|
||||
frame.layers.put(depth, new DepthState(swf,frame));
|
||||
}
|
||||
DepthState fl = frame.layers.get(depth);
|
||||
int characterId = po.getCharacterId();
|
||||
@@ -163,7 +154,7 @@ public class Timeline {
|
||||
}
|
||||
}
|
||||
|
||||
public void toImage(int frame, int ratio, List<Tag> tags, Map<Integer, CharacterTag> characters, Stack<Integer> visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
|
||||
public void toImage(int frame, int ratio, Point mousePos,int mouseButton,SerializableImage image, Matrix transformation, ColorTransform colorTransform) {
|
||||
SWF.frameToImage(this, frame, mousePos,mouseButton,image, transformation, colorTransform);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user