Search in sources :

Example 1 with Profiles

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

the class MainFX method validateSelectedProfile.

/**
 * Validates the selected profile according to the constraints
 */
private void validateSelectedProfile() {
    Profiles ps = kernel.getProfiles();
    // Check if selected profile passes the current settings
    Profile selected = ps.getSelectedProfile();
    VersionMeta selectedVersion = selected.getVersionID();
    if (selected.getType() == ProfileType.SNAPSHOT && !settings.getEnableSnapshots()) {
        ps.setSelectedProfile(ps.getReleaseProfile());
    } else if (selected.getType() == ProfileType.CUSTOM) {
        VersionType type = selectedVersion.getType();
        if (type == VersionType.SNAPSHOT && !settings.getEnableSnapshots()) {
            ps.setSelectedProfile(ps.getReleaseProfile());
        } else if (type == VersionType.OLD_ALPHA && !settings.getEnableHistorical()) {
            ps.setSelectedProfile(ps.getReleaseProfile());
        } else if (type == VersionType.OLD_BETA && !settings.getEnableHistorical()) {
            ps.setSelectedProfile(ps.getReleaseProfile());
        }
    }
    updateGameVersion();
}
Also used : VersionMeta(kml.game.version.VersionMeta) Profiles(kml.game.profile.Profiles) Profile(kml.game.profile.Profile) VersionType(kml.game.version.VersionType)

Example 2 with Profiles

use of kml.game.profile.Profiles 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

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