Merge branch 'master' into user-status-wiring

This commit is contained in:
Lucas A
2019-04-15 11:43:53 +02:00
committed by GitHub
60 changed files with 222 additions and 182 deletions

View File

@ -25,6 +25,7 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
namespace osu.Game.Screens.Select
@ -309,12 +310,12 @@ namespace osu.Game.Screens.Select
try
{
// Try to get the beatmap with the user's ruleset
playableBeatmap = beatmap.GetPlayableBeatmap(ruleset);
playableBeatmap = beatmap.GetPlayableBeatmap(ruleset, Array.Empty<Mod>());
}
catch (BeatmapInvalidForRulesetException)
{
// Can't be converted to the user's ruleset, so use the beatmap's own ruleset
playableBeatmap = beatmap.GetPlayableBeatmap(beatmap.BeatmapInfo.Ruleset);
playableBeatmap = beatmap.GetPlayableBeatmap(beatmap.BeatmapInfo.Ruleset, Array.Empty<Mod>());
}
labels.AddRange(playableBeatmap.GetStatistics().Select(s => new InfoLabel(s)));

View File

@ -2,8 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -26,9 +24,6 @@ namespace osu.Game.Screens.Select
[Resolved(typeof(Room))]
protected Bindable<PlaylistItem> CurrentItem { get; private set; }
[Resolved]
private Bindable<IEnumerable<Mod>> selectedMods { get; set; }
[Resolved]
private BeatmapManager beatmaps { get; set; }
@ -46,7 +41,7 @@ namespace osu.Game.Screens.Select
RulesetID = Ruleset.Value.ID ?? 0
};
item.RequiredMods.AddRange(SelectedMods.Value);
item.RequiredMods.AddRange(Mods.Value);
Selected?.Invoke(item);
@ -65,11 +60,12 @@ namespace osu.Game.Screens.Select
{
Ruleset.Value = CurrentItem.Value.Ruleset;
Beatmap.Value = beatmaps.GetWorkingBeatmap(CurrentItem.Value.Beatmap);
Beatmap.Value.Mods.Value = selectedMods.Value = CurrentItem.Value.RequiredMods ?? Enumerable.Empty<Mod>();
Mods.Value = CurrentItem.Value.RequiredMods?.ToArray() ?? Array.Empty<Mod>();
}
Beatmap.Disabled = true;
Ruleset.Disabled = true;
Mods.Disabled = true;
return false;
}
@ -80,6 +76,7 @@ namespace osu.Game.Screens.Select
Beatmap.Disabled = false;
Ruleset.Disabled = false;
Mods.Disabled = false;
}
}
}

View File

@ -55,10 +55,10 @@ namespace osu.Game.Screens.Select
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
var autoType = auto.GetType();
var mods = SelectedMods.Value;
var mods = Mods.Value;
if (mods.All(m => m.GetType() != autoType))
{
SelectedMods.Value = mods.Append(auto);
Mods.Value = mods.Append(auto).ToArray();
removeAutoModOnResume = true;
}
}

View File

@ -84,8 +84,8 @@ namespace osu.Game.Screens.Select
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
[Cached]
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
private readonly Bindable<IReadOnlyList<Mod>> mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>()); // Bound to the game's mods, but is not reset on exiting
protected SongSelect()
{
@ -217,10 +217,9 @@ namespace osu.Game.Screens.Select
}
[BackgroundDependencyLoader(true)]
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, Bindable<IEnumerable<Mod>> selectedMods)
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins)
{
if (selectedMods != null)
SelectedMods.BindTo(selectedMods);
mods.BindTo(Mods);
if (Footer != null)
{
@ -269,6 +268,7 @@ namespace osu.Game.Screens.Select
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs(this);
dependencies.CacheAs(decoupledRuleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(decoupledRuleset);
@ -394,7 +394,7 @@ namespace osu.Game.Screens.Select
{
Logger.Log($"ruleset changed from \"{decoupledRuleset.Value}\" to \"{ruleset}\"");
Beatmap.Value.Mods.Value = Enumerable.Empty<Mod>();
mods.Value = Array.Empty<Mod>();
decoupledRuleset.Value = ruleset;
// force a filter before attempting to change the beatmap.
@ -529,8 +529,8 @@ namespace osu.Game.Screens.Select
if (Beatmap.Value.Track != null)
Beatmap.Value.Track.Looping = false;
SelectedMods.UnbindAll();
Beatmap.Value.Mods.Value = new Mod[] { };
mods.UnbindAll();
Mods.Value = Array.Empty<Mod>();
return false;
}
@ -557,8 +557,6 @@ namespace osu.Game.Screens.Select
/// <param name="beatmap">The working beatmap.</param>
protected virtual void UpdateBeatmap(WorkingBeatmap beatmap)
{
beatmap.Mods.BindTo(SelectedMods);
Logger.Log($"working beatmap updated to {beatmap}");
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)