private void MoveSelectedQuestStepChoiceDownButton_Click(object sender, RoutedEventArgs e) { object dgr = (sender as Button).FindName("QuestStepChoiceGridRoot"); gamedataObject selected = (dgr as DataGrid).SelectedItem as gamedataObject; if (selected != null) { //Find the largest sort index less than the selected one, that's who we want to swap numbers with. int sortIndex = Int32.MaxValue; gamedataObject objectToSwap = null; foreach (gamedataObject otherChoice in GameDataViewObject.selectedQuestStepChoicesObservable) { if (otherChoice.sortOrder < sortIndex && otherChoice.sortOrder > selected.sortOrder) { objectToSwap = otherChoice; sortIndex = otherChoice.sortOrder; } } if (objectToSwap != null) //If it is still null, there must be nothing above the selected in the list { objectToSwap.sortOrder = selected.sortOrder; selected.sortOrder = sortIndex; } } CollectionViewSource source = (CollectionViewSource)(this.Resources["selectedQuestStepChoicesViewSource"]); source.View.SortDescriptions.Clear(); source.View.SortDescriptions.Add(new System.ComponentModel.SortDescription("sortOrder", System.ComponentModel.ListSortDirection.Ascending)); }
private void SortOrderDownButton_Click(object sender, RoutedEventArgs e) { gamedataObject selected = GameDataViewObject.gameData; if (selected != null) { //Find the largest sort index less than the selected one, that's who we want to swap numbers with. int sortIndex = Int32.MaxValue; gamedataObject objectToSwap = null; foreach (gamedataObject iterObject in GameDataViewObject.root.Items.Where <gamedataObject>(iter => [email protected](selected.@class) && iter.deleted == "False")) { if (iterObject.sortOrder < sortIndex && iterObject.sortOrder > selected.sortOrder) { objectToSwap = iterObject; sortIndex = iterObject.sortOrder; } } if (objectToSwap != null) //If it is still null, there must be nothing above the selected in the list { objectToSwap.sortOrder = selected.sortOrder; selected.sortOrder = sortIndex; } } GameDataViewObject.reSortGameTree(); }
private bool doesIdenticalObjectExist(gamedataObject obj, gamedata rhsData) { gamedataObject otherObject = rhsData.getItemByID(obj.uuid); if (otherObject == null) { return(false); } if (!obj.Equals(otherObject)) { return(false); } return(true); }
public void commitMerge() { //At this point, everything that differs should have SelectOriginal or SelectMerge set; take the relevant things from //_mergeData and put them into _originalData (those that have SelectMerge or where original wasn't present) //For items where we selected the original, or were present in the original but not the merge, or were identical, we just leave //it in the original data. foreach (MergeTreeItem categoryMTI in MergeTree) { foreach (MergeTreeItem objectMTI in categoryMTI.Children) { if (objectMTI.SelectMerge || objectMTI.OriginalObjectRef == null) { if (objectMTI.OriginalObjectRef != null) { _originalData.Items.Remove(objectMTI.OriginalObjectRef); foreach (gamedataObject originalDependentObj in objectMTI.OriginalObjectRef.GetDependentObjects()) { _originalData.Items.Remove(originalDependentObj); } } if (_originalData.getDeletedItemByID(objectMTI.MergeObjectRef.uuid) != null) { //Deleted items weren't added to the merge tree, so it is possible that the original is present but deleted, in which case we need to remove it. gamedataObject deletedOriginalObj = _originalData.getDeletedItemByID(objectMTI.MergeObjectRef.uuid); _originalData.Items.Remove(deletedOriginalObj); foreach (gamedataObject originalDependentObj in deletedOriginalObj.GetDependentObjects()) { _originalData.Items.Remove(originalDependentObj); } } _originalData.Items.Add(objectMTI.MergeObjectRef); foreach (gamedataObject mergeDependentObj in objectMTI.MergeObjectRef.GetDependentObjects()) { _originalData.Items.Add(mergeDependentObj); } } } } }
public Boolean Equals(gamedataObject rhs) { //First, check all the required fields. if (!nameField.Equals(rhs.nameField)) { return(false); } if (descriptionField != rhs.descriptionField) { return(false); } if (commentField != rhs.commentField) { return(false); } if (questPreDescriptionField != rhs.questPreDescriptionField) { return(false); } if (iconField != rhs.iconField) { return(false); } if (giveItemNumberField != rhs.giveItemNumberField) { return(false); } if (minimumField != rhs.minimumField) { return(false); } if (maximumField != rhs.maximumField) { return(false); } if (equippableField != rhs.equippableField) { return(false); } if (uuidField != rhs.uuidField) { return(false); } if (valueField != rhs.valueField) { return(false); } if (statTargetField != rhs.statTargetField) { return(false); } if (alternateBackgroundField != rhs.alternateBackgroundField) { return(false); } if (deletedField != rhs.deletedField) { return(false); } if (displayedOnSidebarField != rhs.displayedOnSidebarField) { return(false); } if (displayedOnMainStatPageField != rhs.displayedOnMainStatPageField) { return(false); } if (oneTimeQuestField != rhs.oneTimeQuestField) { return(false); } if (questIsForceGrantedField != rhs.questIsForceGrantedField) { return(false); } if (cooldownTimerField != rhs.cooldownTimerField) { return(false); } if (questEnergyCostField != rhs.questEnergyCostField) { return(false); } if (sortOrderField != rhs.sortOrderField) { return(false); } if (!itemField.SequenceEqual(rhs.itemField)) { return(false); } if (!startingCharacterInfoField.SequenceEqual(rhs.startingCharacterInfoField)) { return(false); } if (!stepField.SequenceEqual(rhs.stepField)) { return(false); } if (!firstStepField.SequenceEqual(rhs.firstStepField)) { return(false); } if (!failStepField.SequenceEqual(rhs.failStepField)) { return(false); } if (!nextStepField.SequenceEqual(rhs.nextStepField)) { return(false); } if (!questField.SequenceEqual(rhs.questField)) { return(false); } if (!questStepChoiceField.SequenceEqual(rhs.questStepChoiceField)) { return(false); } if (!statField.SequenceEqual(rhs.statField)) { return(false); } if (!xpStatField.SequenceEqual(rhs.xpStatField)) { return(false); } if (!henchmanField.SequenceEqual(rhs.henchmanField)) { return(false); } if (!itemTypeField.SequenceEqual(rhs.itemTypeField)) { return(false); } if (!subLocationOfField.SequenceEqual(rhs.subLocationOfField)) { return(false); } if (!requiredLocationField.SequenceEqual(rhs.requiredLocationField)) { return(false); } if (!startingLocationField.SequenceEqual(rhs.startingLocationField)) { return(false); } if (!associatedLocationField.SequenceEqual(rhs.associatedLocationField)) { return(false); } if (!unlockLocationField.SequenceEqual(rhs.unlockLocationField)) { return(false); } if (!moveToLocationField.SequenceEqual(rhs.moveToLocationField)) { return(false); } if (!associatedNPCField.SequenceEqual(rhs.associatedNPCField)) { return(false); } if (!startingQuestField.SequenceEqual(rhs.startingQuestField)) { return(false); } if (!statGroupField.SequenceEqual(rhs.statGroupField)) { return(false); } //Next, for objects with many-to-one relationships with something else, check the something else //Nothing relevant for ItemType, Stat, StatGroup, Location, or NPC if (@class == "ItemData") { //For an item to be equal, they need to have identical stat mods if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "ItemStatModifierData", (gamedataObject) => itemID.Equals(uuid))) { return(false); } } if (@class == "StartingCharacterInfoData") { //For starting character to be equal, they need to have identical stats if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "StartingCharacterInfoStatModifierData", (gamedataObject) => startingCharacterInfoID.Equals(uuid))) { return(false); } } if (@class == "HenchmanData") { //For a henchman to be equal, they need to have identical stats if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "HenchmanStatData", (gamedataObject) => henchmanID.Equals(uuid))) { return(false); } } if (@class == "QuestData") { //For a quest to be equal, they need to have identical steps and requirements. Note that this is recursive, so the steps need to have identical step requirements etc (see below) if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestStepData", (gamedataObject) => questID.Equals(uuid))) { return(false); } if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestStatRequirementData", (gamedataObject) => questID.Equals(uuid))) { return(false); } if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestItemRequirementData", (gamedataObject) => questID.Equals(uuid))) { return(false); } } if (@class == "QuestStepData") { //For a quest to be equal, they need to have identical steps and requirements. Note that this is recursive, so the steps need to have identical step requirements etc (see below) if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestStepChoiceData", (gamedataObject) => stepID.Equals(uuid))) { return(false); } if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestStepStatGrantData", (gamedataObject) => stepID.Equals(uuid))) { return(false); } if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestStepItemGrantData", (gamedataObject) => stepID.Equals(uuid))) { return(false); } if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestStepHenchmanGrantData", (gamedataObject) => stepID.Equals(uuid))) { return(false); } } if (@class == "QuestStepChoiceData") { //For a quest step choice to be equal, they need to have identical requirement and grants. if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestStepChoiceStatRequirementData", (gamedataObject) => questStepChoiceID.Equals(uuid))) { return(false); } if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestStepChoiceStatGrantData", (gamedataObject) => questStepChoiceID.Equals(uuid))) { return(false); } if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestStepChoiceItemGrantData", (gamedataObject) => questStepChoiceID.Equals(uuid))) { return(false); } if (!doIdenticalRelatedObjectsExist(associatedRootData, rhs.associatedRootData, "QuestStepChoiceHenchmanGrantData", (gamedataObject) => questStepChoiceID.Equals(uuid))) { return(false); } } return(true); }