mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 09:20:47 +00:00
better text editing
top labels for flash preview and parameters edit
This commit is contained in:
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.abc.gui.ABCPanel;
|
||||
import com.jpexs.decompiler.flash.abc.gui.ClassesListTreeModel;
|
||||
import com.jpexs.decompiler.flash.abc.gui.DeobfuscationDialog;
|
||||
import com.jpexs.decompiler.flash.abc.gui.LineMarkedEditorPane;
|
||||
import com.jpexs.decompiler.flash.abc.gui.TreeElement;
|
||||
import com.jpexs.decompiler.flash.abc.gui.TreeLeafScript;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
@@ -86,6 +87,7 @@ import java.awt.CardLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -109,6 +111,8 @@ import javax.swing.BoxLayout;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
@@ -122,11 +126,13 @@ import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
@@ -164,7 +170,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
final static String DETAILCARDAS3NAVIGATOR = "Traits list";
|
||||
final static String DETAILCARDEMPTYPANEL = "Empty card";
|
||||
final static String CARDTEXTPANEL = "Text card";
|
||||
private JTextField textValue = new JTextField("");
|
||||
private LineMarkedEditorPane textValue;
|
||||
private JPEGTablesTag jtt;
|
||||
private HashMap<Integer, CharacterTag> characters;
|
||||
private List<ABCContainerTag> abcList;
|
||||
@@ -178,6 +184,8 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
private JButton textSaveButton;
|
||||
private JButton textEditButton;
|
||||
private JButton textCancelButton;
|
||||
private JPanel parametersPanel;
|
||||
private JSplitPane previewSplitPane;
|
||||
|
||||
public void setPercent(int percent) {
|
||||
progressBar.setValue(percent);
|
||||
@@ -490,9 +498,10 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
list2.addAll(swf.tags);
|
||||
parseCharacters(list2);
|
||||
JPanel textTopPanel = new JPanel(new BorderLayout());
|
||||
textTopPanel.add(textValue, BorderLayout.CENTER);
|
||||
textValue.setEditable(false);
|
||||
|
||||
textValue = new LineMarkedEditorPane();
|
||||
textTopPanel.add(new JScrollPane(textValue), BorderLayout.CENTER);
|
||||
textValue.setEditable(false);
|
||||
//textValue.setFont(UIManager.getFont("TextField.font"));
|
||||
|
||||
/*JPanel textBottomPanel = new JPanel();
|
||||
textBottomPanel.setLayout(new BoxLayout(textBottomPanel, BoxLayout.X_AXIS));
|
||||
@@ -508,7 +517,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
|
||||
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
|
||||
buttonsPanel.setLayout(new FlowLayout());
|
||||
|
||||
|
||||
textSaveButton = new JButton("Save", View.getIcon("save16"));
|
||||
@@ -533,7 +542,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
textSaveButton.setVisible(false);
|
||||
textCancelButton.setVisible(false);
|
||||
|
||||
textTopPanel.add(buttonsPanel, BorderLayout.EAST);
|
||||
textTopPanel.add(buttonsPanel, BorderLayout.SOUTH);
|
||||
|
||||
displayWithPreview = new JPanel(new CardLayout());
|
||||
|
||||
@@ -544,25 +553,50 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
//textPanel.add(textBottomPanel);
|
||||
|
||||
displayWithPreview.add(textPanel, CARDTEXTPANEL);
|
||||
displayWithPreview.setVisible(false);
|
||||
//displayWithPreview.setVisible(false);
|
||||
|
||||
|
||||
JPanel panWithPreview = new JPanel(new BorderLayout());
|
||||
panWithPreview.add(displayWithPreview, BorderLayout.SOUTH);
|
||||
|
||||
|
||||
Component leftComponent = null;
|
||||
|
||||
try {
|
||||
flashPanel = new FlashPlayerPanel(this);
|
||||
} catch (FlashUnsupportedException fue) {
|
||||
}
|
||||
displayPanel = new JPanel(new CardLayout());
|
||||
displayPanel.add(panWithPreview, CARDFLASHPANEL);
|
||||
|
||||
if (flashPanel != null) {
|
||||
panWithPreview.add(flashPanel, BorderLayout.CENTER);
|
||||
leftComponent=flashPanel;
|
||||
} else {
|
||||
JPanel swtPanel = new JPanel(new BorderLayout());
|
||||
swtPanel.add(new JLabel("<html><center>Preview of this object is not available on this platform. (Windows only)</center></html>", JLabel.CENTER), BorderLayout.CENTER);
|
||||
swtPanel.setBackground(Color.white);
|
||||
panWithPreview.add(swtPanel, BorderLayout.CENTER);
|
||||
leftComponent = swtPanel;
|
||||
}
|
||||
|
||||
textValue.setContentType("text/swf_text");
|
||||
|
||||
previewSplitPane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||||
previewSplitPane.setDividerLocation(300);
|
||||
JPanel pan=new JPanel(new BorderLayout());
|
||||
JLabel prevLabel=new JLabel("SWF preview");
|
||||
prevLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
prevLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
|
||||
|
||||
JLabel paramsLabel=new JLabel("Parameters");
|
||||
paramsLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
paramsLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
|
||||
pan.add(prevLabel,BorderLayout.NORTH);
|
||||
pan.add(leftComponent,BorderLayout.CENTER);
|
||||
previewSplitPane.setLeftComponent(pan);
|
||||
|
||||
parametersPanel=new JPanel(new BorderLayout());
|
||||
parametersPanel.add(paramsLabel,BorderLayout.NORTH);
|
||||
parametersPanel.add(displayWithPreview,BorderLayout.CENTER);
|
||||
previewSplitPane.setRightComponent(parametersPanel);
|
||||
parametersPanel.setVisible(false);
|
||||
displayPanel.add(previewSplitPane, CARDFLASHPANEL);
|
||||
imagePanel = new ImagePanel();
|
||||
displayPanel.add(imagePanel, CARDIMAGEPANEL);
|
||||
displayPanel.add(new JPanel(), CARDEMPTYPANEL);
|
||||
@@ -1799,11 +1833,12 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
}
|
||||
|
||||
if (tagObj instanceof TextTag) {
|
||||
displayWithPreview.setVisible(true);
|
||||
parametersPanel.setVisible(true);
|
||||
previewSplitPane.setDividerLocation(previewSplitPane.getWidth()/2);
|
||||
showDetailWithPreview(CARDTEXTPANEL);
|
||||
textValue.setText(((TextTag) tagObj).getFormattedText(swf.tags));
|
||||
} else {
|
||||
displayWithPreview.setVisible(false);
|
||||
parametersPanel.setVisible(false);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -130,18 +130,18 @@ public class DefineEditTextTag extends CharacterTag implements BoundedTag, TextT
|
||||
String ret = "";
|
||||
ret += "[";
|
||||
String[] alignValues = {"left", "right", "center", "justify"};
|
||||
ret += "xmin " + bounds.Xmin + " ymin " + bounds.Ymin + " xmax " + bounds.Xmax + " ymax " + bounds.Ymax + " ";
|
||||
ret += (wordWrap ? "wordwrap 1 " : "") + (multiline ? "multiline 1 " : "")
|
||||
+ (password ? "password 1 " : "") + (readOnly ? "readonly 1 " : "")
|
||||
+ (autoSize ? "autosize 1 " : "") + (noSelect ? "noselect 1 " : "")
|
||||
+ (border ? "border 1 " : "") + (wasStatic ? "wasstatic 1 " : "")
|
||||
+ (html ? "html 1 " : "") + (useOutlines ? "useoutlines 1 " : "")
|
||||
+ (hasFont ? "font " + fontId + " " : "") + (hasTextColor ? "color " + textColor.toHexARGB() + " " : "")
|
||||
+ (hasFontClass ? "fontclass " + fontClass + " " : "") + (hasMaxLength ? "maxlength " + maxLength + " " : "")
|
||||
+ "align " + alignValues[align] + " "
|
||||
+ (hasLayout ? "leftmargin " + leftMargin + " rightmargin " + rightMargin + " indent " + indent + " leading " + leading + " " : "")
|
||||
+ (!variableName.equals("") ? "variablename " + variableName + " " : "");
|
||||
ret = ret.trim() + "]";
|
||||
ret += "\r\nxmin " + bounds.Xmin + "\r\nymin " + bounds.Ymin + "\r\nxmax " + bounds.Xmax + "\r\nymax " + bounds.Ymax + "\r\n";
|
||||
ret += (wordWrap ? "wordwrap 1\r\n" : "") + (multiline ? "multiline 1\r\n" : "")
|
||||
+ (password ? "password 1\r\n" : "") + (readOnly ? "readonly 1\r\n" : "")
|
||||
+ (autoSize ? "autosize 1\r\n" : "") + (noSelect ? "noselect 1\r\n" : "")
|
||||
+ (border ? "border 1\r\n" : "") + (wasStatic ? "wasstatic 1\r\n" : "")
|
||||
+ (html ? "html 1\r\n" : "") + (useOutlines ? "useoutlines 1\r\n" : "")
|
||||
+ (hasFont ? "font " + fontId + "\r\n" : "") + (hasTextColor ? "color " + textColor.toHexARGB() + "\r\n" : "")
|
||||
+ (hasFontClass ? "fontclass " + fontClass + "\r\n" : "") + (hasMaxLength ? "maxlength " + maxLength + "\r\n" : "")
|
||||
+ "align " + alignValues[align] + "\r\n"
|
||||
+ (hasLayout ? "leftmargin " + leftMargin + "\r\nrightmargin " + rightMargin + "\r\nindent " + indent + "\r\nleading " + leading + "\r\n" : "")
|
||||
+ (!variableName.equals("") ? "variablename " + variableName + "\r\n" : "");
|
||||
ret = ret + "]";
|
||||
if (hasText) {
|
||||
ret += initialText.replace("\\", "\\\\").replace("[", "\\[").replace("]", "\\]");
|
||||
}
|
||||
|
||||
@@ -96,22 +96,22 @@ public class DefineText2Tag extends CharacterTag implements BoundedTag, TextTag
|
||||
public String getFormattedText(List<Tag> tags) {
|
||||
FontTag fnt = null;
|
||||
String ret = "";
|
||||
ret += "[xmin " + textBounds.Xmin + " ymin " + textBounds.Ymin + " xmax " + textBounds.Xmax + " ymax " + textBounds.Ymax;
|
||||
ret += "[\r\nxmin " + textBounds.Xmin + "\r\nymin " + textBounds.Ymin + "\r\nxmax " + textBounds.Xmax + "\r\nymax " + textBounds.Ymax;
|
||||
if (textMatrix.translateX != 0) {
|
||||
ret += " translatex " + textMatrix.translateX;
|
||||
ret += "\r\ntranslatex " + textMatrix.translateX;
|
||||
}
|
||||
if (textMatrix.translateY != 0) {
|
||||
ret += " translatey " + textMatrix.translateY;
|
||||
ret += "\r\ntranslatey " + textMatrix.translateY;
|
||||
}
|
||||
if (textMatrix.hasScale) {
|
||||
ret += " scalex " + textMatrix.scaleX;
|
||||
ret += " scaley " + textMatrix.scaleY;
|
||||
ret += "\r\nscalex " + textMatrix.scaleX;
|
||||
ret += "\r\nscaley " + textMatrix.scaleY;
|
||||
}
|
||||
if (textMatrix.hasRotate) {
|
||||
ret += " rotateskew0 " + textMatrix.rotateSkew0;
|
||||
ret += " rotateskew1 " + textMatrix.rotateSkew1;
|
||||
ret += "\r\nrotateskew0 " + textMatrix.rotateSkew0;
|
||||
ret += "\r\nrotateskew1 " + textMatrix.rotateSkew1;
|
||||
}
|
||||
ret += "]";
|
||||
ret += "\r\n]";
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
String params = "";
|
||||
if (rec.styleFlagsHasFont) {
|
||||
@@ -123,19 +123,19 @@ public class DefineText2Tag extends CharacterTag implements BoundedTag, TextTag
|
||||
}
|
||||
}
|
||||
}
|
||||
params += " font " + rec.fontId + " height " + rec.textHeight;
|
||||
params += "\r\nfont " + rec.fontId + "\r\nheight " + rec.textHeight;
|
||||
}
|
||||
if (rec.styleFlagsHasColor) {
|
||||
params += " color " + rec.textColorA.toHexARGB();
|
||||
params += "\r\ncolor " + rec.textColorA.toHexARGB();
|
||||
}
|
||||
if (rec.styleFlagsHasXOffset) {
|
||||
params += " x " + rec.xOffset;
|
||||
params += "\r\nx " + rec.xOffset;
|
||||
}
|
||||
if (rec.styleFlagsHasYOffset) {
|
||||
params += " y " + rec.yOffset;
|
||||
params += "\r\ny " + rec.yOffset;
|
||||
}
|
||||
if (params.length() > 0) {
|
||||
ret += "[" + params.trim() + "]";
|
||||
ret += "[" + params + "\r\n]";
|
||||
}
|
||||
ret += Helper.escapeString(rec.getText(tags, fnt)).replace("[", "\\[").replace("]", "\\]");
|
||||
}
|
||||
|
||||
@@ -96,22 +96,22 @@ public class DefineTextTag extends CharacterTag implements BoundedTag, TextTag {
|
||||
public String getFormattedText(List<Tag> tags) {
|
||||
FontTag fnt = null;
|
||||
String ret = "";
|
||||
ret += "[xmin " + textBounds.Xmin + " ymin " + textBounds.Ymin + " xmax " + textBounds.Xmax + " ymax " + textBounds.Ymax;
|
||||
ret += "[\r\nxmin " + textBounds.Xmin + "\r\nymin " + textBounds.Ymin + "\r\nxmax " + textBounds.Xmax + "\r\nymax " + textBounds.Ymax;
|
||||
if (textMatrix.translateX != 0) {
|
||||
ret += " translatex " + textMatrix.translateX;
|
||||
ret += "\r\ntranslatex " + textMatrix.translateX;
|
||||
}
|
||||
if (textMatrix.translateY != 0) {
|
||||
ret += " translatey " + textMatrix.translateY;
|
||||
ret += "\r\ntranslatey " + textMatrix.translateY;
|
||||
}
|
||||
if (textMatrix.hasScale) {
|
||||
ret += " scalex " + textMatrix.scaleX;
|
||||
ret += " scaley " + textMatrix.scaleY;
|
||||
ret += "\r\nscalex " + textMatrix.scaleX;
|
||||
ret += "\r\nscaley " + textMatrix.scaleY;
|
||||
}
|
||||
if (textMatrix.hasRotate) {
|
||||
ret += " rotateskew0 " + textMatrix.rotateSkew0;
|
||||
ret += " rotateskew1 " + textMatrix.rotateSkew1;
|
||||
ret += "\r\nrotateskew0 " + textMatrix.rotateSkew0;
|
||||
ret += "\r\nrotateskew1 " + textMatrix.rotateSkew1;
|
||||
}
|
||||
ret += "]";
|
||||
ret += "\r\n]";
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
String params = "";
|
||||
if (rec.styleFlagsHasFont) {
|
||||
@@ -123,19 +123,19 @@ public class DefineTextTag extends CharacterTag implements BoundedTag, TextTag {
|
||||
}
|
||||
}
|
||||
}
|
||||
params += " font " + rec.fontId + " height " + rec.textHeight;
|
||||
params += "\r\nfont " + rec.fontId + "\r\nheight " + rec.textHeight;
|
||||
}
|
||||
if (rec.styleFlagsHasColor) {
|
||||
params += " color " + rec.textColor.toHexRGB();
|
||||
params += "\r\ncolor " + rec.textColor.toHexRGB();
|
||||
}
|
||||
if (rec.styleFlagsHasXOffset) {
|
||||
params += " x " + rec.xOffset;
|
||||
params += "\r\nx " + rec.xOffset;
|
||||
}
|
||||
if (rec.styleFlagsHasYOffset) {
|
||||
params += " y " + rec.yOffset;
|
||||
params += "\r\ny " + rec.yOffset;
|
||||
}
|
||||
if (params.length() > 0) {
|
||||
ret += "[" + params.trim() + "]";
|
||||
ret += "[" + params + "\r\n]";
|
||||
}
|
||||
ret += Helper.escapeString(rec.getText(tags, fnt)).replace("[", "\\[").replace("]", "\\]");
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -55,7 +55,8 @@ package com.jpexs.decompiler.flash.tags.text;
|
||||
%}
|
||||
|
||||
Parameter = [a-z0-9_]+
|
||||
Value = [^ \]]+
|
||||
Value = [^ \r\n\]]+
|
||||
Divider = [ \r\n]+
|
||||
|
||||
%state PARAMETER,VALUE
|
||||
|
||||
@@ -89,7 +90,7 @@ Value = [^ \]]+
|
||||
}
|
||||
|
||||
<PARAMETER> {
|
||||
" " {}
|
||||
{Divider} {}
|
||||
{Parameter} {
|
||||
parameterName = yytext();
|
||||
yybegin(VALUE);
|
||||
@@ -100,7 +101,7 @@ Value = [^ \]]+
|
||||
}
|
||||
|
||||
<VALUE> {
|
||||
" " {}
|
||||
{Divider} {}
|
||||
{Value} {
|
||||
yybegin(PARAMETER);
|
||||
return new ParsedSymbol(SymbolType.PARAMETER,new Object[]{parameterName,yytext()});
|
||||
|
||||
Reference in New Issue
Block a user