Browse Source

New main UI, lots of UI tweaks

master
JellySquid 3 years ago
parent
commit
edd0837a77
18 changed files with 276 additions and 86 deletions
  1. 4
    1
      .gitignore
  2. 5
    1
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/LauncherFrame.java
  3. 58
    21
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/components/FlatButton.java
  4. 1
    1
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/components/FlatProgressbar.java
  5. 65
    13
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/components/FlatTabPane.java
  6. 63
    0
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/components/UserIndicator.java
  7. 1
    8
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/panels/TitlebarPanel.java
  8. 12
    1
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/resources/AvatarCache.java
  9. 3
    0
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/resources/LauncherFonts.java
  10. 2
    1
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/resources/LauncherIcons.java
  11. 1
    1
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/resources/LauncherStyles.java
  12. 1
    11
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/views/AccountListModel.java
  13. 3
    3
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/views/AccountListView.java
  14. 5
    7
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/views/OptionsView.java
  15. 52
    17
      launcher-gg/src/main/java/com/gildedgames/launcher/ui/views/PlayView.java
  16. BIN
      launcher-gg/src/main/resources/com/gildedgames/assets/fonts/OpenSans-Bold.ttf
  17. BIN
      launcher-gg/src/main/resources/com/gildedgames/assets/icons/maximize.png
  18. BIN
      launcher-gg/src/main/resources/com/gildedgames/assets/images/background.jpg

+ 4
- 1
.gitignore View File

@@ -151,4 +151,7 @@ $RECYCLE.BIN/
151 151
 *.lnk
152 152
 
153 153
 /classes/
154
-/testing/
154
+/testing/
155
+
156
+# Windows garbage
157
+Thumbs.db

+ 5
- 1
launcher-gg/src/main/java/com/gildedgames/launcher/ui/LauncherFrame.java View File

@@ -63,7 +63,9 @@ public class LauncherFrame extends JFrame {
63 63
 		this.getContentPane().add(this.titlebar, BorderLayout.NORTH);
64 64
 		this.getContentPane().add(this.layout.getRoot(), BorderLayout.CENTER);
65 65
 
66
-		this.layout.show(new PlayView(this.launcher, this));
66
+		PlayView view = new PlayView(this.launcher, this);
67
+
68
+		this.layout.show(view);
67 69
 
68 70
 		if (this.launcher.getAccounts().getSize() <= 0) {
69 71
 			AccountAddView accountAddView = new AccountAddView(this, this.launcher);
@@ -72,6 +74,8 @@ public class LauncherFrame extends JFrame {
72 74
 				this.launcher.getAccounts().setSelectedAccount(account);
73 75
 
74 76
 				Persistence.commitAndForget(LauncherFrame.this.launcher.getAccounts());
77
+
78
+				view.updateUserIndicator(account);
75 79
 			});
76 80
 
77 81
 			this.layout.show(accountAddView);

+ 58
- 21
launcher-gg/src/main/java/com/gildedgames/launcher/ui/components/FlatButton.java View File

@@ -6,35 +6,43 @@ import lombok.Setter;
6 6
 import javax.swing.BorderFactory;
7 7
 import javax.swing.ImageIcon;
8 8
 import javax.swing.JButton;
9
+import javax.swing.SwingUtilities;
9 10
 import java.awt.*;
10 11
 import java.awt.event.MouseAdapter;
11 12
 import java.awt.event.MouseEvent;
12 13
 
13 14
 public class FlatButton extends JButton {
14 15
 	public enum ButtonStyle {
15
-		NORMAL(new Color(0x383d3d), new Color(0x4b5252), Color.WHITE),
16
-		DISABLED(new Color(0x777777), new Color(0x777777), new Color(0x444444)),
17
-		LIGHT(new Color(0x505757), new Color(0x626b6b), Color.WHITE),
18
-		HIGHLIGHTED(new Color(0x0086cf), new Color(0x0097ea), Color.WHITE),
19
-		NAVBAR_INACTIVE(null, null, new Color(0xcccccc)),
20
-		NAVBAR_ACTIVE(null, null, Color.WHITE),
21
-		TRANSPARENT(null, null, Color.WHITE);
16
+		NORMAL(new Color(0x333d47), new Color(0x4d5c6b), new Color(0x333d47), Color.WHITE),
17
+		DISABLED(new Color(0x777777), new Color(0x777777), new Color(0x777777), new Color(0x444444)),
18
+		LIGHT(new Color(0x333d47), new Color(0x4d5c6b), new Color(0x333d47), Color.WHITE),
19
+		HIGHLIGHTED(new Color(0x2f68a2), new Color(0x3d8ee0), new Color(0x2f68a2), Color.WHITE),
20
+		TRANSPARENT(null, null, null, Color.WHITE);
21
+
22
+		private final Color bgNormal, bgHover, bgPressed;
22 23
 
23 24
 		@Getter
24
-		private final Color bgNormal, bgHover, text;
25
+		private final Color text;
25 26
 
26
-		ButtonStyle(Color bgNormal, Color bgHover, Color text) {
27
+		ButtonStyle(Color bgNormal, Color bgHover, Color bgPressed, Color text) {
27 28
 			this.bgNormal = bgNormal;
28 29
 			this.bgHover = bgHover;
30
+			this.bgPressed = bgPressed;
29 31
 			this.text = text;
30 32
 		}
31 33
 
32
-		public boolean isTranslucent() {
33
-			return this != NAVBAR_INACTIVE && this != TRANSPARENT;
34
+		public float getTextOpacity(boolean isHovered, boolean isPressed) {
35
+			if (this == TRANSPARENT) {
36
+				return isHovered ? 0.7f : (isPressed ? 0.9f : 0.5f);
37
+			}
38
+
39
+			return 1.0f;
34 40
 		}
35
-	}
36 41
 
37
-	private final Font font;
42
+		public Color getBackground(boolean isHovered, boolean isPressed) {
43
+			return isHovered ? this.bgHover : (isPressed ? this.bgPressed : this.bgNormal);
44
+		}
45
+	}
38 46
 
39 47
 	@Getter
40 48
 	@Setter
@@ -46,14 +54,22 @@ public class FlatButton extends JButton {
46 54
 
47 55
 	@Getter
48 56
 	@Setter
49
-	private boolean isDisabled;
57
+	private boolean isLeftAligned;
50 58
 
51 59
 	private boolean hovered;
52 60
 
61
+	private boolean pressed;
62
+
53 63
 	public FlatButton(String text, Font font) {
64
+		this(text);
65
+
66
+		this.setFont(font);
67
+		this.setText(text);
68
+	}
69
+
70
+	public FlatButton(String text) {
54 71
 		this.setText(text);
55 72
 
56
-		this.font = font;
57 73
 		this.setMargin(new Insets(0, 0, 0, 0));
58 74
 		this.setBorder(BorderFactory.createEmptyBorder(12, 24, 12, 24));
59 75
 
@@ -67,6 +83,16 @@ public class FlatButton extends JButton {
67 83
 			public void mouseExited(MouseEvent e) {
68 84
 				FlatButton.this.hovered = false;
69 85
 			}
86
+
87
+//			@Override
88
+//			public void mouseClicked(MouseEvent e) {
89
+//				FlatButton.this.pressed = true;
90
+//			}
91
+//
92
+//			@Override
93
+//			public void mouseReleased(MouseEvent e) {
94
+//				FlatButton.this.pressed = false;
95
+//			}
70 96
 		});
71 97
 
72 98
 		this.setOpaque(false);
@@ -76,16 +102,17 @@ public class FlatButton extends JButton {
76 102
 	public void paint(Graphics g) {
77 103
 		Graphics2D g2 = (Graphics2D) g;
78 104
 
79
-		Color color = this.hovered ? this.style.getBgHover() : this.style.getBgNormal();
105
+		Color color = this.getStyle().getBackground(this.hovered, this.pressed);
80 106
 
81 107
 		if (color != null) {
82 108
 			g2.clearRect(0, 0, this.getWidth(), this.getHeight());
109
+
83 110
 			g2.setColor(color);
84 111
 			g2.fillRect(0, 0, this.getWidth(), this.getHeight());
85 112
 		}
86 113
 
87 114
 		g2.setColor(this.style.getText());
88
-		g2.setFont(this.font);
115
+		g2.setFont(this.getFont());
89 116
 
90 117
 		FontMetrics fontMetrics = g.getFontMetrics();
91 118
 		int textWidth = fontMetrics.stringWidth(this.getText());
@@ -93,18 +120,28 @@ public class FlatButton extends JButton {
93 120
 
94 121
 		g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
95 122
 
96
-		if (!this.getStyle().isTranslucent()) {
97
-			AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, this.hovered ? 1.0f : 0.6f);
123
+		float textOpacity = this.getStyle().getTextOpacity(this.hovered, this.pressed);
124
+
125
+		if (textOpacity < 1.0f) {
126
+			AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, textOpacity);
98 127
 			g2.setComposite(composite);
99 128
 		}
100 129
 
101 130
 		if (this.getButtonIcon() != null) {
102
-			int x = (this.getWidth() / 2) - ((this.getButtonIcon().getIconWidth() + textWidth + 24) / 2) + 6;
131
+			int x;
132
+
133
+			if (this.isLeftAligned()) {
134
+				x = 12;
135
+			} else {
136
+				x = (this.getWidth() / 2) - ((this.getButtonIcon().getIconWidth() + textWidth + 24) / 2) + 6;
137
+			}
103 138
 
104 139
 			g2.drawImage(this.getButtonIcon().getImage(), x, (this.getHeight() / 2) - (this.getButtonIcon().getIconHeight() / 2), null);
105 140
 			g2.drawString(this.getText(), x + 24, (this.getHeight() / 2) - (textHeight / 2) + fontMetrics.getAscent());
106 141
 		} else {
107
-			g2.drawString(this.getText(), (this.getWidth() / 2) - (textWidth / 2), (this.getHeight() / 2) - (textHeight / 2) + fontMetrics.getAscent());
142
+			int x = this.isLeftAligned() ? 12 : (this.getWidth() / 2) - (textWidth / 2);
143
+
144
+			g2.drawString(this.getText(), x, (this.getHeight() / 2) - (textHeight / 2) + fontMetrics.getAscent());
108 145
 		}
109 146
 	}
110 147
 

+ 1
- 1
launcher-gg/src/main/java/com/gildedgames/launcher/ui/components/FlatProgressbar.java View File

@@ -8,7 +8,7 @@ import java.awt.Graphics2D;
8 8
 public class FlatProgressbar extends JProgressBar {
9 9
 	private static final Color COLOR_UNFILLED = new Color(100, 100, 100);
10 10
 
11
-	private static final Color COLOR_FILLED = new Color(0x1ab0e8);
11
+	private static final Color COLOR_FILLED = new Color(0x1390e0);
12 12
 
13 13
 	@Override
14 14
 	public void paintComponent(Graphics g) {

+ 65
- 13
launcher-gg/src/main/java/com/gildedgames/launcher/ui/components/FlatTabPane.java View File

@@ -2,17 +2,17 @@ package com.gildedgames.launcher.ui.components;
2 2
 
3 3
 import com.gildedgames.launcher.ui.resources.LauncherFonts;
4 4
 import com.gildedgames.launcher.util.Pair;
5
+import lombok.Setter;
5 6
 
6
-import javax.swing.BorderFactory;
7
-import javax.swing.JComponent;
8
-import javax.swing.JPanel;
9
-import java.awt.BorderLayout;
10
-import java.awt.FlowLayout;
7
+import javax.swing.*;
8
+import java.awt.*;
9
+import java.awt.event.MouseAdapter;
10
+import java.awt.event.MouseEvent;
11 11
 import java.util.ArrayList;
12 12
 import java.util.List;
13 13
 
14 14
 public class FlatTabPane extends JPanel {
15
-	private final List<Pair<FlatButton, JComponent>> tabs = new ArrayList<>();
15
+	private final List<Pair<FlatTabButton, JComponent>> tabs = new ArrayList<>();
16 16
 
17 17
 	private final JPanel layoutRoot = new JPanel();
18 18
 
@@ -28,21 +28,21 @@ public class FlatTabPane extends JPanel {
28 28
 	private void initComponents() {
29 29
 		this.layoutRoot.setLayout(new BorderLayout());
30 30
 		this.layoutRoot.setOpaque(false);
31
-		this.layoutRoot.setBorder(BorderFactory.createEmptyBorder(20, 24, 20, 24));
31
+		this.layoutRoot.setBorder(BorderFactory.createEmptyBorder(20, 35, 20, 35));
32 32
 
33 33
 		FlowLayout buttonLayout = new FlowLayout();
34 34
 		buttonLayout.setAlignment(FlowLayout.LEFT);
35 35
 
36 36
 		this.buttonContainer.setLayout(buttonLayout);
37 37
 		this.buttonContainer.setOpaque(false);
38
+		this.buttonContainer.add(Box.createHorizontalStrut(12));
38 39
 
39 40
 		this.add(this.buttonContainer, BorderLayout.NORTH);
40 41
 		this.add(this.layoutRoot, BorderLayout.CENTER);
41 42
 	}
42 43
 
43 44
 	public void addTab(String title, JComponent comp) {
44
-		FlatButton button = new FlatButton(title, LauncherFonts.OPEN_SANS_REGULAR.deriveFont(15.0f));
45
-		button.setStyle(FlatButton.ButtonStyle.TRANSPARENT);
45
+		FlatTabButton button = new FlatTabButton(title);
46 46
 		button.addActionListener(e -> this.setActive(comp));
47 47
 
48 48
 		this.buttonContainer.add(button);
@@ -56,12 +56,64 @@ public class FlatTabPane extends JPanel {
56 56
 		this.layoutRoot.revalidate();
57 57
 		this.layoutRoot.repaint();
58 58
 
59
-		for (Pair<FlatButton, JComponent> pair : this.tabs) {
60
-			FlatButton button = pair.getLeft();
61
-			button.setStyle(pair.getRight() == comp ?
62
-					FlatButton.ButtonStyle.NAVBAR_ACTIVE : FlatButton.ButtonStyle.NAVBAR_INACTIVE);
59
+		for (Pair<FlatTabButton, JComponent> pair : this.tabs) {
60
+			FlatTabButton button = pair.getLeft();
61
+			button.setSelected(pair.getRight() == comp);
63 62
 			button.revalidate();
64 63
 			button.repaint();
65 64
 		}
66 65
 	}
66
+
67
+	private class FlatTabButton extends JButton {
68
+		private final Font normalFont = LauncherFonts.OPEN_SANS_REGULAR.deriveFont(15.0f),
69
+			selectedFont = LauncherFonts.OPEN_SANS_BOLD.deriveFont(15.0f);
70
+
71
+		private boolean hovered;
72
+
73
+		@Setter
74
+		private boolean selected;
75
+
76
+		public FlatTabButton(String text) {
77
+			this.setText(text.toUpperCase());
78
+			this.setForeground(Color.WHITE);
79
+
80
+			this.setMargin(new Insets(0, 0, 0, 0));
81
+			this.setBorder(BorderFactory.createEmptyBorder(12, 24, 12, 24));
82
+
83
+			this.addMouseListener(new MouseAdapter() {
84
+				@Override
85
+				public void mouseEntered(MouseEvent e) {
86
+					FlatTabButton.this.hovered = true;
87
+				}
88
+
89
+				@Override
90
+				public void mouseExited(MouseEvent e) {
91
+					FlatTabButton.this.hovered = false;
92
+				}
93
+			});
94
+
95
+			this.setOpaque(false);
96
+		}
97
+
98
+		@Override
99
+		public void paint(Graphics g) {
100
+			Graphics2D g2 = (Graphics2D) g;
101
+			g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
102
+
103
+			float textOpacity = (this.selected ? 1.0f : (this.hovered ? 0.85f : 0.6f));
104
+
105
+			if (textOpacity < 1.0f) {
106
+				AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, textOpacity);
107
+				g2.setComposite(composite);
108
+			}
109
+
110
+			FontMetrics fontMetrics = g.getFontMetrics();
111
+			int textHeight = fontMetrics.getHeight();
112
+
113
+			g2.setFont(this.selected ? this.selectedFont : this.normalFont);
114
+			g2.setColor(this.getForeground());
115
+
116
+			g2.drawString(this.getText(), 0, (this.getHeight() / 2) - (textHeight / 2) + fontMetrics.getAscent());
117
+		}
118
+	}
67 119
 }

+ 63
- 0
launcher-gg/src/main/java/com/gildedgames/launcher/ui/components/UserIndicator.java View File

@@ -0,0 +1,63 @@
1
+package com.gildedgames.launcher.ui.components;
2
+
3
+import com.gildedgames.launcher.ui.resources.AvatarCache;
4
+import com.gildedgames.launcher.ui.resources.LauncherFonts;
5
+import com.skcraft.launcher.auth.Account;
6
+
7
+import javax.swing.JComponent;
8
+import javax.swing.SwingUtilities;
9
+import java.awt.*;
10
+import java.awt.image.BufferedImage;
11
+
12
+public class UserIndicator extends JComponent {
13
+	private static final Font FONT_HEADER = LauncherFonts.OPEN_SANS_REGULAR.deriveFont(10.0f),
14
+			FONT_USERNAME = LauncherFonts.OPEN_SANS_REGULAR.deriveFont(14.0f);
15
+
16
+	private final AvatarCache avatarCache;
17
+
18
+	private Account account;
19
+
20
+	private AvatarCache.CachedAvatar avatar;
21
+
22
+	public UserIndicator(AvatarCache avatarCache) {
23
+		this.avatarCache = avatarCache;
24
+
25
+		this.setPreferredSize(new Dimension(120, 50));
26
+	}
27
+
28
+	public void setAccount(Account account) {
29
+		this.account = account;
30
+
31
+		if (account == null) {
32
+			this.avatar = null;
33
+		} else {
34
+			this.avatar = this.avatarCache.getCachedAvatar(account, value -> {
35
+				this.avatar = value;
36
+
37
+				SwingUtilities.invokeLater(this::repaint);
38
+			});
39
+		}
40
+	}
41
+
42
+	@Override
43
+	public void paint(Graphics g) {
44
+		Graphics2D g2 = (Graphics2D) g;
45
+		g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
46
+
47
+		Image avatar = AvatarCache.DEFAULT_ICON.getImage();
48
+
49
+		if (this.avatar != null && this.avatar.getImage() != null) {
50
+			avatar = this.avatar.getImage();
51
+		}
52
+
53
+		g.drawImage(avatar, 7, 10, null);
54
+
55
+		g2.setFont(FONT_HEADER);
56
+		g2.setColor(Color.WHITE);
57
+		g2.drawString("LOGGED IN AS", 56, 23);
58
+
59
+		String username = this.account == null ? "nobody" : this.account.getSession().getName();
60
+		g2.setFont(FONT_USERNAME);
61
+		g2.drawString(username, 56, 40);
62
+	}
63
+}

+ 1
- 8
launcher-gg/src/main/java/com/gildedgames/launcher/ui/panels/TitlebarPanel.java View File

@@ -26,7 +26,7 @@ public class TitlebarPanel extends JPanel {
26 26
 
27 27
 		Font font = LauncherFonts.OPEN_SANS_REGULAR;
28 28
 
29
-		this.setLayout(new MigLayout("align center, insets 0", "12[]12[]push[]20[]12[]12"));
29
+		this.setLayout(new MigLayout("align center, insets 0", "12[]12[]push[]12[]12"));
30 30
 		this.setBackground(LauncherStyles.LAUNCHER_BACKGROUND);
31 31
 
32 32
 		JLabel icon = new JLabel();
@@ -42,13 +42,6 @@ public class TitlebarPanel extends JPanel {
42 42
 
43 43
 		this.add(title);
44 44
 
45
-		FlatButton options = new FlatButton("Options", font.deriveFont(12.0f));
46
-		options.setStyle(FlatButton.ButtonStyle.TRANSPARENT);
47
-		options.setButtonIcon(LauncherIcons.GEAR);
48
-		options.addActionListener(e -> frame.showOptions());
49
-
50
-		this.add(options);
51
-
52 45
 		WindowButton minimizeButton = new WindowButton(LauncherIcons.WINDOW_MINIMIZE);
53 46
 		minimizeButton.addActionListener(e -> frame.setState(JFrame.ICONIFIED));
54 47
 

+ 12
- 1
launcher-gg/src/main/java/com/gildedgames/launcher/ui/resources/AvatarCache.java View File

@@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
11 11
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
12 12
 import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
13 13
 import com.fasterxml.jackson.databind.ser.std.StdSerializer;
14
+import com.gildedgames.launcher.ui.views.PlayView;
14 15
 import com.skcraft.concurrency.Callback;
15 16
 import com.skcraft.launcher.Launcher;
16 17
 import com.skcraft.launcher.auth.Account;
@@ -33,6 +34,16 @@ import java.util.concurrent.Executors;
33 34
 
34 35
 @Log
35 36
 public class AvatarCache {
37
+	public static ImageIcon DEFAULT_ICON;
38
+
39
+	static {
40
+		try {
41
+			DEFAULT_ICON = new ImageIcon(ImageIO.read(PlayView.class.getResourceAsStream("/com/gildedgames/assets/images/heads/default.png")));
42
+		} catch (IOException e) {
43
+			e.printStackTrace();
44
+		}
45
+	}
46
+
36 47
 	private static final String SERVICE_URL = "https://crafatar.com/renders/head/%s?scale=2";
37 48
 
38 49
 	private static final int CACHE_TIME = 1000 * 60 * 30;
@@ -58,7 +69,7 @@ public class AvatarCache {
58 69
 		if (avatar == null) {
59 70
 			this.startFetch(uuid, callback);
60 71
 
61
-			return null;
72
+			return new CachedAvatar();
62 73
 		}
63 74
 
64 75
 		if (avatar.getExpires() <= System.currentTimeMillis()) {

+ 3
- 0
launcher-gg/src/main/java/com/gildedgames/launcher/ui/resources/LauncherFonts.java View File

@@ -11,10 +11,13 @@ import java.io.InputStream;
11 11
 public class LauncherFonts {
12 12
 	public static final Font OPEN_SANS_REGULAR;
13 13
 
14
+	public static final Font OPEN_SANS_BOLD;
15
+
14 16
 	// TODO: remove?
15 17
 	public static final Font OPEN_SANS_LIGHT;
16 18
 
17 19
 	static {
20
+		OPEN_SANS_BOLD = load("com/gildedgames/assets/fonts/OpenSans-Bold.ttf");
18 21
 		OPEN_SANS_REGULAR = load("com/gildedgames/assets/fonts/OpenSans-Regular.ttf");
19 22
 		OPEN_SANS_LIGHT = load("com/gildedgames/assets/fonts/OpenSans-Light.ttf");
20 23
 	}

+ 2
- 1
launcher-gg/src/main/java/com/gildedgames/launcher/ui/resources/LauncherIcons.java View File

@@ -20,7 +20,7 @@ public class LauncherIcons {
20 20
 
21 21
 	public static final ImageIcon SWITCH_USER;
22 22
 
23
-	public static final ImageIcon WINDOW_MINIMIZE, WINDOW_CLOSE;
23
+	public static final ImageIcon WINDOW_MINIMIZE, WINDOW_CLOSE, WINDOW_MAXIMIZE;
24 24
 
25 25
 	public static final ImageIcon WINDOW_ICON;
26 26
 
@@ -35,6 +35,7 @@ public class LauncherIcons {
35 35
 
36 36
 		WINDOW_MINIMIZE = load("com/gildedgames/assets/icons/minimize.png");
37 37
 		WINDOW_CLOSE = load("com/gildedgames/assets/icons/close.png");
38
+		WINDOW_MAXIMIZE = load("com/gildedgames/assets/icons/maximize.png");
38 39
 
39 40
 		WINDOW_ICON = load("com/gildedgames/assets/titlebar/window-icon.png");
40 41
 	}

+ 1
- 1
launcher-gg/src/main/java/com/gildedgames/launcher/ui/resources/LauncherStyles.java View File

@@ -3,5 +3,5 @@ package com.gildedgames.launcher.ui.resources;
3 3
 import java.awt.Color;
4 4
 
5 5
 public class LauncherStyles {
6
-	public static final Color LAUNCHER_BACKGROUND = new Color(0x212424);
6
+	public static final Color LAUNCHER_BACKGROUND = new Color(0x212529);
7 7
 }

+ 1
- 11
launcher-gg/src/main/java/com/gildedgames/launcher/ui/views/AccountListModel.java View File

@@ -11,16 +11,6 @@ import javax.swing.table.AbstractTableModel;
11 11
 import java.io.IOException;
12 12
 
13 13
 public class AccountListModel extends AbstractTableModel {
14
-	private static ImageIcon DEFAULT_ICON;
15
-
16
-	static {
17
-		try {
18
-			DEFAULT_ICON = new ImageIcon(ImageIO.read(PlayView.class.getResourceAsStream("/com/gildedgames/assets/images/heads/default.png")));
19
-		} catch (IOException e) {
20
-			e.printStackTrace();
21
-		}
22
-	}
23
-
24 14
 	private final AccountList accounts;
25 15
 
26 16
 	private final AvatarCache avatarCache;
@@ -79,7 +69,7 @@ public class AccountListModel extends AbstractTableModel {
79 69
 			AvatarCache.CachedAvatar avatar = this.avatarCache.getCachedAvatar(account, value -> SwingUtilities.invokeLater(() -> this.fireTableRowsUpdated(rowIndex, rowIndex)));
80 70
 
81 71
 			if (avatar == null) {
82
-				return DEFAULT_ICON;
72
+				return AvatarCache.DEFAULT_ICON;
83 73
 			} else {
84 74
 				return avatar.getIcon();
85 75
 			}

+ 3
- 3
launcher-gg/src/main/java/com/gildedgames/launcher/ui/views/AccountListView.java View File

@@ -71,17 +71,17 @@ public class AccountListView extends JPanel {
71 71
 		this.table.setRowHeight(48);
72 72
 		this.table.getColumnModel().getColumn(0).setMaxWidth(54);
73 73
 		this.table.setTableHeader(null);
74
-		this.table.setBackground(new Color(0x373b3b));
74
+		this.table.setBackground(new Color(0x283038));
75 75
 		this.table.setBorder(BorderFactory.createEmptyBorder());
76 76
 		this.table.setFont(LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
77 77
 		this.table.setForeground(Color.WHITE);
78
-		this.table.setSelectionBackground(new Color(0x0086cf));
78
+		this.table.setSelectionBackground(new Color(0x4c5d6e));
79 79
 		this.table.setRowSelectionInterval(0, 0);
80 80
 
81 81
 		JScrollPane scroller = new JScrollPane(this.table);
82 82
 		scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
83 83
 		scroller.setPreferredSize(new Dimension(500, 320));
84
-		scroller.setBackground(new Color(0x373b3b));
84
+		scroller.setBackground(new Color(0x283038));
85 85
 		scroller.setBorder(BorderFactory.createEmptyBorder());
86 86
 
87 87
 		JPanel accountActions = new JPanel();

+ 5
- 7
launcher-gg/src/main/java/com/gildedgames/launcher/ui/views/OptionsView.java View File

@@ -40,12 +40,12 @@ public class OptionsView extends JPanel {
40 40
 	private void initComponents() {
41 41
 		GeneralPanel general = new GeneralPanel(this.launcher);
42 42
 
43
-		this.pane.addTab("Launcher", general);
43
+		this.pane.addTab("General", general);
44 44
 		this.savable.add(general);
45 45
 
46 46
 		this.pane.addTab("Minecraft", new JPanel());
47 47
 
48
-		this.pane.addTab("Updates", new JPanel());
48
+		this.pane.addTab("Proxy", new JPanel());
49 49
 
50 50
 		this.pane.setActive(general);
51 51
 
@@ -57,8 +57,8 @@ public class OptionsView extends JPanel {
57 57
 
58 58
 		JPanel bottomButtons = new JPanel();
59 59
 		bottomButtons.setLayout(bottomLayout);
60
-		bottomButtons.setBackground(new Color(0x2a2e2e));
61
-		bottomButtons.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
60
+		bottomButtons.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
61
+		bottomButtons.setOpaque(false);
62 62
 
63 63
 		FlatButton saveButton = new FlatButton("Apply", LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
64 64
 		saveButton.setStyle(FlatButton.ButtonStyle.HIGHLIGHTED);
@@ -76,9 +76,7 @@ public class OptionsView extends JPanel {
76 76
 		FlatButton closeButton = new FlatButton("Close", LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
77 77
 		closeButton.setStyle(FlatButton.ButtonStyle.LIGHT);
78 78
 		closeButton.setPreferredSize(new Dimension(100, 32));
79
-		closeButton.addActionListener(e -> {
80
-			this.frame.getLauncherLayout().back();
81
-        });
79
+		closeButton.addActionListener(e -> this.frame.getLauncherLayout().back());
82 80
 
83 81
 		bottomButtons.add(closeButton);
84 82
 		bottomButtons.add(saveButton);

+ 52
- 17
launcher-gg/src/main/java/com/gildedgames/launcher/ui/views/PlayView.java View File

@@ -3,12 +3,14 @@ package com.gildedgames.launcher.ui.views;
3 3
 import com.gildedgames.launcher.launch.LaunchSupervisor;
4 4
 import com.gildedgames.launcher.ui.LauncherFrame;
5 5
 import com.gildedgames.launcher.ui.components.FlatButton;
6
+import com.gildedgames.launcher.ui.components.UserIndicator;
6 7
 import com.gildedgames.launcher.ui.panels.ImagePanel;
7 8
 import com.gildedgames.launcher.ui.resources.LauncherFonts;
8 9
 import com.gildedgames.launcher.ui.resources.LauncherIcons;
9 10
 import com.gildedgames.launcher.ui.resources.LauncherStyles;
10 11
 import com.google.common.util.concurrent.FutureCallback;
11 12
 import com.google.common.util.concurrent.Futures;
13
+import com.skcraft.concurrency.Callback;
12 14
 import com.skcraft.concurrency.ObservableFuture;
13 15
 import com.skcraft.concurrency.ProgressObservable;
14 16
 import com.skcraft.launcher.Instance;
@@ -30,6 +32,8 @@ import java.awt.BorderLayout;
30 32
 import java.awt.Color;
31 33
 import java.awt.Component;
32 34
 import java.awt.Dimension;
35
+import java.awt.event.ActionEvent;
36
+import java.awt.event.ActionListener;
33 37
 import java.awt.event.MouseEvent;
34 38
 import java.io.File;
35 39
 import java.io.IOException;
@@ -56,11 +60,14 @@ public class PlayView extends JPanel {
56 60
 
57 61
 	private JSplitPane splitPane;
58 62
 
63
+	private UserIndicator userIndicator;
64
+
59 65
 	private Launcher launcher;
60 66
 
61 67
 	private LauncherFrame frame;
62 68
 
63 69
 	public PlayView(Launcher launcher, LauncherFrame frame) {
70
+		this.userIndicator = new UserIndicator(frame.getAvatarCache());
64 71
 		this.instancesModel = new InstanceTableModel(launcher.getInstances());
65 72
 		this.launcher = launcher;
66 73
 		this.frame = frame;
@@ -75,7 +82,7 @@ public class PlayView extends JPanel {
75 82
 	private void init() {
76 83
 		this.launchButton = new FlatButton(SharedLocale.tr("launcher.launch"), LauncherFonts.OPEN_SANS_REGULAR.deriveFont(20.0f));
77 84
 		this.launchButton.setStyle(FlatButton.ButtonStyle.HIGHLIGHTED);
78
-		this.launchButton.setPreferredSize(new Dimension(150, 32));
85
+		this.launchButton.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
79 86
 
80 87
 		JPanel empty = new JPanel();
81 88
 		empty.setOpaque(false);
@@ -83,13 +90,34 @@ public class PlayView extends JPanel {
83 90
 		this.switchUserButton = new FlatButton("Switch user", LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
84 91
 		this.switchUserButton.setStyle(FlatButton.ButtonStyle.TRANSPARENT);
85 92
 		this.switchUserButton.setButtonIcon(LauncherIcons.SWITCH_USER);
86
-		this.switchUserButton.setPreferredSize(new Dimension(120, 32));
93
+		this.switchUserButton.setLeftAligned(true);
94
+		this.switchUserButton.setBorder(BorderFactory.createEmptyBorder(9, 9, 9, 9));
87 95
 
88 96
 		this.selfUpdateButton = new FlatButton(SharedLocale.tr("launcher.updateLauncher"), LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
89 97
 		this.selfUpdateButton.setStyle(FlatButton.ButtonStyle.LIGHT);
90 98
 
91
-		this.splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.instancesTable, empty);
92
-		this.splitPane.setResizeWeight(0.0D);
99
+		this.updateUserIndicator(this.launcher.getAccounts().getActiveAccount());
100
+
101
+		FlatButton optionsButton = new FlatButton("Options", LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
102
+		optionsButton.setBorder(BorderFactory.createEmptyBorder(9, 9, 9, 9));
103
+		optionsButton.setStyle(FlatButton.ButtonStyle.TRANSPARENT);
104
+		optionsButton.setLeftAligned(true);
105
+		optionsButton.setButtonIcon(LauncherIcons.GEAR);
106
+		optionsButton.addActionListener(e -> this.frame.showOptions());
107
+
108
+		JLabel profilesLabel = new JLabel("PROFILES");
109
+		profilesLabel.setFont(LauncherFonts.OPEN_SANS_REGULAR.deriveFont(14.0f));
110
+		profilesLabel.setForeground(new Color(160, 160, 160));
111
+		profilesLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
112
+
113
+		JPanel left = new JPanel(new MigLayout("fill, insets 0", "[fill]", "[]4[]0[]12[]12[]0[]"));
114
+		left.add(this.userIndicator, "wrap");
115
+		left.add(this.switchUserButton, "wrap");
116
+		left.add(optionsButton, "wrap");
117
+		left.add(profilesLabel, "wrap");
118
+		left.add(this.instancesTable, "grow, push, wrap");
119
+		left.add(this.launchButton, "wrap");
120
+		left.setBackground(new Color(0x2f353b));
93 121
 
94 122
 		this.selfUpdateButton.setVisible(this.launcher.getUpdateManager().getPendingUpdate());
95 123
 
@@ -101,7 +129,8 @@ public class PlayView extends JPanel {
101 129
 
102 130
 		this.instancesTable.setModel(this.instancesModel);
103 131
 		this.instancesTable.setRowHeight(40);
104
-		this.instancesTable.setBackground(new Color(0x292e2e));
132
+		this.instancesTable.setBackground(new Color(0x283038));
133
+		this.instancesTable.setSelectionBackground(new Color(0x4c5d6e));
105 134
 		this.instancesTable.setBorder(BorderFactory.createEmptyBorder());
106 135
 		this.instancesTable.setFocusable(false);
107 136
 		this.instancesTable.getSelectionModel().addListSelectionListener(e -> {
@@ -122,23 +151,17 @@ public class PlayView extends JPanel {
122 151
 			}
123 152
 		});
124 153
 
125
-		this.splitPane.setDividerLocation(220);
154
+		this.splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, empty);
155
+		this.splitPane.setResizeWeight(0.0D);
156
+		this.splitPane.setDividerLocation(250);
126 157
 		this.splitPane.setDividerSize(4);
127 158
 		this.splitPane.setOpaque(false);
128 159
 
129 160
 		SwingHelper.flattenJSplitPane(this.splitPane);
130 161
 
131
-		JPanel bottomPanel = new JPanel();
132
-		bottomPanel.setLayout(new MigLayout("fill, insets 0", "[]push[]16[]"));
133
-		bottomPanel.add(this.selfUpdateButton);
134
-		bottomPanel.add(this.switchUserButton);
135
-		bottomPanel.add(this.launchButton);
136
-		bottomPanel.setBackground(LauncherStyles.LAUNCHER_BACKGROUND);
137
-
138 162
 		JPanel container = new ImagePanel("com/gildedgames/assets/images/background.jpg");
139
-		container.setLayout(new MigLayout("fill, wrap, insets 0", "[fill]", "[grow]0[]"));
140
-		container.add(this.splitPane, "grow, wrap, w null:680, h null:350");
141
-		container.add(bottomPanel, "grow, push");
163
+		container.setLayout(new BorderLayout());
164
+		container.add(this.splitPane, BorderLayout.CENTER);
142 165
 
143 166
 		this.add(container, BorderLayout.CENTER);
144 167
 
@@ -150,7 +173,16 @@ public class PlayView extends JPanel {
150 173
 
151 174
 		this.instancesTable.addMouseListener(new DoubleClickToButtonAdapter(this.launchButton));
152 175
 
153
-		this.switchUserButton.addActionListener(e -> this.frame.getLauncherLayout().show(new AccountListView(this.launcher, this.frame)));
176
+		this.switchUserButton.addActionListener(e -> {
177
+			AccountListView view = new AccountListView(this.launcher, this.frame);
178
+			view.setCallback(value -> {
179
+				if (value != null) {
180
+					this.updateUserIndicator(value);
181
+				}
182
+			});
183
+
184
+			this.frame.getLauncherLayout().show(view);
185
+		});
154 186
 
155 187
 		this.selfUpdateButton.addActionListener(e -> this.launcher.getUpdateManager().performUpdate(this.frame));
156 188
 
@@ -170,6 +202,9 @@ public class PlayView extends JPanel {
170 202
 		});
171 203
 	}
172 204
 
205
+	public void updateUserIndicator(Account account) {
206
+		this.userIndicator.setAccount(account);
207
+	}
173 208
 
174 209
 	private void popupInstanceMenu(Component component, int x, int y, final Instance selected) {
175 210
 		JPopupMenu popup = new JPopupMenu();

BIN
launcher-gg/src/main/resources/com/gildedgames/assets/fonts/OpenSans-Bold.ttf View File


BIN
launcher-gg/src/main/resources/com/gildedgames/assets/icons/maximize.png View File


BIN
launcher-gg/src/main/resources/com/gildedgames/assets/images/background.jpg View File


Loading…
Cancel
Save