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/
*.lnk

/classes/
/testing/
/testing/

# Windows garbage
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 {
this.getContentPane().add(this.titlebar, BorderLayout.NORTH);
this.getContentPane().add(this.layout.getRoot(), BorderLayout.CENTER);

this.layout.show(new PlayView(this.launcher, this));
PlayView view = new PlayView(this.launcher, this);

this.layout.show(view);

if (this.launcher.getAccounts().getSize() <= 0) {
AccountAddView accountAddView = new AccountAddView(this, this.launcher);
@@ -72,6 +74,8 @@ public class LauncherFrame extends JFrame {
this.launcher.getAccounts().setSelectedAccount(account);

Persistence.commitAndForget(LauncherFrame.this.launcher.getAccounts());

view.updateUserIndicator(account);
});

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;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.SwingUtilities;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class FlatButton extends JButton {
public enum ButtonStyle {
NORMAL(new Color(0x383d3d), new Color(0x4b5252), Color.WHITE),
DISABLED(new Color(0x777777), new Color(0x777777), new Color(0x444444)),
LIGHT(new Color(0x505757), new Color(0x626b6b), Color.WHITE),
HIGHLIGHTED(new Color(0x0086cf), new Color(0x0097ea), Color.WHITE),
NAVBAR_INACTIVE(null, null, new Color(0xcccccc)),
NAVBAR_ACTIVE(null, null, Color.WHITE),
TRANSPARENT(null, null, Color.WHITE);
NORMAL(new Color(0x333d47), new Color(0x4d5c6b), new Color(0x333d47), Color.WHITE),
DISABLED(new Color(0x777777), new Color(0x777777), new Color(0x777777), new Color(0x444444)),
LIGHT(new Color(0x333d47), new Color(0x4d5c6b), new Color(0x333d47), Color.WHITE),
HIGHLIGHTED(new Color(0x2f68a2), new Color(0x3d8ee0), new Color(0x2f68a2), Color.WHITE),
TRANSPARENT(null, null, null, Color.WHITE);
private final Color bgNormal, bgHover, bgPressed;

@Getter
private final Color bgNormal, bgHover, text;
private final Color text;

ButtonStyle(Color bgNormal, Color bgHover, Color text) {
ButtonStyle(Color bgNormal, Color bgHover, Color bgPressed, Color text) {
this.bgNormal = bgNormal;
this.bgHover = bgHover;
this.bgPressed = bgPressed;
this.text = text;
}

public boolean isTranslucent() {
return this != NAVBAR_INACTIVE && this != TRANSPARENT;
public float getTextOpacity(boolean isHovered, boolean isPressed) {
if (this == TRANSPARENT) {
return isHovered ? 0.7f : (isPressed ? 0.9f : 0.5f);
}

return 1.0f;
}
}

private final Font font;
public Color getBackground(boolean isHovered, boolean isPressed) {
return isHovered ? this.bgHover : (isPressed ? this.bgPressed : this.bgNormal);
}
}

@Getter
@Setter
@@ -46,14 +54,22 @@ public class FlatButton extends JButton {

@Getter
@Setter
private boolean isDisabled;
private boolean isLeftAligned;

private boolean hovered;

private boolean pressed;

public FlatButton(String text, Font font) {
this(text);

this.setFont(font);
this.setText(text);
}

public FlatButton(String text) {
this.setText(text);

this.font = font;
this.setMargin(new Insets(0, 0, 0, 0));
this.setBorder(BorderFactory.createEmptyBorder(12, 24, 12, 24));

@@ -67,6 +83,16 @@ public class FlatButton extends JButton {
public void mouseExited(MouseEvent e) {
FlatButton.this.hovered = false;
}

// @Override
// public void mouseClicked(MouseEvent e) {
// FlatButton.this.pressed = true;
// }
//
// @Override
// public void mouseReleased(MouseEvent e) {
// FlatButton.this.pressed = false;
// }
});

this.setOpaque(false);
@@ -76,16 +102,17 @@ public class FlatButton extends JButton {
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;

Color color = this.hovered ? this.style.getBgHover() : this.style.getBgNormal();
Color color = this.getStyle().getBackground(this.hovered, this.pressed);

if (color != null) {
g2.clearRect(0, 0, this.getWidth(), this.getHeight());

g2.setColor(color);
g2.fillRect(0, 0, this.getWidth(), this.getHeight());
}

g2.setColor(this.style.getText());
g2.setFont(this.font);
g2.setFont(this.getFont());

FontMetrics fontMetrics = g.getFontMetrics();
int textWidth = fontMetrics.stringWidth(this.getText());
@@ -93,18 +120,28 @@ public class FlatButton extends JButton {

g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

if (!this.getStyle().isTranslucent()) {
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, this.hovered ? 1.0f : 0.6f);
float textOpacity = this.getStyle().getTextOpacity(this.hovered, this.pressed);

if (textOpacity < 1.0f) {
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, textOpacity);
g2.setComposite(composite);
}

if (this.getButtonIcon() != null) {
int x = (this.getWidth() / 2) - ((this.getButtonIcon().getIconWidth() + textWidth + 24) / 2) + 6;
int x;

if (this.isLeftAligned()) {
x = 12;
} else {
x = (this.getWidth() / 2) - ((this.getButtonIcon().getIconWidth() + textWidth + 24) / 2) + 6;
}

g2.drawImage(this.getButtonIcon().getImage(), x, (this.getHeight() / 2) - (this.getButtonIcon().getIconHeight() / 2), null);
g2.drawString(this.getText(), x + 24, (this.getHeight() / 2) - (textHeight / 2) + fontMetrics.getAscent());
} else {
g2.drawString(this.getText(), (this.getWidth() / 2) - (textWidth / 2), (this.getHeight() / 2) - (textHeight / 2) + fontMetrics.getAscent());
int x = this.isLeftAligned() ? 12 : (this.getWidth() / 2) - (textWidth / 2);

g2.drawString(this.getText(), x, (this.getHeight() / 2) - (textHeight / 2) + fontMetrics.getAscent());
}
}


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

@@ -8,7 +8,7 @@ import java.awt.Graphics2D;
public class FlatProgressbar extends JProgressBar {
private static final Color COLOR_UNFILLED = new Color(100, 100, 100);

private static final Color COLOR_FILLED = new Color(0x1ab0e8);
private static final Color COLOR_FILLED = new Color(0x1390e0);

@Override
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;

import com.gildedgames.launcher.ui.resources.LauncherFonts;
import com.gildedgames.launcher.util.Pair;
import lombok.Setter;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;

public class FlatTabPane extends JPanel {
private final List<Pair<FlatButton, JComponent>> tabs = new ArrayList<>();
private final List<Pair<FlatTabButton, JComponent>> tabs = new ArrayList<>();

private final JPanel layoutRoot = new JPanel();

@@ -28,21 +28,21 @@ public class FlatTabPane extends JPanel {
private void initComponents() {
this.layoutRoot.setLayout(new BorderLayout());
this.layoutRoot.setOpaque(false);
this.layoutRoot.setBorder(BorderFactory.createEmptyBorder(20, 24, 20, 24));
this.layoutRoot.setBorder(BorderFactory.createEmptyBorder(20, 35, 20, 35));

FlowLayout buttonLayout = new FlowLayout();
buttonLayout.setAlignment(FlowLayout.LEFT);

this.buttonContainer.setLayout(buttonLayout);
this.buttonContainer.setOpaque(false);
this.buttonContainer.add(Box.createHorizontalStrut(12));

this.add(this.buttonContainer, BorderLayout.NORTH);
this.add(this.layoutRoot, BorderLayout.CENTER);
}

public void addTab(String title, JComponent comp) {
FlatButton button = new FlatButton(title, LauncherFonts.OPEN_SANS_REGULAR.deriveFont(15.0f));
button.setStyle(FlatButton.ButtonStyle.TRANSPARENT);
FlatTabButton button = new FlatTabButton(title);
button.addActionListener(e -> this.setActive(comp));

this.buttonContainer.add(button);
@@ -56,12 +56,64 @@ public class FlatTabPane extends JPanel {
this.layoutRoot.revalidate();
this.layoutRoot.repaint();

for (Pair<FlatButton, JComponent> pair : this.tabs) {
FlatButton button = pair.getLeft();
button.setStyle(pair.getRight() == comp ?
FlatButton.ButtonStyle.NAVBAR_ACTIVE : FlatButton.ButtonStyle.NAVBAR_INACTIVE);
for (Pair<FlatTabButton, JComponent> pair : this.tabs) {
FlatTabButton button = pair.getLeft();
button.setSelected(pair.getRight() == comp);
button.revalidate();
button.repaint();
}
}

private class FlatTabButton extends JButton {
private final Font normalFont = LauncherFonts.OPEN_SANS_REGULAR.deriveFont(15.0f),
selectedFont = LauncherFonts.OPEN_SANS_BOLD.deriveFont(15.0f);

private boolean hovered;

@Setter
private boolean selected;

public FlatTabButton(String text) {
this.setText(text.toUpperCase());
this.setForeground(Color.WHITE);

this.setMargin(new Insets(0, 0, 0, 0));
this.setBorder(BorderFactory.createEmptyBorder(12, 24, 12, 24));

this.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
FlatTabButton.this.hovered = true;
}

@Override
public void mouseExited(MouseEvent e) {
FlatTabButton.this.hovered = false;
}
});

this.setOpaque(false);
}

@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

float textOpacity = (this.selected ? 1.0f : (this.hovered ? 0.85f : 0.6f));

if (textOpacity < 1.0f) {
AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, textOpacity);
g2.setComposite(composite);
}

FontMetrics fontMetrics = g.getFontMetrics();
int textHeight = fontMetrics.getHeight();

g2.setFont(this.selected ? this.selectedFont : this.normalFont);
g2.setColor(this.getForeground());

g2.drawString(this.getText(), 0, (this.getHeight() / 2) - (textHeight / 2) + fontMetrics.getAscent());
}
}
}

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

@@ -0,0 +1,63 @@
package com.gildedgames.launcher.ui.components;

import com.gildedgames.launcher.ui.resources.AvatarCache;
import com.gildedgames.launcher.ui.resources.LauncherFonts;
import com.skcraft.launcher.auth.Account;

import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import java.awt.*;
import java.awt.image.BufferedImage;

public class UserIndicator extends JComponent {
private static final Font FONT_HEADER = LauncherFonts.OPEN_SANS_REGULAR.deriveFont(10.0f),
FONT_USERNAME = LauncherFonts.OPEN_SANS_REGULAR.deriveFont(14.0f);

private final AvatarCache avatarCache;

private Account account;

private AvatarCache.CachedAvatar avatar;

public UserIndicator(AvatarCache avatarCache) {
this.avatarCache = avatarCache;

this.setPreferredSize(new Dimension(120, 50));
}

public void setAccount(Account account) {
this.account = account;

if (account == null) {
this.avatar = null;
} else {
this.avatar = this.avatarCache.getCachedAvatar(account, value -> {
this.avatar = value;

SwingUtilities.invokeLater(this::repaint);
});
}
}

@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

Image avatar = AvatarCache.DEFAULT_ICON.getImage();

if (this.avatar != null && this.avatar.getImage() != null) {
avatar = this.avatar.getImage();
}

g.drawImage(avatar, 7, 10, null);

g2.setFont(FONT_HEADER);
g2.setColor(Color.WHITE);
g2.drawString("LOGGED IN AS", 56, 23);

String username = this.account == null ? "nobody" : this.account.getSession().getName();
g2.setFont(FONT_USERNAME);
g2.drawString(username, 56, 40);
}
}

+ 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 {

Font font = LauncherFonts.OPEN_SANS_REGULAR;

this.setLayout(new MigLayout("align center, insets 0", "12[]12[]push[]20[]12[]12"));
this.setLayout(new MigLayout("align center, insets 0", "12[]12[]push[]12[]12"));
this.setBackground(LauncherStyles.LAUNCHER_BACKGROUND);

JLabel icon = new JLabel();
@@ -42,13 +42,6 @@ public class TitlebarPanel extends JPanel {

this.add(title);

FlatButton options = new FlatButton("Options", font.deriveFont(12.0f));
options.setStyle(FlatButton.ButtonStyle.TRANSPARENT);
options.setButtonIcon(LauncherIcons.GEAR);
options.addActionListener(e -> frame.showOptions());

this.add(options);

WindowButton minimizeButton = new WindowButton(LauncherIcons.WINDOW_MINIMIZE);
minimizeButton.addActionListener(e -> frame.setState(JFrame.ICONIFIED));


+ 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;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.gildedgames.launcher.ui.views.PlayView;
import com.skcraft.concurrency.Callback;
import com.skcraft.launcher.Launcher;
import com.skcraft.launcher.auth.Account;
@@ -33,6 +34,16 @@ import java.util.concurrent.Executors;

@Log
public class AvatarCache {
public static ImageIcon DEFAULT_ICON;

static {
try {
DEFAULT_ICON = new ImageIcon(ImageIO.read(PlayView.class.getResourceAsStream("/com/gildedgames/assets/images/heads/default.png")));
} catch (IOException e) {
e.printStackTrace();
}
}

private static final String SERVICE_URL = "https://crafatar.com/renders/head/%s?scale=2";

private static final int CACHE_TIME = 1000 * 60 * 30;
@@ -58,7 +69,7 @@ public class AvatarCache {
if (avatar == null) {
this.startFetch(uuid, callback);

return null;
return new CachedAvatar();
}

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;
public class LauncherFonts {
public static final Font OPEN_SANS_REGULAR;

public static final Font OPEN_SANS_BOLD;

// TODO: remove?
public static final Font OPEN_SANS_LIGHT;

static {
OPEN_SANS_BOLD = load("com/gildedgames/assets/fonts/OpenSans-Bold.ttf");
OPEN_SANS_REGULAR = load("com/gildedgames/assets/fonts/OpenSans-Regular.ttf");
OPEN_SANS_LIGHT = load("com/gildedgames/assets/fonts/OpenSans-Light.ttf");
}

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

@@ -20,7 +20,7 @@ public class LauncherIcons {

public static final ImageIcon SWITCH_USER;

public static final ImageIcon WINDOW_MINIMIZE, WINDOW_CLOSE;
public static final ImageIcon WINDOW_MINIMIZE, WINDOW_CLOSE, WINDOW_MAXIMIZE;

public static final ImageIcon WINDOW_ICON;

@@ -35,6 +35,7 @@ public class LauncherIcons {

WINDOW_MINIMIZE = load("com/gildedgames/assets/icons/minimize.png");
WINDOW_CLOSE = load("com/gildedgames/assets/icons/close.png");
WINDOW_MAXIMIZE = load("com/gildedgames/assets/icons/maximize.png");

WINDOW_ICON = load("com/gildedgames/assets/titlebar/window-icon.png");
}

+ 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;
import java.awt.Color;

public class LauncherStyles {
public static final Color LAUNCHER_BACKGROUND = new Color(0x212424);
public static final Color LAUNCHER_BACKGROUND = new Color(0x212529);
}

+ 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;
import java.io.IOException;

public class AccountListModel extends AbstractTableModel {
private static ImageIcon DEFAULT_ICON;

static {
try {
DEFAULT_ICON = new ImageIcon(ImageIO.read(PlayView.class.getResourceAsStream("/com/gildedgames/assets/images/heads/default.png")));
} catch (IOException e) {
e.printStackTrace();
}
}

private final AccountList accounts;

private final AvatarCache avatarCache;
@@ -79,7 +69,7 @@ public class AccountListModel extends AbstractTableModel {
AvatarCache.CachedAvatar avatar = this.avatarCache.getCachedAvatar(account, value -> SwingUtilities.invokeLater(() -> this.fireTableRowsUpdated(rowIndex, rowIndex)));

if (avatar == null) {
return DEFAULT_ICON;
return AvatarCache.DEFAULT_ICON;
} else {
return avatar.getIcon();
}

+ 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 {
this.table.setRowHeight(48);
this.table.getColumnModel().getColumn(0).setMaxWidth(54);
this.table.setTableHeader(null);
this.table.setBackground(new Color(0x373b3b));
this.table.setBackground(new Color(0x283038));
this.table.setBorder(BorderFactory.createEmptyBorder());
this.table.setFont(LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
this.table.setForeground(Color.WHITE);
this.table.setSelectionBackground(new Color(0x0086cf));
this.table.setSelectionBackground(new Color(0x4c5d6e));
this.table.setRowSelectionInterval(0, 0);

JScrollPane scroller = new JScrollPane(this.table);
scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroller.setPreferredSize(new Dimension(500, 320));
scroller.setBackground(new Color(0x373b3b));
scroller.setBackground(new Color(0x283038));
scroller.setBorder(BorderFactory.createEmptyBorder());

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 {
private void initComponents() {
GeneralPanel general = new GeneralPanel(this.launcher);

this.pane.addTab("Launcher", general);
this.pane.addTab("General", general);
this.savable.add(general);

this.pane.addTab("Minecraft", new JPanel());

this.pane.addTab("Updates", new JPanel());
this.pane.addTab("Proxy", new JPanel());

this.pane.setActive(general);

@@ -57,8 +57,8 @@ public class OptionsView extends JPanel {

JPanel bottomButtons = new JPanel();
bottomButtons.setLayout(bottomLayout);
bottomButtons.setBackground(new Color(0x2a2e2e));
bottomButtons.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
bottomButtons.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
bottomButtons.setOpaque(false);

FlatButton saveButton = new FlatButton("Apply", LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
saveButton.setStyle(FlatButton.ButtonStyle.HIGHLIGHTED);
@@ -76,9 +76,7 @@ public class OptionsView extends JPanel {
FlatButton closeButton = new FlatButton("Close", LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
closeButton.setStyle(FlatButton.ButtonStyle.LIGHT);
closeButton.setPreferredSize(new Dimension(100, 32));
closeButton.addActionListener(e -> {
this.frame.getLauncherLayout().back();
});
closeButton.addActionListener(e -> this.frame.getLauncherLayout().back());

bottomButtons.add(closeButton);
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;
import com.gildedgames.launcher.launch.LaunchSupervisor;
import com.gildedgames.launcher.ui.LauncherFrame;
import com.gildedgames.launcher.ui.components.FlatButton;
import com.gildedgames.launcher.ui.components.UserIndicator;
import com.gildedgames.launcher.ui.panels.ImagePanel;
import com.gildedgames.launcher.ui.resources.LauncherFonts;
import com.gildedgames.launcher.ui.resources.LauncherIcons;
import com.gildedgames.launcher.ui.resources.LauncherStyles;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.skcraft.concurrency.Callback;
import com.skcraft.concurrency.ObservableFuture;
import com.skcraft.concurrency.ProgressObservable;
import com.skcraft.launcher.Instance;
@@ -30,6 +32,8 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
@@ -56,11 +60,14 @@ public class PlayView extends JPanel {

private JSplitPane splitPane;

private UserIndicator userIndicator;

private Launcher launcher;

private LauncherFrame frame;

public PlayView(Launcher launcher, LauncherFrame frame) {
this.userIndicator = new UserIndicator(frame.getAvatarCache());
this.instancesModel = new InstanceTableModel(launcher.getInstances());
this.launcher = launcher;
this.frame = frame;
@@ -75,7 +82,7 @@ public class PlayView extends JPanel {
private void init() {
this.launchButton = new FlatButton(SharedLocale.tr("launcher.launch"), LauncherFonts.OPEN_SANS_REGULAR.deriveFont(20.0f));
this.launchButton.setStyle(FlatButton.ButtonStyle.HIGHLIGHTED);
this.launchButton.setPreferredSize(new Dimension(150, 32));
this.launchButton.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

JPanel empty = new JPanel();
empty.setOpaque(false);
@@ -83,13 +90,34 @@ public class PlayView extends JPanel {
this.switchUserButton = new FlatButton("Switch user", LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
this.switchUserButton.setStyle(FlatButton.ButtonStyle.TRANSPARENT);
this.switchUserButton.setButtonIcon(LauncherIcons.SWITCH_USER);
this.switchUserButton.setPreferredSize(new Dimension(120, 32));
this.switchUserButton.setLeftAligned(true);
this.switchUserButton.setBorder(BorderFactory.createEmptyBorder(9, 9, 9, 9));

this.selfUpdateButton = new FlatButton(SharedLocale.tr("launcher.updateLauncher"), LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
this.selfUpdateButton.setStyle(FlatButton.ButtonStyle.LIGHT);

this.splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.instancesTable, empty);
this.splitPane.setResizeWeight(0.0D);
this.updateUserIndicator(this.launcher.getAccounts().getActiveAccount());

FlatButton optionsButton = new FlatButton("Options", LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
optionsButton.setBorder(BorderFactory.createEmptyBorder(9, 9, 9, 9));
optionsButton.setStyle(FlatButton.ButtonStyle.TRANSPARENT);
optionsButton.setLeftAligned(true);
optionsButton.setButtonIcon(LauncherIcons.GEAR);
optionsButton.addActionListener(e -> this.frame.showOptions());

JLabel profilesLabel = new JLabel("PROFILES");
profilesLabel.setFont(LauncherFonts.OPEN_SANS_REGULAR.deriveFont(14.0f));
profilesLabel.setForeground(new Color(160, 160, 160));
profilesLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));

JPanel left = new JPanel(new MigLayout("fill, insets 0", "[fill]", "[]4[]0[]12[]12[]0[]"));
left.add(this.userIndicator, "wrap");
left.add(this.switchUserButton, "wrap");
left.add(optionsButton, "wrap");
left.add(profilesLabel, "wrap");
left.add(this.instancesTable, "grow, push, wrap");
left.add(this.launchButton, "wrap");
left.setBackground(new Color(0x2f353b));

this.selfUpdateButton.setVisible(this.launcher.getUpdateManager().getPendingUpdate());

@@ -101,7 +129,8 @@ public class PlayView extends JPanel {

this.instancesTable.setModel(this.instancesModel);
this.instancesTable.setRowHeight(40);
this.instancesTable.setBackground(new Color(0x292e2e));
this.instancesTable.setBackground(new Color(0x283038));
this.instancesTable.setSelectionBackground(new Color(0x4c5d6e));
this.instancesTable.setBorder(BorderFactory.createEmptyBorder());
this.instancesTable.setFocusable(false);
this.instancesTable.getSelectionModel().addListSelectionListener(e -> {
@@ -122,23 +151,17 @@ public class PlayView extends JPanel {
}
});

this.splitPane.setDividerLocation(220);
this.splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, empty);
this.splitPane.setResizeWeight(0.0D);
this.splitPane.setDividerLocation(250);
this.splitPane.setDividerSize(4);
this.splitPane.setOpaque(false);

SwingHelper.flattenJSplitPane(this.splitPane);

JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new MigLayout("fill, insets 0", "[]push[]16[]"));
bottomPanel.add(this.selfUpdateButton);
bottomPanel.add(this.switchUserButton);
bottomPanel.add(this.launchButton);
bottomPanel.setBackground(LauncherStyles.LAUNCHER_BACKGROUND);

JPanel container = new ImagePanel("com/gildedgames/assets/images/background.jpg");
container.setLayout(new MigLayout("fill, wrap, insets 0", "[fill]", "[grow]0[]"));
container.add(this.splitPane, "grow, wrap, w null:680, h null:350");
container.add(bottomPanel, "grow, push");
container.setLayout(new BorderLayout());
container.add(this.splitPane, BorderLayout.CENTER);

this.add(container, BorderLayout.CENTER);

@@ -150,7 +173,16 @@ public class PlayView extends JPanel {

this.instancesTable.addMouseListener(new DoubleClickToButtonAdapter(this.launchButton));

this.switchUserButton.addActionListener(e -> this.frame.getLauncherLayout().show(new AccountListView(this.launcher, this.frame)));
this.switchUserButton.addActionListener(e -> {
AccountListView view = new AccountListView(this.launcher, this.frame);
view.setCallback(value -> {
if (value != null) {
this.updateUserIndicator(value);
}
});

this.frame.getLauncherLayout().show(view);
});

this.selfUpdateButton.addActionListener(e -> this.launcher.getUpdateManager().performUpdate(this.frame));

@@ -170,6 +202,9 @@ public class PlayView extends JPanel {
});
}

public void updateUserIndicator(Account account) {
this.userIndicator.setAccount(account);
}

private void popupInstanceMenu(Component component, int x, int y, final Instance selected) {
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