private void CreateSubtreeRecursive(Act root, ref Vector2 lastPosition, ref Vector2 size) { if (root == null) { return; } else { ActElement element = new ActElement(); element.act = root; element.position = lastPosition; Elements.Add(element); lastPosition.Y += ElementHeight; lastPosition.X += ElementWidth; size += Datastructures.SafeMeasure(GUI.DefaultFont, element.act.Name); size.X += ElementWidth; size.Y += ElementHeight; if (root.Children != null && root.Enumerator.Current != Act.Status.Success) { foreach (Act child in root.Children) { CreateSubtreeRecursive(child, ref lastPosition, ref size); } } lastPosition.X -= ElementWidth; } }
private void InitAct() { Vector2 lastPosition = new Vector2(5, 5); Vector2 size = new Vector2(0, 0); if (CurrentAct != null && CurrentAct.IsInitialized) { ActElement element = new ActElement(); element.act = CurrentAct; element.position = lastPosition; Elements.Clear(); Elements.Add(element); lastPosition += new Vector2(ElementWidth, ElementHeight); size.X += ElementWidth; size.Y += ElementHeight; if (CurrentAct.Children != null) { foreach (Act child in CurrentAct.Children) { CreateSubtreeRecursive(child, ref lastPosition, ref size); } } } else if (CurrentAct != null) { CurrentAct = null; } LocalBounds = new Rectangle(LocalBounds.X, LocalBounds.Y, (int)size.X, (int)size.Y); }