Beispiel #1
0
        private IEnumerator LoadEventDefs()
        {
            Debug.Log("LoadEventDefs ", "BloxEditor.BloxEventsPopup", Color.green);
            BloxEd.Instance.LoadEventDefs();
            while (BloxEd.Instance.EventDefsLoading)
            {
                yield return((object)null);
            }
            plyEdTreeItem <BloxEventDef> treeRoot = new plyEdTreeItem <BloxEventDef>
            {
                children = new List <plyEdTreeItem <BloxEventDef> >()
            };
            int count            = 0;
            int countBeforeYield = 20;

            List <BloxEventDef> .Enumerator enumerator = BloxEd.Instance.eventDefs.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    BloxEventDef current = enumerator.Current;
                    string[]     array   = current.ident.Split('/');
                    plyEdTreeItem <BloxEventDef> plyEdTreeItem = treeRoot;
                    for (int i = 0; i < array.Length - 1; i++)
                    {
                        string text = array[i];
                        bool   flag = false;
                        if (plyEdTreeItem.children == null)
                        {
                            plyEdTreeItem.children = new List <plyEdTreeItem <BloxEventDef> >();
                        }
                        foreach (plyEdTreeItem <BloxEventDef> child in plyEdTreeItem.children)
                        {
                            if (child.label == text)
                            {
                                flag          = true;
                                plyEdTreeItem = child;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            plyEdTreeItem <BloxEventDef> plyEdTreeItem2 = new plyEdTreeItem <BloxEventDef>
                            {
                                label = text
                            };
                            plyEdTreeItem.AddChild(plyEdTreeItem2);
                            plyEdTreeItem = plyEdTreeItem2;
                            if (plyEdTreeItem2.parent == treeRoot)
                            {
                                plyEdTreeItem2.icon = BloxEdGUI.Instance.folderIcon;
                            }
                        }
                    }
                    if (plyEdTreeItem.children == null)
                    {
                        plyEdTreeItem.children = new List <plyEdTreeItem <BloxEventDef> >();
                    }
                    plyEdTreeItem.children.Add(new plyEdTreeItem <BloxEventDef>
                    {
                        icon  = ((current.iconName == null) ? null : BloxEdGUI.Instance.namedIcons[current.iconName]),
                        label = array[array.Length - 1],
                        data  = current
                    });
                    count++;
                    if (count >= countBeforeYield)
                    {
                        count = 0;
                        yield return((object)null);
                    }
                }
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            enumerator    = default(List <BloxEventDef> .Enumerator);
            this.treeView = new plyEdTreeView <BloxEventDef>(null, treeRoot, BloxEdGUI.Instance.folderIcon, "Events");
        }
Beispiel #2
0
        private IEnumerator Load()
        {
            plyVariablesEditor.LoadVarEds();
            BloxEd.Instance.LoadBlockDefs(true);
            while (BloxEd.Instance.BlockDefsLoading)
            {
                yield return((object)null);
            }
            plyEdTreeItem <BloxBlockDef> treeRoot = new plyEdTreeItem <BloxBlockDef>
            {
                children = new List <plyEdTreeItem <BloxBlockDef> >()
            };
            int count            = 0;
            int countBeforeYield = 50;

            Dictionary <string, BloxBlockDef> .ValueCollection.Enumerator enumerator = BloxEd.Instance.blockDefs.Values.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    BloxBlockDef current = enumerator.Current;
                    string[]     array   = current.ident.Split('/');
                    if (string.IsNullOrEmpty(current.name))
                    {
                        current.name = array[array.Length - 1];
                    }
                    if ((UnityEngine.Object)current.icon == (UnityEngine.Object)null)
                    {
                        if (current.ident.StartsWith("UnityEngine"))
                        {
                            current.icon = BloxEdGUI.Instance.unityIcon;
                        }
                        else
                        {
                            current.icon = BloxEdGUI.Instance.bloxIcon;
                        }
                    }
                    plyEdTreeItem <BloxBlockDef> plyEdTreeItem = treeRoot;
                    plyEdTreeItem <BloxBlockDef> plyEdTreeItem2;
                    for (int i = 0; i < array.Length - 1; i++)
                    {
                        string text = array[i];
                        bool   flag = false;
                        if (plyEdTreeItem.children == null)
                        {
                            plyEdTreeItem.children = new List <plyEdTreeItem <BloxBlockDef> >();
                        }
                        foreach (plyEdTreeItem <BloxBlockDef> child in plyEdTreeItem.children)
                        {
                            if (child.label == text)
                            {
                                flag          = true;
                                plyEdTreeItem = child;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            plyEdTreeItem2 = new plyEdTreeItem <BloxBlockDef>
                            {
                                label       = text,
                                searchLabel = text,
                                order       = ((plyEdTreeItem == treeRoot) ? current.order : plyEdTreeItem.order)
                            };
                            if (plyEdTreeItem2.searchLabel.Contains("("))
                            {
                                plyEdTreeItem2.searchLabel = plyEdTreeItem2.searchLabel.Substring(0, plyEdTreeItem2.searchLabel.LastIndexOf('('));
                            }
                            else if (plyEdTreeItem2.searchLabel.Contains(":"))
                            {
                                plyEdTreeItem2.searchLabel = plyEdTreeItem2.searchLabel.Substring(0, plyEdTreeItem2.searchLabel.LastIndexOf(':'));
                            }
                            if (plyEdTreeItem == treeRoot)
                            {
                                plyEdTreeItem2.icon = BloxEdGUI.Instance.folderIcon;
                            }
                            plyEdTreeItem.AddChild(plyEdTreeItem2);
                            plyEdTreeItem = plyEdTreeItem2;
                        }
                    }
                    if (plyEdTreeItem.children == null)
                    {
                        plyEdTreeItem.children = new List <plyEdTreeItem <BloxBlockDef> >();
                    }
                    plyEdTreeItem.children.Add(plyEdTreeItem2 = new plyEdTreeItem <BloxBlockDef>
                    {
                        icon        = current.icon,
                        label       = current.name,
                        searchLabel = current.name,
                        order       = current.order,
                        data        = current
                    });
                    if (plyEdTreeItem2.searchLabel.Contains("("))
                    {
                        plyEdTreeItem2.searchLabel = plyEdTreeItem2.searchLabel.Substring(0, plyEdTreeItem2.searchLabel.LastIndexOf('('));
                    }
                    else if (plyEdTreeItem2.searchLabel.Contains(":"))
                    {
                        plyEdTreeItem2.searchLabel = plyEdTreeItem2.searchLabel.Substring(0, plyEdTreeItem2.searchLabel.LastIndexOf(':'));
                    }
                    Texture2D texture2D = current.icon;
                    if ((UnityEngine.Object)texture2D == (UnityEngine.Object)BloxEdGUI.Instance.bloxFadedIcon)
                    {
                        texture2D = AssetPreview.GetMiniTypeThumbnail(current.returnType);
                        if ((UnityEngine.Object)texture2D == (UnityEngine.Object)null || texture2D.name == "DefaultAsset Icon")
                        {
                            texture2D = ((!current.returnType.FullName.StartsWith("UnityEngine")) ? BloxEdGUI.Instance.bloxIcon : BloxEdGUI.Instance.unityIcon);
                        }
                    }
                    plyEdTreeItem.SetIconRecusriveUp(texture2D);
                    count++;
                    if (count >= countBeforeYield)
                    {
                        count = 0;
                        yield return((object)null);
                    }
                }
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            enumerator    = default(Dictionary <string, BloxBlockDef> .ValueCollection.Enumerator);
            this.treeView = new plyEdTreeView <BloxBlockDef>(null, treeRoot, BloxEdGUI.Instance.folderIcon, "Blocks");
            this.treeView.Sort();
        }