private PlotPointType _ppType; //only valid if in pp editing mode #endregion Fields #region Constructors public WindowActionEditEntity(PlotFragment frag, ActionEditObject currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; _parentPlotFragment = frag; _ppType = null; _currentlyDataBinding = false; //Find editing type if (_currentEntity.ObjectTypeId == currStoryData.CharTypeId) { _editingMode = 0; } else if (_currentEntity.ObjectTypeId == currStoryData.EnvTypeId) { _editingMode = 1; } else { PlotPointType currType = currStoryData.findPlotPointTypeById(_currentEntity.ObjectTypeId); _editingMode = 2; _ppType = currType; } txtBoxNumberInput.NullValue = 0.0; dataBind(); }
public WindowPreconditionEditor(PlotFragment frag, PreconditionStatement currEntity, StoryData currStoryData) { InitializeComponent(); _currentStoryData = currStoryData; _currentEntity = currEntity; _parentPlotFragment = frag; _currentlySelectedConstraint = null; _currentlyDataBinding = false; //Find editing type if (currEntity is PreconditionStatementCharacter) { _editingMode = 0; } else if (currEntity is PreconditionStatementEnvironment) { _editingMode = 1; } else { PlotPointType currType = currStoryData.findPlotPointTypeById(((PreconditionStatementPlotPoint)currEntity).MatchTypeId); _editingMode = 2; _ppType = currType; } txtBoxNumberInput.NullValue = 0.0; dataBind(); }
override public Object Clone() { //TODO: make cloning work properly for duplication of entire plot fragments and author goals //- add a new clone method or something to //stop the creation of new unique names/variable names ActionCreateEnvironment newClone = (ActionCreateEnvironment)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.NewEnvironment = (Environment)_newEntity.Clone(); //Give the new var a unique name, making sure the new name is actually unique. //If name is not unique, keep increment suffix number until it is string newName = newClone.VariableName; int cloneCount = 1; PlotFragment parentFrag = StoryWorldDataProvider.getStoryData().findPlotFragmentById(_parentPlotFragmentId); Action nullAction = null; List <string> prevVars = parentFrag.getAllPreviouslyBoundVariableNames(nullAction, true); while (prevVars.Contains(newName)) { newName = newClone.VariableName + cloneCount.ToString(); cloneCount++; } newClone.VariableName = newName; return(newClone); }
public List <Trait> getPreviouslyBoundPrimitiveVariables(TraitDataType variableType, bool allTypes, Constraint currentConstraint) { PlotFragment parentFrag = StoryWorldDataProvider.getStoryData().findPlotFragmentById(_parentPlotFragmentId); List <Trait> varsToReturn = parentFrag.getPreviouslyBoundPrimitiveVariables(variableType, allTypes, this); foreach (Constraint cons in Constraints) { if (cons == currentConstraint) { //We have found where to stop looking, can now return variable list return(varsToReturn); } else if (cons.ContainsSavedVariable) { if (allTypes || (cons.SavedVariable.Type == variableType)) { //Add the variable names bound in this constraint to the running list varsToReturn.Add(cons.SavedVariable); } } } return(varsToReturn); }
public WindowActionEditEntity(PlotFragment frag, ActionEditObject currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; _parentPlotFragment = frag; _ppType = null; _currentlyDataBinding = false; //Find editing type if (_currentEntity.ObjectTypeId == currStoryData.CharTypeId) { _editingMode = 0; } else if (_currentEntity.ObjectTypeId == currStoryData.EnvTypeId) { _editingMode = 1; } else { PlotPointType currType = currStoryData.findPlotPointTypeById(_currentEntity.ObjectTypeId); _editingMode = 2; _ppType = currType; } txtBoxNumberInput.NullValue = 0.0; dataBind(); }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { base.checkAndUpdateDependences(previouslyBoundVars, world); //Additionally, check that trait names exist in the class of object that this is constrained on //Check to make sure all trait or relationships exist on the object to be edited PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); List <Relationship> relListToCompare = new List <Relationship>(); if (_matchingEntityTypeId == world.CharTypeId) { if (world.Characters.Count > 0) { relListToCompare = world.Characters[0].Relationships; } } else if (_matchingEntityTypeId == world.EnvTypeId) { if (world.Environments.Count > 0) { relListToCompare = world.Environments[0].Relationships; } } //look for trait we are editing if (null == Utilities.findRelationshipByName(relListToCompare, _comparisonValue.Name)) { throw new Exception("A Relationship constraint within a precondition statement within Plot Fragment \"" + parentFrag.Name + "\" refers to a relationship with name \"" + _comparisonValue.Name + "\" that no longer exists."); } }
virtual public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Delete Object Action not have parent Plot Fragment"); } //check if variable to compare to exists if (_comparisonValue.ValueIsBoundToVariable) { if (null == Utilities.findTraitByNameAndType(previouslyBoundVars, (string)_comparisonValue.LiteralValueOrBoundVarName, _comparisonValue.Type)) { throw new Exception("A precondition statement in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + (string)_comparisonValue.LiteralValueOrBoundVarName + "\", \nwhich has a different type or does not exist in any previous Author Goal parameters or precondition statements."); } } //Add new variable to running list of bound vars if (_saveAttribute) { previouslyBoundVars.Add(_savedVariable); } }
public WindowPlotFragmentEditor(PlotFragment currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; _parentGoal = currStoryData.findAuthorGoalById(currEntity.ParentAuthorGoalId); }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Delete Object Action not have parent Plot Fragment"); } //check for variables bound to object references List <string> names = null; if (_entityTypeId == world.CharTypeId) { names = parentFrag.getPreviouslyBoundCharacterVarNames(this); } else if (_entityTypeId == world.EnvTypeId) { names = parentFrag.getPreviouslyBoundEnvironmentVarNames(this); } else { PlotPointType currType = world.findPlotPointTypeById(_entityTypeId); if (currType != null) { names = parentFrag.getPreviouslyBoundPlotPointTypeVarNames(currType, this); } } if (!(names.Contains(_varNameForDeletion))) { throw new Exception("Delete Object Action in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + _varNameForDeletion + "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } //check for any previous deletions of this variable - that would be BAD because another //deletion would cause this to fail in ABL foreach (Action act in parentFrag.Actions) { if (act is ActionDeleteEntity) { if ((act != this) && (((ActionDeleteEntity)act).VariableName == _varNameForDeletion) ) { throw new Exception("The Plot Fragment \"" + parentFrag.Name + "\" deletes the object saved in the variable \"" + _varNameForDeletion + "\" more than once, which is not allowed. ."); } } } return; }
public WindowActionTextOutput(PlotFragment frag, ActionTextOutput textOutputAction) { InitializeComponent(); _parentPlotFrag = frag; _textOutputAction = textOutputAction; textBoxInput.Focus(); dataBind(); }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Calculation Action not have parent Plot Fragment"); } if (ParamLeft.ValueIsBoundToVariable) { bool foundVar = false; foreach (Trait traitItem in previouslyBoundVars) { if ( (traitItem.Name == (string)ParamLeft.LiteralValueOrBoundVarName) && (traitItem.Type == ParamLeft.Type) ) { foundVar = true; break; } } if (!foundVar) { throw new Exception("Calculation Action in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + (string)ParamLeft.LiteralValueOrBoundVarName + "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } } if (ParamRight.ValueIsBoundToVariable) { bool foundVar = false; foreach (Trait traitItem in previouslyBoundVars) { if ( (traitItem.Name == (string)ParamRight.LiteralValueOrBoundVarName) && (traitItem.Type == ParamRight.Type) ) { foundVar = true; break; } } if (!foundVar) { throw new Exception("Calculation Action in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + (string)ParamRight.LiteralValueOrBoundVarName + "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } } previouslyBoundVars.Add(_resultVar); }
public WindowActionCalculationEditor(PlotFragment parentPlotFragment, ActionCalculation calc, StoryData world) { InitializeComponent(); _currentEntity = calc; _parentPlotFragment = parentPlotFragment; _currentStoryData = world; textBoxNumericLeft.NullValue = 0.0; textBoxNumericRight.NullValue = 0.0; }
//Create object actions for charcters and environments do not reference any variables, //only the "edit object" action can do that //The exception is the plot point creator, which can have an error if the plot point type is //missing override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Create object action does not have parent Plot Fragment"); } return; }
virtual public Object Clone() { //TODO: make cloning work properly for duplication of entire plot fragments and author goals //- add a new clone method or something to //stop the creation of new unique names/variable names PlotFragment newClone = (PlotFragment)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.PrecStatements = new List <PreconditionStatement>(); newClone.Actions = new List <Action>(); foreach (PreconditionStatement prec in _precStatements) { //This clone operation will result in variable names with "1" appended, //because the clone operation checks the current parent plot fragment //and attempts to create unique variable names newClone.PrecStatements.Add((PreconditionStatement)prec.Clone()); } foreach (Action act in _actions) { //This clone operation will result in variable names with "1" appended, //because the clone operation checks the current parent plot fragment //and attempts to create unique variable names newClone.Actions.Add((Action)act.Clone()); } string newName = newClone.Name; int cloneCount = 1; List <string> prevVars = new List <string>(); foreach (PlotFragment frag in StoryWorldDataProvider.getStoryData().findAuthorGoalById(_parentAuthorGoalId).PlotFragments) { prevVars.Add(frag.Name); } while (prevVars.Contains(newName)) { newName = newClone.Name + cloneCount.ToString(); cloneCount++; } newClone.Name = newName; return(newClone); }
public override void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Edit Object Action not have parent Plot Fragment"); } //Check to make sure all trait or relationships exist on the object to be edited, for each //constraint List <Trait> traitListToCompare = null; PlotPointType currType = world.findPlotPointTypeById(_plotPointTypeId); if (currType != null) { traitListToCompare = currType.Traits; } else { throw new Exception("A Plot Point-matching Precondition Plot Fragment \"" + parentFrag.Name + "\" refers to a Plot Point type that no longer exists."); } foreach (Constraint cons in _constraints) { if (cons is TraitConstraint) { if (null == Utilities.findTraitByNameAndType(traitListToCompare, cons.ComparisonValue.Name, cons.ComparisonValue.Type)) { throw new Exception("A " + currType.Description + "-matching precondition statement in Plot Fragment \"" + parentFrag.Name + "\" refers to trait variable \"" + cons.ComparisonValue.Name + "\", \nwhich now has a different type or no longer exists."); } } } //Now do individual checks foreach (Constraint cons in _constraints) { cons.checkAndUpdateDependences(previouslyBoundVars, world); } }
public WindowActionSubgoalEditor(bool interactionMode, PlotFragment frag, ActionSubgoal currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; _parentPlotFragment = frag; _currentlySelectedParameter = null; //_previouslySlectedParameter = null; _validData = true; _interactionMode = interactionMode; txtBoxNumberInput.NullValue = 0.0; _currentEntity.syncParametersWithSubgoal(); dataBind(); }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Create plot point action does not have parent Plot Fragment"); } if (world.findPlotPointTypeById(_newPP.TypeId) == null) { throw new Exception("Create Plot Point Action in Plot Fragment \"" + parentFrag.Name + "\" " + "uses a Plot Point Type which no longer exists."); } }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { base.checkAndUpdateDependences(previouslyBoundVars, world); //Additionally, check that trait names exist in the class of object that this is constrained on //Check to make sure all trait or relationships exist on the object to be edited List <Trait> traitListToCompare = new List <Trait>(); PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (_matchingEntityTypeId == world.CharTypeId) { if (world.Characters.Count > 0) { traitListToCompare = world.Characters[0].Traits; } } else if (_matchingEntityTypeId == world.EnvTypeId) { if (world.Environments.Count > 0) { traitListToCompare = world.Environments[0].Traits; } } else { PlotPointType currType = world.findPlotPointTypeById(_matchingEntityTypeId); if (currType != null) { traitListToCompare = currType.Traits; } else { throw new Exception("A Trait constraint within a precondition statement within Plot Fragment \"" + parentFrag.Name + "\" refers to a Plot Point type that no longer exists."); } } //look for trait we are editing if (null == Utilities.findTraitByNameAndType(traitListToCompare, _comparisonValue.Name, _comparisonValue.Type)) { throw new Exception("A Trait constraint within a precondition statement within Plot Fragment \"" + parentFrag.Name + "\" refers to a trait with name \"" + _comparisonValue.Name + "\" and type \"" + Trait.TraitDataTypeToString(_comparisonValue.Type) + "\" that no longer exists."); } }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Text Output Action does not have parent Plot Fragment"); } //Get all variable references from text //Check variable references from previous plot fragment preconditions and actions if (_VariableMatcher == null) { //Matches anything between two outermost "<" and ">" symbols, in that order, //which could also mean other "<" or ">" symbols. This allows variables in the Wide Ruled //interface to have any type of text in them (even though ABL will need them reformatted anyway). // _VariableMatcher = new Regex("(?:[^<]*<)[^<]*(?=>(?!>))", RegexOptions.Compiled | RegexOptions.IgnoreCase); _VariableMatcher = new Regex("(?:[^<])[^<]*(?=>(?!>))", RegexOptions.Compiled | RegexOptions.IgnoreCase); } MatchCollection varMatches = _VariableMatcher.Matches(_textOutput); foreach (Match varMatch in varMatches) { //Don't need to check var types. All primitive types can be converted to strings. bool foundIt = false; foreach (Trait traitItem in previouslyBoundVars) { if (traitItem.Name == varMatch.Value) { foundIt = true; break; } } if (!foundIt) { throw new Exception("Text Output Action in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + varMatch.Value + "\", \nwhich does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } } }
virtual public Object Clone() { //TODO: make cloning work properly for duplication of entire plot fragments and author goals //- add a new clone method or something to //stop the creation of new unique names/variable names PreconditionStatement newClone = (PreconditionStatement)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.Constraints = new List <Constraint>(); foreach (Constraint cons in _constraints) { newClone.Constraints.Add((Constraint)cons.Clone()); } //If name is not unique, keep increment suffix number until it is string newName = newClone.SaveObjectVariableName; int cloneCount = 1; PlotFragment parentFrag = StoryWorldDataProvider.getStoryData().findPlotFragmentById(_parentPlotFragmentId); Action nullAction = null; List <string> prevVars = parentFrag.getAllPreviouslyBoundVariableNames(nullAction, true); while (prevVars.Contains(newName)) { newName = newClone.SaveObjectVariableName + cloneCount.ToString(); cloneCount++; } newClone.SaveObjectVariableName = newName; return(newClone); }
public List <string> getAllPreviouslyBoundVariableNames(Constraint currentConstraint) { PlotFragment parentFrag = StoryWorldDataProvider.getStoryData().findPlotFragmentById(_parentPlotFragmentId); List <string> varsToReturn = parentFrag.getAllPreviouslyBoundVariableNames(this, true); foreach (Constraint cons in Constraints) { if (cons == currentConstraint) { //We have found where to stop looking, can now return variable list return(varsToReturn); } else if (cons.ContainsSavedVariable) { //Add the variable names bound in this constraint to the running list varsToReturn.Add(cons.SavedVariable.Name); } } return(varsToReturn); }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Pursue Subgoal Action does not have parent Plot Fragment"); } AuthorGoal goalToPursue = world.findAuthorGoalById(_subGoalId); if (goalToPursue == null) { //clear out parameter list //_parametersToPass.Clear(); throw new Exception("Pursue Subgoal Action in Plot Fragment \"" + parentFrag.Name + "\" refers to an Author Goal which does not exist."); } if (goalToPursue.PlotFragments.Count == 0) { throw new Exception("Pursue Subgoal Action in Plot Fragment \"" + parentFrag.Name + "\" refers to an Author Goal which has no child plot fragments that fulfill it." + "\nAll goals which are used during story creation must have at least one Plot Fragment associated with them before generation can begin."); } //Check variable references from previous plot fragment preconditions and actions foreach (Parameter param in _parametersToPass) { if (param.ValueIsBoundToVariable) { bool foundIt = false; foreach (Trait traitItem in previouslyBoundVars) { if ( (traitItem.Name == (string)param.LiteralValueOrBoundVarName) && (traitItem.Type == param.Type) ) { foundIt = true; break; } } if (!foundIt) { throw new Exception("Pursue Subgoal Action in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + param.LiteralValueOrBoundVarName + "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } } } bool dataUpdated = syncParametersWithSubgoal(); if (dataUpdated) { throw new Exception("Pursue Subgoal Action in Plot Fragment \"" + parentFrag.Name + "\" refers to an Author Goal that has had its parameters changed.\n" + "Wide Ruled has corrected the changes, but you should look at the Action to make sure the newly updated parameters have the correct value."); } }
private void btGoalFragNew_Click(object sender, RoutedEventArgs e) { List<string> editChoices = new List<string>(); editChoices.Add("Author Goal"); editChoices.Add("Plot Fragment"); int result = -1; if(_currentStoryData.AuthorGoals.Count > 0) result = Utilities.MakeListChoiceDialog("What type of Story Object would you like to create?", editChoices, this); else { result = 0; } if(result < 0) { return; } else if(result == 0) //Author Goal { List<string> choiceConstraints = new List<string>(); foreach (AuthorGoal goal in _currentStoryData.AuthorGoals) { choiceConstraints.Add(goal.Name); } string newName = Utilities.MakeConstrainedTextDialog( "Please enter a name for your new Author Goal:", "That name is already in use by another Author Goal.", choiceConstraints, this); if(newName == null) { return; } AuthorGoal newAuthGoal = new AuthorGoal(newName, _currentStoryData); _currentStoryData.AuthorGoals.Add(newAuthGoal); //If first author goal, set it to the start goal if (_currentStoryData.AuthorGoals.Count == 1) { _currentStoryData.StartGoalId = newAuthGoal.Id; } clearDataElements(); dataBindWindow(); Window newWin = new WindowAuthorGoalEditor(newAuthGoal, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); clearDataElements(); dataBindWindow(); } else if(result == 1) //Plot Fragment { //Get parent author goal editChoices.Clear(); foreach (AuthorGoal goal in _currentStoryData.AuthorGoals) { editChoices.Add(goal.Description); } result = Utilities.MakeListChoiceDialog("Choose the Author Goal for this new Plot Fragment:", editChoices, this); if(result < 0) { return; } AuthorGoal parentAuthorGoal = _currentStoryData.AuthorGoals[result]; // Get name List<string> choiceConstraints = new List<string>(); foreach (PlotFragment frag in parentAuthorGoal.PlotFragments) { choiceConstraints.Add(frag.Name); } string newName = Utilities.MakeConstrainedTextDialog( "Please enter a name for your new Plot Fragment:", "That name is already in use by another Plot Fragment.", choiceConstraints, this); if(newName == null) { return; } PlotFragment newPlotFrag = new PlotFragment(newName, parentAuthorGoal.Id, _currentStoryData); parentAuthorGoal.PlotFragments.Add(newPlotFrag); clearDataElements(); dataBindWindow(); Window newWin = new WindowPlotFragmentEditor(newPlotFrag, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); clearDataElements(); dataBindWindow(); } }
private void btGoalFragNew_Click(object sender, RoutedEventArgs e) { List <string> editChoices = new List <string>(); editChoices.Add("Author Goal"); editChoices.Add("Plot Fragment"); int result = -1; if (_currentStoryData.AuthorGoals.Count > 0) { result = Utilities.MakeListChoiceDialog("What type of Story Object would you like to create?", editChoices, this); } else { result = 0; } if (result < 0) { return; } else if (result == 0) //Author Goal { List <string> choiceConstraints = new List <string>(); foreach (AuthorGoal goal in _currentStoryData.AuthorGoals) { choiceConstraints.Add(goal.Name); } string newName = Utilities.MakeConstrainedTextDialog( "Please enter a name for your new Author Goal:", "That name is already in use by another Author Goal.", choiceConstraints, this); if (newName == null) { return; } AuthorGoal newAuthGoal = new AuthorGoal(newName, _currentStoryData); _currentStoryData.AuthorGoals.Add(newAuthGoal); //If first author goal, set it to the start goal if (_currentStoryData.AuthorGoals.Count == 1) { _currentStoryData.StartGoalId = newAuthGoal.Id; } clearDataElements(); dataBindWindow(); Window newWin = new WindowAuthorGoalEditor(newAuthGoal, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); clearDataElements(); dataBindWindow(); } else if (result == 1) //Plot Fragment { //Get parent author goal editChoices.Clear(); foreach (AuthorGoal goal in _currentStoryData.AuthorGoals) { editChoices.Add(goal.Description); } result = Utilities.MakeListChoiceDialog("Choose the Author Goal for this new Plot Fragment:", editChoices, this); if (result < 0) { return; } AuthorGoal parentAuthorGoal = _currentStoryData.AuthorGoals[result]; // Get name List <string> choiceConstraints = new List <string>(); foreach (PlotFragment frag in parentAuthorGoal.PlotFragments) { choiceConstraints.Add(frag.Name); } string newName = Utilities.MakeConstrainedTextDialog( "Please enter a name for your new Plot Fragment:", "That name is already in use by another Plot Fragment.", choiceConstraints, this); if (newName == null) { return; } PlotFragment newPlotFrag = new PlotFragment(newName, parentAuthorGoal.Id, _currentStoryData); parentAuthorGoal.PlotFragments.Add(newPlotFrag); clearDataElements(); dataBindWindow(); Window newWin = new WindowPlotFragmentEditor(newPlotFrag, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); clearDataElements(); dataBindWindow(); } }
override public void checkAndUpdateDependences(List <Trait> previouslyBoundVars, StoryData world) { PlotFragment parentFrag = world.findPlotFragmentById(_parentPlotFragmentId); if (parentFrag == null) { throw new Exception("Delete Object Action not have parent Plot Fragment"); } //check for variables bound to object references List <string> names = null; string objectTypeString = ""; if (_varObjectTypeId == world.CharTypeId) { names = parentFrag.getPreviouslyBoundCharacterVarNames(this); objectTypeString = "Character"; } else if (_varObjectTypeId == world.EnvTypeId) { names = parentFrag.getPreviouslyBoundEnvironmentVarNames(this); objectTypeString = "Environment"; } else { PlotPointType currType = world.findPlotPointTypeById(_varObjectTypeId); if (currType != null) { names = parentFrag.getPreviouslyBoundPlotPointTypeVarNames(currType, this); objectTypeString = currType.Description; } else { throw new Exception("Edit Plot Point Action in Plot Fragment \"" + parentFrag.Name + "\" " + "uses a Plot Point Type which no longer exists."); } } if (!(names.Contains(_varObjectName))) { throw new Exception("Edit Object Action in Plot Fragment \"" + parentFrag.Name + "\" refers to saved " + objectTypeString + " \"" + _varObjectName + "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } //make sure variable for relationship target edit exists if ((_mode == ObjectEditingMode.RelationshipTarget) && !(names.Contains((string)_newTarget.LiteralValueOrBoundVarName))) { throw new Exception("Edit Object Action in Plot Fragment \"" + parentFrag.Name + "\" refers to saved " + objectTypeString + " \"" + (string)_newTarget.LiteralValueOrBoundVarName + "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } //Check for bound primitive variables when saving trait or relationship strength if ( ((_mode == ObjectEditingMode.RelationshipStrength) || (_mode == ObjectEditingMode.Trait)) && (_newValue.ValueIsBoundToVariable == true) ) { bool foundIt = false; foreach (Trait traitItem in previouslyBoundVars) { if ( (traitItem.Name == (string)_newValue.LiteralValueOrBoundVarName) && (traitItem.Type == _newValue.Type) ) { foundIt = true; break; } } if (!foundIt) { throw new Exception("Edit Object Action in Plot Fragment \"" + parentFrag.Name + "\" refers to variable \"" + (string)_newValue.LiteralValueOrBoundVarName + "\", \nwhich has a different type or does not exist in any previous Author Goal parameters, precondition statements, or actions ."); } } //Check to make sure all trait or relationships exist on the object to be edited List <Trait> traitListToCompare = new List <Trait>(); List <Relationship> relListToCompare = new List <Relationship>(); if (_varObjectTypeId == world.CharTypeId) { if (world.Characters.Count > 0) { traitListToCompare = world.Characters[0].Traits; relListToCompare = world.Characters[0].Relationships; } } else if (_varObjectTypeId == world.EnvTypeId) { if (world.Environments.Count > 0) { traitListToCompare = world.Environments[0].Traits; relListToCompare = world.Environments[0].Relationships; } } else { PlotPointType currType = world.findPlotPointTypeById(_varObjectTypeId); if (currType != null) { traitListToCompare = currType.Traits; } else { throw new Exception("Edit Object Action in Plot Fragment \"" + parentFrag.Name + "\" refers to a Plot Point type that no longer exists."); } } if (_mode == ObjectEditingMode.Trait) { //look for trait we are editing if (null == Utilities.findTraitByNameAndType(traitListToCompare, _newValue.Name, _newValue.Type)) { throw new Exception("Edit Object Action in Plot Fragment \"" + parentFrag.Name + "\" refers to a trait with name \"" + _newValue.Name + "\" and type \"" + Trait.TraitDataTypeToString(_newValue.Type) + "\" that no longer exists."); } } else { //look for relationship we are editing if (null == Utilities.findRelationshipByName(relListToCompare, _newValue.Name)) { throw new Exception("Edit Object Action in Plot Fragment \"" + parentFrag.Name + "\" refers to a relationship with name \"" + _newValue.Name + " that no longer exists."); } } //No new variables to add to the binding list, so we can just exit after all the error checks }