mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 01:51:19 +00:00
allow to save data range in dumpview to file (e.g. for exporting ABC data)
This commit is contained in:
@@ -152,11 +152,11 @@ public class ActionListReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove nulls
|
// remove nulls
|
||||||
index = getNextAddress(addresses, index);
|
index = getNearAddress(addresses, index, true);
|
||||||
while (index > -1) {
|
while (index > -1) {
|
||||||
Action action = actionMap.get(index);
|
Action action = actionMap.get(index);
|
||||||
long nextOffset = nextOffsets.get(index);
|
long nextOffset = nextOffsets.get(index);
|
||||||
long nextIndex = getNextAddress(addresses, index + 1);
|
long nextIndex = getNearAddress(addresses, index + 1, true);
|
||||||
actions.add(action);
|
actions.add(action);
|
||||||
if (nextIndex != -1 && nextOffset != nextIndex) {
|
if (nextIndex != -1 && nextOffset != nextIndex) {
|
||||||
if (!action.isExit() && !(action instanceof ActionJump)) {
|
if (!action.isExit() && !(action instanceof ActionJump)) {
|
||||||
@@ -280,7 +280,7 @@ public class ActionListReader {
|
|||||||
return reta;
|
return reta;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long getNextAddress(List<Long> addresses, long address) {
|
private static long getNearAddress(List<Long> addresses, long address, boolean next) {
|
||||||
int min = 0;
|
int min = 0;
|
||||||
int max = addresses.size() - 1;
|
int max = addresses.size() - 1;
|
||||||
|
|
||||||
@@ -295,25 +295,9 @@ public class ActionListReader {
|
|||||||
max = mid - 1;
|
max = mid - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return min < addresses.size() ? addresses.get(min) : -1;
|
return next
|
||||||
}
|
? (min < addresses.size() ? addresses.get(min) : -1)
|
||||||
|
: (max > 0 ? addresses.get(max) : -1);
|
||||||
private static long getPrevAddress(List<Long> addresses, long address) {
|
|
||||||
int min = 0;
|
|
||||||
int max = addresses.size() - 1;
|
|
||||||
|
|
||||||
while (max >= min) {
|
|
||||||
int mid = (min + max) / 2;
|
|
||||||
long midValue = addresses.get(mid);
|
|
||||||
if(midValue == address)
|
|
||||||
return address;
|
|
||||||
else if (midValue < address)
|
|
||||||
min = mid + 1;
|
|
||||||
else
|
|
||||||
max = mid - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return max > 0 ? addresses.get(max) : -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Long, Action> actionListToMap(List<Action> actions) {
|
private static Map<Long, Action> actionListToMap(List<Action> actions) {
|
||||||
@@ -371,7 +355,7 @@ public class ActionListReader {
|
|||||||
List<Action> lasts = new ArrayList<>(sizes.size());
|
List<Action> lasts = new ArrayList<>(sizes.size());
|
||||||
for (long size : sizes) {
|
for (long size : sizes) {
|
||||||
endAddress += size;
|
endAddress += size;
|
||||||
long lastActionIndex = getPrevAddress(addresses, endAddress - 1);
|
long lastActionIndex = getNearAddress(addresses, endAddress - 1, false);
|
||||||
Action lastAction = null;
|
Action lastAction = null;
|
||||||
if (lastActionIndex != -1) {
|
if (lastActionIndex != -1) {
|
||||||
lastAction = actionMap.get(lastActionIndex);
|
lastAction = actionMap.get(lastActionIndex);
|
||||||
|
|||||||
@@ -75,6 +75,20 @@ public class DumpInfo {
|
|||||||
return childInfos;
|
return childInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getEndByte() {
|
||||||
|
int end = (int) startByte;
|
||||||
|
if (lengthBytes != 0) {
|
||||||
|
end += lengthBytes;
|
||||||
|
} else {
|
||||||
|
int bits = startBit + lengthBits;
|
||||||
|
end += bits / 8;
|
||||||
|
if (bits % 8 != 0) {
|
||||||
|
end++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return end - 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String value = previewValue == null ? "" : previewValue.toString();
|
String value = previewValue == null ? "" : previewValue.toString();
|
||||||
|
|||||||
@@ -1,291 +1,290 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2010-2014 JPEXS
|
* Copyright (C) 2010-2014 JPEXS
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.jpexs.decompiler.flash.gui;
|
package com.jpexs.decompiler.flash.gui;
|
||||||
|
|
||||||
import com.jpexs.browsers.cache.CacheEntry;
|
import com.jpexs.browsers.cache.CacheEntry;
|
||||||
import com.jpexs.browsers.cache.CacheImplementation;
|
import com.jpexs.browsers.cache.CacheImplementation;
|
||||||
import com.jpexs.browsers.cache.CacheReader;
|
import com.jpexs.browsers.cache.CacheReader;
|
||||||
import com.jpexs.decompiler.flash.AppStrings;
|
import com.jpexs.decompiler.flash.AppStrings;
|
||||||
import com.jpexs.decompiler.flash.SWFSourceInfo;
|
import com.jpexs.decompiler.flash.SWFSourceInfo;
|
||||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||||
import com.jpexs.helpers.Helper;
|
import com.jpexs.helpers.Helper;
|
||||||
import com.jpexs.helpers.ReReadableInputStream;
|
import com.jpexs.helpers.ReReadableInputStream;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author JPEXS
|
* @author JPEXS
|
||||||
*/
|
*/
|
||||||
public class LoadFromCacheFrame extends AppFrame implements ActionListener {
|
public class LoadFromCacheFrame extends AppFrame implements ActionListener {
|
||||||
|
|
||||||
static final String ACTION_OPEN = "OPEN";
|
static final String ACTION_OPEN = "OPEN";
|
||||||
static final String ACTION_SAVE = "SAVE";
|
static final String ACTION_SAVE = "SAVE";
|
||||||
static final String ACTION_REFRESH = "REFRESH";
|
static final String ACTION_REFRESH = "REFRESH";
|
||||||
|
|
||||||
private final JList<CacheEntry> list;
|
private final JList<CacheEntry> list;
|
||||||
private final JTextField searchField;
|
private final JTextField searchField;
|
||||||
private List<CacheImplementation> caches;
|
private List<CacheImplementation> caches;
|
||||||
private List<CacheEntry> entries;
|
private List<CacheEntry> entries;
|
||||||
private final JProgressBar progressBar;
|
private final JProgressBar progressBar;
|
||||||
JButton saveButton;
|
JButton saveButton;
|
||||||
JButton refreshButton;
|
JButton refreshButton;
|
||||||
JButton openButton;
|
JButton openButton;
|
||||||
|
|
||||||
public LoadFromCacheFrame() {
|
public LoadFromCacheFrame() {
|
||||||
setSize(900, 600);
|
setSize(900, 600);
|
||||||
View.setWindowIcon(this);
|
View.setWindowIcon(this);
|
||||||
View.centerScreen(this);
|
View.centerScreen(this);
|
||||||
setTitle(translate("dialog.title"));
|
setTitle(translate("dialog.title"));
|
||||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||||
Container cnt = getContentPane();
|
Container cnt = getContentPane();
|
||||||
list = new JList<>();
|
list = new JList<>();
|
||||||
list.addMouseListener(new MouseAdapter() {
|
list.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (e.getClickCount() > 1) {
|
if (e.getClickCount() > 1) {
|
||||||
openSWF();
|
openSWF();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
searchField = new JTextField();
|
searchField = new JTextField();
|
||||||
searchField.addKeyListener(new KeyListener() {
|
searchField.addKeyListener(new KeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent e) {
|
public void keyTyped(KeyEvent e) {
|
||||||
filter();
|
filter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cnt.setLayout(new BorderLayout());
|
cnt.setLayout(new BorderLayout());
|
||||||
cnt.add(searchField, BorderLayout.NORTH);
|
cnt.add(searchField, BorderLayout.NORTH);
|
||||||
cnt.add(new JScrollPane(list), BorderLayout.CENTER);
|
cnt.add(new JScrollPane(list), BorderLayout.CENTER);
|
||||||
|
|
||||||
JPanel bottomPanel = new JPanel();
|
JPanel bottomPanel = new JPanel();
|
||||||
bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
|
bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||||
|
|
||||||
openButton = new JButton(translate("button.open"));
|
openButton = new JButton(translate("button.open"));
|
||||||
openButton.setActionCommand(ACTION_OPEN);
|
openButton.setActionCommand(ACTION_OPEN);
|
||||||
openButton.addActionListener(this);
|
openButton.addActionListener(this);
|
||||||
buttonsPanel.add(openButton);
|
buttonsPanel.add(openButton);
|
||||||
|
|
||||||
saveButton = new JButton(translate("button.save"));
|
saveButton = new JButton(translate("button.save"));
|
||||||
saveButton.setActionCommand(ACTION_SAVE);
|
saveButton.setActionCommand(ACTION_SAVE);
|
||||||
saveButton.addActionListener(this);
|
saveButton.addActionListener(this);
|
||||||
buttonsPanel.add(saveButton);
|
buttonsPanel.add(saveButton);
|
||||||
|
|
||||||
refreshButton = new JButton(translate("button.refresh"));
|
refreshButton = new JButton(translate("button.refresh"));
|
||||||
refreshButton.setActionCommand(ACTION_REFRESH);
|
refreshButton.setActionCommand(ACTION_REFRESH);
|
||||||
refreshButton.addActionListener(this);
|
refreshButton.addActionListener(this);
|
||||||
buttonsPanel.add(refreshButton);
|
buttonsPanel.add(refreshButton);
|
||||||
|
|
||||||
JPanel browsersPanel = new JPanel(new FlowLayout());
|
JPanel browsersPanel = new JPanel(new FlowLayout());
|
||||||
browsersPanel.add(new JLabel(translate("supported.browsers")));
|
browsersPanel.add(new JLabel(translate("supported.browsers")));
|
||||||
JLabel chromeLabel = new JLabel("Google Chrome", View.getIcon("chrome16"), JLabel.CENTER);
|
JLabel chromeLabel = new JLabel("Google Chrome", View.getIcon("chrome16"), JLabel.CENTER);
|
||||||
JLabel firefoxLabel = new JLabel("Mozilla Firefox*", View.getIcon("firefox16"), JLabel.CENTER);
|
JLabel firefoxLabel = new JLabel("Mozilla Firefox*", View.getIcon("firefox16"), JLabel.CENTER);
|
||||||
browsersPanel.add(chromeLabel);
|
browsersPanel.add(chromeLabel);
|
||||||
browsersPanel.add(firefoxLabel);
|
browsersPanel.add(firefoxLabel);
|
||||||
buttonsPanel.setAlignmentX(0.5f);
|
buttonsPanel.setAlignmentX(0.5f);
|
||||||
|
|
||||||
progressBar = new JProgressBar();
|
progressBar = new JProgressBar();
|
||||||
progressBar.setAlignmentX(0.5f);
|
progressBar.setAlignmentX(0.5f);
|
||||||
progressBar.setIndeterminate(true);
|
progressBar.setIndeterminate(true);
|
||||||
bottomPanel.add(progressBar);
|
bottomPanel.add(progressBar);
|
||||||
bottomPanel.add(buttonsPanel);
|
bottomPanel.add(buttonsPanel);
|
||||||
browsersPanel.setAlignmentX(0.5f);
|
browsersPanel.setAlignmentX(0.5f);
|
||||||
bottomPanel.add(browsersPanel);
|
bottomPanel.add(browsersPanel);
|
||||||
JLabel infoLabel = new JLabel(translate("info.closed"));
|
JLabel infoLabel = new JLabel(translate("info.closed"));
|
||||||
infoLabel.setAlignmentX(0.5f);
|
infoLabel.setAlignmentX(0.5f);
|
||||||
bottomPanel.add(infoLabel);
|
bottomPanel.add(infoLabel);
|
||||||
cnt.add(bottomPanel, BorderLayout.SOUTH);
|
cnt.add(bottomPanel, BorderLayout.SOUTH);
|
||||||
progressBar.setVisible(false);
|
progressBar.setVisible(false);
|
||||||
openButton.setEnabled(false);
|
openButton.setEnabled(false);
|
||||||
saveButton.setEnabled(false);
|
saveButton.setEnabled(false);
|
||||||
|
|
||||||
java.util.List<Image> images = new ArrayList<>();
|
java.util.List<Image> images = new ArrayList<>();
|
||||||
images.add(View.loadImage("loadcache16"));
|
images.add(View.loadImage("loadcache16"));
|
||||||
images.add(View.loadImage("loadcache32"));
|
images.add(View.loadImage("loadcache32"));
|
||||||
setIconImages(images);
|
setIconImages(images);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refresh() {
|
private void refresh() {
|
||||||
progressBar.setVisible(true);
|
progressBar.setVisible(true);
|
||||||
openButton.setEnabled(false);
|
openButton.setEnabled(false);
|
||||||
saveButton.setEnabled(false);
|
saveButton.setEnabled(false);
|
||||||
refreshButton.setEnabled(false);
|
refreshButton.setEnabled(false);
|
||||||
new SwingWorker<Object, Object>() {
|
new SwingWorker<Object, Object>() {
|
||||||
@Override
|
@Override
|
||||||
protected Object doInBackground() throws Exception {
|
protected Object doInBackground() throws Exception {
|
||||||
if (caches == null) {
|
if (caches == null) {
|
||||||
caches = new ArrayList<>();
|
caches = new ArrayList<>();
|
||||||
for (String b : CacheReader.availableBrowsers()) {
|
for (String b : CacheReader.availableBrowsers()) {
|
||||||
caches.add(CacheReader.getBrowserCache(b));
|
caches.add(CacheReader.getBrowserCache(b));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (CacheImplementation c : caches) {
|
for (CacheImplementation c : caches) {
|
||||||
c.refresh();
|
c.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entries = new ArrayList<>();
|
entries = new ArrayList<>();
|
||||||
for (CacheImplementation c : caches) {
|
for (CacheImplementation c : caches) {
|
||||||
List<CacheEntry> list = c.getEntries();
|
List<CacheEntry> list = c.getEntries();
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
for (CacheEntry en : c.getEntries()) {
|
for (CacheEntry en : c.getEntries()) {
|
||||||
String contentType = en.getHeader("Content-Type");
|
String contentType = en.getHeader("Content-Type");
|
||||||
if ("application/x-shockwave-flash".equals(contentType)) {
|
if ("application/x-shockwave-flash".equals(contentType)) {
|
||||||
entries.add(en);
|
entries.add(en);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filter();
|
filter();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
openButton.setEnabled(true);
|
openButton.setEnabled(true);
|
||||||
saveButton.setEnabled(true);
|
saveButton.setEnabled(true);
|
||||||
refreshButton.setEnabled(true);
|
refreshButton.setEnabled(true);
|
||||||
progressBar.setVisible(false);
|
progressBar.setVisible(false);
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filter() {
|
private void filter() {
|
||||||
String search = searchField.getText();
|
String search = searchField.getText();
|
||||||
List<CacheEntry> filtered = new ArrayList<>();
|
List<CacheEntry> filtered = new ArrayList<>();
|
||||||
for (CacheEntry en : entries) {
|
for (CacheEntry en : entries) {
|
||||||
if (search.isEmpty() || en.getRequestURL().contains(search)) {
|
if (search.isEmpty() || en.getRequestURL().contains(search)) {
|
||||||
filtered.add(en);
|
filtered.add(en);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.setListData(new Vector<>(filtered));
|
list.setListData(new Vector<>(filtered));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String entryToFileName(CacheEntry en) {
|
private static String entryToFileName(CacheEntry en) {
|
||||||
String ret = en.getRequestURL();
|
String ret = en.getRequestURL();
|
||||||
//Strip parameters
|
//Strip parameters
|
||||||
if (ret.contains("?")) {
|
if (ret.contains("?")) {
|
||||||
ret = ret.substring(0, ret.indexOf('?'));
|
ret = ret.substring(0, ret.indexOf('?'));
|
||||||
}
|
}
|
||||||
//Strip path
|
//Strip path
|
||||||
if (ret.contains("/")) {
|
if (ret.contains("/")) {
|
||||||
ret = ret.substring(ret.lastIndexOf('/') + 1);
|
ret = ret.substring(ret.lastIndexOf('/') + 1);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openSWF() {
|
private void openSWF() {
|
||||||
CacheEntry en = list.getSelectedValue();
|
CacheEntry en = list.getSelectedValue();
|
||||||
if (en != null) {
|
if (en != null) {
|
||||||
ReReadableInputStream str = new ReReadableInputStream(en.getResponseDataStream());
|
ReReadableInputStream str = new ReReadableInputStream(en.getResponseDataStream());
|
||||||
SWFSourceInfo sourceInfo = new SWFSourceInfo(str, null, entryToFileName(en));
|
SWFSourceInfo sourceInfo = new SWFSourceInfo(str, null, entryToFileName(en));
|
||||||
Main.openFile(sourceInfo);
|
Main.openFile(sourceInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
switch (e.getActionCommand()) {
|
switch (e.getActionCommand()) {
|
||||||
case ACTION_REFRESH:
|
case ACTION_REFRESH:
|
||||||
refresh();
|
refresh();
|
||||||
break;
|
break;
|
||||||
case ACTION_OPEN:
|
case ACTION_OPEN:
|
||||||
openSWF();
|
openSWF();
|
||||||
break;
|
break;
|
||||||
case ACTION_SAVE:
|
case ACTION_SAVE:
|
||||||
List<CacheEntry> selected = list.getSelectedValuesList();
|
List<CacheEntry> selected = list.getSelectedValuesList();
|
||||||
if (!selected.isEmpty()) {
|
if (!selected.isEmpty()) {
|
||||||
JFileChooser fc = new JFileChooser();
|
JFileChooser fc = new JFileChooser();
|
||||||
fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
|
fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
|
||||||
if (selected.size() > 1) {
|
if (selected.size() > 1) {
|
||||||
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
} else {
|
} else {
|
||||||
fc.setSelectedFile(new File(Configuration.lastSaveDir.get(), entryToFileName(selected.get(0))));
|
fc.setSelectedFile(new File(Configuration.lastSaveDir.get(), entryToFileName(selected.get(0))));
|
||||||
fc.setFileFilter(new FileFilter() {
|
fc.setFileFilter(new FileFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File f) {
|
public boolean accept(File f) {
|
||||||
return (f.getName().endsWith(".swf")) || (f.isDirectory());
|
return (f.getName().endsWith(".swf")) || (f.isDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return AppStrings.translate("filter.swf");
|
return AppStrings.translate("filter.swf");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
fc.setAcceptAllFileFilterUsed(false);
|
fc.setAcceptAllFileFilterUsed(false);
|
||||||
JFrame f = new JFrame();
|
JFrame f = new JFrame();
|
||||||
View.setWindowIcon(f);
|
View.setWindowIcon(f);
|
||||||
int returnVal = fc.showSaveDialog(f);
|
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
File file = Helper.fixDialogFile(fc.getSelectedFile());
|
||||||
File file = Helper.fixDialogFile(fc.getSelectedFile());
|
try {
|
||||||
try {
|
if (selected.size() == 1) {
|
||||||
if (selected.size() == 1) {
|
Helper.saveStream(selected.get(0).getResponseDataStream(), file);
|
||||||
Helper.saveStream(selected.get(0).getResponseDataStream(), file);
|
} else {
|
||||||
} else {
|
for (CacheEntry sel : selected) {
|
||||||
for (CacheEntry sel : selected) {
|
Helper.saveStream(sel.getResponseDataStream(), new File(file, entryToFileName(sel)));
|
||||||
Helper.saveStream(sel.getResponseDataStream(), new File(file, entryToFileName(sel)));
|
}
|
||||||
}
|
}
|
||||||
}
|
Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath());
|
||||||
Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath());
|
} catch (IOException ex) {
|
||||||
} catch (IOException ex) {
|
View.showMessageDialog(null, translate("error.file.write"));
|
||||||
View.showMessageDialog(null, translate("error.file.write"));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -434,8 +434,7 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
|
|||||||
fc.setAcceptAllFileFilterUsed(false);
|
fc.setAcceptAllFileFilterUsed(false);
|
||||||
JFrame f = new JFrame();
|
JFrame f = new JFrame();
|
||||||
View.setWindowIcon(f);
|
View.setWindowIcon(f);
|
||||||
int returnVal = fc.showSaveDialog(f);
|
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
|
||||||
File file = Helper.fixDialogFile(fc.getSelectedFile());
|
File file = Helper.fixDialogFile(fc.getSelectedFile());
|
||||||
try {
|
try {
|
||||||
if (selected.length == 1) {
|
if (selected.length == 1) {
|
||||||
|
|||||||
@@ -584,8 +584,7 @@ public class Main {
|
|||||||
fc.setAcceptAllFileFilterUsed(false);
|
fc.setAcceptAllFileFilterUsed(false);
|
||||||
JFrame f = new JFrame();
|
JFrame f = new JFrame();
|
||||||
View.setWindowIcon(f);
|
View.setWindowIcon(f);
|
||||||
int returnVal = fc.showSaveDialog(f);
|
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
|
||||||
File file = Helper.fixDialogFile(fc.getSelectedFile());
|
File file = Helper.fixDialogFile(fc.getSelectedFile());
|
||||||
FileFilter selFilter = fc.getFileFilter();
|
FileFilter selFilter = fc.getFileFilter();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1414,8 +1414,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
|||||||
fc.setAcceptAllFileFilterUsed(false);
|
fc.setAcceptAllFileFilterUsed(false);
|
||||||
JFrame f = new JFrame();
|
JFrame f = new JFrame();
|
||||||
View.setWindowIcon(f);
|
View.setWindowIcon(f);
|
||||||
int returnVal = fc.showSaveDialog(f);
|
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
|
||||||
Configuration.lastOpenDir.set(Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath());
|
Configuration.lastOpenDir.set(Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath());
|
||||||
File sf = Helper.fixDialogFile(fc.getSelectedFile());
|
File sf = Helper.fixDialogFile(fc.getSelectedFile());
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.jpexs.decompiler.flash.gui.dumpview;
|
package com.jpexs.decompiler.flash.gui.dumpview;
|
||||||
|
|
||||||
|
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||||
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
|
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
|
||||||
import com.jpexs.decompiler.flash.dumpview.DumpInfoSwfNode;
|
import com.jpexs.decompiler.flash.dumpview.DumpInfoSwfNode;
|
||||||
import com.jpexs.decompiler.flash.gui.Main;
|
import com.jpexs.decompiler.flash.gui.Main;
|
||||||
@@ -29,7 +30,15 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
@@ -48,6 +57,7 @@ public class DumpTree extends JTree implements ActionListener {
|
|||||||
|
|
||||||
private static final String ACTION_CLOSE_SWF = "CLOSESWF";
|
private static final String ACTION_CLOSE_SWF = "CLOSESWF";
|
||||||
private static final String ACTION_EXPAND_RECURSIVE = "EXPANDRECURSIVE";
|
private static final String ACTION_EXPAND_RECURSIVE = "EXPANDRECURSIVE";
|
||||||
|
private static final String ACTION_SAVE_TO_FILE = "SAVETOFILE";
|
||||||
|
|
||||||
private final MainPanel mainPanel;
|
private final MainPanel mainPanel;
|
||||||
|
|
||||||
@@ -100,6 +110,11 @@ public class DumpTree extends JTree implements ActionListener {
|
|||||||
expandRecursiveMenuItem.setActionCommand(ACTION_EXPAND_RECURSIVE);
|
expandRecursiveMenuItem.setActionCommand(ACTION_EXPAND_RECURSIVE);
|
||||||
contextPopupMenu.add(expandRecursiveMenuItem);
|
contextPopupMenu.add(expandRecursiveMenuItem);
|
||||||
|
|
||||||
|
final JMenuItem saveToFileMenuItem = new JMenuItem(mainPanel.translate("contextmenu.saveToFile"));
|
||||||
|
saveToFileMenuItem.addActionListener(this);
|
||||||
|
saveToFileMenuItem.setActionCommand(ACTION_SAVE_TO_FILE);
|
||||||
|
contextPopupMenu.add(saveToFileMenuItem);
|
||||||
|
|
||||||
final JMenuItem closeSelectionMenuItem = new JMenuItem(mainPanel.translate("contextmenu.closeSwf"));
|
final JMenuItem closeSelectionMenuItem = new JMenuItem(mainPanel.translate("contextmenu.closeSwf"));
|
||||||
closeSelectionMenuItem.setActionCommand(ACTION_CLOSE_SWF);
|
closeSelectionMenuItem.setActionCommand(ACTION_CLOSE_SWF);
|
||||||
closeSelectionMenuItem.addActionListener(this);
|
closeSelectionMenuItem.addActionListener(this);
|
||||||
@@ -122,6 +137,7 @@ public class DumpTree extends JTree implements ActionListener {
|
|||||||
}
|
}
|
||||||
closeSelectionMenuItem.setVisible(false);
|
closeSelectionMenuItem.setVisible(false);
|
||||||
expandRecursiveMenuItem.setVisible(false);
|
expandRecursiveMenuItem.setVisible(false);
|
||||||
|
saveToFileMenuItem.setVisible(false);
|
||||||
|
|
||||||
if (paths.length == 1) {
|
if (paths.length == 1) {
|
||||||
DumpInfo treeNode = (DumpInfo) paths[0].getLastPathComponent();
|
DumpInfo treeNode = (DumpInfo) paths[0].getLastPathComponent();
|
||||||
@@ -129,6 +145,10 @@ public class DumpTree extends JTree implements ActionListener {
|
|||||||
if (treeNode instanceof DumpInfoSwfNode) {
|
if (treeNode instanceof DumpInfoSwfNode) {
|
||||||
closeSelectionMenuItem.setVisible(true);
|
closeSelectionMenuItem.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (treeNode.getEndByte() - treeNode.startByte > 3) {
|
||||||
|
saveToFileMenuItem.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
TreeModel model = getModel();
|
TreeModel model = getModel();
|
||||||
expandRecursiveMenuItem.setVisible(model.getChildCount(treeNode) > 0);
|
expandRecursiveMenuItem.setVisible(model.getChildCount(treeNode) > 0);
|
||||||
@@ -151,6 +171,28 @@ public class DumpTree extends JTree implements ActionListener {
|
|||||||
View.expandTreeNodesRecursive(this, path, true);
|
View.expandTreeNodesRecursive(this, path, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ACTION_SAVE_TO_FILE: {
|
||||||
|
TreePath[] paths = getSelectionPaths();
|
||||||
|
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
|
||||||
|
JFileChooser fc = new JFileChooser();
|
||||||
|
String selDir = Configuration.lastOpenDir.get();
|
||||||
|
fc.setCurrentDirectory(new File(selDir));
|
||||||
|
if (!selDir.endsWith(File.separator)) {
|
||||||
|
selDir += File.separator;
|
||||||
|
}
|
||||||
|
JFrame f = new JFrame();
|
||||||
|
View.setWindowIcon(f);
|
||||||
|
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
File sf = Helper.fixDialogFile(fc.getSelectedFile());
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(sf)) {
|
||||||
|
byte[] data = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf().uncompressedData;
|
||||||
|
fos.write(data, (int) dumpInfo.startByte, (int) (dumpInfo.getEndByte() - dumpInfo.startByte + 1));
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ACTION_CLOSE_SWF: {
|
case ACTION_CLOSE_SWF: {
|
||||||
Main.closeFile(mainPanel.getCurrentSwfList());
|
Main.closeFile(mainPanel.getCurrentSwfList());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,20 +46,6 @@ public class DumpViewPanel extends JPanel {
|
|||||||
add(new JScrollPane(dumpViewHexTable), BorderLayout.CENTER);
|
add(new JScrollPane(dumpViewHexTable), BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getEndIndex(DumpInfo dumpInfo) {
|
|
||||||
int end = (int) dumpInfo.startByte;
|
|
||||||
if (dumpInfo.lengthBytes != 0) {
|
|
||||||
end += dumpInfo.lengthBytes;
|
|
||||||
} else {
|
|
||||||
int bits = dumpInfo.startBit + dumpInfo.lengthBits;
|
|
||||||
end += bits / 8;
|
|
||||||
if (bits % 8 != 0) {
|
|
||||||
end++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return end - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(byte[] data, DumpInfo dumpInfo) {
|
public void setData(byte[] data, DumpInfo dumpInfo) {
|
||||||
List<DumpInfo> dumpInfos = new ArrayList<>();
|
List<DumpInfo> dumpInfos = new ArrayList<>();
|
||||||
DumpInfo di = dumpInfo;
|
DumpInfo di = dumpInfo;
|
||||||
@@ -72,13 +58,13 @@ public class DumpViewPanel extends JPanel {
|
|||||||
for (int i = 0; i < dumpInfos.size(); i++) {
|
for (int i = 0; i < dumpInfos.size(); i++) {
|
||||||
DumpInfo di2 = dumpInfos.get(highlightStarts.length - i - 1);
|
DumpInfo di2 = dumpInfos.get(highlightStarts.length - i - 1);
|
||||||
highlightStarts[i] = di2.startByte;
|
highlightStarts[i] = di2.startByte;
|
||||||
highlightEnds[i] = getEndIndex(di2);
|
highlightEnds[i] = di2.getEndByte();
|
||||||
}
|
}
|
||||||
dumpViewHexTable.setData(data, highlightStarts, highlightEnds);
|
dumpViewHexTable.setData(data, highlightStarts, highlightEnds);
|
||||||
|
|
||||||
if (dumpInfo.lengthBytes != 0 || dumpInfo.lengthBits != 0) {
|
if (dumpInfo.lengthBytes != 0 || dumpInfo.lengthBits != 0) {
|
||||||
int selectionStart = (int) dumpInfo.startByte;
|
int selectionStart = (int) dumpInfo.startByte;
|
||||||
int selectionEnd = getEndIndex(dumpInfo);
|
int selectionEnd = (int) dumpInfo.getEndByte();
|
||||||
|
|
||||||
dumpViewHexTable.scrollToByte(highlightStarts, highlightEnds);
|
dumpViewHexTable.scrollToByte(highlightStarts, highlightEnds);
|
||||||
|
|
||||||
|
|||||||
@@ -508,3 +508,5 @@ header.framecount = Frame count:
|
|||||||
header.displayrect = Display rect:
|
header.displayrect = Display rect:
|
||||||
header.displayrect.value.twips = %xmin%,%ymin% => %xmax%,%ymax% twips
|
header.displayrect.value.twips = %xmin%,%ymin% => %xmax%,%ymax% twips
|
||||||
header.displayrect.value.pixels = %xmin%,%ymin% => %xmax%,%ymax% pixels
|
header.displayrect.value.pixels = %xmin%,%ymin% => %xmax%,%ymax% pixels
|
||||||
|
|
||||||
|
contextmenu.saveToFile = Save to File
|
||||||
|
|||||||
@@ -508,3 +508,5 @@ header.framecount = Keret sz\u00e1m:
|
|||||||
header.displayrect = Megjelen\u00edt\u00e9si t\u00e9glalap:
|
header.displayrect = Megjelen\u00edt\u00e9si t\u00e9glalap:
|
||||||
header.displayrect.value.twips = %xmin%,%ymin% => %xmax%,%ymax% twip
|
header.displayrect.value.twips = %xmin%,%ymin% => %xmax%,%ymax% twip
|
||||||
header.displayrect.value.pixels = %xmin%,%ymin% => %xmax%,%ymax% k\u00e9ppont
|
header.displayrect.value.pixels = %xmin%,%ymin% => %xmax%,%ymax% k\u00e9ppont
|
||||||
|
|
||||||
|
contextmenu.saveToFile = Ment\u00e9s f\u00e1jlba
|
||||||
|
|||||||
Reference in New Issue
Block a user