From 5d20a2a17c32cb54722fc0126045fae5db77471a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 6 Nov 2022 11:13:37 +0100 Subject: [PATCH] New file dialog: ActionScript type selection New file - fixed gfx, framecount. --- src/com/jpexs/decompiler/flash/gui/Main.java | 14 +++++++--- .../decompiler/flash/gui/NewFileDialog.java | 28 +++++++++++++++++-- .../gui/locales/NewFileDialog.properties | 4 +++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 1a391df1a..7e0e2aae3 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -1476,7 +1476,8 @@ public class Main { mainFrame.setVisible(false); Helper.freeMem(); } - String fileTitle = AppStrings.translate("new.filename") + ".swf"; + String ext = newFileDialog.isGfx() ? "gfx" : "swf"; + String fileTitle = AppStrings.translate("new.filename") + "." + ext; SWFSourceInfo sourceInfo = new SWFSourceInfo(new ByteArrayInputStream(new byte[0]), null, fileTitle); sourceInfos.add(sourceInfo); SWFList list = new SWFList(); @@ -1494,9 +1495,13 @@ public class Main { swf.compression = newFileDialog.getCompression(); swf.version = newFileDialog.getVersionNumber(); swf.frameRate = newFileDialog.getFrameRate(); + swf.gfx = newFileDialog.isGfx(); swf.setHeaderModified(true); - Tag t; - t = new FileAttributesTag(swf); + FileAttributesTag f = new FileAttributesTag(swf); + if (newFileDialog.isAs3()) { + f.actionScript3 = true; + } + Tag t = f; t.setTimelined(swf); swf.addTag(t); t = new SetBackgroundColorTag(swf, new RGB(newFileDialog.getBackgroundColor())); @@ -1504,7 +1509,8 @@ public class Main { swf.addTag(t); t = new ShowFrameTag(swf); t.setTimelined(swf); - swf.addTag(t); + swf.addTag(t); + swf.frameCount = 1; swf.hasEndTag = true; list.add(swf); swf.swfList = list; diff --git a/src/com/jpexs/decompiler/flash/gui/NewFileDialog.java b/src/com/jpexs/decompiler/flash/gui/NewFileDialog.java index a290f7767..70e655696 100644 --- a/src/com/jpexs/decompiler/flash/gui/NewFileDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/NewFileDialog.java @@ -28,6 +28,7 @@ import java.awt.Graphics; import java.awt.Window; import java.awt.event.ActionEvent; import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JColorChooser; @@ -35,6 +36,7 @@ import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JRadioButton; import javax.swing.JSpinner; import javax.swing.SwingConstants; import javax.swing.border.BevelBorder; @@ -81,6 +83,10 @@ public class NewFileDialog extends AppDialog { private final JLabel warningLabel = new JLabel(); + private final JRadioButton actionScript12RadioButton = new JRadioButton(translate("script.type.actionscript1_2")); + + private final JRadioButton actionScript3RadioButton = new JRadioButton(translate("script.type.actionscript3")); + private JButton backgroundColorButton; private int result = ERROR_OPTION; @@ -175,7 +181,17 @@ public class NewFileDialog extends AppDialog { JPanel backgroundColorPanel = new JPanel(new BorderLayout()); backgroundColorPanel.add(backgroundColorButton, BorderLayout.WEST); - + + actionScript3RadioButton.setSelected(true); + + ButtonGroup actionScriptTypeGroup = new ButtonGroup(); + actionScriptTypeGroup.add(actionScript12RadioButton); + actionScriptTypeGroup.add(actionScript3RadioButton); + + JPanel actionScriptTypePanel = new JPanel(new FlowLayout()); + actionScriptTypePanel.add(actionScript12RadioButton); + actionScriptTypePanel.add(actionScript3RadioButton); + propertiesPanel.add(new JLabel(AppStrings.translate("header.compression")), "0,0"); propertiesPanel.add(compressionEditorPanel, "1,0"); propertiesPanel.add(new JLabel(AppStrings.translate("header.version")), "0,1"); @@ -187,10 +203,12 @@ public class NewFileDialog extends AppDialog { propertiesPanel.add(new JLabel(translate("canvas.size")), "0,4"); propertiesPanel.add(displayRectEditorPanel, "1,4"); propertiesPanel.add(warningPanel, "0,5,1,5"); - propertiesPanel.add(new JLabel(translate("background.color")), "0,6"); - + propertiesPanel.add(new JLabel(translate("background.color")), "0,6"); propertiesPanel.add(backgroundColorPanel, "1,6"); + propertiesPanel.add(new JLabel(translate("script.type")), "0,7"); + propertiesPanel.add(actionScriptTypePanel, "1,7"); + cnt.add(propertiesPanel, BorderLayout.CENTER); @@ -309,4 +327,8 @@ public class NewFileDialog extends AppDialog { public Color getBackgroundColor() { return backgroundColorButton.getBackground(); } + + public boolean isAs3() { + return actionScript3RadioButton.isSelected(); + } } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/NewFileDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/NewFileDialog.properties index 2136a789d..a9f26e8d1 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/NewFileDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/NewFileDialog.properties @@ -23,3 +23,7 @@ unit.pixels = Pixels unit.twips = Twips canvas.size = Canvas size: + +script.type = Script type: +script.type.actionscript1_2 = ActionScript 1/2 +script.type.actionscript3 = ActionScript 3