예제 #1
0
        // Symbol list in node tab and connection tab.
        void LayoutSymbolList()
        {
            // Set the scroll position.
            _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, SymbolList.HeightLayout);
            // Content of scroll area.
            _symbolListArea        = Container.SymbolListArea;
            _symbolListArea.height = Alphabet.Nodes.Count >= Alphabet.Connections.Count ?
                                     (Alphabet.Nodes.Count + 1) * 50 : (Alphabet.Connections.Count + 1) * 50;
            GUILayout.BeginArea(_symbolListArea);
            _symbolListCanvas        = Container.SymbolListCanvas;
            _symbolListCanvas.height = Alphabet.Nodes.Count >= Alphabet.Connections.Count ?
                                       (Alphabet.Nodes.Count + 1) * 50 : (Alphabet.Connections.Count + 1) * 50;

            SampleStyle.DrawGrid(_symbolListCanvas, SampleStyle.MinorGridSize, SampleStyle.MajorGridSize, SampleStyle.GridBackgroundColor, SampleStyle.GridColor);
            GUILayout.EndArea();
            // Layout each symbols in list.
            switch (_currentTab)
            {
            case AlphabetWindowTab.Nodes:
                foreach (var node in Alphabet.Nodes)
                {
                    Alphabet.DrawNodeInList(node);
                    // Custom style to modify padding and margin for label.
                    GUILayout.Label(node.ExpressName, SymbolList.NodeElement);
                }
                break;

            case AlphabetWindowTab.Connections:
                foreach (var connection in Alphabet.Connections)
                {
                    Alphabet.DrawConnectionInList(connection);
                    // Custom style to modify padding and margin for label.
                    GUILayout.Label(connection.Name, SymbolList.ConnectionElement);
                }
                break;
            }
            GUILayout.EndScrollView();
            // Get the Rect object from the last control when the event is Repaint.
            if (Event.current.type == EventType.Repaint)
            {
                _symbolListCanvasInWindow = GUILayoutUtility.GetLastRect();
            }
        }
예제 #2
0
        // Canvas to draw current mission graph.
        private void LayoutMissionGraphCanvas()
        {
            GUILayout.BeginArea(Container.MissionGraphArea);
            GUILayout.BeginVertical(SampleStyle.Frame(SampleStyle.ColorLightestGrey));
            _canvasScrollPosition = GUILayout.BeginScrollView(_canvasScrollPosition, GUILayout.Width(Screen.width - 15), GUILayout.Height(300 - 5));
            Container.ResizeMissionGraphCanvas(_missionGraphCanvasSizeWidth, _missionGraphCanvasSizeHeight);
            SampleStyle.DrawGrid(Container.MissionGraphCanvas, SampleStyle.MinorGridSize, SampleStyle.MajorGridSize, SampleStyle.GridBackgroundColor, SampleStyle.GridColor);
            GUILayout.Label(string.Empty, Container.MissionGraphCanvasContent);
            // Connection
            foreach (Mission.GraphGrammarConnection connection in _currentGraph.Connections)
            {
                connection.Draw();
            }
            // Node
            // Draw and get right bottom position.
            Vector2 positionRightBotton = new Vector2(0, 0);

            foreach (Mission.GraphGrammarNode node in _currentGraph.Nodes)
            {
                // Get right position
                if (node.PositionX > positionRightBotton.x)
                {
                    positionRightBotton.x = node.PositionX;
                }
                // Get bottom position
                if (node.PositionY > positionRightBotton.y)
                {
                    positionRightBotton.y = node.PositionY;
                }
                node.Draw();
            }
            // Compare with screen size.
            _missionGraphCanvasSizeWidth  = Mathf.Max((int)Container.MissionGraphArea.width, (int)positionRightBotton.x + 25);
            _missionGraphCanvasSizeHeight = Mathf.Max((int)Container.MissionGraphArea.height, (int)positionRightBotton.y + 25);
            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            GUILayout.EndArea();
        }