Example #1
0
 public override bool DrawCreateWizard(plyVar target)
 {
     this.targetVar     = target;
     this.targetHandler = (plyVar_Array)target.ValueHandler;
     if (plyVarEd_Array.menu == null)
     {
         List <plyVarEd> list = new List <plyVarEd>();
         foreach (plyVarEd value in plyVariablesEditor.editors.Values)
         {
             if (!((plyVarEdAttribute)value.nfo).UsesAdvancedEditor)
             {
                 list.Add(value);
             }
         }
         plyVarEd_Array.menu = new GenericMenu();
         for (int i = 0; i < list.Count; i++)
         {
             if (list[i].handleTypes.Count == 1)
             {
                 string   varTypeName = ((plyVarEdAttribute)list[i].nfo).VarTypeName;
                 MenuData userData    = new MenuData
                 {
                     varType  = ((plyVarEdAttribute)list[i].nfo).TargetType,
                     baseType = list[i].handleTypes[0]
                 };
                 plyVarEd_Array.menu.AddItem(new GUIContent(varTypeName), false, this.OnTypeSelected, userData);
             }
             else
             {
                 for (int j = 0; j < list[i].handleTypeNames.Length; j++)
                 {
                     string   text      = ((plyVarEdAttribute)list[i].nfo).VarTypeName + "/" + list[i].handleTypeNames[j].text;
                     MenuData userData2 = new MenuData
                     {
                         varType  = ((plyVarEdAttribute)list[i].nfo).TargetType,
                         baseType = list[i].handleTypes[j]
                     };
                     plyVarEd_Array.menu.AddItem(new GUIContent(text), false, this.OnTypeSelected, userData2);
                 }
             }
         }
     }
     if (GUILayout.Button(BloxEd.PrettyTypeName(this.targetHandler.baseType, false)))
     {
         plyVarEd_Array.menu.ShowAsContext();
     }
     return(this.targetHandler.baseType != null);
 }
Example #2
0
 private void DoDataProvider()
 {
     if (this.providerLabels == null)
     {
         base.Close();
         GUIUtility.ExitGUI();
     }
     else
     {
         if (this.isNewlyCreated)
         {
             EditorGUI.BeginChangeCheck();
             this.providerIdx = EditorGUILayout.Popup(DataBindingWindow.GC_Space, this.providerIdx, this.providerLabels);
             if (EditorGUI.EndChangeCheck())
             {
                 string ident = this.bind.dataprovider.ident;
                 DataProviderEd.DestroyDataprovider(this.bind.dataprovider);
                 this.providerEd        = DataProviderEd.factory.CreateEditor(this.providerLabels[this.providerIdx].text);
                 this.bind.dataprovider = DataProviderEd.CreateDataprovider(this.providerEd.nfo.TargetType, ident, this.isForSetter);
                 plyEdUtil.SetDirty(this.bindOwner);
             }
         }
         else
         {
             GUI.enabled = false;
             EditorGUILayout.Popup(DataBindingWindow.GC_Space, this.providerIdx, this.providerLabels);
             GUI.enabled = true;
         }
         DataBindingWindow.GC_Text.text = BloxEd.PrettyTypeName(this.bind.dataprovider.DataType(), !this.isForSetter);
         EditorGUILayout.LabelField(DataBindingWindow.GC_Space, DataBindingWindow.GC_Text);
         if (this.providerEd != null)
         {
             Rect rect = GUILayoutUtility.GetRect(0f, (float)(this.providerEd.EditorHeight(this.bind.dataprovider, this.isForSetter) + 10.0), GUILayout.ExpandWidth(true));
             rect.x      += 5f;
             rect.width  -= 10f;
             rect.y      += 10f;
             rect.height -= 10f;
             this.providerEd.DrawEditor(rect, this.bind.dataprovider, this.isForSetter);
             base.Repaint();
         }
     }
 }
Example #3
0
        private static string GetMemberName(MemberInfo mi)
        {
            if (mi == null)
            {
                return("");
            }
            ParameterInfo[] array = null;
            string          text  = mi.Name;

            if (mi.MemberType == MemberTypes.Method)
            {
                MethodInfo methodInfo = (MethodInfo)mi;
                array = methodInfo.GetParameters();
                text += BloxEd.ParametersNameSection(array);
                if (methodInfo.ReturnType != null && methodInfo.ReturnType != typeof(void))
                {
                    text = text + ": " + BloxEd.PrettyTypeName(methodInfo.ReturnType, true);
                }
            }
            else if (mi.MemberType == MemberTypes.Field)
            {
                FieldInfo fieldInfo = (FieldInfo)mi;
                text = text + ": " + BloxEd.PrettyTypeName(fieldInfo.FieldType, true);
            }
            else if (mi.MemberType == MemberTypes.Property)
            {
                PropertyInfo propertyInfo = (PropertyInfo)mi;
                text = text + ": " + BloxEd.PrettyTypeName(propertyInfo.PropertyType, true);
            }
            text = mi.ReflectedType.FullName.Replace('.', '/') + "/" + text;
            text = text.Replace('+', '.');
            if (string.IsNullOrEmpty(mi.ReflectedType.Namespace))
            {
                text = "Scripts/" + text;
            }
            return(text);
        }
Example #4
0
        public override string VarTypeName(plyVar target)
        {
            plyVar_Array plyVar_Array = (plyVar_Array)target.ValueHandler;

            return("Array<" + BloxEd.PrettyTypeName(plyVar_Array.baseType, false) + ">");
        }
Example #5
0
        protected override void Draw(Rect rect, DataProvider target, bool isSetter)
        {
            MemberBindProvider memberBindProvider = (MemberBindProvider)target;

            rect.height = EditorGUIUtility.singleLineHeight;
            if (MemberBindProviderEd.loader != null)
            {
                plyEdGUI.DrawSpinner(rect, MemberBindProviderEd.GC_Loading);
                if (Event.current.type == EventType.Repaint)
                {
                    MemberBindProviderEd.loader.DoUpdate();
                }
            }
            else
            {
                this.InitCurrBindables(memberBindProvider, isSetter);
                EditorGUIUtility.labelWidth = 65f;
                Rect       rect2 = rect;
                GUIContent label = isSetter ? MemberBindProviderEd.GC_SetMember : MemberBindProviderEd.GC_GetMember;
                if (memberBindProvider.member != null && memberBindProvider.member.MemberType == MemberTypes.Method)
                {
                    label = MemberBindProviderEd.GC_InvokeMember;
                }
                EditorGUI.BeginChangeCheck();
                this.memberBindIdx = EditorGUI.Popup(rect2, label, this.memberBindIdx, this.currBindableLabels);
                if (EditorGUI.EndChangeCheck())
                {
                    memberBindProvider.member         = this.currBindables[this.memberBindIdx].mi;
                    memberBindProvider.instanceMember = null;
                    if (memberBindProvider.valSetterSources.Length != 0)
                    {
                        memberBindProvider.valSetterSources = new DataBindingValueSource[0];
                    }
                    if (memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.Instance)
                    {
                        MemberBindProvider target2 = memberBindProvider;
                        BloxMemberInfo     member  = memberBindProvider.member;
                        this.InitSubBindables(target2, (member != null) ? member.ReflectedType : null);
                    }
                }
                if (memberBindProvider.member == null)
                {
                    if (memberBindProvider.instanceMember != null)
                    {
                        memberBindProvider.instanceMember = null;
                        GUI.changed = true;
                    }
                    if (memberBindProvider.valSetterSources.Length != 0)
                    {
                        memberBindProvider.valSetterSources = new DataBindingValueSource[0];
                        GUI.changed = true;
                    }
                }
                else
                {
                    if (!memberBindProvider.member.IsStatic)
                    {
                        rect2.y += (float)(EditorGUIUtility.singleLineHeight + 2.0);
                        if (memberBindProvider.sourceObjType != 0 && memberBindProvider.sourceObjType != MemberBindProvider.DataSourceOject.Owner)
                        {
                            rect2.width = (float)(EditorGUIUtility.labelWidth + 100.0);
                        }
                        EditorGUI.BeginChangeCheck();
                        memberBindProvider.sourceObjType = (MemberBindProvider.DataSourceOject)EditorGUI.EnumPopup(rect2, MemberBindProviderEd.GC_TargetObject, (Enum)(object)memberBindProvider.sourceObjType);
                        if (EditorGUI.EndChangeCheck())
                        {
                            memberBindProvider.sourceObjData = "";
                            if (memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.Instance)
                            {
                                MemberBindProvider target3 = memberBindProvider;
                                BloxMemberInfo     member2 = memberBindProvider.member;
                                this.InitSubBindables(target3, (member2 != null) ? member2.ReflectedType : null);
                            }
                        }
                        rect2.x    += (float)(EditorGUIUtility.labelWidth + 102.0);
                        rect2.width = (float)(rect.width - (EditorGUIUtility.labelWidth + 102.0));
                        if (memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.WithName || memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.WithTag)
                        {
                            memberBindProvider.sourceObjData = EditorGUI.TextField(rect2, memberBindProvider.sourceObjData);
                        }
                        else if (memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.OfType)
                        {
                            EditorGUI.LabelField(rect2, BloxEd.PrettyTypeName(memberBindProvider.member.ReflectedType, true));
                        }
                        else if (memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.Instance)
                        {
                            EditorGUI.BeginChangeCheck();
                            this.subBindIdx = EditorGUI.Popup(rect2, this.subBindIdx, this.subBindableLabels);
                            if (EditorGUI.EndChangeCheck())
                            {
                                memberBindProvider.instanceMember = this.subBindables[this.subBindIdx].mi;
                            }
                        }
                    }
                    rect2.x     = rect.x;
                    rect2.y    += (float)(EditorGUIUtility.singleLineHeight + 2.0);
                    rect2.width = rect.width;
                    if (memberBindProvider.member.MemberType == MemberTypes.Method)
                    {
                        ParameterInfo[] parameters = memberBindProvider.member.GetParameters();
                        if (memberBindProvider.valSetterSources.Length != parameters.Length)
                        {
                            GUI.changed = true;
                            memberBindProvider.valSetterSources = new DataBindingValueSource[parameters.Length];
                            for (int i = 0; i < parameters.Length; i++)
                            {
                                memberBindProvider.valSetterSources[i] = new DataBindingValueSource();
                            }
                        }
                        if (memberBindProvider.valSetterSources.Length != 0)
                        {
                            GUI.Label(rect2, MemberBindProviderEd.GC_With);
                            for (int j = 0; j < memberBindProvider.valSetterSources.Length; j++)
                            {
                                MemberBindProviderEd.GC_Param.text = parameters[j].Name + "=";
                                rect2.y += (float)(EditorGUIUtility.singleLineHeight + 2.0);
                                memberBindProvider.valSetterSources[j] = DataProviderEd.DataBindingValueSourceField(rect2, MemberBindProviderEd.GC_Param, memberBindProvider.valSetterSources[j], MemberBindProviderEd.GC_ToValBindWin, memberBindProvider);
                            }
                        }
                    }
                    else if (isSetter)
                    {
                        if (memberBindProvider.valSetterSources.Length != 1)
                        {
                            GUI.changed = true;
                            memberBindProvider.valSetterSources = new DataBindingValueSource[1]
                            {
                                new DataBindingValueSource()
                            };
                        }
                        memberBindProvider.valSetterSources[0] = DataProviderEd.DataBindingValueSourceField(rect2, MemberBindProviderEd.GC_ToVal, memberBindProvider.valSetterSources[0], MemberBindProviderEd.GC_ToValBindWin, memberBindProvider);
                    }
                }
            }
        }
Example #6
0
        private void DrawPropertiesListElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            ManagedProperty managedProperty = PropertiesManagerEd.PropertiesManager.properties[index];
            float           num             = (float)(rect.width / 3.0 - 10.0);
            Rect            rect2           = new Rect(rect.x, (float)(rect.y + 2.0), num, EditorGUIUtility.singleLineHeight);

            rect2.width = 20f;
            if (GUI.Button(rect2, MainEditorPanel.GC_RestoreDuringBootstrap[(!managedProperty.runDuringBoot) ? 1 : 0], plyEdGUI.Styles.SmallButtonFlat))
            {
                managedProperty.runDuringBoot = !managedProperty.runDuringBoot;
                plyEdUtil.SetDirty(PropertiesManagerEd.PropertiesManager);
            }
            MainEditorPanel.GC_s0.text = managedProperty.propertyName;
            rect2.x    += 20f;
            rect2.width = (float)(num - 20.0);
            GUI.Label(rect2, MainEditorPanel.GC_s0);
            MainEditorPanel.GC_s1.text = "[none]";
            Type type  = managedProperty.getter.DataType(true);
            Type type2 = managedProperty.setter.DataType(false);

            if (type != null || type2 != null)
            {
                if (type == type2)
                {
                    MainEditorPanel.GC_s1.text = "[" + BloxEd.PrettyTypeName(type, true) + "]";
                }
                else if (type == null || type2 == null)
                {
                    MainEditorPanel.GC_s1.text = "[" + BloxEd.PrettyTypeName(type, true) + "|" + BloxEd.PrettyTypeName(type2, true) + "]";
                }
                else
                {
                    MainEditorPanel.GC_s1.text = "[<color=red>" + BloxEd.PrettyTypeName(type, true) + "|" + BloxEd.PrettyTypeName(type2, true) + "</color>]";
                }
            }
            Vector2 vector = GUI.skin.label.CalcSize(MainEditorPanel.GC_s0);

            vector.x += 2f;
            Vector2 vector2  = plyEdGUI.Styles.Label_RT.CalcSize(MainEditorPanel.GC_s1);
            Rect    position = new Rect(rect2.xMax - vector2.x, rect2.y, vector2.x, rect2.height);

            if (position.x < rect2.x + vector.x)
            {
                position.x     = rect2.x + vector.x;
                position.width = rect2.xMax - (rect2.x + vector.x);
            }
            if (position.width > 0.0)
            {
                GUI.Label(position, MainEditorPanel.GC_s1, plyEdGUI.Styles.Label_RT);
            }
            rect2.x    += (float)(rect2.width + 10.0);
            rect2.width = 20f;
            GUI.Label(rect2, MainEditorPanel.GC_PropertyGetter, plyEdGUI.Styles.Label);
            rect2.x    += 20f;
            rect2.width = (float)(num - 20.0);
            DataProviderEd.DataBindingField(rect2, null, managedProperty.getter, PropertiesManagerEd.PropertiesManager, false, null);
            rect2.x    += (float)(rect2.width + 10.0);
            rect2.width = 20f;
            GUI.Label(rect2, MainEditorPanel.GC_PropertySetter, plyEdGUI.Styles.Label);
            rect2.x    += 20f;
            rect2.width = (float)(num - 20.0);
            DataProviderEd.DataBindingField(rect2, null, managedProperty.setter, PropertiesManagerEd.PropertiesManager, true, null);
        }
Example #7
0
        public override string VarTypeName(plyVar target)
        {
            plyVar_List plyVar_List = (plyVar_List)target.ValueHandler;

            return("List<" + BloxEd.PrettyTypeName(plyVar_List.baseType, false) + ">");
        }