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;
5using osu.Framework.Allocation;
6using osu.Framework.Graphics.Sprites;
7using osu.Framework.Input.Events;
8
9namespace osu.Framework.Graphics.Visualisation
10{
11 internal class TreeContainer : ToolWindow
12 {
13 private readonly SpriteText waitingText;
14
15 public Action ChooseTarget;
16 public Action GoUpOneParent;
17 public Action ToggleInspector;
18
19 internal DrawableInspector DrawableInspector { get; private set; }
20
21 [Resolved]
22 private DrawVisualiser visualiser { get; set; }
23
24 public VisualisedDrawable Target
25 {
26 set
27 {
28 if (value == null)
29 ScrollContent.Clear(false);
30 else
31 ScrollContent.Child = value;
32 }
33 }
34
35 public TreeContainer()
36 : base("Draw Visualiser", "(Ctrl+F1 to toggle)")
37 {
38 AddInternal(waitingText = new SpriteText
39 {
40 Text = @"Waiting for target selection...",
41 Font = FrameworkFont.Regular,
42 Anchor = Anchor.Centre,
43 Origin = Anchor.Centre,
44 });
45
46 AddButton(@"choose target", () => ChooseTarget?.Invoke());
47 AddButton(@"up one parent", () => GoUpOneParent?.Invoke());
48 AddButton(@"toggle inspector", () => ToggleInspector?.Invoke());
49
50 MainHorizontalContent.Add(DrawableInspector = new DrawableInspector());
51 }
52
53 protected override void Update()
54 {
55 waitingText.Alpha = visualiser.Searching ? 1 : 0;
56 base.Update();
57 }
58
59 protected override bool OnClick(ClickEvent e) => true;
60 }
61}