Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceWalkerRS committed Jun 5, 2023
2 parents 9de3e1d + 5649066 commit be92598
Show file tree
Hide file tree
Showing 35 changed files with 1,003 additions and 559 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ subprojects {
}

group = 'net.ornithemc'
version = '1.7.5'
version = '1.8.0'

var ENV = System.getenv()
version = version + (ENV.GITHUB_ACTIONS ? (ENV.SNAPSHOTS_URL ? "-SNAPSHOT" : "") : "+local")
Expand Down
32 changes: 0 additions & 32 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,38 +155,6 @@

<module name="OuterTypeFilename"/>
<module name="PackageDeclaration"/>
<!-- <module name="PackageName">-->
<!-- &lt;!&ndash; require a package following the following structure:-->
<!-- base package name: net.fabricmc.fabric-->
<!-- + api/implementation/mixin subpackage: api/impl/mixin-->
<!-- + client/dedicated server/common env subpackage: client/server/<nothing>-->
<!-- + module name subpackage, singular, may contain multiple .-separated parts-->
<!-- + api only: module major version with v prefix (e.g. v1)-->
<!-- + other subpackages as needed, all singular-->
<!-- The regex works as follows:-->
<!-- It matches (=succeeds) for one of these cases:-->
<!-- - net.fabricmc.fabric.api.client.<module-name>.v<version>[.<extra packages...>]-->
<!-- - net.fabricmc.fabric.api.server.<module-name>.v<version>[.<extra packages...>]-->
<!-- - net.fabricmc.fabric.api.<module-name>.v<version>[.<extra packages...>]-->
<!-- - net.fabricmc.fabric.(impl|mixin).client.<module-name>[.<extra packages...>]-->
<!-- - net.fabricmc.fabric.(impl|mixin).server.<module-name>[.<extra packages...>]-->
<!-- - net.fabricmc.fabric.(impl|mixin).<module-name>[.<extra packages...>]-->
<!-- - <any legacy package>-->
<!-- where <module-name> is a set of '.'-separated words, all in singular (not ending with s except for ss) and not starting with client. or server.-->
<!-- and <version> is a positive integer (1, 2, 3, ...)-->
<!-- and <extra packages...> is a set of '.'-separated words with all the first potentially containing digits.-->
<!-- Negative lookahead ensures that client/server can't be replaced with common disguised as the module name.-->
<!-- The regex is implemented in 3 parts:-->
<!-- - the net.fabricmc.fabric. prefix-->
<!-- - patterns for-->
<!-- - api packages: api + <not common> + client/server/nothing + <module-name> + 'v' + <version>-->
<!-- - impl+mixin packages : impl/mixin + <not common> + client/server/nothing + <module-name>-->
<!-- - literal legacy packages (exceptions)-->
<!-- - largely unconstained trailing subpackages-->
<!-- &ndash;&gt;-->
<!-- <property name="format"-->
<!-- value="^net\.fabricmc\.fabric\.(api(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+([a-rt-z]|ss))+\.v[1-9][0-9]*|(impl|mixin|test)(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+[a-rt-z])+|api\.(event|util|biomes\.v1|registry|client\.screen|container|block|entity|client\.itemgroup|client\.keybinding|tag|tools|client\.model|network|server|client\.render|resource|client\.texture))(|\.[a-z]+(\.[a-z0-9]+)*)$"/>-->
<!-- </module>-->

<!--<module name="InvalidJavadocPosition"/>-->
<module name="JavadocParagraph">
Expand Down
50 changes: 43 additions & 7 deletions enigma-swing/src/main/java/cuchaz/enigma/gui/ClassSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
import cuchaz.enigma.gui.config.keybind.KeyBinds;
import cuchaz.enigma.gui.node.ClassSelectorClassNode;
import cuchaz.enigma.gui.node.SortedMutableTreeNode;
import cuchaz.enigma.stats.StatType;
import cuchaz.enigma.gui.util.StatsManager;
import cuchaz.enigma.stats.StatsResult;
import cuchaz.enigma.gui.util.GuiUtil;
import cuchaz.enigma.translation.representation.entry.ClassEntry;
import cuchaz.enigma.utils.I18n;

import javax.annotation.Nullable;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.Component;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
Expand All @@ -27,13 +34,15 @@ public class ClassSelector extends JTree {

private final Comparator<ClassEntry> comparator;
private final GuiController controller;
private final StatsManager statsManager;

private NestedPackages packageManager;
private ClassSelectionListener selectionListener;

public ClassSelector(Gui gui, Comparator<ClassEntry> comparator) {
this.comparator = comparator;
this.controller = gui.getController();
this.statsManager = gui.getStatsManager();

// configure the tree control
this.setEditable(false);
Expand Down Expand Up @@ -80,27 +89,56 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

if (gui.getController().getProject() != null && leaf && value instanceof ClassSelectorClassNode node) {
JPanel panel = new JPanel();
class TooltipPanel extends JPanel {
@Override
public String getToolTipText(MouseEvent event) {
StringBuilder text = new StringBuilder(I18n.translateFormatted("class_selector.tooltip.stats_for", node.getDeobfEntry().getSimpleName()));
text.append("\n");
StatsResult stats = ClassSelector.this.statsManager.getStats(node);

if (stats == null) {
text.append(I18n.translate("class_selector.tooltip.stats_not_generated"));
} else {
if ((event.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0) {
for (int i = 0; i < StatType.values().length; i++) {
StatType type = StatType.values()[i];
text.append(type.getName()).append(": ").append(stats.toString(type)).append(i == StatType.values().length - 1 ? "" : "\n");
}
} else {
text.append(stats);
}
}

return text.toString();
}
}

JPanel panel = new TooltipPanel();
panel.setOpaque(false);
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(new JLabel(GuiUtil.getClassIcon(gui, node.getObfEntry())));
JLabel nodeLabel = new JLabel(GuiUtil.getClassIcon(gui, node.getObfEntry()));
panel.add(nodeLabel);

if (node.getStats() == null) {
StatsResult stats = ClassSelector.this.statsManager.getStats(node);
if (stats == null) {
// calculate stats on a separate thread for performance reasons
this.setIcon(GuiUtil.PENDING_STATUS_ICON);
node.reloadStats(gui, ClassSelector.this, false);
} else {
this.setIcon(GuiUtil.getDeobfuscationIcon(node.getStats()));
this.setIcon(GuiUtil.getDeobfuscationIcon(stats));
}

panel.add(this);

return panel;
}

return this;
}
});

ToolTipManager.sharedInstance().registerComponent(this);

// init defaults
this.selectionListener = null;
}
Expand Down Expand Up @@ -323,9 +361,7 @@ public void reload() {
* Stats will be calculated asynchronously for each entry the next time that entry is visible.
*/
public void invalidateStats() {
for (ClassEntry entry : this.packageManager.getClassEntries()) {
this.packageManager.getClassNode(entry).setStats(null);
}
this.statsManager.invalidateStats();
}

/**
Expand Down
Loading

0 comments on commit be92598

Please sign in to comment.