0.7.0 release
This commit is contained in:
@@ -52,6 +52,8 @@ public class Config {
|
||||
YML_FILE.setComment("launcher.default-profile", "Set's the profile that will be loaded automatically");
|
||||
YML_FILE.addDefault("launcher.path","default");
|
||||
YML_FILE.setComment("launcher.path","Path to JAML files\n" + "default: " + JAML.path.toString());
|
||||
YML_FILE.addDefault("launcher.keep-open", false);
|
||||
YML_FILE.setComment("launcher.keep-open", "Keeps the launcher open after launching the game");
|
||||
YML_FILE.addDefault("launcher.first-launch", true);
|
||||
YML_FILE.setComment("launcher.first-launch", "Do Not Change, will regenerate files");
|
||||
YML_FILE.addDefault("launcher.verbose", false);
|
||||
|
||||
@@ -9,8 +9,8 @@ public class JAML {
|
||||
public static GuiHandler guiHandler;
|
||||
|
||||
public static void main(String[] args) {
|
||||
//TODO Create logic to check for first launch without the use of config
|
||||
//TODO make guiHandler run first with the initial splash screen while backend is starting, then start homeGui when done. (Possibly multithreaded)
|
||||
|
||||
//TODO make bash script for jenkins to download optimized jre and bundle it with launch4j
|
||||
|
||||
GuiHandler.startup();
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package tech.nevets.jaml;
|
||||
|
||||
import tech.nevets.jaml.events.LaunchEvent;
|
||||
import tech.nevets.jaml.util.ProfileUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -7,9 +8,9 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Launch {
|
||||
public class Launcher {
|
||||
|
||||
public Launch(int jdkVersion, int memoryAmount, String garbageCollection, boolean printConsole) throws IOException {
|
||||
public Launcher(int jdkVersion, int memoryAmount, String garbageCollection, boolean printConsole) throws IOException {
|
||||
ArrayList<String> commandArray = parseCommand(jdkVersion, memoryAmount, garbageCollection);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -22,6 +23,9 @@ public class Launch {
|
||||
|
||||
System.out.println(command);
|
||||
|
||||
LaunchEvent e = new LaunchEvent();
|
||||
e.triggerEvent();
|
||||
|
||||
ProcessBuilder process = new ProcessBuilder();
|
||||
process.directory(ProfileUtils.activeProfile.getGamePath());
|
||||
process.command(command);
|
||||
27
src/main/java/tech/nevets/jaml/events/LaunchEvent.java
Normal file
27
src/main/java/tech/nevets/jaml/events/LaunchEvent.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package tech.nevets.jaml.events;
|
||||
|
||||
import tech.nevets.jaml.Config;
|
||||
import tech.nevets.jaml.gui.GuiHandler;
|
||||
import tech.nevets.jaml.listeners.LaunchListener;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LaunchEvent {
|
||||
private List<LaunchListener> listeners = new ArrayList<>();
|
||||
|
||||
public void addListener(LaunchListener eventListener) {
|
||||
listeners.add(eventListener);
|
||||
}
|
||||
|
||||
public void triggerEvent() {
|
||||
if (!Config.CONFIG.getBoolean("launcher.keep-open")) {
|
||||
for (LaunchListener ll : listeners){
|
||||
for (JFrame frame : GuiHandler.frames) {
|
||||
ll.hideGui(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import tech.nevets.jaml.util.ProfileUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -15,6 +17,12 @@ public class FirstLoginGui extends JFrame {
|
||||
public FirstLoginGui() {
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
removeFromArray();
|
||||
}
|
||||
});
|
||||
setBounds(100, 100, 360, 330);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
@@ -90,4 +98,8 @@ public class FirstLoginGui extends JFrame {
|
||||
});
|
||||
contentPane.add(button);
|
||||
}
|
||||
|
||||
private void removeFromArray() {
|
||||
GuiHandler.removeFromFramesArray(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package tech.nevets.jaml.gui;
|
||||
|
||||
import tech.nevets.jaml.Config;
|
||||
import tech.nevets.jaml.JAML;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GuiHandler {
|
||||
|
||||
@@ -12,8 +12,16 @@ public class GuiHandler {
|
||||
public static final int SCREEN_HEIGHT = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
|
||||
|
||||
private static StartupGui startupFrame;
|
||||
public static ArrayList<JFrame> frames = new ArrayList<>();
|
||||
|
||||
public GuiHandler() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("Using default look and feel");
|
||||
}
|
||||
|
||||
if (Config.getConfig().getBoolean("launcher.first-launch")) {
|
||||
FirstLaunchGui firstLaunchGui = new FirstLaunchGui();
|
||||
Thread firstLaunchThread = new Thread(firstLaunchGui);
|
||||
@@ -22,12 +30,14 @@ public class GuiHandler {
|
||||
|
||||
startupFrame.dispose();
|
||||
|
||||
|
||||
Thread homeGuiThread = new Thread(() -> {
|
||||
HomeGui frame = new HomeGui();
|
||||
frame.setTitle("JAML");
|
||||
frame.setIconImage(new ImageIcon(JAML.path + "\\assets\\icon.png").getImage());
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
HomeGui homeFrame = new HomeGui();
|
||||
homeFrame.setTitle("JAML");
|
||||
homeFrame.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("assets/icon.png")).getImage());
|
||||
homeFrame.setLocationRelativeTo(null);
|
||||
homeFrame.setVisible(true);
|
||||
addToFramesArray(homeFrame);
|
||||
});
|
||||
homeGuiThread.start();
|
||||
|
||||
@@ -39,12 +49,20 @@ public class GuiHandler {
|
||||
|
||||
public void startNewProfileGui() {
|
||||
Thread newProfileGuiThread = new Thread(() -> {
|
||||
NewProfileGui frame = new NewProfileGui();
|
||||
frame.setTitle("Create New Profile");
|
||||
frame.setIconImage(new ImageIcon(JAML.path + "\\assets\\icon.png").getImage());
|
||||
frame.setVisible(true);
|
||||
NewProfileGui newProfileFrame = new NewProfileGui();
|
||||
newProfileFrame.setTitle("Create New Profile");
|
||||
newProfileFrame.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("assets/icon.png")).getImage());
|
||||
newProfileFrame.setVisible(true);
|
||||
addToFramesArray(newProfileFrame);
|
||||
});
|
||||
newProfileGuiThread.start();
|
||||
}
|
||||
|
||||
public static void addToFramesArray(JFrame frame) {
|
||||
frames.add(frame);
|
||||
}
|
||||
|
||||
public static void removeFromFramesArray(JFrame frame) {
|
||||
frames.remove(frame);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package tech.nevets.jaml.gui;
|
||||
|
||||
import tech.nevets.jaml.JAML;
|
||||
import tech.nevets.jaml.gui.panels.HomePanel;
|
||||
import tech.nevets.jaml.gui.panels.ProfilePanel;
|
||||
import tech.nevets.jaml.gui.panels.UsersPanel;
|
||||
import tech.nevets.jaml.listeners.RightClickListener;
|
||||
import tech.nevets.jaml.util.ImageUtils;
|
||||
import tech.nevets.jaml.util.ProfileUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
|
||||
public class HomeGui extends JFrame {
|
||||
|
||||
@@ -25,6 +25,12 @@ public class HomeGui extends JFrame {
|
||||
SpringLayout springLayout = new SpringLayout();
|
||||
getContentPane().setLayout(springLayout);
|
||||
addMouseListener(new RightClickListener());
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
removeFromArray();
|
||||
}
|
||||
});
|
||||
|
||||
tabPanel = new JTabbedPane();
|
||||
springLayout.putConstraint(SpringLayout.NORTH, tabPanel, 0, SpringLayout.NORTH, getContentPane());
|
||||
@@ -48,4 +54,8 @@ public class HomeGui extends JFrame {
|
||||
tabPanel.addMouseListener(new RightClickListener());
|
||||
|
||||
}
|
||||
|
||||
private void removeFromArray() {
|
||||
GuiHandler.removeFromFramesArray(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import tech.nevets.jaml.util.ProfileUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -17,7 +19,14 @@ public class NewProfileGui extends JFrame {
|
||||
setUndecorated(true);
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
removeFromArray();
|
||||
}
|
||||
});
|
||||
setBounds(100, 100, 360, 330);
|
||||
setLocationRelativeTo(null);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
@@ -92,6 +101,10 @@ public class NewProfileGui extends JFrame {
|
||||
});
|
||||
contentPane.add(button);
|
||||
}
|
||||
|
||||
private void removeFromArray() {
|
||||
GuiHandler.removeFromFramesArray(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,11 +13,13 @@ import java.nio.file.Path;
|
||||
|
||||
public class StartupGui extends JFrame {
|
||||
JPanel contentPane;
|
||||
private static JLabel currentTaskLabel;
|
||||
|
||||
public StartupGui() {
|
||||
setUndecorated(true);
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setIconImage(new ImageIcon(getClass().getClassLoader().getResource("assets/icon.png")).getImage());
|
||||
setSize(GuiHandler.SCREEN_WIDTH / 3, GuiHandler.SCREEN_HEIGHT / 3);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
@@ -25,6 +27,10 @@ public class StartupGui extends JFrame {
|
||||
contentPane.setLayout(null);
|
||||
setLocationRelativeTo(null);
|
||||
|
||||
currentTaskLabel = new JLabel("");
|
||||
currentTaskLabel.setBounds(30, 279, 176, 20);
|
||||
contentPane.add(currentTaskLabel);
|
||||
|
||||
int pbWidth = (int) (getWidth() / 1.1);
|
||||
int pbHeight = getHeight() / 24;
|
||||
int pbX = (getWidth() - pbWidth) / 2;
|
||||
@@ -52,22 +58,24 @@ public class StartupGui extends JFrame {
|
||||
|
||||
|
||||
progressBar.setProgress(0);
|
||||
currentTaskLabel.setText("Making Directories...");
|
||||
makeDirs();
|
||||
smoothIncrease(progressBar, 20);
|
||||
currentTaskLabel.setText("Loading Config...");
|
||||
currentTaskLabel.repaint();
|
||||
Config.loadConfig();
|
||||
sleep();
|
||||
smoothIncrease(progressBar, 40);
|
||||
currentTaskLabel.setText("Loading Profiles...");
|
||||
ProfileUtils.getProfileList();
|
||||
sleep();
|
||||
smoothIncrease(progressBar, 60);
|
||||
currentTaskLabel.setText("Loading Active Profile...");
|
||||
ProfileUtils.getActiveProfile();
|
||||
sleep();
|
||||
smoothIncrease(progressBar, 80);
|
||||
currentTaskLabel.setText("Getting Game Loaders...");
|
||||
LoaderUtils.getLoaders();
|
||||
sleep();
|
||||
currentTaskLabel.setText("Done!");
|
||||
smoothIncrease(progressBar, 100);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void sleep() {
|
||||
@@ -78,6 +86,10 @@ public class StartupGui extends JFrame {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCurrentTask(String currentTask) {
|
||||
currentTaskLabel.setText(currentTask);
|
||||
}
|
||||
|
||||
private static void makeDirs() {
|
||||
if (System.getenv("JAML_HOME") == null) {
|
||||
JAML.path = Path.of(System.getenv("APPDATA") + "\\.jaml\\");
|
||||
@@ -134,11 +146,6 @@ public class StartupGui extends JFrame {
|
||||
int i = pb.getProgress();
|
||||
while (i <= to) {
|
||||
pb.setProgress(i);
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class HomePanel extends JPanel {
|
||||
|
||||
JLabel backgroundIcon = new JLabel("");
|
||||
backgroundIcon.setBounds(0, 25, 1264, 542);
|
||||
ImageIcon backgroundImg = new ImageIcon(JAML.path + "\\assets\\background.png");
|
||||
ImageIcon backgroundImg = new ImageIcon(getClass().getClassLoader().getResource("assets/background.png"));
|
||||
backgroundImg = ImageUtils.resizeIcon(backgroundImg, backgroundIcon.getWidth(), backgroundIcon.getHeight());
|
||||
backgroundIcon.setIcon(backgroundImg);
|
||||
add(backgroundIcon);
|
||||
|
||||
16
src/main/java/tech/nevets/jaml/listeners/LaunchListener.java
Normal file
16
src/main/java/tech/nevets/jaml/listeners/LaunchListener.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package tech.nevets.jaml.listeners;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.EventListener;
|
||||
|
||||
public class LaunchListener implements EventListener {
|
||||
public void hideGui(JFrame frame) {
|
||||
frame.setVisible(false);
|
||||
System.out.println("Frame: " + frame.getName() + " was hidden!");
|
||||
}
|
||||
|
||||
public void closeGui(JFrame frame) {
|
||||
frame.dispose();
|
||||
System.out.println("Frame: " + frame.getName() + " was closed!");
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package tech.nevets.jaml.listeners;
|
||||
|
||||
import tech.nevets.jaml.gui.RightClickGui;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user