public BloxBlockEd(BloxBlock b, BloxBlockEd prev, BloxBlockEd parentBlock, BloxBlockEd owningBlock, int fieldIdx) { UnityEngine.Debug.Log("BloxBlockEd init" + b.returnType + b + owningBlock); this.b = b; this.def = BloxEd.Instance.FindBlockDef(b); this.prev = prev; this.parentBlock = parentBlock; this.owningBlock = owningBlock; this.fieldIdx = fieldIdx; if (b.contextBlock != null) { this.contextBlock = new BloxBlockEd(b.contextBlock, null, null, this, -1); } if (((b.paramBlocks != null) ? b.paramBlocks.Length : 0) != 0) { this.paramBlocks = new BloxBlockEd[b.paramBlocks.Length]; for (int i = 0; i < b.paramBlocks.Length; i++) { if (b.paramBlocks[i] != null) { this.paramBlocks[i] = new BloxBlockEd(b.paramBlocks[i], null, null, this, i); } } } if (b.firstChild != null) { this.firstChild = new BloxBlockEd(b.firstChild, null, this, null, -1); } this.UpdateNextBlock(parentBlock); }
public BloxBlockEd(BloxBlock b, BloxBlockEd prev, BloxBlockEd parentBlock, BloxBlockEd owningBlock, int fieldIdx, bool checkNextToo = true) { //Debug.Log("BloxBlockEd", "BloxBlockEd", Color.cyan); this.b = b; this.def = BloxEd.Instance.FindBlockDef(b); this.prev = prev; this.parentBlock = parentBlock; this.owningBlock = owningBlock; if (owningBlock != null) { Debug.Log("b" + b.ident, "BloxBlockEd", Color.green); Debug.Log("owningBlock" + owningBlock.b.ident, "BloxBlockEd", Color.green); } this.fieldIdx = fieldIdx; if (b.contextBlock != null) { this.contextBlock = new BloxBlockEd(b.contextBlock, null, null, this, -1, true); } if (((b.paramBlocks != null) ? b.paramBlocks.Length : 0) != 0) { this.paramBlocks = new BloxBlockEd[b.paramBlocks.Length]; for (int i = 0; i < b.paramBlocks.Length; i++) { if (b.paramBlocks[i] != null) { this.paramBlocks[i] = new BloxBlockEd(b.paramBlocks[i], null, null, this, i, true); } } } if (b.firstChild != null) { this.firstChild = new BloxBlockEd(b.firstChild, null, this, null, -1, false); BloxBlockEd bloxBlockEd = this.firstChild; while (bloxBlockEd.b.next != null) { bloxBlockEd.next = new BloxBlockEd(bloxBlockEd.b.next, bloxBlockEd, this, null, -1, false); bloxBlockEd = bloxBlockEd.next; } } if (checkNextToo) { this.UpdateNextBlock(parentBlock); } }
public void SetSelectedBlock(BloxBlockEd block) { this.currBlock = block; this.selectedBlockDef = ((block != null) ? block.def : null); this.SetShownDef(this.selectedBlockDef); }
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(); }