示例#1
0
 public ClassDataListItem(SaveDataEditorWindow editor, ClassData data)
 {
     this.Editor = editor;
     this.Data   = data;
     LoadProperties();
     UpdateText();
 }
示例#2
0
        private void AddClass()
        {
            ClassData sc = new ClassData();

            sc.Name       = "New";
            sc.Properties = new PropertyData[0];
            _ClassList.Items.Add(new ClassDataListItem(this, sc));
            _ClassList.SelectedIndex = _ClassList.Items.Count - 1;
            RebuildClasses();
        }
示例#3
0
        private static void CheckForErrors(ClassData cl)
        {
            if (string.IsNullOrEmpty(cl.Name))
            {
                Debug.LogError("There is a class with empty name.");
                _ErrorFound = true;
            }
            if (cl.Properties == null)
            {
                return;
            }
            foreach (var p in cl.Properties)
            {
                if (string.IsNullOrEmpty(p.Name))
                {
                    Debug.LogError("There is a property with empty name.");
                    _ErrorFound = true;
                }
                else
                {
                    int count = 0;
                    foreach (var item in cl.Properties)
                    {
                        if (item.Name == p.Name)
                        {
                            count++;
                        }
                    }
                    if (count > 1)
                    {
                        Debug.LogError(string.Format("There are {0} Property in Class {1} with same name ({2}).", count, cl.Name, p.Name));
                        _ErrorFound = true;
                    }
                }

                if (p.Type == PropertyType.Class)
                {
                    int count = 0;
                    foreach (var item in _SaveData.Classes)
                    {
                        if (item.Name == ((ClassPropertyData)p).ClassName)
                        {
                            count++;
                        }
                    }
                    if (count <= 0)
                    {
                        Debug.LogError(string.Format("The property {0} of class {1} has invalid ClassName.", p.Name, cl.Name));
                        _ErrorFound = true;
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// Read data from given element that loaded from file
        /// </summary>
        /// <param name="e">Xelement containing data</param>
        protected override void ReadAttributes(XmlElement e)
        {
            Namespace = e.GetAttributeValueAsString("Namespace", string.Empty);
            XmlElement classes = e["Classes"];

            if (classes != null)
            {
                int count = classes.GetAttributeValueAsInt("Count", 0);
                int i     = 0;
                this.Classes = new ClassData[count];
                foreach (var element in classes)
                {
                    ClassData c = new ClassData();
                    c.Load(element);
                    this.Classes[i++] = c;
                }
            }
            base.ReadAttributes(e);
        }