1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 12:47:25 +08:00

Merge branch 'master' into better-notification-delays

This commit is contained in:
Dean Herbert 2017-12-26 20:48:41 +09:00 committed by GitHub
commit 35ae5173cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 545 additions and 275 deletions

@ -1 +1 @@
Subproject commit 08f85f9bf9a7376aec8dfcde8c7c96d267d8c295
Subproject commit 46d4704b0a3f140fa8ad10ca0b1553b67d8385ab

View File

@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.Catch.Objects
StartTime = lastTickTime,
ComboColour = ComboColour,
X = Curve.PositionAt(distanceProgress).X / CatchPlayfield.BASE_WIDTH,
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
{
Bank = s.Bank,
Name = @"slidertick",
@ -108,7 +108,7 @@ namespace osu.Game.Rulesets.Catch.Objects
StartTime = repeatStartTime + t,
ComboColour = ComboColour,
X = Curve.PositionAt(progress).X / CatchPlayfield.BASE_WIDTH,
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
{
Bank = s.Bank,
Name = @"slidertick",
@ -147,7 +147,7 @@ namespace osu.Game.Rulesets.Catch.Objects
set { Curve.ControlPoints = value; }
}
public List<SampleInfoList> RepeatSamples { get; set; } = new List<SampleInfoList>();
public List<List<SampleInfo>> RepeatSamples { get; set; } = new List<List<SampleInfo>>();
public CurveType CurveType
{

View File

@ -192,7 +192,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
/// </summary>
/// <param name="time">The time to retrieve the sample info list from.</param>
/// <returns></returns>
private SampleInfoList sampleInfoListAt(double time)
private List<SampleInfo> sampleInfoListAt(double time)
{
var curveData = HitObject as IHasCurve;

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Audio;
using osu.Game.Beatmaps;
@ -435,7 +436,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
/// </summary>
/// <param name="time">The time to retrieve the sample info list from.</param>
/// <returns></returns>
private SampleInfoList sampleInfoListAt(double time)
private List<SampleInfo> sampleInfoListAt(double time)
{
var curveData = HitObject as IHasCurve;

View File

@ -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.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.MathUtils;
using osu.Game.Rulesets.Objects;
@ -77,7 +78,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
};
if (hold.Head.Samples == null)
hold.Head.Samples = new SampleInfoList();
hold.Head.Samples = new List<SampleInfo>();
hold.Head.Samples.Add(new SampleInfo { Name = SampleInfo.HIT_NORMAL });

View File

@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Osu.Objects
/// </summary>
internal float LazyTravelDistance;
public List<SampleInfoList> RepeatSamples { get; set; } = new List<SampleInfoList>();
public List<List<SampleInfo>> RepeatSamples { get; set; } = new List<List<SampleInfo>>();
public int RepeatCount { get; set; } = 1;
private int stackHeight;
@ -138,7 +138,7 @@ namespace osu.Game.Rulesets.Osu.Objects
StackHeight = StackHeight,
Scale = Scale,
ComboColour = ComboColour,
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
{
Bank = s.Bank,
Name = @"slidertick",
@ -170,7 +170,7 @@ namespace osu.Game.Rulesets.Osu.Objects
StackHeight = StackHeight,
Scale = Scale,
ComboColour = ComboColour,
Samples = new SampleInfoList(RepeatSamples[repeat])
Samples = new List<SampleInfo>(RepeatSamples[repeat])
});
}
}

View File

@ -0,0 +1,47 @@
// 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.Collections.Generic;
using System.Linq;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints;
namespace osu.Game.Rulesets.Taiko.Audio
{
public class DrumSampleMapping
{
private readonly ControlPointInfo controlPoints;
private readonly Dictionary<SampleControlPoint, DrumSample> mappings = new Dictionary<SampleControlPoint, DrumSample>();
public DrumSampleMapping(ControlPointInfo controlPoints, AudioManager audio)
{
this.controlPoints = controlPoints;
IEnumerable<SampleControlPoint> samplePoints;
if (controlPoints.SamplePoints.Count == 0)
// Get the default sample point
samplePoints = new[] { controlPoints.SamplePointAt(double.MinValue) };
else
samplePoints = controlPoints.SamplePoints;
foreach (var s in samplePoints.Distinct())
{
mappings[s] = new DrumSample
{
Centre = s.GetSampleInfo().GetChannel(audio.Sample),
Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample)
};
}
}
public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time)];
public class DrumSample
{
public SampleChannel Centre;
public SampleChannel Rim;
}
}
}

View File

@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
var curveData = obj as IHasCurve;
// Old osu! used hit sounding to determine various hit type information
SampleInfoList samples = obj.Samples;
List<SampleInfo> samples = obj.Samples;
bool strong = samples.Any(s => s.Name == SampleInfo.HIT_FINISH);
@ -115,12 +115,12 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
{
List<SampleInfoList> allSamples = curveData != null ? curveData.RepeatSamples : new List<SampleInfoList>(new[] { samples });
List<List<SampleInfo>> allSamples = curveData != null ? curveData.RepeatSamples : new List<List<SampleInfo>>(new[] { samples });
int i = 0;
for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing)
{
SampleInfoList currentSamples = allSamples[i];
List<SampleInfo> currentSamples = allSamples[i];
bool isRim = currentSamples.Any(s => s.Name == SampleInfo.HIT_CLAP || s.Name == SampleInfo.HIT_WHISTLE);
strong = currentSamples.Any(s => s.Name == SampleInfo.HIT_FINISH);

View File

@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
validKeyPressed = HitActions.Contains(action);
// Only count this as handled if the new judgement is a hit
return UpdateJudgement(true) && Judgements.LastOrDefault()?.IsHit == true;
return UpdateJudgement(true);
}
protected override void Update()

View File

@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
if (!userTriggered)
{
if (timeOffset > second_hit_window)
AddJudgement(new TaikoStrongHitJudgement { Result = HitResult.Miss });
AddJudgement(new TaikoStrongHitJudgement { Result = HitResult.None });
return;
}
@ -83,7 +83,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
return false;
// Assume the intention was to hit the strong hit with both keys only if the first key is still being held down
return firstKeyHeld && UpdateJudgement(true) && Judgements.LastOrDefault()?.IsHit == true;
return firstKeyHeld && UpdateJudgement(true);
}
}
}

View File

@ -34,10 +34,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private readonly CircularContainer targetRing;
private readonly CircularContainer expandingRing;
private readonly TaikoAction[] rimActions = { TaikoAction.LeftRim, TaikoAction.RightRim };
private readonly TaikoAction[] centreActions = { TaikoAction.LeftCentre, TaikoAction.RightCentre };
private TaikoAction[] lastAction;
/// <summary>
/// The amount of times the user has hit this swell.
/// </summary>
@ -205,19 +201,20 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
}
}
private bool? lastWasCentre;
public override bool OnPressed(TaikoAction action)
{
// Don't handle keys before the swell starts
if (Time.Current < HitObject.StartTime)
return false;
// Find the keyset which this key corresponds to
var keySet = rimActions.Contains(action) ? rimActions : centreActions;
var isCentre = action == TaikoAction.LeftCentre || action == TaikoAction.RightCentre;
// Ensure alternating keysets
if (keySet == lastAction)
// Ensure alternating centre and rim hits
if (lastWasCentre == isCentre)
return false;
lastAction = keySet;
lastWasCentre = isCentre;
UpdateJudgement(true);

View File

@ -6,6 +6,9 @@ using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
using OpenTK;
using System.Linq;
using osu.Game.Audio;
using System.Collections.Generic;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
@ -35,6 +38,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
MainPiece.KiaiMode = HitObject.Kiai;
}
// Normal and clap samples are handled by the drum
protected override IEnumerable<SampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != SampleInfo.HIT_NORMAL && s.Name != SampleInfo.HIT_CLAP);
protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
public abstract bool OnPressed(TaikoAction action);

View File

@ -3,6 +3,7 @@
using osu.Game.Rulesets.Objects.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Audio;
using osu.Game.Beatmaps;
@ -75,7 +76,7 @@ namespace osu.Game.Rulesets.Taiko.Objects
TickSpacing = tickSpacing,
StartTime = t,
IsStrong = IsStrong,
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
{
Bank = s.Bank,
Name = @"slidertick",

View File

@ -16,4 +16,4 @@ namespace osu.Game.Rulesets.Taiko.Objects
/// </summary>
public int RequiredHits = 10;
}
}
}

View File

@ -165,11 +165,15 @@ namespace osu.Game.Rulesets.Taiko.Tests
private void addSwell(double duration = default_duration)
{
rulesetContainer.Playfield.Add(new DrawableSwell(new Swell
var swell = new Swell
{
StartTime = rulesetContainer.Playfield.Time.Current + scroll_time,
Duration = duration,
}));
};
swell.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
rulesetContainer.Playfield.Add(new DrawableSwell(swell));
}
private void addDrumRoll(bool strong, double duration = default_duration)
@ -184,6 +188,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
Duration = duration,
};
d.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
rulesetContainer.Playfield.Add(new DrawableDrumRoll(d));
}
@ -195,6 +201,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
IsStrong = strong
};
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
if (strong)
rulesetContainer.Playfield.Add(new DrawableCentreHitStrong(h));
else
@ -209,6 +217,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
IsStrong = strong
};
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
if (strong)
rulesetContainer.Playfield.Add(new DrawableRimHitStrong(h));
else

View File

@ -4,12 +4,15 @@
using System;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Bindings;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Rulesets.Taiko.Audio;
namespace osu.Game.Rulesets.Taiko.UI
{
@ -18,16 +21,26 @@ namespace osu.Game.Rulesets.Taiko.UI
/// </summary>
internal class InputDrum : Container
{
public InputDrum()
private const float middle_split = 0.025f;
private readonly ControlPointInfo controlPoints;
public InputDrum(ControlPointInfo controlPoints)
{
this.controlPoints = controlPoints;
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fit;
}
const float middle_split = 0.025f;
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
var sampleMappings = new DrumSampleMapping(controlPoints, audio);
Children = new Drawable[]
{
new TaikoHalfDrum(false)
new TaikoHalfDrum(false, sampleMappings)
{
Name = "Left Half",
Anchor = Anchor.Centre,
@ -38,7 +51,7 @@ namespace osu.Game.Rulesets.Taiko.UI
RimAction = TaikoAction.LeftRim,
CentreAction = TaikoAction.LeftCentre
},
new TaikoHalfDrum(true)
new TaikoHalfDrum(true, sampleMappings)
{
Name = "Right Half",
Anchor = Anchor.Centre,
@ -72,8 +85,12 @@ namespace osu.Game.Rulesets.Taiko.UI
private readonly Sprite centre;
private readonly Sprite centreHit;
public TaikoHalfDrum(bool flipped)
private readonly DrumSampleMapping sampleMappings;
public TaikoHalfDrum(bool flipped, DrumSampleMapping sampleMappings)
{
this.sampleMappings = sampleMappings;
Masking = true;
Children = new Drawable[]
@ -128,15 +145,21 @@ namespace osu.Game.Rulesets.Taiko.UI
Drawable target = null;
Drawable back = null;
var drumSample = sampleMappings.SampleAt(Time.Current);
if (action == CentreAction)
{
target = centreHit;
back = centre;
drumSample.Centre.Play();
}
else if (action == RimAction)
{
target = rimHit;
back = rim;
drumSample.Rim.Play();
}
if (target != null)

View File

@ -16,17 +16,11 @@ using osu.Framework.Extensions.Color4Extensions;
using System.Linq;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Framework.Input.Bindings;
using osu.Game.Beatmaps.ControlPoints;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using System.Collections.Generic;
using osu.Game.Audio;
using System;
namespace osu.Game.Rulesets.Taiko.UI
{
public class TaikoPlayfield : ScrollingPlayfield, IKeyBindingHandler<TaikoAction>
public class TaikoPlayfield : ScrollingPlayfield
{
/// <summary>
/// Default height of a <see cref="TaikoPlayfield"/> when inside a <see cref="TaikoRulesetContainer"/>.
@ -61,13 +55,9 @@ namespace osu.Game.Rulesets.Taiko.UI
private readonly Box overlayBackground;
private readonly Box background;
private readonly ControlPointInfo controlPointInfo;
private Dictionary<SampleControlPoint, DrumSamples> drumSampleMappings;
public TaikoPlayfield(ControlPointInfo controlPointInfo)
public TaikoPlayfield(ControlPointInfo controlPoints)
: base(Axes.X)
{
this.controlPointInfo = controlPointInfo;
AddRangeInternal(new Drawable[]
{
backgroundContainer = new Container
@ -160,7 +150,7 @@ namespace osu.Game.Rulesets.Taiko.UI
{
RelativeSizeAxes = Axes.Both,
},
new InputDrum
new InputDrum(controlPoints)
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
@ -205,19 +195,8 @@ namespace osu.Game.Rulesets.Taiko.UI
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio)
private void load(OsuColour colours)
{
drumSampleMappings = new Dictionary<SampleControlPoint, DrumSamples>();
foreach (var s in controlPointInfo.SamplePoints)
{
drumSampleMappings.Add(s,
new DrumSamples
{
Centre = s.GetSampleInfo().GetChannel(audio.Sample),
Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample)
});
}
overlayBackgroundContainer.BorderColour = colours.Gray0;
overlayBackground.Colour = colours.Gray1;
@ -282,28 +261,5 @@ namespace osu.Game.Rulesets.Taiko.UI
kiaiExplosionContainer.Add(new KiaiHitExplosion(judgedObject, isRim));
}
}
public bool OnPressed(TaikoAction action)
{
var samplePoint = controlPointInfo.SamplePointAt(Clock.CurrentTime);
if (!drumSampleMappings.TryGetValue(samplePoint, out var samples))
throw new InvalidOperationException("Current sample set not found.");
if (action == TaikoAction.LeftCentre || action == TaikoAction.RightCentre)
samples.Centre.Play();
else
samples.Rim.Play();
return true;
}
public bool OnReleased(TaikoAction action) => false;
private class DrumSamples
{
public SampleChannel Centre;
public SampleChannel Rim;
}
}
}

View File

@ -44,6 +44,7 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Audio\DrumSampleMapping.cs" />
<Compile Include="Beatmaps\TaikoBeatmapConverter.cs" />
<Compile Include="Judgements\TaikoDrumRollTickJudgement.cs" />
<Compile Include="Judgements\TaikoStrongHitJudgement.cs" />

View File

@ -1,69 +1,161 @@
// 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 System.Collections.Generic;
using System.Linq;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Select;
using osu.Game.Tests.Beatmaps;
namespace osu.Game.Tests.Visual
{
public class TestCaseBeatmapInfoWedge : OsuTestCase
{
private BeatmapManager beatmaps;
private readonly Random random;
private readonly BeatmapInfoWedge infoWedge;
private RulesetStore rulesets;
private TestBeatmapInfoWedge infoWedge;
private readonly List<Beatmap> beatmaps = new List<Beatmap>();
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
public TestCaseBeatmapInfoWedge()
[BackgroundDependencyLoader]
private void load(OsuGameBase game, RulesetStore rulesets)
{
random = new Random(0123);
this.rulesets = rulesets;
Add(infoWedge = new BeatmapInfoWedge
beatmap.BindTo(game.Beatmap);
}
protected override void LoadComplete()
{
base.LoadComplete();
Add(infoWedge = new TestBeatmapInfoWedge
{
Size = new Vector2(0.5f, 245),
RelativeSizeAxes = Axes.X,
Margin = new MarginPadding
{
Top = 20,
},
Margin = new MarginPadding { Top = 20 }
});
AddStep("show", () =>
{
Content.FadeInFromZero(250);
infoWedge.State = Visibility.Visible;
infoWedge.UpdateBeatmap(beatmap);
});
AddStep("hide", () =>
AddWaitStep(3);
AddStep("hide", () => { infoWedge.State = Visibility.Hidden; });
AddWaitStep(3);
AddStep("show", () => { infoWedge.State = Visibility.Visible; });
foreach (var rulesetInfo in rulesets.AvailableRulesets)
{
infoWedge.State = Visibility.Hidden;
Content.FadeOut(100);
var ruleset = rulesetInfo.CreateInstance();
beatmaps.Add(createTestBeatmap(rulesetInfo));
var name = rulesetInfo.ShortName;
selectBeatmap(name);
// TODO: adjust cases once more info is shown for other gamemodes
switch (ruleset)
{
case OsuRuleset osu:
testOsuBeatmap(osu);
testInfoLabels(5);
break;
default:
testInfoLabels(2);
break;
}
}
testNullBeatmap();
}
private void testOsuBeatmap(OsuRuleset ruleset)
{
AddAssert("check version", () => infoWedge.Info.VersionLabel.Text == $"{ruleset.ShortName}Version");
AddAssert("check title", () => infoWedge.Info.TitleLabel.Text == $"{ruleset.ShortName}Source — {ruleset.ShortName}Title");
AddAssert("check artist", () => infoWedge.Info.ArtistLabel.Text == $"{ruleset.ShortName}Artist");
AddAssert("check author", () => infoWedge.Info.MapperContainer.Children.OfType<OsuSpriteText>().Any(s => s.Text == $"{ruleset.ShortName}Author"));
}
private void testInfoLabels(int expectedCount)
{
AddAssert("check infolabels exists", () => infoWedge.Info.InfoLabelContainer.Children.Any());
AddAssert("check infolabels count", () => infoWedge.Info.InfoLabelContainer.Children.Count == expectedCount);
}
private void testNullBeatmap()
{
selectNullBeatmap();
AddAssert("check empty version", () => string.IsNullOrEmpty(infoWedge.Info.VersionLabel.Text));
AddAssert("check default title", () => infoWedge.Info.TitleLabel.Text == beatmap.Default.BeatmapInfo.Metadata.Title);
AddAssert("check default artist", () => infoWedge.Info.ArtistLabel.Text == beatmap.Default.BeatmapInfo.Metadata.Artist);
AddAssert("check empty author", () => !infoWedge.Info.MapperContainer.Children.Any());
AddAssert("check no infolabels", () => !infoWedge.Info.InfoLabelContainer.Children.Any());
}
private void selectBeatmap(string name)
{
var infoBefore = infoWedge.Info;
AddStep($"select {name} beatmap", () =>
{
beatmap.Value = new TestWorkingBeatmap(beatmaps.First(b => b.BeatmapInfo.Ruleset.ShortName == name));
infoWedge.UpdateBeatmap(beatmap);
});
AddStep("random beatmap", randomBeatmap);
AddStep("null beatmap", () => infoWedge.UpdateBeatmap(beatmap.Default));
AddUntilStep(() => infoWedge.Info != infoBefore, "wait for async load");
}
[BackgroundDependencyLoader]
private void load(OsuGameBase game, BeatmapManager beatmaps)
private void selectNullBeatmap()
{
this.beatmaps = beatmaps;
beatmap.BindTo(game.Beatmap);
AddStep("select null beatmap", () =>
{
beatmap.Value = beatmap.Default;
infoWedge.UpdateBeatmap(beatmap);
});
}
private void randomBeatmap()
private Beatmap createTestBeatmap(RulesetInfo ruleset)
{
var sets = beatmaps.GetAllUsableBeatmapSets();
if (sets.Count == 0)
return;
List<HitObject> objects = new List<HitObject>();
for (double i = 0; i < 50000; i += 1000)
objects.Add(new HitObject { StartTime = i });
var b = sets[random.Next(0, sets.Count)].Beatmaps[0];
beatmap.Value = beatmaps.GetWorkingBeatmap(b);
infoWedge.UpdateBeatmap(beatmap);
return new Beatmap
{
BeatmapInfo = new BeatmapInfo
{
Metadata = new BeatmapMetadata
{
AuthorString = $"{ruleset.ShortName}Author",
Artist = $"{ruleset.ShortName}Artist",
Source = $"{ruleset.ShortName}Source",
Title = $"{ruleset.ShortName}Title"
},
Ruleset = ruleset,
StarDifficulty = 6,
Version = $"{ruleset.ShortName}Version"
},
HitObjects = objects
};
}
private class TestBeatmapInfoWedge : BeatmapInfoWedge
{
public new BufferedWedgeInfo Info => base.Info;
}
}
}

View File

@ -26,6 +26,7 @@ namespace osu.Game.Tests.Visual
private RulesetStore rulesets;
private DependencyContainer dependencies;
private WorkingBeatmap defaultBeatmap;
public override IReadOnlyList<Type> RequiredTypes => new[]
{
@ -47,31 +48,61 @@ namespace osu.Game.Tests.Visual
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
private class TestSongSelect : PlaySongSelect
{
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
public new BeatmapCarousel Carousel => base.Carousel;
}
[BackgroundDependencyLoader]
private void load(BeatmapManager baseManager)
{
PlaySongSelect songSelect;
TestSongSelect songSelect = null;
if (manager == null)
var storage = new TestStorage(@"TestCasePlaySongSelect");
// this is by no means clean. should be replacing inside of OsuGameBase somehow.
var context = new OsuDbContext();
Func<OsuDbContext> contextFactory = () => context;
dependencies.Cache(rulesets = new RulesetStore(contextFactory));
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
{
var storage = new TestStorage(@"TestCasePlaySongSelect");
DefaultBeatmap = defaultBeatmap = baseManager.GetWorkingBeatmap(null)
});
// this is by no means clean. should be replacing inside of OsuGameBase somehow.
var context = new OsuDbContext();
void loadNewSongSelect(bool deleteMaps = false) => AddStep("reload song select", () =>
{
if (deleteMaps) manager.DeleteAll();
Func<OsuDbContext> contextFactory = () => context;
dependencies.Cache(rulesets = new RulesetStore(contextFactory));
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
if (songSelect != null)
{
DefaultBeatmap = baseManager.GetWorkingBeatmap(null)
});
Remove(songSelect);
songSelect.Dispose();
}
Add(songSelect = new TestSongSelect());
});
loadNewSongSelect(true);
AddWaitStep(3);
AddAssert("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap);
AddStep("import test maps", () =>
{
for (int i = 0; i < 100; i += 10)
manager.Import(createTestBeatmapSet(i));
}
});
Add(songSelect = new PlaySongSelect());
AddWaitStep(3);
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
loadNewSongSelect();
AddWaitStep(3);
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
AddStep(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });

View File

@ -1,18 +0,0 @@
// 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.Collections.Generic;
namespace osu.Game.Audio
{
public class SampleInfoList : List<SampleInfo>
{
public SampleInfoList()
{
}
public SampleInfoList(IEnumerable<SampleInfo> elements) : base(elements)
{
}
}
}

View File

@ -697,10 +697,12 @@ namespace osu.Game.Beatmaps
}
}
public bool StableInstallationAvailable => GetStableStorage?.Invoke() != null;
/// <summary>
/// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future.
/// </summary>
public void ImportFromStable()
public async Task ImportFromStable()
{
var stable = GetStableStorage?.Invoke();
@ -710,7 +712,7 @@ namespace osu.Game.Beatmaps
return;
}
Import(stable.GetDirectories("Songs"));
await Task.Factory.StartNew(() => Import(stable.GetDirectories("Songs")), TaskCreationOptions.LongRunning);
}
public void DeleteAll()

View File

@ -21,8 +21,7 @@ namespace osu.Game.Beatmaps
Metadata = new BeatmapMetadata
{
Artist = "please load a beatmap!",
Title = "no beatmaps available!",
AuthorString = "no one",
Title = "no beatmaps available!"
},
BeatmapSet = new BeatmapSetInfo(),
BaseDifficulty = new BeatmapDifficulty

View File

@ -261,4 +261,4 @@ namespace osu.Game.Overlays.Notifications
}
}
}
}
}

View File

@ -95,7 +95,7 @@ namespace osu.Game.Overlays.Notifications
protected virtual void Completed()
{
Expire();
base.Close();
CompletionTarget?.Invoke(CreateCompletionNotification());
}

View File

@ -83,8 +83,10 @@ namespace osu.Game.Overlays.Notifications
set
{
if (value == base.Read) return;
base.Read = value;
Light.FadeTo(value ? 1 : 0, 100);
Light.FadeTo(value ? 0 : 1, 100);
}
}
}

View File

@ -30,8 +30,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
Action = () =>
{
importButton.Enabled.Value = false;
Task.Factory.StartNew(beatmaps.ImportFromStable)
.ContinueWith(t => Schedule(() => importButton.Enabled.Value = true), TaskContinuationOptions.LongRunning);
beatmaps.ImportFromStable().ContinueWith(t => Schedule(() => importButton.Enabled.Value = true));
}
},
deleteButton = new DangerousSettingsButton

View File

@ -59,16 +59,27 @@ namespace osu.Game.Overlays.Toolbar
private class CountCircle : CompositeDrawable
{
private readonly OsuSpriteText count;
private readonly OsuSpriteText countText;
private readonly Circle circle;
private int count;
public int Count
{
get { return count; }
set
{
count.Text = value.ToString("#,0");
circle.FlashColour(Color4.White, 600, Easing.OutQuint);
this.ScaleTo(1.1f).Then().ScaleTo(1, 600, Easing.OutElastic);
if (count == value)
return;
if (value > count)
{
circle.FlashColour(Color4.White, 600, Easing.OutQuint);
this.ScaleTo(1.1f).Then().ScaleTo(1, 600, Easing.OutElastic);
}
count = value;
countText.Text = value.ToString("#,0");
}
}
@ -83,7 +94,7 @@ namespace osu.Game.Overlays.Toolbar
RelativeSizeAxes = Axes.Both,
Colour = Color4.Red
},
count = new OsuSpriteText
countText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -72,6 +72,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
public IReadOnlyList<Judgement> Judgements => judgements;
protected List<SampleChannel> Samples = new List<SampleChannel>();
protected virtual IEnumerable<SampleInfo> GetSamples() => HitObject.Samples;
public readonly Bindable<ArmedState> State = new Bindable<ArmedState>();
@ -84,12 +85,14 @@ namespace osu.Game.Rulesets.Objects.Drawables
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
if (HitObject.Samples != null)
var samples = GetSamples();
if (samples.Any())
{
if (HitObject.SampleControlPoint == null)
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)} must always have an attached {nameof(HitObject.SampleControlPoint)}.");
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)}s must always have an attached {nameof(HitObject.SampleControlPoint)}."
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
foreach (SampleInfo s in HitObject.Samples)
foreach (SampleInfo s in samples)
{
SampleInfo localSampleInfo = new SampleInfo
{
@ -174,7 +177,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
judgementOccurred = false;
if (AllJudged || State != ArmedState.Idle)
if (AllJudged)
return false;
if (NestedHitObjects != null)

View File

@ -25,6 +25,8 @@ namespace osu.Game.Rulesets.Objects
/// </summary>
public virtual double StartTime { get; set; }
private List<SampleInfo> samples;
/// <summary>
/// The samples to be played when this hit object is hit.
/// <para>
@ -32,7 +34,11 @@ namespace osu.Game.Rulesets.Objects
/// and can be treated as the default samples for the hit object.
/// </para>
/// </summary>
public SampleInfoList Samples;
public List<SampleInfo> Samples
{
get => samples ?? (samples = new List<SampleInfo>());
set => samples = value;
}
[JsonIgnore]
public SampleControlPoint SampleControlPoint;

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
};
}
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<SampleInfoList> repeatSamples)
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples)
{
return new ConvertSlider
{

View File

@ -127,7 +127,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
}
// Generate the final per-node samples
var nodeSamples = new List<SampleInfoList>(nodes);
var nodeSamples = new List<List<SampleInfo>>(nodes);
for (int i = 0; i <= repeatCount; i++)
nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[i]));
@ -216,7 +216,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <param name="repeatCount">The slider repeat count.</param>
/// <param name="repeatSamples">The samples to be played when the repeat nodes are hit. This includes the head and tail of the slider.</param>
/// <returns>The hit object.</returns>
protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<SampleInfoList> repeatSamples);
protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples);
/// <summary>
/// Creates a legacy Spinner-type hit object.
@ -234,9 +234,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <param name="endTime">The hold end time.</param>
protected abstract HitObject CreateHold(Vector2 position, bool newCombo, double endTime);
private SampleInfoList convertSoundType(LegacySoundType type, SampleBankInfo bankInfo)
private List<SampleInfo> convertSoundType(LegacySoundType type, SampleBankInfo bankInfo)
{
var soundTypes = new SampleInfoList
var soundTypes = new List<SampleInfo>
{
new SampleInfo
{

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
public double Distance { get; set; }
public List<SampleInfoList> RepeatSamples { get; set; }
public List<List<SampleInfo>> RepeatSamples { get; set; }
public int RepeatCount { get; set; } = 1;
public double EndTime => StartTime + RepeatCount * Distance / Velocity;

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
};
}
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<SampleInfoList> repeatSamples)
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples)
{
return new ConvertSlider
{

View File

@ -2,9 +2,9 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Game.Audio;
using osu.Game.Rulesets.Objects.Types;
using System.Collections.Generic;
using osu.Game.Audio;
namespace osu.Game.Rulesets.Objects.Legacy.Osu
{
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
};
}
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<SampleInfoList> repeatSamples)
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples)
{
return new ConvertSlider
{

View File

@ -2,9 +2,9 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Game.Audio;
using osu.Game.Rulesets.Objects.Types;
using System.Collections.Generic;
using osu.Game.Audio;
namespace osu.Game.Rulesets.Objects.Legacy.Taiko
{
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
};
}
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<SampleInfoList> repeatSamples)
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples)
{
return new ConvertSlider
{

View File

@ -19,6 +19,6 @@ namespace osu.Game.Rulesets.Objects.Types
/// <summary>
/// The samples to be played when each repeat node is hit (0 -> first repeat node, 1 -> second repeat node, etc).
/// </summary>
List<SampleInfoList> RepeatSamples { get; }
List<List<SampleInfo>> RepeatSamples { get; }
}
}

View File

@ -324,7 +324,14 @@ namespace osu.Game.Screens.Ranking
title.Colour = artist.Colour = colours.BlueDarker;
versionMapper.Colour = colours.Gray8;
versionMapper.Text = $"{beatmap.Version} - mapped by {beatmap.Metadata.Author.Username}";
var creator = beatmap.Metadata.Author?.Username;
if (!string.IsNullOrEmpty(creator)) {
versionMapper.Text = $"mapped by {creator}";
if (!string.IsNullOrEmpty(beatmap.Version))
versionMapper.Text = $"{beatmap.Version} - " + versionMapper.Text;
}
title.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title);
artist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist);
}

View File

@ -75,7 +75,8 @@ namespace osu.Game.Screens.Select
scrollableContent.Clear(false);
itemsCache.Invalidate();
scrollPositionCache.Invalidate();
BeatmapSetsChanged?.Invoke();
Schedule(() => BeatmapSetsChanged?.Invoke());
}));
}
}
@ -154,6 +155,7 @@ namespace osu.Game.Screens.Select
select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == selectedBeatmap?.Beatmap.ID) ?? newSet);
itemsCache.Invalidate();
Schedule(() => BeatmapSetsChanged?.Invoke());
});
}
@ -511,7 +513,7 @@ namespace osu.Game.Screens.Select
currentY += DrawHeight / 2;
scrollableContent.Height = currentY;
if (selectedBeatmapSet != null && (selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
if (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected)
{
selectedBeatmapSet = null;
SelectionChanged?.Invoke(null);

View File

@ -27,7 +27,7 @@ namespace osu.Game.Screens.Select
{
private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0);
private Drawable info;
protected BufferedWedgeInfo Info;
public BeatmapInfoWedge()
{
@ -35,6 +35,7 @@ namespace osu.Game.Screens.Select
Masking = true;
BorderColour = new Color4(221, 255, 255, 255);
BorderThickness = 2.5f;
Alpha = 0;
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
@ -50,12 +51,14 @@ namespace osu.Game.Screens.Select
{
this.MoveToX(0, 800, Easing.OutQuint);
this.RotateTo(0, 800, Easing.OutQuint);
this.FadeIn(250);
}
protected override void PopOut()
{
this.MoveToX(-100, 800, Easing.InQuint);
this.RotateTo(10, 800, Easing.InQuint);
this.MoveToX(-100, 800, Easing.In);
this.RotateTo(10, 800, Easing.In);
this.FadeOut(500, Easing.In);
}
public void UpdateBeatmap(WorkingBeatmap beatmap)
@ -63,23 +66,30 @@ namespace osu.Game.Screens.Select
LoadComponentAsync(new BufferedWedgeInfo(beatmap)
{
Shear = -Shear,
Depth = info?.Depth + 1 ?? 0,
Depth = Info?.Depth + 1 ?? 0,
}, newInfo =>
{
State = beatmap == null ? Visibility.Hidden : Visibility.Visible;
// ensure we ourselves are visible if not already.
if (!IsPresent)
this.FadeIn(250);
State = Visibility.Visible;
info?.FadeOut(250);
info?.Expire();
Info?.FadeOut(250);
Info?.Expire();
Add(info = newInfo);
Add(Info = newInfo);
});
}
public class BufferedWedgeInfo : BufferedContainer
{
private readonly WorkingBeatmap working;
public OsuSpriteText VersionLabel { get; private set; }
public OsuSpriteText TitleLabel { get; private set; }
public OsuSpriteText ArtistLabel { get; private set; }
public FillFlowContainer MapperContainer { get; private set; }
public FillFlowContainer InfoLabelContainer { get; private set; }
public BufferedWedgeInfo(WorkingBeatmap working)
{
@ -89,34 +99,8 @@ namespace osu.Game.Screens.Select
[BackgroundDependencyLoader]
private void load()
{
BeatmapInfo beatmapInfo = working.BeatmapInfo;
BeatmapMetadata metadata = beatmapInfo.Metadata ?? working.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
Beatmap beatmap = working.Beatmap;
List<InfoLabel> labels = new List<InfoLabel>();
if (beatmap != null)
{
HitObject lastObject = beatmap.HitObjects.LastOrDefault();
double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0;
labels.Add(new InfoLabel(new BeatmapStatistic
{
Name = "Length",
Icon = FontAwesome.fa_clock_o,
Content = beatmap.HitObjects.Count == 0 ? "-" : TimeSpan.FromMilliseconds(endTime - beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"),
}));
labels.Add(new InfoLabel(new BeatmapStatistic
{
Name = "BPM",
Icon = FontAwesome.fa_circle,
Content = getBPMRange(beatmap),
}));
//get statistics from the current ruleset.
labels.AddRange(beatmapInfo.Ruleset.CreateInstance().GetBeatmapStatistics(working).Select(s => new InfoLabel(s)));
}
var beatmapInfo = working.BeatmapInfo;
var metadata = beatmapInfo.Metadata ?? working.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
PixelSnapping = true;
CacheDrawnFrameBuffer = true;
@ -165,7 +149,7 @@ namespace osu.Game.Screens.Select
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new OsuSpriteText
VersionLabel = new OsuSpriteText
{
Font = @"Exo2.0-MediumItalic",
Text = beatmapInfo.Version,
@ -175,69 +159,112 @@ namespace osu.Game.Screens.Select
},
new FillFlowContainer
{
Name = "Bottom-aligned metadata",
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Name = "Centre-aligned metadata",
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopLeft,
Y = -22,
Direction = FillDirection.Vertical,
Margin = new MarginPadding { Top = 15, Left = 25, Right = 10, Bottom = 20 },
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new OsuSpriteText
TitleLabel = new OsuSpriteText
{
Font = @"Exo2.0-MediumItalic",
Text = !string.IsNullOrEmpty(metadata.Source) ? metadata.Source + " — " + metadata.Title : metadata.Title,
Text = string.IsNullOrEmpty(metadata.Source) ? metadata.Title : metadata.Source + " — " + metadata.Title,
TextSize = 28,
},
new OsuSpriteText
ArtistLabel = new OsuSpriteText
{
Font = @"Exo2.0-MediumItalic",
Text = metadata.Artist,
TextSize = 17,
},
new FillFlowContainer
MapperContainer = new FillFlowContainer
{
Margin = new MarginPadding { Top = 10 },
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
Children = new[]
{
new OsuSpriteText
{
Font = @"Exo2.0-Medium",
Text = "mapped by ",
TextSize = 15,
},
new OsuSpriteText
{
Font = @"Exo2.0-Bold",
Text = metadata.Author.Username,
TextSize = 15,
},
}
Children = getMapper(metadata)
},
new FillFlowContainer
InfoLabelContainer = new FillFlowContainer
{
Margin = new MarginPadding { Top = 20 },
Spacing = new Vector2(20, 0),
AutoSizeAxes = Axes.Both,
Children = labels
},
Children = getInfoLabels()
}
}
},
}
};
}
private InfoLabel[] getInfoLabels()
{
var beatmap = working.Beatmap;
var info = working.BeatmapInfo;
List<InfoLabel> labels = new List<InfoLabel>();
if (beatmap?.HitObjects?.Count > 0)
{
HitObject lastObject = beatmap.HitObjects.LastOrDefault();
double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0;
labels.Add(new InfoLabel(new BeatmapStatistic
{
Name = "Length",
Icon = FontAwesome.fa_clock_o,
Content = beatmap.HitObjects.Count == 0 ? "-" : TimeSpan.FromMilliseconds(endTime - beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"),
}));
labels.Add(new InfoLabel(new BeatmapStatistic
{
Name = "BPM",
Icon = FontAwesome.fa_circle,
Content = getBPMRange(beatmap),
}));
//get statistics from the current ruleset.
labels.AddRange(info.Ruleset.CreateInstance().GetBeatmapStatistics(working).Select(s => new InfoLabel(s)));
}
return labels.ToArray();
}
private string getBPMRange(Beatmap beatmap)
{
double bpmMax = beatmap.ControlPointInfo.BPMMaximum;
double bpmMin = beatmap.ControlPointInfo.BPMMinimum;
if (Precision.AlmostEquals(bpmMin, bpmMax)) return $"{bpmMin:0}";
if (Precision.AlmostEquals(bpmMin, bpmMax))
return $"{bpmMin:0}";
return $"{bpmMin:0}-{bpmMax:0} (mostly {beatmap.ControlPointInfo.BPMMode:0})";
}
private OsuSpriteText[] getMapper(BeatmapMetadata metadata)
{
if (string.IsNullOrEmpty(metadata.Author?.Username))
return Array.Empty<OsuSpriteText>();
return new[]
{
new OsuSpriteText
{
Font = @"Exo2.0-Medium",
Text = "mapped by ",
TextSize = 15,
},
new OsuSpriteText
{
Font = @"Exo2.0-Bold",
Text = metadata.Author.Username,
TextSize = 15,
}
};
}
public class InfoLabel : Container, IHasTooltip
{
public string TooltipText { get; private set; }

View File

@ -75,7 +75,7 @@ namespace osu.Game.Screens.Select
{
Children = new Drawable[]
{
new Box
Background = new Box
{
Colour = Color4.Black,
Alpha = 0.8f,
@ -167,6 +167,8 @@ namespace osu.Game.Screens.Select
private Bindable<bool> showConverted;
public readonly Box Background;
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuColour colours, OsuGame osu, OsuConfigManager config)
{

View File

@ -0,0 +1,33 @@
// 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.Game.Graphics;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Screens.Select
{
public class ImportFromStablePopup : PopupDialog
{
public ImportFromStablePopup(Action importFromStable)
{
HeaderText = @"You have no beatmaps!";
BodyText = "An existing copy of osu! was found, though.\nWould you like to import your beatmaps?";
Icon = FontAwesome.fa_trash_o;
Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = @"Yes please!",
Action = importFromStable
},
new PopupDialogCancelButton
{
Text = @"No, I'd like to start from scratch",
},
};
}
}
}

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Play;
@ -45,8 +46,8 @@ namespace osu.Game.Screens.Select
private SampleChannel sampleConfirm;
[BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio)
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay)
{
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
@ -59,6 +60,16 @@ namespace osu.Game.Screens.Select
ValidForResume = false;
Push(new Editor());
}, Key.Number3);
if (dialogOverlay != null)
{
Schedule(() =>
{
// if we have no beatmaps but osu-stable is found, let's prompt the user to import.
if (!beatmaps.GetAllUsableBeatmapSets().Any() && beatmaps.StableInstallationAvailable)
dialogOverlay.Push(new ImportFromStablePopup(() => beatmaps.ImportFromStable()));
});
}
}
protected override void UpdateBeatmap(WorkingBeatmap beatmap)

View File

@ -55,7 +55,7 @@ namespace osu.Game.Screens.Select
protected Container LeftContent;
private readonly BeatmapCarousel carousel;
protected readonly BeatmapCarousel Carousel;
private readonly BeatmapInfoWedge beatmapInfoWedge;
private DialogOverlay dialogOverlay;
private BeatmapManager beatmaps;
@ -103,25 +103,44 @@ namespace osu.Game.Screens.Select
Right = left_area_padding * 2,
}
},
carousel = new BeatmapCarousel
new Container
{
RelativeSizeAxes = Axes.Y,
Size = new Vector2(carousel_width, 1),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
SelectionChanged = carouselSelectionChanged,
BeatmapSetsChanged = carouselBeatmapsLoaded,
},
FilterControl = new FilterControl
{
RelativeSizeAxes = Axes.X,
Height = filter_height,
FilterChanged = c => carousel.Filter(c),
Exit = Exit,
RelativeSizeAxes = Axes.Both,
Masking = true,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 2, //avoid horizontal masking so the panels don't clip when screen stack is pushed.
Child = new Container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 0.5f,
Children = new Drawable[]
{
Carousel = new BeatmapCarousel
{
Masking = false,
RelativeSizeAxes = Axes.Y,
Size = new Vector2(carousel_width, 1),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
SelectionChanged = carouselSelectionChanged,
BeatmapSetsChanged = carouselBeatmapsLoaded,
},
FilterControl = new FilterControl
{
RelativeSizeAxes = Axes.X,
Height = filter_height,
FilterChanged = c => Carousel.Filter(c),
Background = { Width = 2 },
Exit = Exit,
},
}
},
},
beatmapInfoWedge = new BeatmapInfoWedge
{
Alpha = 0,
Size = wedged_container_size,
RelativeSizeAxes = Axes.X,
Margin = new MarginPadding
@ -130,7 +149,7 @@ namespace osu.Game.Screens.Select
Right = left_area_padding,
},
},
new ResetScrollContainer(() => carousel.ScrollToSelected())
new ResetScrollContainer(() => Carousel.ScrollToSelected())
{
RelativeSizeAxes = Axes.Y,
Width = 250,
@ -190,15 +209,15 @@ namespace osu.Game.Screens.Select
initialAddSetsTask = new CancellationTokenSource();
carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets();
Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets();
Beatmap.DisabledChanged += disabled => carousel.AllowSelection = !disabled;
Beatmap.DisabledChanged += disabled => Carousel.AllowSelection = !disabled;
Beatmap.TriggerChange();
Beatmap.ValueChanged += b =>
{
if (IsCurrentScreen)
carousel.SelectBeatmap(b?.BeatmapInfo);
Carousel.SelectBeatmap(b?.BeatmapInfo);
};
}
@ -212,9 +231,9 @@ namespace osu.Game.Screens.Select
{
// 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.FlushPendingFilterOperations();
Carousel.FlushPendingFilterOperations();
carousel.SelectBeatmap(beatmap);
Carousel.SelectBeatmap(beatmap);
if (selectionChangedDebounce?.Completed == false)
{
@ -282,9 +301,9 @@ namespace osu.Game.Screens.Select
private void triggerRandom()
{
if (GetContainingInputManager().CurrentState.Keyboard.ShiftPressed)
carousel.SelectPreviousRandom();
Carousel.SelectPreviousRandom();
else
carousel.SelectNextRandom();
Carousel.SelectNextRandom();
}
protected override void OnEntering(Screen last)
@ -399,7 +418,6 @@ namespace osu.Game.Screens.Select
backgroundModeBeatmap.FadeTo(1, 250);
}
beatmapInfoWedge.State = Visibility.Visible;
beatmapInfoWedge.UpdateBeatmap(beatmap);
}
@ -417,17 +435,17 @@ namespace osu.Game.Screens.Select
}
}
private void onBeatmapSetAdded(BeatmapSetInfo s) => carousel.UpdateBeatmapSet(s);
private void onBeatmapSetRemoved(BeatmapSetInfo s) => carousel.RemoveBeatmapSet(s);
private void onBeatmapRestored(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void onBeatmapHidden(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(s);
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s);
private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void carouselBeatmapsLoaded()
{
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
else
carousel.SelectNextRandom();
Carousel.SelectNextRandom();
}
private void delete(BeatmapSetInfo beatmap)

View File

@ -239,7 +239,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Audio\SampleInfo.cs" />
<Compile Include="Audio\SampleInfoList.cs" />
<Compile Include="Beatmaps\Beatmap.cs" />
<Compile Include="Beatmaps\BeatmapConverter.cs" />
<Compile Include="Beatmaps\BeatmapDifficulty.cs" />
@ -311,6 +310,7 @@
<Compile Include="Overlays\Profile\Sections\Ranks\DrawableTotalScore.cs" />
<Compile Include="Overlays\Profile\Sections\Ranks\ScoreModsContainer.cs" />
<Compile Include="Overlays\Settings\Sections\Maintenance\DeleteAllBeatmapsDialog.cs" />
<Compile Include="Screens\Select\ImportFromStablePopup.cs" />
<Compile Include="Overlays\Settings\SettingsButton.cs" />
<Compile Include="Rulesets\Edit\Layers\Selection\OriginHandle.cs" />
<Compile Include="Rulesets\Edit\Layers\Selection\HitObjectSelectionBox.cs" />