70 lines
2.3 KiB
Java
70 lines
2.3 KiB
Java
package tech.nevets.jaml.gui;
|
|
|
|
import tech.nevets.jaml.Config;
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.util.ArrayList;
|
|
|
|
public class GuiHandler {
|
|
//TODO add config gui for easier config modification
|
|
|
|
public static final int SCREEN_WIDTH = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
|
|
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);
|
|
firstLaunchThread.start();
|
|
}
|
|
|
|
startupFrame.dispose();
|
|
|
|
|
|
Thread homeGuiThread = new Thread(() -> {
|
|
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();
|
|
|
|
}
|
|
|
|
public static void startup() {
|
|
startupFrame = new StartupGui();
|
|
}
|
|
|
|
public void startNewProfileGui() {
|
|
Thread newProfileGuiThread = new Thread(() -> {
|
|
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);
|
|
}
|
|
}
|