-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Copy pathMenuTip.cs
132 lines (117 loc) · 4.55 KB
/
MenuTip.cs
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Copyright (c) ppy Pty Ltd <[email protected]>. 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.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osuTK;
using osuTK.Graphics;
using osu.Game.Localisation;
namespace osu.Game.Screens.Menu
{
public partial class MenuTip : CompositeDrawable
{
[Resolved]
private OsuConfigManager config { get; set; } = null!;
private LinkFlowContainer textFlow = null!;
private Bindable<bool> showMenuTips = null!;
[BackgroundDependencyLoader]
private void load()
{
AutoSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerExponent = 2.5f,
CornerRadius = 15,
Children = new Drawable[]
{
new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
Alpha = 0.4f,
},
}
},
textFlow = new LinkFlowContainer
{
Width = 600,
AutoSizeAxes = Axes.Y,
TextAnchor = Anchor.TopCentre,
Spacing = new Vector2(0, 2),
Margin = new MarginPadding(10)
},
};
}
protected override void LoadComplete()
{
base.LoadComplete();
showMenuTips = config.GetBindable<bool>(OsuSetting.MenuTips);
showMenuTips.BindValueChanged(_ => ShowNextTip(), true);
}
public void ShowNextTip()
{
if (!showMenuTips.Value)
{
this.FadeOut(100, Easing.OutQuint);
return;
}
static void formatRegular(SpriteText t) => t.Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular);
static void formatSemiBold(SpriteText t) => t.Font = OsuFont.GetFont(size: 16, weight: FontWeight.SemiBold);
var tip = getRandomTip();
textFlow.Clear();
textFlow.AddParagraph(MenuTipStrings.MenuTipTitle, formatSemiBold);
textFlow.AddParagraph(tip, formatRegular);
this.FadeInFromZero(200, Easing.OutQuint)
.Delay(1000 + 80 * tip.ToString().Length)
.Then()
.FadeOutFromOne(2000, Easing.OutQuint);
}
private LocalisableString getRandomTip()
{
LocalisableString[] tips =
{
MenuTipStrings.ToggleToolbarShortcut,
MenuTipStrings.GameSettingsShortcut,
MenuTipStrings.DynamicSettings,
MenuTipStrings.NewFeaturesAreComingOnline,
MenuTipStrings.UIScalingSettings,
MenuTipStrings.ScreenScalingSettings,
MenuTipStrings.FreeOsuDirect,
MenuTipStrings.ReplaySeeking,
MenuTipStrings.MultithreadingSupport,
MenuTipStrings.TryNewMods,
MenuTipStrings.EmbeddedWebContent,
MenuTipStrings.BeatmapRightClick,
MenuTipStrings.TemporaryDeleteOperations,
MenuTipStrings.DiscoverPlaylists,
MenuTipStrings.ToggleAdvancedFPSCounter,
MenuTipStrings.GlobalStatisticsShortcut,
MenuTipStrings.ReplayPausing,
MenuTipStrings.ConfigurableHotkeys,
MenuTipStrings.PeekHUDWhenHidden,
MenuTipStrings.SkinEditor,
MenuTipStrings.DragAndDropImageInSkinEditor,
MenuTipStrings.ModPresets,
MenuTipStrings.ModCustomisationSettings,
MenuTipStrings.RandomSkinShortcut,
MenuTipStrings.ToggleReplaySettingsShortcut,
MenuTipStrings.CopyModsFromScore,
MenuTipStrings.AutoplayBeatmapShortcut,
MenuTipStrings.LazerIsNotAWord
};
return tips[RNG.Next(0, tips.Length)];
}
}
}