Beispiel #1
0
 protected virtual void refresh()
 {
     this.panel.clearElements();
     for (int i = 0; i < this.array.Length; i++)
     {
         Type type = this.array.GetValue(i).GetType();
         Sleek2TypeInspector sleek2TypeInspector = TypeInspectorRegistry.inspect(type);
         if (sleek2TypeInspector != null)
         {
             sleek2TypeInspector.inspect(new ObjectInspectableArray(this.parentInfo, this.rootInspector.instance as IDirtyable, this.array, this.arrayType, i, new TranslationReference("#SDG::Array_" + i), TranslationReference.invalid));
             this.panel.addElement(sleek2TypeInspector);
         }
         else
         {
             Sleek2InspectorFoldout sleek2InspectorFoldout = new Sleek2InspectorFoldout();
             sleek2InspectorFoldout.transform.anchorMin = new Vector2(0f, 1f);
             sleek2InspectorFoldout.transform.anchorMax = new Vector2(1f, 1f);
             sleek2InspectorFoldout.transform.pivot     = new Vector2(0.5f, 1f);
             sleek2InspectorFoldout.transform.sizeDelta = new Vector2(0f, (float)Sleek2Config.bodyHeight);
             sleek2InspectorFoldout.label.translation   = new TranslatedTextFallback('[' + i.ToString() + ']');
             sleek2InspectorFoldout.label.translation.format();
             this.panel.addElement(sleek2InspectorFoldout);
             this.rootInspector.reflect(new ObjectInspectableArray(this.parentInfo, this.rootInspector.instance as IDirtyable, this.array, this.arrayType, i, new TranslationReference("#SDG::Array_" + i), TranslationReference.invalid), this.array.GetValue(i), sleek2InspectorFoldout.contents);
         }
     }
 }
Beispiel #2
0
 protected void updateTypeInspectors(float width, float scaleFactor, Sleek2Element container)
 {
     foreach (Sleek2Element sleek2Element in container.elements)
     {
         if (sleek2Element is Sleek2TypeInspector)
         {
             Sleek2TypeInspector sleek2TypeInspector = sleek2Element as Sleek2TypeInspector;
             float num   = (sleek2TypeInspector.transform.position.x - this.kvContainer.transform.position.x) / scaleFactor;
             float value = (width - num) / sleek2TypeInspector.transform.rect.size.x;
             sleek2TypeInspector.split(value);
             sleek2TypeInspector.refresh();
             sleek2TypeInspector.inspectable.validate();
         }
         this.updateTypeInspectors(width, scaleFactor, sleek2Element);
     }
 }
Beispiel #3
0
 // Token: 0x060011B4 RID: 4532 RVA: 0x00072C74 File Offset: 0x00071074
 protected virtual void refresh()
 {
     this.panel.clearElements();
     for (int i = 0; i < this.list.Count; i++)
     {
         Type type = this.list[i].GetType();
         Sleek2TypeInspector sleek2TypeInspector = TypeInspectorRegistry.inspect(type);
         if (sleek2TypeInspector != null)
         {
             sleek2TypeInspector.inspect(new ObjectInspectableList(this.parentInfo, this.rootInspector.instance as IDirtyable, this.list, this.listType, i, new TranslationReference("#SDG::List_" + i), TranslationReference.invalid));
             this.panel.addElement(sleek2TypeInspector);
         }
         else
         {
             object obj = this.list[i];
             Sleek2InspectorFoldoutList sleek2InspectorFoldoutList = new Sleek2InspectorFoldoutList(i);
             sleek2InspectorFoldoutList.transform.anchorMin = new Vector2(0f, 1f);
             sleek2InspectorFoldoutList.transform.anchorMax = new Vector2(1f, 1f);
             sleek2InspectorFoldoutList.transform.pivot     = new Vector2(0.5f, 1f);
             sleek2InspectorFoldoutList.transform.sizeDelta = new Vector2(0f, (float)Sleek2Config.bodyHeight);
             if (obj is IInspectableListElement)
             {
                 sleek2InspectorFoldoutList.name = ((IInspectableListElement)obj).inspectableListIndexInternalName;
                 sleek2InspectorFoldoutList.label.translation = new TranslatedText(((IInspectableListElement)obj).inspectableListIndexDisplayName);
             }
             else
             {
                 sleek2InspectorFoldoutList.label.translation = new TranslatedTextFallback('[' + i.ToString() + ']');
             }
             sleek2InspectorFoldoutList.label.translation.format();
             sleek2InspectorFoldoutList.removeButton.clicked += this.handleRemoveButtonClicked;
             this.panel.addElement(sleek2InspectorFoldoutList);
             this.rootInspector.reflect(new ObjectInspectableList(this.parentInfo, this.rootInspector.instance as IDirtyable, this.list, this.listType, i, new TranslationReference("#SDG::List_" + i), TranslationReference.invalid), obj, sleek2InspectorFoldoutList.contents);
             if (this.collapseFoldoutsByDefault)
             {
                 sleek2InspectorFoldoutList.isOpen = false;
             }
         }
     }
 }
Beispiel #4
0
        public void reflect(ObjectInspectableInfo parent, object instance, Sleek2Element panel)
        {
            if (instance == null)
            {
                panel.addElement(new Sleek2Label
                {
                    transform =
                    {
                        anchorMin = new Vector2(0f, 1f),
                        anchorMax = new Vector2(1f, 1f),
                        pivot     = new Vector2(0f, 1f),
                        sizeDelta = new Vector2(0f, 30f)
                    },
                    textComponent =
                    {
                        text = "null"
                    }
                });
                return;
            }
            Type type = instance.GetType();

            if (type.IsArray)
            {
                Array newArray               = instance as Array;
                Type  elementType            = type.GetElementType();
                Sleek2InspectorArray element = new Sleek2InspectorArray(this, parent, newArray, elementType);
                panel.addElement(element);
            }
            else if (type.IsGenericType && typeof(IList).IsAssignableFrom(type))
            {
                IList               newList        = instance as IList;
                Type                newListType    = type.GetGenericArguments()[0];
                IInspectableList    newInspectable = instance as IInspectableList;
                Sleek2InspectorList element2       = new Sleek2InspectorList(this, parent, newList, newListType, newInspectable);
                panel.addElement(element2);
            }
            foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.Instance | BindingFlags.Public))
            {
                object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(InspectableAttribute), false);
                if (customAttributes.Length > 0)
                {
                    InspectableAttribute inspectableAttribute = customAttributes[0] as InspectableAttribute;
                    Sleek2TypeInspector  sleek2TypeInspector  = TypeInspectorRegistry.inspect(fieldInfo.FieldType);
                    if (sleek2TypeInspector != null)
                    {
                        sleek2TypeInspector.inspect(new ObjectInspectableField(parent, fieldInfo, this.instance as IDirtyable, instance, inspectableAttribute.name, inspectableAttribute.tooltip));
                        panel.addElement(sleek2TypeInspector);
                    }
                    else
                    {
                        Sleek2InspectorFoldout sleek2InspectorFoldout = new Sleek2InspectorFoldout();
                        sleek2InspectorFoldout.transform.anchorMin = new Vector2(0f, 1f);
                        sleek2InspectorFoldout.transform.anchorMax = new Vector2(1f, 1f);
                        sleek2InspectorFoldout.transform.pivot     = new Vector2(0.5f, 1f);
                        sleek2InspectorFoldout.transform.sizeDelta = new Vector2(0f, (float)Sleek2Config.bodyHeight);
                        sleek2InspectorFoldout.label.translation   = new TranslatedText(inspectableAttribute.name);
                        sleek2InspectorFoldout.label.translation.format();
                        sleek2InspectorFoldout.label.tooltip = new TranslatedText(inspectableAttribute.tooltip);
                        sleek2InspectorFoldout.label.tooltip.format();
                        panel.addElement(sleek2InspectorFoldout);
                        this.reflect(new ObjectInspectableField(parent, fieldInfo, this.instance as IDirtyable, instance, TranslationReference.invalid, TranslationReference.invalid), fieldInfo.GetValue(instance), sleek2InspectorFoldout.contents);
                        if (this.collapseFoldoutsByDefault)
                        {
                            sleek2InspectorFoldout.isOpen = false;
                        }
                    }
                }
            }
            foreach (PropertyInfo propertyInfo in type.GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                object[] customAttributes2 = propertyInfo.GetCustomAttributes(typeof(InspectableAttribute), false);
                if (customAttributes2.Length > 0)
                {
                    InspectableAttribute inspectableAttribute2 = customAttributes2[0] as InspectableAttribute;
                    Sleek2TypeInspector  sleek2TypeInspector2  = TypeInspectorRegistry.inspect(propertyInfo.PropertyType);
                    if (sleek2TypeInspector2 != null)
                    {
                        sleek2TypeInspector2.inspect(new ObjectInspectableProperty(parent, propertyInfo, this.instance as IDirtyable, instance, inspectableAttribute2.name, inspectableAttribute2.tooltip));
                        panel.addElement(sleek2TypeInspector2);
                    }
                    else
                    {
                        Sleek2InspectorFoldout sleek2InspectorFoldout2 = new Sleek2InspectorFoldout();
                        sleek2InspectorFoldout2.transform.anchorMin = new Vector2(0f, 1f);
                        sleek2InspectorFoldout2.transform.anchorMax = new Vector2(1f, 1f);
                        sleek2InspectorFoldout2.transform.pivot     = new Vector2(0.5f, 1f);
                        sleek2InspectorFoldout2.transform.sizeDelta = new Vector2(0f, (float)Sleek2Config.bodyHeight);
                        sleek2InspectorFoldout2.label.translation   = new TranslatedText(inspectableAttribute2.name);
                        sleek2InspectorFoldout2.label.translation.format();
                        sleek2InspectorFoldout2.label.tooltip = new TranslatedText(inspectableAttribute2.tooltip);
                        sleek2InspectorFoldout2.label.tooltip.format();
                        panel.addElement(sleek2InspectorFoldout2);
                        this.reflect(new ObjectInspectableProperty(parent, propertyInfo, this.instance as IDirtyable, instance, TranslationReference.invalid, TranslationReference.invalid), propertyInfo.GetValue(instance, null), sleek2InspectorFoldout2.contents);
                        if (this.collapseFoldoutsByDefault)
                        {
                            sleek2InspectorFoldout2.isOpen = false;
                        }
                    }
                }
            }
        }