Пример #1
0
        protected override void OnGUIConnected()
        {
            if (Event.current.type == EventType.MouseMove)
            {
                this.Repaint();
            }
            else if (Event.current.type == EventType.KeyUp)
            {
                if (Event.current.keyCode == KeyCode.LeftControl || Event.current.keyCode == KeyCode.RightControl)
                {
                    this.filterByPacketId = 0;
                    this.pickingFilter    = !this.pickingFilter;
                    this.Repaint();
                    Event.current.Use();
                }
            }

            float height = 0F;

            for (int i = this.Hierarchy.Client.sentPacketsHistoric.Count - 1; i >= 0; --i)
            {
                Client.InPipePacket inPacket = this.Hierarchy.Client.sentPacketsHistoric[i];

                if (this.hidePingPackets == true && inPacket.packet is ClientSendPingPacket)
                {
                    continue;
                }

                if (this.filterByPacketId != 0 && this.filterByPacketId != inPacket.packet.packetId)
                {
                    continue;
                }

                height += Constants.SingleLineHeight;
            }

            Rect bodyRect = new Rect(0F, Constants.SingleLineHeight * 2F + 4F, this.position.width, this.position.height - (Constants.SingleLineHeight * 2F + 4F));
            Rect viewRect = new Rect(0F, 0F, 0F, height);
            Rect r        = new Rect(0F, 0F, this.position.width, Constants.SingleLineHeight);

            this.scrollBatchPosition = GUI.BeginScrollView(bodyRect, this.scrollBatchPosition, viewRect);
            {
                if (viewRect.height >= bodyRect.height)
                {
                    bodyRect.width -= 16F;
                }

                float indexWidth = 18F;
                int   max        = this.Hierarchy.Client.sentPacketsHistoric.Count;

                while (max >= 10)
                {
                    max        /= 10;
                    indexWidth += 8F;
                }

                for (int i = this.Hierarchy.Client.sentPacketsHistoric.Count - 1; i >= 0; --i)
                {
                    Client.InPipePacket inPacket = this.Hierarchy.Client.sentPacketsHistoric[i];

                    if (this.hidePingPackets == true && inPacket.packet is ClientSendPingPacket)
                    {
                        continue;
                    }

                    if (this.filterByPacketId != 0 && this.filterByPacketId != inPacket.packet.packetId)
                    {
                        continue;
                    }

                    if (r.y + r.height <= this.scrollBatchPosition.y)
                    {
                        r.y += r.height;
                        continue;
                    }

                    r.x     = 0F;
                    r.width = this.position.width;

                    if (this.pickingFilter == true)
                    {
                        if (r.Contains(Event.current.mousePosition) == true)
                        {
                            if (Event.current.type == EventType.Repaint)
                            {
                                Utility.DrawUnfillRect(r, Color.yellow);
                            }
                            else if (Event.current.type == EventType.MouseDown)
                            {
                                this.filterByPacketId = inPacket.packet.packetId;
                                this.pickingFilter    = false;
                                this.Repaint();
                            }
                        }
                    }

                    if (Conf.DebugMode != Conf.DebugState.None && r.yMin < Event.current.mousePosition.y && r.yMax > Event.current.mousePosition.y)
                    {
                        r.width = 60F;
                        if (Event.current.type == EventType.MouseDown)
                        {
                            this.Hierarchy.Client.AddPacket(inPacket.packet);
                        }
                    }

                    r.width = indexWidth;

                    EditorGUI.LabelField(r, (i + 1).ToCachedString());
                    r.x += r.width;

                    r.width = 90F;
                    GUI.Label(r, inPacket.ReadableSendTime);
                    r.x += r.width;

                    r.width = bodyRect.width - r.x;
                    GUILayout.BeginArea(r);
                    {
                        GUILayout.BeginHorizontal();
                        {
                            IGUIPacket clientPacket = inPacket.packet as IGUIPacket;

                            if (clientPacket != null)
                            {
                                clientPacket.OnGUI(this.Hierarchy);
                            }
                            else
                            {
                                GUILayout.Label(inPacket.packet.GetType().Name);
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndArea();

                    r.x     = 0F;
                    r.width = this.position.width;

                    if (Conf.DebugMode != Conf.DebugState.None && r.yMin < Event.current.mousePosition.y && r.yMax > Event.current.mousePosition.y)
                    {
                        r.width = 60F;
                        GUI.Button(r, LC.G("NGInspector_Resend"));
                    }

                    r.y += r.height;

                    if (r.y - this.scrollBatchPosition.y > bodyRect.height)
                    {
                        break;
                    }
                }
            }
            GUI.EndScrollView();
        }
Пример #2
0
        public void     DrawBatch()
        {
            this.bodyRect.y      = Constants.SingleLineHeight;        // Header
            this.bodyRect.width  = this.position.width;
            this.bodyRect.height = this.position.height;
            this.viewRect.height = this.Hierarchy.Client.batchedPackets.Count * Constants.SingleLineHeight;
            this.r.x             = 0F;
            this.r.y             = Constants.SingleLineHeight;
            this.r.height        = Constants.SingleLineHeight;
            this.r.width         = this.position.width;

            GUILayout.BeginArea(this.r);
            {
                EditorGUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button(LC.G("Execute")) == true)
                    {
                        this.Hierarchy.Client.ExecuteBatch();
                    }

                    if (GUILayout.Button(LC.G("Save"), GUILayoutOptionPool.MaxWidth(100F)) == true)
                    {
                        PromptWindow.Start("Noname", this.PromptSaveBatch, null);
                    }
                }
                EditorGUILayout.EndHorizontal();
                this.bodyRect.y += Constants.SingleLineHeight;
            }
            GUILayout.EndArea();

            if (this.Hierarchy.Client.BatchNames.Length > 0)
            {
                this.r.y += this.r.height;
                GUILayout.BeginArea(this.r);
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        this.selectedBatch = EditorGUILayout.Popup(this.selectedBatch, this.Hierarchy.Client.BatchNames);
                        if (GUILayout.Button(LC.G("Load"), GUILayoutOptionPool.MaxWidth(100F)) == true)
                        {
                            this.Hierarchy.Client.LoadBatch(this.selectedBatch);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    this.bodyRect.y      += Constants.SingleLineHeight;
                    this.bodyRect.height -= this.bodyRect.y;
                }
                GUILayout.EndArea();
            }

            this.scrollBatchPosition = GUI.BeginScrollView(this.bodyRect, this.scrollBatchPosition, this.viewRect);
            {
                if (this.viewRect.height >= this.bodyRect.height)
                {
                    this.r.width -= 16F;
                }

                this.r.y      = 0F;
                this.r.height = Constants.SingleLineHeight;

                for (int i = 0; i < this.Hierarchy.Client.batchedPackets.Count; i++)
                {
                    GUILayout.BeginArea(r);
                    {
                        GUILayout.BeginHorizontal();
                        {
                            IGUIPacket clientPacket = this.Hierarchy.Client.batchedPackets[i].packet as IGUIPacket;

                            if (clientPacket != null)
                            {
                                clientPacket.OnGUI(this.Hierarchy);
                            }

                            if (GUILayout.Button("X", GUILayoutOptionPool.Width(20F)) == true)
                            {
                                this.Hierarchy.Client.batchedPackets.RemoveAt(i);
                                return;
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndArea();

                    this.r.y += this.r.height;
                }
            }
            GUI.EndScrollView();
        }