From 892b2ff278f08ebc42e59f2e02221f69aa0ebd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Fri, 13 Sep 2013 07:07:21 +0200 Subject: [PATCH] try to call flash functions --- .../jpexs/decompiler/flash/gui/MainFrame.java | 15 +++++------ .../flash/gui/player/FlashPlayerPanel.java | 27 +++++++++++++++++++ .../flash/gui/player/PlayerControls.java | 2 +- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 92fdad4d1..0581e8534 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -290,6 +290,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel private ComponentListener fontChangeList; private JComboBox fontSelection; private JCommandButton saveCommandButton; + private PlayerControls flashControls; private Map sourceFontsMap = new HashMap<>(); private AbortRetryIgnoreHandler errorHandler = new AbortRetryIgnoreHandler() { @Override @@ -1249,7 +1250,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel if (flashPanel != null) { JPanel flashPlayPanel = new JPanel(new BorderLayout()); flashPlayPanel.add(flashPanel, BorderLayout.CENTER); - flashPlayPanel.add(new PlayerControls(flashPanel), BorderLayout.SOUTH); + flashPlayPanel.add(flashControls = new PlayerControls(flashPanel), BorderLayout.SOUTH); leftComponent = flashPlayPanel; } else { JPanel swtPanel = new JPanel(new BorderLayout()); @@ -2953,6 +2954,9 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel if (!forceReload && (tagObj == oldValue)) { return; } + + swfPreviewPanel.stop(); + stopFlashPlayer(); oldValue = tagObj; if (tagObj instanceof ScriptPack) { final ScriptPack scriptLeaf = (ScriptPack) tagObj; @@ -2990,9 +2994,9 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel } else { showDetail(DETAILCARDEMPTYPANEL); } - swfPreviewPanel.stop(); + + if ((tagObj instanceof SWFRoot)) { - stopFlashPlayer(); if (miInternalViewer.isSelected()) { showCard(CARDSWFPREVIEWPANEL); swfPreviewPanel.load(swf); @@ -3029,23 +3033,18 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel } else if ((tagObj instanceof DefineSoundTag) || (tagObj instanceof SoundStreamHeadTag) || (tagObj instanceof SoundStreamHead2Tag)) { showCard(CARDEMPTYPANEL); } */ else if (tagObj instanceof DefineBinaryDataTag) { - stopFlashPlayer(); showCard(CARDEMPTYPANEL); } else if (tagObj instanceof ASMSource) { - stopFlashPlayer(); showCard(CARDACTIONSCRIPTPANEL); actionPanel.setSource((ASMSource) tagObj, !forceReload); } else if (tagObj instanceof ImageTag) { - stopFlashPlayer(); imageButtonsPanel.setVisible(((ImageTag) tagObj).importSupported()); showCard(CARDIMAGEPANEL); imagePanel.setImage(((ImageTag) tagObj).getImage(swf.tags)); } else if ((tagObj instanceof DrawableTag) && (!(tagObj instanceof TextTag)) && (miInternalViewer.isSelected())) { - stopFlashPlayer(); showCard(CARDDRAWPREVIEWPANEL); previewImagePanel.setDrawable((DrawableTag) tagObj, swf, characters, 50/*FIXME*/); } else if (tagObj instanceof FrameNode && ((FrameNode) tagObj).isDisplayed() && (miInternalViewer.isSelected())) { - stopFlashPlayer(); showCard(CARDDRAWPREVIEWPANEL); FrameNode fn = (FrameNode) tagObj; List controlTags = swf.tags; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index 2e5e29448..49ac0c868 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -49,8 +49,35 @@ public class FlashPlayerPanel extends Panel implements FlashDisplay { private static final int CMD_PLAYING = 8; private static final int CMD_REWIND = 9; private static final int CMD_GOTO = 10; + private static final int CMD_CALL = 11; private int frameRate; + public boolean functionPlayback = false; + public synchronized String call(String callString){ + if (pipe != null) { + IntByReference ibr = new IntByReference(); + Kernel32.INSTANCE.WriteFile(pipe, new byte[]{CMD_CALL}, 1, ibr, null); + int callLen=callString.getBytes().length; + Kernel32.INSTANCE.WriteFile(pipe, new byte[]{(byte)((callLen>>8) &0xff),(byte)(callLen & 0xff)}, 2, ibr, null); + Kernel32.INSTANCE.WriteFile(pipe, callString.getBytes(), callLen, ibr, null); + + byte res[] = new byte[2]; + if (Kernel32.INSTANCE.ReadFile(pipe, res, 2, ibr, null)) { + int retLen = ((res[0] & 0xff) << 8) + (res[1] & 0xff); + res = new byte[retLen]; + if (Kernel32.INSTANCE.ReadFile(pipe, res, retLen, ibr, null)) { + String ret=new String(res,0,retLen); + return ret; + }else{ + return null; + } + } else { + return null; + } + } + return null; + } + private synchronized void resize() { if (pipe != null) { IntByReference ibr = new IntByReference(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java b/trunk/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java index 24f3f682e..caac1b1ea 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java @@ -49,7 +49,7 @@ public class PlayerControls extends JPanel implements ActionListener { private JLabel timeLabel; private JLabel totalTimeLabel; private static final Icon pauseIcon = View.getIcon("pause16"); - private static final Icon playIcon = View.getIcon("play16"); + private static final Icon playIcon = View.getIcon("play16"); public PlayerControls(final FlashDisplay display) { this.display = display;