Exemplo n.º 1
0
        /// <inheritdoc />
        protected override void OnLoad()
        {
            Title = $"Box2DSharp Testbed - Runtime Version: {_environment}";
            var testBaseType = typeof(TestBase);
            var testTypes    = typeof(HelloWorld).Assembly.GetTypes()
                               .Where(e => testBaseType.IsAssignableFrom(e) && !e.IsAbstract && e.GetCustomAttribute <TestCaseAttribute>() != null)
                               .ToHashSet();
            var inheritedTest = this.GetType()
                                .Assembly.GetTypes()
                                .Where(
                e => testBaseType.IsAssignableFrom(e) &&
                e.GetCustomAttribute <TestInheritAttribute>() != null &&
                e.GetCustomAttribute <TestCaseAttribute>() != null)
                                .ToList();

            foreach (var type in inheritedTest)
            {
                testTypes.Remove(type.BaseType);
            }

            var typeList = new List <Type>(testTypes.Count + inheritedTest.Count);

            typeList.AddRange(testTypes);
            typeList.AddRange(inheritedTest);
            Global.SetupTestCases(typeList);

            GL.ClearColor(0.2f, 0.2f, 0.2f, 1.0f);
            _controller = new ImGuiController(Size.X, Size.Y);
            DebugDrawer.Create();

            _currentTestIndex = Math.Clamp(_currentTestIndex, 0, Global.Tests.Count - 1);
            _testSelected     = _currentTestIndex;
            LoadTest(_testSelected);
            base.OnLoad();
        }