From 43183a23022c173ce2b077e887c50c812d663ddb Mon Sep 17 00:00:00 2001 From: ceikry Date: Sat, 26 Jun 2021 14:37:20 -0500 Subject: [PATCH] Refactor launcher to address certain issues, add new close button --- src/main/java/rs09/Settings.java | 2 +- src/main/java/rs09/components/AppFrame.java | 45 +++++++++++++++----- src/main/resources/data/img/close.png | Bin 0 -> 295 bytes src/main/resources/data/img/close_hi.png | Bin 0 -> 316 bytes 4 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/data/img/close.png create mode 100644 src/main/resources/data/img/close_hi.png diff --git a/src/main/java/rs09/Settings.java b/src/main/java/rs09/Settings.java index a5842f1..cffe718 100644 --- a/src/main/java/rs09/Settings.java +++ b/src/main/java/rs09/Settings.java @@ -20,7 +20,7 @@ public class Settings { public static final boolean enableMusicPlayer = false; // Frame Settings - public static final Dimension frameSize = new Dimension(600, 350); + public static final Dimension frameSize = new Dimension(600, 300); public static final Color borderColor = new Color(0, 0, 0); public static final Color backgroundColor = new Color(158,134,94); public static final Color primaryColor = new Color(255,204,54); diff --git a/src/main/java/rs09/components/AppFrame.java b/src/main/java/rs09/components/AppFrame.java index de18d65..3d62537 100644 --- a/src/main/java/rs09/components/AppFrame.java +++ b/src/main/java/rs09/components/AppFrame.java @@ -6,10 +6,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JProgressBar; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import javax.swing.plaf.basic.BasicProgressBarUI; @@ -39,11 +36,12 @@ public class AppFrame extends JFrame { //addMenuBar(); addNewsBox(); - addWorldSelect(); + //addWorldSelect(); addLinks(); addHeader(); addPlayButton(); addProgressBar(); + addCloseButton(); setIconImage(Utils.getImage("favicon_large.png").getImage()); addMouseListener(); @@ -79,11 +77,11 @@ public class AppFrame extends JFrame { public static Control playButton = new Control("Play"); private void addPlayButton() { - playButton.setActionCommand("play1"); + playButton.setActionCommand("play2"); playButton.setBackground(Settings.primaryColor); playButton.addActionListener(new ButtonListener()); //(appWidth / 2) - (167 / 2) - playButton.setBounds(151, appHeight - 88, 100, 35); + playButton.setBounds(0, appHeight - 35, 100, 35); Utils.setFont(playButton, "OpenSans-Regular.ttf", 16); add(playButton); } @@ -101,7 +99,7 @@ public class AppFrame extends JFrame { } private void addWorldSelect() { - JLabel world1box = new JLabel(""); + /*JLabel world1box = new JLabel(""); JLabel world1text = new JLabel("World 1 - Authentic"); world1text.setBounds(20, appHeight - 80, 145,20); world1text.setForeground(Color.WHITE); @@ -111,7 +109,7 @@ public class AppFrame extends JFrame { world1box.setBackground(new Color(0.0f,0.0f,0.0f,0.2f)); add(world1box); add(world1text); - +*/ IconLabel globeIcon = new IconLabel("\uf0ac",50); globeIcon.setBounds(275,appHeight - 98,64,64); add(globeIcon); @@ -135,7 +133,7 @@ public class AppFrame extends JFrame { private void addLinks() { tooltip = new JLabel(""); - tooltip.setBounds(135, appHeight - 140, 335, 35); + tooltip.setBounds(135, appHeight - 90, 335, 35); tooltip.setHorizontalAlignment(SwingConstants.CENTER); Utils.setFont(tooltip, "OpenSans-Light.ttf", 30); tooltip.setForeground(Color.white); @@ -289,5 +287,32 @@ public class AppFrame extends JFrame { } }); } + + private void addCloseButton() { + ImageIcon close_dark = new ImageIcon(getClass().getResource("/data/img/close.png")); + ImageIcon close_hi = new ImageIcon(getClass().getResource("/data/img/close_hi.png")); + JLabel button = new JLabel(close_hi); + button.setDisabledIcon(close_dark); + button.setEnabled(false); + button.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseEvent) { + System.exit(0); + } + + @Override + public void mouseEntered(MouseEvent mouseEvent) { + button.setEnabled(true); + } + + @Override + public void mouseExited(MouseEvent mouseEvent) { + button.setEnabled(false); + } + }); + + button.setBounds(appWidth - 40, 0, 40, 40); + add(button); + } } diff --git a/src/main/resources/data/img/close.png b/src/main/resources/data/img/close.png new file mode 100644 index 0000000000000000000000000000000000000000..470ce7482c84f0d2bff7a751ed47527bffbb6f38 GIT binary patch literal 295 zcmV+?0oeYDP)-85m(=Sq5r50PwaC@qS36b&P4AgH@me1IVFVSi?z7pacWJ(+p$2<^naa z7SmxM2P2l+{48M4PPT936I@&b7ssv+E;>3msfeq8;o#>)uI0i_nxsi-;g;9D+(Vnb z_p0xGYJF7&SJ02!>o9S&oR4fSFz99Cyf*f@8vm68rjH)@TTmoE&xL*0vrcfQM>jmS zjS!zUCJ5$!4+%+ literal 0 HcmV?d00001