public WindowPlotFragmentEditor(PlotFragment currEntity, StoryData currStoryData) { InitializeComponent(); _currentEntity = currEntity; _currentStoryData = currStoryData; _parentGoal = currStoryData.findAuthorGoalById(currEntity.ParentAuthorGoalId); }
private void dataBindList() { titleTextBlock.Text = _currentStoryData.findAuthorGoalById(_currentEntity.SubGoalId).Name; paramDataGrid.ItemsSource = _currentEntity.ParametersToPass; paramDataGrid.SelectedItem = null; _currentlySelectedParameter = null; }
public void checkAndUpdateDependencesAsInteraction(Interaction parentInteraction, List <Trait> previouslyBoundVars, StoryData world) { AuthorGoal goalToPursue = world.findAuthorGoalById(_subGoalId); if (goalToPursue == null) { //clear out parameter list _parametersToPass.Clear(); throw new Exception("Interaction \"" + parentInteraction.Title + "\" refers to an Author Goal which does not exist."); } if (goalToPursue.PlotFragments.Count == 0) { throw new Exception("Interaction \"" + parentInteraction.Title + "\" refers to an Author Goal which has no child plot fragments that fulfill it." + "\nAll Interactions must have at least one Plot Fragment associated with the goal they pursue before generation can begin."); } bool dataUpdated = syncParametersWithSubgoal(); if (dataUpdated) { throw new Exception("Interaction \"" + parentInteraction.Title + "\" refers to an Author Goal that has had its parameters changed.\n" + "Wide Ruled has corrected the changes, but you should look at the Interaction to make sure the newly updated parameters have the correct value."); } }
public ActionSubgoal(UInt64 parentPlotFragmentId, UInt64 subgoalId, StoryData world) : base(parentPlotFragmentId, world) { _subGoalId = subgoalId; _parametersToPass = new List<Parameter>(); AuthorGoal subGoal = world.findAuthorGoalById(subgoalId); if (subGoal != null) { List<Parameter> parameters = subGoal.Parameters; foreach (Parameter param in parameters) { // Add all parameters from the subgoal, which will later be filled in // with literals or variables _parametersToPass.Add(new Parameter(param.Name, param.Type, false, world)); } } }
public ActionSubgoal(UInt64 parentPlotFragmentId, UInt64 subgoalId, StoryData world) : base(parentPlotFragmentId, world) { _subGoalId = subgoalId; _parametersToPass = new List <Parameter>(); AuthorGoal subGoal = world.findAuthorGoalById(subgoalId); if (subGoal != null) { List <Parameter> parameters = subGoal.Parameters; foreach (Parameter param in parameters) { // Add all parameters from the subgoal, which will later be filled in // with literals or variables _parametersToPass.Add(new Parameter(param.Name, param.Type, false, world)); } } }
public static AuthorGoal findAuthorGoalById(UInt64 id) { return(_storyWorld.findAuthorGoalById(id)); }
public void checkAndUpdateDependencesAsInteraction(Interaction parentInteraction, List<Trait> previouslyBoundVars, StoryData world) { AuthorGoal goalToPursue = world.findAuthorGoalById(_subGoalId); if (goalToPursue == null) { //clear out parameter list _parametersToPass.Clear(); throw new Exception("Interaction \"" + parentInteraction.Title + "\" refers to an Author Goal which does not exist."); } if (goalToPursue.PlotFragments.Count == 0) { throw new Exception("Interaction \"" + parentInteraction.Title + "\" refers to an Author Goal which has no child plot fragments that fulfill it." + "\nAll Interactions must have at least one Plot Fragment associated with the goal they pursue before generation can begin."); } bool dataUpdated = syncParametersWithSubgoal(); if (dataUpdated) { throw new Exception("Interaction \"" + parentInteraction.Title + "\" refers to an Author Goal that has had its parameters changed.\n" + "Wide Ruled has corrected the changes, but you should look at the Interaction to make sure the newly updated parameters have the correct value."); } }
public override 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 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 buttonGenerate_Click(object sender, RoutedEventArgs e) { if (_currentStoryData.AuthorGoals.Count == 0) { Utilities.MakeErrorDialog("Your story needs at least one Author Goal.", this); return; } if (_currentStoryData.findAuthorGoalById(_currentStoryData.StartGoalId) == null) { Utilities.MakeErrorDialog("One of your Author Goals must be selected as the start goal. You can modify this setting in the Author Goal editor window.", this); return; } if (_currentStoryData.findAuthorGoalById(_currentStoryData.StartGoalId).Parameters.Count > 0) { Utilities.MakeErrorDialog("Your selected start goal has parameters. Please select a start goal with no parameters, or remove these parameters from the start goal.", this); return; } if (_currentStoryData.findAuthorGoalById(_currentStoryData.StartGoalId).PlotFragments.Count == 0) { Utilities.MakeErrorDialog("Your Start Goal has no associated Plot Fragments that fulfill it. " + "All goals which are used during story creation must have at least one Plot Fragment associated with them before generation can begin.", this); return; } //Author goal and plot fragment checks string goalName = ""; try { foreach (AuthorGoal goal in _currentStoryData.AuthorGoals) { goalName = goal.Name; goal.checkAndUpdateDependences(new List <Trait>(), _currentStoryData); } } catch (Exception authGoalException) { Utilities.MakeErrorDialog("Error in Author Goal \"" + goalName + "\": " + authGoalException.Message, this); return; } //Interaction checks string interactionTitle = ""; try { foreach (Interaction interact in _currentStoryData.Interactions) { interactionTitle = interact.Title; interact.checkAndUpdateDependences(new List <Trait>(), _currentStoryData); } } catch (Exception interactExeption) { Utilities.MakeErrorDialog("Error in Interaction \"" + interactionTitle + "\": " + interactExeption.Message, this); return; } AblCommObject.Instance.reset(); try { AblCodeGenerator gen = new AblCodeGenerator(_currentStoryData); gen.BuildCode(); } catch (System.Exception buildError) { Utilities.MakeErrorDialog("Error during code generation: " + buildError.Message, this); return; } try { Thread newThread = new Thread(AblCommunicator.ExecuteStory); newThread.Start(); } catch (System.Exception genError) { Utilities.MakeErrorDialog("Error while generating story: " + genError.Message, this); return; } //Interactivity Windows WindowInteraction interactionWindow = new WindowInteraction(_currentStoryData.Interactions); WindowStoryOutputText outputWin = new WindowStoryOutputText(interactionWindow); outputWin.ShowDialog(); }
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."); } }