mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-22 14:45:42 +00:00
#805 Autosave
This commit is contained in:
@@ -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