Exemple #1
0
        private void SelectType(int i)
        {
            selectedType = i;

            if (selectedType == -1)
            {
                SaveType("TypesWindowSelectedType", -1);
                return;
            }

            SaveType("TypesWindowSelectedType", selectedType);

            if (!recentTypes.Contains(i))
            {
                // If our recent type queue is full, remove an item before adding another.
                if (recentTypes.Count == recentTypeCount)
                {
                    recentTypes.RemoveAt(0);
                }
                recentTypes.Add(i);
                for (int j = 0; j < recentTypes.Count; j++)
                {
                    SaveType("TypesWindowRecentType" + j, recentTypes[j]);
                }
            }

            var type = types[selectedType].type;

            fields        = ES3Reflection.GetSerializableES3Fields(type);
            fieldSelected = new bool[fields.Length];

            var es3Type = ES3TypeMgr.GetES3Type(type);

            // If there's no ES3Type for this, no fields will be selected so we can exit early.
            if (es3Type == null)
            {
                return;
            }

            // Get fields and whether they're selected.
            var selectedFields     = new List <string>();
            var propertyAttributes = es3Type.GetType().GetCustomAttributes(typeof(ES3PropertiesAttribute), false);

            if (propertyAttributes.Length > 0)
            {
                selectedFields.AddRange(((ES3PropertiesAttribute)propertyAttributes[0]).properties);
            }

            fieldSelected = new bool[fields.Length];

            for (int j = 0; j < fields.Length; j++)
            {
                fieldSelected[j] = selectedFields.Contains(fields[j].Name);
            }
        }