Ejemplo n.º 1
0
    private void loadSelectedSessions(int currentSelectedIndex)
    {
        if (_selectedJsonFileIndex == currentSelectedIndex)
        {
            return;
        }

        try
        {
            if (currentSelectedIndex < 0)
            {
                throw new System.ArgumentException(string.Format("invalid selected index ({0}). ", currentSelectedIndex));
            }

            string file = getSessionsBySelectedIndex(HanoiUtil.GetVaildJsonFolders(), currentSelectedIndex);
            if (!loadJsonData(file))
            {
                throw new System.ArgumentException(string.Format("loading file `{0}` failed. ", file));
            }

            HanoiUtil.TotalTimeConsuming = HanoiUtil.calculateTotalTimeConsuming(m_data.Root.callStats);
            HanoiUtil.CalculateFrameInterval(m_data.Root.callStats, null);
            _selectedJsonFileIndex = currentSelectedIndex;
        }
        catch (Exception ex)
        {
            _selectedJsonFileIndex = -1;
            Debug.LogErrorFormat("[Hanoi] Loading session failed. ({0})", ex.Message);
        }
    }
Ejemplo n.º 2
0
    private void loadSession(string file)
    {
        ClearHanoiRoot();
        if (!loadJsonData(file))
        {
            throw new System.ArgumentException(string.Format("loading file `{0}` failed. ", file));
        }

        HanoiUtil.CalculateFrameInterval(m_data.Root.callStats, null);
        calculateStackHeight();
    }
Ejemplo n.º 3
0
    private void DrawHanoiData(HanoiRoot r)
    {
        if (r.callStats == null)
        {
            return;
        }

        HanoiVars.LabelBackgroundWidth = GetDrawingLengthByPanelPixels(200);
        HanoiVars.DrawnStackCount      = m_data.MaxStackLevel;

        // draw 3 passes
        HanoiUtil.DrawRecursively(r.callStats);
        HanoiUtil.DrawLabelsRecursively(r.callStats);
    }
Ejemplo n.º 4
0
    public void OnGUI()
    {
        CheckForResizing();
        Handles.BeginGUI();
        Handles.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1, 1, 1));
        //control窗口内容
        GUILayout.BeginArea(new Rect(0, m_controlScreenPosY, m_winWidth, m_controlScreenHeight));
        {
            drawGUIElement();
        }
        GUILayout.EndArea();

        //navigation窗口内容
        GUILayout.BeginArea(new Rect(0, m_navigationScreenPosY, m_winWidth, m_navigationScreenHeight));
        {
            if (m_data.isHanoiDataHasContent())
            {
                GraphItWindowLuaPro.DrawGraphs(position, this);
            }
        }
        GUILayout.EndArea();

        if (m_data.isHanoiDataLoadSucc() && (EditorWindow.focusedWindow == this))
        {
            CheckForInput();
            //detail窗口内容
            GUILayout.BeginArea(new Rect(0, m_detailScreenPosY, m_winWidth, m_detailScreenHeight));
            {
                Handles.matrix = Matrix4x4.TRS(m_Translation, Quaternion.identity, new Vector3(m_Scale.x, m_Scale.y, 1));
                HanoiUtil.CalculateFrameInterval(m_data.Root.callStats, null);
                calculateStackHeight();

                calculateScreenClipRange();
                DrawHanoiData(m_data.Root);

                drawTimeInterval();
                drawFrameInfo(m_data.Root.callStats, mousePositionInDrawing.x);
                if (m_mouseArea == MouseInArea.DetailScreen)
                {
                    showMouseGlobalTime();
                }
            }
            GUILayout.EndArea();
        }

        Handles.EndGUI();
    }
Ejemplo n.º 5
0
 private void refreshCheckJasonFilesUpadate()
 {
     try
     {
         string[] files = HanoiUtil.GetVaildJsonFolders();
         for (int i = 0; i < files.Length; i++)
         {
             int begin = files[i].LastIndexOfAny(new char[] { '\\', '/' });
             if (begin != -1)
             {
                 files[i] = files[i].Substring(begin + 1);
             }
         }
         _JsonFilesPath = files;
     }
     catch (Exception ex)
     {
         Debug.LogException(ex);
         _JsonFilesPath = new string[] { };
     }
 }
Ejemplo n.º 6
0
    private void CheckForInput()
    {
        switch (Event.current.type)
        {
        case EventType.MouseMove:
        {
            if (m_picked != null)
            {
                HanoiUtil.ForeachInParentChain(m_picked, (n) => { n.highlighted = false; });
                m_picked = null;
            }

            HanoiNode picked = PickHanoiRecursively(m_data.Root.callStats, mousePositionInDrawing);
            if (picked != null)
            {
                HanoiUtil.ForeachInParentChain(picked, (n) => {
                        n.highlighted = true;
                    });
                m_picked = picked;

                Debug.LogFormat("Picked: f {0}, m {1}", m_picked.funcName, m_picked.moduleName);
            }
            else
            {
                Debug.LogFormat("Picked nothing.");
            }

            if (EditorWindow.focusedWindow == this)
            {
                if ((Event.current.mousePosition.x >= 0 && Event.current.mousePosition.x <= m_winWidth) &&
                    (Event.current.mousePosition.y >= m_detailScreenPosY && Event.current.mousePosition.y <= m_winHeight))
                {
                    Repaint();
                }
            }
        }
        break;

        case EventType.MouseDrag:
            if (Event.current.button == 1)
            {
                m_Translation.x += Event.current.delta.x;
                Repaint();
            }
            break;

        case EventType.ScrollWheel:
        {
            float delta = Event.current.delta.x + Event.current.delta.y;
            delta = -delta;

            // Scale multiplier. Don't allow scale of zero or below!
            float scale = Mathf.Max(0.1F, 1 + delta * 0.1F);

            // Offset to make zoom centered around cursor position
            m_Translation.x -= mousePositionInDrawing.x * (scale - 1) * m_Scale.x;

            // Apply zooming
            m_Scale.x *= scale;

            Repaint();
        }
        break;

        default:
            break;
        }
    }
Ejemplo n.º 7
0
 private void drawFrameInfo(HanoiNode n, float mouseX)
 {
     HanoiUtil.DrawFrameStatementRecursively(n);
     HanoiUtil.DrawSelectedFrameInfoRecursively(n, mouseX);
 }