Browse Source

Added GZIP support to bootstrapper, added Java settings, added Patreon badge

master
JellySquid 4 years ago
parent
commit
73497b72a6
10 changed files with 256 additions and 35 deletions
  1. +16
    -1
      launcher-aether/src/main/java/com/gildedgames/launcher/ui/panels/TitlebarPanel.java
  2. +4
    -0
      launcher-aether/src/main/java/com/gildedgames/launcher/ui/resources/LauncherIcons.java
  3. +212
    -24
      launcher-aether/src/main/java/com/gildedgames/launcher/ui/views/OptionsView.java
  4. BIN
      launcher-aether/src/main/resources/com/gildedgames/assets/icons/16/patreon.png
  5. +10
    -0
      launcher-bootstrap/src/main/java/com/skcraft/launcher/Bootstrap.java
  6. +1
    -1
      launcher-bootstrap/src/main/java/com/skcraft/launcher/bootstrap/Downloader.java
  7. +7
    -3
      launcher-bootstrap/src/main/java/com/skcraft/launcher/bootstrap/LauncherBinary.java
  8. +2
    -2
      launcher-bootstrap/src/main/resources/com/skcraft/launcher/bootstrap.properties
  9. BIN
      launcher-bootstrap/src/main/resources/com/skcraft/launcher/bootstrapper_icon.png
  10. +4
    -4
      launcher-bootstrap/src/main/resources/com/skcraft/launcher/lang/Bootstrap.properties

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

@@ -23,6 +23,8 @@ import java.net.URI;
public class TitlebarPanel extends JPanel {
private static final String REPORT_BUG_URL = "https://git.gildedgames.com/GildedGames/Aether-Launcher/issues";

private static final String PATREON_URL = "https://patreon.com/GildedGames";

private final JFrame frame;

public TitlebarPanel(final LauncherFrame frame) {
@@ -30,7 +32,7 @@ public class TitlebarPanel extends JPanel {

Font font = LauncherFonts.OPEN_SANS_REGULAR;

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

JLabel icon = new JLabel();
@@ -46,6 +48,19 @@ public class TitlebarPanel extends JPanel {

this.add(title);

FlatButton patreon = new FlatButton("Support us on Patreon", LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
patreon.setStyle(FlatButton.ButtonStyle.TRANSPARENT);
patreon.setButtonIcon(LauncherIcons.PATREON);
patreon.addActionListener(e -> {
try {
Desktop.getDesktop().browse(URI.create(PATREON_URL));
} catch (IOException e1) {
SwingHelper.showErrorDialog(this.frame, "An error occured opening the bug tracker.", "Well, this is akward.", e1);
}
});

this.add(patreon);

FlatButton bug = new FlatButton("Report an issue", LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));
bug.setStyle(FlatButton.ButtonStyle.TRANSPARENT);
bug.setButtonIcon(LauncherIcons.BUG);


+ 4
- 0
launcher-aether/src/main/java/com/gildedgames/launcher/ui/resources/LauncherIcons.java View File

@@ -21,6 +21,8 @@ public class LauncherIcons {

public static final ImageIcon BUG, WARN;

public static final ImageIcon PATREON;

public static final ImageIcon WINDOW_MINIMIZE, WINDOW_CLOSE, WINDOW_MAXIMIZE;

public static final ImageIcon WINDOW_ICON;
@@ -35,6 +37,8 @@ public class LauncherIcons {
BUG = loadIcon("com/gildedgames/assets/icons/16/bug.png");
WARN = loadIcon("com/gildedgames/assets/icons/16/warn.png");

PATREON = loadIcon("com/gildedgames/assets/icons/16/patreon.png");

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


+ 212
- 24
launcher-aether/src/main/java/com/gildedgames/launcher/ui/views/OptionsView.java View File

@@ -21,8 +21,9 @@ import com.skcraft.launcher.util.SwingExecutor;
import javax.annotation.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.nio.file.Files;
import java.text.DecimalFormat;
import java.util.HashSet;
import java.util.Set;
@@ -53,7 +54,10 @@ public class OptionsView extends JPanel {
this.pane.addTab("General", general);
this.savable.add(general);

this.pane.addTab("Minecraft", new JPanel());
MinecraftPanel minecraft = new MinecraftPanel(this.launcher);

this.pane.addTab("Minecraft", minecraft);
this.savable.add(minecraft);

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

@@ -134,9 +138,7 @@ public class OptionsView extends JPanel {
private final JLabel cacheSizeLabel;

public GeneralPanel(Launcher launcher) {
this.setOpaque(false);
this.setLayout(new GridBagLayout());
this.setBorder(BorderFactory.createEmptyBorder(20, 35, 20, 35));
super();

GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
@@ -146,7 +148,6 @@ public class OptionsView extends JPanel {
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.NORTHWEST;

c.ipady = 12;
c.gridy = 0;

this.addLabel("Storage", c, 16.0f);
@@ -253,25 +254,36 @@ public class OptionsView extends JPanel {

this.add(clearCacheButton, c);

// c.gridy = 4;
// c.ipady = 12;
//
// this.addLabel("Keys", c, 16.0f);
//
// c.gridy = 5;
//
// this.addLabel("Game keys unlock special access to features and other goodies. Every key is unique.", c, 12.0f);
//
// c.gridy = 6;
//
// c.weightx = 0.0D;
// c.weighty = 1.0D;
// c.ipady = 0;
//
c.gridy = 10;

this.add(Box.createVerticalStrut(20), c);

c.gridy = 11;

this.addLabel("Keys", c, 16.0f);

c.gridy = 12;

this.add(Box.createVerticalStrut(12), c);

c.gridy = 13;

this.addLabel("Game keys unlock special access to features and other goodies. Every key is unique.", c, 12.0f);

c.gridy = 14;

c.weightx = 0.0D;
c.weighty = 1.0D;
c.ipady = 0;

this.add(Box.createVerticalStrut(12), c);

c.gridy = 15;

this.gameKey = new FlatTextField("Game key");
this.gameKey.setPreferredSize(new Dimension(400, 25));
//
// this.add(this.gameKey, c);
this.add(this.gameKey, c);
}

private void refreshCacheSize() {
@@ -295,6 +307,7 @@ public class OptionsView extends JPanel {
}
}, SwingExecutor.INSTANCE);
}

@Override
public void save(Launcher launcher, Configuration config) {
config.setGameKey(this.gameKey.getText());
@@ -307,11 +320,186 @@ public class OptionsView extends JPanel {

@Override
public void validate(Launcher launcher, Configuration config) throws ConfigurationValidationException {
// throw new ConfigurationValidationException("Oops");

}
}

private class MinecraftPanel extends SettingsPanel {
private final Launcher launcher;

private JCheckBox autoManageMemory;

private JSpinner maxMemorySpinner, minMemorySpinner, youngGenMemorySpinner;

private FlatTextField jvmPath, jvmArgs;

public MinecraftPanel(Launcher launcher) {
this.launcher = launcher;

this.initComponents();
}

private void initComponents() {
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridheight = 1;
c.gridwidth = 1;
c.weightx = 1.0D;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.NORTHWEST;

c.gridy = 0;

this.addLabel("Java", c, 16.0f);

c.gridy = 1;

this.add(Box.createVerticalStrut(12), c);

c.gridy = 2;

this.autoManageMemory = new JCheckBox("Auto manage memory (recommended)");
this.autoManageMemory.addActionListener(e -> this.updateMemorySpinners());
this.autoManageMemory.setOpaque(false);
this.autoManageMemory.setForeground(Color.WHITE);
this.autoManageMemory.setFont(LauncherFonts.OPEN_SANS_REGULAR.deriveFont(12.0f));

this.add(this.autoManageMemory, c);

// Max Memory
c.gridy = 3;
this.add(Box.createVerticalStrut(20), c);

c.gridy = 4;
this.addLabel("Max Memory", c, 12.0f);

c.gridx = 1;
this.maxMemorySpinner = new JSpinner();
this.maxMemorySpinner.setPreferredSize(new Dimension(200, 20));

this.add(this.maxMemorySpinner, c);

// Min memory
c.gridx = 0;
c.gridy = 5;
this.add(Box.createVerticalStrut(10), c);

c.gridy = 6;
this.addLabel("Minimum Memory", c, 12.0f);

c.gridx = 1;
this.minMemorySpinner = new JSpinner();
this.minMemorySpinner.setPreferredSize(new Dimension(200, 20));

this.add(this.minMemorySpinner, c);

// PermGen
c.gridx = 0;
c.gridy = 7;
this.add(Box.createVerticalStrut(10), c);

c.gridy = 8;
this.addLabel("YoungGen Memory", c, 12.0f);

c.gridx = 1;

this.youngGenMemorySpinner = new JSpinner();
this.youngGenMemorySpinner.setPreferredSize(new Dimension(200, 20));

this.add(this.youngGenMemorySpinner, c);

// JVM Path
c.gridx = 0;
c.gridy = 9;

this.add(Box.createVerticalStrut(30), c);

c.gridy = 10;

this.addLabel("Java Path", c, 12.0f);

c.gridx = 1;
this.jvmPath = new FlatTextField("(default)");
this.jvmPath.setPreferredSize(new Dimension(400, 26));

this.add(this.jvmPath, c);

// JVM Path
c.gridx = 0;
c.gridy = 11;

this.add(Box.createVerticalStrut(10), c);

c.gridy = 12;

this.addLabel("Java Arguments", c, 12.0f);

c.gridx = 1;
this.jvmArgs = new FlatTextField("(none)");
this.jvmArgs.setPreferredSize(new Dimension(400, 26));

this.add(this.jvmArgs, c);
}

private void updateMemorySpinners() {
boolean enabled = !this.autoManageMemory.isSelected();

this.minMemorySpinner.setEnabled(enabled);
this.maxMemorySpinner.setEnabled(enabled);
this.youngGenMemorySpinner.setEnabled(enabled);

if (this.autoManageMemory.isSelected()) {
this.launcher.setOptimizedMemoryConfig();

Configuration config = this.launcher.getConfig();

this.maxMemorySpinner.setValue(config.getMaxMemory());
this.minMemorySpinner.setValue(config.getMinMemory());
this.youngGenMemorySpinner.setValue(config.getYoungGen());
}
}

@Override
public void save(Launcher launcher, Configuration config) {
config.setJvmPath(this.jvmPath.getText());
config.setJvmArgs(this.jvmArgs.getText());
config.setYoungGen((Integer) this.youngGenMemorySpinner.getValue());
config.setMaxMemory((Integer) this.maxMemorySpinner.getValue());
config.setMinMemory((Integer) this.minMemorySpinner.getValue());
config.setMemoryManaged(this.autoManageMemory.isSelected());

if (this.autoManageMemory.isSelected()) {
launcher.setOptimizedMemoryConfig();
}
}

@Override
public void load(Launcher launcher, Configuration config) {
this.jvmPath.setText(config.getJvmPath());
this.jvmArgs.setText(config.getJvmArgs());
this.youngGenMemorySpinner.setValue(config.getYoungGen());
this.maxMemorySpinner.setValue(config.getMaxMemory());
this.minMemorySpinner.setValue(config.getMinMemory());
this.autoManageMemory.setSelected(config.isMemoryManaged());

this.updateMemorySpinners();
}

@Override
public void validate(Launcher launcher, Configuration config) throws ConfigurationValidationException {
if ((int) this.maxMemorySpinner.getValue() < (int) this.minMemorySpinner.getValue()) {
throw new ConfigurationValidationException("The minimum memory value cannot be smaller than the max memory value.");
}
}
}

private abstract class SettingsPanel extends JPanel {
public SettingsPanel() {
this.setOpaque(false);
this.setLayout(new GridBagLayout());
this.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

protected void addLabel(String text, GridBagConstraints c, float size) {
JLabel label = new JLabel(text);
label.setFont(LauncherFonts.OPEN_SANS_REGULAR.deriveFont(size));


BIN
launcher-aether/src/main/resources/com/gildedgames/assets/icons/16/patreon.png View File

Before After
Width: 16  |  Height: 16  |  Size: 456 B

+ 10
- 0
launcher-bootstrap/src/main/java/com/skcraft/launcher/Bootstrap.java View File

@@ -49,6 +49,12 @@ public class Bootstrap {

boolean portable = isPortableMode();

if (!isJava8()) {
JOptionPane.showMessageDialog(null, "The Aether launcher requires Java 8 or newer. Please update your installation of Java.", "Outdated Java", JOptionPane.ERROR_MESSAGE);

return;
}

Bootstrap bootstrap = new Bootstrap(portable, args);

Bootstrap.addLetsEncryptSSL();
@@ -76,6 +82,10 @@ public class Bootstrap {
binariesDir.mkdirs();
}

private static boolean isJava8() {
return System.getProperty("java.version").startsWith("1.8.");
}

public void cleanup() {
File[] files = binariesDir.listFiles(new FileFilter() {
@Override


+ 1
- 1
launcher-bootstrap/src/main/java/com/skcraft/launcher/bootstrap/Downloader.java View File

@@ -61,7 +61,7 @@ public class Downloader implements Runnable, ProgressObservable {
}
});

File finalFile = new File(bootstrap.getBinariesDir(), System.currentTimeMillis() + ".jar.pack");
File finalFile = new File(bootstrap.getBinariesDir(), System.currentTimeMillis() + ".jar.pack.gz");
File tempFile = new File(finalFile.getParentFile(), finalFile.getName() + ".tmp");
URL updateUrl = HttpRequest.url(bootstrap.getProperties().getProperty("latestUrl"));



+ 7
- 3
launcher-bootstrap/src/main/java/com/skcraft/launcher/bootstrap/LauncherBinary.java View File

@@ -15,13 +15,14 @@ import java.util.jar.Pack200;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;

import static com.skcraft.launcher.bootstrap.BootstrapUtils.closeQuietly;

@Log
public class LauncherBinary implements Comparable<LauncherBinary> {

public static final Pattern PATTERN = Pattern.compile("^([0-9]+)\\.jar(\\.pack)?$");
public static final Pattern PATTERN = Pattern.compile("^([0-9]+)\\.jar(\\.pack.gz)?$");
@Getter
private final File path;
private final long time;
@@ -43,13 +44,14 @@ public class LauncherBinary implements Comparable<LauncherBinary> {
log.log(Level.INFO, "Need to unpack " + path.getAbsolutePath());

String packName = path.getName();
File outputPath = new File(path.getParentFile(), packName.substring(0, packName.length() - 5));
File outputPath = new File(path.getParentFile(), packName.substring(0, packName.length() - 7));

if (outputPath.exists()) {
return outputPath;
}

FileInputStream fis = null;
GZIPInputStream gis = null;
BufferedInputStream bis = null;
FileOutputStream fos = null;
BufferedOutputStream bos = null;
@@ -57,7 +59,8 @@ public class LauncherBinary implements Comparable<LauncherBinary> {

try {
fis = new FileInputStream(path);
bis = new BufferedInputStream(fis);
gis = new GZIPInputStream(fis);
bis = new BufferedInputStream(gis);
fos = new FileOutputStream(outputPath);
bos = new BufferedOutputStream(fos);
jos = new JarOutputStream(bos);
@@ -67,6 +70,7 @@ public class LauncherBinary implements Comparable<LauncherBinary> {
closeQuietly(bos);
closeQuietly(fos);
closeQuietly(bis);
closeQuietly(gis);
closeQuietly(fis);
}



+ 2
- 2
launcher-bootstrap/src/main/resources/com/skcraft/launcher/bootstrap.properties View File

@@ -4,7 +4,7 @@
# Please see LICENSE.txt for license information.
#

homeFolderWindows=Gilded Games
homeFolder=.gglauncher
homeFolderWindows=Aether Launcher
homeFolder=.aether_launcher
launcherClass=com.gildedgames.launcher.Start
latestUrl=https://files.gildedgames.com/minecraft/launcher/latest.json

BIN
launcher-bootstrap/src/main/resources/com/skcraft/launcher/bootstrapper_icon.png View File

Before After
Width: 48  |  Height: 48  |  Size: 19 KiB Width: 48  |  Height: 48  |  Size: 1.5 KiB

+ 4
- 4
launcher-bootstrap/src/main/resources/com/skcraft/launcher/lang/Bootstrap.properties View File

@@ -7,15 +7,15 @@
button.cancal=Cancel

errorTitle=Error
errors.failedDownloadError=The GG launcher could not be downloaded.
errors.failedDownloadError=The Aether launcher could not be downloaded.
errors.bootstrapError=An error occurred while trying to bootstrap the launcher\!

errorDialog.reportError=To report this error, provide\:

downloader.title=Downloading GG Launcher...
downloader.title=Downloading Aether Launcher...
downloader.pleaseWait=Please wait...
downloader.status=Downloading latest GG Launcher...
downloader.progressStatus=Downloading latest GG Launcher (%.2f%%)...
downloader.status=Downloading Aether Launcher updates...
downloader.progressStatus=Downloading Aether Launcher (%.2f%%)...

progress.confirmCancel=Are you sure that you wish to cancel?
progress.confirmCancelTitle=Cancel

Loading…
Cancel
Save