1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 19:22:56 +08:00

Merge branch 'master' of github.com:ppy/osu into better-transforms

# Conflicts:
#	osu-framework
This commit is contained in:
Thomas Müller 2017-07-21 11:15:26 +02:00
commit 2cd8f6b30c
17 changed files with 185 additions and 105 deletions

@ -1 +1 @@
Subproject commit 1f117839890835c9142680df55c94e22daf7d783 Subproject commit 82044038805e640ae4602be2fe4772bf09d23e94

View File

@ -22,14 +22,11 @@ namespace osu.Game.Beatmaps
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>(new Mod[] { }); public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
public readonly bool WithStoryboard; protected WorkingBeatmap(BeatmapInfo beatmapInfo)
protected WorkingBeatmap(BeatmapInfo beatmapInfo, bool withStoryboard = false)
{ {
BeatmapInfo = beatmapInfo; BeatmapInfo = beatmapInfo;
BeatmapSetInfo = beatmapInfo.BeatmapSet; BeatmapSetInfo = beatmapInfo.BeatmapSet;
Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo.Metadata; Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo.Metadata;
WithStoryboard = withStoryboard;
Mods.ValueChanged += mods => applyRateAdjustments(); Mods.ValueChanged += mods => applyRateAdjustments();
} }

View File

@ -291,7 +291,7 @@ namespace osu.Game.Database
if (beatmapInfo.Metadata == null) if (beatmapInfo.Metadata == null)
beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata;
WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard); WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo);
previous?.TransferTo(working); previous?.TransferTo(working);

View File

@ -14,8 +14,8 @@ namespace osu.Game.Database
{ {
private readonly BeatmapDatabase database; private readonly BeatmapDatabase database;
public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, bool withStoryboard = false) public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo)
: base(beatmapInfo, withStoryboard) : base(beatmapInfo)
{ {
this.database = database; this.database = database;
} }
@ -37,7 +37,7 @@ namespace osu.Game.Database
beatmap = decoder.Decode(stream); beatmap = decoder.Decode(stream);
} }
if (beatmap == null || !WithStoryboard || BeatmapSetInfo.StoryboardFile == null) if (beatmap == null || BeatmapSetInfo.StoryboardFile == null)
return beatmap; return beatmap;
using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile))) using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile)))

View File

@ -174,11 +174,11 @@ namespace osu.Game
LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add);
LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add);
LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add);
LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -1 }, mainContent.Add);
LoadComponentAsync(settings = new SettingsOverlay { Depth = -1 }, overlayContent.Add); LoadComponentAsync(settings = new SettingsOverlay { Depth = -1 }, overlayContent.Add);
LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add);
LoadComponentAsync(musicController = new MusicController LoadComponentAsync(musicController = new MusicController
{ {
Depth = -2, Depth = -3,
Position = new Vector2(0, Toolbar.HEIGHT), Position = new Vector2(0, Toolbar.HEIGHT),
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
@ -186,14 +186,14 @@ namespace osu.Game
LoadComponentAsync(notificationManager = new NotificationManager LoadComponentAsync(notificationManager = new NotificationManager
{ {
Depth = -2, Depth = -3,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}, overlayContent.Add); }, overlayContent.Add);
LoadComponentAsync(dialogOverlay = new DialogOverlay LoadComponentAsync(dialogOverlay = new DialogOverlay
{ {
Depth = -4, Depth = -5,
}, overlayContent.Add); }, overlayContent.Add);
Logger.NewEntry += entry => Logger.NewEntry += entry =>
@ -220,7 +220,7 @@ namespace osu.Game
LoadComponentAsync(Toolbar = new Toolbar LoadComponentAsync(Toolbar = new Toolbar
{ {
Depth = -3, Depth = -4,
OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); }, OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
}, overlayContent.Add); }, overlayContent.Add);

View File

@ -133,9 +133,27 @@ namespace osu.Game
Token = LocalConfig.Get<string>(OsuSetting.Token) Token = LocalConfig.Get<string>(OsuSetting.Token)
}); });
Beatmap.ValueChanged += b =>
{
// compare to last baetmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
if (lastBeatmap?.Track != b.Track)
{
// this disposal is done to stop the audio track.
// it may not be exactly what we want for cases beatmaps are reused, as it will
// trigger a fresh load of contained resources.
lastBeatmap?.Dispose();
Audio.Track.AddItem(b.Track);
}
lastBeatmap = b;
};
API.Register(this); API.Register(this);
} }
private WorkingBeatmap lastBeatmap;
public void APIStateChanged(APIAccess api, APIState state) public void APIStateChanged(APIAccess api, APIState state)
{ {
switch (state) switch (state)

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -11,6 +12,7 @@ using OpenTK.Graphics;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Users;
namespace osu.Game.Overlays.Chat namespace osu.Game.Overlays.Chat
{ {
@ -62,6 +64,8 @@ namespace osu.Game.Overlays.Chat
private const float message_padding = 200; private const float message_padding = 200;
private const float text_size = 20; private const float text_size = 20;
private Action<User> loadProfile;
private Color4 customUsernameColour; private Color4 customUsernameColour;
public ChatLine(Message message) public ChatLine(Message message)
@ -75,9 +79,10 @@ namespace osu.Game.Overlays.Chat
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours, UserProfileOverlay profile)
{ {
customUsernameColour = colours.ChatBlue; customUsernameColour = colours.ChatBlue;
loadProfile = u => profile?.ShowUser(u);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -87,8 +92,6 @@ namespace osu.Game.Overlays.Chat
bool hasBackground = !string.IsNullOrEmpty(Message.Sender.Colour); bool hasBackground = !string.IsNullOrEmpty(Message.Sender.Colour);
Drawable username = new OsuSpriteText Drawable username = new OsuSpriteText
{ {
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
Font = @"Exo2.0-BoldItalic", Font = @"Exo2.0-BoldItalic",
Text = $@"{Message.Sender.Username}" + (hasBackground ? "" : ":"), Text = $@"{Message.Sender.Username}" + (hasBackground ? "" : ":"),
Colour = hasBackground ? customUsernameColour : username_colours[Message.UserId % username_colours.Length], Colour = hasBackground ? customUsernameColour : username_colours[Message.UserId % username_colours.Length],
@ -132,7 +135,7 @@ namespace osu.Game.Overlays.Chat
new Container new Container
{ {
Size = new Vector2(message_padding, text_size), Size = new Vector2(message_padding, text_size),
Children = new[] Children = new Drawable[]
{ {
new OsuSpriteText new OsuSpriteText
{ {
@ -144,7 +147,14 @@ namespace osu.Game.Overlays.Chat
TextSize = text_size * 0.75f, TextSize = text_size * 0.75f,
Alpha = 0.4f, Alpha = 0.4f,
}, },
username new ClickableContainer
{
AutoSizeAxes = Axes.Both,
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
Child = username,
Action = () => loadProfile(Message.Sender),
},
} }
}, },
new Container new Container

View File

@ -3,9 +3,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -15,7 +13,6 @@ using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Extensions;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -30,7 +27,6 @@ namespace osu.Game.Overlays.Music
private FilterControl filter; private FilterControl filter;
private PlaylistList list; private PlaylistList list;
private TrackManager trackManager;
private BeatmapDatabase beatmaps; private BeatmapDatabase beatmaps;
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>(); private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
@ -43,7 +39,6 @@ namespace osu.Game.Overlays.Music
{ {
this.inputManager = inputManager; this.inputManager = inputManager;
this.beatmaps = beatmaps; this.beatmaps = beatmaps;
trackManager = game.Audio.Track;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -154,13 +149,7 @@ namespace osu.Game.Overlays.Music
private void playSpecified(BeatmapInfo info) private void playSpecified(BeatmapInfo info)
{ {
beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking); beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking);
beatmapBacking.Value.Track.Start();
Task.Run(() =>
{
var track = beatmapBacking.Value.Track;
trackManager.SetExclusive(track);
track.Start();
}).ContinueWith(task => Schedule(task.ThrowIfFaulted), TaskContinuationOptions.OnlyOnFaulted);
} }
} }

View File

@ -12,16 +12,20 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Users; using osu.Game.Users;
using System.Diagnostics;
using System.Globalization;
namespace osu.Game.Overlays.Profile namespace osu.Game.Overlays.Profile
{ {
public class ProfileHeader : Container public class ProfileHeader : Container
{ {
private readonly OsuTextFlowContainer infoTextLeft, infoTextRight; private readonly OsuTextFlowContainer infoTextLeft;
private readonly LinkFlowContainer infoTextRight;
private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText; private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText;
private readonly Container coverContainer, chartContainer, supporterTag; private readonly Container coverContainer, chartContainer, supporterTag;
@ -29,6 +33,7 @@ namespace osu.Game.Overlays.Profile
private readonly SpriteText levelText; private readonly SpriteText levelText;
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
private readonly Box colourBar; private readonly Box colourBar;
private readonly DrawableFlag countryFlag;
private const float cover_height = 350; private const float cover_height = 350;
private const float info_height = 150; private const float info_height = 150;
@ -114,16 +119,17 @@ namespace osu.Game.Overlays.Profile
} }
} }
}, },
new OsuSpriteText new LinkFlowContainer.LinkText
{ {
Text = user.Username, Text = user.Username,
Url = $@"https://osu.ppy.sh/users/{user.Id}",
TextSize = 30, TextSize = 30,
Font = @"Exo2.0-RegularItalic", Font = @"Exo2.0-RegularItalic",
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Y = -48 Y = -48
}, },
new DrawableFlag(user.Country?.FlagName ?? "__") countryFlag = new DrawableFlag(user.Country?.FlagName ?? "__")
{ {
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
@ -158,7 +164,7 @@ namespace osu.Game.Overlays.Profile
ParagraphSpacing = 0.8f, ParagraphSpacing = 0.8f,
LineSpacing = 0.2f LineSpacing = 0.2f
}, },
infoTextRight = new OsuTextFlowContainer(t => infoTextRight = new LinkFlowContainer(t =>
{ {
t.TextSize = 14; t.TextSize = 14;
t.Font = @"Exo2.0-RegularItalic"; t.Font = @"Exo2.0-RegularItalic";
@ -350,6 +356,7 @@ namespace osu.Game.Overlays.Profile
{ {
infoTextLeft.AddText("from "); infoTextLeft.AddText("from ");
infoTextLeft.AddText(user.Country.FullName, boldItalic); infoTextLeft.AddText(user.Country.FullName, boldItalic);
countryFlag.FlagName = user.Country.FlagName;
} }
infoTextLeft.NewParagraph(); infoTextLeft.NewParagraph();
@ -373,14 +380,22 @@ namespace osu.Game.Overlays.Profile
infoTextLeft.AddText(string.Join(", ", user.PlayStyle), boldItalic); infoTextLeft.AddText(string.Join(", ", user.PlayStyle), boldItalic);
} }
string websiteWithoutProtcol = user.Website;
if (!string.IsNullOrEmpty(websiteWithoutProtcol))
{
int protocolIndex = websiteWithoutProtcol.IndexOf("//", StringComparison.Ordinal);
if (protocolIndex >= 0)
websiteWithoutProtcol = websiteWithoutProtcol.Substring(protocolIndex + 2);
}
tryAddInfoRightLine(FontAwesome.fa_map_marker, user.Location); tryAddInfoRightLine(FontAwesome.fa_map_marker, user.Location);
tryAddInfoRightLine(FontAwesome.fa_heart_o, user.Intrerests); tryAddInfoRightLine(FontAwesome.fa_heart_o, user.Intrerests);
tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation); tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation);
infoTextRight.NewParagraph(); infoTextRight.NewParagraph();
if (!string.IsNullOrEmpty(user.Twitter)) if (!string.IsNullOrEmpty(user.Twitter))
tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter); tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}");
tryAddInfoRightLine(FontAwesome.fa_globe, user.Website); tryAddInfoRightLine(FontAwesome.fa_globe, websiteWithoutProtcol, user.Website);
tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype); tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype, @"skype:" + user.Skype + @"?chat");
if (user.Statistics != null) if (user.Statistics != null)
{ {
@ -390,7 +405,7 @@ namespace osu.Game.Overlays.Profile
scoreText.Add(createScoreText("Ranked Score")); scoreText.Add(createScoreText("Ranked Score"));
scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0"))); scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0")));
scoreText.Add(createScoreText("Accuracy")); scoreText.Add(createScoreText("Accuracy"));
scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy}%")); scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy.ToString("0.##", CultureInfo.CurrentCulture)}%"));
scoreText.Add(createScoreText("Play Count")); scoreText.Add(createScoreText("Play Count"));
scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0"))); scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0")));
scoreText.Add(createScoreText("Total Score")); scoreText.Add(createScoreText("Total Score"));
@ -433,12 +448,12 @@ namespace osu.Game.Overlays.Profile
Text = text Text = text
}; };
private void tryAddInfoRightLine(FontAwesome icon, string str) private void tryAddInfoRightLine(FontAwesome icon, string str, string url = null)
{ {
if (string.IsNullOrEmpty(str)) return; if (string.IsNullOrEmpty(str)) return;
infoTextRight.AddIcon(icon); infoTextRight.AddIcon(icon);
infoTextRight.AddText(" " + str); infoTextRight.AddLink(" " + str, url);
infoTextRight.NewLine(); infoTextRight.NewLine();
} }
@ -479,5 +494,51 @@ namespace osu.Game.Overlays.Profile
badge.Texture = textures.Get($"Grades/{grade}"); badge.Texture = textures.Get($"Grades/{grade}");
} }
} }
private class LinkFlowContainer : OsuTextFlowContainer
{
public override bool HandleInput => true;
public LinkFlowContainer(Action<SpriteText> defaultCreationParameters = null) : base(defaultCreationParameters)
{
}
protected override SpriteText CreateSpriteText() => new LinkText();
public void AddLink(string text, string url) => AddText(text, link => ((LinkText)link).Url = url);
public class LinkText : OsuSpriteText
{
public override bool HandleInput => Url != null;
public string Url;
private Color4 hoverColour;
protected override bool OnHover(InputState state)
{
FadeColour(hoverColour, 500, EasingTypes.OutQuint);
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
FadeColour(Color4.White, 500, EasingTypes.OutQuint);
base.OnHoverLost(state);
}
protected override bool OnClick(InputState state)
{
Process.Start(Url);
return true;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
hoverColour = colours.Yellow;
}
}
}
} }
} }

View File

@ -72,8 +72,6 @@ namespace osu.Game.Screens.Menu
menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice); menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic); menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
var trackManager = audio.Track;
BeatmapSetInfo setInfo = null; BeatmapSetInfo setInfo = null;
if (!menuMusic) if (!menuMusic)
@ -106,7 +104,6 @@ namespace osu.Game.Screens.Menu
Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
track = Beatmap.Value.Track; track = Beatmap.Value.Track;
trackManager.SetExclusive(track);
welcome = audio.Sample.Get(@"welcome"); welcome = audio.Sample.Get(@"welcome");
seeya = audio.Sample.Get(@"seeya"); seeya = audio.Sample.Get(@"seeya");
@ -121,7 +118,9 @@ namespace osu.Game.Screens.Menu
Scheduler.AddDelayed(delegate Scheduler.AddDelayed(delegate
{ {
track.Start(); // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Manu.
if (menuMusic)
track.Start();
LoadComponentAsync(mainMenu = new MainMenu()); LoadComponentAsync(mainMenu = new MainMenu());

View File

@ -94,9 +94,7 @@ namespace osu.Game.Screens.Menu
{ {
if (!track.IsRunning) if (!track.IsRunning)
{ {
track.Seek(metadata.PreviewTime); track.Seek(metadata.PreviewTime != -1 ? metadata.PreviewTime : 0.4f * track.Length);
if (metadata.PreviewTime == -1)
track.Seek(track.Length * 0.4f);
track.Start(); track.Start();
} }
} }

View File

@ -35,8 +35,6 @@ namespace osu.Game.Screens.Play
internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor; internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor;
public BeatmapInfo BeatmapInfo;
public Action RestartRequested; public Action RestartRequested;
internal override bool AllowBeatmapRulesetChange => false; internal override bool AllowBeatmapRulesetChange => false;
@ -72,7 +70,7 @@ namespace osu.Game.Screens.Play
private bool loadedSuccessfully => HitRenderer?.Objects.Any() == true; private bool loadedSuccessfully => HitRenderer?.Objects.Any() == true;
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, OsuGame osu) private void load(AudioManager audio, OsuConfigManager config, OsuGame osu)
{ {
dimLevel = config.GetBindable<double>(OsuSetting.DimLevel); dimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel); mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
@ -83,10 +81,6 @@ namespace osu.Game.Screens.Play
try try
{ {
if (!Beatmap.Value.WithStoryboard)
// we need to ensure the storyboard is loaded.
Beatmap.Value = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true);
if (Beatmap.Value.Beatmap == null) if (Beatmap.Value.Beatmap == null)
throw new InvalidOperationException("Beatmap was not loaded"); throw new InvalidOperationException("Beatmap was not loaded");
@ -121,10 +115,7 @@ namespace osu.Game.Screens.Play
Track track = Beatmap.Value.Track; Track track = Beatmap.Value.Track;
if (track != null) if (track != null)
{
audio.Track.SetExclusive(track);
adjustableSourceClock = track; adjustableSourceClock = track;
}
adjustableSourceClock = (IAdjustableClock)track ?? new StopwatchClock(); adjustableSourceClock = (IAdjustableClock)track ?? new StopwatchClock();

View File

@ -25,7 +25,7 @@ namespace osu.Game.Screens.Play
return; return;
var firstHit = objects.First().StartTime; var firstHit = objects.First().StartTime;
var lastHit = (objects.Last() as IHasEndTime)?.EndTime ?? 0; var lastHit = objects.Max(o => (o as IHasEndTime)?.EndTime ?? o.StartTime);
if (lastHit == 0) if (lastHit == 0)
lastHit = objects.Last().StartTime; lastHit = objects.Last().StartTime;

View File

@ -25,6 +25,8 @@ namespace osu.Game.Screens.Select
{ {
public BeatmapInfo SelectedBeatmap => selectedPanel?.Beatmap; public BeatmapInfo SelectedBeatmap => selectedPanel?.Beatmap;
public override bool HandleInput => AllowSelection;
public Action BeatmapsChanged; public Action BeatmapsChanged;
public IEnumerable<BeatmapSetInfo> Beatmaps public IEnumerable<BeatmapSetInfo> Beatmaps
@ -133,7 +135,7 @@ namespace osu.Game.Screens.Select
public void SelectNext(int direction = 1, bool skipDifficulties = true) public void SelectNext(int direction = 1, bool skipDifficulties = true)
{ {
if (groups.Count == 0) if (groups.All(g => g.State == BeatmapGroupState.Hidden))
{ {
selectedGroup = null; selectedGroup = null;
selectedPanel = null; selectedPanel = null;
@ -228,6 +230,14 @@ namespace osu.Game.Screens.Select
private ScheduledDelegate filterTask; private ScheduledDelegate filterTask;
public bool AllowSelection = true;
public void FlushPendingFilters()
{
if (filterTask?.Completed == false)
Filter(null, false);
}
public void Filter(FilterCriteria newCriteria = null, bool debounce = true) public void Filter(FilterCriteria newCriteria = null, bool debounce = true)
{ {
if (newCriteria != null) if (newCriteria != null)
@ -259,6 +269,8 @@ namespace osu.Game.Screens.Select
}; };
filterTask?.Cancel(); filterTask?.Cancel();
filterTask = null;
if (debounce) if (debounce)
filterTask = Scheduler.AddDelayed(perform, 250); filterTask = Scheduler.AddDelayed(perform, 250);
else else

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
@ -31,7 +32,7 @@ namespace osu.Game.Screens.Select
public Action OnBack; public Action OnBack;
public Action OnStart; public Action OnStart;
private readonly FillFlowContainer buttons; private readonly FillFlowContainer<FooterButton> buttons;
public OsuLogo StartButton; public OsuLogo StartButton;
@ -43,29 +44,21 @@ namespace osu.Game.Screens.Select
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para> /// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para> /// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
/// </param> /// </param>
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) => buttons.Add(new FooterButton
{ {
var button = new FooterButton Text = text,
{ Height = play_song_select_button_height,
Text = text, Width = play_song_select_button_width,
Height = play_song_select_button_height, Depth = depth,
Width = play_song_select_button_width, SelectedColour = colour,
Depth = depth, DeselectedColour = colour.Opacity(0.5f),
SelectedColour = colour, Hotkey = hotkey,
DeselectedColour = colour.Opacity(0.5f), Hovered = updateModeLight,
Hotkey = hotkey, HoverLost = updateModeLight,
}; Action = action,
});
button.Hovered = () => updateModeLight(button); private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint);
button.HoverLost = () => updateModeLight();
button.Action = action;
buttons.Add(button);
}
private void updateModeLight(FooterButton button = null)
{
modeLight.FadeColour(button?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint);
}
public Footer() public Footer()
{ {
@ -111,7 +104,7 @@ namespace osu.Game.Screens.Select
Spacing = new Vector2(padding, 0), Spacing = new Vector2(padding, 0),
Children = new Drawable[] Children = new Drawable[]
{ {
buttons = new FillFlowContainer buttons = new FillFlowContainer<FooterButton>
{ {
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(0.2f, 0), Spacing = new Vector2(0.2f, 0),

View File

@ -105,6 +105,7 @@ namespace osu.Game.Screens.Select
if (player != null) return; if (player != null) return;
Beatmap.Value.Track.Looping = false; Beatmap.Value.Track.Looping = false;
Beatmap.Disabled = true;
LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player)); LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player));
} }

View File

@ -32,7 +32,6 @@ namespace osu.Game.Screens.Select
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
private readonly BeatmapCarousel carousel; private readonly BeatmapCarousel carousel;
private TrackManager trackManager;
private DialogOverlay dialogOverlay; private DialogOverlay dialogOverlay;
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245); private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
@ -110,7 +109,7 @@ namespace osu.Game.Screens.Select
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
SelectionChanged = carouselSelectionChanged, SelectionChanged = carouselSelectionChanged,
BeatmapsChanged = carouselBeatmapsLoaded, BeatmapsChanged = carouselBeatmapsLoaded,
StartRequested = carouselRaisedStart StartRequested = carouselRaisedStart,
}); });
Add(FilterControl = new FilterControl Add(FilterControl = new FilterControl
{ {
@ -174,7 +173,6 @@ namespace osu.Game.Screens.Select
database.BeatmapSetAdded += onBeatmapSetAdded; database.BeatmapSetAdded += onBeatmapSetAdded;
database.BeatmapSetRemoved += onBeatmapSetRemoved; database.BeatmapSetRemoved += onBeatmapSetRemoved;
trackManager = audio.Track;
dialogOverlay = dialog; dialogOverlay = dialog;
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty"); sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
@ -185,11 +183,14 @@ namespace osu.Game.Screens.Select
carousel.Beatmaps = database.GetAllWithChildren<BeatmapSetInfo>(b => !b.DeletePending); carousel.Beatmaps = database.GetAllWithChildren<BeatmapSetInfo>(b => !b.DeletePending);
Beatmap.ValueChanged += beatmap_ValueChanged; Beatmap.ValueChanged += beatmap_ValueChanged;
Beatmap.DisabledChanged += disabled => carousel.AllowSelection = !disabled;
carousel.AllowSelection = !Beatmap.Disabled;
} }
private void carouselBeatmapsLoaded() private void carouselBeatmapsLoaded()
{ {
if (Beatmap.Value != null && !Beatmap.Value.BeatmapSetInfo.DeletePending) if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false); carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false);
else else
carousel.SelectNext(); carousel.SelectNext();
@ -197,13 +198,15 @@ namespace osu.Game.Screens.Select
private void carouselRaisedStart() private void carouselRaisedStart()
{ {
var pendingSelection = selectionChangedDebounce; // if we have a pending filter operation, we want to run it now.
selectionChangedDebounce = null; // it could change selection (ie. if the ruleset has been changed).
carousel.FlushPendingFilters();
if (pendingSelection?.Completed == false) if (selectionChangedDebounce?.Completed == false)
{ {
pendingSelection.RunTask(); selectionChangedDebounce.RunTask();
pendingSelection.Cancel(); // cancel the already scheduled task. selectionChangedDebounce.Cancel(); // cancel the already scheduled task.
selectionChangedDebounce = null;
} }
OnSelected(); OnSelected();
@ -221,14 +224,26 @@ namespace osu.Game.Screens.Select
{ {
Action performLoad = delegate Action performLoad = delegate
{ {
bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID; // We may be arriving here due to another component changing the bindable Beatmap.
// In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
if (beatmap?.Equals(Beatmap.Value.BeatmapInfo) != true)
{
bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID;
Beatmap.Value = database.GetWorkingBeatmap(beatmap, Beatmap); Beatmap.Value = database.GetWorkingBeatmap(beatmap, Beatmap);
ensurePlayingSelected(preview);
}
ensurePlayingSelected(preview);
changeBackground(Beatmap.Value); changeBackground(Beatmap.Value);
}; };
selectionChangedDebounce?.Cancel();
if (beatmap?.Equals(beatmapNoDebounce) == true)
return;
beatmapNoDebounce = beatmap;
if (beatmap == null) if (beatmap == null)
{ {
if (!Beatmap.IsDefault) if (!Beatmap.IsDefault)
@ -236,18 +251,13 @@ namespace osu.Game.Screens.Select
} }
else else
{ {
selectionChangedDebounce?.Cancel(); ruleset.Value = beatmap.Ruleset;
if (beatmap.Equals(beatmapNoDebounce))
return;
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID) if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
sampleChangeDifficulty.Play(); sampleChangeDifficulty.Play();
else else
sampleChangeBeatmap.Play(); sampleChangeBeatmap.Play();
beatmapNoDebounce = beatmap;
if (beatmap == Beatmap.Value.BeatmapInfo) if (beatmap == Beatmap.Value.BeatmapInfo)
performLoad(); performLoad();
else else
@ -358,10 +368,11 @@ namespace osu.Game.Screens.Select
{ {
Track track = Beatmap.Value.Track; Track track = Beatmap.Value.Track;
trackManager.SetExclusive(track); if (!track.IsRunning)
{
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime); if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
track.Start(); track.Start();
}
} }
private void removeBeatmapSet(BeatmapSetInfo beatmapSet) private void removeBeatmapSet(BeatmapSetInfo beatmapSet)