summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui/Gui.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/Gui.java')
-rw-r--r--src/main/java/cuchaz/enigma/gui/Gui.java48
1 files changed, 26 insertions, 22 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java
index ee8fbdf..8f0d6fa 100644
--- a/src/main/java/cuchaz/enigma/gui/Gui.java
+++ b/src/main/java/cuchaz/enigma/gui/Gui.java
@@ -11,6 +11,18 @@
11 11
12package cuchaz.enigma.gui; 12package cuchaz.enigma.gui;
13 13
14import java.awt.*;
15import java.awt.event.*;
16import java.nio.file.Path;
17import java.util.List;
18import java.util.*;
19import java.util.function.Function;
20
21import javax.swing.*;
22import javax.swing.text.BadLocationException;
23import javax.swing.text.Highlighter;
24import javax.swing.tree.*;
25
14import com.google.common.base.Strings; 26import com.google.common.base.Strings;
15import com.google.common.collect.Lists; 27import com.google.common.collect.Lists;
16import cuchaz.enigma.Constants; 28import cuchaz.enigma.Constants;
@@ -37,20 +49,10 @@ import cuchaz.enigma.throwables.IllegalNameException;
37import cuchaz.enigma.translation.mapping.*; 49import cuchaz.enigma.translation.mapping.*;
38import cuchaz.enigma.translation.representation.entry.*; 50import cuchaz.enigma.translation.representation.entry.*;
39import cuchaz.enigma.utils.I18n; 51import cuchaz.enigma.utils.I18n;
52import cuchaz.enigma.gui.util.ScaleUtil;
40import cuchaz.enigma.utils.Utils; 53import cuchaz.enigma.utils.Utils;
41import de.sciss.syntaxpane.DefaultSyntaxKit; 54import de.sciss.syntaxpane.DefaultSyntaxKit;
42 55
43import javax.swing.*;
44import javax.swing.text.BadLocationException;
45import javax.swing.text.Highlighter;
46import javax.swing.tree.*;
47import java.awt.*;
48import java.awt.event.*;
49import java.nio.file.Path;
50import java.util.List;
51import java.util.*;
52import java.util.function.Function;
53
54public class Gui { 56public class Gui {
55 57
56 public final PopupMenuBar popupMenu; 58 public final PopupMenuBar popupMenu;
@@ -119,6 +121,8 @@ public class Gui {
119 121
120 this.controller = new GuiController(this, profile); 122 this.controller = new GuiController(this, profile);
121 123
124 Themes.updateTheme(this);
125
122 // init file choosers 126 // init file choosers
123 this.jarFileChooser = new FileDialog(getFrame(), I18n.translate("menu.file.jar.open"), FileDialog.LOAD); 127 this.jarFileChooser = new FileDialog(getFrame(), I18n.translate("menu.file.jar.open"), FileDialog.LOAD);
124 128
@@ -135,14 +139,13 @@ public class Gui {
135 splitClasses.setResizeWeight(0.3); 139 splitClasses.setResizeWeight(0.3);
136 this.classesPanel = new JPanel(); 140 this.classesPanel = new JPanel();
137 this.classesPanel.setLayout(new BorderLayout()); 141 this.classesPanel.setLayout(new BorderLayout());
138 this.classesPanel.setPreferredSize(new Dimension(250, 0)); 142 this.classesPanel.setPreferredSize(ScaleUtil.getDimension(250, 0));
139 143
140 // init info panel 144 // init info panel
141 infoPanel = new PanelIdentifier(this); 145 infoPanel = new PanelIdentifier(this);
142 infoPanel.clearReference(); 146 infoPanel.clearReference();
143 147
144 // init editor 148 // init editor
145 Themes.updateTheme(this);
146 selectionHighlightPainter = new SelectionHighlightPainter(); 149 selectionHighlightPainter = new SelectionHighlightPainter();
147 this.editor = new PanelEditor(this); 150 this.editor = new PanelEditor(this);
148 JScrollPane sourceScroller = new JScrollPane(this.editor); 151 JScrollPane sourceScroller = new JScrollPane(this.editor);
@@ -257,8 +260,8 @@ public class Gui {
257 } 260 }
258 } 261 }
259 }); 262 });
260 tokens.setPreferredSize(new Dimension(0, 200)); 263 tokens.setPreferredSize(ScaleUtil.getDimension(0, 200));
261 tokens.setMinimumSize(new Dimension(0, 200)); 264 tokens.setMinimumSize(ScaleUtil.getDimension(0, 200));
262 JSplitPane callPanel = new JSplitPane( 265 JSplitPane callPanel = new JSplitPane(
263 JSplitPane.VERTICAL_SPLIT, 266 JSplitPane.VERTICAL_SPLIT,
264 true, 267 true,
@@ -274,7 +277,7 @@ public class Gui {
274 centerPanel.add(infoPanel, BorderLayout.NORTH); 277 centerPanel.add(infoPanel, BorderLayout.NORTH);
275 centerPanel.add(sourceScroller, BorderLayout.CENTER); 278 centerPanel.add(sourceScroller, BorderLayout.CENTER);
276 tabs = new JTabbedPane(); 279 tabs = new JTabbedPane();
277 tabs.setPreferredSize(new Dimension(250, 0)); 280 tabs.setPreferredSize(ScaleUtil.getDimension(250, 0));
278 tabs.addTab(I18n.translate("info_panel.tree.inheritance"), inheritancePanel); 281 tabs.addTab(I18n.translate("info_panel.tree.inheritance"), inheritancePanel);
279 tabs.addTab(I18n.translate("info_panel.tree.implementations"), implementationsPanel); 282 tabs.addTab(I18n.translate("info_panel.tree.implementations"), implementationsPanel);
280 tabs.addTab(I18n.translate("info_panel.tree.calls"), callPanel); 283 tabs.addTab(I18n.translate("info_panel.tree.calls"), callPanel);
@@ -301,10 +304,11 @@ public class Gui {
301 304
302 // show the frame 305 // show the frame
303 pane.doLayout(); 306 pane.doLayout();
304 this.frame.setSize(1024, 576); 307 this.frame.setSize(ScaleUtil.getDimension(1024, 576));
305 this.frame.setMinimumSize(new Dimension(640, 480)); 308 this.frame.setMinimumSize(ScaleUtil.getDimension(640, 480));
306 this.frame.setVisible(true); 309 this.frame.setVisible(true);
307 this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 310 this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
311 this.frame.setLocationRelativeTo(null);
308 } 312 }
309 313
310 public JFrame getFrame() { 314 public JFrame getFrame() {
@@ -492,7 +496,7 @@ public class Gui {
492 panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); 496 panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0));
493 497
494 JLabel label = new JLabel(name + ":", JLabel.RIGHT); 498 JLabel label = new JLabel(name + ":", JLabel.RIGHT);
495 label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); 499 label.setPreferredSize(ScaleUtil.getDimension(100, ScaleUtil.invert(label.getPreferredSize().height)));
496 panel.add(label); 500 panel.add(label);
497 501
498 panel.add(Utils.unboldLabel(new JLabel(value, JLabel.LEFT))); 502 panel.add(Utils.unboldLabel(new JLabel(value, JLabel.LEFT)));
@@ -506,11 +510,11 @@ public class Gui {
506 JPanel panel = new JPanel(); 510 JPanel panel = new JPanel();
507 panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); 511 panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0));
508 JLabel label = new JLabel(name + ":", JLabel.RIGHT); 512 JLabel label = new JLabel(name + ":", JLabel.RIGHT);
509 label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); 513 label.setPreferredSize(ScaleUtil.getDimension(100, ScaleUtil.invert(label.getPreferredSize().height)));
510 panel.add(label); 514 panel.add(label);
511 JComboBox<AccessModifier> combo = new JComboBox<>(AccessModifier.values()); 515 JComboBox<AccessModifier> combo = new JComboBox<>(AccessModifier.values());
512 ((JLabel) combo.getRenderer()).setHorizontalAlignment(JLabel.LEFT); 516 ((JLabel) combo.getRenderer()).setHorizontalAlignment(JLabel.LEFT);
513 combo.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); 517 combo.setPreferredSize(ScaleUtil.getDimension(100, ScaleUtil.invert(label.getPreferredSize().height)));
514 518
515 EntryMapping mapping = controller.project.getMapper().getDeobfMapping(entry); 519 EntryMapping mapping = controller.project.getMapper().getDeobfMapping(entry);
516 if (mapping != null) { 520 if (mapping != null) {
@@ -628,7 +632,7 @@ public class Gui {
628 EntryReference<Entry<?>, Entry<?>> translatedReference = controller.project.getMapper().deobfuscate(cursorReference); 632 EntryReference<Entry<?>, Entry<?>> translatedReference = controller.project.getMapper().deobfuscate(cursorReference);
629 renameTextField.setText(translatedReference.getNameableName()); 633 renameTextField.setText(translatedReference.getNameableName());
630 634
631 renameTextField.setPreferredSize(new Dimension(360, renameTextField.getPreferredSize().height)); 635 renameTextField.setPreferredSize(ScaleUtil.getDimension(360, ScaleUtil.invert(renameTextField.getPreferredSize().height)));
632 renameTextField.addKeyListener(new KeyAdapter() { 636 renameTextField.addKeyListener(new KeyAdapter() {
633 @Override 637 @Override
634 public void keyPressed(KeyEvent event) { 638 public void keyPressed(KeyEvent event) {