-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathReplayOverlay.cs
More file actions
86 lines (71 loc) · 2.73 KB
/
ReplayOverlay.cs
File metadata and controls
86 lines (71 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Input.Bindings;
namespace osu.Game.Screens.Play.HUD
{
public partial class ReplayOverlay : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{
public ReplaySettingsOverlay Settings { get; private set; } = null!;
private const int fade_duration = 200;
private Bindable<bool> configSettingsOverlay = null!;
private Container messageContainer = null!;
private Container content = null!;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
RelativeSizeAxes = Axes.Both;
configSettingsOverlay = config.GetBindable<bool>(OsuSetting.ReplaySettingsOverlay);
InternalChild = content = new Container
{
Alpha = 0,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
messageContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue,
},
Settings = new ReplaySettingsOverlay(),
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
configSettingsOverlay.BindValueChanged(_ => updateVisibility(), true);
}
private void updateVisibility()
{
if (configSettingsOverlay.Value)
content.FadeIn(fade_duration, Easing.OutQuint);
else
content.FadeOut(fade_duration, Easing.OutQuint);
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Repeat)
return false;
switch (e.Action)
{
case GlobalAction.ToggleReplaySettings:
configSettingsOverlay.Value = !configSettingsOverlay.Value;
return true;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
public override void Show() => this.FadeIn(fade_duration, Easing.OutQuint);
public override void Hide() => this.FadeOut(fade_duration, Easing.OutQuint);
public void SetMessage(ScrollingMessage scrollingMessage) => messageContainer.Child = scrollingMessage;
}
}