Example #1
0
 private void InitSubBindables(MemberBindProvider target, Type rt)
 {
     if (this.currSubBindType != rt)
     {
         this.currSubBindType = rt;
         this.subBindIdx      = -1;
         this.subBindables.Clear();
         this.subBindableLabels = new GUIContent[0];
         if (rt != null)
         {
             foreach (BindableData value in MemberBindProviderEd.getterBindables.Values)
             {
                 if (value.mi.IsStatic && rt.IsAssignableFrom(value.mi.ReturnType))
                 {
                     this.subBindables.Add(new BindableData
                     {
                         visibleName = value.mi.ReflectedType.FullName.Replace(".", "/") + "/" + value.mi.Name,
                         mi          = value.mi,
                         type        = null
                     });
                 }
             }
             string a = BloxMemberInfo.FullMemberPath(target.instanceMember).Replace(".", "/");
             this.subBindableLabels = new GUIContent[this.subBindables.Count];
             for (int i = 0; i < this.subBindables.Count; i++)
             {
                 this.subBindableLabels[i] = new GUIContent(this.subBindables[i].visibleName);
                 if (a == this.subBindables[i].visibleName)
                 {
                     this.subBindIdx = i;
                 }
             }
         }
     }
 }
Example #2
0
        public override string Label(DataProvider target)
        {
            MemberBindProvider memberBindProvider = (MemberBindProvider)target;

            if (memberBindProvider.member == null)
            {
                return(base.nfo.Name);
            }
            return(BloxMemberInfo.SimpleMemberPath(memberBindProvider.member));
        }
Example #3
0
        public override float EditorHeight(DataProvider target, bool isSetter)
        {
            MemberBindProvider memberBindProvider = (MemberBindProvider)target;
            float num = (float)(memberBindProvider.valSetterSources.Length + 1);

            if (memberBindProvider.member != null)
            {
                if (!memberBindProvider.member.IsStatic)
                {
                    num = (float)(num + 1.0);
                }
                if (((memberBindProvider.member.MemberType == MemberTypes.Method) ? memberBindProvider.valSetterSources.Length : 0) != 0)
                {
                    num = (float)(num + 1.0);
                }
            }
            return((float)((EditorGUIUtility.singleLineHeight + 2.0) * num));
        }
Example #4
0
        private void InitCurrBindables(MemberBindProvider target, bool isForSetter)
        {
            if (this.currBindables != null && this.currBindableLabels != null)
            {
                return;
            }
            Dictionary <string, BindableData> dictionary = isForSetter ? MemberBindProviderEd.setterBindables : MemberBindProviderEd.getterBindables;

            this.currBindables = new BindableData[dictionary.Count];
            dictionary.Values.CopyTo(this.currBindables, 0);
            this.currBindableLabels = new GUIContent[this.currBindables.Length];
            for (int i = 0; i < this.currBindables.Length; i++)
            {
                this.currBindableLabels[i] = new GUIContent(this.currBindables[i].visibleName);
            }
            this.memberBindIdx = -1;
            BloxMemberInfo member     = target.member;
            string         memberName = MemberBindProviderEd.GetMemberName((member != null) ? member.MI : null);

            if (!string.IsNullOrEmpty(memberName))
            {
                int num = 0;
                while (num < this.currBindables.Length)
                {
                    if (!(memberName == this.currBindables[num].visibleName))
                    {
                        num++;
                        continue;
                    }
                    this.memberBindIdx = num;
                    break;
                }
            }
            if (target.sourceObjType == MemberBindProvider.DataSourceOject.Instance && target.member != null)
            {
                this.InitSubBindables(target, target.member.ReflectedType);
            }
        }
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);
                    }
                }
            }
        }