mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 02:10:44 +00:00
#1676 View video tags in external flash projector
This commit is contained in:
@@ -467,6 +467,28 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
public static void runAsync(File swfFile) {
|
||||
String playerLocation = Configuration.playerLocation.get();
|
||||
if (playerLocation.isEmpty() || (!new File(playerLocation).exists())) {
|
||||
ViewMessages.showMessageDialog(getDefaultMessagesComponent(), AppStrings.translate("message.playerpath.notset"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
|
||||
advancedSettings("paths");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Process process = Runtime.getRuntime().exec(new String[]{playerLocation, swfFile.getAbsolutePath()});
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (process.isAlive()) {
|
||||
process.destroyForcibly();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void run(SWF swf) {
|
||||
String flashVars = "";//key=val&key2=val2
|
||||
String playerLocation = Configuration.playerLocation.get();
|
||||
|
||||
@@ -3559,10 +3559,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
previewPanel.showImagePanel(swf, swf, -1);
|
||||
} else {
|
||||
previewPanel.setParametersPanelVisible(false);
|
||||
if (flashPanel != null) { //same for flashPanel2
|
||||
previewPanel.showFlashViewerPanel();
|
||||
previewPanel.showSwf(swf);
|
||||
}
|
||||
//if (flashPanel != null) { //same for flashPanel2
|
||||
previewPanel.showFlashViewerPanel();
|
||||
previewPanel.showSwf(swf);
|
||||
|
||||
//}
|
||||
}
|
||||
} else if ((treeItem instanceof PlaceObjectTypeTag) && (previewPanel != dumpPreviewPanel)) {
|
||||
TreePath path = tagTree.getModel().getTreePath(treeItem);
|
||||
|
||||
@@ -48,8 +48,12 @@ import java.awt.BorderLayout;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
@@ -190,6 +194,9 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
|
||||
private final int PLACE_EDIT_RAW = 2;
|
||||
private int placeEditMode = 0;
|
||||
|
||||
//used only for flash player
|
||||
private TreeItem currentItem;
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
this.readOnly = readOnly;
|
||||
setDividerSize(this.readOnly ? 0 : dividerSize);
|
||||
@@ -355,8 +362,8 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
|
||||
flashPlayPanel2.add(new PlayerControls(mainPanel, flashPanel), BorderLayout.SOUTH);
|
||||
leftComponent = flashPlayPanel2;
|
||||
} else {
|
||||
JPanel swtPanel = new JPanel(new BorderLayout());
|
||||
String labelStr = "";
|
||||
JPanel swtPanel = new JPanel(new GridBagLayout());
|
||||
/*String labelStr = "";
|
||||
if (!Platform.isWindows()) {
|
||||
labelStr = mainPanel.translate("notavailonthisplatform");
|
||||
} else {
|
||||
@@ -368,7 +375,17 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
|
||||
}
|
||||
String htmlLabelStr = "<html><center>" + labelStr.replace("\n", "<br>") + "</center></html>";
|
||||
swtPanel.add(new JLabel(htmlLabelStr, JLabel.CENTER), BorderLayout.CENTER);
|
||||
swtPanel.setBackground(View.getDefaultBackgroundColor());
|
||||
swtPanel.setBackground(View.getDefaultBackgroundColor());*/
|
||||
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
JButton flashProjectorButton = new JButton(mainPanel.translate("button.showin.flashprojector"));
|
||||
flashProjectorButton.addActionListener(this::flashProjectorActionPerformed);
|
||||
buttonsPanel.add(flashProjectorButton);
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.anchor = GridBagConstraints.CENTER;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
swtPanel.add(buttonsPanel, gbc);
|
||||
|
||||
leftComponent = swtPanel;
|
||||
}
|
||||
|
||||
@@ -376,6 +393,10 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
|
||||
return pan;
|
||||
}
|
||||
|
||||
private void flashProjectorActionPerformed(ActionEvent e) {
|
||||
createAndRunTempSwf(currentItem);
|
||||
}
|
||||
|
||||
private JPanel createImagesCard() {
|
||||
JPanel shapesCard = new JPanel(new BorderLayout());
|
||||
JPanel previewPanel = new JPanel(new BorderLayout());
|
||||
@@ -716,6 +737,46 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
|
||||
nextFontsButton.setVisible(false);
|
||||
}
|
||||
|
||||
private void createAndRunTempSwf(TreeItem treeItem) {
|
||||
try {
|
||||
File extTempFile = File.createTempFile("ffdec_viewext_", ".swf");
|
||||
extTempFile.deleteOnExit();
|
||||
|
||||
if (treeItem instanceof SWF) {
|
||||
SWF swf = (SWF) treeItem;
|
||||
try (FileOutputStream fos = new FileOutputStream(extTempFile)) {
|
||||
swf.saveTo(fos);
|
||||
}
|
||||
} else {
|
||||
Color backgroundColor = View.getSwfBackgroundColor();
|
||||
|
||||
if (treeItem instanceof Tag) {
|
||||
Tag tag = (Tag) treeItem;
|
||||
if (tag instanceof FontTag) { //Fonts are always black on white
|
||||
backgroundColor = View.getDefaultBackgroundColor();
|
||||
}
|
||||
} else if (treeItem instanceof Frame) {
|
||||
Frame fn = (Frame) treeItem;
|
||||
SWF sourceSwf = fn.getSwf();
|
||||
if (fn.timeline.timelined == sourceSwf) {
|
||||
SetBackgroundColorTag setBgColorTag = sourceSwf.getBackgroundColor();
|
||||
if (setBgColorTag != null) {
|
||||
backgroundColor = setBgColorTag.backgroundColor.toColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SWFHeader header;
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(extTempFile))) {
|
||||
header = new PreviewExporter().exportSwf(fos, treeItem, backgroundColor, fontPageNum, true);
|
||||
}
|
||||
}
|
||||
Main.runAsync(extTempFile);
|
||||
} catch (IOException | ActionParseException ex) {
|
||||
Logger.getLogger(PreviewPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void createAndShowTempSwf(TreeItem treeItem) {
|
||||
try {
|
||||
if (tempFile != null) {
|
||||
@@ -745,13 +806,15 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
|
||||
|
||||
SWFHeader header;
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) {
|
||||
header = new PreviewExporter().exportSwf(fos, treeItem, backgroundColor, fontPageNum);
|
||||
header = new PreviewExporter().exportSwf(fos, treeItem, backgroundColor, fontPageNum, false);
|
||||
}
|
||||
|
||||
if (flashPanel != null) {
|
||||
flashPanel.displaySWF(tempFile.getAbsolutePath(), backgroundColor, header.frameRate);
|
||||
}
|
||||
|
||||
this.currentItem = treeItem;
|
||||
|
||||
showFlashViewerPanel();
|
||||
} catch (IOException | ActionParseException ex) {
|
||||
Logger.getLogger(PreviewPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@@ -759,6 +822,10 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
|
||||
}
|
||||
|
||||
public void showSwf(SWF swf) {
|
||||
currentItem = swf;
|
||||
if (flashPanel == null) {
|
||||
return;
|
||||
}
|
||||
Color backgroundColor = View.getDefaultBackgroundColor();
|
||||
SetBackgroundColorTag setBgColorTag = swf.getBackgroundColor();
|
||||
if (setBgColorTag != null) {
|
||||
|
||||
@@ -826,3 +826,5 @@ notavailable.activex = Preview of this object is not available since Flash Activ
|
||||
notavailable.activex.disable = You can enable using internal viewer by unchecking\n \
|
||||
Advanced Settings / Other / (Deprecated) Use Adobe Flash player for preview of objects\n \
|
||||
But unfortunately, this won't work for movie tags.
|
||||
|
||||
button.showin.flashprojector = Show in flash projector
|
||||
@@ -801,4 +801,6 @@ notavailable.activex = N\u00e1hled tohoto objektu nen\u00ed dostupn\u00fd proto\
|
||||
|
||||
notavailable.activex.disable = M\u016f\u017eete povolit pou\u017eit\u00ed intern\u00edho prohl\u00ed\u017ee\u010de od\u0161krtnut\u00edm\n \
|
||||
Pokro\u010dil\u00e1 nastaven\u00ed / Ostatn\u00ed / (P\u0159ekon\u00e1no) Pou\u017e\u00edvat Adobe Flash player pro n\u00e1hledy objekt\u016f\n \
|
||||
Ale bohu\u017eel, tohle nebude fungovat pro tagy s videi.
|
||||
Ale bohu\u017eel, tohle nebude fungovat pro tagy s videi.
|
||||
|
||||
button.showin.flashprojector = Zobrazit ve flash projektoru
|
||||
Reference in New Issue
Block a user