From da5b66152b55fd9cada17248f7ee2d1d1751cc26 Mon Sep 17 00:00:00 2001 From: ix0rai Date: Sun, 3 Dec 2023 17:44:41 -0600 Subject: [PATCH] check the style --- .../enigma/gui/config/DockerConfig.java | 1 - .../enigma/gui/config/theme/Theme.java | 59 +++++++++---------- .../quiltmc/enigma/gui/dialog/FontDialog.java | 7 ++- .../org/quiltmc/enigma/gui/docker/Docker.java | 2 + .../quiltmc/enigma/gui/util/ScaleUtil.java | 5 +- 5 files changed, 38 insertions(+), 36 deletions(-) diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/DockerConfig.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/DockerConfig.java index ac1067549..9c86dd2c1 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/DockerConfig.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/DockerConfig.java @@ -5,7 +5,6 @@ import org.quiltmc.config.api.values.ValueMap; import org.quiltmc.enigma.gui.docker.AllClassesDocker; import org.quiltmc.enigma.gui.docker.CallsTreeDocker; -import org.quiltmc.enigma.gui.docker.ClassesDocker; import org.quiltmc.enigma.gui.docker.CollabDocker; import org.quiltmc.enigma.gui.docker.DeobfuscatedClassesDocker; import org.quiltmc.enigma.gui.docker.Docker; diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/theme/Theme.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/theme/Theme.java index 1600c9d15..df8a9f3e2 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/theme/Theme.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/config/theme/Theme.java @@ -5,7 +5,6 @@ import org.quiltmc.config.api.values.ConfigSerializableObject; import org.quiltmc.config.api.values.TrackedValue; import org.quiltmc.config.api.values.ValueMap; -import org.quiltmc.enigma.gui.util.ScaleUtil; import java.awt.Color; import java.awt.Font; @@ -20,11 +19,11 @@ public Theme(LookAndFeel lookAndFeel) { public final Fonts fonts = new Fonts(); public static class Fonts extends ReflectiveConfig.Section { - public final TrackedValue defaultFont = this.value(new SerializableFont(Font.decode(Font.DIALOG).deriveFont(Font.BOLD))); - public final TrackedValue small = this.value(new SerializableFont(Font.decode(Font.DIALOG))); - public final TrackedValue editor = this.value(new SerializableFont(Font.decode(Font.MONOSPACED))); + public final TrackedValue defaultFont = this.value(new SerializableFont(Font.decode(Font.DIALOG).deriveFont(Font.BOLD))); + public final TrackedValue small = this.value(new SerializableFont(Font.decode(Font.DIALOG))); + public final TrackedValue editor = this.value(new SerializableFont(Font.decode(Font.MONOSPACED))); - private static class SerializableFont extends Font implements ConfigSerializableObject> { + public static class SerializableFont extends Font implements ConfigSerializableObject> { public SerializableFont(Font font) { this(font.getName(), font.getStyle(), font.getSize()); } @@ -59,41 +58,41 @@ public ComplexConfigValue copy() { } public static class Colors extends ReflectiveConfig.Section { - public final TrackedValue lineNumbersForeground = this.value(new SerializableColor(0xFF333300)); - public final TrackedValue lineNumbersBackground = this.value(new SerializableColor(0xFFEEEEFF)); - public final TrackedValue lineNumbersSelected = this.value(new SerializableColor(0xFFCCCCEE)); + public final TrackedValue lineNumbersForeground = this.value(new SerializableColor(0xFF333300)); + public final TrackedValue lineNumbersBackground = this.value(new SerializableColor(0xFFEEEEFF)); + public final TrackedValue lineNumbersSelected = this.value(new SerializableColor(0xFFCCCCEE)); - public final TrackedValue obfuscated = this.value(new SerializableColor(0xFFFFDCDC)); - public final TrackedValue obfuscatedOutline = this.value(new SerializableColor(0xFFA05050)); + public final TrackedValue obfuscated = this.value(new SerializableColor(0xFFFFDCDC)); + public final TrackedValue obfuscatedOutline = this.value(new SerializableColor(0xFFA05050)); - public final TrackedValue proposed = this.value(new SerializableColor(0xFF000000)); - public final TrackedValue proposedOutline = this.value(new SerializableColor(0xBF000000)); + public final TrackedValue proposed = this.value(new SerializableColor(0xFF000000)); + public final TrackedValue proposedOutline = this.value(new SerializableColor(0xBF000000)); - public final TrackedValue deobfuscated = this.value(new SerializableColor(0xFFDCFFDC)); - public final TrackedValue deobfuscatedOutline = this.value(new SerializableColor(0xFF50A050)); + public final TrackedValue deobfuscated = this.value(new SerializableColor(0xFFDCFFDC)); + public final TrackedValue deobfuscatedOutline = this.value(new SerializableColor(0xFF50A050)); - public final TrackedValue editorBackground = this.value(new SerializableColor(0xFF50A050)); - public final TrackedValue highlight = this.value(new SerializableColor(0xFF50A050)); - public final TrackedValue caret = this.value(new SerializableColor(0xFF50A050)); - public final TrackedValue selectionHighlight = this.value(new SerializableColor(0xFF50A050)); - public final TrackedValue string = this.value(new SerializableColor(0xFFCC6600)); - public final TrackedValue number = this.value(new SerializableColor(0xFF999933)); - public final TrackedValue operator = this.value(new SerializableColor(0xFF000000)); - public final TrackedValue delimiter = this.value(new SerializableColor(0xFF000000)); - public final TrackedValue type = this.value(new SerializableColor(0xFF000000)); - public final TrackedValue identifier = this.value(new SerializableColor(0xFF000000)); - public final TrackedValue comment = this.value(new SerializableColor(0xFF339933)); - public final TrackedValue text = this.value(new SerializableColor(0xFF000000)); + public final TrackedValue editorBackground = this.value(new SerializableColor(0xFF50A050)); + public final TrackedValue highlight = this.value(new SerializableColor(0xFF50A050)); + public final TrackedValue caret = this.value(new SerializableColor(0xFF50A050)); + public final TrackedValue selectionHighlight = this.value(new SerializableColor(0xFF50A050)); + public final TrackedValue string = this.value(new SerializableColor(0xFFCC6600)); + public final TrackedValue number = this.value(new SerializableColor(0xFF999933)); + public final TrackedValue operator = this.value(new SerializableColor(0xFF000000)); + public final TrackedValue delimiter = this.value(new SerializableColor(0xFF000000)); + public final TrackedValue type = this.value(new SerializableColor(0xFF000000)); + public final TrackedValue identifier = this.value(new SerializableColor(0xFF000000)); + public final TrackedValue comment = this.value(new SerializableColor(0xFF339933)); + public final TrackedValue text = this.value(new SerializableColor(0xFF000000)); - public final TrackedValue debugToken = this.value(new SerializableColor(0xFFD9BEF9)); - public final TrackedValue debugTokenOutline = this.value(new SerializableColor(0xFFBD93F9)); + public final TrackedValue debugToken = this.value(new SerializableColor(0xFFD9BEF9)); + public final TrackedValue debugTokenOutline = this.value(new SerializableColor(0xFFBD93F9)); - public final TrackedValue dockHighlight = this.value(new SerializableColor(0xFF0000FF)); + public final TrackedValue dockHighlight = this.value(new SerializableColor(0xFF0000FF)); private static class SerializableColor extends Color implements ConfigSerializableObject { private final int rgba; - public SerializableColor(int rgba) { + SerializableColor(int rgba) { super(rgba, true); this.rgba = rgba; } diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/dialog/FontDialog.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/dialog/FontDialog.java index b8b283a64..3e72bf1e1 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/dialog/FontDialog.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/dialog/FontDialog.java @@ -2,6 +2,7 @@ import org.quiltmc.config.api.values.TrackedValue; import org.quiltmc.enigma.gui.config.Config; +import org.quiltmc.enigma.gui.config.theme.Theme; import org.quiltmc.enigma.gui.util.GridBagConstraintsBuilder; import org.quiltmc.enigma.gui.util.ScaleUtil; import org.quiltmc.enigma.util.I18n; @@ -20,7 +21,7 @@ import javax.swing.JList; public class FontDialog extends JDialog { - private static final List> FONTS = List.of( + private static final List> FONTS = List.of( Config.currentFonts().defaultFont, Config.currentFonts().small, Config.currentFonts().editor @@ -35,7 +36,7 @@ public class FontDialog extends JDialog { private final JList entries = new JList<>(CATEGORY_TEXTS.stream().map(I18n::translate).toArray(String[]::new)); private final FontChooser chooser = new FontChooser(Font.decode(Font.DIALOG)); private final JCheckBox customCheckBox = new JCheckBox(I18n.translate("fonts.use_custom")); - private final Font[] fontValues = new Font[]{FONTS.get(0).value(), FONTS.get(1).value(), FONTS.get(2).value()}; + private final Theme.Fonts.SerializableFont[] fontValues = new Theme.Fonts.SerializableFont[]{FONTS.get(0).value(), FONTS.get(1).value(), FONTS.get(2).value()}; public FontDialog(Frame owner) { super(owner, "Fonts", true); @@ -85,7 +86,7 @@ private void categoryChanged() { private void selectedFontChanged() { int selectedIndex = this.entries.getSelectedIndex(); if (selectedIndex != -1) { - this.fontValues[selectedIndex] = this.chooser.getSelectedFont(); + this.fontValues[selectedIndex] = new Theme.Fonts.SerializableFont(this.chooser.getSelectedFont()); } } diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/docker/Docker.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/docker/Docker.java index 8696c2bce..a41d5d8c3 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/docker/Docker.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/docker/Docker.java @@ -130,6 +130,7 @@ public ComplexConfigValue copy() { /** * Represents the side of the screen a docker is located on. + * @implNote these names cannot be changed without breaking configurations */ public enum Side { LEFT, @@ -138,6 +139,7 @@ public enum Side { /** * Represents the occupied vertical location of a docker. + * @implNote these names cannot be changed without breaking configurations */ public enum VerticalLocation { TOP, diff --git a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/util/ScaleUtil.java b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/util/ScaleUtil.java index 9916e2e9d..fed605a1d 100644 --- a/enigma-swing/src/main/java/org/quiltmc/enigma/gui/util/ScaleUtil.java +++ b/enigma-swing/src/main/java/org/quiltmc/enigma/gui/util/ScaleUtil.java @@ -7,6 +7,7 @@ import com.github.swingdpi.plaf.WindowsTweaker; import org.quiltmc.config.api.values.TrackedValue; import org.quiltmc.enigma.gui.config.Config; +import org.quiltmc.enigma.gui.config.theme.Theme; import org.quiltmc.syntaxpain.SyntaxpainConfiguration; import java.awt.Dimension; @@ -55,8 +56,8 @@ public static Font scaleFont(Font font) { return createTweakerForCurrentLook(Config.get().scaleFactor.value()).modifyFont("", font); } - private static void rescaleFontInConfig(TrackedValue font, float oldScale) { - font.setValue(rescaleFont(font.value(), oldScale), true); + private static void rescaleFontInConfig(TrackedValue font, float oldScale) { + font.setValue(new Theme.Fonts.SerializableFont(rescaleFont(font.value(), oldScale)), true); } // This does not use the font that's currently active in the UI!