コード例 #1
0
ファイル: SmallXmlParser.cs プロジェクト: WaylandGod/UnitySVG
 private void Cleanup()
 {
     line    = 1;
     column  = 0;
     handler = null;
     reader  = null;
     elementNames.Clear();
     attributes.Clear();
     buffer.Length = 0;
 }
コード例 #2
0
        internal void Reset()
        {
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            foreach (string strAttribute in AttributeStrings)
            {
                CharacterAttrib objAttribute;
                switch (CharacterAttrib.ConvertToAttributeCategory(strAttribute))
                {
                case CharacterAttrib.AttributeCategory.Special:
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Special);
                    SpecialAttributeList.Add(objAttribute);
                    break;

                case CharacterAttrib.AttributeCategory.Standard:
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                    AttributeList.Add(objAttribute);
                    break;
                }
            }
            BuildBindingList();
        }
コード例 #3
0
 public void UnbindAttributeSection()
 {
     _dicBindings.Clear();
     foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
     {
         objAttribute.UnbindAttribute();
     }
     AttributeList.Clear();
     SpecialAttributeList.Clear();
 }
コード例 #4
0
        public void ClearTempAttributes()
        {
            for (int i = 0; i < AttributeList.Count; i++)
            {
                Attribute tempAttribute = AttributeList[i];
                database.Table <Attribute>().Delete(x => x.Id == tempAttribute.Id);
            }

            AttributeList.Clear();
        }
コード例 #5
0
        public void DeleteTypeCommandExecute()
        {
            DialogResult flag = MessageBox.Show("Do you want to delete this xml setting from Setting File?",
                                                "Setting File Change Confirm",
                                                MessageBoxButtons.YesNo,
                                                MessageBoxIcon.Exclamation);

            if (flag == DialogResult.Yes)
            {
                IXmlSetting currentXmlSetting = m_CurrentSettingCollection.GetSetting(SelectType);
                m_CurrentSettingCollection.RemoveSetting(currentXmlSetting);
                _ea.GetEvent <CollectionEvent>().Publish(m_CurrentSettingCollection);
                XmlTypeList = null;
                XmlTypeList = new ObservableCollection <string>(m_CurrentSettingCollection.GetAllSettingTypes());
                SelectType  = null;
                AttributeList.Clear();
            }
        }
コード例 #6
0
		internal void Reset()
		{
			AttributeList.Clear();
			SpecialAttributeList.Clear();
			foreach (string strAttribute in AttributeStrings)
			{
				CharacterAttrib att = new CharacterAttrib(_character, strAttribute);
				switch (att.ConvertToAttributeCategory(att.Abbrev))
				{
					case CharacterAttrib.AttributeCategory.Special:
						SpecialAttributeList.Add(att);
						break;
					case CharacterAttrib.AttributeCategory.Standard:
						AttributeList.Add(att);
						break;
				}
			}
			BuildBindingList();
		}
コード例 #7
0
        private void BindAttributes()
        {
            AttributeList.Clear();

            var attributes = new List <NameValue>();

            foreach (string keyAttributeId in GetUserPreference("Rock.KeyAttributes").SplitDelimitedValues())
            {
                int attributeId = 0;
                if (Int32.TryParse(keyAttributeId, out attributeId))
                {
                    var attribute = Rock.Web.Cache.AttributeCache.Read(attributeId);
                    if (attribute != null && attribute.IsAuthorized("View", CurrentPerson))
                    {
                        AttributeList.Add(attribute.Id);
                    }
                }
            }

            CreateControls(true);
        }
コード例 #8
0
        public void LoadFromHeroLab(XmlNode xmlStatBlockBaseNode)
        {
            Timekeeper.Start("load_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument objXmlDocument  = XmlManager.Load(_objCharacter.IsCritter ? "critters.xml" : "metatypes.xml");
            XmlNode     xmlMetatypeNode = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            XmlNode     xmlCharNode     = xmlMetatypeNode?.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]") ?? xmlMetatypeNode;
            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            XmlNode xmlCharNodeAnimalForm = _objCharacter.MetatypeCategory == "Shapeshifter" && _objCharacter.Created ? xmlMetatypeNode : null;

            foreach (string strAttribute in AttributeStrings)
            {
                // First, remake the attribute
                CharacterAttrib objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                {
                case CharacterAttrib.AttributeCategory.Special:
                    SpecialAttributeList.Add(objAttribute);
                    break;

                case CharacterAttrib.AttributeCategory.Standard:
                    AttributeList.Add(objAttribute);
                    break;
                }
                if (xmlCharNodeAnimalForm != null)
                {
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Shapeshifter);
                    objAttribute = RemakeAttribute(objAttribute, xmlCharNodeAnimalForm);
                    switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(objAttribute);
                        break;
                    }
                }

                // Then load in attribute karma levels (we'll adjust these later if the character is in Create mode)
                if (strAttribute == "ESS") // Not Essence though, this will get modified automatically instead of having its value set to the one HeroLab displays
                {
                    continue;
                }
                XmlNode xmlHeroLabAttributeNode = xmlStatBlockBaseNode.SelectSingleNode("attributes/attribute[@name = \"" + GetAttributeEnglishName(strAttribute) + "\"]");
                XmlNode xmlAttributeBaseNode    = xmlHeroLabAttributeNode?.SelectSingleNode("@base");
                if (xmlAttributeBaseNode != null &&
                    int.TryParse(xmlAttributeBaseNode.InnerText, out int intHeroLabAttributeBaseValue))
                {
                    int intAttributeMinimumValue = GetAttributeByName(strAttribute).MetatypeMinimum;
                    if (intHeroLabAttributeBaseValue != intAttributeMinimumValue)
                    {
                        objAttribute.Karma = intHeroLabAttributeBaseValue - intAttributeMinimumValue;
                    }
                }
            }

            if (!_objCharacter.Created && _objCharacter.BuildMethodHasSkillPoints)
            {
                // Allocate Attribute Points
                int             intAttributePointCount = _objCharacter.TotalAttributes;
                CharacterAttrib objAttributeToPutPointsInto;
                // First loop through attributes where costs can be 100% covered with points
                do
                {
                    objAttributeToPutPointsInto = null;
                    int intAttributeToPutPointsIntoTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in AttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null || (objLoopAttribute.Karma <= intAttributePointCount &&
                                                                    (intLoopTotalKarmaCost > intAttributeToPutPointsIntoTotalKarmaCost ||
                                                                     (intLoopTotalKarmaCost == intAttributeToPutPointsIntoTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intAttributeToPutPointsIntoTotalKarmaCost = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base  = objAttributeToPutPointsInto.Karma;
                        intAttributePointCount           -= objAttributeToPutPointsInto.Karma;
                        objAttributeToPutPointsInto.Karma = 0;
                    }
                } while (objAttributeToPutPointsInto != null && intAttributePointCount > 0);

                // If any points left over, then put them all into the attribute with the highest karma cost
                if (intAttributePointCount > 0 && AttributeList.Any(x => x.Karma != 0))
                {
                    int intHighestTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in AttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null ||
                            intLoopTotalKarmaCost > intHighestTotalKarmaCost ||
                            (intLoopTotalKarmaCost == intHighestTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intHighestTotalKarmaCost    = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base   = intAttributePointCount;
                        objAttributeToPutPointsInto.Karma -= intAttributePointCount;
                    }
                }

                // Allocate Special Attribute Points
                intAttributePointCount = _objCharacter.TotalSpecial;
                // First loop through attributes where costs can be 100% covered with points
                do
                {
                    objAttributeToPutPointsInto = null;
                    int intAttributeToPutPointsIntoTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in SpecialAttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null || (objLoopAttribute.Karma <= intAttributePointCount &&
                                                                    (intLoopTotalKarmaCost > intAttributeToPutPointsIntoTotalKarmaCost ||
                                                                     (intLoopTotalKarmaCost == intAttributeToPutPointsIntoTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intAttributeToPutPointsIntoTotalKarmaCost = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base  = objAttributeToPutPointsInto.Karma;
                        intAttributePointCount           -= objAttributeToPutPointsInto.Karma;
                        objAttributeToPutPointsInto.Karma = 0;
                    }
                } while (objAttributeToPutPointsInto != null);

                // If any points left over, then put them all into the attribute with the highest karma cost
                if (intAttributePointCount > 0 && SpecialAttributeList.Any(x => x.Karma != 0))
                {
                    int intHighestTotalKarmaCost = 0;
                    foreach (CharacterAttrib objLoopAttribute in SpecialAttributeList)
                    {
                        if (objLoopAttribute.Karma == 0)
                        {
                            continue;
                        }
                        // Put points into the attribute with the highest total karma cost.
                        // In case of ties, pick the one that would need more points to cover it (the other one will hopefully get picked up at a later cycle)
                        int intLoopTotalKarmaCost = objLoopAttribute.TotalKarmaCost;
                        if (objAttributeToPutPointsInto == null ||
                            intLoopTotalKarmaCost > intHighestTotalKarmaCost ||
                            (intLoopTotalKarmaCost == intHighestTotalKarmaCost && objLoopAttribute.Karma > objAttributeToPutPointsInto.Karma))
                        {
                            objAttributeToPutPointsInto = objLoopAttribute;
                            intHighestTotalKarmaCost    = intLoopTotalKarmaCost;
                        }
                    }

                    if (objAttributeToPutPointsInto != null)
                    {
                        objAttributeToPutPointsInto.Base   = intAttributePointCount;
                        objAttributeToPutPointsInto.Karma -= intAttributePointCount;
                    }
                }
            }
            ResetBindings();
            _objCharacter.RefreshAttributeBindings();
            Timekeeper.Finish("load_char_attrib");
        }
コード例 #9
0
        public void Load(XmlNode xmlSavedCharacterNode)
        {
            Timekeeper.Start("load_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument objXmlDocument  = XmlManager.Load(_objCharacter.IsCritter ? "critters.xml" : "metatypes.xml");
            XmlNode     xmlMetatypeNode = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            XmlNode     xmlCharNode     = xmlMetatypeNode?.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]") ?? xmlMetatypeNode;
            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            XmlNode xmlCharNodeAnimalForm = _objCharacter.MetatypeCategory == "Shapeshifter" && _objCharacter.Created ? xmlMetatypeNode : null;

            foreach (string strAttribute in AttributeStrings)
            {
                XmlNodeList lstAttributeNodes = xmlSavedCharacterNode.SelectNodes("attributes/attribute[name = \"" + strAttribute + "\"]");
                // Couldn't find the appopriate attribute in the loaded file, so regenerate it from scratch.
                if (lstAttributeNodes == null || lstAttributeNodes.Count == 0 || xmlCharNodeAnimalForm != null && _objCharacter.LastSavedVersion < new Version("5.200.25"))
                {
                    CharacterAttrib objAttribute;
                    switch (CharacterAttrib.ConvertToAttributeCategory(strAttribute))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Special);
                        objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                        objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                        AttributeList.Add(objAttribute);
                        break;
                    }

                    if (xmlCharNodeAnimalForm == null)
                    {
                        continue;
                    }
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Shapeshifter);
                    objAttribute = RemakeAttribute(objAttribute, xmlCharNodeAnimalForm);
                    switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(objAttribute);
                        break;
                    }
                }
                else
                {
                    foreach (XmlNode xmlAttributeNode in lstAttributeNodes)
                    {
                        CharacterAttrib att = new CharacterAttrib(_objCharacter, strAttribute);
                        att.Load(xmlAttributeNode);
                        switch (CharacterAttrib.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
            }

            Attributes = new ObservableCollection <CharacterAttrib>
            {
                _objCharacter.BOD,
                _objCharacter.AGI,
                _objCharacter.REA,
                _objCharacter.STR,
                _objCharacter.CHA,
                _objCharacter.INT,
                _objCharacter.LOG,
                _objCharacter.WIL,
                _objCharacter.EDG
            };
            if (_objCharacter.MAGEnabled)
            {
                Attributes.Add(_objCharacter.MAG);
                if (_objCharacter.Options.MysAdeptSecondMAGAttribute && _objCharacter.IsMysticAdept)
                {
                    Attributes.Add(_objCharacter.MAGAdept);
                }
            }
            if (_objCharacter.RESEnabled)
            {
                Attributes.Add(_objCharacter.RES);
            }
            if (_objCharacter.DEPEnabled)
            {
                Attributes.Add(_objCharacter.DEP);
            }
            ResetBindings();
            _objCharacter.RefreshAttributeBindings();
            Timekeeper.Finish("load_char_attrib");
        }
コード例 #10
0
        public void Create(XmlNode charNode, int intValue, int intMinModifier = 0, int intMaxModifier = 0)
        {
            Timekeeper.Start("create_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();

            foreach (string strAttribute in AttributeStrings)
            {
                CharacterAttrib objAttribute;
                switch (CharacterAttrib.ConvertToAttributeCategory(strAttribute))
                {
                case CharacterAttrib.AttributeCategory.Special:
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Special);
                    SpecialAttributeList.Add(objAttribute);
                    break;

                case CharacterAttrib.AttributeCategory.Standard:
                    objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                    AttributeList.Add(objAttribute);
                    break;
                }
            }

            _objCharacter.BOD.AssignLimits(CommonFunctions.ExpressionToString(charNode["bodmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["bodmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["bodaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.AGI.AssignLimits(CommonFunctions.ExpressionToString(charNode["agimin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["agimax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["agiaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.REA.AssignLimits(CommonFunctions.ExpressionToString(charNode["reamin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["reamax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["reaaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.STR.AssignLimits(CommonFunctions.ExpressionToString(charNode["strmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["strmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["straug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.CHA.AssignLimits(CommonFunctions.ExpressionToString(charNode["chamin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["chamax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["chaaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.INT.AssignLimits(CommonFunctions.ExpressionToString(charNode["intmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["intmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["intaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.LOG.AssignLimits(CommonFunctions.ExpressionToString(charNode["logmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["logmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["logaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.WIL.AssignLimits(CommonFunctions.ExpressionToString(charNode["wilmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["wilmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["wilaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.MAG.AssignLimits(CommonFunctions.ExpressionToString(charNode["magmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["magmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["magaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.RES.AssignLimits(CommonFunctions.ExpressionToString(charNode["resmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["resmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["resaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.EDG.AssignLimits(CommonFunctions.ExpressionToString(charNode["edgmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["edgmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["edgaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.DEP.AssignLimits(CommonFunctions.ExpressionToString(charNode["depmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["depmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["depaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.MAGAdept.AssignLimits(CommonFunctions.ExpressionToString(charNode["magmin"]?.InnerText, intValue, intMinModifier), CommonFunctions.ExpressionToString(charNode["magmax"]?.InnerText, intValue, intMaxModifier), CommonFunctions.ExpressionToString(charNode["magaug"]?.InnerText, intValue, intMaxModifier));
            _objCharacter.ESS.AssignLimits(CommonFunctions.ExpressionToString(charNode["essmin"]?.InnerText, intValue, 0), CommonFunctions.ExpressionToString(charNode["essmax"]?.InnerText, intValue, 0), CommonFunctions.ExpressionToString(charNode["essaug"]?.InnerText, intValue, 0));

            Attributes = new ObservableCollection <CharacterAttrib>
            {
                _objCharacter.BOD,
                _objCharacter.AGI,
                _objCharacter.REA,
                _objCharacter.STR,
                _objCharacter.CHA,
                _objCharacter.INT,
                _objCharacter.LOG,
                _objCharacter.WIL,
                _objCharacter.EDG
            };
            if (_objCharacter.MAGEnabled)
            {
                Attributes.Add(_objCharacter.MAG);
                if (_objCharacter.Options.MysAdeptSecondMAGAttribute && _objCharacter.IsMysticAdept)
                {
                    Attributes.Add(_objCharacter.MAGAdept);
                }
            }
            if (_objCharacter.RESEnabled)
            {
                Attributes.Add(_objCharacter.RES);
            }
            if (_objCharacter.DEPEnabled)
            {
                Attributes.Add(_objCharacter.DEP);
            }
            ResetBindings();
            _objCharacter.RefreshAttributeBindings();
            Timekeeper.Finish("create_char_attrib");
        }
コード例 #11
0
 /// <summary>
 /// Clear Attribute
 /// </summary>
 public void ClearAttribute()
 {
     AttributeRootMap.Clear();
     AttributeList.Clear();
     AttributeListMap.Clear();
 }
コード例 #12
0
        public string SetConditions()
        {
            string ErrorMsg = null;

            if (JobEnabled.Checked)
            {
                JobList.Clear();
                for (int i = 0; i <= (JobListBox.Items.Count - 1); i++)
                {
                    if (JobListBox.GetItemChecked(i))
                    {
                        JobList.Add(JobListBox.Items[i].ToString());
                    }
                }
                if (JobList.Count != 0)
                {
                    if (OneJobOnly.Checked)
                    {
                        job = Convert.ToString((string)JobList[random.Next(0, JobList.Count)]);
                    }
                    if (JobList.Count < 4 && JobExistFalse.Checked)
                    {
                        Error     = true;
                        ErrorMsg += ("職業を被らせない設定は選択している職業数が4つ以上である必要があります。\n");
                    }
                }
                else
                {
                    Error     = true;
                    ErrorMsg += ("職業が選択されていません。\n");
                }
            }
            if (TypeEnabled.Checked)
            {
                TypeList.Clear();
                for (int i = 0; i <= (TypeListBox.Items.Count - 1); i++)
                {
                    if (TypeListBox.GetItemChecked(i))
                    {
                        TypeList.Add(TypeListBox.Items[i].ToString());
                    }
                }
                if (TypeList.Count != 0)
                {
                    if (OneTypeOnly.Checked)
                    {
                        type = Convert.ToString((string)TypeList[random.Next(0, TypeList.Count)]);
                    }
                    if (TypeList.Count < 4 && TypeExistFalse.Checked)
                    {
                        Error     = true;
                        ErrorMsg += ("タイプを被らせない設定は選択しているタイプ数が4つ以上である必要があります。\n");
                    }
                }
                else
                {
                    Error     = true;
                    ErrorMsg += ("タイプが選択されていません。\n");
                }
            }
            if (RarityEnabled.Checked)
            {
                RareList.Clear();
                if (UseRarity.Checked)
                {
                    for (int i = 0; i <= (RarityListBox.Items.Count - 1); i++)
                    {
                        if (RarityListBox.GetItemChecked(i))
                        {
                            RareList.Add(RarityListBox.Items[i].ToString());
                        }
                    }
                    TRResult.Text = "";
                    if (RareList.Count == 0)
                    {
                        Error     = true;
                        ErrorMsg += ("レアリティが選択されていません。\n");
                    }
                }
                if (UseTotalRarity.Checked)
                {
                    TRResult.Text = "レアリティ合計値:" + random.Next((int)TRMinimum.Value, (int)TRMax.Value);
                }
            }
            if (RareTypeEnabled.Checked)
            {
                RareTypeList.Clear();
                for (int i = 0; i <= (RareTypeListBox.Items.Count - 1); i++)
                {
                    if (RareTypeListBox.GetItemChecked(i))
                    {
                        RareTypeList.Add(RareTypeListBox.Items[i].ToString());
                    }
                }
                if (RareTypeList.Count != 0)
                {
                    if (OneRareTypeOnly.Checked)
                    {
                        raretype = Convert.ToString((string)RareTypeList[random.Next(0, RareTypeList.Count)]);
                    }
                }
                else
                {
                    Error     = true;
                    ErrorMsg += ("種類が選択されていません。\n");
                }
            }
            if (AttributeEnabled.Checked)
            {
                AttributeList.Clear();
                for (int i = 0; i <= (AttributeListBox.Items.Count - 1); i++)
                {
                    if (AttributeListBox.GetItemChecked(i))
                    {
                        AttributeList.Add(AttributeListBox.Items[i].ToString());
                    }
                }
                if (AttributeList.Count != 0)
                {
                    attribute = Convert.ToString((string)AttributeList[random.Next(0, AttributeList.Count)]);
                }
                else
                {
                    Error     = true;
                    ErrorMsg += ("属性が選択されていません。\n");
                }
            }
            if (!JobEnabled.Checked && !TypeEnabled.Checked && !RarityEnabled.Checked && !RareTypeEnabled.Checked && !AttributeEnabled.Checked)
            {
                Error     = true;
                ErrorMsg += ("有効になっている条件がありません。");
            }
            return(ErrorMsg);
        }
コード例 #13
0
ファイル: AttributeListFixture.cs プロジェクト: BgRva/Blob1
        public void Clear_ClearsAll()
        {
            _Net = new BasicAdjList(Guid.NewGuid());
            // increase capacity
            _Net.CreateNode();
            _Net.CreateNode();
            _Mgr = new DataAttributeMgr(AttributeListMgrFixture.NODE_ATTRIB_LIST, _Net);

            AttributeList<string> list = new AttributeList<string>(_Mgr);
            list.Name = "Blah";

            Assert.AreEqual(_Net.NodeCount, list.Count, "list.Count should match expected");
            Assert.IsNotNull(list.Manager, "list.Manager should not be null");
            Assert.IsNotNull(list.Name, "list.Name should not be null");

            list.Clear();

            Assert.AreEqual(0, list.Count, "list.Count should match 0");
            Assert.IsNull(list.Manager, "list.Manager should not null");
            Assert.IsNull(list.Name, "list.Name should not null");
        }
コード例 #14
0
ファイル: AttributeSection.cs プロジェクト: PStucke/chummer5a
        public void Load(XmlDocument xmlDoc)
        {
            Timekeeper.Start("load_char_attrib");
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument    objXmlDocument = XmlManager.Load(_character.IsCritter ? "critters.xml" : "metatypes.xml");
            XPathNavigator nav            = objXmlDocument.CreateNavigator();
            XmlNode        objCharNode    = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _character.Metatype + "\"]/metavariants/metavariant[name = \"" + _character.Metavariant + "\"]")
                                            ?? objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _character.Metatype + "\"]");
            XmlNode objCharNodeAnimalForm = null;

            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            if (_character.MetatypeCategory == "Shapeshifter" && _character.Created)
            {
                objCharNodeAnimalForm = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _character.Metatype + "\"]");
            }
            foreach (string s in AttributeStrings)
            {
                XmlNodeList attNodeList = xmlDoc.SelectNodes("/character/attributes/attribute[name = \"" + s + "\"]");
                // Couldn't find the appopriate attribute in the loaded file, so regenerate it from scratch.
                if (attNodeList.Count == 0)
                {
                    CharacterAttrib att = new CharacterAttrib(_character, s);
                    att = RemakeAttribute(att, objCharNode, nav);
                    switch (att.ConvertToAttributeCategory(att.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(att);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(att);
                        break;
                    }
                    if (objCharNodeAnimalForm != null)
                    {
                        att = new CharacterAttrib(_character, s, CharacterAttrib.AttributeCategory.Shapeshifter);
                        att = RemakeAttribute(att, objCharNodeAnimalForm, nav);
                        switch (att.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
                else
                {
                    foreach (XmlNode attNode in attNodeList)
                    {
                        CharacterAttrib att = new CharacterAttrib(_character, s);
                        att.Load(attNode);
                        switch (att.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
            }
            ResetBindings();
            Timekeeper.Finish("load_char_attrib");
        }
コード例 #15
0
        public void Load(XmlNode xmlSavedCharacterNode)
        {
            Timekeeper.Start("load_char_attrib");
            foreach (CharacterAttrib objAttribute in AttributeList.Concat(SpecialAttributeList))
            {
                objAttribute.UnbindAttribute();
            }
            AttributeList.Clear();
            SpecialAttributeList.Clear();
            XmlDocument objXmlDocument  = XmlManager.Load(_objCharacter.IsCritter ? "critters.xml" : "metatypes.xml");
            XmlNode     xmlMetatypeNode = objXmlDocument.SelectSingleNode("/chummer/metatypes/metatype[name = \"" + _objCharacter.Metatype + "\"]");
            XmlNode     xmlCharNode     = xmlMetatypeNode?.SelectSingleNode("metavariants/metavariant[name = \"" + _objCharacter.Metavariant + "\"]") ?? xmlMetatypeNode;
            // We only want to remake attributes for shifters in career mode, because they only get their second set of attributes when exporting from create mode into career mode
            XmlNode xmlCharNodeAnimalForm = _objCharacter.MetatypeCategory == "Shapeshifter" && _objCharacter.Created ? xmlMetatypeNode : null;

            foreach (string strAttribute in AttributeStrings)
            {
                XmlNodeList lstAttributeNodes = xmlSavedCharacterNode.SelectNodes("attributes/attribute[name = \"" + strAttribute + "\"]");
                // Couldn't find the appopriate attribute in the loaded file, so regenerate it from scratch.
                if (lstAttributeNodes == null || lstAttributeNodes.Count == 0)
                {
                    CharacterAttrib objAttribute = new CharacterAttrib(_objCharacter, strAttribute);
                    objAttribute = RemakeAttribute(objAttribute, xmlCharNode);
                    switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                    {
                    case CharacterAttrib.AttributeCategory.Special:
                        SpecialAttributeList.Add(objAttribute);
                        break;

                    case CharacterAttrib.AttributeCategory.Standard:
                        AttributeList.Add(objAttribute);
                        break;
                    }
                    if (xmlCharNodeAnimalForm != null)
                    {
                        objAttribute = new CharacterAttrib(_objCharacter, strAttribute, CharacterAttrib.AttributeCategory.Shapeshifter);
                        objAttribute = RemakeAttribute(objAttribute, xmlCharNodeAnimalForm);
                        switch (CharacterAttrib.ConvertToAttributeCategory(objAttribute.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(objAttribute);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(objAttribute);
                            break;
                        }
                    }
                }
                else
                {
                    foreach (XmlNode xmlAttributeNode in lstAttributeNodes)
                    {
                        CharacterAttrib att = new CharacterAttrib(_objCharacter, strAttribute);
                        att.Load(xmlAttributeNode);
                        switch (CharacterAttrib.ConvertToAttributeCategory(att.Abbrev))
                        {
                        case CharacterAttrib.AttributeCategory.Special:
                            SpecialAttributeList.Add(att);
                            break;

                        case CharacterAttrib.AttributeCategory.Standard:
                            AttributeList.Add(att);
                            break;
                        }
                    }
                }
            }
            ResetBindings();
            Timekeeper.Finish("load_char_attrib");
        }
コード例 #16
0
 public void Clear()
 {
     fMessages.Clear();
     fEnemies.Clear();
 }