mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-29 10:24:38 +00:00
#805 Autosave
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class BigObject {
|
||||
|
||||
private byte[] dummy = new byte[512 * 1024 * 1024];
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
System.out.println("swf finalized");
|
||||
}
|
||||
}
|
||||
@@ -182,6 +182,8 @@ import org.monte.media.avi.AVIWriter;
|
||||
*/
|
||||
public final class SWF implements SWFContainerItem, Timelined {
|
||||
|
||||
// big object for testing cleanup
|
||||
//BigObject bigObj = new BigObject();
|
||||
/**
|
||||
* Default version of SWF file format
|
||||
*/
|
||||
|
||||
@@ -409,6 +409,10 @@ public class Configuration {
|
||||
@ConfigurationCategory("ui")
|
||||
public static final ConfigurationItem<Boolean> editorMode = null;
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("ui")
|
||||
public static final ConfigurationItem<Boolean> autoSaveTagModifications = null;
|
||||
|
||||
private enum OSId {
|
||||
|
||||
WINDOWS, OSX, UNIX
|
||||
|
||||
@@ -660,6 +660,10 @@ public class DefineEditTextTag extends TextTag {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTextBounds() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alignText(TextAlign textAlign) {
|
||||
return true;
|
||||
|
||||
@@ -436,10 +436,15 @@ public class DefineText2Tag extends TextTag {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
updateTextBounds(textBounds);
|
||||
updateTextBounds();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTextBounds() {
|
||||
updateTextBounds(textBounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alignText(TextAlign textAlign) {
|
||||
alignText(swf, textRecords, textAlign);
|
||||
@@ -450,6 +455,7 @@ public class DefineText2Tag extends TextTag {
|
||||
@Override
|
||||
public boolean translateText(int diff) {
|
||||
textMatrix.translateX += diff;
|
||||
updateTextBounds();
|
||||
setModified(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -444,10 +444,15 @@ public class DefineTextTag extends TextTag {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
updateTextBounds(textBounds);
|
||||
updateTextBounds();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTextBounds() {
|
||||
updateTextBounds(textBounds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alignText(TextAlign textAlign) {
|
||||
alignText(swf, textRecords, textAlign);
|
||||
@@ -458,6 +463,7 @@ public class DefineTextTag extends TextTag {
|
||||
@Override
|
||||
public boolean translateText(int diff) {
|
||||
textMatrix.translateX += diff;
|
||||
updateTextBounds();
|
||||
setModified(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@ public abstract class TextTag extends CharacterTag implements DrawableTag {
|
||||
// use the texts from the "texts" argument when it is not null
|
||||
public abstract boolean setFormattedText(MissingCharacterHandler missingCharHandler, String formattedText, String[] texts) throws TextParseException;
|
||||
|
||||
public abstract void updateTextBounds();
|
||||
|
||||
public abstract boolean alignText(TextAlign textAlign);
|
||||
|
||||
public abstract boolean translateText(int diff);
|
||||
@@ -500,7 +502,7 @@ public abstract class TextTag extends CharacterTag implements DrawableTag {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void updateTextBounds(RECT textBounds) {
|
||||
protected void updateTextBounds(RECT textBounds) {
|
||||
TextImportResizeTextBoundsMode resizeMode = Configuration.textImportResizeTextBoundsMode.get();
|
||||
if (resizeMode != null && (resizeMode.equals(TextImportResizeTextBoundsMode.GROW_ONLY) || resizeMode.equals(TextImportResizeTextBoundsMode.GROW_AND_SHRINK))) {
|
||||
ExportRectangle newBounds = calculateTextBounds();
|
||||
|
||||
@@ -853,6 +853,12 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
|
||||
return outlines;
|
||||
}
|
||||
|
||||
public synchronized void clearAll() {
|
||||
stop();
|
||||
timelined = null;
|
||||
swf = null;
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
clear();
|
||||
stopAllSounds();
|
||||
|
||||
@@ -2377,7 +2377,13 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
|
||||
}
|
||||
|
||||
private void closeTag() {
|
||||
previewPanel.closeTag();
|
||||
}
|
||||
|
||||
public void reload(boolean forceReload) {
|
||||
closeTag();
|
||||
|
||||
if (Configuration.dumpView.get()) {
|
||||
dumpViewReload(forceReload);
|
||||
return;
|
||||
|
||||
@@ -455,11 +455,11 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
showCardRight(CARDTEXTPANEL);
|
||||
parametersPanel.setVisible(true);
|
||||
setDividerLocation(Configuration.guiPreviewSplitPaneDividerLocation.get(getWidth() / 2));
|
||||
textPanel.setText(textTag.getFormattedText());
|
||||
textPanel.setText(textTag);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
imagePanel.stop();
|
||||
imagePanel.clearAll();
|
||||
if (media != null) {
|
||||
media.pause();
|
||||
}
|
||||
@@ -469,6 +469,10 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
|
||||
fontPanel.clear();
|
||||
}
|
||||
|
||||
public void closeTag() {
|
||||
textPanel.closeTag();
|
||||
}
|
||||
|
||||
public void showBinaryPanel(DefineBinaryDataTag binaryDataTag) {
|
||||
showCardLeft(BINARY_TAG_CARD);
|
||||
binaryPanel.setBinaryData(binaryDataTag);
|
||||
|
||||
@@ -20,13 +20,11 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane;
|
||||
import com.jpexs.decompiler.flash.tags.DefineEditTextTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
import com.jpexs.decompiler.flash.tags.text.TextAlign;
|
||||
import com.jpexs.decompiler.flash.tags.text.TextParseException;
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
@@ -76,6 +74,8 @@ public class TextPanel extends JPanel {
|
||||
|
||||
private final JButton undoChangesButton;
|
||||
|
||||
private TextTag textTag;
|
||||
|
||||
private boolean modified = false;
|
||||
|
||||
public TextPanel(final MainPanel mainPanel) {
|
||||
@@ -160,13 +160,22 @@ public class TextPanel extends JPanel {
|
||||
return textSearchPanel;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
textValue.setText(text);
|
||||
public void setText(TextTag textTag) {
|
||||
this.textTag = textTag;
|
||||
textValue.setText(textTag.getFormattedText());
|
||||
textValue.setCaretPosition(0);
|
||||
modified = false;
|
||||
setEditText(false);
|
||||
}
|
||||
|
||||
public void closeTag() {
|
||||
if (modified && Configuration.autoSaveTagModifications.get()) {
|
||||
saveText();
|
||||
}
|
||||
|
||||
textTag = null;
|
||||
}
|
||||
|
||||
private void setEditText(boolean edit) {
|
||||
textValue.setEditable(Configuration.editorMode.get() || edit);
|
||||
updateButtonsVisibility();
|
||||
@@ -181,9 +190,8 @@ public class TextPanel extends JPanel {
|
||||
textCancelButton.setVisible(edit);
|
||||
textCancelButton.setEnabled(modified || !editorMode);
|
||||
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
boolean alignable = false;
|
||||
if (item instanceof TextTag && !(item instanceof DefineEditTextTag)) {
|
||||
if (textTag != null && !(textTag instanceof DefineEditTextTag)) {
|
||||
alignable = !edit || (editorMode && !modified);
|
||||
}
|
||||
|
||||
@@ -194,7 +202,7 @@ public class TextPanel extends JPanel {
|
||||
increaseTranslateXButton.setVisible(alignable);
|
||||
decreaseTranslateXButton.setVisible(alignable);
|
||||
|
||||
undoChangesButton.setVisible(item != null && item instanceof TextTag && ((Tag) item).isModified());
|
||||
undoChangesButton.setVisible(textTag != null && textTag.isModified());
|
||||
}
|
||||
|
||||
public void updateSearchPos() {
|
||||
@@ -219,54 +227,39 @@ public class TextPanel extends JPanel {
|
||||
}
|
||||
|
||||
private void saveText() {
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
if (item instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) item;
|
||||
if (mainPanel.saveText(textTag, textValue.getText(), null)) {
|
||||
setEditText(false);
|
||||
modified = false;
|
||||
item.getSwf().clearImageCache();
|
||||
mainPanel.refreshTree();
|
||||
}
|
||||
if (mainPanel.saveText(textTag, textValue.getText(), null)) {
|
||||
setEditText(false);
|
||||
modified = false;
|
||||
textTag.getSwf().clearImageCache();
|
||||
mainPanel.refreshTree();
|
||||
}
|
||||
}
|
||||
|
||||
private void textAlign(TextAlign textAlign) {
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
if (item instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) item;
|
||||
if (mainPanel.alignText(textTag, textAlign)) {
|
||||
updateButtonsVisibility();
|
||||
item.getSwf().clearImageCache();
|
||||
mainPanel.refreshTree();
|
||||
}
|
||||
if (mainPanel.alignText(textTag, textAlign)) {
|
||||
updateButtonsVisibility();
|
||||
textTag.getSwf().clearImageCache();
|
||||
mainPanel.refreshTree();
|
||||
}
|
||||
}
|
||||
|
||||
private void translateX(int delta) {
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
if (item instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) item;
|
||||
if (mainPanel.translateText(textTag, delta)) {
|
||||
updateButtonsVisibility();
|
||||
item.getSwf().clearImageCache();
|
||||
mainPanel.refreshTree();
|
||||
}
|
||||
if (mainPanel.translateText(textTag, delta)) {
|
||||
updateButtonsVisibility();
|
||||
textTag.getSwf().clearImageCache();
|
||||
mainPanel.refreshTree();
|
||||
}
|
||||
}
|
||||
|
||||
private void undoChanges() {
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
if (item instanceof TextTag) {
|
||||
try {
|
||||
((Tag) item).undo();
|
||||
} catch (InterruptedException | IOException ex) {
|
||||
Logger.getLogger(TextPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
item.getSwf().clearImageCache();
|
||||
mainPanel.refreshTree();
|
||||
try {
|
||||
textTag.undo();
|
||||
} catch (InterruptedException | IOException ex) {
|
||||
Logger.getLogger(TextPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
textTag.getSwf().clearImageCache();
|
||||
mainPanel.refreshTree();
|
||||
}
|
||||
|
||||
private void textChanged() {
|
||||
@@ -282,29 +275,25 @@ public class TextPanel extends JPanel {
|
||||
}
|
||||
|
||||
if (textValue.isEditable()) {
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
if (item instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) item;
|
||||
boolean ok = false;
|
||||
try {
|
||||
TextTag copyTextTag = (TextTag) textTag.cloneTag();
|
||||
if (copyTextTag.setFormattedText(new MissingCharacterHandler() {
|
||||
boolean ok = false;
|
||||
try {
|
||||
TextTag copyTextTag = (TextTag) textTag.cloneTag();
|
||||
if (copyTextTag.setFormattedText(new MissingCharacterHandler() {
|
||||
|
||||
@Override
|
||||
public boolean handle(TextTag textTag, FontTag font, char character) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}, textValue.getText(), null)) {
|
||||
ok = true;
|
||||
mainPanel.showTextTagWithNewValue(textTag, copyTextTag);
|
||||
@Override
|
||||
public boolean handle(TextTag textTag, FontTag font, char character) {
|
||||
return false;
|
||||
}
|
||||
} catch (TextParseException | InterruptedException | IOException ex) {
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
mainPanel.showTextTagWithNewValue(textTag, null);
|
||||
}, textValue.getText(), null)) {
|
||||
ok = true;
|
||||
mainPanel.showTextTagWithNewValue(textTag, copyTextTag);
|
||||
}
|
||||
} catch (TextParseException | InterruptedException | IOException ex) {
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
mainPanel.showTextTagWithNewValue(textTag, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.MemoryInputStream;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
@@ -44,7 +43,6 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenuItem;
|
||||
@@ -92,13 +90,6 @@ public class DumpTree extends JTree implements ActionListener {
|
||||
setCellRenderer(new DumpTreeCellRenderer());
|
||||
setRootVisible(false);
|
||||
setBackground(Color.white);
|
||||
setUI(new BasicTreeUI() {
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
setHashColor(Color.gray);
|
||||
super.paint(g, c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createContextMenu() {
|
||||
@@ -293,6 +284,13 @@ public class DumpTree extends JTree implements ActionListener {
|
||||
@Override
|
||||
public void setModel(TreeModel tm) {
|
||||
super.setModel(tm);
|
||||
|
||||
setUI(new BasicTreeUI() {
|
||||
{
|
||||
setHashColor(Color.gray);
|
||||
}
|
||||
});
|
||||
|
||||
if (tm != null) {
|
||||
int rowCount = tm.getChildCount(tm.getRoot());
|
||||
for (int i = rowCount - 1; i >= 0; i--) {
|
||||
|
||||
@@ -320,3 +320,6 @@ config.description.updateProxyAddress = Http Proxy address for checking updates.
|
||||
|
||||
config.name.editorMode = Editor Mode
|
||||
config.description.editorMode = Make text areas edittable automatically when you select a Text or Script node
|
||||
|
||||
config.name.autoSaveTagModifications = Auto save tag modificatios
|
||||
config.description.autoSaveTagModifications = Save the changes when you select a new tag in the tree
|
||||
|
||||
@@ -317,3 +317,6 @@ config.description.showTraitSavedMessage = Trait mentve \u00fczenet \u00fajra mu
|
||||
|
||||
config.name.updateProxyAddress = Http Proxy c\u00edm a friss\u00edt\u00e9sek keres\u00e9s\u00e9hez
|
||||
config.description.updateProxyAddress = Http Proxy c\u00edm a friss\u00edt\u00e9sek keres\u00e9s\u00e9hez. Form\u00e1tum: example.com:8080
|
||||
|
||||
config.name.autoSaveTagModifications = Tag m\u00f3dos\u00edt\u00e1sainak automatikus ment\u00e9se
|
||||
config.description.autoSaveTagModifications = V\u00e1ltoz\u00e1sok ment\u00e9se amikor \u00faj tag-et v\u00e1laszt ki a f\u00e1ban
|
||||
|
||||
@@ -119,7 +119,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.plaf.TreeUI;
|
||||
import javax.swing.plaf.basic.BasicLabelUI;
|
||||
import javax.swing.plaf.basic.BasicTreeUI;
|
||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
@@ -218,14 +217,6 @@ public class TagTree extends JTree {
|
||||
setBackground(Color.white);
|
||||
setRowHeight(16);
|
||||
setLargeModel(true);
|
||||
|
||||
TreeUI treeUI = new BasicTreeUI() {
|
||||
{
|
||||
setHashColor(Color.gray);
|
||||
}
|
||||
};
|
||||
|
||||
setUI(treeUI);
|
||||
}
|
||||
|
||||
public void createContextMenu() {
|
||||
@@ -545,6 +536,13 @@ public class TagTree extends JTree {
|
||||
@Override
|
||||
public void setModel(TreeModel tm) {
|
||||
super.setModel(tm);
|
||||
|
||||
setUI(new BasicTreeUI() {
|
||||
{
|
||||
setHashColor(Color.gray);
|
||||
}
|
||||
});
|
||||
|
||||
if (tm != null) {
|
||||
int rowCount = tm.getChildCount(tm.getRoot());
|
||||
for (int i = rowCount - 1; i >= 0; i--) {
|
||||
|
||||
Reference in New Issue
Block a user