private void btEditPrecond_Click(object sender, RoutedEventArgs e) { Object itemToEdit = precondDataGrid.SelectedItem; if ((itemToEdit == null) || !(itemToEdit is PreconditionStatement)) { return; } if (itemToEdit.GetType() == typeof(PreconditionStatementCharacter)) { Window newWin = new WindowPreconditionEditor(_currentEntity, (PreconditionStatementCharacter)itemToEdit, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(PreconditionStatementEnvironment)) { Window newWin = new WindowPreconditionEditor(_currentEntity, (PreconditionStatementEnvironment)itemToEdit, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } else if (itemToEdit.GetType() == typeof(PreconditionStatementPlotPoint)) { PreconditionStatementPlotPoint ppPrecond = (PreconditionStatementPlotPoint)itemToEdit; if (null == _currentStoryData.findPlotPointTypeById(ppPrecond.MatchTypeId)) { //Very bad - precondition statement has no associated type. The user //is not allowed to edit this, and must delete it Utilities.MakeErrorDialog("This Precondition Statement 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 WindowPreconditionEditor(_currentEntity, ppPrecond, _currentStoryData); newWin.Owner = this; newWin.ShowDialog(); } clearDataBindings(); 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 PreconditionStatementPlotPoint newClone = (PreconditionStatementPlotPoint)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); }
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(); }
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(); }