Example #1
0
        public override void Load()
        {
            base.Load();

            Size  = new Vector2(WIDTH, HEIGHT);
            Alpha = alpha_when_inactive;

            for (int i = 0; i < timeBars.Length; ++i)
            {
                timeBars[i] = new TimeBar();
            }

            Children = new Drawable[]
            {
                new Container
                {
                    Masking          = true,
                    RelativeSizeAxes = Axes.Both,
                    Children         = timeBars
                },
                fpsDisplay = new FpsDisplay(monitor.Clock)
                {
                    Anchor = Anchor.BottomRight,
                    Origin = Anchor.BottomRight,
                },
                overlayContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Children         = new []
                    {
                        new SpriteText
                        {
                            Text     = Name,
                            Origin   = Anchor.BottomCentre,
                            Anchor   = Anchor.CentreLeft,
                            Rotation = -90
                        },
                        legendContainer = new FlowContainer
                        {
                            Anchor   = Anchor.TopRight,
                            Origin   = Anchor.TopRight,
                            Padding  = new Vector2(5, 1),
                            Children = new[]
                            {
                                new Box
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Colour           = Color4.Black,
                                    Alpha            = 0.2f
                                }
                            }
                        },
                        new SpriteText
                        {
                            Text = $@"{visible_range}ms"
                        },
                        new SpriteText
                        {
                            Text   = @"0ms",
                            Anchor = Anchor.BottomLeft,
                            Origin = Anchor.BottomLeft
                        }
                    }
                }
            };

            foreach (PerformanceCollectionType t in Enum.GetValues(typeof(PerformanceCollectionType)))
            {
                if (t >= PerformanceCollectionType.Empty)
                {
                    continue;
                }

                legendContainer.Add(legendMapping[(int)t] = new SpriteText
                {
                    Colour = getColour(t),
                    Text   = t.ToString(),
                    Alpha  = 0
                });
            }

            overlayContainer.FadeOut(2000, EasingTypes.InExpo);

            // Initialize background
            for (int i = 0; i < WIDTH * timeBars.Length; ++i)
            {
                currentX = i;

                TextureUpload upload = new TextureUpload(HEIGHT * 4, textureBufferStack)
                {
                    Bounds = new Rectangle(TimeBarX, 0, 1, HEIGHT)
                };

                addArea(null, PerformanceCollectionType.Empty, HEIGHT, upload.Data);
                timeBars[TimeBarIndex].Sprite.Texture.SetData(upload);
            }
        }
        public FrameStatisticsDisplay(GameThread thread, TextureAtlas atlas)
        {
            Name    = thread.Thread.Name;
            monitor = thread.Monitor;

            Origin       = Anchor.TopRight;
            AutoSizeAxes = Axes.Both;
            Alpha        = alpha_when_active;

            bool hasCounters = monitor.ActiveCounters.Any(b => b);

            Child = new Container
            {
                AutoSizeAxes = Axes.Both,
                Children     = new[]
                {
                    new Container
                    {
                        Origin           = Anchor.TopRight,
                        AutoSizeAxes     = Axes.X,
                        RelativeSizeAxes = Axes.Y,
                        Children         = new[]
                        {
                            labelText = new SpriteText
                            {
                                Text     = Name,
                                Origin   = Anchor.BottomCentre,
                                Anchor   = Anchor.CentreLeft,
                                Rotation = -90,
                            },
                            !hasCounters
                                ? new Container {
                                Width = 2
                            }
                                : new Container
                            {
                                Masking          = true,
                                CornerRadius     = 5,
                                AutoSizeAxes     = Axes.X,
                                RelativeSizeAxes = Axes.Y,
                                Margin           = new MarginPadding {
                                    Right = 2, Left = 2
                                },
                                Children = new Drawable[]
                                {
                                    counterBarBackground = new Sprite
                                    {
                                        Texture          = atlas.Add(1, HEIGHT),
                                        RelativeSizeAxes = Axes.Both,
                                        Size             = new Vector2(1, 1),
                                    },
                                    new FillFlowContainer
                                    {
                                        Direction          = FillDirection.Horizontal,
                                        AutoSizeAxes       = Axes.X,
                                        RelativeSizeAxes   = Axes.Y,
                                        ChildrenEnumerable =
                                            from StatisticsCounterType t in Enum.GetValues(typeof(StatisticsCounterType))
                                            where monitor.ActiveCounters[(int)t]
                                            select counterBars[t] = new CounterBar
                                        {
                                            Colour = getColour(t),
                                            Label  = t.ToString(),
                                        },
                                    },
                                }
                            }
                        }
                    },
                    mainContainer = new Container
                    {
                        Size     = new Vector2(WIDTH, HEIGHT),
                        Children = new[]
                        {
                            timeBarsContainer = new Container
                            {
                                Masking          = true,
                                CornerRadius     = 5,
                                RelativeSizeAxes = Axes.Both,
                                Children         = timeBars = new[]
                                {
                                    new TimeBar(atlas),
                                    new TimeBar(atlas),
                                },
                            },
                            fpsDisplay = new FpsDisplay(monitor.Clock)
                            {
                                Anchor = Anchor.BottomRight,
                                Origin = Anchor.BottomRight,
                            },
                            overlayContainer = new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Alpha            = 0,
                                Children         = new[]
                                {
                                    new FillFlowContainer
                                    {
                                        Anchor       = Anchor.TopRight,
                                        Origin       = Anchor.TopRight,
                                        AutoSizeAxes = Axes.Both,
                                        Spacing      = new Vector2(5, 1),
                                        Padding      = new MarginPadding {
                                            Right = 5
                                        },
                                        ChildrenEnumerable =
                                            from PerformanceCollectionType t in Enum.GetValues(typeof(PerformanceCollectionType))
                                            select legendMapping[(int)t] = new SpriteText
                                        {
                                            Colour = getColour(t),
                                            Text   = t.ToString(),
                                            Alpha  = 0
                                        },
                                    },
                                    new SpriteText
                                    {
                                        Padding = new MarginPadding {
                                            Left = 4
                                        },
                                        Text = $@"{visible_ms_range}ms"
                                    },
                                    new SpriteText
                                    {
                                        Padding = new MarginPadding {
                                            Left = 4
                                        },
                                        Text   = @"0ms",
                                        Anchor = Anchor.BottomLeft,
                                        Origin = Anchor.BottomLeft
                                    }
                                }
                            }
                        }
                    }
                }
            };

            textureBufferStack = new BufferStack <byte>(timeBars.Length * WIDTH);
        }
Example #3
0
        public FrameStatisticsDisplay(string name, PerformanceMonitor monitor, TextureAtlas atlas)
        {
            Name         = name;
            this.monitor = monitor;

            Origin       = Anchor.TopRight;
            AutoSizeAxes = Axes.Both;
            Alpha        = alpha_when_inactive;

            bool hasCounters = false;

            for (int i = 0; i < (int)StatisticsCounterType.AmountTypes; ++i)
            {
                if (monitor.Counters[i] != null)
                {
                    hasCounters = true;
                }
            }

            Children = new Drawable[]
            {
                new Container
                {
                    AutoSizeAxes = Axes.Both,
                    Children     = new[]
                    {
                        new Container
                        {
                            Origin           = Anchor.TopRight,
                            AutoSizeAxes     = Axes.X,
                            RelativeSizeAxes = Axes.Y,
                            Position         = new Vector2(-2, 0),
                            Children         = new[]
                            {
                                labelText = new SpriteText
                                {
                                    Text     = Name,
                                    Origin   = Anchor.BottomCentre,
                                    Anchor   = Anchor.CentreLeft,
                                    Rotation = -90,
                                    Position = new Vector2(-2, 0),
                                },
                                !hasCounters ? new Container() : new Container
                                {
                                    Masking          = true,
                                    CornerRadius     = 5,
                                    AutoSizeAxes     = Axes.X,
                                    RelativeSizeAxes = Axes.Y,
                                    Children         = new Drawable[]
                                    {
                                        counterBarBackground = new Sprite
                                        {
                                            Texture          = atlas.Add(1, HEIGHT),
                                            RelativeSizeAxes = Axes.Both,
                                            Size             = new Vector2(1, 1),
                                        },
                                        new FlowContainer
                                        {
                                            Direction        = FlowDirection.HorizontalOnly,
                                            AutoSizeAxes     = Axes.X,
                                            RelativeSizeAxes = Axes.Y,
                                            Children         = from StatisticsCounterType t in Enum.GetValues(typeof(StatisticsCounterType))
                                                               where t < StatisticsCounterType.AmountTypes && monitor.Counters[(int)t] != null
                                                               select counterBars[t] = new CounterBar
                                            {
                                                Colour = getColour(t),
                                                Label  = t.ToString(),
                                            },
                                        },
                                    }
                                }
                            }
                        },
                        mainContainer = new Container
                        {
                            Size     = new Vector2(WIDTH, HEIGHT),
                            Children = new[]
                            {
                                timeBarsContainer = new Container
                                {
                                    Masking          = true,
                                    CornerRadius     = 5,
                                    RelativeSizeAxes = Axes.Both,
                                    Children         = timeBars = new[]
                                    {
                                        new TimeBar(atlas),
                                        new TimeBar(atlas),
                                    },
                                },
                                fpsDisplay = new FpsDisplay(monitor.Clock)
                                {
                                    Anchor = Anchor.BottomRight,
                                    Origin = Anchor.BottomRight,
                                },
                                overlayContainer = new Container
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Alpha            = 0,
                                    Children         = new []
                                    {
                                        new FlowContainer
                                        {
                                            Anchor       = Anchor.TopRight,
                                            Origin       = Anchor.TopRight,
                                            AutoSizeAxes = Axes.Both,
                                            Spacing      = new Vector2(5, 1),
                                            Padding      = new MarginPadding {
                                                Right = 5
                                            },
                                            Children = from PerformanceCollectionType t in Enum.GetValues(typeof(PerformanceCollectionType))
                                                       where t < PerformanceCollectionType.Empty
                                                       select legendMapping[(int)t] = new SpriteText
                                            {
                                                Colour = getColour(t),
                                                Text   = t.ToString(),
                                                Alpha  = 0
                                            },
                                        },
                                        new SpriteText
                                        {
                                            Padding = new MarginPadding {
                                                Left = 4
                                            },
                                            Text = $@"{VISIBLE_MS_RANGE}ms"
                                        },
                                        new SpriteText
                                        {
                                            Padding = new MarginPadding {
                                                Left = 4
                                            },
                                            Text   = @"0ms",
                                            Anchor = Anchor.BottomLeft,
                                            Origin = Anchor.BottomLeft
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
            };

            textureBufferStack = new BufferStack <byte>(timeBars.Length * WIDTH);
        }