public void OpenFolder(MCInstallation i)
        {
            string Directory = Filepaths.GetInstallationsFolderPath(ConfigManager.CurrentProfile, i.DirectoryName_Full);

            if (!System.IO.Directory.Exists(Directory))
            {
                System.IO.Directory.CreateDirectory(Directory);
            }
            Process.Start("explorer.exe", Directory);
        }
        private void UpdateEditingFields(int index, MCInstallation i)
        {
            IsEditMode = true;
            InstallationVersionSelect.SelectedItem = Versions.Where(x => x.UUID == i.VersionUUID).FirstOrDefault();
            InstallationNameField.Text             = i.DisplayName;
            InstallationDirectoryField.Text        = i.DirectoryName;
            InstallationIconSelect.Init(i.IconPath, i.IsCustomIcon);
            EditingIndex = index;

            Header.SetResourceReference(TextBlock.TextProperty, "EditingInstallationScreen_Header");
            CreateButton.SetResourceReference(Button.ContentProperty, "EditingInstallationScreen_SaveButton");
        }
        public static void DeleteInstallation(MCInstallation installation)
        {
            if (ProfileList.profiles.ContainsKey(CurrentProfile))
            {
                if (ProfileList.profiles[CurrentProfile].Installations == null)
                {
                    return;
                }

                ProfileList.profiles[CurrentProfile].Installations.RemoveAll(x => x.DisplayName == installation.DisplayName && !x.ReadOnly);
                SaveProfiles();
            }
        }
        public void Play(MCInstallation i)
        {
            {
                var v = i.Version;
                switch (v.DisplayInstallStatus.ToString())
                {
                case "Not installed":
                    InvokeDownload(v);
                    break;

                case "Installed":
                    InvokeLaunch(v);
                    break;
                }
            }
        }
        public static bool Filter_InstallationList(object obj)
        {
            MCInstallation v = obj as MCInstallation;

            if (!Properties.LauncherSettings.Default.ShowBetas && v.IsBeta)
            {
                return(false);
            }
            else if (!Properties.LauncherSettings.Default.ShowReleases && !v.IsBeta)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 6
0
        public void Play(MCInstallation i)
        {
            Properties.LauncherSettings.Default.CurrentInstallation = ConfigManager.CurrentInstallations.IndexOf(i);
            Properties.LauncherSettings.Default.Save();

            var v = i.Version;

            switch (v.DisplayInstallStatus.ToString())
            {
            case "Not installed":
                InvokeDownload(v);
                break;

            case "Installed":
                InvokeLaunch(v);
                break;
            }
        }
        public static void DuplicateInstallation(MCInstallation installation)
        {
            if (ProfileList.profiles.ContainsKey(CurrentProfile))
            {
                if (ProfileList.profiles[CurrentProfile].Installations == null)
                {
                    return;
                }

                string newName = installation.DisplayName;
                int    i       = 1;

                while (ProfileList.profiles[CurrentProfile].Installations.Exists(x => x.DisplayName == newName))
                {
                    newName = newName + "(" + i + ")";
                    i++;
                }

                CreateInstallation(newName, installation.Version, installation.DirectoryName, installation.IconPath_Full, installation.IsCustomIcon);
            }
        }
        public static void LoadInstallations(string profile = null)
        {
            if (profile == null)
            {
                profile = CurrentProfile;
            }
            CurrentInstallations = new List <MCInstallation>();
            CurrentInstallations = ConfigManager.GetInstallations(profile);

            MCInstallation latest_release = new MCInstallation();

            latest_release.DisplayName      = "Latest Release";
            latest_release.DirectoryName    = "Latest Release";
            latest_release.VersionUUID      = "latest_release";
            latest_release.UseLatestVersion = true;
            latest_release.UseLatestBeta    = false;
            latest_release.IconPath_Full    = @"/BedrockLauncher;component/Resources/images/installation_icons/Grass_Block.png";
            latest_release.ReadOnly         = true;
            if (!CurrentInstallations.Exists(x => x.DisplayName == "Latest Release" && x.ReadOnly))
            {
                CurrentInstallations.Add(latest_release);
            }

            MCInstallation latest_beta = new MCInstallation();

            latest_beta.DisplayName      = "Latest Beta";
            latest_beta.DirectoryName    = "Latest Beta";
            latest_beta.VersionUUID      = "latest_beta";
            latest_beta.UseLatestVersion = true;
            latest_beta.UseLatestBeta    = true;
            latest_beta.IconPath_Full    = @"/BedrockLauncher;component/Resources/images/installation_icons/Crafting_Table.png";
            latest_beta.ReadOnly         = true;
            if (!CurrentInstallations.Exists(x => x.DisplayName == "Latest Beta" && x.ReadOnly))
            {
                CurrentInstallations.Add(latest_beta);
            }
        }
        public static void CreateInstallation(string name, MCVersion version, string directory, string iconPath = @"/BedrockLauncher;component/Resources/images/installation_icons/Furnace.png", bool isCustom = false)
        {
            if (ProfileList.profiles.ContainsKey(CurrentProfile))
            {
                MCInstallation installation = new MCInstallation();
                installation.DisplayName   = name;
                installation.IconPath_Full = iconPath;
                installation.IsCustomIcon  = isCustom;
                installation.DirectoryName = directory;


                if (version == null || version.UUID == "latest_release")
                {
                    installation.UseLatestVersion = true;
                    installation.VersionUUID      = "latest_release";
                }
                else if (version.UUID == "latest_beta")
                {
                    installation.UseLatestVersion = true;
                    installation.UseLatestBeta    = true;
                    installation.VersionUUID      = "latest_beta";
                }
                else
                {
                    installation.VersionUUID = version.UUID;
                }


                if (ProfileList.profiles[CurrentProfile].Installations == null)
                {
                    ProfileList.profiles[CurrentProfile].Installations = new List <MCInstallation>();
                }
                ProfileList.profiles[CurrentProfile].Installations.Add(installation);
                SaveProfiles();
            }
        }
 public EditInstallationScreen(int index, MCInstallation i)
 {
     InitializeComponent();
     UpdateVersionsComboBox();
     UpdateEditingFields(index, i);
 }