Exemplo n.º 1
0
        private void load(Storage storage, GameHost host, FrameworkConfigManager frameworkConfig, FontStore fonts, Game game, AudioManager audio)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            exit = host.Exit;

            audio.AddAdjustment(AdjustableProperty.Frequency, audioRateAdjust);

            var resources = game.Resources;

            //Roboto
            game.AddFont(resources, @"Fonts/Roboto/Roboto-Regular");
            game.AddFont(resources, @"Fonts/Roboto/Roboto-Bold");

            //RobotoCondensed
            game.AddFont(resources, @"Fonts/RobotoCondensed/RobotoCondensed-Regular");
            game.AddFont(resources, @"Fonts/RobotoCondensed/RobotoCondensed-Bold");

            showLogOverlay = frameworkConfig.GetBindable <bool>(FrameworkSetting.ShowLogOverlay);

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = test_list_width
                    },
                    Children = new Drawable[]
                    {
                        new SafeAreaContainer
                        {
                            SafeAreaOverrideEdges = Edges.Right | Edges.Bottom,
                            RelativeSizeAxes      = Axes.Both,
                            Child = testContentContainer = new Container
                            {
                                Clock            = framedClock,
                                RelativeSizeAxes = Axes.Both,
                                Padding          = new MarginPadding {
                                    Top = 50
                                },
                                Child = compilingNotice = new Container
                                {
                                    Alpha        = 0,
                                    Anchor       = Anchor.Centre,
                                    Origin       = Anchor.Centre,
                                    Masking      = true,
                                    Depth        = float.MinValue,
                                    CornerRadius = 5,
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new Drawable[]
                                    {
                                        new Box
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Colour           = Color4.Black,
                                        },
                                        new SpriteText
                                        {
                                            Font = new FontUsage(size: 30),
                                            Text = @"Compiling new version..."
                                        }
                                    },
                                }
                            }
                        },
                        toolbar = new TestBrowserToolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                        },
                    }
                },
                leftContainer = new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(test_list_width, 1),
                    Masking          = true,
                    Children         = new Drawable[]
                    {
                        new SafeAreaContainer
                        {
                            SafeAreaOverrideEdges = Edges.Left | Edges.Top | Edges.Bottom,
                            RelativeSizeAxes      = Axes.Both,
                            Child = new Box
                            {
                                Colour           = FrameworkColour.GreenDark,
                                RelativeSizeAxes = Axes.Both
                            }
                        },
                        new FillFlowContainer
                        {
                            Direction        = FillDirection.Vertical,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                searchTextBox = new TestBrowserTextBox
                                {
                                    Height           = 25,
                                    RelativeSizeAxes = Axes.X,
                                    PlaceholderText  = "type to search",
                                    Depth            = -1,
                                },
                                new BasicScrollContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Masking          = false,
                                    Child            = leftFlowContainer = new SearchContainer <TestGroupButton>
                                    {
                                        Padding = new MarginPadding {
                                            Top = 3, Bottom = 20
                                        },
                                        Direction        = FillDirection.Vertical,
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                    }
                                }
                            }
                        }
                    }
                },
            };

            searchTextBox.OnCommit += delegate
            {
                var firstTest = leftFlowContainer.Where(b => b.IsPresent).SelectMany(b => b.FilterableChildren).OfType <TestSubButton>()
                                .FirstOrDefault(b => b.MatchingFilter)?.TestType;
                if (firstTest != null)
                {
                    LoadTest(firstTest);
                }
            };

            searchTextBox.Current.ValueChanged += e => leftFlowContainer.SearchTerm = e.NewValue;

            if (RuntimeInfo.IsDesktop)
            {
                backgroundCompiler = new DynamicClassCompiler <TestScene>();
                backgroundCompiler.CompilationStarted  += compileStarted;
                backgroundCompiler.CompilationFinished += compileFinished;
                backgroundCompiler.CompilationFailed   += compileFailed;

                try
                {
                    backgroundCompiler.Start();
                }
                catch
                {
                    //it's okay for this to fail for now.
                }
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AddAssembly(asm.GetName().Name, asm);
            }

            Assembly.BindValueChanged(updateList);
            RunAllSteps.BindValueChanged(v => runTests(null));
            PlaybackRate.BindValueChanged(e =>
            {
                rateAdjustClock.Rate  = e.NewValue;
                audioRateAdjust.Value = e.NewValue;
            }, true);
        }
Exemplo n.º 2
0
        private void load(Storage storage, GameHost host, AudioManager audio)
        {
            interactive = host.Window != null;
            config      = new TestBrowserConfig(storage);

            audio.AddAdjustment(AdjustableProperty.Frequency, audioRateAdjust);

            var rateAdjustClock = new StopwatchClock(true);
            var framedClock     = new FramedClock(rateAdjustClock);

            Children = new Drawable[]
            {
                mainContainer = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = test_list_width
                    },
                    Children = new Drawable[]
                    {
                        new SafeAreaContainer
                        {
                            SafeAreaOverrideEdges = Edges.Right | Edges.Bottom,
                            RelativeSizeAxes      = Axes.Both,
                            Child = testContentContainer = new Container
                            {
                                Clock            = framedClock,
                                RelativeSizeAxes = Axes.Both,
                                Padding          = new MarginPadding {
                                    Top = 50
                                },
                                Child = compilingNotice = new Container
                                {
                                    Alpha        = 0,
                                    Anchor       = Anchor.Centre,
                                    Origin       = Anchor.Centre,
                                    Masking      = true,
                                    Depth        = float.MinValue,
                                    CornerRadius = 5,
                                    AutoSizeAxes = Axes.Both,
                                    Children     = new Drawable[]
                                    {
                                        new Box
                                        {
                                            RelativeSizeAxes = Axes.Both,
                                            Colour           = Color4.Black,
                                        },
                                        new SpriteText
                                        {
                                            Font = FrameworkFont.Regular.With(size: 30),
                                            Text = @"Compiling new version..."
                                        }
                                    },
                                }
                            }
                        },
                        toolbar = new TestBrowserToolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 50,
                        },
                    }
                },
                leftContainer = new Container
                {
                    RelativeSizeAxes = Axes.Y,
                    Size             = new Vector2(test_list_width, 1),
                    Masking          = true,
                    Children         = new Drawable[]
                    {
                        new SafeAreaContainer
                        {
                            SafeAreaOverrideEdges = Edges.Left | Edges.Top | Edges.Bottom,
                            RelativeSizeAxes      = Axes.Both,
                            Child = new Box
                            {
                                Colour           = FrameworkColour.GreenDark,
                                RelativeSizeAxes = Axes.Both
                            }
                        },
                        new FillFlowContainer
                        {
                            Direction        = FillDirection.Vertical,
                            RelativeSizeAxes = Axes.Both,
                            Children         = new Drawable[]
                            {
                                searchTextBox = new TestBrowserTextBox
                                {
                                    Height           = 25,
                                    RelativeSizeAxes = Axes.X,
                                    PlaceholderText  = "type to search",
                                    Depth            = -1,
                                },
                                new BasicScrollContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Masking          = false,
                                    Child            = leftFlowContainer = new SearchContainer <TestGroupButton>
                                    {
                                        AllowNonContiguousMatching = true,
                                        Padding = new MarginPadding {
                                            Top = 3, Bottom = 20
                                        },
                                        Direction        = FillDirection.Vertical,
                                        AutoSizeAxes     = Axes.Y,
                                        RelativeSizeAxes = Axes.X,
                                    }
                                }
                            }
                        }
                    }
                },
            };

            searchTextBox.OnCommit += delegate
            {
                var firstTest = leftFlowContainer.Where(b => b.IsPresent).SelectMany(b => b.FilterableChildren).OfType <TestSubButton>()
                                .FirstOrDefault(b => b.MatchingFilter)?.TestType;
                if (firstTest != null)
                {
                    LoadTest(firstTest);
                }
            };

            searchTextBox.Current.ValueChanged += e => leftFlowContainer.SearchTerm = e.NewValue;

            if (RuntimeInfo.IsDesktop)
            {
                HotReloadCallbackReceiver.CompilationFinished += compileFinished;
            }

            foreach (Assembly asm in assemblies)
            {
                toolbar.AddAssembly(asm.GetName().Name, asm);
            }

            Assembly.BindValueChanged(updateList);
            RunAllSteps.BindValueChanged(v => runTests(null));
            PlaybackRate.BindValueChanged(e =>
            {
                rateAdjustClock.Rate  = e.NewValue;
                audioRateAdjust.Value = e.NewValue;
            }, true);
        }