mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 11:30:47 +00:00
replace shape with image
This commit is contained in:
@@ -270,7 +270,6 @@ public class FolderPreviewPanel extends JPanel {
|
||||
int h = h1 * w2 / w1;
|
||||
if (h > h2) {
|
||||
w = w1 * h2 / h1;
|
||||
h = h2;
|
||||
} else {
|
||||
w = w2;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ public class FontPanel extends javax.swing.JPanel {
|
||||
setAllowSave(false);
|
||||
String key = swf.getShortFileName() + "_" + ft.getFontId() + "_" + ft.getFontName();
|
||||
|
||||
String selectedFont = "";
|
||||
String selectedFont;
|
||||
|
||||
if (swf.sourceFontNamesMap.containsKey(ft.getFontId())) {
|
||||
selectedFont = swf.sourceFontNamesMap.get(ft.getFontId());
|
||||
|
||||
@@ -420,7 +420,6 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
|
||||
h = h1 * w2 / w1;
|
||||
if (h > h2) {
|
||||
w = w1 * h2 / h1;
|
||||
h = h2;
|
||||
} else {
|
||||
w = w2;
|
||||
}
|
||||
|
||||
@@ -1306,8 +1306,8 @@ public class Main {
|
||||
final java.util.List<Version> versions = new ArrayList<>();
|
||||
String header = "";
|
||||
Pattern headerPat = Pattern.compile("\\[([a-zA-Z0-9]+)\\]");
|
||||
int updateMajor = 0;
|
||||
int updateMinor = 0;
|
||||
int updateMajor;
|
||||
int updateMinor;
|
||||
Version ver = null;
|
||||
while ((s = br.readLine()) != null) {
|
||||
if (start) {
|
||||
|
||||
@@ -70,6 +70,7 @@ import com.jpexs.decompiler.flash.gui.timeline.TimelineViewPanel;
|
||||
import com.jpexs.decompiler.flash.helpers.Freed;
|
||||
import com.jpexs.decompiler.flash.importers.BinaryDataImporter;
|
||||
import com.jpexs.decompiler.flash.importers.ImageImporter;
|
||||
import com.jpexs.decompiler.flash.importers.ShapeImporter;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag;
|
||||
@@ -1948,51 +1949,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
|
||||
if (item instanceof DefineSoundTag) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
|
||||
fc.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return (f.getName().toLowerCase().endsWith(".mp3"))
|
||||
|| (f.getName().toLowerCase().endsWith(".wav"))
|
||||
|| (f.isDirectory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return translate("filter.sounds");
|
||||
}
|
||||
});
|
||||
fc.addChoosableFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return (f.getName().toLowerCase().endsWith(".mp3"))
|
||||
|| (f.isDirectory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return translate("filter.sounds.mp3");
|
||||
}
|
||||
});
|
||||
fc.addChoosableFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return (f.getName().toLowerCase().endsWith(".wav"))
|
||||
|| (f.isDirectory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return translate("filter.sounds.wav");
|
||||
}
|
||||
});
|
||||
JFrame f = new JFrame();
|
||||
View.setWindowIcon(f);
|
||||
int returnVal = fc.showOpenDialog(f);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
Configuration.lastOpenDir.set(Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath());
|
||||
File selfile = Helper.fixDialogFile(fc.getSelectedFile());
|
||||
File selectedFile = showImportFileChooser("filter.sounds|*.mp3;*.wav|filter.sounds.mp3|*.mp3|filter.sounds.wav|*.wav");
|
||||
if (selectedFile != null) {
|
||||
Configuration.lastOpenDir.set(Helper.fixDialogFile(selectedFile).getParentFile().getAbsolutePath());
|
||||
File selfile = Helper.fixDialogFile(selectedFile);
|
||||
DefineSoundTag ds = (DefineSoundTag) item;
|
||||
int soundFormat = SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN;
|
||||
if (selfile.getName().toLowerCase().endsWith(".mp3")) {
|
||||
@@ -2014,32 +1974,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
if (item instanceof ImageTag) {
|
||||
ImageTag it = (ImageTag) item;
|
||||
if (it.importSupported()) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
|
||||
fc.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return (f.getName().toLowerCase().endsWith(".jpg"))
|
||||
|| (f.getName().toLowerCase().endsWith(".jpeg"))
|
||||
|| (f.getName().toLowerCase().endsWith(".gif"))
|
||||
|| (f.getName().toLowerCase().endsWith(".png"))
|
||||
|| (f.isDirectory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return translate("filter.images");
|
||||
}
|
||||
});
|
||||
JFrame f = new JFrame();
|
||||
View.setWindowIcon(f);
|
||||
int returnVal = fc.showOpenDialog(f);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
Configuration.lastOpenDir.set(Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath());
|
||||
File selfile = Helper.fixDialogFile(fc.getSelectedFile());
|
||||
File selectedFile = showImportFileChooser("filter.images|*.jpg;*.jpeg;*.gif;*.png");
|
||||
if (selectedFile != null) {
|
||||
Configuration.lastOpenDir.set(Helper.fixDialogFile(selectedFile).getParentFile().getAbsolutePath());
|
||||
File selfile = Helper.fixDialogFile(selectedFile);
|
||||
byte[] data = Helper.readFile(selfile.getAbsolutePath());
|
||||
try {
|
||||
SWF swf = it.getSwf();
|
||||
Tag newTag = new ImageImporter().importImage(it, data);
|
||||
if (newTag != null) {
|
||||
refreshTree();
|
||||
@@ -2054,16 +1994,33 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item instanceof ShapeTag) {
|
||||
ShapeTag st = (ShapeTag) item;
|
||||
File selectedFile = showImportFileChooser("filter.images|*.jpg;*.jpeg;*.gif;*.png");
|
||||
if (selectedFile != null) {
|
||||
Configuration.lastOpenDir.set(Helper.fixDialogFile(selectedFile).getParentFile().getAbsolutePath());
|
||||
File selfile = Helper.fixDialogFile(selectedFile);
|
||||
byte[] data = Helper.readFile(selfile.getAbsolutePath());
|
||||
try {
|
||||
Tag newTag = new ShapeImporter().importImage(st, data);
|
||||
if (newTag != null) {
|
||||
refreshTree();
|
||||
setTagTreeSelectedNode(newTag);
|
||||
}
|
||||
SWF.clearImageCache();
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, "Invalid image", ex);
|
||||
View.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
reload(true);
|
||||
}
|
||||
}
|
||||
if (item instanceof DefineBinaryDataTag) {
|
||||
DefineBinaryDataTag bt = (DefineBinaryDataTag) item;
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
|
||||
JFrame f = new JFrame();
|
||||
View.setWindowIcon(f);
|
||||
int returnVal = fc.showOpenDialog(f);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
Configuration.lastOpenDir.set(Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath());
|
||||
File selfile = Helper.fixDialogFile(fc.getSelectedFile());
|
||||
File selectedFile = showImportFileChooser("");
|
||||
if (selectedFile != null) {
|
||||
Configuration.lastOpenDir.set(Helper.fixDialogFile(selectedFile).getParentFile().getAbsolutePath());
|
||||
File selfile = Helper.fixDialogFile(selectedFile);
|
||||
byte[] data = Helper.readFile(selfile.getAbsolutePath());
|
||||
new BinaryDataImporter().importData(bt, data);
|
||||
reload(true);
|
||||
@@ -2084,6 +2041,58 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
}
|
||||
}
|
||||
|
||||
private File showImportFileChooser(String filter) {
|
||||
String[] filterArray = filter.split("\\|");
|
||||
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
|
||||
boolean first = true;
|
||||
for (int i = 0; i < filterArray.length; i += 2) {
|
||||
final String filterName = filterArray[i];
|
||||
final String[] extensions = filterArray[i + 1].split(";");
|
||||
for (int j = 0; j < extensions.length; j++) {
|
||||
if (extensions[j].startsWith("*.")) {
|
||||
extensions[j] = extensions[j].substring(1);
|
||||
}
|
||||
}
|
||||
FileFilter ff = new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (f.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
String fileName = f.getName().toLowerCase();
|
||||
for (String ext : extensions) {
|
||||
if (fileName.endsWith(ext)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return translate(filterName);
|
||||
}
|
||||
};
|
||||
if (first) {
|
||||
fc.setFileFilter(ff);
|
||||
} else {
|
||||
fc.addChoosableFileFilter(ff);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
||||
JFrame f = new JFrame();
|
||||
View.setWindowIcon(f);
|
||||
if (fc.showOpenDialog(f) == JFileChooser.APPROVE_OPTION) {
|
||||
return fc.getSelectedFile();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private int splitPos = 0;
|
||||
|
||||
public void showDetail(String card) {
|
||||
|
||||
@@ -302,7 +302,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
SyntaxDocument sd = (SyntaxDocument) getDocument();
|
||||
Token t = sd.getTokenAt(pos + 1);
|
||||
Token lastToken = t;
|
||||
Token prev = null;
|
||||
Token prev;
|
||||
while (t.type == TokenType.IDENTIFIER || t.type == TokenType.KEYWORD || t.type == TokenType.REGEX) {
|
||||
prev = sd.getPrevToken(t);
|
||||
if (prev != null) {
|
||||
@@ -323,7 +323,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
if (currentType.equals("*")) {
|
||||
return false;
|
||||
}
|
||||
boolean found = false;
|
||||
boolean found;
|
||||
t = sd.getNextToken(t);
|
||||
while (t != lastToken && !currentType.equals("*")) {
|
||||
t = sd.getNextToken(t);
|
||||
@@ -540,7 +540,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
setNoTrait();
|
||||
return;
|
||||
}
|
||||
Trait currentTrait = null;
|
||||
Trait currentTrait;
|
||||
currentTraitHighlight = Highlighting.search(traitHighlights, pos);
|
||||
if (currentTraitHighlight != null) {
|
||||
lastTraitIndex = (int) (long) currentTraitHighlight.getPropertyLong("index");
|
||||
|
||||
@@ -213,7 +213,7 @@ public class ColorEditor extends JPanel implements GenericTagEditor, ActionListe
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
Color newColor = null;
|
||||
Color newColor;
|
||||
if (colorType == COLOR_TYPE_RGB) {
|
||||
try {
|
||||
newColor = noTransparencyColorChooser(null, AppStrings.translate("dialog.selectcolor.title"), color);
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.timeline.Frame;
|
||||
import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
import com.jpexs.decompiler.flash.treeitems.FolderItem;
|
||||
@@ -223,6 +224,10 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
|
||||
replaceMenuItem.setVisible(true);
|
||||
}
|
||||
|
||||
if (firstItem instanceof ShapeTag) {
|
||||
replaceMenuItem.setVisible(true);
|
||||
}
|
||||
|
||||
if (firstItem instanceof DefineBinaryDataTag) {
|
||||
replaceMenuItem.setVisible(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user