Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. package fr.fazacube.fazacube.bootstrap;
  2.  
  3. import static fr.theshark34.swinger.Swinger.*;
  4.  
  5.  
  6. import java.io.File;
  7. import java.io.IOException;
  8.  
  9. import fr.theshark34.openlauncherlib.bootstrap.Bootstrap;
  10. import fr.theshark34.openlauncherlib.bootstrap.LauncherClasspath;
  11. import fr.theshark34.openlauncherlib.bootstrap.LauncherInfos;
  12. import fr.theshark34.openlauncherlib.util.ErrorUtil;
  13. import fr.theshark34.openlauncherlib.util.GameDir;
  14. import fr.theshark34.openlauncherlib.util.SplashScreen;
  15. import fr.theshark34.supdate.BarAPI;
  16. import fr.theshark34.supdate.SUpdate;
  17. import fr.theshark34.swinger.colored.SColoredBar;
  18.  
  19. public class FazacubeBootstrap {
  20.  
  21. private static SplashScreen splash;
  22. private static SColoredBar bar;
  23. private static Thread barThread;
  24.  
  25. private static final LauncherInfos FC_B_INFOS = new LauncherInfos("Fazacube", "fr.fazacube.fazacube.Launcher.LauncherFrame");
  26. private static final File FC_DIR = GameDir.createGameDir("Fazacube");
  27. private static final LauncherClasspath FC_B_CP = new LauncherClasspath(new File(FC_DIR, "Launcher/launcher.jar"), new File(FC_DIR, "Launcher/Libs/"));
  28.  
  29. private static ErrorUtil errorUtil= new ErrorUtil(new File (FC_DIR, "Launcher/crashes/"));
  30.  
  31. public static void main(String[] args) {
  32. setResourcePath("/fr/fazazcube/fazacube/bootstrap/resources/");
  33. displaySplash();
  34. try {
  35. doUpdate();
  36. } catch (Exception e) {
  37. errorUtil.catchError(e, "Impossible de mettre a jour le launcher !");
  38. barThread.interrupt();
  39. }
  40. try {
  41. launchLauncher();
  42. } catch (IOException e) {
  43. errorUtil.catchError(e, "Impossible de lancer le launcher !");
  44. }
  45. }
  46. private static void displaySplash() {
  47. splash = new SplashScreen("Fazacube", getResource("splash.png"));
  48. splash.setLayout(null);
  49. splash.setBackground(TRANSPARENT);
  50. splash.getContentPane().setBackground(TRANSPARENT);
  51.  
  52. bar = new SColoredBar(getTransparentWhite(100), getTransparentWhite(175));
  53. bar.setBounds(0, 490, 350, 20);
  54. splash.add(bar);
  55.  
  56.  
  57. splash.setVisible(true);
  58.  
  59. }
  60.  
  61. private static void doUpdate() throws Exception {
  62. SUpdate su = new SUpdate("http://launcherfazacube.livehost.fr/bootstrap/", new File(FC_DIR, "Launcher"));
  63.  
  64.  
  65. barThread = new Thread() {
  66. @Override
  67. public void run() {
  68. while(!this.isInterrupted()) {
  69. bar.setValue((int) (BarAPI.getNumberOfTotalDownloadedBytes() / 1000));
  70. bar.setMaximum((int) (BarAPI.getNumberOfTotalBytesToDownload() / 1000));
  71. }
  72. }
  73. };
  74. barThread.start();
  75.  
  76. su.start();
  77. barThread.interrupt();
  78.  
  79. }
  80.  
  81. private static void launchLauncher() throws IOException {
  82. Bootstrap bootstrap = new Bootstrap(FC_B_CP, FC_B_INFOS);
  83. Process p = bootstrap.launch();
  84.  
  85. splash.setVisible(false);
  86.  
  87. try {
  88. p.waitFor();
  89. } catch (InterruptedException e) {
  90. }
  91. System.exit(0);
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement