mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Merge branch 'master' of github.com:ppy/osu into better-transforms
# Conflicts: # osu-framework
This commit is contained in:
commit
2cd8f6b30c
@ -1 +1 @@
|
||||
Subproject commit 1f117839890835c9142680df55c94e22daf7d783
|
||||
Subproject commit 82044038805e640ae4602be2fe4772bf09d23e94
|
@ -22,14 +22,11 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
|
||||
|
||||
public readonly bool WithStoryboard;
|
||||
|
||||
protected WorkingBeatmap(BeatmapInfo beatmapInfo, bool withStoryboard = false)
|
||||
protected WorkingBeatmap(BeatmapInfo beatmapInfo)
|
||||
{
|
||||
BeatmapInfo = beatmapInfo;
|
||||
BeatmapSetInfo = beatmapInfo.BeatmapSet;
|
||||
Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo.Metadata;
|
||||
WithStoryboard = withStoryboard;
|
||||
|
||||
Mods.ValueChanged += mods => applyRateAdjustments();
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ namespace osu.Game.Database
|
||||
if (beatmapInfo.Metadata == null)
|
||||
beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata;
|
||||
|
||||
WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard);
|
||||
WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo);
|
||||
|
||||
previous?.TransferTo(working);
|
||||
|
||||
|
@ -14,8 +14,8 @@ namespace osu.Game.Database
|
||||
{
|
||||
private readonly BeatmapDatabase database;
|
||||
|
||||
public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, bool withStoryboard = false)
|
||||
: base(beatmapInfo, withStoryboard)
|
||||
public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo)
|
||||
: base(beatmapInfo)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
@ -37,7 +37,7 @@ namespace osu.Game.Database
|
||||
beatmap = decoder.Decode(stream);
|
||||
}
|
||||
|
||||
if (beatmap == null || !WithStoryboard || BeatmapSetInfo.StoryboardFile == null)
|
||||
if (beatmap == null || BeatmapSetInfo.StoryboardFile == null)
|
||||
return beatmap;
|
||||
|
||||
using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile)))
|
||||
|
@ -174,11 +174,11 @@ namespace osu.Game
|
||||
LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add);
|
||||
LoadComponentAsync(social = new SocialOverlay { 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(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add);
|
||||
LoadComponentAsync(musicController = new MusicController
|
||||
{
|
||||
Depth = -2,
|
||||
Depth = -3,
|
||||
Position = new Vector2(0, Toolbar.HEIGHT),
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
@ -186,14 +186,14 @@ namespace osu.Game
|
||||
|
||||
LoadComponentAsync(notificationManager = new NotificationManager
|
||||
{
|
||||
Depth = -2,
|
||||
Depth = -3,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
}, overlayContent.Add);
|
||||
|
||||
LoadComponentAsync(dialogOverlay = new DialogOverlay
|
||||
{
|
||||
Depth = -4,
|
||||
Depth = -5,
|
||||
}, overlayContent.Add);
|
||||
|
||||
Logger.NewEntry += entry =>
|
||||
@ -220,7 +220,7 @@ namespace osu.Game
|
||||
|
||||
LoadComponentAsync(Toolbar = new Toolbar
|
||||
{
|
||||
Depth = -3,
|
||||
Depth = -4,
|
||||
OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
|
||||
}, overlayContent.Add);
|
||||
|
||||
|
@ -133,9 +133,27 @@ namespace osu.Game
|
||||
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);
|
||||
}
|
||||
|
||||
private WorkingBeatmap lastBeatmap;
|
||||
|
||||
public void APIStateChanged(APIAccess api, APIState state)
|
||||
{
|
||||
switch (state)
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
@ -11,6 +12,7 @@ using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Chat
|
||||
{
|
||||
@ -62,6 +64,8 @@ namespace osu.Game.Overlays.Chat
|
||||
private const float message_padding = 200;
|
||||
private const float text_size = 20;
|
||||
|
||||
private Action<User> loadProfile;
|
||||
|
||||
private Color4 customUsernameColour;
|
||||
|
||||
public ChatLine(Message message)
|
||||
@ -75,9 +79,10 @@ namespace osu.Game.Overlays.Chat
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OsuColour colours, UserProfileOverlay profile)
|
||||
{
|
||||
customUsernameColour = colours.ChatBlue;
|
||||
loadProfile = u => profile?.ShowUser(u);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -87,8 +92,6 @@ namespace osu.Game.Overlays.Chat
|
||||
bool hasBackground = !string.IsNullOrEmpty(Message.Sender.Colour);
|
||||
Drawable username = new OsuSpriteText
|
||||
{
|
||||
Origin = Anchor.TopRight,
|
||||
Anchor = Anchor.TopRight,
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
Text = $@"{Message.Sender.Username}" + (hasBackground ? "" : ":"),
|
||||
Colour = hasBackground ? customUsernameColour : username_colours[Message.UserId % username_colours.Length],
|
||||
@ -132,7 +135,7 @@ namespace osu.Game.Overlays.Chat
|
||||
new Container
|
||||
{
|
||||
Size = new Vector2(message_padding, text_size),
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
@ -144,7 +147,14 @@ namespace osu.Game.Overlays.Chat
|
||||
TextSize = text_size * 0.75f,
|
||||
Alpha = 0.4f,
|
||||
},
|
||||
username
|
||||
new ClickableContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Origin = Anchor.TopRight,
|
||||
Anchor = Anchor.TopRight,
|
||||
Child = username,
|
||||
Action = () => loadProfile(Message.Sender),
|
||||
},
|
||||
}
|
||||
},
|
||||
new Container
|
||||
|
@ -3,9 +3,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -15,7 +13,6 @@ using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
|
||||
@ -30,7 +27,6 @@ namespace osu.Game.Overlays.Music
|
||||
private FilterControl filter;
|
||||
private PlaylistList list;
|
||||
|
||||
private TrackManager trackManager;
|
||||
private BeatmapDatabase beatmaps;
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
||||
@ -43,7 +39,6 @@ namespace osu.Game.Overlays.Music
|
||||
{
|
||||
this.inputManager = inputManager;
|
||||
this.beatmaps = beatmaps;
|
||||
trackManager = game.Audio.Track;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -154,13 +149,7 @@ namespace osu.Game.Overlays.Music
|
||||
private void playSpecified(BeatmapInfo info)
|
||||
{
|
||||
beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking);
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var track = beatmapBacking.Value.Track;
|
||||
trackManager.SetExclusive(track);
|
||||
track.Start();
|
||||
}).ContinueWith(task => Schedule(task.ThrowIfFaulted), TaskContinuationOptions.OnlyOnFaulted);
|
||||
beatmapBacking.Value.Track.Start();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,16 +12,20 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
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 Container coverContainer, chartContainer, supporterTag;
|
||||
@ -29,6 +33,7 @@ namespace osu.Game.Overlays.Profile
|
||||
private readonly SpriteText levelText;
|
||||
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
|
||||
private readonly Box colourBar;
|
||||
private readonly DrawableFlag countryFlag;
|
||||
|
||||
private const float cover_height = 350;
|
||||
private const float info_height = 150;
|
||||
@ -114,16 +119,17 @@ namespace osu.Game.Overlays.Profile
|
||||
}
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
new LinkFlowContainer.LinkText
|
||||
{
|
||||
Text = user.Username,
|
||||
Url = $@"https://osu.ppy.sh/users/{user.Id}",
|
||||
TextSize = 30,
|
||||
Font = @"Exo2.0-RegularItalic",
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Y = -48
|
||||
},
|
||||
new DrawableFlag(user.Country?.FlagName ?? "__")
|
||||
countryFlag = new DrawableFlag(user.Country?.FlagName ?? "__")
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
@ -158,7 +164,7 @@ namespace osu.Game.Overlays.Profile
|
||||
ParagraphSpacing = 0.8f,
|
||||
LineSpacing = 0.2f
|
||||
},
|
||||
infoTextRight = new OsuTextFlowContainer(t =>
|
||||
infoTextRight = new LinkFlowContainer(t =>
|
||||
{
|
||||
t.TextSize = 14;
|
||||
t.Font = @"Exo2.0-RegularItalic";
|
||||
@ -350,6 +356,7 @@ namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
infoTextLeft.AddText("from ");
|
||||
infoTextLeft.AddText(user.Country.FullName, boldItalic);
|
||||
countryFlag.FlagName = user.Country.FlagName;
|
||||
}
|
||||
infoTextLeft.NewParagraph();
|
||||
|
||||
@ -373,14 +380,22 @@ namespace osu.Game.Overlays.Profile
|
||||
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_heart_o, user.Intrerests);
|
||||
tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation);
|
||||
infoTextRight.NewParagraph();
|
||||
if (!string.IsNullOrEmpty(user.Twitter))
|
||||
tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter);
|
||||
tryAddInfoRightLine(FontAwesome.fa_globe, user.Website);
|
||||
tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype);
|
||||
tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}");
|
||||
tryAddInfoRightLine(FontAwesome.fa_globe, websiteWithoutProtcol, user.Website);
|
||||
tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype, @"skype:" + user.Skype + @"?chat");
|
||||
|
||||
if (user.Statistics != null)
|
||||
{
|
||||
@ -390,7 +405,7 @@ namespace osu.Game.Overlays.Profile
|
||||
scoreText.Add(createScoreText("Ranked Score"));
|
||||
scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0")));
|
||||
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"));
|
||||
scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0")));
|
||||
scoreText.Add(createScoreText("Total Score"));
|
||||
@ -433,12 +448,12 @@ namespace osu.Game.Overlays.Profile
|
||||
Text = text
|
||||
};
|
||||
|
||||
private void tryAddInfoRightLine(FontAwesome icon, string str)
|
||||
private void tryAddInfoRightLine(FontAwesome icon, string str, string url = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str)) return;
|
||||
|
||||
infoTextRight.AddIcon(icon);
|
||||
infoTextRight.AddText(" " + str);
|
||||
infoTextRight.AddLink(" " + str, url);
|
||||
infoTextRight.NewLine();
|
||||
}
|
||||
|
||||
@ -479,5 +494,51 @@ namespace osu.Game.Overlays.Profile
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,8 +72,6 @@ namespace osu.Game.Screens.Menu
|
||||
menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
|
||||
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
|
||||
|
||||
var trackManager = audio.Track;
|
||||
|
||||
BeatmapSetInfo setInfo = null;
|
||||
|
||||
if (!menuMusic)
|
||||
@ -106,7 +104,6 @@ namespace osu.Game.Screens.Menu
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
|
||||
|
||||
track = Beatmap.Value.Track;
|
||||
trackManager.SetExclusive(track);
|
||||
|
||||
welcome = audio.Sample.Get(@"welcome");
|
||||
seeya = audio.Sample.Get(@"seeya");
|
||||
@ -121,7 +118,9 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
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());
|
||||
|
||||
|
@ -94,9 +94,7 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
if (!track.IsRunning)
|
||||
{
|
||||
track.Seek(metadata.PreviewTime);
|
||||
if (metadata.PreviewTime == -1)
|
||||
track.Seek(track.Length * 0.4f);
|
||||
track.Seek(metadata.PreviewTime != -1 ? metadata.PreviewTime : 0.4f * track.Length);
|
||||
track.Start();
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor;
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
|
||||
public Action RestartRequested;
|
||||
|
||||
internal override bool AllowBeatmapRulesetChange => false;
|
||||
@ -72,7 +70,7 @@ namespace osu.Game.Screens.Play
|
||||
private bool loadedSuccessfully => HitRenderer?.Objects.Any() == 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);
|
||||
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
||||
@ -83,10 +81,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
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)
|
||||
throw new InvalidOperationException("Beatmap was not loaded");
|
||||
|
||||
@ -121,10 +115,7 @@ namespace osu.Game.Screens.Play
|
||||
Track track = Beatmap.Value.Track;
|
||||
|
||||
if (track != null)
|
||||
{
|
||||
audio.Track.SetExclusive(track);
|
||||
adjustableSourceClock = track;
|
||||
}
|
||||
|
||||
adjustableSourceClock = (IAdjustableClock)track ?? new StopwatchClock();
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Screens.Play
|
||||
return;
|
||||
|
||||
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)
|
||||
lastHit = objects.Last().StartTime;
|
||||
|
@ -25,6 +25,8 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
public BeatmapInfo SelectedBeatmap => selectedPanel?.Beatmap;
|
||||
|
||||
public override bool HandleInput => AllowSelection;
|
||||
|
||||
public Action BeatmapsChanged;
|
||||
|
||||
public IEnumerable<BeatmapSetInfo> Beatmaps
|
||||
@ -133,7 +135,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public void SelectNext(int direction = 1, bool skipDifficulties = true)
|
||||
{
|
||||
if (groups.Count == 0)
|
||||
if (groups.All(g => g.State == BeatmapGroupState.Hidden))
|
||||
{
|
||||
selectedGroup = null;
|
||||
selectedPanel = null;
|
||||
@ -228,6 +230,14 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
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)
|
||||
{
|
||||
if (newCriteria != null)
|
||||
@ -259,6 +269,8 @@ namespace osu.Game.Screens.Select
|
||||
};
|
||||
|
||||
filterTask?.Cancel();
|
||||
filterTask = null;
|
||||
|
||||
if (debounce)
|
||||
filterTask = Scheduler.AddDelayed(perform, 250);
|
||||
else
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Input;
|
||||
@ -31,7 +32,7 @@ namespace osu.Game.Screens.Select
|
||||
public Action OnBack;
|
||||
public Action OnStart;
|
||||
|
||||
private readonly FillFlowContainer buttons;
|
||||
private readonly FillFlowContainer<FooterButton> buttons;
|
||||
|
||||
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>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
|
||||
/// </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,
|
||||
Width = play_song_select_button_width,
|
||||
Depth = depth,
|
||||
SelectedColour = colour,
|
||||
DeselectedColour = colour.Opacity(0.5f),
|
||||
Hotkey = hotkey,
|
||||
};
|
||||
Text = text,
|
||||
Height = play_song_select_button_height,
|
||||
Width = play_song_select_button_width,
|
||||
Depth = depth,
|
||||
SelectedColour = colour,
|
||||
DeselectedColour = colour.Opacity(0.5f),
|
||||
Hotkey = hotkey,
|
||||
Hovered = updateModeLight,
|
||||
HoverLost = updateModeLight,
|
||||
Action = action,
|
||||
});
|
||||
|
||||
button.Hovered = () => updateModeLight(button);
|
||||
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);
|
||||
}
|
||||
private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
||||
|
||||
public Footer()
|
||||
{
|
||||
@ -111,7 +104,7 @@ namespace osu.Game.Screens.Select
|
||||
Spacing = new Vector2(padding, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
buttons = new FillFlowContainer
|
||||
buttons = new FillFlowContainer<FooterButton>
|
||||
{
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(0.2f, 0),
|
||||
|
@ -105,6 +105,7 @@ namespace osu.Game.Screens.Select
|
||||
if (player != null) return;
|
||||
|
||||
Beatmap.Value.Track.Looping = false;
|
||||
Beatmap.Disabled = true;
|
||||
|
||||
LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player));
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ namespace osu.Game.Screens.Select
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
|
||||
|
||||
private readonly BeatmapCarousel carousel;
|
||||
private TrackManager trackManager;
|
||||
private DialogOverlay dialogOverlay;
|
||||
|
||||
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
||||
@ -110,7 +109,7 @@ namespace osu.Game.Screens.Select
|
||||
Origin = Anchor.CentreRight,
|
||||
SelectionChanged = carouselSelectionChanged,
|
||||
BeatmapsChanged = carouselBeatmapsLoaded,
|
||||
StartRequested = carouselRaisedStart
|
||||
StartRequested = carouselRaisedStart,
|
||||
});
|
||||
Add(FilterControl = new FilterControl
|
||||
{
|
||||
@ -174,7 +173,6 @@ namespace osu.Game.Screens.Select
|
||||
database.BeatmapSetAdded += onBeatmapSetAdded;
|
||||
database.BeatmapSetRemoved += onBeatmapSetRemoved;
|
||||
|
||||
trackManager = audio.Track;
|
||||
dialogOverlay = dialog;
|
||||
|
||||
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
|
||||
@ -185,11 +183,14 @@ namespace osu.Game.Screens.Select
|
||||
carousel.Beatmaps = database.GetAllWithChildren<BeatmapSetInfo>(b => !b.DeletePending);
|
||||
|
||||
Beatmap.ValueChanged += beatmap_ValueChanged;
|
||||
|
||||
Beatmap.DisabledChanged += disabled => carousel.AllowSelection = !disabled;
|
||||
carousel.AllowSelection = !Beatmap.Disabled;
|
||||
}
|
||||
|
||||
private void carouselBeatmapsLoaded()
|
||||
{
|
||||
if (Beatmap.Value != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
|
||||
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
||||
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false);
|
||||
else
|
||||
carousel.SelectNext();
|
||||
@ -197,13 +198,15 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private void carouselRaisedStart()
|
||||
{
|
||||
var pendingSelection = selectionChangedDebounce;
|
||||
selectionChangedDebounce = null;
|
||||
// if we have a pending filter operation, we want to run it now.
|
||||
// it could change selection (ie. if the ruleset has been changed).
|
||||
carousel.FlushPendingFilters();
|
||||
|
||||
if (pendingSelection?.Completed == false)
|
||||
if (selectionChangedDebounce?.Completed == false)
|
||||
{
|
||||
pendingSelection.RunTask();
|
||||
pendingSelection.Cancel(); // cancel the already scheduled task.
|
||||
selectionChangedDebounce.RunTask();
|
||||
selectionChangedDebounce.Cancel(); // cancel the already scheduled task.
|
||||
selectionChangedDebounce = null;
|
||||
}
|
||||
|
||||
OnSelected();
|
||||
@ -221,14 +224,26 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
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);
|
||||
};
|
||||
|
||||
selectionChangedDebounce?.Cancel();
|
||||
|
||||
if (beatmap?.Equals(beatmapNoDebounce) == true)
|
||||
return;
|
||||
|
||||
beatmapNoDebounce = beatmap;
|
||||
|
||||
if (beatmap == null)
|
||||
{
|
||||
if (!Beatmap.IsDefault)
|
||||
@ -236,18 +251,13 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
else
|
||||
{
|
||||
selectionChangedDebounce?.Cancel();
|
||||
|
||||
if (beatmap.Equals(beatmapNoDebounce))
|
||||
return;
|
||||
ruleset.Value = beatmap.Ruleset;
|
||||
|
||||
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
|
||||
sampleChangeDifficulty.Play();
|
||||
else
|
||||
sampleChangeBeatmap.Play();
|
||||
|
||||
beatmapNoDebounce = beatmap;
|
||||
|
||||
if (beatmap == Beatmap.Value.BeatmapInfo)
|
||||
performLoad();
|
||||
else
|
||||
@ -358,10 +368,11 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
Track track = Beatmap.Value.Track;
|
||||
|
||||
trackManager.SetExclusive(track);
|
||||
|
||||
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
|
||||
track.Start();
|
||||
if (!track.IsRunning)
|
||||
{
|
||||
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
|
||||
track.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
|
Loading…
Reference in New Issue
Block a user