Skip to content

Commit

Permalink
strip out some pointless laf stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed Dec 10, 2023
1 parent 4f89d55 commit 24d83b7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 46 deletions.
2 changes: 1 addition & 1 deletion enigma-swing/src/main/java/org/quiltmc/enigma/gui/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public Gui(EnigmaProfile profile, Set<EditableType> editableTypes, boolean visib
this.setupUi();

LanguageUtil.addListener(this::retranslateUi);
Themes.addListener((lookAndFeel, boxHighlightPainters) -> SwingUtilities.updateComponentTreeUI(this.getFrame()));
//Themes.addListener((lookAndFeel, boxHighlightPainters) -> SwingUtilities.updateComponentTreeUI(this.getFrame()));

this.mainWindow.setVisible(visible);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public static DecompilerConfig decompiler() {

public static Theme currentTheme() {
return switch (activeLookAndFeel) {
case DEFAULT -> MAIN.defaultTheme;
case DARCULA -> MAIN.darculaTheme;
case METAL -> MAIN.metalTheme;
case SYSTEM -> MAIN.systemTheme;
case NONE -> MAIN.noneTheme;
case DEFAULT -> main().defaultTheme;
case DARCULA -> main().darculaTheme;
case METAL -> main().metalTheme;
case SYSTEM -> main().systemTheme;
case NONE -> main().noneTheme;
};
}

Expand All @@ -114,11 +114,11 @@ public static Theme.Fonts currentFonts() {
}

public static void insertRecentProject(String jarPath, String mappingsPath) {
MAIN.recentProjects.value().add(0, new RecentProject(jarPath, mappingsPath));
main().recentProjects.value().add(0, new RecentProject(jarPath, mappingsPath));
}

public static RecentProject getMostRecentProject() {
return MAIN.recentProjects.value().get(0);
return main().recentProjects.value().get(0);
}

public record RecentProject(String jarPath, String mappingsPath) implements ConfigSerializableObject<ValueMap<String>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import javax.swing.UIManager;

public class Themes {
private static final Set<ThemeChangeListener> listeners = new HashSet<>();

// Calling this after the UI is initialized (e.g. when the user changes
// theme settings) is currently not functional.
public static void setupTheme() {
Expand All @@ -27,8 +25,6 @@ public static void setupTheme() {
Themes.setFonts();
UIManager.put("ScrollBar.showButtons", true);
JEditorPane.registerEditorKitForContentType("text/enigma-sources", JavaSyntaxKit.class.getName());
Map<TokenType, BoxHighlightPainter> boxHighlightPainters = getBoxHighlightPainters();
listeners.forEach(l -> l.onThemeChanged(laf, boxHighlightPainters));
ScaleUtil.applyScaling();
Config.updateSyntaxpain();
}
Expand Down Expand Up @@ -88,12 +84,4 @@ public static Map<TokenType, BoxHighlightPainter> getBoxHighlightPainters() {
TokenType.DEBUG, BoxHighlightPainter.create(Config.currentColors().debugToken.value(), Config.currentColors().debugTokenOutline.value())
);
}

public static void addListener(ThemeChangeListener listener) {
listeners.add(listener);
}

public static void removeListener(ThemeChangeListener listener) {
listeners.remove(listener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public EditorPanel openClass(ClassEntry entry) {
if (ch == null) return null;
this.navigator = new NavigatorPanel(this.gui);
EditorPanel ed = new EditorPanel(this.gui, this.navigator);
ed.setup();
ed.setClassHandle(ch);
this.openFiles.addTab(ed.getFileName(), ed.getUi());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
import org.quiltmc.enigma.gui.EditableType;
import org.quiltmc.enigma.gui.Gui;
import org.quiltmc.enigma.gui.GuiController;
import org.quiltmc.enigma.gui.config.theme.LookAndFeel;
import org.quiltmc.enigma.gui.config.theme.Themes;
import org.quiltmc.enigma.gui.config.Config;
import org.quiltmc.enigma.gui.config.keybind.KeyBinds;
import org.quiltmc.enigma.gui.element.EditorPopupMenu;
import org.quiltmc.enigma.gui.element.NavigatorPanel;
import org.quiltmc.enigma.gui.event.EditorActionListener;
import org.quiltmc.enigma.gui.event.ThemeChangeListener;
import org.quiltmc.enigma.gui.highlight.BoxHighlightPainter;
import org.quiltmc.enigma.gui.highlight.SelectionHighlightPainter;
import org.quiltmc.enigma.gui.util.GridBagConstraintsBuilder;
Expand Down Expand Up @@ -97,14 +95,11 @@ public class EditorPanel {
private boolean mouseIsPressed = false;
private boolean shouldNavigateOnClick;

public LookAndFeel editorLaf;
private int fontSize = 12;
private Map<TokenType, BoxHighlightPainter> boxHighlightPainters;
private final Map<TokenType, BoxHighlightPainter> boxHighlightPainters;

private final List<EditorActionListener> listeners = new ArrayList<>();

private final ThemeChangeListener themeChangeListener;

private ClassHandle classHandle;
private DecompiledClassSource source;
private boolean settingSource;
Expand Down Expand Up @@ -210,20 +205,6 @@ public void keyReleased(KeyEvent event) {

this.retryButton.addActionListener(e -> this.redecompileClass());

this.themeChangeListener = (laf, boxHighlightPainters) -> {
if ((this.editorLaf == null || this.editorLaf != laf)) {
this.editor.updateUI();
this.editor.setBackground(Config.currentColors().editorBackground.value());
if (this.editorLaf != null) {
this.classHandle.invalidateMapped();
}

this.editorLaf = laf;
}

this.boxHighlightPainters = boxHighlightPainters;
};

this.ui.putClientProperty(EditorPanel.class, this);
}

Expand Down Expand Up @@ -289,12 +270,7 @@ public void onDeleted(ClassHandle h) {
this.listeners.forEach(l -> l.onClassHandleChanged(this, old, handle));
}

public void setup() {
Themes.addListener(this.themeChangeListener);
}

public void destroy() {
Themes.removeListener(this.themeChangeListener);
this.classHandle.close();
}

Expand Down

0 comments on commit 24d83b7

Please sign in to comment.