Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. package fr.vekorax.derivium.bootstrap;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import fr.theshark34.openlauncherlib.bootstrap.Bootstrap;
  7. import fr.theshark34.openlauncherlib.bootstrap.LauncherClasspath;
  8. import fr.theshark34.openlauncherlib.bootstrap.LauncherInfos;
  9. import fr.theshark34.openlauncherlib.external.ClasspathConstructor;
  10. import fr.theshark34.openlauncherlib.external.ExternalLaunchProfile;
  11. import fr.theshark34.openlauncherlib.external.ExternalLauncher;
  12. import fr.theshark34.openlauncherlib.util.CrashReporter;
  13. import fr.theshark34.openlauncherlib.util.ErrorUtil;
  14. import fr.theshark34.openlauncherlib.util.GameDir;
  15. import fr.theshark34.openlauncherlib.util.SplashScreen;
  16. import fr.theshark34.openlauncherlib.util.explorer.ExploredDirectory;
  17. import fr.theshark34.openlauncherlib.util.explorer.Explorer;
  18. import fr.theshark34.openlauncherlib.util.ramselector.RamSelector;
  19. import fr.theshark34.supdate.BarAPI;
  20. import fr.theshark34.supdate.SUpdate;
  21. import fr.theshark34.swinger.Swinger;
  22. import fr.theshark34.swinger.colored.SColoredBar;
  23.  
  24. public class deriviumbootstrap {
  25.  
  26. private static SplashScreen splash;
  27. private static SColoredBar bar;
  28. private static Thread barThread;
  29.  
  30. private static final LauncherInfos DL_B_INFOS = new LauncherInfos("Derivium", "fr.vekorax.derivium.launcher.LauncherFrame");
  31. private static final File DL_DIR = GameDir.createGameDir("Derivium");
  32. private static final LauncherClasspath DL_B_CP = new LauncherClasspath(new File(DL_DIR, "Launcher/launcher.jar"), new File(DL_DIR, "Launcher/libs/"));
  33. private static final File DL_B_DIR = new File(DL_DIR, "Launcher/crashes/");
  34. private static final CrashReporter errorUtil = new CrashReporter("Derivium", DL_B_DIR);
  35. private static RamSelector selector = new RamSelector(new File(DL_DIR, "ram.txt"));
  36.  
  37. public static void main(String[] args) {
  38. Swinger.setResourcePath("/fr/vekorax/derivium/bootstrap/ressource/");
  39. displaySplash();
  40. try {
  41. doUpdate();
  42. } catch (Exception e) {
  43. errorUtil.catchError(e, "Impossible de mettre a jour le launcher !");
  44. barThread.interrupt();
  45. }
  46.  
  47. try {
  48. launchLauncher();
  49. } catch (IOException e) {
  50. errorUtil.catchError(e, "Impossible de lancer le launcher !");
  51. }
  52. }
  53.  
  54. private static void displaySplash() {
  55. splash = new SplashScreen("Derivium", Swinger.getResource("bootstrap.png"));
  56. splash.setBackground(Swinger.TRANSPARENT);
  57. //splash.getContentPane().setBackground(Swinger.TRANSPARENT);
  58. splash.setLayout(null);
  59.  
  60. bar = new SColoredBar(Swinger.getTransparentWhite(100), Swinger.getTransparentWhite(175));
  61. bar.setBounds(8, 344, 315, 22);
  62. splash.add(bar);
  63.  
  64. splash.setVisible(true);
  65. }
  66.  
  67. private static void doUpdate() throws Exception {
  68. SUpdate su = new SUpdate("https://fabricemorin00.000webhostapp.com/" , new File(DL_DIR, "Launcher"));
  69.  
  70. barThread = new Thread() {
  71. @Override
  72. public void run() {
  73. while(!this.isInterrupted()) {
  74. bar.setValue((int) (BarAPI.getNumberOfTotalDownloadedBytes() / 1000));
  75. bar.setMaximum((int) (BarAPI.getNumberOfTotalBytesToDownload() / 1000));
  76. }
  77.  
  78. }
  79. };
  80. barThread.start();
  81.  
  82. su.start();
  83. //selector.display();
  84. barThread.interrupt();
  85. }
  86.  
  87. private static void launchLauncher() throws IOException {
  88.  
  89. //ClasspathConstructor constructor = new ClasspathConstructor();
  90. //ExploredDirectory gameDir = Explorer.dir("DL_B_DIR");
  91. //constructor.add(gameDir.sub("Libs").allRecursive().files().match("^(.*\\((jar)$))*$"));
  92. //constructor.add(gameDir.get("launcher.jar"));
  93.  
  94. //ExternalLaunchProfile profile = new ExternalLaunchProfile("fr.vekorax.derivium.launcher.LauncherFrame", constructor.make());
  95. //ExternalLauncher Launcher = new ExternalLauncher(profile);
  96.  
  97. Bootstrap bootstrap = new Bootstrap(DL_B_CP, DL_B_INFOS);
  98. Process p = bootstrap.launch();
  99. splash.setVisible(false);
  100. try {
  101. p.waitFor();
  102. } catch (InterruptedException e) {
  103.  
  104. }
  105. System.exit(0);
  106. }
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement