Esempio n. 1
0
  /** Cancels the language selection. */
  private void cancel() {
    dispose();
    // Cancel was pressed, revert to the default language
    Language.loadAndActivateLanguage(Settings.DEFAULT_APP_LANGUAGE);
    Settings.remove(Settings.KEY_SETTINGS_VOICE);

    synchronized (WelcomeFrame.this) {
      Sounds.playSoundSample(Sounds.SAMPLE_THANK_YOU, false);
      WelcomeFrame.this.notify(); // Notify the main thread to continue starting the application
    }
  }
Esempio n. 2
0
  /**
   * The entry point of the program.
   *
   * <p>Checks for running instances, and passes arguments if have to. Else loads the settings,
   * language files etc. and then instantiates the main frame.
   *
   * @param arguments if command line mode is desired, they will be handled by the {@link
   *     CliHandler}; else they will be treated as files (like replays, replay lists, replay
   *     sources) and will be opened properly
   * @throws MalformedURLException
   */
  public static void main(final String[] arguments) {
    // Add Sc2gears version and OS info to the User-Agent HTTP request property.
    // The final user agent string will be the value of this property + the default (which is the
    // Java version).
    System.setProperty(
        "http.agent",
        Consts.APPLICATION_NAME
            + "/"
            + Consts.APPLICATION_VERSION
            + " ("
            + System.getProperty("os.name")
            + "; "
            + System.getProperty("os.version")
            + "; "
            + System.getProperty("os.arch")
            + ")");

    checkFolders();

    Settings.loadProperties();

    final boolean cliMode = CliHandler.checkCliMode(arguments);

    if (!cliMode) {
      InstanceMonitor.checkRunningInstance(arguments);
      Log.init();
    }

    if (!cliMode) {
      installExtraLAFs();
      GuiUtils.setLAF(Settings.getString(Settings.KEY_SETTINGS_LAF));
    }

    if (Settings.doesSettingsFileExist()) {
      Language.loadAndActivateLanguage(Settings.getString(Settings.KEY_SETTINGS_LANGUAGE));
    } else {
      // Only show the welcome frame if we're not in CLI mode
      if (!cliMode) {
        final WelcomeFrame welcomeFrame = new WelcomeFrame();
        synchronized (welcomeFrame) {
          try {
            welcomeFrame.wait(); // Wait until the welcome frame is closed.
          } catch (final InterruptedException ie) {
            // This should never happen.
          }
        }
      }
    }

    // Now language is loaded, initialize codes that build on it.
    Language.applyDateTimeFormats();
    Settings.completeDefaultPropertiesInitialization();
    GuiUtils.initFileFilters();

    // Must be after completeDefaultPropertiesInitialization()!
    checkAndPerformPostUpdate();

    // Ensure ReplayUtils and AbilityCodesRepository is initialized
    // (else opening a replay from the file menu or by the CilHandler would fail!)
    try {
      Class.forName(ReplayUtils.class.getName());
    } catch (final ClassNotFoundException cfe) {
      // Never to happen
      cfe.printStackTrace();
    }

    if (cliMode) System.exit(CliHandler.handleArguments(arguments));
    else {
      // Load the Native class now, else later it might hang (dead lock?)
      if (GeneralUtils.isWindows()) // Currently JNA is only used on windows
      try {
          Class.forName(Native.class.getName());
        } catch (final ClassNotFoundException cfe) {
          // Never to happen
          cfe.printStackTrace();
        }

      // Apply proxy config
      applyProxyConfig();

      // Load plugins
      PluginManager.loadPlugins();

      // Now instantiate the main frame
      new MainFrame(arguments);
    }
  }