private void Signal_PendingRemovalConfirm() { if (pendingRemoval.GetParent() == depsRoot) { ModProject.Dependencies.Remove(deps[pendingRemoval]); deps.Remove(pendingRemoval); } else if (pendingRemoval.GetParent() == updateKeysRoot) { ModProject.UpdateKeys.Remove(updateKeys[pendingRemoval]); updateKeys.Remove(pendingRemoval); } else if (pendingRemoval.GetParent() == resourcesRoot) { string filename = resourcesNames[pendingRemoval]; System.IO.File.Delete(System.IO.Path.Combine(ModProjectDir, filename)); foreach (var mod in ModProject.Mods) { var controller = ContentPackController.GetControllerForMod(mod.ContentPackFor); controller.OnResourceDeleted(this, mod, filename); } } else if (pendingRemoval.GetMeta(Meta.CorrespondingController) != null) { var controller = ContentPackController.GetControllerForMod((string)pendingRemoval.GetMeta(Meta.CorrespondingController)); var data = ModProject.Mods.Find(md => md.ContentPackFor == controller.ModUniqueId); if (pendingRemoval.GetParent() == ProjectRoot) { ModProject.Mods.Remove(data); } else { controller.OnRemoved(this, data, pendingRemoval); } } pendingRemoval.GetParent().RemoveChild(pendingRemoval); }
private void Signal_TreeButtonPressed(TreeItem item, int column, int id) { if (id == REMOVE_BUTTON_INDEX) { pendingRemoval = item; var confirm = GetNode <ConfirmationDialog>("PendingRemovalDialog"); confirm.PopupCenteredClamped(); } else if (id == ADD_BUTTON_INDEX) { if (item == depsRoot) { Dependency dep; ModProject.Dependencies.Add(dep = new Dependency() { UniqueID = "mod.id" }); var depItem = ProjectTree.CreateItem(depsRoot); depItem.SetText(0, dep.UniqueID); depItem.AddButton(0, RemoveIcon, REMOVE_BUTTON_INDEX, tooltip: "Remove this dependency"); deps.Add(depItem, dep); } else if (item == updateKeysRoot) { UpdateKey updateKey; ModProject.UpdateKeys.Add(updateKey = new UpdateKey() { Platform = "Nexus" }); var updateKeyItem = ProjectTree.CreateItem(updateKeysRoot); updateKeyItem.SetText(0, "Nexus:"); updateKeyItem.AddButton(0, RemoveIcon, REMOVE_BUTTON_INDEX, tooltip: "Remove this update key"); updateKeys.Add(updateKeyItem, updateKey); } else if (item == resourcesRoot) { var import = GetNode <FileDialog>("ResourceImportDialog"); import.PopupCenteredClamped(); } else if (item.GetMeta(Meta.CorrespondingController) != null) { var controller = ContentPackController.GetControllerForMod((string)item.GetParent().GetMeta(Meta.CorrespondingController)); var data = ModProject.Mods.Find(md => md.ContentPackFor == controller.ModUniqueId); controller.OnAdded(this, data, item); } } }