Search in sources :

Example 1 with ProfileIcon

use of kml.game.profile.ProfileIcon in project Krothium-Launcher by DarkLBP.

the class MainFX method loadIcons.

/**
 * Loads the profile icons
 */
private void loadIcons() {
    console.print("Loading icons...");
    ObservableList<ImageView> icons = FXCollections.observableArrayList();
    for (ProfileIcon p : ProfileIcon.values()) {
        if (p != ProfileIcon.CRAFTING_TABLE && p != ProfileIcon.GRASS) {
            ImageView imv = new ImageView(kernel.getProfileIcon(p));
            imv.setFitHeight(68);
            imv.setFitWidth(68);
            imv.setId(p.name());
            icons.add(imv);
        }
    }
    iconList.setItems(icons);
    console.print("Icons loaded.");
}
Also used : ProfileIcon(kml.game.profile.ProfileIcon) ImageView(javafx.scene.image.ImageView)

Example 2 with ProfileIcon

use of kml.game.profile.ProfileIcon in project Krothium-Launcher by DarkLBP.

the class MainFX method getProfileList.

/**
 * Generates an ObservableList of Labels representing each profile
 * @return The profiles ObservableList
 */
private ObservableList<Label> getProfileList() {
    ObservableList<Label> profileListItems = FXCollections.observableArrayList();
    Profiles ps = kernel.getProfiles();
    Label l;
    ImageView iv;
    String text;
    for (Profile p : ps.getProfiles()) {
        if (p.getType() == ProfileType.SNAPSHOT && !settings.getEnableSnapshots()) {
            continue;
        }
        switch(p.getType()) {
            case RELEASE:
                iv = new ImageView(kernel.getProfileIcon(ProfileIcon.GRASS));
                text = Language.get(59);
                break;
            case SNAPSHOT:
                iv = new ImageView(kernel.getProfileIcon(ProfileIcon.CRAFTING_TABLE));
                text = Language.get(60);
                break;
            default:
                text = p.hasName() ? p.getName() : Language.get(70);
                ProfileIcon pi = p.hasIcon() ? p.getIcon() : ProfileIcon.FURNACE;
                iv = new ImageView(kernel.getProfileIcon(pi));
                break;
        }
        iv.setFitWidth(68);
        iv.setFitHeight(68);
        l = new Label(text, iv);
        // Fetch Minecraft version used by the profile
        VersionMeta verID;
        switch(p.getType()) {
            case CUSTOM:
                Versions versions = kernel.getVersions();
                verID = p.hasVersion() ? p.getVersionID() : versions.getLatestRelease();
                break;
            case RELEASE:
                verID = kernel.getVersions().getLatestRelease();
                break;
            default:
                verID = kernel.getVersions().getLatestSnapshot();
                break;
        }
        l.setId(p.getID());
        if (verID != null) {
            // If profile has any known version just show it below the profile name
            if (verID.getType() == VersionType.SNAPSHOT && !settings.getEnableSnapshots()) {
                continue;
            }
            if ((verID.getType() == VersionType.OLD_ALPHA || verID.getType() == VersionType.OLD_BETA) && !settings.getEnableHistorical()) {
                continue;
            }
            l.setText(l.getText() + '\n' + verID.getID());
        }
        if (ps.getSelectedProfile().equals(p)) {
            l.getStyleClass().add("selectedProfile");
        }
        profileListItems.add(l);
    }
    return profileListItems;
}
Also used : Versions(kml.game.version.Versions) VersionMeta(kml.game.version.VersionMeta) Profiles(kml.game.profile.Profiles) ProfileIcon(kml.game.profile.ProfileIcon) ImageView(javafx.scene.image.ImageView) Profile(kml.game.profile.Profile)

Aggregations

ImageView (javafx.scene.image.ImageView)2 ProfileIcon (kml.game.profile.ProfileIcon)2 Profile (kml.game.profile.Profile)1 Profiles (kml.game.profile.Profiles)1 VersionMeta (kml.game.version.VersionMeta)1 Versions (kml.game.version.Versions)1