mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-03 07:45:28 +00:00
#463 Global search in Define*Texts parameters implemented
This commit is contained in:
@@ -1417,15 +1417,14 @@ public final class SWF implements TreeItem {
|
||||
for (final Tag t : tags) {
|
||||
if (t instanceof TextTag) {
|
||||
final File file = new File(outdir + File.separator + ((TextTag) t).getCharacterId() + ".txt");
|
||||
final List<Tag> ttags = this.tags;
|
||||
new RetryTask(new RunnableIOEx() {
|
||||
@Override
|
||||
public void run() throws IOException {
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
if (formatted) {
|
||||
fos.write(Utf8Helper.getBytes(((TextTag) t).getFormattedText(ttags)));
|
||||
fos.write(Utf8Helper.getBytes(((TextTag) t).getFormattedText()));
|
||||
} else {
|
||||
fos.write(Utf8Helper.getBytes(((TextTag) t).getText(ttags)));
|
||||
fos.write(Utf8Helper.getBytes(((TextTag) t).getText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ public class FontPanel extends javax.swing.JPanel {
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) tag;
|
||||
if (textTag.getFontIds(swf.tags).contains(fontId)) {
|
||||
String text = textTag.getFormattedText(textTag.getSwf().tags);
|
||||
if (textTag.getFontIds().contains(fontId)) {
|
||||
String text = textTag.getFormattedText();
|
||||
mainPanel.saveText(textTag, text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +151,7 @@ import java.util.Stack;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.Icon;
|
||||
@@ -187,7 +188,7 @@ import javax.swing.tree.TreeSelectionModel;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public final class MainPanel extends JPanel implements ActionListener, TreeSelectionListener, Freed {
|
||||
public final class MainPanel extends JPanel implements ActionListener, TreeSelectionListener, SearchListener<TextTag>, Freed {
|
||||
|
||||
private final MainFrame mainFrame;
|
||||
private final List<SWF> swfs;
|
||||
@@ -224,6 +225,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
private static final String INTERNAL_VIEWER_CARD = "INTERNALVIEWER";
|
||||
private static final String SPLIT_PANE1 = "SPLITPANE1";
|
||||
private static final String WELCOME_PANEL = "WELCOMEPANEL";
|
||||
private SearchPanel<TextTag> textSearchPanel;
|
||||
private final LineMarkedEditorPane textValue;
|
||||
private final JSplitPane splitPane1;
|
||||
private final JSplitPane splitPane2;
|
||||
@@ -611,13 +613,14 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
add(statusPanel, BorderLayout.SOUTH);
|
||||
|
||||
JPanel textTopPanel = new JPanel(new BorderLayout());
|
||||
textSearchPanel = new SearchPanel<>(new FlowLayout(), this);
|
||||
textTopPanel.add(textSearchPanel, BorderLayout.NORTH);
|
||||
textValue = new LineMarkedEditorPane();
|
||||
textTopPanel.add(new JScrollPane(textValue), BorderLayout.CENTER);
|
||||
textValue.setEditable(false);
|
||||
//textValue.setFont(UIManager.getFont("TextField.font"));
|
||||
|
||||
|
||||
|
||||
JPanel textButtonsPanel = new JPanel();
|
||||
textButtonsPanel.setLayout(new FlowLayout());
|
||||
|
||||
@@ -1487,31 +1490,30 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
boolean found = false;
|
||||
if (swf.isAS3) {
|
||||
if (abcPanel != null && abcPanel.search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) {
|
||||
found = true;
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showDetail(DETAILCARDAS3NAVIGATOR);
|
||||
showCard(CARDACTIONSCRIPT3PANEL);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (actionPanel.search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) {
|
||||
found = true;
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showCard(CARDACTIONSCRIPTPANEL);
|
||||
}
|
||||
});
|
||||
if (searchDialog.searchInASRadioButton.isSelected()) {
|
||||
if (swf.isAS3) {
|
||||
if (abcPanel != null && abcPanel.search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) {
|
||||
found = true;
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showDetail(DETAILCARDAS3NAVIGATOR);
|
||||
showCard(CARDACTIONSCRIPT3PANEL);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (actionPanel.search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) {
|
||||
found = true;
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showCard(CARDACTIONSCRIPTPANEL);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && searchDialog.searchInTextsCheckBox.isSelected()) {
|
||||
} else if (searchDialog.searchInTextsRadioButton.isSelected()) {
|
||||
if (searchText(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected(), swf)) {
|
||||
found = true;
|
||||
}
|
||||
@@ -1529,9 +1531,40 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
|
||||
private boolean searchText(String txt, boolean ignoreCase, boolean regexp, SWF swf) {
|
||||
if ((txt != null) && (!txt.isEmpty())) {
|
||||
textSearchPanel.setOptions(ignoreCase, regexp);
|
||||
List<TextTag> found = new ArrayList<>();
|
||||
Pattern pat = null;
|
||||
if (regexp) {
|
||||
pat = Pattern.compile(txt, ignoreCase ? Pattern.CASE_INSENSITIVE : 0);
|
||||
} else {
|
||||
pat = Pattern.compile(Pattern.quote(txt), ignoreCase ? Pattern.CASE_INSENSITIVE : 0);
|
||||
}
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) tag;
|
||||
if (pat.matcher(textTag.getFormattedText()).find()) {
|
||||
found.add(textTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
textSearchPanel.setSearchText(txt);
|
||||
return textSearchPanel.setResults(found);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSearchPos(TextTag item) {
|
||||
TagTreeModel ttm = (TagTreeModel) tagTree.getModel();
|
||||
TreePath tp = ttm.getTagPath(item);
|
||||
tagTree.setSelectionPath(tp);
|
||||
tagTree.scrollPathToVisible(tp);
|
||||
textValue.setCaretPosition(0);
|
||||
|
||||
textSearchPanel.showQuickFindDialog(textValue);
|
||||
}
|
||||
|
||||
public void autoDeobfuscateChanged() {
|
||||
clearCache();
|
||||
if (abcPanel != null) {
|
||||
@@ -1914,7 +1947,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
return true;
|
||||
|
||||
}
|
||||
}, textTag.getSwf().tags, text)) {
|
||||
}, text)) {
|
||||
return true;
|
||||
}
|
||||
} catch (ParseException ex) {
|
||||
@@ -2293,7 +2326,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
previewSplitPane.setDividerLocation(Configuration.guiPreviewSplitPaneDividerLocation.get(previewSplitPane.getWidth() / 2));
|
||||
showDetailWithPreview(CARDTEXTPANEL);
|
||||
textValue.setContentType("text/swf_text");
|
||||
textValue.setText(textTag.getFormattedText(textTag.getSwf().tags));
|
||||
textValue.setText(textTag.getFormattedText());
|
||||
textValue.setCaretPosition(0);
|
||||
} else if (tagObj instanceof FontTag) {
|
||||
showFontTag((FontTag) tagObj);
|
||||
|
||||
@@ -24,12 +24,14 @@ import java.awt.event.ActionListener;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
/**
|
||||
@@ -44,7 +46,8 @@ public class SearchDialog extends AppDialog implements ActionListener {
|
||||
public JTextField searchField = new MyTextField();
|
||||
public JCheckBox ignoreCaseCheckBox = new JCheckBox(translate("checkbox.ignorecase"));
|
||||
public JCheckBox regexpCheckBox = new JCheckBox(translate("checkbox.regexp"));
|
||||
public JCheckBox searchInTextsCheckBox = new JCheckBox(translate("checkbox.searchText"));
|
||||
public JRadioButton searchInASRadioButton = new JRadioButton(translate("checkbox.searchAS"));
|
||||
public JRadioButton searchInTextsRadioButton = new JRadioButton(translate("checkbox.searchText"));
|
||||
public boolean result = false;
|
||||
|
||||
public SearchDialog() {
|
||||
@@ -70,11 +73,19 @@ public class SearchDialog extends AppDialog implements ActionListener {
|
||||
JPanel checkPanel = new JPanel(new FlowLayout());
|
||||
checkPanel.add(ignoreCaseCheckBox);
|
||||
checkPanel.add(regexpCheckBox);
|
||||
// todo: honfika: add checkbox when text search is implemented
|
||||
//searchInTextsCheckBox.setSelected(true);
|
||||
//checkPanel.add(searchInTextsCheckBox);
|
||||
cnt.add(checkPanel);
|
||||
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(searchInASRadioButton);
|
||||
group.add(searchInTextsRadioButton);
|
||||
|
||||
JPanel rbPanel = new JPanel(new FlowLayout());
|
||||
searchInASRadioButton.setSelected(true);
|
||||
searchInTextsRadioButton.setSelected(false);
|
||||
rbPanel.add(searchInASRadioButton);
|
||||
rbPanel.add(searchInTextsRadioButton);
|
||||
cnt.add(rbPanel);
|
||||
|
||||
cnt.add(panButtons);
|
||||
getRootPane().setDefaultButton(okButton);
|
||||
View.centerScreen(this);
|
||||
|
||||
@@ -23,3 +23,4 @@ error = Error
|
||||
error.invalidregexp = Invalid pattern
|
||||
|
||||
checkbox.searchText = Search in texts
|
||||
checkbox.searchAS = Search in AS
|
||||
|
||||
@@ -23,3 +23,4 @@ error = Hiba
|
||||
error.invalidregexp = \u00c9rv\u00e9nytelen minta
|
||||
|
||||
checkbox.searchText = Keres\u00e9s a sz\u00f6vegek k\u00f6z\u00f6tt
|
||||
checkbox.searchAS = Keres\u00e9s az ActionScriptekben
|
||||
|
||||
@@ -128,7 +128,7 @@ public class DefineEditTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(List<Tag> tags) {
|
||||
public String getText() {
|
||||
String ret = "";
|
||||
if (hasText) {
|
||||
ret = initialText;
|
||||
@@ -141,14 +141,14 @@ public class DefineEditTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getFontIds(List<Tag> tags) {
|
||||
public List<Integer> getFontIds() {
|
||||
List<Integer> ret = new ArrayList<>();
|
||||
ret.add(fontId);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormattedText(List<Tag> tags) {
|
||||
public String getFormattedText() {
|
||||
String ret = "";
|
||||
ret += "[";
|
||||
String[] alignValues = {"left", "right", "center", "justify"};
|
||||
@@ -171,7 +171,7 @@ public class DefineEditTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFormattedText(MissingCharacterHandler missingCharHandler, List<Tag> tags, String text) throws ParseException {
|
||||
public boolean setFormattedText(MissingCharacterHandler missingCharHandler, String text) throws ParseException {
|
||||
try {
|
||||
TextLexer lexer = new TextLexer(new StringReader(text));
|
||||
ParsedSymbol s = null;
|
||||
|
||||
@@ -78,12 +78,12 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(List<Tag> tags) {
|
||||
public String getText() {
|
||||
FontTag fnt = null;
|
||||
String ret = "";
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
if (rec.styleFlagsHasFont) {
|
||||
for (Tag t : tags) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FontTag) {
|
||||
if (((FontTag) t).getFontId() == rec.fontId) {
|
||||
fnt = ((FontTag) t);
|
||||
@@ -97,13 +97,13 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
|
||||
ret += "\r\n";
|
||||
}
|
||||
}
|
||||
ret += rec.getText(tags, fnt);
|
||||
ret += rec.getText(swf.tags, fnt);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getFontIds(List<Tag> tags) {
|
||||
public List<Integer> getFontIds() {
|
||||
List<Integer> ret = new ArrayList<>();
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
if (rec.styleFlagsHasFont) {
|
||||
@@ -114,7 +114,7 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormattedText(List<Tag> tags) {
|
||||
public String getFormattedText() {
|
||||
FontTag fnt = null;
|
||||
String ret = "";
|
||||
ret += "[\r\nxmin " + textBounds.Xmin + "\r\nymin " + textBounds.Ymin + "\r\nxmax " + textBounds.Xmax + "\r\nymax " + textBounds.Ymax;
|
||||
@@ -136,7 +136,7 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
String params = "";
|
||||
if (rec.styleFlagsHasFont) {
|
||||
for (Tag t : tags) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FontTag) {
|
||||
if (((FontTag) t).getFontId() == rec.fontId) {
|
||||
fnt = ((FontTag) t);
|
||||
@@ -158,13 +158,13 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
|
||||
if (params.length() > 0) {
|
||||
ret += "[" + params + "\r\n]";
|
||||
}
|
||||
ret += Helper.escapeString(rec.getText(tags, fnt)).replace("[", "\\[").replace("]", "\\]");
|
||||
ret += Helper.escapeString(rec.getText(swf.tags, fnt)).replace("[", "\\[").replace("]", "\\]");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFormattedText(MissingCharacterHandler missingCharHandler, List<Tag> tags, String text) throws ParseException {
|
||||
public boolean setFormattedText(MissingCharacterHandler missingCharHandler, String text) throws ParseException {
|
||||
List<TEXTRECORD> oldTextRecords = textRecords;
|
||||
try {
|
||||
TextLexer lexer = new TextLexer(new StringReader(text));
|
||||
@@ -203,7 +203,7 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
|
||||
try {
|
||||
fontId = Integer.parseInt(paramValue);
|
||||
|
||||
for (Tag t : tags) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FontTag) {
|
||||
if (((FontTag) t).getFontId() == fontId) {
|
||||
font = (FontTag) t;
|
||||
@@ -347,6 +347,7 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
|
||||
}
|
||||
String txt = (String) s.values[0];
|
||||
tr.glyphEntries = new GLYPHENTRY[txt.length()];
|
||||
List<Tag> tags = swf.tags;
|
||||
for (int i = 0; i < txt.length(); i++) {
|
||||
char c = txt.charAt(i);
|
||||
Character nextChar = null;
|
||||
|
||||
@@ -79,12 +79,12 @@ public class DefineTextTag extends TextTag implements DrawableTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(List<Tag> tags) {
|
||||
public String getText() {
|
||||
FontTag fnt = null;
|
||||
String ret = "";
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
if (rec.styleFlagsHasFont) {
|
||||
for (Tag t : tags) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FontTag) {
|
||||
if (((FontTag) t).getFontId() == rec.fontId) {
|
||||
fnt = ((FontTag) t);
|
||||
@@ -98,13 +98,13 @@ public class DefineTextTag extends TextTag implements DrawableTag {
|
||||
ret += "\r\n";
|
||||
}
|
||||
}
|
||||
ret += rec.getText(tags, fnt);
|
||||
ret += rec.getText(swf.tags, fnt);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getFontIds(List<Tag> tags) {
|
||||
public List<Integer> getFontIds() {
|
||||
List<Integer> ret = new ArrayList<>();
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
if (rec.styleFlagsHasFont) {
|
||||
@@ -115,7 +115,7 @@ public class DefineTextTag extends TextTag implements DrawableTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormattedText(List<Tag> tags) {
|
||||
public String getFormattedText() {
|
||||
FontTag fnt = null;
|
||||
String ret = "";
|
||||
ret += "[\r\nxmin " + textBounds.Xmin + "\r\nymin " + textBounds.Ymin + "\r\nxmax " + textBounds.Xmax + "\r\nymax " + textBounds.Ymax;
|
||||
@@ -137,7 +137,7 @@ public class DefineTextTag extends TextTag implements DrawableTag {
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
String params = "";
|
||||
if (rec.styleFlagsHasFont) {
|
||||
for (Tag t : tags) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FontTag) {
|
||||
if (((FontTag) t).getFontId() == rec.fontId) {
|
||||
fnt = ((FontTag) t);
|
||||
@@ -163,14 +163,14 @@ public class DefineTextTag extends TextTag implements DrawableTag {
|
||||
if (fnt == null) {
|
||||
ret += AppStrings.translate("fontNotFound").replace("%fontId%", Integer.toString(rec.fontId));
|
||||
} else {
|
||||
ret += Helper.escapeString(rec.getText(tags, fnt)).replace("[", "\\[").replace("]", "\\]");
|
||||
ret += Helper.escapeString(rec.getText(swf.tags, fnt)).replace("[", "\\[").replace("]", "\\]");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFormattedText(MissingCharacterHandler missingCharHandler, List<Tag> tags, String text) throws ParseException {
|
||||
public boolean setFormattedText(MissingCharacterHandler missingCharHandler, String text) throws ParseException {
|
||||
List<TEXTRECORD> oldTextRecords = textRecords;
|
||||
try {
|
||||
TextLexer lexer = new TextLexer(new StringReader(text));
|
||||
@@ -209,7 +209,7 @@ public class DefineTextTag extends TextTag implements DrawableTag {
|
||||
try {
|
||||
fontId = Integer.parseInt(paramValue);
|
||||
|
||||
for (Tag t : tags) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FontTag) {
|
||||
if (((FontTag) t).getFontId() == fontId) {
|
||||
font = (FontTag) t;
|
||||
@@ -353,6 +353,7 @@ public class DefineTextTag extends TextTag implements DrawableTag {
|
||||
}
|
||||
String txt = (String) s.values[0];
|
||||
tr.glyphEntries = new GLYPHENTRY[txt.length()];
|
||||
List<Tag> tags = swf.tags;
|
||||
for (int i = 0; i < txt.length(); i++) {
|
||||
char c = txt.charAt(i);
|
||||
Character nextChar = null;
|
||||
|
||||
@@ -50,13 +50,13 @@ public abstract class TextTag extends CharacterTag implements BoundedTag {
|
||||
|
||||
public abstract MATRIX getTextMatrix();
|
||||
|
||||
public abstract String getText(List<Tag> tags);
|
||||
public abstract String getText();
|
||||
|
||||
public abstract List<Integer> getFontIds(List<Tag> tags);
|
||||
public abstract List<Integer> getFontIds();
|
||||
|
||||
public abstract String getFormattedText(List<Tag> tags);
|
||||
public abstract String getFormattedText();
|
||||
|
||||
public abstract boolean setFormattedText(MissingCharacterHandler missingCharHandler, List<Tag> tags, String text) throws ParseException;
|
||||
public abstract boolean setFormattedText(MissingCharacterHandler missingCharHandler, String text) throws ParseException;
|
||||
|
||||
@Override
|
||||
public abstract int getCharacterId();
|
||||
|
||||
Reference in New Issue
Block a user