diff options
| author | 2025-09-11 17:35:30 +0100 | |
|---|---|---|
| committer | 2025-09-13 09:14:23 +0100 | |
| commit | f8c7b8497e9687e15123caca7d4fde54f5bf067a (patch) | |
| tree | 92a9da7756e0e18cb8925c1cc01e2a2edc10e60f /enigma-swing/src | |
| parent | Add factory methods to the entry views (diff) | |
| download | enigma-f8c7b8497e9687e15123caca7d4fde54f5bf067a.tar.gz enigma-f8c7b8497e9687e15123caca7d4fde54f5bf067a.tar.xz enigma-f8c7b8497e9687e15123caca7d4fde54f5bf067a.zip | |
Allow you to specify the libraries in the program args rather than always using the runtime classpath
Diffstat (limited to 'enigma-swing/src')
3 files changed, 8 insertions, 6 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java index 5ea9ab1c..1853a9fc 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java | |||
| @@ -55,7 +55,6 @@ import cuchaz.enigma.api.view.GuiView; | |||
| 55 | import cuchaz.enigma.api.view.entry.EntryReferenceView; | 55 | import cuchaz.enigma.api.view.entry.EntryReferenceView; |
| 56 | import cuchaz.enigma.classhandle.ClassHandle; | 56 | import cuchaz.enigma.classhandle.ClassHandle; |
| 57 | import cuchaz.enigma.classhandle.ClassHandleProvider; | 57 | import cuchaz.enigma.classhandle.ClassHandleProvider; |
| 58 | import cuchaz.enigma.classprovider.ClasspathClassProvider; | ||
| 59 | import cuchaz.enigma.gui.config.NetConfig; | 58 | import cuchaz.enigma.gui.config.NetConfig; |
| 60 | import cuchaz.enigma.gui.config.UiConfig; | 59 | import cuchaz.enigma.gui.config.UiConfig; |
| 61 | import cuchaz.enigma.gui.dialog.ProgressDialog; | 60 | import cuchaz.enigma.gui.dialog.ProgressDialog; |
| @@ -136,11 +135,11 @@ public class GuiController implements ClientPacketHandler, GuiView, DataInvalida | |||
| 136 | return project != null && project.getMapper().isDirty(); | 135 | return project != null && project.getMapper().isDirty(); |
| 137 | } | 136 | } |
| 138 | 137 | ||
| 139 | public CompletableFuture<Void> openJar(final List<Path> jarPaths) { | 138 | public CompletableFuture<Void> openJar(final List<Path> jarPaths, final List<Path> libraries) { |
| 140 | this.gui.onStartOpenJar(); | 139 | this.gui.onStartOpenJar(); |
| 141 | 140 | ||
| 142 | return ProgressDialog.runOffThread(gui.getFrame(), progress -> { | 141 | return ProgressDialog.runOffThread(gui.getFrame(), progress -> { |
| 143 | project = enigma.openJars(jarPaths, new ClasspathClassProvider(), progress, false); | 142 | project = enigma.openJars(jarPaths, libraries, progress, false); |
| 144 | project.addDataInvalidationListener(this); | 143 | project.addDataInvalidationListener(this); |
| 145 | indexTreeBuilder = new IndexTreeBuilder(project.getJarIndex()); | 144 | indexTreeBuilder = new IndexTreeBuilder(project.getJarIndex()); |
| 146 | chp = new ClassHandleProvider(project, UiConfig.getDecompiler().service); | 145 | chp = new ClassHandleProvider(project, UiConfig.getDecompiler().service); |
| @@ -275,11 +274,12 @@ public class GuiController implements ClientPacketHandler, GuiView, DataInvalida | |||
| 275 | 274 | ||
| 276 | public void reloadAll() { | 275 | public void reloadAll() { |
| 277 | List<Path> jarPaths = this.project.getJarPaths(); | 276 | List<Path> jarPaths = this.project.getJarPaths(); |
| 277 | List<Path> libraryPaths = this.project.getLibraryPaths(); | ||
| 278 | MappingFormat loadedMappingFormat = this.loadedMappingFormat; | 278 | MappingFormat loadedMappingFormat = this.loadedMappingFormat; |
| 279 | Path loadedMappingPath = this.loadedMappingPath; | 279 | Path loadedMappingPath = this.loadedMappingPath; |
| 280 | 280 | ||
| 281 | this.closeJar(); | 281 | this.closeJar(); |
| 282 | CompletableFuture<Void> f = this.openJar(jarPaths); | 282 | CompletableFuture<Void> f = this.openJar(jarPaths, libraryPaths); |
| 283 | 283 | ||
| 284 | if (loadedMappingFormat != null && loadedMappingPath != null) { | 284 | if (loadedMappingFormat != null && loadedMappingPath != null) { |
| 285 | f.whenComplete((v, t) -> this.openMappings(loadedMappingFormat, loadedMappingPath)); | 285 | f.whenComplete((v, t) -> this.openMappings(loadedMappingFormat, loadedMappingPath)); |
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java index 66402ad8..b9ad19e8 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java | |||
| @@ -40,6 +40,7 @@ public class Main { | |||
| 40 | OptionParser parser = new OptionParser(); | 40 | OptionParser parser = new OptionParser(); |
| 41 | 41 | ||
| 42 | OptionSpec<Path> jar = parser.accepts("jar", "Jar file to open at startup; if there are multiple jars, the order must be the same between all collab session members").withRequiredArg().withValuesConvertedBy(PathConverter.INSTANCE); | 42 | OptionSpec<Path> jar = parser.accepts("jar", "Jar file to open at startup; if there are multiple jars, the order must be the same between all collab session members").withRequiredArg().withValuesConvertedBy(PathConverter.INSTANCE); |
| 43 | OptionSpec<Path> library = parser.accepts("library", "The libraries for the input jar files").withRequiredArg().withValuesConvertedBy(PathConverter.INSTANCE); | ||
| 43 | 44 | ||
| 44 | OptionSpec<Path> mappings = parser.accepts("mappings", "Mappings file to open at startup").withRequiredArg().withValuesConvertedBy(PathConverter.INSTANCE); | 45 | OptionSpec<Path> mappings = parser.accepts("mappings", "Mappings file to open at startup").withRequiredArg().withValuesConvertedBy(PathConverter.INSTANCE); |
| 45 | 46 | ||
| @@ -140,7 +141,8 @@ public class Main { | |||
| 140 | 141 | ||
| 141 | if (options.has(jar)) { | 142 | if (options.has(jar)) { |
| 142 | List<Path> jarPaths = options.valuesOf(jar); | 143 | List<Path> jarPaths = options.valuesOf(jar); |
| 143 | controller.openJar(jarPaths).whenComplete((v, t) -> { | 144 | List<Path> libraryPaths = options.valuesOf(library); |
| 145 | controller.openJar(jarPaths, libraryPaths).whenComplete((v, t) -> { | ||
| 144 | if (options.has(mappings)) { | 146 | if (options.has(mappings)) { |
| 145 | Path mappingsPath = options.valueOf(mappings); | 147 | Path mappingsPath = options.valueOf(mappings); |
| 146 | 148 | ||
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java index 1789def1..02fa9e36 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java | |||
| @@ -244,7 +244,7 @@ public class MenuBar { | |||
| 244 | 244 | ||
| 245 | // checks if the file name corresponds to an existing file | 245 | // checks if the file name corresponds to an existing file |
| 246 | if (paths.stream().allMatch(Files::exists)) { | 246 | if (paths.stream().allMatch(Files::exists)) { |
| 247 | this.gui.getController().openJar(paths); | 247 | this.gui.getController().openJar(paths, gui.getController().project.getLibraryPaths()); |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | UiConfig.setLastSelectedDir(d.getCurrentDirectory().getAbsolutePath()); | 250 | UiConfig.setLastSelectedDir(d.getCurrentDirectory().getAbsolutePath()); |