private void Specific_Mod_Remove_Click(object sender, RoutedEventArgs e) { var tag = ((Button)sender).Tag.ToString(); var modItem = ModItems.First(p => p.UUID == tag); if (RemoveModWindow == null) { return; } RemoveModWindow.SetModTitle(modItem.Title); RemoveModWindow.RemovedMod = () => { var deleted = Shrek2MM.DeleteModFromDataFolder(modItem.FileName); if (deleted == false) { MessageBox.Show("Failed to delete the mod file/zip from Data folder, this can be becaues of read/write permissions. You can delete this file yourself if you go to 'Your PC/My Documents/Shrek 2 Mod Manager/Added mods'."); } ModItems.Remove(modItem); var saved = Shrek2MM.SaveMods(ModItems.ToList()); if (saved == false) { MessageBox.Show("Failed to update mod list, this can be becaues of read/write permissions."); } }; DialogHost.Show(RemoveModWindow.Content); }
private async void Window_Initialized(object sender, EventArgs e) { RemoveModWindow = new RemoveModWindow { CloseModal = () => { DialogHost.Close(null); } }; EditModWindow = new EditModWindow { CloseModal = () => { DialogHost.Close(null); } }; SettingsWindow = new SettingsWindow { CloseModal = () => { DialogHost.Close(null); } }; var mods = Shrek2MM.LoadMods(); if (mods == null) { MessageBox.Show("Failed to load Added Mods correctly, this might indicate that the JSON file is corrupted or damaged! Please close this application and ensure the JSON file isn't damaged in any way before proceeding."); Add_Mod_Button.IsEnabled = false; Play_Button.IsEnabled = false; ModItemsList.ItemsSource = ModItems; return; } var extractedModLoader = await Shrek2MM.ExtractModLoader(); if (extractedModLoader == false) { MessageBox.Show("Couldn't extract the Mod Loader which is embedded in the Shrek 2 Mod Manager Program. Please check that the program has permissions to read/write on disk, and if the issue still persists please contact the developer."); Add_Mod_Button.IsEnabled = false; Play_Button.IsEnabled = false; ModItemsList.ItemsSource = ModItems; return; } mods.ForEach(mod => ModItems.Add(mod)); ModItemsList.ItemsSource = ModItems; }