private void DrawConnectionPanel(ConnectionManager connect, Graph.Node node, Func <Graph.Node, Vector2> toScreenPosFunc, string symbol, Vector2 posOffset) { if (ConnectedWithOngoing(connect, node)) { symbol = "x"; } Vector2 p = toScreenPosFunc == null ? node.pos : toScreenPosFunc(node); if (!connect.Ongoing ? Rooms.AnySelected(node.value) : (connect.from.value != node.value)) { if (GUI.Button(new Rect(p + posOffset, Vector2.one * 20), symbol)) { CommitConnection(connect, node); } } }
private void DrawRoom(Graph.Node room) { if (room?.value == null) { Debug.LogError("Room node cannot be null"); return; } Vector2 p = ScreenPos(room.pos), s = ScreenSize(room.size); if (t.IdAvailable(room.value)) { throw new ArgumentException("The room " + room.value + " has no corresponding block container"); } #region Draw Node (with menu) DrawImage(new Rect(p, s), t.GetMapById(room.value).Texture); DrawOutline(p, s, 2, Rooms.IsSelected(room) ? SelectColor : Color.black, default); // Only draw node menu if it is selected if (Rooms.AnySelected(room)) { if (!Rooms.IsRoot(room) && GUI.Button(new Rect(p + ROOT_POS, new Vector2(50, 14)), "Root")) { Rooms.Root = room; } } #endregion Handles.Label(p, room.value, LabelStyles.Colored(Color.white, FontStyle.Bold)); if (showDebugInfo) { Handles.Label(p + Vector2.right * s + Vector2.down * 16, Rooms.IndexOf(room).ToString(), LabelStyles.Colored(Color.white, FontStyle.Normal)); } if (Rooms.IsRoot(room)) { Handles.Label(p + ROOT_POS + Vector2.up * 4, "Root", LabelStyles.Colored(HighlightColor, FontStyle.Bold)); } }
private void DrawConnections() { foreach (var(ai, bi) in Rooms.Edges) { Graph.Node a = Rooms[ai], b = Rooms[bi]; DrawEdge(ScreenPos(a.pos), ScreenPos(b.pos), Palette[new int[] { ai, bi }.Perform((i) => { return(Rooms.AnySelected(Rooms[i].value) ? 1 : 0); }).Max()], 3, CGUI.Constants.LineStyle.Dashed, true); } foreach (var(ai, bi) in Exits.Edges) { Graph.Node a = Exits[ai], b = Exits[bi]; Vector2 p0 = ExitToScreenPos(a), s = ScreenSize(a.size); Vector2 p1 = ExitToScreenPos(b); DrawEdge(p0, p1, Palette[new int[] { ai, bi }.Perform((i) => { return(Exits.IndexOf(connectExits.from) == i ? 2 : Rooms.AnySelected(Exits[i].value) ? 1 : 0); }).Max()], 2, CGUI.Constants.LineStyle.Bezier, false); } }