From c6d611836c0c778b3d5475561ce02a7705d1626f Mon Sep 17 00:00:00 2001 From: ME1312 Date: Tue, 2 Jul 2019 00:11:10 -0400 Subject: [PATCH] Add display scaling to SubServers.Console --- SubServers.Bungee/pom.xml | 7 +- SubServers.Client/Bukkit/pom.xml | 4 +- SubServers.Client/Sponge/pom.xml | 4 +- SubServers.Console/pom.xml | 4 +- .../SubServers/Console/ConsoleWindow.form | 3 + .../SubServers/Console/ConsoleWindow.java | 66 ++++++++++++++----- SubServers.Host/pom.xml | 5 +- SubServers.Sync/pom.xml | 7 +- 8 files changed, 76 insertions(+), 24 deletions(-) diff --git a/SubServers.Bungee/pom.xml b/SubServers.Bungee/pom.xml index 3b848b25..1177c849 100644 --- a/SubServers.Bungee/pom.xml +++ b/SubServers.Bungee/pom.xml @@ -30,13 +30,14 @@ net.ME1312.Galaxi GalaxiUtil - 19w26a + 19w27b compile + true net.ME1312.Galaxi GalaxiEngine - 19w26a + 19w27b provided @@ -44,12 +45,14 @@ Server 19w26a compile + true com.dosse.upnp WaifUPnP 1.1 compile + true com.imaginarycode.minecraft diff --git a/SubServers.Client/Bukkit/pom.xml b/SubServers.Client/Bukkit/pom.xml index 2ae3a3a4..7c936fc5 100644 --- a/SubServers.Client/Bukkit/pom.xml +++ b/SubServers.Client/Bukkit/pom.xml @@ -48,14 +48,16 @@ net.ME1312.Galaxi GalaxiUtil - 19w26a + 19w27b compile + true net.ME1312.SubData Client 19w26a compile + true io.puharesource.mc diff --git a/SubServers.Client/Sponge/pom.xml b/SubServers.Client/Sponge/pom.xml index 20ec2ed6..63bd9e08 100644 --- a/SubServers.Client/Sponge/pom.xml +++ b/SubServers.Client/Sponge/pom.xml @@ -30,14 +30,16 @@ net.ME1312.Galaxi GalaxiUtil - 19w26a + 19w27b compile + true net.ME1312.SubData Client 19w26a compile + true diff --git a/SubServers.Console/pom.xml b/SubServers.Console/pom.xml index a8e18bb5..6e4bdf13 100644 --- a/SubServers.Console/pom.xml +++ b/SubServers.Console/pom.xml @@ -21,14 +21,14 @@ org.fusesource.jansi jansi 1.17.1 - compile - true + provided com.intellij forms_rt 7.0.3 compile + true net.md_5 diff --git a/SubServers.Console/src/net/ME1312/SubServers/Console/ConsoleWindow.form b/SubServers.Console/src/net/ME1312/SubServers/Console/ConsoleWindow.form index d2acfbec..307b7efc 100644 --- a/SubServers.Console/src/net/ME1312/SubServers/Console/ConsoleWindow.form +++ b/SubServers.Console/src/net/ME1312/SubServers/Console/ConsoleWindow.form @@ -115,6 +115,7 @@ + @@ -128,6 +129,7 @@ + @@ -141,6 +143,7 @@ + diff --git a/SubServers.Console/src/net/ME1312/SubServers/Console/ConsoleWindow.java b/SubServers.Console/src/net/ME1312/SubServers/Console/ConsoleWindow.java index 6ec41a14..988f286e 100644 --- a/SubServers.Console/src/net/ME1312/SubServers/Console/ConsoleWindow.java +++ b/SubServers.Console/src/net/ME1312/SubServers/Console/ConsoleWindow.java @@ -31,6 +31,7 @@ public final class ConsoleWindow implements SubLogFilter { private static final String RESET_VALUE = "\n\u00A0\n\u00A0"; private ConsolePlugin plugin; private JFrame window; + private double scale = 1.0; private JPanel panel; private JTextField input; private boolean ifocus = false; @@ -50,7 +51,7 @@ public final class ConsoleWindow implements SubLogFilter { private boolean running = true; private LinkedList messages = new LinkedList(); private SubLogger logger; - private int fontSize = 12; + private int fontSize; private File file = null; private FileOutputStream filewriter = null; private List spost = new LinkedList(); @@ -130,6 +131,24 @@ public final class ConsoleWindow implements SubLogFilter { findO = 0; } break; + case KeyEvent.VK_F: + if (kpressed[KeyEvent.VK_SHIFT] == Boolean.TRUE) { + boolean open = false; + if (ifocus) { + findT.setText(input.getSelectedText()); + open = true; + } else if (log.hasFocus()) { + findT.setText(log.getSelectedText()); + open = true; + } + if (open) { + findI = 0; + findO = 0; + ConsoleWindow.this.find.setVisible(true); + ConsoleWindow.this.find(true); + } + } + break; case KeyEvent.VK_ENTER: if (find.isVisible() && !ifocus) ConsoleWindow.this.find(kpressed[KeyEvent.VK_SHIFT] != Boolean.TRUE); @@ -157,6 +176,14 @@ public final class ConsoleWindow implements SubLogFilter { } window = new JFrame(); + Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + if (Float.parseFloat(System.getProperty("java.class.version")) < 53.0) { // Automatic scaling for Java 8 + if (screen.getWidth() < screen.getHeight()) { + if (screen.getWidth() > 1920) scale = screen.getWidth() / 1920; + } else { + if (screen.getHeight() > 1080) scale = screen.getHeight() / 1080; + } + } JMenuBar jMenu = new JMenuBar(); JMenu menu = new JMenu("\u00A0Log\u00A0"); @@ -298,7 +325,7 @@ public final class ConsoleWindow implements SubLogFilter { @Override public void actionPerformed(ActionEvent event) { HTMLDocument doc = (HTMLDocument) log.getDocument(); - fontSize = 12; + fontSize = (int) (12 * scale); doc.getStyleSheet().addRule("body {font-size: " + fontSize + ";}\n"); ConsoleWindow.this.hScroll(); } @@ -310,7 +337,7 @@ public final class ConsoleWindow implements SubLogFilter { @Override public void actionPerformed(ActionEvent event) { HTMLDocument doc = (HTMLDocument) log.getDocument(); - fontSize += 2; + fontSize += 2 * scale; doc.getStyleSheet().addRule("body {font-size: " + fontSize + ";}\n"); ConsoleWindow.this.hScroll(); } @@ -322,7 +349,7 @@ public final class ConsoleWindow implements SubLogFilter { @Override public void actionPerformed(ActionEvent event) { HTMLDocument doc = (HTMLDocument) log.getDocument(); - fontSize -= 2; + fontSize -= 2 * scale; doc.getStyleSheet().addRule("body {font-size: " + fontSize + ";}\n"); ConsoleWindow.this.hScroll(); } @@ -341,10 +368,11 @@ public final class ConsoleWindow implements SubLogFilter { }); window.setTitle(logger.getName() + " \u2014 SubServers 2"); window.setSize(1024, 576); - Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); - int x = (int) ((dimension.getWidth() - window.getWidth()) / 2); - int y = (int) ((dimension.getHeight() - window.getHeight()) / 2); - window.setLocation(x, y); + window.setSize((int) (1024 * scale), (int) (576 * scale)); + window.setLocation( + (int) ((screen.getWidth() - window.getWidth()) / 2), + (int) ((screen.getHeight() - window.getHeight()) / 2) + ); window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); window.addWindowListener(new WindowAdapter() { @Override @@ -363,16 +391,17 @@ public final class ConsoleWindow implements SubLogFilter { log.setContentType("text/html"); log.setEditorKit(new HTMLEditorKit()); StyleSheet style = new StyleSheet(); + fontSize = (int) (12 * scale); String font; try { Font f = Font.createFont(Font.TRUETYPE_FONT, ConsoleWindow.class.getResourceAsStream("/net/ME1312/SubServers/Console/ConsoleFont.ttf")); GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(f); font = f.getFontName(); - input.setFont(f.deriveFont(14f)); + input.setFont(f.deriveFont((float) (14 * scale))); } catch (Exception e) { font = "Courier"; } - style.addRule("body {color: #dcdcdc; font-family: " + font + "; font-size: 12;}\n"); + style.addRule("body {color: #dcdcdc; font-family: " + font + "; font-size: " + fontSize + ";}\n"); log.setDocument(new HTMLDocument(style)); log.setBorder(BorderFactory.createLineBorder(new Color(40, 44, 45))); new TextFieldPopup(log, false); @@ -398,7 +427,9 @@ public final class ConsoleWindow implements SubLogFilter { popup = new TextFieldPopup(input, true); - input.setBorder(BorderFactory.createLineBorder(new Color(40, 44, 45), 4)); + input.setFont(input.getFont().deriveFont((float) (14 * scale))); + input.getPreferredSize().setSize(input.getPreferredSize().getWidth(), input.getPreferredSize().getHeight() * scale); + input.setBorder(BorderFactory.createLineBorder(new Color(40, 44, 45), (int) (4 * scale))); input.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @@ -487,7 +518,9 @@ public final class ConsoleWindow implements SubLogFilter { }); new TextFieldPopup(findT, false); - findT.setBorder(BorderFactory.createLineBorder(new Color(40, 44, 45), 4)); + findT.setFont(findT.getFont().deriveFont((float) (findT.getFont().getSize() * scale))); + findT.getPreferredSize().setSize(findT.getPreferredSize().getWidth(), findT.getPreferredSize().getHeight() * scale); + findT.setBorder(BorderFactory.createLineBorder(new Color(40, 44, 45), (int) (4 * scale))); ((AbstractDocument) findT.getDocument()).setDocumentFilter(new DocumentFilter() { @Override public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException { @@ -510,6 +543,7 @@ public final class ConsoleWindow implements SubLogFilter { findO = 0; } }); + findP.setFont(findP.getFont().deriveFont((float) (findP.getFont().getSize() * scale))); findP.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -517,7 +551,8 @@ public final class ConsoleWindow implements SubLogFilter { else findP.setBackground(new Color(69, 73, 74)); } }); - findP.setBorder(new ButtonBorder(40, 44, 45, 4)); + findP.setBorder(new ButtonBorder(40, 44, 45, (int) (4 * scale))); + findN.setFont(findN.getFont().deriveFont((float) (findN.getFont().getSize() * scale))); findP.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @@ -531,13 +566,14 @@ public final class ConsoleWindow implements SubLogFilter { else findN.setBackground(new Color(69, 73, 74)); } }); - findN.setBorder(new ButtonBorder(40, 44, 45, 4)); + findN.setBorder(new ButtonBorder(40, 44, 45, (int) (4 * scale))); findN.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { ConsoleWindow.this.find(true); } }); + findD.setFont(findD.getFont().deriveFont((float) (findD.getFont().getSize() * scale))); findD.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -545,7 +581,7 @@ public final class ConsoleWindow implements SubLogFilter { else findD.setBackground(new Color(69, 73, 74)); } }); - findD.setBorder(new ButtonBorder(40, 44, 45, 4)); + findD.setBorder(new ButtonBorder(40, 44, 45, (int) (4 * scale))); findD.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { diff --git a/SubServers.Host/pom.xml b/SubServers.Host/pom.xml index cce314d0..f6a81315 100644 --- a/SubServers.Host/pom.xml +++ b/SubServers.Host/pom.xml @@ -20,20 +20,23 @@ net.ME1312.Galaxi GalaxiEngine - 19w26a + 19w27b compile + true net.ME1312.SubData Client 19w26a compile + true com.dosse.upnp WaifUPnP 1.1 compile + true diff --git a/SubServers.Sync/pom.xml b/SubServers.Sync/pom.xml index 45127c96..0ba6f4e4 100644 --- a/SubServers.Sync/pom.xml +++ b/SubServers.Sync/pom.xml @@ -30,13 +30,14 @@ net.ME1312.Galaxi GalaxiUtil - 19w26a + 19w27b compile + true net.ME1312.Galaxi GalaxiEngine - 19w26a + 19w27b provided @@ -44,12 +45,14 @@ Client 19w26a compile + true com.dosse.upnp WaifUPnP 1.1 compile + true com.imaginarycode.minecraft