mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-22 14:16:20 +00:00
update menu selection when configuration changed in advanced settings
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
@@ -33,6 +36,8 @@ public class ConfigurationItem<T> {
|
||||
|
||||
private boolean modified;
|
||||
|
||||
private List<ConfigurationItemChangeListener<T>> listeners;
|
||||
|
||||
public ConfigurationItem(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -71,12 +76,14 @@ public class ConfigurationItem<T> {
|
||||
hasValue = true;
|
||||
modified = true;
|
||||
this.value = value;
|
||||
fireConfigurationItemChanged(value);
|
||||
}
|
||||
|
||||
public void unset() {
|
||||
hasValue = false;
|
||||
modified = true;
|
||||
this.value = null;
|
||||
fireConfigurationItemChanged(defaultValue);
|
||||
}
|
||||
|
||||
public boolean hasValue() {
|
||||
@@ -91,4 +98,26 @@ public class ConfigurationItem<T> {
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private void fireConfigurationItemChanged(T newValue) {
|
||||
if (listeners != null) {
|
||||
for (ConfigurationItemChangeListener<T> listener : listeners) {
|
||||
listener.configurationItemChanged(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener(ConfigurationItemChangeListener<T> l) {
|
||||
if (listeners == null) {
|
||||
listeners = new ArrayList<>();
|
||||
}
|
||||
|
||||
listeners.add(l);
|
||||
}
|
||||
|
||||
public void removeListener(ConfigurationItemChangeListener<T> l) {
|
||||
if (listeners != null) {
|
||||
listeners.remove(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
* @param <T>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ConfigurationItemChangeListener<T> {
|
||||
|
||||
public void configurationItemChanged(T newValue);
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.exporters.morphshape.CanvasMorphShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
import static com.jpexs.decompiler.flash.tags.base.DrawableTag.PARAMETER_RATIO;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY;
|
||||
|
||||
@@ -267,7 +267,7 @@ public class AdvancedSettingsDialog extends AppDialog {
|
||||
for (String name : keys) {
|
||||
Field field = fields.get(name);
|
||||
ConfigurationCategory cat = field.getAnnotation(ConfigurationCategory.class);
|
||||
String scat = cat == null ? "other" : cat.value();
|
||||
String scat = (cat == null || cat.value().equals("")) ? "other" : cat.value();
|
||||
if (!categorized.containsKey(scat)) {
|
||||
categorized.put(scat, new HashMap<>());
|
||||
}
|
||||
|
||||
@@ -30,8 +30,6 @@ import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.SymbolClassExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.TextExportMode;
|
||||
import static com.jpexs.decompiler.flash.gui.AppDialog.CANCEL_OPTION;
|
||||
import static com.jpexs.decompiler.flash.gui.AppDialog.OK_OPTION;
|
||||
import com.jpexs.decompiler.flash.gui.tagtree.TagTreeModel;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag;
|
||||
|
||||
@@ -896,8 +896,9 @@ public class Main {
|
||||
ContextMenuTools.addToContextMenu(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
Configuration.offeredAssociation.set(true);
|
||||
}
|
||||
Configuration.offeredAssociation.set(true);
|
||||
}
|
||||
|
||||
public static void initLang() {
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.SWFBundle;
|
||||
import com.jpexs.decompiler.flash.SWFSourceInfo;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.console.ContextMenuTools;
|
||||
import static com.jpexs.decompiler.flash.gui.Main.openFile;
|
||||
import com.jpexs.decompiler.flash.gui.debugger.DebuggerTools;
|
||||
import com.jpexs.decompiler.flash.gui.helpers.CheckResources;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
@@ -706,6 +705,7 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
|
||||
public void createMenuBar() {
|
||||
initMenu();
|
||||
|
||||
if (supportsAppMenu()) {
|
||||
addMenuItem("_", null, null, null, 0, null, false);
|
||||
addMenuItem("_/open", translate("menu.file.open"), "open32", this::openActionPerformed, PRIORITY_TOP, this::loadRecent, false);
|
||||
@@ -733,6 +733,7 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
} else {
|
||||
finishMenu("/file/open");
|
||||
}
|
||||
|
||||
addMenuItem("/file/save", translate("menu.file.save"), "save32", this::saveActionPerformed, PRIORITY_TOP, null, true);
|
||||
addMenuItem("/file/saveAs", translate("menu.file.saveas"), "saveas16", this::saveAsActionPerformed, PRIORITY_MEDIUM, null, true);
|
||||
addMenuItem("/file/saveAsExe", translate("menu.file.saveasexe"), "saveasexe16", this::saveAsExeActionPerformed, PRIORITY_MEDIUM, null, true);
|
||||
@@ -743,7 +744,6 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
addMenuItem("/file/export", translate("menu.export"), null, null, 0, null, false);
|
||||
addMenuItem("/file/export/exportFla", translate("menu.file.export.fla"), "exportfla32", this::exportFlaActionPerformed, PRIORITY_TOP, null, true);
|
||||
addMenuItem("/file/export/exportXml", translate("menu.file.export.xml"), "exportxml32", this::exportXmlActionPerformed, PRIORITY_MEDIUM, null, true);
|
||||
|
||||
addMenuItem("/file/export/exportAll", translate("menu.file.export.all"), "export16", this::exportAllActionPerformed, PRIORITY_MEDIUM, null, true);
|
||||
addMenuItem("/file/export/exportSelected", translate("menu.file.export.selection"), "exportsel16", this::exportSelectedActionPerformed, PRIORITY_MEDIUM, null, true);
|
||||
finishMenu("/file/export");
|
||||
@@ -768,6 +768,7 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
addSeparator("/file");
|
||||
addMenuItem("/file/exit", translate("menu.file.exit"), "exit32", this::exitActionPerformed, PRIORITY_TOP, null, true);
|
||||
}
|
||||
|
||||
finishMenu("/file");
|
||||
|
||||
if (Configuration.dumpView.get()) {
|
||||
@@ -805,22 +806,17 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
addMenuItem("/settings", translate("menu.settings"), null, null, 0, null, false);
|
||||
|
||||
addToggleMenuItem("/settings/autoDeobfuscation", translate("menu.settings.autodeobfuscation"), null, null, this::autoDeobfuscationActionPerformed, 0);
|
||||
|
||||
addToggleMenuItem("/settings/internalViewer", translate("menu.settings.internalflashviewer"), null, null, this::internalViewerSwitchActionPerformed, 0);
|
||||
|
||||
addToggleMenuItem("/settings/parallelSpeedUp", translate("menu.settings.parallelspeedup"), null, null, this::parallelSpeedUpActionPerformed, 0);
|
||||
|
||||
addToggleMenuItem("/settings/disableDecompilation", translate("menu.settings.disabledecompilation"), null, null, this::disableDecompilationActionPerformed, 0);
|
||||
|
||||
addToggleMenuItem("/settings/cacheOnDisk", translate("menu.settings.cacheOnDisk"), null, null, this::cacheOnDiskActionPerformed, 0);
|
||||
|
||||
addToggleMenuItem("/settings/gotoMainClassOnStartup", translate("menu.settings.gotoMainClassOnStartup"), null, null, this::gotoDucumentClassOnStartupActionPerformed, 0);
|
||||
|
||||
addToggleMenuItem("/settings/autoRenameIdentifiers", translate("menu.settings.autoRenameIdentifiers"), null, null, this::autoRenameIdentifiersActionPerformed, 0);
|
||||
|
||||
if (Platform.isWindows()) {
|
||||
addToggleMenuItem("/settings/associate", translate("menu.settings.addtocontextmenu"), null, null, this::associateActionPerformed, 0);
|
||||
}
|
||||
|
||||
addMenuItem("/settings/language", translate("menu.language"), null, null, 0, null, false);
|
||||
addMenuItem("/settings/language/setLanguage", translate("menu.settings.language"), "setlanguage32", this::setLanguageActionPerformed, PRIORITY_TOP, null, true);
|
||||
finishMenu("/settings/language");
|
||||
@@ -838,22 +834,49 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
addMenuItem("/settings/advancedSettings", translate("menu.advancedsettings.advancedsettings"), null, null, 0, null, false);
|
||||
addMenuItem("/settings/advancedSettings/advancedSettings", translate("menu.advancedsettings.advancedsettings"), "settings32", this::advancedSettingsActionPerformed, PRIORITY_TOP, null, true);
|
||||
addMenuItem("/settings/advancedSettings/clearRecentFiles", translate("menu.tools.otherTools.clearRecentFiles"), "clearrecent16", this::clearRecentFilesActionPerformed, PRIORITY_MEDIUM, null, true);
|
||||
|
||||
finishMenu("/settings/advancedSettings");
|
||||
|
||||
finishMenu("/settings");
|
||||
|
||||
setMenuChecked("/settings/autoDeobfuscation", Configuration.autoDeobfuscate.get());
|
||||
Configuration.autoDeobfuscate.addListener((Boolean newValue) -> {
|
||||
setMenuChecked("/settings/autoDeobfuscation", newValue);
|
||||
});
|
||||
|
||||
setMenuChecked("/settings/internalViewer", Configuration.internalFlashViewer.get() || externalFlashPlayerUnavailable);
|
||||
Configuration.autoDeobfuscate.addListener((Boolean newValue) -> {
|
||||
setMenuChecked("/settings/internalViewer", newValue || externalFlashPlayerUnavailable);
|
||||
});
|
||||
|
||||
setMenuChecked("/settings/parallelSpeedUp", Configuration.parallelSpeedUp.get());
|
||||
Configuration.autoDeobfuscate.addListener((Boolean newValue) -> {
|
||||
setMenuChecked("/settings/parallelSpeedUp", newValue);
|
||||
});
|
||||
|
||||
setMenuChecked("/settings/disableDecompilation", !Configuration.decompile.get());
|
||||
setMenuChecked("/settings/cacheOnDisk", !Configuration.cacheOnDisk.get());
|
||||
Configuration.autoDeobfuscate.addListener((Boolean newValue) -> {
|
||||
setMenuChecked("/settings/disableDecompilation", !newValue);
|
||||
});
|
||||
|
||||
setMenuChecked("/settings/cacheOnDisk", Configuration.cacheOnDisk.get());
|
||||
Configuration.autoDeobfuscate.addListener((Boolean newValue) -> {
|
||||
setMenuChecked("/settings/cacheOnDisk", newValue);
|
||||
});
|
||||
|
||||
setMenuChecked("/settings/gotoMainClassOnStartup", Configuration.gotoMainClassOnStartup.get());
|
||||
Configuration.autoDeobfuscate.addListener((Boolean newValue) -> {
|
||||
setMenuChecked("/settings/gotoMainClassOnStartup", newValue);
|
||||
});
|
||||
|
||||
setMenuChecked("/settings/autoRenameIdentifiers", Configuration.autoRenameIdentifiers.get());
|
||||
Configuration.autoDeobfuscate.addListener((Boolean newValue) -> {
|
||||
setMenuChecked("/settings/autoRenameIdentifiers", newValue);
|
||||
});
|
||||
|
||||
if (externalFlashPlayerUnavailable) {
|
||||
setMenuEnabled("/settings/internalViewer", false);
|
||||
}
|
||||
|
||||
int deobfuscationMode = Configuration.deobfuscationMode.get();
|
||||
switch (deobfuscationMode) {
|
||||
case 0:
|
||||
@@ -863,10 +886,11 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
setGroupSelection("deobfuscation", "/settings/deobfuscation/new");
|
||||
break;
|
||||
}
|
||||
|
||||
if (Platform.isWindows()) {
|
||||
setMenuChecked("/settings/associate", ContextMenuTools.isAddedToContextMenu());
|
||||
|
||||
}
|
||||
|
||||
//Help
|
||||
addMenuItem("/help", translate("menu.help"), null, null, 0, null, false);
|
||||
addMenuItem("/help/helpUs", translate("menu.help.helpus"), "donate32", this::helpUsActionPerformed, PRIORITY_TOP, null, true);
|
||||
@@ -910,12 +934,14 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
}, PRIORITY_MEDIUM, null, true);
|
||||
addMenuItem("/debug/openTestSwfs", "Open test SWFs", "update16", e -> {
|
||||
String path;
|
||||
|
||||
SWFSourceInfo[] sourceInfos = new SWFSourceInfo[2];
|
||||
path = Main.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "\\..\\..\\libsrc\\ffdec_lib\\testdata\\as2\\as2.swf";
|
||||
String mainPath = Main.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
path = mainPath + "\\..\\..\\libsrc\\ffdec_lib\\testdata\\as2\\as2.swf";
|
||||
sourceInfos[0] = new SWFSourceInfo(null, path, null);
|
||||
path = Main.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "\\..\\..\\libsrc\\ffdec_lib\\testdata\\as3\\as3.swf";
|
||||
path = mainPath + "\\..\\..\\libsrc\\ffdec_lib\\testdata\\as3\\as3.swf";
|
||||
sourceInfos[1] = new SWFSourceInfo(null, path, null);
|
||||
openFile(sourceInfos);
|
||||
Main.openFile(sourceInfos);
|
||||
}, PRIORITY_MEDIUM, null, true);
|
||||
finishMenu("/debug");
|
||||
}
|
||||
@@ -928,7 +954,6 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
mainFrame.getPanel().showView(MainPanel.VIEW_RESOURCES);
|
||||
setGroupSelection("view", "/file/view/viewResources");
|
||||
setMenuChecked("/tools/timeline", false);
|
||||
|
||||
}
|
||||
|
||||
private void viewHexActionPerformed(ActionEvent evt) {
|
||||
@@ -989,6 +1014,5 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
|
||||
finishMenu("/file/" + (supportsMenuAction() ? "open" : "recent"));
|
||||
finishMenu("_/open");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import static com.jpexs.decompiler.flash.gui.AppDialog.ERROR_OPTION;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
|
||||
Reference in New Issue
Block a user