A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using System.Linq;
5using System.Reflection;
6using osu.Framework.Allocation;
7using osu.Framework.Graphics;
8using osu.Framework.Graphics.Containers;
9using osu.Framework.Graphics.Sprites;
10using osu.Framework.Graphics.UserInterface;
11using osuTK;
12
13namespace osu.Framework.Testing.Drawables.Sections
14{
15 public class ToolbarAssemblySection : ToolbarSection
16 {
17 private AssemblyDropdown assemblyDropdown;
18
19 public ToolbarAssemblySection()
20 {
21 AutoSizeAxes = Axes.X;
22 Masking = false;
23 }
24
25 [BackgroundDependencyLoader]
26 private void load(TestBrowser browser)
27 {
28 InternalChild = new FillFlowContainer
29 {
30 Spacing = new Vector2(5),
31 Direction = FillDirection.Horizontal,
32 RelativeSizeAxes = Axes.Y,
33 AutoSizeAxes = Axes.X,
34 Children = new Drawable[]
35 {
36 new SpriteText
37 {
38 Padding = new MarginPadding(5),
39 Font = FrameworkFont.Condensed,
40 Text = "Assembly"
41 },
42 assemblyDropdown = new AssemblyDropdown
43 {
44 Width = 250,
45 Current = browser.Assembly
46 },
47 new BasicCheckbox
48 {
49 LabelText = "Run all steps",
50 RightHandedCheckbox = true,
51 AutoSizeAxes = Axes.Both,
52 Anchor = Anchor.CentreLeft,
53 Origin = Anchor.CentreLeft,
54 Current = browser.RunAllSteps
55 },
56 }
57 };
58 }
59
60 public void AddAssembly(string name, Assembly assembly) => assemblyDropdown.AddAssembly(name, assembly);
61
62 private class AssemblyDropdown : BasicDropdown<Assembly>
63 {
64 public void AddAssembly(string name, Assembly assembly)
65 {
66 if (assembly == null) return;
67
68 foreach (var item in MenuItems.ToArray())
69 {
70 if (item.Text.Value.ToString().Contains("dynamic"))
71 RemoveDropdownItem(item.Value);
72 }
73
74 AddDropdownItem(name, assembly);
75 }
76 }
77 }
78}