Skip to content

Commit

Permalink
check the style
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed Dec 3, 2023
1 parent ffc84d9 commit da5b661
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,11 +19,11 @@ public Theme(LookAndFeel lookAndFeel) {
public final Fonts fonts = new Fonts();

public static class Fonts extends ReflectiveConfig.Section {
public final TrackedValue<Font> defaultFont = this.value(new SerializableFont(Font.decode(Font.DIALOG).deriveFont(Font.BOLD)));
public final TrackedValue<Font> small = this.value(new SerializableFont(Font.decode(Font.DIALOG)));
public final TrackedValue<Font> editor = this.value(new SerializableFont(Font.decode(Font.MONOSPACED)));
public final TrackedValue<SerializableFont> defaultFont = this.value(new SerializableFont(Font.decode(Font.DIALOG).deriveFont(Font.BOLD)));
public final TrackedValue<SerializableFont> small = this.value(new SerializableFont(Font.decode(Font.DIALOG)));
public final TrackedValue<SerializableFont> editor = this.value(new SerializableFont(Font.decode(Font.MONOSPACED)));

private static class SerializableFont extends Font implements ConfigSerializableObject<ValueMap<String>> {
public static class SerializableFont extends Font implements ConfigSerializableObject<ValueMap<String>> {
public SerializableFont(Font font) {
this(font.getName(), font.getStyle(), font.getSize());
}
Expand Down Expand Up @@ -59,41 +58,41 @@ public ComplexConfigValue copy() {
}

public static class Colors extends ReflectiveConfig.Section {
public final TrackedValue<Color> lineNumbersForeground = this.value(new SerializableColor(0xFF333300));
public final TrackedValue<Color> lineNumbersBackground = this.value(new SerializableColor(0xFFEEEEFF));
public final TrackedValue<Color> lineNumbersSelected = this.value(new SerializableColor(0xFFCCCCEE));
public final TrackedValue<SerializableColor> lineNumbersForeground = this.value(new SerializableColor(0xFF333300));
public final TrackedValue<SerializableColor> lineNumbersBackground = this.value(new SerializableColor(0xFFEEEEFF));
public final TrackedValue<SerializableColor> lineNumbersSelected = this.value(new SerializableColor(0xFFCCCCEE));

public final TrackedValue<Color> obfuscated = this.value(new SerializableColor(0xFFFFDCDC));
public final TrackedValue<Color> obfuscatedOutline = this.value(new SerializableColor(0xFFA05050));
public final TrackedValue<SerializableColor> obfuscated = this.value(new SerializableColor(0xFFFFDCDC));
public final TrackedValue<SerializableColor> obfuscatedOutline = this.value(new SerializableColor(0xFFA05050));

public final TrackedValue<Color> proposed = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<Color> proposedOutline = this.value(new SerializableColor(0xBF000000));
public final TrackedValue<SerializableColor> proposed = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<SerializableColor> proposedOutline = this.value(new SerializableColor(0xBF000000));

public final TrackedValue<Color> deobfuscated = this.value(new SerializableColor(0xFFDCFFDC));
public final TrackedValue<Color> deobfuscatedOutline = this.value(new SerializableColor(0xFF50A050));
public final TrackedValue<SerializableColor> deobfuscated = this.value(new SerializableColor(0xFFDCFFDC));
public final TrackedValue<SerializableColor> deobfuscatedOutline = this.value(new SerializableColor(0xFF50A050));

public final TrackedValue<Color> editorBackground = this.value(new SerializableColor(0xFF50A050));
public final TrackedValue<Color> highlight = this.value(new SerializableColor(0xFF50A050));
public final TrackedValue<Color> caret = this.value(new SerializableColor(0xFF50A050));
public final TrackedValue<Color> selectionHighlight = this.value(new SerializableColor(0xFF50A050));
public final TrackedValue<Color> string = this.value(new SerializableColor(0xFFCC6600));
public final TrackedValue<Color> number = this.value(new SerializableColor(0xFF999933));
public final TrackedValue<Color> operator = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<Color> delimiter = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<Color> type = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<Color> identifier = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<Color> comment = this.value(new SerializableColor(0xFF339933));
public final TrackedValue<Color> text = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<SerializableColor> editorBackground = this.value(new SerializableColor(0xFF50A050));
public final TrackedValue<SerializableColor> highlight = this.value(new SerializableColor(0xFF50A050));
public final TrackedValue<SerializableColor> caret = this.value(new SerializableColor(0xFF50A050));
public final TrackedValue<SerializableColor> selectionHighlight = this.value(new SerializableColor(0xFF50A050));
public final TrackedValue<SerializableColor> string = this.value(new SerializableColor(0xFFCC6600));
public final TrackedValue<SerializableColor> number = this.value(new SerializableColor(0xFF999933));
public final TrackedValue<SerializableColor> operator = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<SerializableColor> delimiter = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<SerializableColor> type = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<SerializableColor> identifier = this.value(new SerializableColor(0xFF000000));
public final TrackedValue<SerializableColor> comment = this.value(new SerializableColor(0xFF339933));
public final TrackedValue<SerializableColor> text = this.value(new SerializableColor(0xFF000000));

public final TrackedValue<Color> debugToken = this.value(new SerializableColor(0xFFD9BEF9));
public final TrackedValue<Color> debugTokenOutline = this.value(new SerializableColor(0xFFBD93F9));
public final TrackedValue<SerializableColor> debugToken = this.value(new SerializableColor(0xFFD9BEF9));
public final TrackedValue<SerializableColor> debugTokenOutline = this.value(new SerializableColor(0xFFBD93F9));

public final TrackedValue<Color> dockHighlight = this.value(new SerializableColor(0xFF0000FF));
public final TrackedValue<SerializableColor> dockHighlight = this.value(new SerializableColor(0xFF0000FF));

private static class SerializableColor extends Color implements ConfigSerializableObject<Integer> {
private final int rgba;

public SerializableColor(int rgba) {
SerializableColor(int rgba) {
super(rgba, true);
this.rgba = rgba;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,7 +21,7 @@
import javax.swing.JList;

public class FontDialog extends JDialog {
private static final List<TrackedValue<Font>> FONTS = List.of(
private static final List<TrackedValue<Theme.Fonts.SerializableFont>> FONTS = List.of(
Config.currentFonts().defaultFont,
Config.currentFonts().small,
Config.currentFonts().editor
Expand All @@ -35,7 +36,7 @@ public class FontDialog extends JDialog {
private final JList<String> 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);
Expand Down Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,8 +56,8 @@ public static Font scaleFont(Font font) {
return createTweakerForCurrentLook(Config.get().scaleFactor.value()).modifyFont("", font);
}

private static void rescaleFontInConfig(TrackedValue<Font> font, float oldScale) {
font.setValue(rescaleFont(font.value(), oldScale), true);
private static void rescaleFontInConfig(TrackedValue<Theme.Fonts.SerializableFont> 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!
Expand Down

0 comments on commit da5b661

Please sign in to comment.