Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.mine4craft.bootstrap;
- import java.awt.Color;
- import java.io.File;
- import java.io.IOException;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- 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.supdate.application.integrated.FileDeleter;
- import fr.theshark34.swinger.Swinger;
- import fr.theshark34.swinger.textured.STexturedProgressBar;
- @SuppressWarnings("serial")
- public class MyBootstrap extends JFrame{
- private static SplashScreen splash;
- private static Thread barThread;
- private static JLabel infoText = new JLabel("", 0);
- private static STexturedProgressBar bar ;
- private static final LauncherInfos M4C_B_INFOS = new LauncherInfos("mine4craft", "fr.mine4craft.launcher.LauncherFrame");
- private static File M4C_B_DIR = GameDir.createGameDir("Mine4Craft");
- private static final LauncherClasspath M4C_B_CP = new LauncherClasspath(new File(M4C_B_DIR, "launcher.jar"), new File(M4C_B_DIR, "launcher_lib/"));
- private static ErrorUtil errorUtil = new ErrorUtil(new File(M4C_B_DIR, "crashes"));
- public static void main(String[] args) {
- Swinger.setResourcePath("/fr/mine4craft/bootstrap/ressources/");
- 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...");
- }
- }
- public static void displaySplash() {
- splash = new SplashScreen("Mine4Craft", Swinger.getResource("backgroundbootstrap.png"));
- splash.setLayout(null);
- infoText.setBounds(300, 470, 300, 20);
- infoText.setFont(infoText.getFont().deriveFont(20.0F));
- infoText.setForeground(Color.WHITE);
- splash.add(infoText);
- bar = new STexturedProgressBar(Swinger.getResource("barre_vide.png"), Swinger.getResource("barre_pleine.png"));
- bar.setBounds(0, 490, 900, 10);
- splash.add(bar);
- splash.setIconImage(Swinger.getResource("favicon.png"));
- splash.setVisible(true);
- }
- public static void doUpdate() throws Exception{
- SUpdate su = new SUpdate("http://mine4craft.fr/bootstrapdata/", M4C_B_DIR);
- su.getServerRequester().setRewriteEnabled(true);
- su.addApplication(new FileDeleter());
- barThread = new Thread () {
- @Override
- public void run(){
- while(!this.isInterrupted()){
- infoText.setText("Verification du launcher");
- bar.setValue((int)(BarAPI.getNumberOfTotalDownloadedBytes()/ 1000));
- bar.setMaximum((int) (BarAPI.getNumberOfTotalBytesToDownload()/ 100));
- }
- }
- };
- barThread.start();
- su.start();
- barThread.interrupt();
- }
- private static void launchLauncher() throws IOException{
- Bootstrap bootstrap = new Bootstrap(M4C_B_CP, M4C_B_INFOS);
- Process p = bootstrap.launch();
- infoText.setText("Lancement du launcher");
- splash.setVisible(false);
- try {
- p.waitFor();
- }
- catch (InterruptedException e){
- System.exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement