コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
        }