Advertisement
Guest User

Bootstrap

a guest
Jun 25th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. package fr.Neranaton.ReachEscrot.Bootstrap;
  2.  
  3. import static fr.theshark34.swinger.Swinger.getResource;
  4. import static fr.theshark34.swinger.Swinger.setResourcePath;
  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.Swinger;
  18. import fr.theshark34.swinger.colored.SColoredBar;
  19.  
  20. public class ReachEscrotBootstrap {
  21.  
  22. private static SplashScreen splash;
  23. private static SColoredBar bar;
  24. private static Thread barThread;
  25.  
  26. private static final LauncherInfos SC_B_INFOS = new LauncherInfos("ReachEscrot 1", "fr.Neranaton.ReachEscrot.LauncherFrame");
  27. private static final File SC_DIR = GameDir.createGameDir("ReachEscrot 1");
  28. private static final LauncherClasspath SC_B_CP = new LauncherClasspath(new File(SC_DIR, "Launcher/launcher.jar"), new File(SC_DIR, "Launcher/Libs/"));
  29.  
  30. private static ErrorUtil errorUtil = new ErrorUtil(new File(SC_DIR, "Launcher/crashes/*"));
  31.  
  32. public static void main(String[] args) {
  33. Swinger.setResourcePath("fr/Neranaton/ReachEscrot/BootStrap/resources");
  34. displaySplash();
  35. try {
  36. doUpdate();
  37. } catch (Exception e) {
  38. errorUtil.catchError(e, "Impossible de mettre a jour le Launcher !");
  39. barThread.interrupt();
  40. }
  41.  
  42. try {
  43. launchLauncher();
  44. } catch (IOException e) {
  45. errorUtil.catchError(e, "Impossible de lancer le Launcher !");
  46.  
  47. }
  48.  
  49. }
  50.  
  51. private static void displaySplash() {
  52. splash = new SplashScreen("ReachEscrot 1", Swinger.getResource("splash.png"));
  53. bar.setBounds(0, 490, 350, 20);
  54. splash.add(bar);
  55.  
  56. bar = new SColoredBar(Swinger.getTransparentWhite(100), Swinger.getTransparentWhite(175));
  57.  
  58. splash.setVisible(true);
  59.  
  60. }
  61.  
  62. private static void doUpdate() throws Exception {
  63. SUpdate su = new SUpdate("http://escrot.livehost.fr/Bootstrap", new File(SC_DIR, "Launcher"));
  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. };
  75. barThread.start();
  76.  
  77. su.start();
  78. barThread.interrupt();
  79. }
  80.  
  81. private static void launchLauncher() throws IOException {
  82. Bootstrap bootstrap = new Bootstrap(SC_B_CP, SC_B_INFOS);
  83. Process p = bootstrap.launch();
  84.  
  85. splash.setVisible(false);
  86.  
  87. try {
  88. p.waitFor();
  89. } catch (InterruptedException e) {
  90.  
  91. }
  92. System.exit(0);
  93. }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement