1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 14:52:57 +08:00

Merge remote-tracking branch 'upstream/master' into fix-info-wedge

This commit is contained in:
Dean Herbert 2017-12-25 01:06:56 +09:00
commit fa95612fb7
5 changed files with 65 additions and 55 deletions

View File

@ -170,6 +170,7 @@ namespace osu.Game.Rulesets.Osu.Objects
StackHeight = StackHeight, StackHeight = StackHeight,
Scale = Scale, Scale = Scale,
ComboColour = ComboColour, ComboColour = ComboColour,
Samples = new SampleInfoList(RepeatSamples[repeat])
}); });
} }
} }

View File

@ -3,19 +3,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
[TestFixture]
public class TestCaseNotificationOverlay : OsuTestCase public class TestCaseNotificationOverlay : OsuTestCase
{ {
private readonly NotificationOverlay manager; private readonly NotificationOverlay manager;
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
public TestCaseNotificationOverlay() public TestCaseNotificationOverlay()
{ {
@ -24,15 +22,14 @@ namespace osu.Game.Tests.Visual
Content.Add(manager = new NotificationOverlay Content.Add(manager = new NotificationOverlay
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight
}); });
AddToggleStep(@"show", state => manager.State = state ? Visibility.Visible : Visibility.Hidden); AddStep(@"toggle", manager.ToggleVisibility);
AddStep(@"simple #1", sendHelloNotification);
AddStep(@"simple #1", sendNotification1); AddStep(@"simple #2", sendAmazingNotification);
AddStep(@"simple #2", sendNotification2); AddStep(@"progress #1", sendUploadProgress);
AddStep(@"progress #1", sendProgress1); AddStep(@"progress #2", sendDownloadProgress);
AddStep(@"progress #2", sendProgress2);
AddStep(@"barrage", () => sendBarrage()); AddStep(@"barrage", () => sendBarrage());
} }
@ -41,16 +38,16 @@ namespace osu.Game.Tests.Visual
switch (RNG.Next(0, 4)) switch (RNG.Next(0, 4))
{ {
case 0: case 0:
sendNotification1(); sendHelloNotification();
break; break;
case 1: case 1:
sendNotification2(); sendAmazingNotification();
break; break;
case 2: case 2:
sendProgress1(); sendUploadProgress();
break; break;
case 3: case 3:
sendProgress2(); sendDownloadProgress();
break; break;
} }
@ -80,7 +77,7 @@ namespace osu.Game.Tests.Visual
} }
} }
private void sendProgress2() private void sendDownloadProgress()
{ {
var n = new ProgressNotification var n = new ProgressNotification
{ {
@ -91,9 +88,7 @@ namespace osu.Game.Tests.Visual
progressingNotifications.Add(n); progressingNotifications.Add(n);
} }
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>(); private void sendUploadProgress()
private void sendProgress1()
{ {
var n = new ProgressNotification var n = new ProgressNotification
{ {
@ -104,12 +99,12 @@ namespace osu.Game.Tests.Visual
progressingNotifications.Add(n); progressingNotifications.Add(n);
} }
private void sendNotification2() private void sendAmazingNotification()
{ {
manager.Post(new SimpleNotification { Text = @"You are amazing" }); manager.Post(new SimpleNotification { Text = @"You are amazing" });
} }
private void sendNotification1() private void sendHelloNotification()
{ {
manager.Post(new SimpleNotification { Text = @"Welcome to osu!. Enjoy your stay!" }); manager.Post(new SimpleNotification { Text = @"Welcome to osu!. Enjoy your stay!" });
} }

View File

@ -37,7 +37,7 @@ namespace osu.Game
private MusicController musicController; private MusicController musicController;
private NotificationOverlay notificationOverlay; private NotificationOverlay notifications;
private DialogOverlay dialogOverlay; private DialogOverlay dialogOverlay;
@ -136,7 +136,7 @@ namespace osu.Game
if (s.Beatmap == null) if (s.Beatmap == null)
{ {
notificationOverlay.Post(new SimpleNotification notifications.Post(new SimpleNotification
{ {
Text = @"Tried to load a score for a beatmap we don't have!", Text = @"Tried to load a score for a beatmap we don't have!",
Icon = FontAwesome.fa_life_saver, Icon = FontAwesome.fa_life_saver,
@ -154,7 +154,7 @@ namespace osu.Game
base.LoadComplete(); base.LoadComplete();
// hook up notifications to components. // hook up notifications to components.
BeatmapManager.PostNotification = n => notificationOverlay?.Post(n); BeatmapManager.PostNotification = n => notifications?.Post(n);
BeatmapManager.GetStableStorage = GetStorageForStableInstall; BeatmapManager.GetStableStorage = GetStorageForStableInstall;
AddRange(new Drawable[] AddRange(new Drawable[]
@ -207,8 +207,9 @@ namespace osu.Game
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}, overlayContent.Add); }, overlayContent.Add);
loadComponentSingleFile(notificationOverlay = new NotificationOverlay loadComponentSingleFile(notifications = new NotificationOverlay
{ {
GetToolbarHeight = () => ToolbarOffset,
Depth = -4, Depth = -4,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
@ -223,7 +224,7 @@ namespace osu.Game
{ {
if (entry.Level < LogLevel.Important) return; if (entry.Level < LogLevel.Important) return;
notificationOverlay.Post(new SimpleNotification notifications.Post(new SimpleNotification
{ {
Text = $@"{entry.Level}: {entry.Message}" Text = $@"{entry.Level}: {entry.Message}"
}); });
@ -236,7 +237,7 @@ namespace osu.Game
dependencies.Cache(userProfile); dependencies.Cache(userProfile);
dependencies.Cache(musicController); dependencies.Cache(musicController);
dependencies.Cache(beatmapSetOverlay); dependencies.Cache(beatmapSetOverlay);
dependencies.Cache(notificationOverlay); dependencies.Cache(notifications);
dependencies.Cache(dialogOverlay); dependencies.Cache(dialogOverlay);
// ensure only one of these overlays are open at once. // ensure only one of these overlays are open at once.
@ -271,19 +272,21 @@ namespace osu.Game
}; };
} }
settings.StateChanged += delegate Action<Visibility> stateChanged = delegate
{ {
switch (settings.State) float offset = 0;
{
case Visibility.Hidden: if (settings.State == Visibility.Visible)
intro.MoveToX(0, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint); offset += ToolbarButton.WIDTH / 2;
break; if (notifications.State == Visibility.Visible)
case Visibility.Visible: offset -= ToolbarButton.WIDTH / 2;
intro.MoveToX(SettingsOverlay.SIDEBAR_WIDTH / 2, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
break; intro.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
}
}; };
settings.StateChanged += stateChanged;
notifications.StateChanged += stateChanged;
Cursor.State = Visibility.Hidden; Cursor.State = Visibility.Hidden;
} }
@ -351,7 +354,7 @@ namespace osu.Game
direct.State = Visibility.Hidden; direct.State = Visibility.Hidden;
social.State = Visibility.Hidden; social.State = Visibility.Hidden;
userProfile.State = Visibility.Hidden; userProfile.State = Visibility.Hidden;
notificationOverlay.State = Visibility.Hidden; notifications.State = Visibility.Hidden;
} }
private void screenChanged(Screen newScreen) private void screenChanged(Screen newScreen)

View File

@ -10,6 +10,7 @@ using osu.Game.Overlays.Notifications;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using System;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
@ -19,9 +20,13 @@ namespace osu.Game.Overlays
public const float TRANSITION_LENGTH = 600; public const float TRANSITION_LENGTH = 600;
private ScrollContainer scrollContainer;
private FlowContainer<NotificationSection> sections; private FlowContainer<NotificationSection> sections;
/// <summary>
/// Provide a source for the toolbar height.
/// </summary>
public Func<float> GetToolbarHeight;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
@ -36,12 +41,12 @@ namespace osu.Game.Overlays
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.Black, Colour = Color4.Black,
Alpha = 0.6f, Alpha = 0.6f
}, },
scrollContainer = new OsuScrollContainer new OsuScrollContainer
{ {
Masking = true,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = Toolbar.Toolbar.HEIGHT },
Children = new[] Children = new[]
{ {
sections = new FillFlowContainer<NotificationSection> sections = new FillFlowContainer<NotificationSection>
@ -55,14 +60,14 @@ namespace osu.Game.Overlays
{ {
Title = @"Notifications", Title = @"Notifications",
ClearText = @"Clear All", ClearText = @"Clear All",
AcceptTypes = new[] { typeof(SimpleNotification) }, AcceptTypes = new[] { typeof(SimpleNotification) }
}, },
new NotificationSection new NotificationSection
{ {
Title = @"Running Tasks", Title = @"Running Tasks",
ClearText = @"Cancel All", ClearText = @"Cancel All",
AcceptTypes = new[] { typeof(ProgressNotification) }, AcceptTypes = new[] { typeof(ProgressNotification) }
}, }
} }
} }
} }
@ -103,14 +108,8 @@ namespace osu.Game.Overlays
{ {
base.PopIn(); base.PopIn();
scrollContainer.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
this.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint); this.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(1, TRANSITION_LENGTH / 2); this.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint);
}
private void markAllRead()
{
sections.Children.ForEach(s => s.MarkAllRead());
} }
protected override void PopOut() protected override void PopOut()
@ -120,7 +119,19 @@ namespace osu.Game.Overlays
markAllRead(); markAllRead();
this.MoveToX(width, TRANSITION_LENGTH, Easing.OutQuint); this.MoveToX(width, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(0, TRANSITION_LENGTH / 2); this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
}
private void markAllRead()
{
sections.Children.ForEach(s => s.MarkAllRead());
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
} }
} }
} }

View File

@ -24,7 +24,7 @@ namespace osu.Game.Overlays
public const float TRANSITION_LENGTH = 600; public const float TRANSITION_LENGTH = 600;
public const float SIDEBAR_WIDTH = Sidebar.DEFAULT_WIDTH; private const float sidebar_width = Sidebar.DEFAULT_WIDTH;
protected const float WIDTH = 400; protected const float WIDTH = 400;
@ -102,7 +102,7 @@ namespace osu.Game.Overlays
if (showSidebar) if (showSidebar)
{ {
AddInternal(Sidebar = new Sidebar { Width = SIDEBAR_WIDTH }); AddInternal(Sidebar = new Sidebar { Width = sidebar_width });
SectionsContainer.SelectedSection.ValueChanged += section => SectionsContainer.SelectedSection.ValueChanged += section =>
{ {
@ -167,7 +167,7 @@ namespace osu.Game.Overlays
ContentContainer.MoveToX(-WIDTH, TRANSITION_LENGTH, Easing.OutQuint); ContentContainer.MoveToX(-WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
Sidebar?.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, Easing.OutQuint); Sidebar?.MoveToX(-sidebar_width, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint); this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
searchTextBox.HoldFocus = false; searchTextBox.HoldFocus = false;