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); } } }
async public override void _Ready() { if (!enabled) { return; } TreeItem rootItem = CreateItem(this) as TreeItem; TestRunner testRunner = new TestRunner(GetTree()); passed = 0; failed = 0; panel = GetParent() as Panel; richTextLabel = GetNodeByTypeInChildren <RichTextLabel>(GetParent()); hideButton = GetNodeByTypeInChildren <Button>(GetParent().GetParent()); await testRunner.Run((TestResult testResult) => { bool didFail = testResult.result == TestResult.Result.Failed; if (didFail) { failed++; } else { passed++; } string classType = testResult.classType.ToString(); if (!treeItems.ContainsKey(classType)) { treeItems[classType] = CreateTreeItemsForClassType(classType, rootItem); } treeItems[classType].SetText(0, testResult.classType.ToString()); TreeItem testItem = CreateItem(treeItems[classType]) as TreeItem; testItem.SetText(0, testResult.testMethod.Name); testItem.SetIcon(0, didFail ? failedIcon : passedIcon); if (didFail) { TreeItem top = treeItems[classType]; while (top != null) { top.SetIcon(0, failedIcon); top = top.GetParent(); } } itemSelections[testItem] = testResult; }); if (string.IsNullOrEmpty(richTextLabel.Text)) { SetPassedFailedText(); } hideButton.Connect("pressed", this, "_HidePressed"); Connect("cell_selected", this, "_CellSelected"); }