Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.fazacube.fazacube.bootstrap;
- import static fr.theshark34.swinger.Swinger.*;
- import java.io.File;
- import java.io.IOException;
- import fr.theshark34.openlauncherlib.bootstrap.Bootstrap;
- import fr.theshark34.openlauncherlib.bootstrap.LauncherClasspath;
- import fr.theshark34.openlauncherlib.bootstrap.LauncherInfos;
- import fr.theshark34.openlauncherlib.util.ErrorUtil;
- import fr.theshark34.openlauncherlib.util.GameDir;
- import fr.theshark34.openlauncherlib.util.SplashScreen;
- import fr.theshark34.supdate.BarAPI;
- import fr.theshark34.supdate.SUpdate;
- import fr.theshark34.swinger.colored.SColoredBar;
- public class FazacubeBootstrap {
- private static SplashScreen splash;
- private static SColoredBar bar;
- private static Thread barThread;
- private static final LauncherInfos FC_B_INFOS = new LauncherInfos("Fazacube", "fr.fazacube.fazacube.Launcher.LauncherFrame");
- private static final File FC_DIR = GameDir.createGameDir("Fazacube");
- private static final LauncherClasspath FC_B_CP = new LauncherClasspath(new File(FC_DIR, "Launcher/launcher.jar"), new File(FC_DIR, "Launcher/Libs/"));
- private static ErrorUtil errorUtil= new ErrorUtil(new File (FC_DIR, "Launcher/crashes/"));
- public static void main(String[] args) {
- setResourcePath("/fr/fazazcube/fazacube/bootstrap/resources/");
- displaySplash();
- try {
- doUpdate();
- } catch (Exception e) {
- errorUtil.catchError(e, "Impossible de mettre a jour le launcher !");
- barThread.interrupt();
- }
- try {
- launchLauncher();
- } catch (IOException e) {
- errorUtil.catchError(e, "Impossible de lancer le launcher !");
- }
- }
- private static void displaySplash() {
- splash = new SplashScreen("Fazacube", getResource("splash.png"));
- splash.setLayout(null);
- splash.setBackground(TRANSPARENT);
- splash.getContentPane().setBackground(TRANSPARENT);
- bar = new SColoredBar(getTransparentWhite(100), getTransparentWhite(175));
- bar.setBounds(0, 490, 350, 20);
- splash.add(bar);
- splash.setVisible(true);
- }
- private static void doUpdate() throws Exception {
- SUpdate su = new SUpdate("http://launcherfazacube.livehost.fr/bootstrap/", new File(FC_DIR, "Launcher"));
- barThread = new Thread() {
- @Override
- public void run() {
- while(!this.isInterrupted()) {
- bar.setValue((int) (BarAPI.getNumberOfTotalDownloadedBytes() / 1000));
- bar.setMaximum((int) (BarAPI.getNumberOfTotalBytesToDownload() / 1000));
- }
- }
- };
- barThread.start();
- su.start();
- barThread.interrupt();
- }
- private static void launchLauncher() throws IOException {
- Bootstrap bootstrap = new Bootstrap(FC_B_CP, FC_B_INFOS);
- Process p = bootstrap.launch();
- splash.setVisible(false);
- try {
- p.waitFor();
- } catch (InterruptedException e) {
- }
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement