private static void TestPath(
        string pathString,
        out Dictionary <string, object> leafNodeParent,
        out string leafNodeToken)
    {
        string[] tokens    = pathString.Split(PATH_SEPERATOR);
        string   lastToken = (tokens.Length > 0) ? tokens[tokens.Length - 1] : pathString;

        DebugRegistry registry = GetInstance();
        Dictionary <string, object> parentNode = registry._rootNode;

        // Make sure the path to the node exists
        for (int tokenIndex = 0; parentNode != null && tokenIndex < tokens.Length - 1; ++tokenIndex)
        {
            string token = tokens[tokenIndex];

            if (parentNode.ContainsKey(token))
            {
                parentNode = (Dictionary <string, object>)parentNode[token];
            }
            else
            {
                parentNode = null;
            }
        }

        leafNodeParent = parentNode;
        leafNodeToken  = lastToken;
    }
    private static void CreatePath(
        string pathString,
        out Dictionary <string, object> leafNodeParent,
        out string leafNodeToken)
    {
        string[] tokens    = pathString.Split(PATH_SEPERATOR);
        string   lastToken = (tokens.Length > 0) ? tokens[tokens.Length - 1] : pathString;

        DebugRegistry registry = GetInstance();
        Dictionary <string, object> parentNode = registry._rootNode;

        // Create any missing nodes along the path
        for (int tokenIndex = 0; tokenIndex < tokens.Length - 1; ++tokenIndex)
        {
            string token = tokens[tokenIndex];

            if (!parentNode.ContainsKey(token))
            {
                parentNode.Add(token, new Dictionary <string, object>());
            }

            parentNode = (Dictionary <string, object>)parentNode[token];
        }

        leafNodeParent = parentNode;
        leafNodeToken  = lastToken;
    }
    private static DebugRegistry GetInstance()
    {
        if (_instance == null)
        {
            _instance = new DebugRegistry();
        }

        return(_instance);
    }
示例#4
0
    public IRCSocket()
    {
        SocketReady = false;

        if (Debug.isDebugBuild)
        {
            DebugRegistry.SetToggle("irc.socket.log", false);
        }
    }
    public GameWorldDebug(GameWorldController gameWorldController)
    {
        _gameWorldController = gameWorldController;
        _pathComputer        = new PathComputer();

        DebugRegistry.SetToggle("entity.pathfinding.render_debug_path", false);
        DebugRegistry.SetToggle("entity.pathfinding.render_nav_mesh", false);
        DebugRegistry.SetToggle("entity.pathfinding.render_visibility", false);
        DebugRegistry.SetToggle("ui.outline_hover_widget", false);
        DebugRegistry.SetToggle("ui.show_cursor_position", false);
    }
示例#6
0
    public void Start(WidgetGroup widgetGroup)
    {
        Point2d newMousePosition = GetMousePosition();

        m_rootWidgetGroup = widgetGroup;

        m_mousePosition.Set(newMousePosition.x, newMousePosition.y);
        m_mouseOverIWidget = m_rootWidgetGroup.FindChildIWidgetContainingPoint(m_mousePosition);
        m_mouseIsDragging  = false;
        m_mouseWasDown     = Input.GetMouseButton((int)eMouseButton.left);

        if (Debug.isDebugBuild)
        {
            DebugRegistry.SetToggle("ui.event.log", false);
        }
    }
    public void Update()
    {
        if (DebugRegistry.TestToggle("entity.pathfinding.*"))
        {
            if (DebugRegistry.TestToggle("entity.pathfinding.render_debug_path"))
            {
                DebugDrawTestPath();
            }

            if (DebugRegistry.TestToggle("entity.pathfinding.render_visibility"))
            {
                DebugDrawTestVisibility();
            }

            if (DebugRegistry.TestToggle("entity.pathfinding.render_nav_mesh"))
            {
                DebugDrawNavMesh();
            }
        }
        else
        {
            _pathStatusLabel.Visible       = false;
            _visibilityStatusLabel.Visible = false;
        }

        if (DebugRegistry.TestToggle("ui.outline_hover_widget"))
        {
            DebugDrawHoverWidget();
        }
        else
        {
            _widgetLabel.Visible = false;
        }

        if (DebugRegistry.TestToggle("ui.show_cursor_position"))
        {
            DebugCursorPosition();
        }
        else
        {
            _positionLabel.Visible = false;
        }
    }
    // Events
    public void OnWidgetEvent(WidgetEvent widgetEvent)
    {
        bool handeled = false;

        if (widgetEvent.EventSource == _chatInput)
        {
            if (widgetEvent.EventType == WidgetEvent.eEventType.textInputReturn)
            {
                string inputText = _chatInput.Text;

                // Attempt to execute the chat string as a debug command first
                // If it works, well get a valid result string back.
                string commandResult = DebugRegistry.ExecuteDebugCommand(inputText);

                _chatInput.Text = "";

                if (commandResult.Length > 0)
                {
                    _chatWindowController.OnSystemMessage(commandResult);
                }
                else
                {
                    _chatWindowController.OnChatTextInput(inputText);
                }

                // No need to forward this event on
                handeled = true;
            }
            else if (widgetEvent.EventType == WidgetEvent.eEventType.textInputTab)
            {
                string        partialText = _chatInput.Text;
                List <string> completions = DebugRegistry.CompleteDebugCommand(partialText);

                if (completions.Count > 1)
                {
                    foreach (string completion in completions)
                    {
                        _chatWindowController.OnSystemMessage(completion);
                    }

                    _chatInput.Text = partialText;
                }
                else if (completions.Count == 1)
                {
                    _chatInput.Text = completions[0];

                    // Force the cursor to the end of the line
                    {
                        TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);

                        editor.selectPos = _chatInput.Text.Length + 1;
                        editor.pos       = _chatInput.Text.Length + 1;
                    }
                }

                // No need to forward this event on
                handeled = true;
            }
        }

        // Forward unhanded events onto our parent
        if (!handeled)
        {
            _rootWidgetGroup.ParentWidgetGroup.OnWidgetEvent(widgetEvent);
        }
    }
示例#9
0
    private static DebugRegistry GetInstance()
    {
        if (_instance == null)
        {
            _instance = new DebugRegistry();
        }

        return _instance;
    }