From f998c208dbfb0a56024a784e9ce961826f2cc5cc Mon Sep 17 00:00:00 2001 From: Diana Gunasena Date: Thu, 28 Apr 2022 19:34:03 -0400 Subject: [PATCH] Rename and Duplicate pack options (#53) * Rename and Duplicate pack options * Reimplement pack duplicate and rename * Proper naming for Rename Profile and Duplicate Profile naming windows --- .../Windows/AddProfileWindow.xaml.cs | 4 +- FrostyModManager/Windows/MainWindow.xaml | 6 ++ FrostyModManager/Windows/MainWindow.xaml.cs | 62 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/FrostyModManager/Windows/AddProfileWindow.xaml.cs b/FrostyModManager/Windows/AddProfileWindow.xaml.cs index b4d92ad71..85d6dc793 100644 --- a/FrostyModManager/Windows/AddProfileWindow.xaml.cs +++ b/FrostyModManager/Windows/AddProfileWindow.xaml.cs @@ -10,10 +10,12 @@ public partial class AddProfileWindow : FrostyDockableWindow { public string ProfileName { get; set; } - public AddProfileWindow() + public AddProfileWindow(string title = "Add Profile") { InitializeComponent(); + this.Title = title; + Window mainWin = Application.Current.MainWindow; if (mainWin != null) { diff --git a/FrostyModManager/Windows/MainWindow.xaml b/FrostyModManager/Windows/MainWindow.xaml index 23ea09159..2c8697ed2 100644 --- a/FrostyModManager/Windows/MainWindow.xaml +++ b/FrostyModManager/Windows/MainWindow.xaml @@ -269,6 +269,12 @@ + + diff --git a/FrostyModManager/Windows/MainWindow.xaml.cs b/FrostyModManager/Windows/MainWindow.xaml.cs index ce0139cec..d557da92a 100644 --- a/FrostyModManager/Windows/MainWindow.xaml.cs +++ b/FrostyModManager/Windows/MainWindow.xaml.cs @@ -541,6 +541,68 @@ private void removeProfileButton_Click(object sender, RoutedEventArgs e) } } + private void packRename_Click(object sender, RoutedEventArgs e) { + + AddProfileWindow win = new AddProfileWindow("Rename Pack"); + win.ShowDialog(); + + if (win.DialogResult == true) { + string newPackName = win.ProfileName; + var oldPack = selectedPack; + + FrostyPack existingPack = packs.Find((FrostyPack a) => { + return a.Name.CompareTo(newPackName) == 0; + }); + + if (existingPack == null) { + Config.Rename(oldPack.Name, newPackName, ConfigScope.Pack); + + FrostyPack newPack = new FrostyPack(newPackName); + foreach (var mod in oldPack.AppliedMods) { + newPack.AppliedMods.Add(mod); + } + + packs.Add(newPack); + packs.Remove(oldPack); + + packsComboBox.Items.Refresh(); + packsComboBox.SelectedItem = newPack; + } + else FrostyMessageBox.Show("A pack with the same name already exists", "Frosty Mod Manager"); + + } + } + + private void packDuplicate_Click(object sender, RoutedEventArgs e) { + + AddProfileWindow win = new AddProfileWindow("Duplicate Pack"); + win.ShowDialog(); + + if (win.DialogResult == true) { + string newPackName = win.ProfileName; + var oldPack = selectedPack; + + FrostyPack existingPack = packs.Find((FrostyPack a) => { + return a.Name.CompareTo(newPackName) == 0; + }); + + if (existingPack == null) { + Config.Add(newPackName, ConfigScope.Pack); + + FrostyPack newPack = new FrostyPack(newPackName); + foreach (var mod in oldPack.AppliedMods) { + newPack.AppliedMods.Add(mod); + } + + packs.Add(newPack); + + packsComboBox.Items.Refresh(); + packsComboBox.SelectedItem = newPack; + } + else FrostyMessageBox.Show("A pack with the same name already exists", "Frosty Mod Manager"); + } + } + private void removeButton_Click(object sender, RoutedEventArgs e) { int selectedIndex = appliedModsList.SelectedIndex;