Skip to content

Commit

Permalink
Merge pull request #11 from 1fxe/fix/mappings
Browse files Browse the repository at this point in the history
fix: mappings not applying visually
  • Loading branch information
1fxe authored Nov 14, 2021
2 parents ee5eaeb + 17bf628 commit 3e15595
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8

recaf {
mainClass = project.mainClass
recafVersion = "2.21.4"
}

task processSource(type: Sync) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Recaf4Forge
version=1.2.2
version=1.2.3
group=dev.fxe
description=Recaf4Forge
mainClass=dev.fxe.recaf4forge.Recaf4Forge
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/dev/fxe/recaf4forge/Recaf4Forge.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import dev.fxe.recaf4forge.utils.Extractor;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.Tab;
import me.coley.recaf.config.Conf;
import me.coley.recaf.control.Controller;
import me.coley.recaf.control.gui.GuiController;
Expand All @@ -19,7 +20,10 @@
import me.coley.recaf.ui.MainWindow;
import me.coley.recaf.ui.controls.ActionMenuItem;
import me.coley.recaf.ui.controls.ExceptionAlert;
import me.coley.recaf.ui.controls.node.ClassNodeEditorPane;
import me.coley.recaf.ui.controls.view.ClassViewport;
import me.coley.recaf.util.Log;
import me.coley.recaf.util.ThreadUtil;
import me.coley.recaf.util.struct.ListeningMap;
import me.coley.recaf.workspace.Workspace;
import org.plugface.core.annotations.Plugin;
Expand Down Expand Up @@ -107,6 +111,7 @@ public Menu createMenu() {
}

private void applyMapping() {
if (this.currentWorkspace == null) return;
MappingImpl mappingIml = Versions.MAP.get(this.currentVersion);
String path = this.exporter.getPluginResource(this.currentVersion, ("/mappings." + mappingIml).toLowerCase());
Path mappingPath = Extractor.getResourcePath(null, path);
Expand All @@ -120,9 +125,20 @@ private void applyMapping() {
mappings.setCheckMethodHierarchy(true);
mappings.accept(this.currentWorkspace.getPrimary());
Recaf4Forge.info("Finished applying mappings");
if (this.getController() instanceof GuiController && this.notify) {
if (this.getController() instanceof GuiController) {
MainWindow window = MainWindow.get((GuiController) this.getController());
Notification.create(this.getName() + " Mappings", "Successfully applied mappings!").show(window.getRoot());
ThreadUtil.checkJfxAndEnqueue(() -> {
for (Tab tab : window.getTabs().getTabs()) {
if (tab.getContent() instanceof ClassViewport) {
ClassViewport classViewport = (ClassViewport) tab.getContent();
classViewport.updateView();
}
}
});

if (this.notify) {
Notification.create(this.getName() + " Mappings", "Successfully applied mappings!").show(window.getRoot());
}
}
} catch (Exception ex) {
ExceptionAlert.show(ex, this.getName() + " Failed to apply mappings");
Expand Down

0 comments on commit 3e15595

Please sign in to comment.