Skip to content

Commit

Permalink
Minor tidying of #381
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed May 29, 2021
1 parent d1285fb commit 7378b39
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 24 deletions.
9 changes: 4 additions & 5 deletions src/main/java/me/coley/recaf/command/impl/Remap.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,19 @@ public Void call() throws Exception {

byte[] manifestBytes = primary.getFiles().get("META-INF/MANIFEST.MF");
if (manifestBytes != null) {
debug("Found manifest file");
Manifest manifest = new Manifest(new ByteArrayInputStream(manifestBytes));
Attributes attr = manifest.getMainAttributes();
if (!attr.isEmpty()) {
String mainClass = attr.getValue("Main-Class").replaceAll("\\.", "/");
if (mapped.containsKey(mainClass)) {
debug("Found Main-Class attribute");
attr.putValue("Main-Class", new ClassReader(mapped.get(mainClass))
.getClassName().replaceAll("/", "\\."));
String mappedName = new ClassReader(mapped.get(mainClass))
.getClassName().replaceAll("/", "\\.");
debug("Remapping Main-Class attribute in MANIFEST.MF from '{}' to '{}'", mainClass, mappedName);
attr.putValue("Main-Class", mappedName);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
manifest.write(outputStream);
primary.getFiles().put("META-INF/MANIFEST.MF", outputStream.toByteArray());
outputStream.close();
debug("Remapped manifest");
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/me/coley/recaf/config/ConfDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ public class ConfDisplay extends Config {
@Conf("display.maxtreedepth")
public int maxTreeDepth = 30;

/**
* Displays access flags tooltip for class/field/method icons
*/
@Conf("display.accessflags")
public boolean accessFlagsTooltip = true;

ConfDisplay() {
super("display");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,6 @@ public void updateItem(Integer item, boolean empty) {
setGraphic(null);
} else {
setGraphic(UiUtil.createFieldGraphic(item));
setTooltip(new Tooltip(AccessFlag.getApplicableFlags(AccessFlag.Type.FIELD).stream()
.filter(flag -> (flag.getMask() & item) == flag.getMask())
.map(AccessFlag::getName)
.collect(Collectors.joining(", "))));
}
}
});
Expand Down Expand Up @@ -316,10 +312,6 @@ public void updateItem(Integer item, boolean empty) {
setGraphic(null);
} else {
setGraphic(UiUtil.createMethodGraphic(item));
setTooltip(new Tooltip(AccessFlag.getApplicableFlags(AccessFlag.Type.METHOD).stream()
.filter(flag -> (flag.getMask() & item) == flag.getMask())
.map(AccessFlag::getName)
.collect(Collectors.joining(", "))));
}
}
});
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/me/coley/recaf/util/UiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import javafx.scene.image.WritableImage;
import javafx.scene.paint.Color;
import javafx.util.Duration;
import me.coley.recaf.Recaf;
import me.coley.recaf.ui.controls.IconView;
import me.coley.recaf.workspace.*;

Expand Down Expand Up @@ -192,14 +191,13 @@ private static void createAccessToolTips(Node node, AccessFlag.Type type, int ac
Set<String> accessFlags = AccessFlag.getApplicableFlags(type, access).stream()
.map(AccessFlag::getName).collect(Collectors.toSet());
Tooltip tooltip = new Tooltip(String.join(", ", accessFlags));
// Show tooltip instantly, Tooltip.install(node, tooltip) has a significant delay
node.setOnMouseEntered(event -> {
if (!tooltip.getText().isEmpty() && Recaf.getController().config().display().accessFlagsTooltip) {
tooltip.show(node, event.getScreenX(), event.getScreenY() + 15);
if (!tooltip.getText().isEmpty()) {
tooltip.show(node, event.getScreenX() + 10, event.getScreenY() + 1);
}
});
node.setOnMouseExited(event -> tooltip.hide());
// This has a weird delay
// Tooltip.install(node, tooltip);
}

/**
Expand Down

0 comments on commit 7378b39

Please sign in to comment.