Пример #1
0
  /** @since 3.0.5 */
  public static void showDBResults(StartupParameters params) {
    // System.err.println("not implemented full yet");

    // We want to do this, but because we don't know if structure-gui.jar is in the classpath we use
    // reflection to hide the calls

    UserConfiguration config = UserConfiguration.fromStartupParams(params);

    String tableClass = "org.biojava.nbio.structure.align.gui.DBResultTable";

    try {
      Class<?> c = Class.forName(tableClass);
      Object table = c.newInstance();

      Method show = c.getMethod("show", new Class[] {File.class, UserConfiguration.class});

      show.invoke(table, new File(params.getShowDBresult()), config);

    } catch (Exception e) {
      e.printStackTrace();

      System.err.println(
          "Probably structure-gui.jar is not in the classpath, can't show results...");
    }

    // DBResultTable table = new DBResultTable();

    // table.show(new File(params.getShowDBresult()),config);

  }
  @Override
  public void runGame(String user, String session, String downloadTicket) {
    Dimension size;
    if (OperatingSystem.getOS() == OperatingSystem.WINDOWS_8) {
      size = new Dimension(900, 540);
    } else {
      size = new Dimension(880, 520);
    }

    Dimension currentSize = Launcher.getSkin().getLoginFrame().getSize();
    Point location = Launcher.getSkin().getLoginFrame().getLocation();
    Point centeredLoc =
        new Point(
            location.x + (currentSize.width - size.width) / 2,
            location.y + (currentSize.height - size.height) / 2);

    this.setLocation(centeredLoc);
    this.setSize(size);

    ((SimpleGameUpdater) Launcher.getGameUpdater()).setWaiting(true);
    while (!((SimpleGameUpdater) Launcher.getGameUpdater()).isFinished()) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException ignore) {
      }
    }

    Applet applet = null;
    try {
      applet = MinecraftLauncher.getMinecraftApplet();
    } catch (CorruptedMinecraftJarException corruption) {
      corruption.printStackTrace();
    } catch (MinecraftVerifyException verify) {
      Launcher.clearCache();
      JOptionPane.showMessageDialog(
          getParent(),
          "Your Minecraft installation is corrupt, but has been cleaned. \nTry to login again. If that fails, close and \nrestart the appplication.");
      this.setVisible(false);
      this.dispose();
      return;
    }
    if (applet == null) {
      String message = "Failed to launch Spoutcraft!";
      this.setVisible(false);
      JOptionPane.showMessageDialog(getParent(), message);
      this.dispose();
      return;
    }

    StartupParameters params = Utils.getStartupParameters();

    minecraft = new MinecraftAppletEnglober(applet);
    minecraft.addParameter("username", user);
    minecraft.addParameter("sessionid", session);
    minecraft.addParameter("downloadticket", downloadTicket);
    minecraft.addParameter("spoutcraftlauncher", "true");
    minecraft.addParameter("portable", params.isPortable() + "");
    if (params.getServer() != null) {
      minecraft.addParameter("server", params.getServer());
      if (params.getPort() != null) {
        minecraft.addParameter("port", params.getPort());
      } else {
        minecraft.addParameter("port", "25565");
      }
    }
    if (params.getProxyHost() != null) {
      minecraft.addParameter("proxy_host", params.getProxyHost());
    }
    if (params.getProxyPort() != null) {
      minecraft.addParameter("proxy_port", params.getProxyPort());
    }
    if (params.getProxyUser() != null) {
      minecraft.addParameter("proxy_user", params.getProxyUser());
    }
    if (params.getProxyPassword() != null) {
      minecraft.addParameter("proxy_pass", params.getProxyPassword());
    }

    applet.setStub(minecraft);
    this.add(minecraft);

    validate();
    this.setVisible(true);
    minecraft.init();
    minecraft.setSize(getWidth(), getHeight());
    minecraft.start();
    Launcher.getSkin().getLoginFrame().onRawEvent(Event.GAME_LAUNCH);
    return;
  }
  public void runGame(String user, String session, String downloadTicket) {
    Dimension size = WindowMode.getModeById(Settings.getWindowModeId()).getDimension(this);
    Point centeredLoc =
        WindowMode.getModeById(Settings.getWindowModeId())
            .getCenteredLocation(Launcher.getLoginFrame());

    this.setLocation(centeredLoc);
    this.setSize(size);

    Launcher.getGameUpdater().setWaiting(true);
    while (!Launcher.getGameUpdater().isFinished()) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException ignore) {
      }
    }

    Applet applet = null;
    try {
      applet =
          MinecraftLauncher.getMinecraftApplet(Launcher.getGameUpdater().getBuild().getLibraries());
    } catch (CorruptedMinecraftJarException corruption) {
      corruption.printStackTrace();
    } catch (MinecraftVerifyException verify) {
      Launcher.clearCache();
      JOptionPane.showMessageDialog(
          getParent(),
          "Your Minecraft installation is corrupt, but has been cleaned. \nTry to login again.\n\n If that fails, close and restart the appplication.");
      this.setVisible(false);
      this.dispose();
      Launcher.getLoginFrame().enableForm();
      return;
    }
    if (applet == null) {
      String message = "Failed to launch Spoutcraft!";
      this.setVisible(false);
      JOptionPane.showMessageDialog(getParent(), message);
      this.dispose();
      Launcher.getLoginFrame().enableForm();
      return;
    }

    StartupParameters params = Utils.getStartupParameters();

    minecraft = new MinecraftAppletEnglober(applet);
    minecraft.addParameter("username", user);
    minecraft.addParameter("sessionid", session);
    minecraft.addParameter("downloadticket", downloadTicket);
    minecraft.addParameter("spoutcraftlauncher", "true");
    minecraft.addParameter("portable", params.isPortable() + "");
    if (params.getServer() != null) {
      minecraft.addParameter("server", params.getServer());
      if (params.getPort() != null) {
        minecraft.addParameter("port", params.getPort());
      } else {
        minecraft.addParameter("port", "25565");
      }
    } else if (Settings.getDirectJoin() != null && Settings.getDirectJoin().length() > 0) {
      String address = Settings.getDirectJoin();
      String port = "25565";
      if (address.contains(":")) {
        String[] s = address.split(":");
        address = s[0];
        port = s[1];
      }
      minecraft.addParameter("server", address);
      minecraft.addParameter("port", port);
    }
    if (params.getProxyHost() != null) {
      minecraft.addParameter("proxy_host", params.getProxyHost());
    }
    if (params.getProxyPort() != null) {
      minecraft.addParameter("proxy_port", params.getProxyPort());
    }
    if (params.getProxyUser() != null) {
      minecraft.addParameter("proxy_user", params.getProxyUser());
    }
    if (params.getProxyPassword() != null) {
      minecraft.addParameter("proxy_pass", params.getProxyPassword());
    }
    // minecraft.addParameter("fullscreen", WindowMode.getModeById(Settings.getWindowModeId()) ==
    // WindowMode.FULL_SCREEN ? "true" : "false");

    applet.setStub(minecraft);
    this.add(minecraft);

    validate();
    this.setVisible(true);
    minecraft.init();
    minecraft.setSize(getWidth(), getHeight());
    minecraft.start();
    Launcher.getLoginFrame().onEvent(Event.GAME_LAUNCH);
    return;
  }