private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TxtName.Text))
            {
                App.ShowError("\"Name\" cannot be empty.");
                return;
            }

            if (BoundProfile == null)
            {
                BoundProfile = new BoundProfile(
                    TxtName.Text,
                    CbModpack.SelectedItem as BoundModList,
                    TxtName.Text
                    );
            }
            else
            {
                BoundProfile.DisplayName  = TxtName.Text;
                BoundProfile.BoundModList = CbModpack.SelectedItem as BoundModList;
                BoundProfile.Save();
            }

            DialogResult = true;
        }
Пример #2
0
        private void OpenMainWindow()
        {
            Mods     = new ModInstallationService();
            Modpacks = new ModpacksService();
            Modpacks.AddVanillaModpack();
            ActiveModsConfig = new ModActivationService();
            Profiles         = new ProfilesService();
            if (!ProfilesService.IsSavesFolderSymlinked())
            {
                if (
                    MessageBox.Show(
                        "In order for the launcher to work, saves must be moved to a new profile.\nWould you like your saves to be moved to a new profile?",
                        "Move saves to new profile?",
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Question
                        ) == MessageBoxResult.Yes
                    )
                {
                    var oldModpack = new BoundModList("Old modpack", "old");
                    oldModpack.CopyTo(ActiveModsConfig.FetchActiveMods().ToArray(), 0);
                    Modpacks.LoadModpacks();
                    var profile = new BoundProfile("Old profile", oldModpack, "old");
                    profile.SavesFolder?.Delete(true);
                    Config.FetchDataFolder().GetDirectories().First(directory =>
                                                                    directory.Name == RimWorldLauncher.Properties.Resources.SavesFolderName)
                    .MoveTo(Path.Combine(profile.ProfileFolder.FullName,
                                         RimWorldLauncher.Properties.Resources.SavesFolderName));
                    Profiles.LoadProfiles();
                }
                else
                {
                    Current.Shutdown();
                    return;
                }
            }

            SwitchMainWindow(new WinMain());
        }
Пример #3
0
 private void LvProfiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     _selectedBoundProfile = (sender as ListView)?.SelectedItem as BoundProfile;
     BtnPlay.IsEnabled     = _selectedBoundProfile != null;
 }