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 May 26, 2022
1 parent 63a49a3 commit a7e397b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
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
4 changes: 2 additions & 2 deletions FrostyModManager/Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@
<Menu Grid.Row="0">
<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="packRename" Header="Rename" Click="packRename_Click"/>
<MenuItem x:Name="packDuplicate" Header="Duplicate" Click="packDuplicate_Click"/>
<MenuItem x:Name="packExport" Header="Export" Click="packExport_Click"/>
<MenuItem x:Name="packImport" Header="Import" Click="packImport_Click"/>
</MenuItem>
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 @@ -513,6 +513,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 a7e397b

Please sign in to comment.