コード例 #1
0
 public RelationshipConstraint(TraitConstraint cons, StoryData world) :
     base(cons.ParentPlotFragmentId, cons.ParentPreconditionStatementId, cons.AllowedToSave, cons.MatchingEntityTypeId, world)
 {
     _constraintType  = cons.ConstraintType;
     _comparisonValue = (Parameter)cons.ComparisonValue.Clone();
     _saveAttribute   = cons.ContainsSavedVariable;
     _savedVariable   = (Trait)cons.SavedVariable.Clone();
 }
コード例 #2
0
 public RelationshipConstraint(TraitConstraint cons, StoryData world)
     : base(cons.ParentPlotFragmentId, cons.ParentPreconditionStatementId, cons.AllowedToSave, cons.MatchingEntityTypeId, world)
 {
     _constraintType = cons.ConstraintType;
     _comparisonValue = (Parameter)cons.ComparisonValue.Clone();
     _saveAttribute = cons.ContainsSavedVariable;
     _savedVariable = (Trait)cons.SavedVariable.Clone();
 }
コード例 #3
0
        private void btNew_Click(object sender, RoutedEventArgs e)
        {
            TraitConstraint newCons = null;

            saveData();

            if (_editingMode == 0) //characters
            {
                newCons = new TraitConstraint(_currentEntity.ParentPlotFragmentId,
                                              _currentEntity.Id,
                                              _currentEntity.ObjectExists,
                                              _currentStoryData.CharTypeId,
                                              _currentStoryData);

                List <Character> globalChars = Utilities.getGlobalCharacterList(_currentStoryData);
                newCons.ComparisonValue.Name = globalChars[0].Traits[0].Name;
                newCons.ComparisonValue.Type = globalChars[0].Traits[0].Type;
                newCons.SavedVariable.Type   = globalChars[0].Traits[0].Type;
            }
            else if (_editingMode == 1) //environments
            {
                newCons = new TraitConstraint(_currentEntity.ParentPlotFragmentId,
                                              _currentEntity.Id,
                                              _currentEntity.ObjectExists,
                                              _currentStoryData.EnvTypeId,
                                              _currentStoryData);
                List <Environment> globalEnv = Utilities.getGlobalEnvironmentList(_currentStoryData);
                newCons.ComparisonValue.Name = globalEnv[0].Traits[0].Name;
                newCons.ComparisonValue.Type = globalEnv[0].Traits[0].Type;
                newCons.SavedVariable.Type   = globalEnv[0].Traits[0].Type;
            }
            else
            {
                newCons = new TraitConstraint(_currentEntity.ParentPlotFragmentId,
                                              _currentEntity.Id,
                                              _currentEntity.ObjectExists,
                                              _ppType.Id,
                                              _currentStoryData);

                newCons.ComparisonValue.Name = _ppType.Traits[0].Name;
                newCons.ComparisonValue.Type = _ppType.Traits[0].Type;
                newCons.SavedVariable.Type   = _ppType.Traits[0].Type;
            }


            _currentEntity.Constraints.Add(newCons);



            clearHeaderElements();
            dataBindHeaderItems();

            constraintDataGrid.SelectedItem = _currentEntity.Constraints[_currentEntity.Constraints.Count - 1];
            constraintDataGrid_MouseUp(null, null);
        }
コード例 #4
0
        private void comboBoxTraitRelationship_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_currentlyDataBinding) return;

            if (comboBoxTraitRelationship.SelectedIndex < 0) { return; }

            //First check for no changes

            if (
                (_currentlySelectedConstraint is TraitConstraint) &&
                (comboBoxTraitRelationship.SelectedIndex == 0)
                )
            {
                return;
            }
            else if (
                (_currentlySelectedConstraint is RelationshipConstraint) &&
                (((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode == true) &&
                (comboBoxTraitRelationship.SelectedIndex == 1)
                )
            {
                return;
            }
            else if (
                (_currentlySelectedConstraint is RelationshipConstraint) &&
                (((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode == false) &&
                (comboBoxTraitRelationship.SelectedIndex == 2)
                )
            {
                return;
            }

               if(comboBoxTraitRelationship.SelectedIndex == 0) //Trait type constraint
               {
                if (_currentlySelectedConstraint is RelationshipConstraint)
                {
                    //convert relationship constraint to trait constraint
                    TraitConstraint newCons = new TraitConstraint((RelationshipConstraint)_currentlySelectedConstraint, _currentStoryData);
                    newCons.ComparisonValue.ValueIsBoundToVariable = false;

                    if(_editingMode == 0) //characters
                    {
                        List<Character> globalChars = Utilities.getGlobalCharacterList(_currentStoryData);
                        newCons.ComparisonValue.Name = globalChars[0].Traits[0].Name;
                        newCons.ComparisonValue.Type = globalChars[0].Traits[0].Type;
                        newCons.SavedVariable.Type = globalChars[0].Traits[0].Type;
                    }
                    else if(_editingMode == 1) //environments
                    {
                        List<Environment> globalEnv = Utilities.getGlobalEnvironmentList(_currentStoryData);
                        newCons.ComparisonValue.Name = globalEnv[0].Traits[0].Name;
                        newCons.ComparisonValue.Type = globalEnv[0].Traits[0].Type;
                        newCons.SavedVariable.Type = globalEnv[0].Traits[0].Type;
                    }
                    else
                    {
                        newCons.ComparisonValue.Name = _ppType.Traits[0].Name;
                        newCons.ComparisonValue.Type = _ppType.Traits[0].Type;
                        newCons.SavedVariable.Type = _ppType.Traits[0].Type;
                    }

                    // Replace constraint in the constraint list
                    _currentEntity.Constraints[
                        _currentEntity.Constraints.IndexOf(_currentlySelectedConstraint)]
                         = newCons;
                    clearDataElements();
                    dataBind();
                    constraintDataGrid.SelectedItem = newCons;
                    constraintDataGrid_MouseUp(null, null);

                }
               }
               else if ((comboBoxTraitRelationship.SelectedIndex == 1) || (comboBoxTraitRelationship.SelectedIndex == 2)) //Relationship type constraint
               {
               if (_currentlySelectedConstraint is TraitConstraint)
               {
                   //convert trait constraint to rel constraint
                    RelationshipConstraint newCons = new RelationshipConstraint((TraitConstraint)_currentlySelectedConstraint, _currentStoryData);
                    if(_editingMode == 0) //characters
                    {
                        List<Character> globalChars = Utilities.getGlobalCharacterList(_currentStoryData);
                        newCons.ComparisonValue.Name = globalChars[0].Relationships[0].Name;
                        newCons.ComparisonValue.ValueIsBoundToVariable = false;
                        if(comboBoxTraitRelationship.SelectedIndex == 1)
                        {
                            newCons.ComparisonValue.Type = TraitDataType.Text;
                            newCons.SavedVariable.Type = TraitDataType.Text;
                            newCons.TargetNameMode = true; // relationship target name

                        }
                        else
                        {
                            newCons.ComparisonValue.Type = TraitDataType.Number;
                            newCons.SavedVariable.Type = TraitDataType.Number;
                            newCons.TargetNameMode = false; // relationship strength
                        }
                    }
                    else if(_editingMode == 1) //environments
                    {
                        List<Environment> globalEnv = Utilities.getGlobalEnvironmentList(_currentStoryData);
                        newCons.ComparisonValue.Name = globalEnv[0].Relationships[0].Name;
                        newCons.ComparisonValue.ValueIsBoundToVariable = false;
                        if(comboBoxTraitRelationship.SelectedIndex == 1)
                        {
                            newCons.ComparisonValue.Type = TraitDataType.Text;
                            newCons.SavedVariable.Type = TraitDataType.Text;
                            newCons.TargetNameMode = true; // relationship target name

                        }
                        else
                        {

                            newCons.ComparisonValue.Type = TraitDataType.Number;
                            newCons.SavedVariable.Type = TraitDataType.Number;
                            newCons.TargetNameMode = false; // relationship strength
                        }
                    }

                    // Replace constraint in the constraint list
                    _currentEntity.Constraints[
                        _currentEntity.Constraints.IndexOf(_currentlySelectedConstraint)]
                         = newCons;
                    clearDataElements();
                    dataBind();
                    constraintDataGrid.SelectedItem = newCons;
                    constraintDataGrid_MouseUp(null, null);

               }
               else if (
                        ((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode &&
                        (comboBoxTraitRelationship.SelectedIndex == 2)
                        )
               {
                   //Convert relationship target name constraint to strength constraint
                   ((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode = false;
                   ((RelationshipConstraint)_currentlySelectedConstraint).ComparisonValue.Type = TraitDataType.Number;
                   ((RelationshipConstraint)_currentlySelectedConstraint).SavedVariable.Type = TraitDataType.Number;
                   ((RelationshipConstraint)_currentlySelectedConstraint).ComparisonValue.ValueIsBoundToVariable = false;
                   //((RelationshipConstraint)_currentlySelectedConstraint).ContainsSavedVariable = false;
                   //((RelationshipConstraint)_currentlySelectedConstraint).ConstraintType = ConstraintComparisonType.Equals;
                   //((RelationshipConstraint)_currentlySelectedConstraint).SavedVariable.Name = "";
                   clearDataElements();
                   dataBind();
                   constraintDataGrid.SelectedItem = _currentlySelectedConstraint;
                   constraintDataGrid_MouseUp(null, null);
               }
               else if (
                        ((!(((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode) )) &&
                        (comboBoxTraitRelationship.SelectedIndex == 1)
                        )
               {
                   //Convert relationship strength constraint to target name constraint
                   ((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode = true;
                   ((RelationshipConstraint)_currentlySelectedConstraint).ComparisonValue.Type = TraitDataType.Text;
                   ((RelationshipConstraint)_currentlySelectedConstraint).SavedVariable.Type = TraitDataType.Text;
                   //((RelationshipConstraint)_currentlySelectedConstraint).ContainsSavedVariable = false;
                   ((RelationshipConstraint)_currentlySelectedConstraint).ComparisonValue.ValueIsBoundToVariable = false;
                   //((RelationshipConstraint)_currentlySelectedConstraint).ConstraintType = ConstraintComparisonType.Equals;
                   //((RelationshipConstraint)_currentlySelectedConstraint).SavedVariable.Name = "";
                   clearDataElements();
                   dataBind();
                   constraintDataGrid.SelectedItem = _currentlySelectedConstraint;
                   constraintDataGrid_MouseUp(null, null);
               }

               }
        }
コード例 #5
0
        private void btNew_Click(object sender, RoutedEventArgs e)
        {
            TraitConstraint newCons = null;

            saveData();

            if(_editingMode == 0) //characters
            {
                newCons = new TraitConstraint(_currentEntity.ParentPlotFragmentId,
                    _currentEntity.Id,
                    _currentEntity.ObjectExists,
                    _currentStoryData.CharTypeId,
                    _currentStoryData);

                List<Character> globalChars = Utilities.getGlobalCharacterList(_currentStoryData);
                newCons.ComparisonValue.Name = globalChars[0].Traits[0].Name;
                newCons.ComparisonValue.Type = globalChars[0].Traits[0].Type;
                newCons.SavedVariable.Type = globalChars[0].Traits[0].Type;
            }
            else if(_editingMode == 1) //environments
            {
                newCons = new TraitConstraint(_currentEntity.ParentPlotFragmentId,
                    _currentEntity.Id,
                    _currentEntity.ObjectExists,
                    _currentStoryData.EnvTypeId,
                    _currentStoryData);
                List<Environment> globalEnv = Utilities.getGlobalEnvironmentList(_currentStoryData);
                newCons.ComparisonValue.Name = globalEnv[0].Traits[0].Name;
                newCons.ComparisonValue.Type = globalEnv[0].Traits[0].Type;
                newCons.SavedVariable.Type = globalEnv[0].Traits[0].Type;
            }
            else
            {

                newCons = new TraitConstraint(_currentEntity.ParentPlotFragmentId,
                    _currentEntity.Id,
                    _currentEntity.ObjectExists,
                    _ppType.Id,
                    _currentStoryData);

                newCons.ComparisonValue.Name = _ppType.Traits[0].Name;
                newCons.ComparisonValue.Type = _ppType.Traits[0].Type;
                newCons.SavedVariable.Type = _ppType.Traits[0].Type;
            }

            _currentEntity.Constraints.Add(newCons);

            clearHeaderElements();
            dataBindHeaderItems();

            constraintDataGrid.SelectedItem = _currentEntity.Constraints[_currentEntity.Constraints.Count - 1];
            constraintDataGrid_MouseUp(null, null);
        }
コード例 #6
0
        private void comboBoxTraitRelationship_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_currentlyDataBinding)
            {
                return;
            }

            if (comboBoxTraitRelationship.SelectedIndex < 0)
            {
                return;
            }


            //First check for no changes

            if (
                (_currentlySelectedConstraint is TraitConstraint) &&
                (comboBoxTraitRelationship.SelectedIndex == 0)
                )
            {
                return;
            }
            else if (
                (_currentlySelectedConstraint is RelationshipConstraint) &&
                (((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode == true) &&
                (comboBoxTraitRelationship.SelectedIndex == 1)
                )
            {
                return;
            }
            else if (
                (_currentlySelectedConstraint is RelationshipConstraint) &&
                (((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode == false) &&
                (comboBoxTraitRelationship.SelectedIndex == 2)
                )
            {
                return;
            }



            if (comboBoxTraitRelationship.SelectedIndex == 0) //Trait type constraint
            {
                if (_currentlySelectedConstraint is RelationshipConstraint)
                {
                    //convert relationship constraint to trait constraint
                    TraitConstraint newCons = new TraitConstraint((RelationshipConstraint)_currentlySelectedConstraint, _currentStoryData);
                    newCons.ComparisonValue.ValueIsBoundToVariable = false;

                    if (_editingMode == 0) //characters
                    {
                        List <Character> globalChars = Utilities.getGlobalCharacterList(_currentStoryData);
                        newCons.ComparisonValue.Name = globalChars[0].Traits[0].Name;
                        newCons.ComparisonValue.Type = globalChars[0].Traits[0].Type;
                        newCons.SavedVariable.Type   = globalChars[0].Traits[0].Type;
                    }
                    else if (_editingMode == 1) //environments
                    {
                        List <Environment> globalEnv = Utilities.getGlobalEnvironmentList(_currentStoryData);
                        newCons.ComparisonValue.Name = globalEnv[0].Traits[0].Name;
                        newCons.ComparisonValue.Type = globalEnv[0].Traits[0].Type;
                        newCons.SavedVariable.Type   = globalEnv[0].Traits[0].Type;
                    }
                    else
                    {
                        newCons.ComparisonValue.Name = _ppType.Traits[0].Name;
                        newCons.ComparisonValue.Type = _ppType.Traits[0].Type;
                        newCons.SavedVariable.Type   = _ppType.Traits[0].Type;
                    }

                    // Replace constraint in the constraint list
                    _currentEntity.Constraints[
                        _currentEntity.Constraints.IndexOf(_currentlySelectedConstraint)]
                        = newCons;
                    clearDataElements();
                    dataBind();
                    constraintDataGrid.SelectedItem = newCons;
                    constraintDataGrid_MouseUp(null, null);
                }
            }
            else if ((comboBoxTraitRelationship.SelectedIndex == 1) || (comboBoxTraitRelationship.SelectedIndex == 2)) //Relationship type constraint
            {
                if (_currentlySelectedConstraint is TraitConstraint)
                {
                    //convert trait constraint to rel constraint
                    RelationshipConstraint newCons = new RelationshipConstraint((TraitConstraint)_currentlySelectedConstraint, _currentStoryData);
                    if (_editingMode == 0) //characters
                    {
                        List <Character> globalChars = Utilities.getGlobalCharacterList(_currentStoryData);
                        newCons.ComparisonValue.Name = globalChars[0].Relationships[0].Name;
                        newCons.ComparisonValue.ValueIsBoundToVariable = false;
                        if (comboBoxTraitRelationship.SelectedIndex == 1)
                        {
                            newCons.ComparisonValue.Type = TraitDataType.Text;
                            newCons.SavedVariable.Type   = TraitDataType.Text;
                            newCons.TargetNameMode       = true; // relationship target name
                        }
                        else
                        {
                            newCons.ComparisonValue.Type = TraitDataType.Number;
                            newCons.SavedVariable.Type   = TraitDataType.Number;
                            newCons.TargetNameMode       = false; // relationship strength
                        }
                    }
                    else if (_editingMode == 1) //environments
                    {
                        List <Environment> globalEnv = Utilities.getGlobalEnvironmentList(_currentStoryData);
                        newCons.ComparisonValue.Name = globalEnv[0].Relationships[0].Name;
                        newCons.ComparisonValue.ValueIsBoundToVariable = false;
                        if (comboBoxTraitRelationship.SelectedIndex == 1)
                        {
                            newCons.ComparisonValue.Type = TraitDataType.Text;
                            newCons.SavedVariable.Type   = TraitDataType.Text;
                            newCons.TargetNameMode       = true; // relationship target name
                        }
                        else
                        {
                            newCons.ComparisonValue.Type = TraitDataType.Number;
                            newCons.SavedVariable.Type   = TraitDataType.Number;
                            newCons.TargetNameMode       = false; // relationship strength
                        }
                    }


                    // Replace constraint in the constraint list
                    _currentEntity.Constraints[
                        _currentEntity.Constraints.IndexOf(_currentlySelectedConstraint)]
                        = newCons;
                    clearDataElements();
                    dataBind();
                    constraintDataGrid.SelectedItem = newCons;
                    constraintDataGrid_MouseUp(null, null);
                }
                else if (
                    ((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode &&
                    (comboBoxTraitRelationship.SelectedIndex == 2)
                    )
                {
                    //Convert relationship target name constraint to strength constraint
                    ((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode       = false;
                    ((RelationshipConstraint)_currentlySelectedConstraint).ComparisonValue.Type = TraitDataType.Number;
                    ((RelationshipConstraint)_currentlySelectedConstraint).SavedVariable.Type   = TraitDataType.Number;
                    ((RelationshipConstraint)_currentlySelectedConstraint).ComparisonValue.ValueIsBoundToVariable = false;
                    //((RelationshipConstraint)_currentlySelectedConstraint).ContainsSavedVariable = false;
                    //((RelationshipConstraint)_currentlySelectedConstraint).ConstraintType = ConstraintComparisonType.Equals;
                    //((RelationshipConstraint)_currentlySelectedConstraint).SavedVariable.Name = "";
                    clearDataElements();
                    dataBind();
                    constraintDataGrid.SelectedItem = _currentlySelectedConstraint;
                    constraintDataGrid_MouseUp(null, null);
                }
                else if (
                    ((!(((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode))) &&
                    (comboBoxTraitRelationship.SelectedIndex == 1)
                    )
                {
                    //Convert relationship strength constraint to target name constraint
                    ((RelationshipConstraint)_currentlySelectedConstraint).TargetNameMode       = true;
                    ((RelationshipConstraint)_currentlySelectedConstraint).ComparisonValue.Type = TraitDataType.Text;
                    ((RelationshipConstraint)_currentlySelectedConstraint).SavedVariable.Type   = TraitDataType.Text;
                    //((RelationshipConstraint)_currentlySelectedConstraint).ContainsSavedVariable = false;
                    ((RelationshipConstraint)_currentlySelectedConstraint).ComparisonValue.ValueIsBoundToVariable = false;
                    //((RelationshipConstraint)_currentlySelectedConstraint).ConstraintType = ConstraintComparisonType.Equals;
                    //((RelationshipConstraint)_currentlySelectedConstraint).SavedVariable.Name = "";
                    clearDataElements();
                    dataBind();
                    constraintDataGrid.SelectedItem = _currentlySelectedConstraint;
                    constraintDataGrid_MouseUp(null, null);
                }
            }
        }