public static void SavePPTypeTraits(PlotPointType currPPType, List <Trait> newList, StoryData world) { List <Trait> properList = new List <Trait>(); foreach (Trait newTrait in newList) { // Trait oldTrait = currPPType.getTraitByTypeId(newTrait.TypeId); // if (oldTrait == null) // { Trait convertedTrait = new Trait(newTrait, world); Trait oldTrait = currPPType.findTraitByName(newTrait.Name); if ((oldTrait != null) && (oldTrait.Type == newTrait.Type)) { convertedTrait.Value = oldTrait.Value; } properList.Add(convertedTrait); // properList.Add(new Trait(newTrait, world)); // } // else // { // oldTrait.Name = newTrait.Name; //oldTrait.Type = newTrait.Type; //properList.Add(oldTrait); //} } currPPType.Traits = properList; }
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(); }
public static void SynchronizePlotPointWithType(PlotPointType ppType, PlotPoint pp, StoryData world) { List <Trait> properList = new List <Trait>(); foreach (Trait newTrait in ppType.Traits) { // Trait oldTrait = pp.getTraitByTypeId(newTrait.TypeId); // if (oldTrait == null) //{ Trait convertedTrait = new Trait(newTrait, world); Trait oldTrait = pp.findTraitByName(newTrait.Name); if ((oldTrait != null) && (oldTrait.Type == newTrait.Type)) { convertedTrait.Value = oldTrait.Value; } properList.Add(convertedTrait); // properList.Add(new Trait(newTrait, world)); // } // else //{ // oldTrait.Name = newTrait.Name; // oldTrait.Type = newTrait.Type; //properList.Add(oldTrait); //} } pp.Traits = properList; }
//Plot Point is story entity without relationships public PlotPoint(PlotPointType type, StoryData world) : base("", world.getNewId(), type.Id, world) { _traits.Clear(); //Don't need name trait Utilities.SynchronizePlotPointWithType(type, this, world); }
private Parameter _newTarget; //for relationship target (always bound to variable) //_newValue.Name => name of trait or relationship //_newValue.LiteralValueOrBoundVarName => literal value or variable bound value of trait or relationship strength //_newTarget.Name => name of relationship (should be same as _newValue.Name) //_newTarget.LiteralValueOrBoundVarName => character variable that is bound to new relationship public ActionEditObject(UInt64 parentPlotFragmentId, string varObjectName, UInt64 objectTypeId, ObjectEditingMode mode, StoryData world) : base(parentPlotFragmentId, world) { _varObjectName = varObjectName; _varObjectTypeId = objectTypeId; _mode = mode; //Find editing type if (objectTypeId == world.CharTypeId) //Character { _newValue = new Parameter("Name", TraitDataType.Text, false, world); _newTarget = new Parameter("", TraitDataType.Text, true, world); } else if (objectTypeId == world.EnvTypeId) //Environment { _newValue = new Parameter("Name", TraitDataType.Text, false, world); _newTarget = new Parameter("", TraitDataType.Text, true, world); } else //Plot Point { PlotPointType currType = world.findPlotPointTypeById(objectTypeId); _newValue = new Parameter(currType.Traits[0].Name, currType.Traits[0].Type, false, world); _newTarget = new Parameter("", TraitDataType.Text, true, world); } }
public List <string> getPreviouslyBoundPlotPointTypeVarNames(PlotPointType type, Action currentAction) { List <string> ppVars = new List <string>(); foreach (PreconditionStatement precStmt in _precStatements) { //Match the ID of the type now, since plot points have different types if ( (precStmt is PreconditionStatementPlotPoint) && (((PreconditionStatementPlotPoint)precStmt).MatchTypeId == type.Id) && ((PreconditionStatementPlotPoint)precStmt).SaveMatchedObject ) { ppVars.Add(((PreconditionStatementPlotPoint)precStmt).SaveObjectVariableName); } } foreach (Action actItem in _actions) { //We have found where to stop looking, can now return variable list if (actItem == currentAction) { return(ppVars); } else if ( (actItem is ActionCreatePlotPoint) && (((ActionCreatePlotPoint)actItem).NewPlotPoint.TypeId == type.Id) ) { ppVars.Add(((ActionCreatePlotPoint)actItem).VariableName); } } return(ppVars); }
private void btPpTypeNew_Click(object sender, RoutedEventArgs e) { List <string> existingPPTypeNames = new List <string>(); foreach (PlotPointType ppT in _currentStoryData.PlotPointTypes) { existingPPTypeNames.Add(ppT.Name); } string constraintErrorMessage = "That name is already in use by another Plot Point Type."; string newName = Utilities.MakeConstrainedTextDialog("Please enter a name for your new Plot Point Type:", constraintErrorMessage, existingPPTypeNames, this); if (newName != null) { PlotPointType newPPType = new PlotPointType(newName, _currentStoryData); _currentStoryData.PlotPointTypes.Add(newPPType); clearDataElements(); dataBindWindow(); Window newWin = new WindowPlotPointTypeEditor(newPPType, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); clearDataElements(); dataBindWindow(); } }
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(); }
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(); }
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 WindowPlotPointTypeEditor(PlotPointType currentEntity, StoryData storyData) { InitializeComponent(); _currentEntity = currentEntity; _currentStoryData = storyData; _newList = new List<Trait>(); this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); }
public WindowPlotPointTypeEditor(PlotPointType currentEntity, StoryData storyData) { InitializeComponent(); _currentEntity = currentEntity; _currentStoryData = storyData; _newList = new List <Trait>(); this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); }
public WindowPlotPointEditor(PlotPoint existingPP, StoryData storyData) { InitializeComponent(); _pP = existingPP; _ppType = storyData.findPlotPointTypeById(existingPP.TypeId); _currentStoryData = storyData; this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); dataBind(); }
public List <string> getNewPlotPointActionVarNames(PlotPointType type) { List <string> varNames = new List <string>(); foreach (Action act in _actions) { if ((act is ActionCreatePlotPoint) && (((ActionCreatePlotPoint)act).NewPlotPoint.TypeId == type.Id)) { varNames.Add(((ActionCreatePlotPoint)act).VariableName); } } return(varNames); }
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); } }
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."); } }
private void btPPTypeDelete_Click(object sender, RoutedEventArgs e) { Object itemToEdit = ppDataGrid.SelectedItem; if ((itemToEdit == null) || (itemToEdit.GetType() != typeof(PlotPointType))) { return; } PlotPointType ppTypeSelected = (PlotPointType)itemToEdit; if (Utilities.MakeYesNoWarningDialog("Are you sure you want to delete Plot Point Type \"" + ppTypeSelected.Name + "\"?", "Confirm Deletion", this) == MessageBoxResult.No) { return; } _currentStoryData.PlotPointTypes.Remove(ppTypeSelected); clearDataElements(); dataBindWindow(); }
public static List <PlotPoint> getGlobalPlotPointList(PlotPointType type, StoryData world) { List <PlotPoint> fullPPList = new List <PlotPoint>(); //Go get all new characters created in plot fragment actions foreach (AuthorGoal goal in world.AuthorGoals) { foreach (PlotFragment frag in goal.PlotFragments) { foreach (Action act in frag.Actions) { if ((act is ActionCreatePlotPoint) && ((ActionCreatePlotPoint)act).NewPlotPoint.TypeId == type.Id) { fullPPList.Add(((ActionCreatePlotPoint)act).NewPlotPoint); } } } } return(fullPPList); }
public static void SynchronizeGlobalPlotPointsWithType(PlotPointType type, StoryData world) { List <PlotPoint> globalPlotPoints = getGlobalPlotPointList(type, world); foreach (PlotPoint currEntity in globalPlotPoints) { List <Trait> properList = new List <Trait>(); foreach (Trait newTrait in type.Traits) { // Trait oldTrait = currEntity.getTraitByTypeId(newTrait.TypeId); // if (oldTrait == null) // { Trait convertedTrait = new Trait(newTrait, world); Trait oldTrait = currEntity.findTraitByName(newTrait.Name); if ((oldTrait != null) && (oldTrait.Type == newTrait.Type)) { convertedTrait.Value = oldTrait.Value; } properList.Add(convertedTrait); // } // else // { // oldTrait.Name = newTrait.Name; // oldTrait.Type = newTrait.Type; // properList.Add(oldTrait); //} } currEntity.Traits = properList; } }
public ActionCreatePlotPoint(UInt64 parentPlotFragmentId, PlotPointType type, string varName, StoryData world) : base(parentPlotFragmentId, varName, world) { _newPP = new PlotPoint(type, world); }
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 }
public List<string> getNewPlotPointActionVarNames(PlotPointType type) { List<string> varNames = new List<string>(); foreach (Action act in _actions) { if ((act is ActionCreatePlotPoint) && (((ActionCreatePlotPoint)act).NewPlotPoint.TypeId == type.Id)) { varNames.Add(((ActionCreatePlotPoint)act).VariableName); } } return varNames; }
public List<string> getPreviouslyBoundPlotPointTypeVarNames(PlotPointType type, Action currentAction) { List<string> ppVars = new List<string>(); foreach (PreconditionStatement precStmt in _precStatements) { //Match the ID of the type now, since plot points have different types if ( (precStmt is PreconditionStatementPlotPoint) && (((PreconditionStatementPlotPoint)precStmt).MatchTypeId == type.Id) && ((PreconditionStatementPlotPoint)precStmt).SaveMatchedObject ) { ppVars.Add(((PreconditionStatementPlotPoint)precStmt).SaveObjectVariableName); } } foreach (Action actItem in _actions) { //We have found where to stop looking, can now return variable list if (actItem == currentAction) { return ppVars; } else if ( (actItem is ActionCreatePlotPoint) && (((ActionCreatePlotPoint)actItem).NewPlotPoint.TypeId == type.Id) ) { ppVars.Add(((ActionCreatePlotPoint)actItem).VariableName); } } return ppVars; }
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 btPpTypeNew_Click(object sender, RoutedEventArgs e) { List<string> existingPPTypeNames = new List<string>(); foreach (PlotPointType ppT in _currentStoryData.PlotPointTypes) { existingPPTypeNames.Add(ppT.Name); } string constraintErrorMessage = "That name is already in use by another Plot Point Type."; string newName = Utilities.MakeConstrainedTextDialog("Please enter a name for your new Plot Point Type:", constraintErrorMessage, existingPPTypeNames, this); if (newName != null) { PlotPointType newPPType = new PlotPointType(newName, _currentStoryData); _currentStoryData.PlotPointTypes.Add(newPPType); clearDataElements(); dataBindWindow(); Window newWin = new WindowPlotPointTypeEditor(newPPType, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); clearDataElements(); dataBindWindow(); } }
public static void SynchronizeGlobalPlotPointsWithType(PlotPointType type, StoryData world) { List<PlotPoint> globalPlotPoints = getGlobalPlotPointList(type, world); foreach (PlotPoint currEntity in globalPlotPoints) { List<Trait> properList = new List<Trait>(); foreach (Trait newTrait in type.Traits) { // Trait oldTrait = currEntity.getTraitByTypeId(newTrait.TypeId); // if (oldTrait == null) // { Trait convertedTrait = new Trait(newTrait, world); Trait oldTrait = currEntity.findTraitByName(newTrait.Name); if ((oldTrait != null) && (oldTrait.Type == newTrait.Type)) { convertedTrait.Value = oldTrait.Value; } properList.Add(convertedTrait); // } // else // { // oldTrait.Name = newTrait.Name; // oldTrait.Type = newTrait.Type; // properList.Add(oldTrait); //} } currEntity.Traits = properList; } }
public static void SavePPTypeTraits(PlotPointType currPPType, List<Trait> newList, StoryData world) { List<Trait> properList = new List<Trait>(); foreach (Trait newTrait in newList) { // Trait oldTrait = currPPType.getTraitByTypeId(newTrait.TypeId); // if (oldTrait == null) // { Trait convertedTrait = new Trait(newTrait, world); Trait oldTrait = currPPType.findTraitByName(newTrait.Name); if ((oldTrait != null) && (oldTrait.Type == newTrait.Type)) { convertedTrait.Value = oldTrait.Value; } properList.Add(convertedTrait); // properList.Add(new Trait(newTrait, world)); // } // else // { // oldTrait.Name = newTrait.Name; //oldTrait.Type = newTrait.Type; //properList.Add(oldTrait); //} } currPPType.Traits = properList; }
public static List<PlotPoint> getGlobalPlotPointList(PlotPointType type, StoryData world) { List<PlotPoint> fullPPList = new List<PlotPoint>(); //Go get all new characters created in plot fragment actions foreach (AuthorGoal goal in world.AuthorGoals) { foreach (PlotFragment frag in goal.PlotFragments) { foreach (Action act in frag.Actions) { if ((act is ActionCreatePlotPoint) && ((ActionCreatePlotPoint)act).NewPlotPoint.TypeId == type.Id) { fullPPList.Add(((ActionCreatePlotPoint)act).NewPlotPoint); } } } } return fullPPList; }
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 btNewPrecond_Click(object sender, RoutedEventArgs e) { List <string> newChoices = new List <string>(); newChoices.Add("Character Constraint"); newChoices.Add("Environment Constraint"); foreach (PlotPointType pp in _currentStoryData.PlotPointTypes) { newChoices.Add(pp.Description + " Constraint"); } int result = -1; result = Utilities.MakeListChoiceDialog("What type of constraint would you like to create?", newChoices, this); if (result < 0) { return; } //ASK FOR EXISTENCE OR NONEXISTENCE - THIS CANNOT BE CHANGED IN THE EDITOR //changes would result in the editor having to wipe out variable saves within constraints and generally it would be extra work //to maintain List <string> existNonExistChoices = new List <string>(); existNonExistChoices.Add("The object must exist"); existNonExistChoices.Add("The object must NOT exist"); int resultExistence = Utilities.MakeListChoiceDialog("Would like the object you are matching to exist or not exist in the story world?", existNonExistChoices, this); if (resultExistence < 0) { return; } bool objectExists = (resultExistence == 0); if (result == 0) //Character { if (Utilities.getGlobalCharacterList(_currentStoryData).Count == 0) { Utilities.MakeErrorDialog("Please make a new Character, either in the Character editor, or within a Create Object action, before creating Character-matching precondition statements.", this); return; } PreconditionStatementCharacter newPrecond = new PreconditionStatementCharacter(_currentEntity.Id, _currentStoryData); newPrecond.ObjectExists = objectExists; _currentEntity.PrecStatements.Add(newPrecond); clearDataBindings(); dataBind(); Window newWin = new WindowPreconditionEditor(_currentEntity, newPrecond, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (result == 1) //Environment { if (Utilities.getGlobalEnvironmentList(_currentStoryData).Count == 0) { Utilities.MakeErrorDialog("Please make a new Environment, either in the Environment editor, or within a Create Environment action, before creating Environment-matching precondition statements.", this); return; } PreconditionStatementEnvironment newPrecond = new PreconditionStatementEnvironment(_currentEntity.Id, _currentStoryData); newPrecond.ObjectExists = objectExists; _currentEntity.PrecStatements.Add(newPrecond); clearDataBindings(); dataBind(); Window newWin = new WindowPreconditionEditor(_currentEntity, newPrecond, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (result > 1) //PlotPointType { int plotPointIndex = result - 2; PlotPointType currType = _currentStoryData.PlotPointTypes[plotPointIndex]; if (currType.Traits.Count == 0) { Utilities.MakeErrorDialog("The " + currType.Description + " type has no traits to save or compare, and therefore cannot be used in a Precondition statement", this); return; } PreconditionStatementPlotPoint newPrecond = new PreconditionStatementPlotPoint(_currentEntity.Id, currType, _currentStoryData); newPrecond.ObjectExists = objectExists; _currentEntity.PrecStatements.Add(newPrecond); clearDataBindings(); dataBind(); Window newWin = new WindowPreconditionEditor(_currentEntity, newPrecond, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } clearDataBindings(); dataBind(); }
public PreconditionStatementPlotPoint(UInt64 parentPlotFragmentId, PlotPointType type, StoryData world) : base(parentPlotFragmentId, world) { _plotPointTypeId = type.Id; }
private void declareNewPlotPoint(bool prependType, PlotPoint pp, PlotPointType ppType, string saveAsName) { int currentCount = 0; string typeName = (string)_plotPointTypeNames[ppType.Id]; int paramCount = 1 + ppType.Traits.Count; if(prependType) { _tw.WriteLine(typeName + " " + saveAsName + " = new " + typeName + " ( "); } else { _tw.WriteLine(saveAsName + " = new " + typeName + " ( "); } _tw.Indent(); _tw.WriteLine(pp.Id.ToString() + ", "); currentCount++; string attribString; foreach (Trait tr in pp.Traits) { attribString = generateJavaValueString(tr); currentCount++; if (currentCount != paramCount) { attribString += ", "; } _tw.WriteLine(attribString); } _tw.OutDent(); _tw.WriteLine(");"); }
public static void SynchronizePlotPointWithType(PlotPointType ppType, PlotPoint pp, StoryData world) { List<Trait> properList = new List<Trait>(); foreach (Trait newTrait in ppType.Traits) { // Trait oldTrait = pp.getTraitByTypeId(newTrait.TypeId); // if (oldTrait == null) //{ Trait convertedTrait = new Trait(newTrait, world); Trait oldTrait = pp.findTraitByName(newTrait.Name); if ((oldTrait != null) && (oldTrait.Type == newTrait.Type)) { convertedTrait.Value = oldTrait.Value; } properList.Add(convertedTrait); // properList.Add(new Trait(newTrait, world)); // } // else //{ // oldTrait.Name = newTrait.Name; // oldTrait.Type = newTrait.Type; //properList.Add(oldTrait); //} } pp.Traits = properList; }