private void btCharNew_Click(object sender, RoutedEventArgs e) { string newName = Utilities.MakeTextDialog("Please enter a name for the new Character:", this); if (newName != null) { Character newChar = new Character(newName, _currentStoryData.CharTypeId, _currentStoryData); List <Character> globalCharList = Utilities.getGlobalCharacterList(_currentStoryData); //Synchronize all traits and relationships if (globalCharList.Count > 0) { Utilities.SynchronizeTwoCharacters(globalCharList[0], newChar, _currentStoryData); } _currentStoryData.Characters.Add(newChar); clearDataElements(); dataBindWindow(); Window newWin = new WindowCharacterEditor(newChar, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); clearDataElements(); dataBindWindow(); } }
private void btCharEdit_Click(object sender, RoutedEventArgs e) { Object itemToEdit = charDataGrid.SelectedItem; if ((itemToEdit == null) || (itemToEdit.GetType() != typeof(Character))) { return; } Window newWin = new WindowCharacterEditor((Character)itemToEdit, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); clearDataElements(); dataBindWindow(); }
private void btEditAction_Click(object sender, RoutedEventArgs e) { Object itemToEdit = actionsDataGrid.SelectedItem; if ((itemToEdit == null) || !(itemToEdit is Action)) { return; } if (itemToEdit.GetType() == typeof(ActionSubgoal)) { AuthorGoal subGoal = _currentStoryData.findAuthorGoalById(((ActionSubgoal)itemToEdit).SubGoalId); if (subGoal == null) { Utilities.MakeErrorDialog("This Pursue Subgoal Action refers to an Author Goal that no longer exists. You cannot edit its contents. Please delete it in order to generate a story.", this); return; } else { Window newWin = new WindowActionSubgoalEditor(false, _currentEntity, (ActionSubgoal)itemToEdit, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } } else if (itemToEdit.GetType() == typeof(ActionEditObject)) { UInt64 editObjTypeId = ((ActionEditObject)itemToEdit).ObjectTypeId; if ((editObjTypeId == _currentStoryData.CharTypeId) || (editObjTypeId == _currentStoryData.EnvTypeId)) { } else { PlotPointType currType = _currentStoryData.findPlotPointTypeById(editObjTypeId); if (currType == null) { //Very bad - precondition statement has no associated type. The user //is not allowed to edit this, and must delete it Utilities.MakeErrorDialog("This Edit Plot Point Action refers to a Plot Point Type that no longer exists. You cannot edit its contents. Please delete it in order to generate a story.", this); return; } } Window newWin = new WindowActionEditEntity(_currentEntity, (ActionEditObject)itemToEdit, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionTextOutput)) { Window newWin = new WindowActionTextOutput(_currentEntity, (ActionTextOutput)itemToEdit); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionCalculation)) { Window newWin = new WindowActionCalculationEditor(_currentEntity, (ActionCalculation)itemToEdit, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionCreatePlotPoint)) { if (null == _currentStoryData.findPlotPointTypeById(((ActionCreatePlotPoint)itemToEdit).NewPlotPoint.TypeId)) { //Very bad - precondition statement has no associated type. The user //is not allowed to edit this, and must delete it Utilities.MakeErrorDialog("This Create Plot Point Action refers to a Plot Point Type that no longer exists. You cannot edit its contents. Please delete it in order to generate a story.", this); return; } Window newWin = new WindowPlotPointEditor(((ActionCreatePlotPoint)itemToEdit).NewPlotPoint, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionCreateEnvironment)) { Window newWin = new WindowEnvironmentEditor(((ActionCreateEnvironment)itemToEdit).NewEnvironment, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionCreateCharacter)) { Window newWin = new WindowCharacterEditor(((ActionCreateCharacter)itemToEdit).NewCharacter, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionDeleteEntity)) //Edit an object deletion action { ActionDeleteEntity deletionAction = (ActionDeleteEntity)itemToEdit; if (deletionAction.TypeId == _currentStoryData.CharTypeId) //Edit char deletion { List <string> deleteObjectChoices = _currentEntity.getPreviouslyBoundCharacterVarNames(null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Character variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved Character would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } deletionAction.VariableName = deleteObjectChoices[resultChooseDeletionTarget]; } else if (deletionAction.TypeId == _currentStoryData.EnvTypeId) //Edit environment deletion { List <string> deleteObjectChoices = _currentEntity.getPreviouslyBoundEnvironmentVarNames(null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Environment variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved Environment would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } deletionAction.VariableName = deleteObjectChoices[resultChooseDeletionTarget]; } else //Edit some plot point type deletion { PlotPointType currType = _currentStoryData.findPlotPointTypeById(deletionAction.TypeId); if (currType == null) { Utilities.MakeErrorDialog("This Delete Plot Point Action refers to a Plot Point Type that no longer exists. You cannot edit its contents. Please delete it in order to generate a story.", this); return; } List <string> deleteObjectChoices = _currentEntity.getPreviouslyBoundPlotPointTypeVarNames(currType, null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved " + currType.Description + " variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved " + currType.Description + " would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } deletionAction.VariableName = deleteObjectChoices[resultChooseDeletionTarget]; } } clearDataBindings(); dataBind(); }
private void btNewAction_Click(object sender, RoutedEventArgs e) { List <string> editChoices = new List <string>(); editChoices.Add("Output Text"); editChoices.Add("Pursue a Subgoal"); editChoices.Add("Make a Calculation"); editChoices.Add("Create a new Character/Environment/Plot Point"); editChoices.Add("Edit a saved Character/Environment/Plot Point"); editChoices.Add("Delete a saved Character/Environment/Plot Point"); int result = -1; result = Utilities.MakeListChoiceDialog("What type of Action would you like to create?", editChoices, this); if (result < 0) { return; } else if (result == 0) //Output Text { ActionTextOutput newTextOutputAction = new ActionTextOutput(_currentEntity.Id, "", _currentStoryData); _currentEntity.Actions.Add(newTextOutputAction); Window newWin = new WindowActionTextOutput(_currentEntity, newTextOutputAction); newWin.Owner = this; newWin.ShowDialog(); } else if (result == 1) //Pursue Subgoal { List <string> choiceList = new List <string>(); foreach (AuthorGoal goal in _currentStoryData.AuthorGoals) { choiceList.Add(goal.Description); } result = Utilities.MakeListChoiceDialog("Select an Author Goal to pursue", choiceList, this); if (result > -1) { AuthorGoal goalToPursue = _currentStoryData.AuthorGoals[result]; ActionSubgoal newAction = new ActionSubgoal(_currentEntity.Id, goalToPursue.Id, _currentStoryData); _currentEntity.Actions.Add(newAction); if (goalToPursue.Parameters.Count > 0) { Window newWin = new WindowActionSubgoalEditor(false, _currentEntity, newAction, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } } } else if (result == 2) //Make a calculation { Action nullAction = null; List <string> existingVarNames = _currentEntity.getAllPreviouslyBoundVariableNames(nullAction, true); string varName = Utilities.MakeConstrainedTextDialog( "Please enter a name for the variable that will store the data in this calculation:", "That variable name has already been used.", existingVarNames, this); if (varName != null) { ActionCalculation newCalc = new ActionCalculation(_currentEntity.Id, varName, _currentStoryData); _currentEntity.Actions.Add(newCalc); Window newWin = new WindowActionCalculationEditor(_currentEntity, newCalc, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } } else if (result == 3) //Create a new object { List <string> newObjectChoices = new List <string>(); newObjectChoices.Add("Character"); newObjectChoices.Add("Environment"); foreach (PlotPointType pp in _currentStoryData.PlotPointTypes) { newObjectChoices.Add(pp.Description); } int resultCreateObject = Utilities.MakeListChoiceDialog("What type of object would you like to create?", newObjectChoices, this); if (resultCreateObject < 0) { return; } Action nullAction = null; List <string> existingVarNames = _currentEntity.getAllPreviouslyBoundVariableNames(nullAction, true); string varName = Utilities.MakeConstrainedTextDialog( "Please enter a name for the variable that will store your new Object", "That variable name has already been used.", existingVarNames, this); if (varName == null) { return; } if (resultCreateObject == 0) { string entityName = Utilities.MakeTextDialog("Please enter a name for the new Character:", this); if (entityName == null) { return; } ActionCreateCharacter newCreateEntityAction = new ActionCreateCharacter(_currentEntity.Id, entityName, varName, _currentStoryData); _currentEntity.Actions.Add(newCreateEntityAction); //Synchronize all traits and relationships if (_currentStoryData.Characters.Count > 1) { Utilities.SynchronizeTwoCharacters(_currentStoryData.Characters[0], newCreateEntityAction.NewCharacter, _currentStoryData); } clearDataBindings(); dataBind(); Window newWin = new WindowCharacterEditor(newCreateEntityAction.NewCharacter, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (resultCreateObject == 1) { string entityName = Utilities.MakeTextDialog("Please enter a name for the new Environment:", this); if (entityName == null) { return; } ActionCreateEnvironment newCreateEntityAction = new ActionCreateEnvironment(_currentEntity.Id, entityName, varName, _currentStoryData); _currentEntity.Actions.Add(newCreateEntityAction); //Synchronize all traits and relationships if (_currentStoryData.Environments.Count > 1) { Utilities.SynchronizeTwoEnvironments(_currentStoryData.Environments[0], newCreateEntityAction.NewEnvironment, _currentStoryData); } clearDataBindings(); dataBind(); Window newWin = new WindowEnvironmentEditor(newCreateEntityAction.NewEnvironment, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else { int plotPointIndex = resultCreateObject - 2; PlotPointType currType = _currentStoryData.PlotPointTypes[plotPointIndex]; ActionCreatePlotPoint newCreateEntityAction = new ActionCreatePlotPoint(_currentEntity.Id, currType, varName, _currentStoryData); _currentEntity.Actions.Add(newCreateEntityAction); clearDataBindings(); dataBind(); Window newWin = new WindowPlotPointEditor(newCreateEntityAction.NewPlotPoint, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } } else if (result == 4) //Edit a saved object { List <string> editObjectChoices = new List <string>(); editObjectChoices.Add("Character"); editObjectChoices.Add("Environment"); foreach (PlotPointType pp in _currentStoryData.PlotPointTypes) { editObjectChoices.Add(pp.Description); } int resultEditObject = Utilities.MakeListChoiceDialog("What type of object would you like to edit?", editObjectChoices, this); if (resultEditObject < 0) { return; } else if (resultEditObject == 0) //Edit character { List <string> editObjVarChoices = _currentEntity.getPreviouslyBoundCharacterVarNames(null); if (editObjVarChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Character variables to edit", this); return; } int resultChooseEditTarget = Utilities.MakeListChoiceDialog( "What saved Character would you like to edit?", editObjVarChoices, this); if (resultChooseEditTarget < 0) { return; } ActionEditObject newEditObj = new ActionEditObject( _currentEntity.Id, editObjVarChoices[resultChooseEditTarget], _currentStoryData.CharTypeId, ObjectEditingMode.Trait, _currentStoryData); _currentEntity.Actions.Add(newEditObj); clearDataBindings(); dataBind(); Window newWin = new WindowActionEditEntity(_currentEntity, newEditObj, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (resultEditObject == 1) //Edit Environment { List <string> editObjVarChoices = _currentEntity.getPreviouslyBoundEnvironmentVarNames(null); if (editObjVarChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Environment variables to edit", this); return; } int resultChooseEditTarget = Utilities.MakeListChoiceDialog( "What saved Environment would you like to edit?", editObjVarChoices, this); if (resultChooseEditTarget < 0) { return; } ActionEditObject newEditObj = new ActionEditObject( _currentEntity.Id, editObjVarChoices[resultChooseEditTarget], _currentStoryData.EnvTypeId, ObjectEditingMode.Trait, _currentStoryData); _currentEntity.Actions.Add(newEditObj); clearDataBindings(); dataBind(); Window newWin = new WindowActionEditEntity(_currentEntity, newEditObj, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (resultEditObject > 1) //Edit a Plot Point { int plotPointIndex = resultEditObject - 2; PlotPointType currType = _currentStoryData.PlotPointTypes[plotPointIndex]; if (currType.Traits.Count == 0) { Utilities.MakeErrorDialog("The " + currType.Description + " type has no traits to edit.", this); return; } List <string> editObjVarChoices = _currentEntity.getPreviouslyBoundPlotPointTypeVarNames(currType, null); if (editObjVarChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved " + currType.Description + " variables to edit", this); return; } int resultChooseEditTarget = Utilities.MakeListChoiceDialog( "What saved " + currType.Description + " would you like to edit?", editObjVarChoices, this); if (resultChooseEditTarget < 0) { return; } ActionEditObject newEditObj = new ActionEditObject( _currentEntity.Id, editObjVarChoices[resultChooseEditTarget], currType.Id, ObjectEditingMode.Trait, _currentStoryData); _currentEntity.Actions.Add(newEditObj); clearDataBindings(); dataBind(); Window newWin = new WindowActionEditEntity(_currentEntity, newEditObj, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } } else if (result == 5) //Delete a saved object { List <string> editObjectChoices = new List <string>(); editObjectChoices.Add("Character"); editObjectChoices.Add("Environment"); foreach (PlotPointType pp in _currentStoryData.PlotPointTypes) { editObjectChoices.Add("Plot Point: " + pp.Name); } int resultDelObject = Utilities.MakeListChoiceDialog("What type of object would you like to delete?", editObjectChoices, this); if (resultDelObject < 0) { return; } else if (resultDelObject == 0) //Delete character { List <string> deleteObjectChoices = _currentEntity.getPreviouslyBoundCharacterVarNames(null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Character variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved Character would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } ActionDeleteEntity newDelEntity = new ActionDeleteEntity( _currentEntity.Id, deleteObjectChoices[resultChooseDeletionTarget], _currentStoryData.CharTypeId, _currentStoryData); _currentEntity.Actions.Add(newDelEntity); } else if (resultDelObject == 1) //Delete Environment { List <string> deleteObjectChoices = _currentEntity.getPreviouslyBoundEnvironmentVarNames(null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Environment variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved Environment would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } ActionDeleteEntity newDelEntity = new ActionDeleteEntity( _currentEntity.Id, deleteObjectChoices[resultChooseDeletionTarget], _currentStoryData.EnvTypeId, _currentStoryData); _currentEntity.Actions.Add(newDelEntity); } else if (resultDelObject > 1) //Delete a Plot Point { int plotPointIndex = resultDelObject - 2; PlotPointType currType = _currentStoryData.PlotPointTypes[plotPointIndex]; List <string> deleteObjectChoices = _currentEntity.getPreviouslyBoundPlotPointTypeVarNames(currType, null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved " + currType.Description + " variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved " + currType.Description + " would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } ActionDeleteEntity newDelEntity = new ActionDeleteEntity( _currentEntity.Id, deleteObjectChoices[resultChooseDeletionTarget], currType.Id, _currentStoryData); _currentEntity.Actions.Add(newDelEntity); } } clearDataBindings(); dataBind(); }
private void btCharNew_Click(object sender, RoutedEventArgs e) { string newName = Utilities.MakeTextDialog("Please enter a name for the new Character:", this); if(newName != null) { Character newChar = new Character(newName, _currentStoryData.CharTypeId, _currentStoryData); List<Character> globalCharList = Utilities.getGlobalCharacterList(_currentStoryData); //Synchronize all traits and relationships if (globalCharList.Count > 0) { Utilities.SynchronizeTwoCharacters(globalCharList[0], newChar, _currentStoryData); } _currentStoryData.Characters.Add(newChar); clearDataElements(); dataBindWindow(); Window newWin = new WindowCharacterEditor(newChar, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); clearDataElements(); dataBindWindow(); } }
private void btNewAction_Click(object sender, RoutedEventArgs e) { List<string> editChoices = new List<string>(); editChoices.Add("Output Text"); editChoices.Add("Pursue a Subgoal"); editChoices.Add("Make a Calculation"); editChoices.Add("Create a new Character/Environment/Plot Point"); editChoices.Add("Edit a saved Character/Environment/Plot Point"); editChoices.Add("Delete a saved Character/Environment/Plot Point"); int result = -1; result = Utilities.MakeListChoiceDialog("What type of Action would you like to create?", editChoices, this); if (result < 0) { return; } else if (result == 0) //Output Text { ActionTextOutput newTextOutputAction = new ActionTextOutput(_currentEntity.Id, "", _currentStoryData); _currentEntity.Actions.Add(newTextOutputAction); Window newWin = new WindowActionTextOutput(_currentEntity, newTextOutputAction); newWin.Owner = this; newWin.ShowDialog(); } else if (result == 1) //Pursue Subgoal { List<string> choiceList = new List<string>(); foreach (AuthorGoal goal in _currentStoryData.AuthorGoals) { choiceList.Add(goal.Description); } result = Utilities.MakeListChoiceDialog("Select an Author Goal to pursue", choiceList, this); if (result > -1) { AuthorGoal goalToPursue = _currentStoryData.AuthorGoals[result]; ActionSubgoal newAction = new ActionSubgoal(_currentEntity.Id, goalToPursue.Id, _currentStoryData); _currentEntity.Actions.Add(newAction); if(goalToPursue.Parameters.Count > 0) { Window newWin = new WindowActionSubgoalEditor(false, _currentEntity, newAction, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } } } else if (result == 2) //Make a calculation { Action nullAction = null; List<string> existingVarNames = _currentEntity.getAllPreviouslyBoundVariableNames(nullAction, true); string varName = Utilities.MakeConstrainedTextDialog( "Please enter a name for the variable that will store the data in this calculation:", "That variable name has already been used.", existingVarNames, this); if(varName != null) { ActionCalculation newCalc = new ActionCalculation(_currentEntity.Id, varName, _currentStoryData); _currentEntity.Actions.Add(newCalc); Window newWin = new WindowActionCalculationEditor(_currentEntity, newCalc, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } } else if (result == 3) //Create a new object { List<string> newObjectChoices = new List<string>(); newObjectChoices.Add("Character"); newObjectChoices.Add("Environment"); foreach (PlotPointType pp in _currentStoryData.PlotPointTypes) { newObjectChoices.Add(pp.Description); } int resultCreateObject = Utilities.MakeListChoiceDialog("What type of object would you like to create?", newObjectChoices, this); if (resultCreateObject < 0) { return; } Action nullAction = null; List<string> existingVarNames = _currentEntity.getAllPreviouslyBoundVariableNames(nullAction, true); string varName = Utilities.MakeConstrainedTextDialog( "Please enter a name for the variable that will store your new Object", "That variable name has already been used.", existingVarNames, this); if(varName == null) return; if(resultCreateObject == 0) { string entityName = Utilities.MakeTextDialog("Please enter a name for the new Character:", this); if (entityName == null) return; ActionCreateCharacter newCreateEntityAction = new ActionCreateCharacter(_currentEntity.Id, entityName, varName, _currentStoryData); _currentEntity.Actions.Add(newCreateEntityAction); //Synchronize all traits and relationships if (_currentStoryData.Characters.Count > 1) { Utilities.SynchronizeTwoCharacters(_currentStoryData.Characters[0], newCreateEntityAction.NewCharacter, _currentStoryData); } clearDataBindings(); dataBind(); Window newWin = new WindowCharacterEditor(newCreateEntityAction.NewCharacter, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if(resultCreateObject == 1) { string entityName = Utilities.MakeTextDialog("Please enter a name for the new Environment:", this); if (entityName == null) return; ActionCreateEnvironment newCreateEntityAction = new ActionCreateEnvironment(_currentEntity.Id, entityName, varName, _currentStoryData); _currentEntity.Actions.Add(newCreateEntityAction); //Synchronize all traits and relationships if (_currentStoryData.Environments.Count > 1) { Utilities.SynchronizeTwoEnvironments(_currentStoryData.Environments[0], newCreateEntityAction.NewEnvironment, _currentStoryData); } clearDataBindings(); dataBind(); Window newWin = new WindowEnvironmentEditor(newCreateEntityAction.NewEnvironment, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else { int plotPointIndex = resultCreateObject - 2; PlotPointType currType = _currentStoryData.PlotPointTypes[plotPointIndex]; ActionCreatePlotPoint newCreateEntityAction = new ActionCreatePlotPoint(_currentEntity.Id, currType, varName, _currentStoryData); _currentEntity.Actions.Add(newCreateEntityAction); clearDataBindings(); dataBind(); Window newWin = new WindowPlotPointEditor(newCreateEntityAction.NewPlotPoint, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } } else if (result == 4) //Edit a saved object { List<string> editObjectChoices = new List<string>(); editObjectChoices.Add("Character"); editObjectChoices.Add("Environment"); foreach (PlotPointType pp in _currentStoryData.PlotPointTypes) { editObjectChoices.Add(pp.Description); } int resultEditObject = Utilities.MakeListChoiceDialog("What type of object would you like to edit?", editObjectChoices, this); if (resultEditObject < 0) { return; } else if (resultEditObject == 0) //Edit character { List<string> editObjVarChoices = _currentEntity.getPreviouslyBoundCharacterVarNames(null); if (editObjVarChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Character variables to edit", this); return; } int resultChooseEditTarget = Utilities.MakeListChoiceDialog( "What saved Character would you like to edit?", editObjVarChoices, this); if (resultChooseEditTarget < 0) { return; } ActionEditObject newEditObj = new ActionEditObject( _currentEntity.Id, editObjVarChoices[resultChooseEditTarget], _currentStoryData.CharTypeId, ObjectEditingMode.Trait, _currentStoryData); _currentEntity.Actions.Add(newEditObj); clearDataBindings(); dataBind(); Window newWin = new WindowActionEditEntity(_currentEntity, newEditObj, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (resultEditObject == 1) //Edit Environment { List<string> editObjVarChoices = _currentEntity.getPreviouslyBoundEnvironmentVarNames(null); if (editObjVarChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Environment variables to edit", this); return; } int resultChooseEditTarget = Utilities.MakeListChoiceDialog( "What saved Environment would you like to edit?", editObjVarChoices, this); if (resultChooseEditTarget < 0) { return; } ActionEditObject newEditObj = new ActionEditObject( _currentEntity.Id, editObjVarChoices[resultChooseEditTarget], _currentStoryData.EnvTypeId, ObjectEditingMode.Trait, _currentStoryData); _currentEntity.Actions.Add(newEditObj); clearDataBindings(); dataBind(); Window newWin = new WindowActionEditEntity(_currentEntity, newEditObj, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (resultEditObject > 1) //Edit a Plot Point { int plotPointIndex = resultEditObject - 2; PlotPointType currType = _currentStoryData.PlotPointTypes[plotPointIndex]; if(currType.Traits.Count == 0) { Utilities.MakeErrorDialog("The " + currType.Description + " type has no traits to edit.", this); return; } List<string> editObjVarChoices = _currentEntity.getPreviouslyBoundPlotPointTypeVarNames(currType, null); if (editObjVarChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved " + currType.Description + " variables to edit", this); return; } int resultChooseEditTarget = Utilities.MakeListChoiceDialog( "What saved " + currType.Description + " would you like to edit?", editObjVarChoices, this); if (resultChooseEditTarget < 0) { return; } ActionEditObject newEditObj = new ActionEditObject( _currentEntity.Id, editObjVarChoices[resultChooseEditTarget], currType.Id, ObjectEditingMode.Trait, _currentStoryData); _currentEntity.Actions.Add(newEditObj); clearDataBindings(); dataBind(); Window newWin = new WindowActionEditEntity(_currentEntity, newEditObj, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } } else if (result == 5) //Delete a saved object { List<string> editObjectChoices = new List<string>(); editObjectChoices.Add("Character"); editObjectChoices.Add("Environment"); foreach (PlotPointType pp in _currentStoryData.PlotPointTypes) { editObjectChoices.Add("Plot Point: " + pp.Name); } int resultDelObject = Utilities.MakeListChoiceDialog("What type of object would you like to delete?", editObjectChoices, this); if (resultDelObject < 0) { return; } else if (resultDelObject == 0) //Delete character { List<string> deleteObjectChoices = _currentEntity.getPreviouslyBoundCharacterVarNames(null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Character variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved Character would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } ActionDeleteEntity newDelEntity = new ActionDeleteEntity( _currentEntity.Id, deleteObjectChoices[resultChooseDeletionTarget], _currentStoryData.CharTypeId, _currentStoryData); _currentEntity.Actions.Add(newDelEntity); } else if (resultDelObject == 1) //Delete Environment { List<string> deleteObjectChoices = _currentEntity.getPreviouslyBoundEnvironmentVarNames(null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Environment variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved Environment would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } ActionDeleteEntity newDelEntity = new ActionDeleteEntity( _currentEntity.Id, deleteObjectChoices[resultChooseDeletionTarget], _currentStoryData.EnvTypeId, _currentStoryData); _currentEntity.Actions.Add(newDelEntity); } else if (resultDelObject > 1) //Delete a Plot Point { int plotPointIndex = resultDelObject - 2; PlotPointType currType = _currentStoryData.PlotPointTypes[plotPointIndex]; List<string> deleteObjectChoices = _currentEntity.getPreviouslyBoundPlotPointTypeVarNames(currType,null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved " + currType.Description + " variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved " + currType.Description + " would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } ActionDeleteEntity newDelEntity = new ActionDeleteEntity( _currentEntity.Id, deleteObjectChoices[resultChooseDeletionTarget], currType.Id, _currentStoryData); _currentEntity.Actions.Add(newDelEntity); } } clearDataBindings(); dataBind(); }
private void btEditAction_Click(object sender, RoutedEventArgs e) { Object itemToEdit = actionsDataGrid.SelectedItem; if ((itemToEdit == null) || !(itemToEdit is Action)) { return; } if (itemToEdit.GetType() == typeof(ActionSubgoal)) { AuthorGoal subGoal = _currentStoryData.findAuthorGoalById(((ActionSubgoal)itemToEdit).SubGoalId); if(subGoal == null) { Utilities.MakeErrorDialog("This Pursue Subgoal Action refers to an Author Goal that no longer exists. You cannot edit its contents. Please delete it in order to generate a story.", this); return; } else { Window newWin = new WindowActionSubgoalEditor(false, _currentEntity, (ActionSubgoal)itemToEdit, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } } else if (itemToEdit.GetType() == typeof(ActionEditObject)) { UInt64 editObjTypeId = ((ActionEditObject)itemToEdit).ObjectTypeId; if ((editObjTypeId == _currentStoryData.CharTypeId) || (editObjTypeId == _currentStoryData.EnvTypeId)) { } else { PlotPointType currType = _currentStoryData.findPlotPointTypeById(editObjTypeId); if (currType == null) { //Very bad - precondition statement has no associated type. The user //is not allowed to edit this, and must delete it Utilities.MakeErrorDialog("This Edit Plot Point Action refers to a Plot Point Type that no longer exists. You cannot edit its contents. Please delete it in order to generate a story.", this); return; } } Window newWin = new WindowActionEditEntity(_currentEntity, (ActionEditObject)itemToEdit, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionTextOutput)) { Window newWin = new WindowActionTextOutput(_currentEntity, (ActionTextOutput)itemToEdit); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionCalculation)) { Window newWin = new WindowActionCalculationEditor(_currentEntity, (ActionCalculation)itemToEdit, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionCreatePlotPoint)) { if (null == _currentStoryData.findPlotPointTypeById(((ActionCreatePlotPoint)itemToEdit).NewPlotPoint.TypeId)) { //Very bad - precondition statement has no associated type. The user //is not allowed to edit this, and must delete it Utilities.MakeErrorDialog("This Create Plot Point Action refers to a Plot Point Type that no longer exists. You cannot edit its contents. Please delete it in order to generate a story.", this); return; } Window newWin = new WindowPlotPointEditor(((ActionCreatePlotPoint)itemToEdit).NewPlotPoint, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionCreateEnvironment)) { Window newWin = new WindowEnvironmentEditor(((ActionCreateEnvironment)itemToEdit).NewEnvironment, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionCreateCharacter)) { Window newWin = new WindowCharacterEditor(((ActionCreateCharacter)itemToEdit).NewCharacter, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(ActionDeleteEntity)) //Edit an object deletion action { ActionDeleteEntity deletionAction = (ActionDeleteEntity)itemToEdit; if (deletionAction.TypeId == _currentStoryData.CharTypeId) //Edit char deletion { List<string> deleteObjectChoices = _currentEntity.getPreviouslyBoundCharacterVarNames(null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Character variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved Character would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } deletionAction.VariableName = deleteObjectChoices[resultChooseDeletionTarget]; } else if(deletionAction.TypeId == _currentStoryData.EnvTypeId) //Edit environment deletion { List<string> deleteObjectChoices = _currentEntity.getPreviouslyBoundEnvironmentVarNames(null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved Environment variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved Environment would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } deletionAction.VariableName = deleteObjectChoices[resultChooseDeletionTarget]; } else //Edit some plot point type deletion { PlotPointType currType = _currentStoryData.findPlotPointTypeById(deletionAction.TypeId); if(currType == null) { Utilities.MakeErrorDialog("This Delete Plot Point Action refers to a Plot Point Type that no longer exists. You cannot edit its contents. Please delete it in order to generate a story.", this); return; } List<string> deleteObjectChoices = _currentEntity.getPreviouslyBoundPlotPointTypeVarNames(currType, null); if (deleteObjectChoices.Count == 0) { Utilities.MakeErrorDialog("There are no saved " + currType.Description + " variables to delete", this); return; } int resultChooseDeletionTarget = Utilities.MakeListChoiceDialog( "What saved " + currType.Description + " would you like to delete?", deleteObjectChoices, this); if (resultChooseDeletionTarget < 0) { return; } deletionAction.VariableName = deleteObjectChoices[resultChooseDeletionTarget]; } } clearDataBindings(); dataBind(); }