Skip to content

Commit

Permalink
Rename and Duplicate pack options (CadeEvs#53)
Browse files Browse the repository at this point in the history
* Rename and Duplicate pack options

* Reimplement pack duplicate and rename

* Proper naming for Rename Profile and Duplicate Profile naming windows
  • Loading branch information
Dyvinia committed Aug 11, 2023
1 parent 6039171 commit f998c20
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
4 changes: 3 additions & 1 deletion FrostyModManager/Windows/AddProfileWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 6 additions & 0 deletions FrostyModManager/Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@
<MenuItem Header="File"
Height="22">
<MenuItem Header="Pack">
<MenuItem x:Name="packRename"
Header="Rename"
Click="packRename_Click" />
<MenuItem x:Name="packDuplicate"
Header="Duplicate"
Click="packDuplicate_Click" />
<MenuItem x:Name="packExport"
Header="Export"
Click="packExport_Click" />
Expand Down
62 changes: 62 additions & 0 deletions FrostyModManager/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f998c20

Please sign in to comment.