Search in sources :

Example 1 with OnLaunchItem

use of net.technicpack.launcher.ui.listitems.OnLaunchItem in project LauncherV3 by TechnicPack.

the class OptionsDialog method initControlValues.

private void initControlValues() {
    javaArgs.getDocument().removeDocumentListener(javaArgsListener);
    javaArgs.setText(settings.getJavaArgs());
    javaArgs.getDocument().addDocumentListener(javaArgsListener);
    wrapperCommand.getDocument().removeDocumentListener(wrapperCommandListener);
    wrapperCommand.setText(settings.getWrapperCommand());
    wrapperCommand.getDocument().addDocumentListener(wrapperCommandListener);
    installField.setText(settings.getTechnicRoot().getAbsolutePath());
    clientId.setText(settings.getClientId());
    for (ActionListener listener : showConsole.getActionListeners()) showConsole.removeActionListener(listener);
    showConsole.setSelected(settings.getShowConsole());
    showConsole.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeShowConsole();
        }
    });
    for (ActionListener listener : askFirstBox.getActionListeners()) askFirstBox.removeActionListener(listener);
    askFirstBox.setSelected(!settings.shouldAutoAcceptModpackRequirements());
    askFirstBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeAskFirst();
        }
    });
    for (ActionListener listener : useMojangJava.getActionListeners()) useMojangJava.removeActionListener(listener);
    useMojangJava.setSelected(settings.shouldUseMojangJava());
    useMojangJava.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeUseMojangJava();
        }
    });
    for (ActionListener listener : launchToModpacks.getActionListeners()) launchToModpacks.removeActionListener(listener);
    launchToModpacks.setSelected(settings.getLaunchToModpacks());
    launchToModpacks.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeLaunchToModpacks();
        }
    });
    for (ActionListener listener : versionSelect.getActionListeners()) versionSelect.removeActionListener(listener);
    versionSelect.removeAllItems();
    versionSelect.addItem(new DefaultVersionItem(javaVersions.getVersion(null, true), resources));
    IJavaVersion best64Bit = javaVersions.getBest64BitVersion();
    if (best64Bit != null)
        versionSelect.addItem(new Best64BitVersionItem(javaVersions.getVersion("64bit", true), resources));
    for (IJavaVersion version : javaVersions.getVersions()) {
        versionSelect.addItem(new JavaVersionItem(version, resources));
    }
    String settingsVersion = settings.getJavaVersion();
    boolean settingsBitness = settings.getJavaBitness();
    if (settingsVersion == null || settingsVersion.isEmpty() || settingsVersion.equals("default"))
        versionSelect.setSelectedIndex(0);
    else if (settingsVersion.equals("64bit"))
        versionSelect.setSelectedIndex(1);
    else {
        for (int i = 2; i < versionSelect.getItemCount(); i++) {
            if (((JavaVersionItem) versionSelect.getItemAt(i)).getVersionNumber().equals(settingsVersion) && ((JavaVersionItem) versionSelect.getItemAt(i)).is64Bit() == settingsBitness) {
                versionSelect.setSelectedIndex(i);
                break;
            }
        }
    }
    versionSelect.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeJavaVersion();
        }
    });
    rebuildMemoryList();
    for (ActionListener listener : streamSelect.getActionListeners()) {
        streamSelect.removeActionListener(listener);
    }
    streamSelect.removeAllItems();
    streamSelect.addItem(new StreamItem(resources.getString("launcheroptions.build.stable"), "stable"));
    streamSelect.addItem(new StreamItem(resources.getString("launcheroptions.build.beta"), "beta"));
    streamSelect.setSelectedIndex((settings.getBuildStream().equals("beta")) ? 1 : 0);
    streamSelect.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeStream();
        }
    });
    for (ActionListener listener : launchSelect.getActionListeners()) launchSelect.removeActionListener(listener);
    launchSelect.removeAllItems();
    launchSelect.addItem(new OnLaunchItem(resources.getString("launcheroptions.packlaunch.hide"), LaunchAction.HIDE));
    launchSelect.addItem(new OnLaunchItem(resources.getString("launcheroptions.packlaunch.close"), LaunchAction.CLOSE));
    launchSelect.addItem(new OnLaunchItem(resources.getString("launcheroptions.packlaunch.nothing"), LaunchAction.NOTHING));
    switch(settings.getLaunchAction()) {
        case HIDE:
            launchSelect.setSelectedIndex(0);
            break;
        case CLOSE:
            launchSelect.setSelectedIndex(1);
            break;
        case NOTHING:
            launchSelect.setSelectedIndex(2);
            break;
        default:
            launchSelect.setSelectedIndex(0);
    }
    launchSelect.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeLaunchAction();
        }
    });
    for (ActionListener listener : langSelect.getActionListeners()) langSelect.removeActionListener(listener);
    langSelect.removeAllItems();
    String defaultLocaleText = resources.getString("launcheroptions.language.default");
    if (!resources.isDefaultLocaleSupported()) {
        defaultLocaleText = defaultLocaleText.concat(" (" + resources.getString("launcheroptions.language.unavailable") + ")");
    }
    langSelect.setRenderer(new LanguageCellRenderer(resources, null, langSelect.getBackground(), langSelect.getForeground()));
    langSelect.addItem(new LanguageItem(ResourceLoader.DEFAULT_LOCALE, defaultLocaleText, resources));
    for (int i = 0; i < LauncherMain.supportedLanguages.length; i++) {
        langSelect.addItem(new LanguageItem(resources.getCodeFromLocale(LauncherMain.supportedLanguages[i]), LauncherMain.supportedLanguages[i].getDisplayName(LauncherMain.supportedLanguages[i]), resources.getVariant(LauncherMain.supportedLanguages[i])));
    }
    if (!settings.getLanguageCode().equalsIgnoreCase(ResourceLoader.DEFAULT_LOCALE)) {
        Locale loc = resources.getLocaleFromCode(settings.getLanguageCode());
        for (int i = 0; i < LauncherMain.supportedLanguages.length; i++) {
            if (loc.equals(LauncherMain.supportedLanguages[i])) {
                langSelect.setSelectedIndex(i + 1);
                break;
            }
        }
    }
    langSelect.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeLanguage();
        }
    });
    widthInput.getDocument().removeDocumentListener(dimensionListener);
    heightInput.getDocument().removeDocumentListener(dimensionListener);
    int width = settings.getCustomWidth();
    int height = settings.getCustomHeight();
    width = (width < 1) ? 800 : width;
    height = (height < 1) ? 600 : height;
    widthInput.setText(Integer.toString(width));
    heightInput.setText(Integer.toString(height));
    widthInput.getDocument().addDocumentListener(dimensionListener);
    heightInput.getDocument().addDocumentListener(dimensionListener);
    for (ActionListener listener : windowSelect.getActionListeners()) {
        windowSelect.removeActionListener(listener);
    }
    windowSelect.removeAllItems();
    windowSelect.addItem(resources.getString("launcheroptions.video.windowSize.default"));
    windowSelect.addItem(resources.getString("launcheroptions.video.windowSize.fullscreen"));
    windowSelect.addItem(resources.getString("launcheroptions.video.windowSize.custom"));
    switch(settings.getLaunchWindowType()) {
        case DEFAULT:
            windowSelect.setSelectedIndex(0);
            break;
        case FULLSCREEN:
            windowSelect.setSelectedIndex(1);
            break;
        case CUSTOM:
            windowSelect.setSelectedIndex(2);
            break;
    }
    windowSelect.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeWindowType();
        }
    });
    updateDimensionsEnabled();
    for (ActionListener listener : useStencil.getActionListeners()) {
        useStencil.removeActionListener(listener);
    }
    useStencil.removeAllItems();
    useStencil.addItem(resources.getString("launcheroptions.video.stencil.enabled"));
    useStencil.addItem(resources.getString("launcheroptions.video.stencil.disabled"));
    if (settings.shouldUseStencilBuffer())
        useStencil.setSelectedIndex(0);
    else
        useStencil.setSelectedIndex(1);
    useStencil.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeEnableStencil();
        }
    });
}
Also used : Locale(java.util.Locale) StreamItem(net.technicpack.launcher.ui.listitems.StreamItem) ActionEvent(java.awt.event.ActionEvent) DefaultVersionItem(net.technicpack.ui.listitems.javaversion.DefaultVersionItem) Best64BitVersionItem(net.technicpack.ui.listitems.javaversion.Best64BitVersionItem) JavaVersionItem(net.technicpack.ui.listitems.javaversion.JavaVersionItem) IJavaVersion(net.technicpack.launchercore.launch.java.IJavaVersion) OnLaunchItem(net.technicpack.launcher.ui.listitems.OnLaunchItem) LanguageCellRenderer(net.technicpack.ui.controls.lang.LanguageCellRenderer) ActionListener(java.awt.event.ActionListener) LanguageItem(net.technicpack.ui.listitems.LanguageItem)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Locale (java.util.Locale)1 OnLaunchItem (net.technicpack.launcher.ui.listitems.OnLaunchItem)1 StreamItem (net.technicpack.launcher.ui.listitems.StreamItem)1 IJavaVersion (net.technicpack.launchercore.launch.java.IJavaVersion)1 LanguageCellRenderer (net.technicpack.ui.controls.lang.LanguageCellRenderer)1 LanguageItem (net.technicpack.ui.listitems.LanguageItem)1 Best64BitVersionItem (net.technicpack.ui.listitems.javaversion.Best64BitVersionItem)1 DefaultVersionItem (net.technicpack.ui.listitems.javaversion.DefaultVersionItem)1 JavaVersionItem (net.technicpack.ui.listitems.javaversion.JavaVersionItem)1