1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-14 01:42:59 +08:00

Merge remote-tracking branch 'upstream/master' into hide-useless-beatmap-info

This commit is contained in:
Dean Herbert 2017-12-26 20:18:53 +09:00
commit 3182c22c7d
131 changed files with 10325 additions and 795 deletions

@ -1 +1 @@
Subproject commit f4fde31f8c09305d2130064da2f7bae995be8286 Subproject commit 46d4704b0a3f140fa8ad10ca0b1553b67d8385ab

View File

@ -37,9 +37,9 @@ namespace osu.Game.Rulesets.Catch.Objects
/// </summary> /// </summary>
public CatchHitObject HyperDashTarget; public CatchHitObject HyperDashTarget;
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
Scale = 1.0f - 0.7f * (difficulty.CircleSize - 5) / 5; Scale = 1.0f - 0.7f * (difficulty.CircleSize - 5) / 5;
} }

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.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using OpenTK; using OpenTK;
@ -25,7 +26,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
RelativeChildSize = new Vector2(1, (float)HitObject.Duration) RelativeChildSize = new Vector2(1, (float)HitObject.Duration)
}; };
foreach (CatchHitObject tick in s.Ticks) foreach (CatchHitObject tick in s.NestedHitObjects.OfType<CatchHitObject>())
{ {
TinyDroplet tiny = tick as TinyDroplet; TinyDroplet tiny = tick as TinyDroplet;
if (tiny != null) if (tiny != null)

View File

@ -11,7 +11,6 @@ using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using OpenTK; using OpenTK;
using osu.Framework.Lists;
namespace osu.Game.Rulesets.Catch.Objects namespace osu.Game.Rulesets.Catch.Objects
{ {
@ -29,9 +28,9 @@ namespace osu.Game.Rulesets.Catch.Objects
public double Velocity; public double Velocity;
public double TickDistance; public double TickDistance;
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime); DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
@ -42,14 +41,17 @@ namespace osu.Game.Rulesets.Catch.Objects
TickDistance = scoringDistance / difficulty.SliderTickRate; TickDistance = scoringDistance / difficulty.SliderTickRate;
} }
public IEnumerable<CatchHitObject> Ticks protected override void CreateNestedHitObjects()
{ {
get base.CreateNestedHitObjects();
{
SortedList<CatchHitObject> ticks = new SortedList<CatchHitObject>((a, b) => a.StartTime.CompareTo(b.StartTime));
createTicks();
}
private void createTicks()
{
if (TickDistance == 0) if (TickDistance == 0)
return ticks; return;
var length = Curve.Distance; var length = Curve.Distance;
var tickDistance = Math.Min(TickDistance, length); var tickDistance = Math.Min(TickDistance, length);
@ -57,7 +59,7 @@ namespace osu.Game.Rulesets.Catch.Objects
var minDistanceFromEnd = Velocity * 0.01; var minDistanceFromEnd = Velocity * 0.01;
ticks.Add(new Fruit AddNested(new Fruit
{ {
Samples = Samples, Samples = Samples,
ComboColour = ComboColour, ComboColour = ComboColour,
@ -79,12 +81,12 @@ namespace osu.Game.Rulesets.Catch.Objects
var distanceProgress = reversed ? 1 - timeProgress : timeProgress; var distanceProgress = reversed ? 1 - timeProgress : timeProgress;
var lastTickTime = repeatStartTime + timeProgress * repeatDuration; var lastTickTime = repeatStartTime + timeProgress * repeatDuration;
ticks.Add(new Droplet AddNested(new Droplet
{ {
StartTime = lastTickTime, StartTime = lastTickTime,
ComboColour = ComboColour, ComboColour = ComboColour,
X = Curve.PositionAt(distanceProgress).X / CatchPlayfield.BASE_WIDTH, 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, Bank = s.Bank,
Name = @"slidertick", Name = @"slidertick",
@ -101,12 +103,12 @@ namespace osu.Game.Rulesets.Catch.Objects
{ {
double progress = reversed ? 1 - t / repeatDuration : t / repeatDuration; double progress = reversed ? 1 - t / repeatDuration : t / repeatDuration;
ticks.Add(new TinyDroplet AddNested(new TinyDroplet
{ {
StartTime = repeatStartTime + t, StartTime = repeatStartTime + t,
ComboColour = ComboColour, ComboColour = ComboColour,
X = Curve.PositionAt(progress).X / CatchPlayfield.BASE_WIDTH, 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, Bank = s.Bank,
Name = @"slidertick", Name = @"slidertick",
@ -115,7 +117,7 @@ namespace osu.Game.Rulesets.Catch.Objects
}); });
} }
ticks.Add(new Fruit AddNested(new Fruit
{ {
Samples = Samples, Samples = Samples,
ComboColour = ComboColour, ComboColour = ComboColour,
@ -124,10 +126,9 @@ namespace osu.Game.Rulesets.Catch.Objects
}); });
} }
return ticks;
}
} }
public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity; public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity;
public float EndX => Curve.PositionAt(ProgressAt(1)).X / CatchPlayfield.BASE_WIDTH; public float EndX => Curve.PositionAt(ProgressAt(1)).X / CatchPlayfield.BASE_WIDTH;
@ -146,7 +147,7 @@ namespace osu.Game.Rulesets.Catch.Objects
set { Curve.ControlPoints = value; } 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 public CurveType CurveType
{ {

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.Linq;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
@ -28,7 +29,7 @@ namespace osu.Game.Rulesets.Catch.Scoring
AddJudgement(new CatchJudgement { Result = HitResult.Perfect }); AddJudgement(new CatchJudgement { Result = HitResult.Perfect });
AddJudgement(new CatchJudgement { Result = HitResult.Perfect }); AddJudgement(new CatchJudgement { Result = HitResult.Perfect });
foreach (var unused in stream.Ticks) foreach (var unused in stream.NestedHitObjects.OfType<CatchHitObject>())
AddJudgement(new CatchJudgement { Result = HitResult.Perfect }); AddJudgement(new CatchJudgement { Result = HitResult.Perfect });
continue; continue;

View File

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

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.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -435,7 +436,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
/// </summary> /// </summary>
/// <param name="time">The time to retrieve the sample info list from.</param> /// <param name="time">The time to retrieve the sample info list from.</param>
/// <returns></returns> /// <returns></returns>
private SampleInfoList sampleInfoListAt(double time) private List<SampleInfo> sampleInfoListAt(double time)
{ {
var curveData = HitObject as IHasCurve; var curveData = HitObject as IHasCurve;

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

View File

@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
} }
}); });
foreach (var tick in HitObject.Ticks) foreach (var tick in HitObject.NestedHitObjects.OfType<HoldNoteTick>())
{ {
var drawableTick = new DrawableHoldNoteTick(tick) var drawableTick = new DrawableHoldNoteTick(tick)
{ {

View File

@ -1,7 +1,6 @@
// 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.Collections.Generic;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
@ -63,9 +62,9 @@ namespace osu.Game.Rulesets.Mania.Objects
/// </summary> /// </summary>
private double tickSpacing = 50; private double tickSpacing = 50;
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
@ -74,29 +73,27 @@ namespace osu.Game.Rulesets.Mania.Objects
Tail.ApplyDefaults(controlPointInfo, difficulty); Tail.ApplyDefaults(controlPointInfo, difficulty);
} }
/// <summary> protected override void CreateNestedHitObjects()
/// The scoring scoring ticks of the hold note.
/// </summary>
public IEnumerable<HoldNoteTick> Ticks => ticks ?? (ticks = createTicks());
private List<HoldNoteTick> ticks;
private List<HoldNoteTick> createTicks()
{ {
var ret = new List<HoldNoteTick>(); base.CreateNestedHitObjects();
createTicks();
}
private void createTicks()
{
if (tickSpacing == 0) if (tickSpacing == 0)
return ret; return;
for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing) for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing)
{ {
ret.Add(new HoldNoteTick AddNested(new HoldNoteTick
{ {
StartTime = t, StartTime = t,
Column = Column Column = Column
}); });
} }
return ret;
} }
/// <summary> /// <summary>
@ -110,9 +107,9 @@ namespace osu.Game.Rulesets.Mania.Objects
/// </summary> /// </summary>
private const double release_window_lenience = 1.5; private const double release_window_lenience = 1.5;
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
HitWindows *= release_window_lenience; HitWindows *= release_window_lenience;
} }

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 Newtonsoft.Json;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Judgements;
@ -15,11 +16,12 @@ namespace osu.Game.Rulesets.Mania.Objects
/// <summary> /// <summary>
/// The key-press hit window for this note. /// The key-press hit window for this note.
/// </summary> /// </summary>
[JsonIgnore]
public HitWindows HitWindows { get; protected set; } = new HitWindows(); public HitWindows HitWindows { get; protected set; } = new HitWindows();
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
HitWindows = new HitWindows(difficulty.OverallDifficulty); HitWindows = new HitWindows(difficulty.OverallDifficulty);
} }

View File

@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Mania.Scoring
AddJudgement(new ManiaJudgement { Result = HitResult.Perfect }); AddJudgement(new ManiaJudgement { Result = HitResult.Perfect });
// Ticks // Ticks
int tickCount = holdNote.Ticks.Count(); int tickCount = holdNote.NestedHitObjects.OfType<HoldNoteTick>().Count();
for (int i = 0; i < tickCount; i++) for (int i = 0; i < tickCount; i++)
AddJudgement(new HoldNoteTickJudgement { Result = HitResult.Perfect }); AddJudgement(new HoldNoteTickJudgement { Result = HitResult.Perfect });
} }

View File

@ -9,7 +9,6 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Lists;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
@ -44,7 +43,7 @@ namespace osu.Game.Rulesets.Mania.UI
// Generate the bar lines // Generate the bar lines
double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue; double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue;
SortedList<TimingControlPoint> timingPoints = Beatmap.ControlPointInfo.TimingPoints; var timingPoints = Beatmap.ControlPointInfo.TimingPoints;
var barLines = new List<DrawableBarLine>(); var barLines = new List<DrawableBarLine>();
for (int i = 0; i < timingPoints.Count; i++) for (int i = 0; i < timingPoints.Count; i++)

View File

@ -40,6 +40,10 @@
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath> <HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
</ItemGroup> </ItemGroup>

View File

@ -9,5 +9,7 @@ namespace osu.Game.Rulesets.Osu.Edit
public class OsuEditPlayfield : OsuPlayfield public class OsuEditPlayfield : OsuPlayfield
{ {
protected override CursorContainer CreateCursor() => null; protected override CursorContainer CreateCursor() => null;
protected override bool ProxyApproachCircles => false;
} }
} }

View File

@ -57,6 +57,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Scale = s.Scale, Scale = s.Scale,
ComboColour = s.ComboColour, ComboColour = s.ComboColour,
Samples = s.Samples, Samples = s.Samples,
SampleControlPoint = s.SampleControlPoint
}) })
}; };
@ -66,7 +67,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
AddNested(initialCircle); AddNested(initialCircle);
var repeatDuration = s.Curve.Distance / s.Velocity; var repeatDuration = s.Curve.Distance / s.Velocity;
foreach (var tick in s.Ticks) foreach (var tick in s.NestedHitObjects.OfType<SliderTick>())
{ {
var repeatStartTime = s.StartTime + tick.RepeatIndex * repeatDuration; var repeatStartTime = s.StartTime + tick.RepeatIndex * repeatDuration;
var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2); var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2);
@ -83,7 +84,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
AddNested(drawableTick); AddNested(drawableTick);
} }
foreach (var repeatPoint in s.RepeatPoints) foreach (var repeatPoint in s.NestedHitObjects.OfType<RepeatPoint>())
{ {
var repeatStartTime = s.StartTime + repeatPoint.RepeatIndex * repeatDuration; var repeatStartTime = s.StartTime + repeatPoint.RepeatIndex * repeatDuration;
var fadeInTime = repeatStartTime + (repeatPoint.StartTime - repeatStartTime) / 2 - (repeatPoint.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2); var fadeInTime = repeatStartTime + (repeatPoint.StartTime - repeatStartTime) / 2 - (repeatPoint.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2);

View File

@ -68,9 +68,9 @@ namespace osu.Game.Rulesets.Osu.Objects
return HitResult.Miss; return HitResult.Miss;
} }
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2; Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2;
} }

View File

@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Osu.Objects
/// </summary> /// </summary>
internal float LazyTravelDistance; 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; public int RepeatCount { get; set; } = 1;
private int stackHeight; private int stackHeight;
@ -74,9 +74,9 @@ namespace osu.Game.Rulesets.Osu.Objects
public double Velocity; public double Velocity;
public double TickDistance; public double TickDistance;
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime); DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
@ -99,11 +99,17 @@ namespace osu.Game.Rulesets.Osu.Objects
public int RepeatAt(double progress) => (int)(progress * RepeatCount); public int RepeatAt(double progress) => (int)(progress * RepeatCount);
public IEnumerable<SliderTick> Ticks protected override void CreateNestedHitObjects()
{ {
get base.CreateNestedHitObjects();
createTicks();
createRepeatPoints();
}
private void createTicks()
{ {
if (TickDistance == 0) yield break; if (TickDistance == 0) return;
var length = Curve.Distance; var length = Curve.Distance;
var tickDistance = Math.Min(TickDistance, length); var tickDistance = Math.Min(TickDistance, length);
@ -124,7 +130,7 @@ namespace osu.Game.Rulesets.Osu.Objects
var distanceProgress = d / length; var distanceProgress = d / length;
var timeProgress = reversed ? 1 - distanceProgress : distanceProgress; var timeProgress = reversed ? 1 - distanceProgress : distanceProgress;
yield return new SliderTick AddNested(new SliderTick
{ {
RepeatIndex = repeat, RepeatIndex = repeat,
StartTime = repeatStartTime + timeProgress * repeatDuration, StartTime = repeatStartTime + timeProgress * repeatDuration,
@ -132,20 +138,18 @@ namespace osu.Game.Rulesets.Osu.Objects
StackHeight = StackHeight, StackHeight = StackHeight,
Scale = Scale, Scale = Scale,
ComboColour = ComboColour, ComboColour = ComboColour,
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
{ {
Bank = s.Bank, Bank = s.Bank,
Name = @"slidertick", Name = @"slidertick",
Volume = s.Volume Volume = s.Volume
})) }))
}; });
} }
} }
} }
}
public IEnumerable<RepeatPoint> RepeatPoints private void createRepeatPoints()
{
get
{ {
var length = Curve.Distance; var length = Curve.Distance;
var repeatPointDistance = Math.Min(Distance, length); var repeatPointDistance = Math.Min(Distance, length);
@ -158,7 +162,7 @@ namespace osu.Game.Rulesets.Osu.Objects
var repeatStartTime = StartTime + repeat * repeatDuration; var repeatStartTime = StartTime + repeat * repeatDuration;
var distanceProgress = d / length; var distanceProgress = d / length;
yield return new RepeatPoint AddNested(new RepeatPoint
{ {
RepeatIndex = repeat, RepeatIndex = repeat,
StartTime = repeatStartTime, StartTime = repeatStartTime,
@ -166,8 +170,8 @@ namespace osu.Game.Rulesets.Osu.Objects
StackHeight = StackHeight, StackHeight = StackHeight,
Scale = Scale, Scale = Scale,
ComboColour = ComboColour, ComboColour = ComboColour,
}; Samples = new List<SampleInfo>(RepeatSamples[repeat])
} });
} }
} }
} }

View File

@ -19,9 +19,9 @@ namespace osu.Game.Rulesets.Osu.Objects
public override bool NewCombo => true; public override bool NewCombo => true;
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
SpinsRequired = (int)(Duration / 1000 * BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 3, 5, 7.5)); SpinsRequired = (int)(Duration / 1000 * BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 3, 5, 7.5));

View File

@ -107,7 +107,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
} }
}); });
var scoringTimes = slider.Ticks.Select(t => t.StartTime).Concat(slider.RepeatPoints.Select(r => r.StartTime)).OrderBy(t => t); var scoringTimes = slider.NestedHitObjects.Select(t => t.StartTime);
foreach (var time in scoringTimes) foreach (var time in scoringTimes)
computeVertex(time); computeVertex(time);
computeVertex(slider.EndTime); computeVertex(slider.EndTime);

View File

@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
countHitCircles = Beatmap.HitObjects.Count(h => h is HitCircle); countHitCircles = Beatmap.HitObjects.Count(h => h is HitCircle);
beatmapMaxCombo = Beatmap.HitObjects.Count; beatmapMaxCombo = Beatmap.HitObjects.Count;
beatmapMaxCombo += Beatmap.HitObjects.OfType<Slider>().Sum(s => s.RepeatCount + s.Ticks.Count()); beatmapMaxCombo += Beatmap.HitObjects.OfType<Slider>().Sum(s => s.NestedHitObjects.Count) + 1;
} }
public override double Calculate(Dictionary<string, double> categoryRatings = null) public override double Calculate(Dictionary<string, double> categoryRatings = null)

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.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
@ -39,11 +40,11 @@ namespace osu.Game.Rulesets.Osu.Scoring
AddJudgement(new OsuJudgement { Result = HitResult.Great }); AddJudgement(new OsuJudgement { Result = HitResult.Great });
// Ticks // Ticks
foreach (var unused in slider.Ticks) foreach (var unused in slider.NestedHitObjects.OfType<SliderTick>())
AddJudgement(new OsuJudgement { Result = HitResult.Great }); AddJudgement(new OsuJudgement { Result = HitResult.Great });
//Repeats //Repeats
foreach (var unused in slider.RepeatPoints) foreach (var unused in slider.NestedHitObjects.OfType<RepeatPoint>())
AddJudgement(new OsuJudgement { Result = HitResult.Great }); AddJudgement(new OsuJudgement { Result = HitResult.Great });
} }

View File

@ -25,6 +25,10 @@ namespace osu.Game.Rulesets.Osu.UI
public override bool ProvidingUserCursor => true; public override bool ProvidingUserCursor => true;
// Todo: This should not be a thing, but is currently required for the editor
// https://github.com/ppy/osu-framework/issues/1283
protected virtual bool ProxyApproachCircles => true;
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384); public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
public override Vector2 Size public override Vector2 Size
@ -80,7 +84,7 @@ namespace osu.Game.Rulesets.Osu.UI
h.Depth = (float)h.HitObject.StartTime; h.Depth = (float)h.HitObject.StartTime;
var c = h as IDrawableHitObjectWithProxiedApproach; var c = h as IDrawableHitObjectWithProxiedApproach;
if (c != null) if (c != null && ProxyApproachCircles)
approachCircles.Add(c.ProxiedLayer.CreateProxy()); approachCircles.Add(c.ProxiedLayer.CreateProxy());
base.Add(h); base.Add(h);

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; var curveData = obj as IHasCurve;
// Old osu! used hit sounding to determine various hit type information // 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); 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) 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; int i = 0;
for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing) 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); bool isRim = currentSamples.Any(s => s.Name == SampleInfo.HIT_CLAP || s.Name == SampleInfo.HIT_WHISTLE);
strong = currentSamples.Any(s => s.Name == SampleInfo.HIT_FINISH); strong = currentSamples.Any(s => s.Name == SampleInfo.HIT_FINISH);

View File

@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
RelativeChildSize = new Vector2((float)HitObject.Duration, 1) RelativeChildSize = new Vector2((float)HitObject.Duration, 1)
}); });
foreach (var tick in drumRoll.Ticks) foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
{ {
var newTick = new DrawableDrumRollTick(tick); var newTick = new DrawableDrumRollTick(tick);
newTick.OnJudgement += onTickJudgement; newTick.OnJudgement += onTickJudgement;

View File

@ -67,6 +67,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {
validKeyPressed = HitActions.Contains(action); validKeyPressed = HitActions.Contains(action);
// Only count this as handled if the new judgement is a hit
return UpdateJudgement(true); return UpdateJudgement(true);
} }

View File

@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
if (!userTriggered) if (!userTriggered)
{ {
if (timeOffset > second_hit_window) if (timeOffset > second_hit_window)
AddJudgement(new TaikoStrongHitJudgement { Result = HitResult.Miss }); AddJudgement(new TaikoStrongHitJudgement { Result = HitResult.None });
return; return;
} }

View File

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

View File

@ -6,6 +6,9 @@ using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces; using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
using OpenTK; using OpenTK;
using System.Linq;
using osu.Game.Audio;
using System.Collections.Generic;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {
@ -35,6 +38,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
MainPiece.KiaiMode = HitObject.Kiai; 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(); protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
public abstract bool OnPressed(TaikoAction action); public abstract bool OnPressed(TaikoAction action);

View File

@ -37,53 +37,46 @@ namespace osu.Game.Rulesets.Taiko.Objects
/// </summary> /// </summary>
public double RequiredGreatHits { get; protected set; } public double RequiredGreatHits { get; protected set; }
/// <summary>
/// Total number of drum roll ticks.
/// </summary>
public int TotalTicks => Ticks.Count();
/// <summary>
/// Initializes the drum roll ticks if not initialized and returns them.
/// </summary>
public IEnumerable<DrumRollTick> Ticks => ticks ?? (ticks = createTicks());
private List<DrumRollTick> ticks;
/// <summary> /// <summary>
/// The length (in milliseconds) between ticks of this drumroll. /// The length (in milliseconds) between ticks of this drumroll.
/// <para>Half of this value is the hit window of the ticks.</para> /// <para>Half of this value is the hit window of the ticks.</para>
/// </summary> /// </summary>
private double tickSpacing = 100; private double tickSpacing = 100;
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
tickSpacing = timingPoint.BeatLength / TickRate; tickSpacing = timingPoint.BeatLength / TickRate;
RequiredGoodHits = TotalTicks * Math.Min(0.15, 0.05 + 0.10 / 6 * difficulty.OverallDifficulty); RequiredGoodHits = NestedHitObjects.Count * Math.Min(0.15, 0.05 + 0.10 / 6 * difficulty.OverallDifficulty);
RequiredGreatHits = TotalTicks * Math.Min(0.30, 0.10 + 0.20 / 6 * difficulty.OverallDifficulty); RequiredGreatHits = NestedHitObjects.Count * Math.Min(0.30, 0.10 + 0.20 / 6 * difficulty.OverallDifficulty);
} }
private List<DrumRollTick> createTicks() protected override void CreateNestedHitObjects()
{ {
var ret = new List<DrumRollTick>(); base.CreateNestedHitObjects();
createTicks();
}
private void createTicks()
{
if (tickSpacing == 0) if (tickSpacing == 0)
return ret; return;
bool first = true; bool first = true;
for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing) for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing)
{ {
ret.Add(new DrumRollTick AddNested(new DrumRollTick
{ {
FirstTick = first, FirstTick = first,
TickSpacing = tickSpacing, TickSpacing = tickSpacing,
StartTime = t, StartTime = t,
IsStrong = IsStrong, IsStrong = IsStrong,
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
{ {
Bank = s.Bank, Bank = s.Bank,
Name = @"slidertick", Name = @"slidertick",
@ -93,8 +86,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
first = false; first = false;
} }
return ret;
} }
} }
} }

View File

@ -23,9 +23,9 @@ namespace osu.Game.Rulesets.Taiko.Objects
/// </summary> /// </summary>
public double HitWindowMiss = 95; public double HitWindowMiss = 95;
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(controlPointInfo, difficulty); base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
HitWindowGreat = BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 50, 35, 20); HitWindowGreat = BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 50, 35, 20);
HitWindowGood = BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 120, 80, 50); HitWindowGood = BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 120, 80, 50);

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
@ -83,7 +84,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
} }
else if (drumRoll != null) else if (drumRoll != null)
{ {
foreach (var tick in drumRoll.Ticks) foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
{ {
Frames.Add(new ReplayFrame(tick.StartTime, null, null, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2)); Frames.Add(new ReplayFrame(tick.StartTime, null, null, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2));
hitButton = !hitButton; hitButton = !hitButton;

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.Linq;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
@ -88,7 +89,7 @@ namespace osu.Game.Rulesets.Taiko.Scoring
} }
else if (obj is DrumRoll) else if (obj is DrumRoll)
{ {
for (int i = 0; i < ((DrumRoll)obj).TotalTicks; i++) for (int i = 0; i < ((DrumRoll)obj).NestedHitObjects.OfType<DrumRollTick>().Count(); i++)
{ {
AddJudgement(new TaikoDrumRollTickJudgement { Result = HitResult.Great }); AddJudgement(new TaikoDrumRollTickJudgement { Result = HitResult.Great });

View File

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

View File

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

View File

@ -16,6 +16,7 @@ using osu.Framework.Extensions.Color4Extensions;
using System.Linq; using System.Linq;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Taiko.Objects.Drawables; using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Beatmaps.ControlPoints;
namespace osu.Game.Rulesets.Taiko.UI namespace osu.Game.Rulesets.Taiko.UI
{ {
@ -54,7 +55,7 @@ namespace osu.Game.Rulesets.Taiko.UI
private readonly Box overlayBackground; private readonly Box overlayBackground;
private readonly Box background; private readonly Box background;
public TaikoPlayfield() public TaikoPlayfield(ControlPointInfo controlPoints)
: base(Axes.X) : base(Axes.X)
{ {
AddRangeInternal(new Drawable[] AddRangeInternal(new Drawable[]
@ -149,7 +150,7 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
new InputDrum new InputDrum(controlPoints)
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
@ -249,7 +250,9 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
topLevelHitContainer.Add(judgedObject.CreateProxy()); topLevelHitContainer.Add(judgedObject.CreateProxy());
} }
catch { } catch
{
}
} }
hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim)); hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim));

View File

@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Taiko.UI
public override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo); public override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo);
protected override Playfield CreatePlayfield() => new TaikoPlayfield protected override Playfield CreatePlayfield() => new TaikoPlayfield(Beatmap.ControlPointInfo)
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft Origin = Anchor.CentreLeft

View File

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

View File

@ -146,8 +146,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual(116999, difficultyPoint.Time); Assert.AreEqual(116999, difficultyPoint.Time);
Assert.AreEqual(0.75000000000000189d, difficultyPoint.SpeedMultiplier); Assert.AreEqual(0.75000000000000189d, difficultyPoint.SpeedMultiplier);
Assert.AreEqual(34, controlPoints.SoundPoints.Count); Assert.AreEqual(34, controlPoints.SamplePoints.Count);
var soundPoint = controlPoints.SoundPoints[0]; var soundPoint = controlPoints.SamplePoints[0];
Assert.AreEqual(956, soundPoint.Time); Assert.AreEqual(956, soundPoint.Time);
Assert.AreEqual("soft", soundPoint.SampleBank); Assert.AreEqual("soft", soundPoint.SampleBank);
Assert.AreEqual(60, soundPoint.SampleVolume); Assert.AreEqual(60, soundPoint.SampleVolume);

View File

@ -0,0 +1,176 @@
// 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.IO;
using System.Linq;
using DeepEqual.Syntax;
using NUnit.Framework;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Tests.Resources;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Tests.Beatmaps.Formats
{
[TestFixture]
public class OsuJsonDecoderTest
{
private const string normal = "Soleily - Renatus (Gamu) [Insane].osu";
private const string marathon = "Within Temptation - The Unforgiving (Armin) [Marathon].osu";
private const string with_sb = "Kozato snow - Rengetsu Ouka (_Kiva) [Yuki YukI].osu";
[Test]
public void TestDecodeMetadata()
{
var beatmap = decodeAsJson(normal);
var meta = beatmap.BeatmapInfo.Metadata;
Assert.AreEqual(241526, meta.OnlineBeatmapSetID);
Assert.AreEqual("Soleily", meta.Artist);
Assert.AreEqual("Soleily", meta.ArtistUnicode);
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
Assert.AreEqual("Gamu", meta.AuthorString);
Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile);
Assert.AreEqual(164471, meta.PreviewTime);
Assert.AreEqual(string.Empty, meta.Source);
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags);
Assert.AreEqual("Renatus", meta.Title);
Assert.AreEqual("Renatus", meta.TitleUnicode);
}
[Test]
public void TestDecodeGeneral()
{
var beatmap = decodeAsJson(normal);
var beatmapInfo = beatmap.BeatmapInfo;
Assert.AreEqual(0, beatmapInfo.AudioLeadIn);
Assert.AreEqual(false, beatmapInfo.Countdown);
Assert.AreEqual(0.7f, beatmapInfo.StackLeniency);
Assert.AreEqual(false, beatmapInfo.SpecialStyle);
Assert.IsTrue(beatmapInfo.RulesetID == 0);
Assert.AreEqual(false, beatmapInfo.LetterboxInBreaks);
Assert.AreEqual(false, beatmapInfo.WidescreenStoryboard);
}
[Test]
public void TestDecodeEditor()
{
var beatmap = decodeAsJson(normal);
var beatmapInfo = beatmap.BeatmapInfo;
int[] expectedBookmarks =
{
11505, 22054, 32604, 43153, 53703, 64252, 74802, 85351,
95901, 106450, 116999, 119637, 130186, 140735, 151285,
161834, 164471, 175020, 185570, 196119, 206669, 209306
};
Assert.AreEqual(expectedBookmarks.Length, beatmapInfo.Bookmarks.Length);
for (int i = 0; i < expectedBookmarks.Length; i++)
Assert.AreEqual(expectedBookmarks[i], beatmapInfo.Bookmarks[i]);
Assert.AreEqual(1.8, beatmapInfo.DistanceSpacing);
Assert.AreEqual(4, beatmapInfo.BeatDivisor);
Assert.AreEqual(4, beatmapInfo.GridSize);
Assert.AreEqual(2, beatmapInfo.TimelineZoom);
}
[Test]
public void TestDecodeDifficulty()
{
var beatmap = decodeAsJson(normal);
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
Assert.AreEqual(6.5f, difficulty.DrainRate);
Assert.AreEqual(4, difficulty.CircleSize);
Assert.AreEqual(8, difficulty.OverallDifficulty);
Assert.AreEqual(9, difficulty.ApproachRate);
Assert.AreEqual(1.8f, difficulty.SliderMultiplier);
Assert.AreEqual(2, difficulty.SliderTickRate);
}
[Test]
public void TestDecodeColors()
{
var beatmap = decodeAsJson(normal);
Color4[] expected =
{
new Color4(142, 199, 255, 255),
new Color4(255, 128, 128, 255),
new Color4(128, 255, 255, 255),
new Color4(128, 255, 128, 255),
new Color4(255, 187, 255, 255),
new Color4(255, 177, 140, 255),
};
Assert.AreEqual(expected.Length, beatmap.ComboColors.Count);
for (int i = 0; i < expected.Length; i++)
Assert.AreEqual(expected[i], beatmap.ComboColors[i]);
}
[Test]
public void TestDecodeHitObjects()
{
var beatmap = decodeAsJson(normal);
var curveData = beatmap.HitObjects[0] as IHasCurve;
var positionData = beatmap.HitObjects[0] as IHasPosition;
Assert.IsNotNull(positionData);
Assert.IsNotNull(curveData);
Assert.AreEqual(new Vector2(192, 168), positionData.Position);
Assert.AreEqual(956, beatmap.HitObjects[0].StartTime);
Assert.IsTrue(beatmap.HitObjects[0].Samples.Any(s => s.Name == SampleInfo.HIT_NORMAL));
positionData = beatmap.HitObjects[1] as IHasPosition;
Assert.IsNotNull(positionData);
Assert.AreEqual(new Vector2(304, 56), positionData.Position);
Assert.AreEqual(1285, beatmap.HitObjects[1].StartTime);
Assert.IsTrue(beatmap.HitObjects[1].Samples.Any(s => s.Name == SampleInfo.HIT_CLAP));
}
[TestCase(normal)]
[TestCase(marathon)]
// Currently fails:
// [TestCase(with_sb)]
public void TestParity(string beatmap)
{
var beatmaps = decode(beatmap);
beatmaps.jsonDecoded.ShouldDeepEqual(beatmaps.legacyDecoded);
}
/// <summary>
/// Reads a .osu file first with a <see cref="LegacyBeatmapDecoder"/>, serializes the resulting <see cref="Beatmap"/> to JSON
/// and then deserializes the result back into a <see cref="Beatmap"/> through an <see cref="JsonBeatmapDecoder"/>.
/// </summary>
/// <param name="filename">The .osu file to decode.</param>
/// <returns>The <see cref="Beatmap"/> after being decoded by an <see cref="LegacyBeatmapDecoder"/>.</returns>
private Beatmap decodeAsJson(string filename) => decode(filename).jsonDecoded;
/// <summary>
/// Reads a .osu file first with a <see cref="LegacyBeatmapDecoder"/>, serializes the resulting <see cref="Beatmap"/> to JSON
/// and then deserializes the result back into a <see cref="Beatmap"/> through an <see cref="JsonBeatmapDecoder"/>.
/// </summary>
/// <param name="filename">The .osu file to decode.</param>
/// <returns>The <see cref="Beatmap"/> after being decoded by an <see cref="LegacyBeatmapDecoder"/>.</returns>
private (Beatmap legacyDecoded, Beatmap jsonDecoded) decode(string filename)
{
using (var stream = Resource.OpenResource(filename))
using (var sr = new StreamReader(stream))
{
var legacyDecoded = new LegacyBeatmapDecoder().DecodeBeatmap(sr);
using (var ms = new MemoryStream())
using (var sw = new StreamWriter(ms))
using (var sr2 = new StreamReader(ms))
{
sw.Write(legacyDecoded.Serialize());
sw.Flush();
ms.Position = 0;
return (legacyDecoded, new JsonBeatmapDecoder().DecodeBeatmap(sr2));
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -7,13 +7,13 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Lists;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays; using osu.Game.Overlays;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Lists;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {

View File

@ -69,6 +69,8 @@ namespace osu.Game.Tests.Visual
testSorting(); testSorting();
testRemoveAll(); testRemoveAll();
testEmptyTraversal();
testHiding();
} }
private void ensureRandomFetchSuccess() => private void ensureRandomFetchSuccess() =>
@ -103,6 +105,8 @@ namespace osu.Game.Tests.Visual
AddAssert($"{count} {(diff ? "diffs" : "sets")} visible", () => AddAssert($"{count} {(diff ? "diffs" : "sets")} visible", () =>
carousel.Items.Count(s => (diff ? s.Item is CarouselBeatmap : s.Item is CarouselBeatmapSet) && s.Item.Visible) == count); carousel.Items.Count(s => (diff ? s.Item is CarouselBeatmap : s.Item is CarouselBeatmapSet) && s.Item.Visible) == count);
private void checkNoSelection() => AddAssert("Selection is null", () => currentSelection == null);
private void nextRandom() => private void nextRandom() =>
AddStep("select random next", () => AddStep("select random next", () =>
{ {
@ -274,9 +278,57 @@ namespace osu.Game.Tests.Visual
return false; return false;
}, "Remove all"); }, "Remove all");
AddAssert("Selection is null", () => currentSelection == null); checkNoSelection();
} }
private void testEmptyTraversal()
{
advanceSelection(direction: 1, diff: false);
checkNoSelection();
advanceSelection(direction: 1, diff: true);
checkNoSelection();
advanceSelection(direction: -1, diff: false);
checkNoSelection();
advanceSelection(direction: -1, diff: true);
checkNoSelection();
}
private void testHiding()
{
var hidingSet = createTestBeatmapSet(1);
hidingSet.Beatmaps[1].Hidden = true;
AddStep("Add set with diff 2 hidden", () => carousel.UpdateBeatmapSet(hidingSet));
setSelected(1, 1);
checkVisibleItemCount(true, 2);
advanceSelection(true);
checkSelected(1, 3);
setHidden(3);
checkSelected(1, 1);
setHidden(2, false);
advanceSelection(true);
checkSelected(1, 2);
setHidden(1);
checkSelected(1, 2);
setHidden(2);
checkNoSelection();
void setHidden(int diff, bool hidden = true)
{
AddStep((hidden ? "" : "un") + $"hide diff {diff}", () =>
{
hidingSet.Beatmaps[diff - 1].Hidden = hidden;
carousel.UpdateBeatmapSet(hidingSet);
});
}
}
private BeatmapSetInfo createTestBeatmapSet(int i) private BeatmapSetInfo createTestBeatmapSet(int i)
{ {

View File

@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual
b.ControlPointInfo.EffectPoints.Add(new EffectControlPoint { Time = random.Next(0, length) }); b.ControlPointInfo.EffectPoints.Add(new EffectControlPoint { Time = random.Next(0, length) });
for (int i = 0; i < random.Next(1, 5); i++) for (int i = 0; i < random.Next(1, 5); i++)
b.ControlPointInfo.SoundPoints.Add(new SoundControlPoint { Time = random.Next(0, length) }); b.ControlPointInfo.SamplePoints.Add(new SampleControlPoint { Time = random.Next(0, length) });
b.BeatmapInfo.Bookmarks = new int[random.Next(10, 30)]; b.BeatmapInfo.Bookmarks = new int[random.Next(10, 30)];
for (int i = 0; i < b.BeatmapInfo.Bookmarks.Length; i++) for (int i = 0; i < b.BeatmapInfo.Bookmarks.Length; i++)

View File

@ -36,6 +36,7 @@ namespace osu.Game.Tests.Visual
AddStep(@"Network failure", () => leaderboard.SetRetrievalState(PlaceholderState.NetworkFailure)); AddStep(@"Network failure", () => leaderboard.SetRetrievalState(PlaceholderState.NetworkFailure));
AddStep(@"No supporter", () => leaderboard.SetRetrievalState(PlaceholderState.NotSupporter)); AddStep(@"No supporter", () => leaderboard.SetRetrievalState(PlaceholderState.NotSupporter));
AddStep(@"Not logged in", () => leaderboard.SetRetrievalState(PlaceholderState.NotLoggedIn)); AddStep(@"Not logged in", () => leaderboard.SetRetrievalState(PlaceholderState.NotLoggedIn));
AddStep(@"Unavailable", () => leaderboard.SetRetrievalState(PlaceholderState.Unavailable));
AddStep(@"Real beatmap", realBeatmap); AddStep(@"Real beatmap", realBeatmap);
} }

View File

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

View File

@ -26,6 +26,7 @@ namespace osu.Game.Tests.Visual
private RulesetStore rulesets; private RulesetStore rulesets;
private DependencyContainer dependencies; private DependencyContainer dependencies;
private WorkingBeatmap defaultBeatmap;
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
@ -47,13 +48,17 @@ namespace osu.Game.Tests.Visual
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent); 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] [BackgroundDependencyLoader]
private void load(BeatmapManager baseManager) private void load(BeatmapManager baseManager)
{ {
PlaySongSelect songSelect; TestSongSelect songSelect = null;
if (manager == null)
{
var storage = new TestStorage(@"TestCasePlaySongSelect"); var storage = new TestStorage(@"TestCasePlaySongSelect");
// this is by no means clean. should be replacing inside of OsuGameBase somehow. // this is by no means clean. should be replacing inside of OsuGameBase somehow.
@ -64,14 +69,40 @@ namespace osu.Game.Tests.Visual
dependencies.Cache(rulesets = new RulesetStore(contextFactory)); dependencies.Cache(rulesets = new RulesetStore(contextFactory));
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null) dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
{ {
DefaultBeatmap = baseManager.GetWorkingBeatmap(null) DefaultBeatmap = defaultBeatmap = baseManager.GetWorkingBeatmap(null)
}); });
for (int i = 0; i < 100; i += 10) void loadNewSongSelect(bool deleteMaps = false) => AddStep("reload song select", () =>
manager.Import(createTestBeatmapSet(i)); {
if (deleteMaps) manager.DeleteAll();
if (songSelect != null)
{
Remove(songSelect);
songSelect.Dispose();
} }
Add(songSelect = new PlaySongSelect()); 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));
});
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 Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; }); AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });

View File

@ -0,0 +1,37 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Tests.Visual
{
public class TestCasePopupDialog : OsuTestCase
{
public TestCasePopupDialog()
{
var popup = new PopupDialog
{
RelativeSizeAxes = Axes.Both,
State = Framework.Graphics.Containers.Visibility.Visible,
Icon = FontAwesome.fa_assistive_listening_systems,
HeaderText = @"This is a test popup",
BodyText = "I can say lots of stuff and even wrap my words!",
Buttons = new PopupDialogButton[]
{
new PopupDialogCancelButton
{
Text = @"Yes. That you can.",
},
new PopupDialogOkButton
{
Text = @"You're a fake!",
},
}
};
Add(popup);
}
}
}

View File

@ -0,0 +1,123 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Overlays.Profile;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using OpenTK;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using System.Collections.Generic;
using System;
using osu.Game.Graphics.UserInterface;
using osu.Game.Users;
namespace osu.Game.Tests.Visual
{
public class TestCaseRankGraph : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(RankGraph),
typeof(LineGraph)
};
public TestCaseRankGraph()
{
RankGraph graph;
var data = new int[89];
var dataWithZeros = new int[89];
var smallData = new int[89];
for (int i = 0; i < 89; i++)
data[i] = dataWithZeros[i] = (i + 1) * 1000;
for (int i = 20; i < 60; i++)
dataWithZeros[i] = 0;
for (int i = 79; i < 89; i++)
smallData[i] = 100000 - i * 1000;
Add(new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(300, 150),
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f)
},
graph = new RankGraph
{
RelativeSizeAxes = Axes.Both,
}
}
});
AddStep("null user", () => graph.User.Value = null);
AddStep("rank only", () =>
{
graph.User.Value = new User
{
Statistics = new UserStatistics
{
Rank = 123456,
PP = 12345,
}
};
});
AddStep("with rank history", () =>
{
graph.User.Value = new User
{
Statistics = new UserStatistics
{
Rank = 89000,
PP = 12345,
},
RankHistory = new User.RankHistoryData
{
Data = data,
}
};
});
AddStep("with zero values", () =>
{
graph.User.Value = new User
{
Statistics = new UserStatistics
{
Rank = 89000,
PP = 12345,
},
RankHistory = new User.RankHistoryData
{
Data = dataWithZeros,
}
};
});
AddStep("small amount of data", () =>
{
graph.User.Value = new User
{
Statistics = new UserStatistics
{
Rank = 12000,
PP = 12345,
},
RankHistory = new User.RankHistoryData
{
Data = smallData,
}
};
});
}
}
}

View File

@ -0,0 +1,39 @@
// 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 osu.Framework.Graphics.Containers;
using osu.Game.Overlays.Toolbar;
namespace osu.Game.Tests.Visual
{
public class TestCaseToolbar : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ToolbarButton),
typeof(ToolbarModeSelector),
typeof(ToolbarModeButton),
typeof(ToolbarNotificationButton),
};
public TestCaseToolbar()
{
var toolbar = new Toolbar { State = Visibility.Visible };
Add(toolbar);
var notificationButton = toolbar.Children.OfType<FillFlowContainer>().Last().Children.OfType<ToolbarNotificationButton>().First();
void setNotifications(int count) => AddStep($"set notification count to {count}", () => notificationButton.NotificationCount.Value = count);
setNotifications(1);
setNotifications(2);
setNotifications(3);
setNotifications(0);
setNotifications(144);
}
}
}

View File

@ -2,18 +2,35 @@
// 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.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Profile;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
public class TestCaseUserProfile : OsuTestCase public class TestCaseUserProfile : OsuTestCase
{ {
private readonly TestUserProfileOverlay profile;
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ProfileHeader),
typeof(UserProfileOverlay),
typeof(RankGraph),
typeof(LineGraph),
};
public TestCaseUserProfile() public TestCaseUserProfile()
{ {
var profile = new UserProfileOverlay(); Add(profile = new TestUserProfileOverlay());
Add(profile); }
protected override void LoadComplete()
{
base.LoadComplete();
AddStep("Show offline dummy", () => profile.ShowUser(new User AddStep("Show offline dummy", () => profile.ShowUser(new User
{ {
@ -37,6 +54,9 @@ namespace osu.Game.Tests.Visual
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray() Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
} }
}, false)); }, false));
checkSupporterTag(false);
AddStep("Show ppy", () => profile.ShowUser(new User AddStep("Show ppy", () => profile.ShowUser(new User
{ {
Username = @"peppy", Username = @"peppy",
@ -44,6 +64,9 @@ namespace osu.Game.Tests.Visual
Country = new Country { FullName = @"Australia", FlagName = @"AU" }, Country = new Country { FullName = @"Australia", FlagName = @"AU" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
})); }));
checkSupporterTag(true);
AddStep("Show flyte", () => profile.ShowUser(new User AddStep("Show flyte", () => profile.ShowUser(new User
{ {
Username = @"flyte", Username = @"flyte",
@ -51,8 +74,23 @@ namespace osu.Game.Tests.Visual
Country = new Country { FullName = @"Japan", FlagName = @"JP" }, Country = new Country { FullName = @"Japan", FlagName = @"JP" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
})); }));
AddStep("Hide", profile.Hide); AddStep("Hide", profile.Hide);
AddStep("Show without reload", profile.Show); AddStep("Show without reload", profile.Show);
} }
private void checkSupporterTag(bool isSupporter)
{
AddUntilStep(() => profile.Header.User != null, "wait for load");
if (isSupporter)
AddAssert("is supporter", () => profile.Header.SupporterTag.Alpha == 1);
else
AddAssert("no supporter", () => profile.Header.SupporterTag.Alpha == 0);
}
private class TestUserProfileOverlay : UserProfileOverlay
{
public new ProfileHeader Header => base.Header;
}
} }
} }

View File

@ -30,6 +30,9 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="DeepEqual, Version=1.6.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>$(SolutionDir)\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath> <HintPath>$(SolutionDir)\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -83,6 +86,7 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Beatmaps\Formats\OsuJsonDecoderTest.cs" />
<Compile Include="Beatmaps\Formats\LegacyStoryboardDecoderTest.cs" /> <Compile Include="Beatmaps\Formats\LegacyStoryboardDecoderTest.cs" />
<Compile Include="Beatmaps\IO\OszArchiveReaderTest.cs" /> <Compile Include="Beatmaps\IO\OszArchiveReaderTest.cs" />
<Compile Include="Beatmaps\IO\ImportBeatmapTest.cs" /> <Compile Include="Beatmaps\IO\ImportBeatmapTest.cs" />
@ -130,6 +134,8 @@
<Compile Include="Visual\TestCaseOsuGame.cs" /> <Compile Include="Visual\TestCaseOsuGame.cs" />
<Compile Include="Visual\TestCasePlaybackControl.cs" /> <Compile Include="Visual\TestCasePlaybackControl.cs" />
<Compile Include="Visual\TestCasePlaySongSelect.cs" /> <Compile Include="Visual\TestCasePlaySongSelect.cs" />
<Compile Include="Visual\TestCasePopupDialog.cs" />
<Compile Include="Visual\TestCaseRankGraph.cs" />
<Compile Include="Visual\TestCaseReplay.cs" /> <Compile Include="Visual\TestCaseReplay.cs" />
<Compile Include="Visual\TestCaseReplaySettingsOverlay.cs" /> <Compile Include="Visual\TestCaseReplaySettingsOverlay.cs" />
<Compile Include="Visual\TestCaseResults.cs" /> <Compile Include="Visual\TestCaseResults.cs" />
@ -143,6 +149,7 @@
<Compile Include="Visual\TestCaseStoryboard.cs" /> <Compile Include="Visual\TestCaseStoryboard.cs" />
<Compile Include="Visual\TestCaseTabControl.cs" /> <Compile Include="Visual\TestCaseTabControl.cs" />
<Compile Include="Visual\TestCaseTextAwesome.cs" /> <Compile Include="Visual\TestCaseTextAwesome.cs" />
<Compile Include="Visual\TestCaseToolbar.cs" />
<Compile Include="Visual\TestCaseTwoLayerButton.cs" /> <Compile Include="Visual\TestCaseTwoLayerButton.cs" />
<Compile Include="Visual\TestCaseUserPanel.cs" /> <Compile Include="Visual\TestCaseUserPanel.cs" />
<Compile Include="Visual\TestCaseUserProfile.cs" /> <Compile Include="Visual\TestCaseUserProfile.cs" />
@ -152,6 +159,8 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Resources\Soleily - Renatus %28Gamu%29 [Insane].osu" /> <EmbeddedResource Include="Resources\Soleily - Renatus %28Gamu%29 [Insane].osu" />
<EmbeddedResource Include="Resources\Himeringo - Yotsuya-san ni Yoroshiku %28RLC%29 [Winber1%27s Extreme].osu" /> <EmbeddedResource Include="Resources\Himeringo - Yotsuya-san ni Yoroshiku %28RLC%29 [Winber1%27s Extreme].osu" />
<EmbeddedResource Include="Resources\Within Temptation - The Unforgiving %28Armin%29 [Marathon].osu" />
<EmbeddedResource Include="Resources\Kozato snow - Rengetsu Ouka %28_Kiva%29 [Yuki YukI].osu" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -4,6 +4,7 @@ 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
--> -->
<packages> <packages>
<package id="DeepEqual" version="1.6.0.0" targetFramework="net461" />
<package id="NUnit" version="3.8.1" targetFramework="net461" /> <package id="NUnit" version="3.8.1" targetFramework="net461" />
<package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" /> <package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" /> <package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />

View File

@ -1,8 +1,12 @@
// 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.Audio.Sample;
namespace osu.Game.Audio namespace osu.Game.Audio
{ {
[Serializable]
public class SampleInfo public class SampleInfo
{ {
public const string HIT_WHISTLE = @"hitwhistle"; public const string HIT_WHISTLE = @"hitwhistle";
@ -10,6 +14,13 @@ namespace osu.Game.Audio
public const string HIT_NORMAL = @"hitnormal"; public const string HIT_NORMAL = @"hitnormal";
public const string HIT_CLAP = @"hitclap"; public const string HIT_CLAP = @"hitclap";
public SampleChannel GetChannel(SampleManager manager)
{
var channel = manager.Get($"Gameplay/{Bank}-{Name}");
channel.Volume.Value = Volume / 100.0;
return channel;
}
/// <summary> /// <summary>
/// The bank to load the sample from. /// The bank to load the sample from.
/// </summary> /// </summary>

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

@ -8,19 +8,21 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.IO.Serialization; using osu.Game.IO.Serialization;
using Newtonsoft.Json;
using osu.Game.IO.Serialization.Converters;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
/// <summary> /// <summary>
/// A Beatmap containing converted HitObjects. /// A Beatmap containing converted HitObjects.
/// </summary> /// </summary>
public class Beatmap<T> public class Beatmap<T> : IJsonSerializable
where T : HitObject where T : HitObject
{ {
public BeatmapInfo BeatmapInfo = new BeatmapInfo(); public BeatmapInfo BeatmapInfo = new BeatmapInfo();
public ControlPointInfo ControlPointInfo = new ControlPointInfo(); public ControlPointInfo ControlPointInfo = new ControlPointInfo();
public List<BreakPeriod> Breaks = new List<BreakPeriod>(); public List<BreakPeriod> Breaks = new List<BreakPeriod>();
public readonly List<Color4> ComboColors = new List<Color4> public List<Color4> ComboColors = new List<Color4>
{ {
new Color4(17, 136, 170, 255), new Color4(17, 136, 170, 255),
new Color4(102, 136, 0, 255), new Color4(102, 136, 0, 255),
@ -28,16 +30,19 @@ namespace osu.Game.Beatmaps
new Color4(121, 9, 13, 255) new Color4(121, 9, 13, 255)
}; };
[JsonIgnore]
public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata; public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
/// <summary> /// <summary>
/// The HitObjects this Beatmap contains. /// The HitObjects this Beatmap contains.
/// </summary> /// </summary>
[JsonConverter(typeof(TypedListConverter<HitObject>))]
public List<T> HitObjects = new List<T>(); public List<T> HitObjects = new List<T>();
/// <summary> /// <summary>
/// Total amount of break time in the beatmap. /// Total amount of break time in the beatmap.
/// </summary> /// </summary>
[JsonIgnore]
public double TotalBreakTime => Breaks.Sum(b => b.Duration); public double TotalBreakTime => Breaks.Sum(b => b.Duration);
/// <summary> /// <summary>

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.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
@ -13,6 +14,7 @@ namespace osu.Game.Beatmaps
public const float DEFAULT_DIFFICULTY = 5; public const float DEFAULT_DIFFICULTY = 5;
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[JsonIgnore]
public int ID { get; set; } public int ID { get; set; }
public float DrainRate { get; set; } = DEFAULT_DIFFICULTY; public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;

View File

@ -12,9 +12,11 @@ using osu.Game.Rulesets;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
[Serializable]
public class BeatmapInfo : IEquatable<BeatmapInfo>, IJsonSerializable, IHasPrimaryKey public class BeatmapInfo : IEquatable<BeatmapInfo>, IJsonSerializable, IHasPrimaryKey
{ {
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[JsonIgnore]
public int ID { get; set; } public int ID { get; set; }
//TODO: should be in database //TODO: should be in database
@ -38,13 +40,16 @@ namespace osu.Game.Beatmaps
set { onlineBeatmapSetID = value > 0 ? value : null; } set { onlineBeatmapSetID = value > 0 ? value : null; }
} }
[JsonIgnore]
public int BeatmapSetInfoID { get; set; } public int BeatmapSetInfoID { get; set; }
[Required] [Required]
[JsonIgnore]
public BeatmapSetInfo BeatmapSet { get; set; } public BeatmapSetInfo BeatmapSet { get; set; }
public BeatmapMetadata Metadata { get; set; } public BeatmapMetadata Metadata { get; set; }
[JsonIgnore]
public int BaseDifficultyID { get; set; } public int BaseDifficultyID { get; set; }
public BeatmapDifficulty BaseDifficulty { get; set; } public BeatmapDifficulty BaseDifficulty { get; set; }
@ -60,6 +65,7 @@ namespace osu.Game.Beatmaps
[JsonProperty("file_sha2")] [JsonProperty("file_sha2")]
public string Hash { get; set; } public string Hash { get; set; }
[JsonIgnore]
public bool Hidden { get; set; } public bool Hidden { get; set; }
/// <summary> /// <summary>

View File

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

View File

@ -10,9 +10,11 @@ using osu.Game.Users;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
[Serializable]
public class BeatmapMetadata : IEquatable<BeatmapMetadata> public class BeatmapMetadata : IEquatable<BeatmapMetadata>
{ {
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[JsonIgnore]
public int ID { get; set; } public int ID { get; set; }
private int? onlineBeatmapSetID; private int? onlineBeatmapSetID;
@ -30,7 +32,10 @@ namespace osu.Game.Beatmaps
public string Artist { get; set; } public string Artist { get; set; }
public string ArtistUnicode { get; set; } public string ArtistUnicode { get; set; }
[JsonIgnore]
public List<BeatmapInfo> Beatmaps { get; set; } public List<BeatmapInfo> Beatmaps { get; set; }
[JsonIgnore]
public List<BeatmapSetInfo> BeatmapSets { get; set; } public List<BeatmapSetInfo> BeatmapSets { get; set; }
/// <summary> /// <summary>
@ -47,6 +52,7 @@ namespace osu.Game.Beatmaps
/// <summary> /// <summary>
/// The author of the beatmaps in this set. /// The author of the beatmaps in this set.
/// </summary> /// </summary>
[JsonIgnore]
public User Author; public User Author;
public string Source { get; set; } public string Source { get; set; }
@ -59,6 +65,7 @@ namespace osu.Game.Beatmaps
public override string ToString() => $"{Artist} - {Title} ({Author})"; public override string ToString() => $"{Artist} - {Title} ({Author})";
[JsonIgnore]
public string[] SearchableTerms => new[] public string[] SearchableTerms => new[]
{ {
Author?.Username, Author?.Username,

View File

@ -4,31 +4,37 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json;
using osu.Framework.Lists; using osu.Framework.Lists;
namespace osu.Game.Beatmaps.ControlPoints namespace osu.Game.Beatmaps.ControlPoints
{ {
[Serializable]
public class ControlPointInfo public class ControlPointInfo
{ {
/// <summary> /// <summary>
/// All timing points. /// All timing points.
/// </summary> /// </summary>
public readonly SortedList<TimingControlPoint> TimingPoints = new SortedList<TimingControlPoint>(Comparer<TimingControlPoint>.Default); [JsonProperty]
public SortedList<TimingControlPoint> TimingPoints { get; private set; } = new SortedList<TimingControlPoint>(Comparer<TimingControlPoint>.Default);
/// <summary> /// <summary>
/// All difficulty points. /// All difficulty points.
/// </summary> /// </summary>
public readonly SortedList<DifficultyControlPoint> DifficultyPoints = new SortedList<DifficultyControlPoint>(Comparer<DifficultyControlPoint>.Default); [JsonProperty]
public SortedList<DifficultyControlPoint> DifficultyPoints { get; private set; } = new SortedList<DifficultyControlPoint>(Comparer<DifficultyControlPoint>.Default);
/// <summary> /// <summary>
/// All sound points. /// All sound points.
/// </summary> /// </summary>
public readonly SortedList<SoundControlPoint> SoundPoints = new SortedList<SoundControlPoint>(Comparer<SoundControlPoint>.Default); [JsonProperty]
public SortedList<SampleControlPoint> SamplePoints { get; private set; } = new SortedList<SampleControlPoint>(Comparer<SampleControlPoint>.Default);
/// <summary> /// <summary>
/// All effect points. /// All effect points.
/// </summary> /// </summary>
public readonly SortedList<EffectControlPoint> EffectPoints = new SortedList<EffectControlPoint>(Comparer<EffectControlPoint>.Default); [JsonProperty]
public SortedList<EffectControlPoint> EffectPoints { get; private set; } = new SortedList<EffectControlPoint>(Comparer<EffectControlPoint>.Default);
/// <summary> /// <summary>
/// Finds the difficulty control point that is active at <paramref name="time"/>. /// Finds the difficulty control point that is active at <paramref name="time"/>.
@ -49,7 +55,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// </summary> /// </summary>
/// <param name="time">The time to find the sound control point at.</param> /// <param name="time">The time to find the sound control point at.</param>
/// <returns>The sound control point.</returns> /// <returns>The sound control point.</returns>
public SoundControlPoint SoundPointAt(double time) => binarySearch(SoundPoints, time); public SampleControlPoint SamplePointAt(double time) => binarySearch(SamplePoints, time, SamplePoints.FirstOrDefault());
/// <summary> /// <summary>
/// Finds the timing control point that is active at <paramref name="time"/>. /// Finds the timing control point that is active at <paramref name="time"/>.
@ -58,18 +64,21 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <returns>The timing control point.</returns> /// <returns>The timing control point.</returns>
public TimingControlPoint TimingPointAt(double time) => binarySearch(TimingPoints, time, TimingPoints.FirstOrDefault()); public TimingControlPoint TimingPointAt(double time) => binarySearch(TimingPoints, time, TimingPoints.FirstOrDefault());
[JsonIgnore]
/// <summary> /// <summary>
/// Finds the maximum BPM represented by any timing control point. /// Finds the maximum BPM represented by any timing control point.
/// </summary> /// </summary>
public double BPMMaximum => public double BPMMaximum =>
60000 / (TimingPoints.OrderBy(c => c.BeatLength).FirstOrDefault() ?? new TimingControlPoint()).BeatLength; 60000 / (TimingPoints.OrderBy(c => c.BeatLength).FirstOrDefault() ?? new TimingControlPoint()).BeatLength;
[JsonIgnore]
/// <summary> /// <summary>
/// Finds the minimum BPM represented by any timing control point. /// Finds the minimum BPM represented by any timing control point.
/// </summary> /// </summary>
public double BPMMinimum => public double BPMMinimum =>
60000 / (TimingPoints.OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? new TimingControlPoint()).BeatLength; 60000 / (TimingPoints.OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? new TimingControlPoint()).BeatLength;
[JsonIgnore]
/// <summary> /// <summary>
/// Finds the mode BPM (most common BPM) represented by the control points. /// Finds the mode BPM (most common BPM) represented by the control points.
/// </summary> /// </summary>

View File

@ -0,0 +1,34 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Audio;
namespace osu.Game.Beatmaps.ControlPoints
{
public class SampleControlPoint : ControlPoint
{
public const string DEFAULT_BANK = "normal";
/// <summary>
/// The default sample bank at this control point.
/// </summary>
public string SampleBank = DEFAULT_BANK;
/// <summary>
/// The default sample volume at this control point.
/// </summary>
public int SampleVolume;
/// <summary>
/// Create a SampleInfo based on the sample settings in this control point.
/// </summary>
/// <param name="sampleName">The name of the same.</param>
/// <returns>A populated <see cref="SampleInfo"/>.</returns>
public SampleInfo GetSampleInfo(string sampleName = SampleInfo.HIT_NORMAL) => new SampleInfo
{
Bank = SampleBank,
Name = sampleName,
Volume = SampleVolume,
};
}
}

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
namespace osu.Game.Beatmaps.ControlPoints
{
public class SoundControlPoint : ControlPoint
{
/// <summary>
/// The default sample bank at this control point.
/// </summary>
public string SampleBank;
/// <summary>
/// The default sample volume at this control point.
/// </summary>
public int SampleVolume;
}
}

View File

@ -10,11 +10,12 @@ namespace osu.Game.Beatmaps.Formats
{ {
public abstract class Decoder public abstract class Decoder
{ {
private static readonly Dictionary<string, Type> decoders = new Dictionary<string, Type>(); private static readonly Dictionary<string, Func<string, Decoder>> decoders = new Dictionary<string, Func<string, Decoder>>();
static Decoder() static Decoder()
{ {
LegacyDecoder.Register(); LegacyDecoder.Register();
JsonBeatmapDecoder.Register();
} }
/// <summary> /// <summary>
@ -33,17 +34,18 @@ namespace osu.Game.Beatmaps.Formats
if (line == null || !decoders.ContainsKey(line)) if (line == null || !decoders.ContainsKey(line))
throw new IOException(@"Unknown file format"); throw new IOException(@"Unknown file format");
return (Decoder)Activator.CreateInstance(decoders[line], line);
return decoders[line](line);
} }
/// <summary> /// <summary>
/// Adds the <see cref="Decoder"/> to the list of <see cref="Beatmap"/> and <see cref="Storyboard"/> decoder. /// Registers an instantiation function for a <see cref="Decoder"/>.
/// </summary> /// </summary>
/// <typeparam name="T">Type to decode a <see cref="Beatmap"/> with.</typeparam> /// <param name="magic">A string in the file which triggers this decoder to be used.</param>
/// <param name="version">A string representation of the version.</param> /// <param name="constructor">A function which constructs the <see cref="Decoder"/> given <paramref name="magic"/>.</param>
protected static void AddDecoder<T>(string version) where T : Decoder protected static void AddDecoder(string magic, Func<string, Decoder> constructor)
{ {
decoders[version] = typeof(T); decoders[magic] = constructor;
} }
/// <summary> /// <summary>

View File

@ -0,0 +1,35 @@
// 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.IO;
using osu.Game.IO.Serialization;
using osu.Game.Storyboards;
namespace osu.Game.Beatmaps.Formats
{
public class JsonBeatmapDecoder : Decoder
{
public static void Register()
{
AddDecoder("{", m => new JsonBeatmapDecoder());
}
public override Decoder GetStoryboardDecoder() => this;
protected override void ParseBeatmap(StreamReader stream, Beatmap beatmap)
{
stream.BaseStream.Position = 0;
stream.DiscardBufferedData();
stream.ReadToEnd().DeserializeInto(beatmap);
foreach (var hitObject in beatmap.HitObjects)
hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
}
protected override void ParseStoryboard(StreamReader stream, Storyboard storyboard)
{
// throw new System.NotImplementedException();
}
}
}

View File

@ -313,7 +313,7 @@ namespace osu.Game.Beatmaps.Formats
stringSampleSet = @"normal"; stringSampleSet = @"normal";
DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(time); DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(time);
SoundControlPoint soundPoint = beatmap.ControlPointInfo.SoundPointAt(time); SampleControlPoint samplePoint = beatmap.ControlPointInfo.SamplePointAt(time);
EffectControlPoint effectPoint = beatmap.ControlPointInfo.EffectPointAt(time); EffectControlPoint effectPoint = beatmap.ControlPointInfo.EffectPointAt(time);
if (timingChange) if (timingChange)
@ -336,9 +336,9 @@ namespace osu.Game.Beatmaps.Formats
}); });
} }
if (stringSampleSet != soundPoint.SampleBank || sampleVolume != soundPoint.SampleVolume) if (stringSampleSet != samplePoint.SampleBank || sampleVolume != samplePoint.SampleVolume)
{ {
beatmap.ControlPointInfo.SoundPoints.Add(new SoundControlPoint beatmap.ControlPointInfo.SamplePoints.Add(new SampleControlPoint
{ {
Time = time, Time = time,
SampleBank = stringSampleSet, SampleBank = stringSampleSet,

View File

@ -13,18 +13,18 @@ namespace osu.Game.Beatmaps.Formats
{ {
public static void Register() public static void Register()
{ {
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v14"); AddDecoder(@"osu file format v14", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v13"); AddDecoder(@"osu file format v13", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v12"); AddDecoder(@"osu file format v12", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v11"); AddDecoder(@"osu file format v11", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v10"); AddDecoder(@"osu file format v10", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v9"); AddDecoder(@"osu file format v9", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v8"); AddDecoder(@"osu file format v8", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v7"); AddDecoder(@"osu file format v7", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v6"); AddDecoder(@"osu file format v6", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v5"); AddDecoder(@"osu file format v5", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v4"); AddDecoder(@"osu file format v4", m => new LegacyBeatmapDecoder(m));
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v3"); AddDecoder(@"osu file format v3", m => new LegacyBeatmapDecoder(m));
// TODO: differences between versions // TODO: differences between versions
} }

View File

@ -10,6 +10,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Game.Storyboards; using osu.Game.Storyboards;
using osu.Framework.IO.File;
using System.IO;
using osu.Game.IO.Serialization;
using System.Diagnostics;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
@ -38,6 +42,17 @@ namespace osu.Game.Beatmaps
storyboard = new AsyncLazy<Storyboard>(populateStoryboard); storyboard = new AsyncLazy<Storyboard>(populateStoryboard);
} }
/// <summary>
/// Saves the <see cref="Beatmap"/>.
/// </summary>
public void Save()
{
var path = FileSafety.GetTempPath(Guid.NewGuid().ToString().Replace("-", string.Empty) + ".json");
using (var sw = new StreamWriter(path))
sw.WriteLine(Beatmap.Serialize());
Process.Start(path);
}
protected abstract Beatmap GetBeatmap(); protected abstract Beatmap GetBeatmap();
protected abstract Texture GetBackground(); protected abstract Texture GetBackground();
protected abstract Track GetTrack(); protected abstract Track GetTrack();

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Caching;
using OpenTK; using OpenTK;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -47,7 +48,16 @@ namespace osu.Game.Graphics.UserInterface
set set
{ {
values = value.ToArray(); values = value.ToArray();
applyPath();
float max = values.Max(), min = values.Min();
if (MaxValue > max) max = MaxValue.Value;
if (MinValue < min) min = MinValue.Value;
ActualMaxValue = max;
ActualMinValue = min;
pathCached.Invalidate();
maskingContainer.Width = 0; maskingContainer.Width = 0;
maskingContainer.ResizeWidthTo(1, transform_duration, Easing.OutQuint); maskingContainer.ResizeWidthTo(1, transform_duration, Easing.OutQuint);
} }
@ -63,13 +73,28 @@ namespace osu.Game.Graphics.UserInterface
}); });
} }
private bool pending;
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
{ {
if ((invalidation & Invalidation.DrawSize) != 0) if ((invalidation & Invalidation.DrawSize) > 0)
applyPath(); pathCached.Invalidate();
return base.Invalidate(invalidation, source, shallPropagate); return base.Invalidate(invalidation, source, shallPropagate);
} }
private Cached pathCached = new Cached();
protected override void Update()
{
base.Update();
if (!pathCached.IsValid)
{
applyPath();
pathCached.Validate();
}
}
private void applyPath() private void applyPath()
{ {
path.ClearVertices(); path.ClearVertices();
@ -77,13 +102,6 @@ namespace osu.Game.Graphics.UserInterface
int count = Math.Max(values.Length, DefaultValueCount); int count = Math.Max(values.Length, DefaultValueCount);
float max = values.Max(), min = values.Min();
if (MaxValue > max) max = MaxValue.Value;
if (MinValue < min) min = MinValue.Value;
ActualMaxValue = max;
ActualMinValue = min;
for (int i = 0; i < values.Length; i++) for (int i = 0; i < values.Length; i++)
{ {
float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1; float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1;

View File

@ -0,0 +1,100 @@
// 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 Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace osu.Game.IO.Serialization.Converters
{
/// <summary>
/// A type of <see cref="JsonConverter"/> that serializes a <see cref="List<T>"/> alongside
/// a lookup table for the types contained. The lookup table is used in deserialization to
/// reconstruct the objects with their original types.
/// </summary>
/// <typeparam name="T">The type of objects contained in the <see cref="List<T>"/> this attribute is attached to.</typeparam>
public class TypedListConverter<T> : JsonConverter
{
private readonly bool requiresTypeVersion;
/// <summary>
/// Constructs a new <see cref="TypedListConverter{T}"/>.
/// </summary>
// ReSharper disable once UnusedMember.Global
public TypedListConverter()
{
}
/// <summary>
/// Constructs a new <see cref="TypedListConverter{T}"/>.
/// </summary>
/// <param name="requiresTypeVersion">Whether the version of the type should be serialized.</param>
// ReSharper disable once UnusedMember.Global (Used in Beatmap)
public TypedListConverter(bool requiresTypeVersion)
{
this.requiresTypeVersion = requiresTypeVersion;
}
public override bool CanConvert(Type objectType) => objectType == typeof(List<T>);
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var list = new List<T>();
var obj = JObject.Load(reader);
var lookupTable = serializer.Deserialize<List<string>>(obj["lookup_table"].CreateReader());
foreach (var tok in obj["items"])
{
var itemReader = tok.CreateReader();
var typeName = lookupTable[(int)tok["type"]];
var instance = (T)Activator.CreateInstance(Type.GetType(typeName));
serializer.Populate(itemReader, instance);
list.Add(instance);
}
return list;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var list = (List<T>)value;
var lookupTable = new List<string>();
var objects = new List<JObject>();
foreach (var item in list)
{
var type = item.GetType();
var assemblyName = type.Assembly.GetName();
var typeString = $"{type.FullName}, {assemblyName.Name}";
if (requiresTypeVersion)
typeString += $", {assemblyName.Version}";
int typeId = lookupTable.IndexOf(typeString);
if (typeId == -1)
{
lookupTable.Add(typeString);
typeId = lookupTable.Count - 1;
}
var itemObject = JObject.FromObject(item, serializer);
itemObject.AddFirst(new JProperty("type", typeId));
objects.Add(itemObject);
}
writer.WriteStartObject();
writer.WritePropertyName("lookup_table");
serializer.Serialize(writer, lookupTable);
writer.WritePropertyName("items");
serializer.Serialize(writer, objects);
writer.WriteEndObject();
}
}
}

View File

@ -0,0 +1,38 @@
// 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 Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OpenTK;
namespace osu.Game.IO.Serialization.Converters
{
/// <summary>
/// A type of <see cref="JsonConverter"/> that serializes only the X and Y coordinates of a <see cref="Vector2"/>.
/// </summary>
public class Vector2Converter : JsonConverter
{
public override bool CanConvert(Type objectType) => objectType == typeof(Vector2);
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var obj = JObject.Load(reader);
return new Vector2((float)obj["x"], (float)obj["y"]);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var vector = (Vector2)value;
writer.WriteStartObject();
writer.WritePropertyName("x");
writer.WriteValue(vector.X);
writer.WritePropertyName("y");
writer.WriteValue(vector.Y);
writer.WriteEndObject();
}
}
}

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 Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.IO.Serialization.Converters;
namespace osu.Game.IO.Serialization namespace osu.Game.IO.Serialization
{ {
@ -11,20 +12,26 @@ namespace osu.Game.IO.Serialization
public static class JsonSerializableExtensions public static class JsonSerializableExtensions
{ {
public static string Serialize(this IJsonSerializable obj) public static string Serialize(this IJsonSerializable obj) => JsonConvert.SerializeObject(obj, CreateGlobalSettings());
{
return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
}
public static T Deserialize<T>(this string objString) public static T Deserialize<T>(this string objString) => JsonConvert.DeserializeObject<T>(objString, CreateGlobalSettings());
{
return JsonConvert.DeserializeObject<T>(objString);
}
public static T DeepClone<T>(this T obj) public static void DeserializeInto<T>(this string objString, T target) => JsonConvert.PopulateObject(objString, target, CreateGlobalSettings());
where T : IJsonSerializable
public static T DeepClone<T>(this T obj) where T : IJsonSerializable => Deserialize<T>(Serialize(obj));
/// <summary>
/// Creates the default <see cref="JsonSerializerSettings"/> that should be used for all <see cref="IJsonSerializable"/>s.
/// </summary>
/// <returns></returns>
public static JsonSerializerSettings CreateGlobalSettings() => new JsonSerializerSettings
{ {
return Deserialize<T>(Serialize(obj)); ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
} Formatting = Formatting.Indented,
ObjectCreationHandling = ObjectCreationHandling.Replace,
DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate,
Converters = new JsonConverter[] { new Vector2Converter() },
ContractResolver = new KeyContractResolver()
};
} }
} }

View File

@ -0,0 +1,16 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using Humanizer;
using Newtonsoft.Json.Serialization;
namespace osu.Game.IO.Serialization
{
public class KeyContractResolver : DefaultContractResolver
{
protected override string ResolvePropertyName(string propertyName)
{
return propertyName.Underscore();
}
}
}

View File

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

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -176,7 +177,7 @@ namespace osu.Game.Overlays.BeatmapSet
Shadow = false, Shadow = false,
Margin = new MarginPadding { Top = 20 }, Margin = new MarginPadding { Top = 20 },
}, },
textFlow = new TextFlowContainer textFlow = new OsuTextFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,

View File

@ -32,7 +32,7 @@ namespace osu.Game.Overlays.Dialog
private readonly FillFlowContainer<PopupDialogButton> buttonsContainer; private readonly FillFlowContainer<PopupDialogButton> buttonsContainer;
private readonly SpriteIcon icon; private readonly SpriteIcon icon;
private readonly SpriteText header; private readonly SpriteText header;
private readonly SpriteText body; private readonly TextFlowContainer body;
public FontAwesome Icon public FontAwesome Icon
{ {
@ -48,7 +48,6 @@ namespace osu.Game.Overlays.Dialog
public string BodyText public string BodyText
{ {
get { return body.Text; }
set { body.Text = value; } set { body.Text = value; }
} }
@ -220,17 +219,15 @@ namespace osu.Game.Overlays.Dialog
{ {
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Text = @"Header",
TextSize = 25, TextSize = 25,
Shadow = true, Shadow = true,
}, },
body = new OsuSpriteText body = new OsuTextFlowContainer(t => t.TextSize = 18)
{ {
Origin = Anchor.TopCentre, Padding = new MarginPadding(15),
Anchor = Anchor.TopCentre, RelativeSizeAxes = Axes.X,
Text = @"Body", AutoSizeAxes = Axes.Y,
TextSize = 18, TextAnchor = Anchor.TopCentre,
Shadow = true,
}, },
}, },
}, },

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Users; using osu.Game.Users;
@ -88,7 +89,7 @@ namespace osu.Game.Overlays.MedalSplash
Alpha = 0f, Alpha = 0f,
Scale = new Vector2(1f / scale_when_full), Scale = new Vector2(1f / scale_when_full),
}, },
description = new TextFlowContainer description = new OsuTextFlowContainer
{ {
TextAnchor = Anchor.TopCentre, TextAnchor = Anchor.TopCentre,
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,

View File

@ -10,6 +10,8 @@ using osu.Game.Overlays.Notifications;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using System;
using osu.Framework.Configuration;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
@ -19,9 +21,13 @@ namespace osu.Game.Overlays
public const float TRANSITION_LENGTH = 600; public const float TRANSITION_LENGTH = 600;
private ScrollContainer scrollContainer;
private FlowContainer<NotificationSection> sections; private FlowContainer<NotificationSection> sections;
/// <summary>
/// Provide a source for the toolbar height.
/// </summary>
public Func<float> GetToolbarHeight;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
@ -36,12 +42,12 @@ namespace osu.Game.Overlays
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.Black, Colour = Color4.Black,
Alpha = 0.6f, Alpha = 0.6f
}, },
scrollContainer = new OsuScrollContainer new OsuScrollContainer
{ {
Masking = true,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = Toolbar.Toolbar.HEIGHT },
Children = new[] Children = new[]
{ {
sections = new FillFlowContainer<NotificationSection> sections = new FillFlowContainer<NotificationSection>
@ -55,14 +61,14 @@ namespace osu.Game.Overlays
{ {
Title = @"Notifications", Title = @"Notifications",
ClearText = @"Clear All", ClearText = @"Clear All",
AcceptTypes = new[] { typeof(SimpleNotification) }, AcceptTypes = new[] { typeof(SimpleNotification) }
}, },
new NotificationSection new NotificationSection
{ {
Title = @"Running Tasks", Title = @"Running Tasks",
ClearText = @"Cancel All", ClearText = @"Cancel All",
AcceptTypes = new[] { typeof(ProgressNotification) }, AcceptTypes = new[] { typeof(ProgressNotification) }
}, }
} }
} }
} }
@ -70,21 +76,24 @@ namespace osu.Game.Overlays
}; };
} }
private int totalCount => sections.Select(c => c.DisplayedCount).Sum();
private int unreadCount => sections.Select(c => c.UnreadCount).Sum();
public readonly BindableInt UnreadCount = new BindableInt();
private int runningDepth; private int runningDepth;
private void notificationClosed() private void notificationClosed()
{ {
// hide ourselves if all notifications have been dismissed. // hide ourselves if all notifications have been dismissed.
if (sections.Select(c => c.DisplayedCount).Sum() == 0) if (totalCount == 0)
State = Visibility.Hidden; State = Visibility.Hidden;
updateCounts();
} }
public void Post(Notification notification) public void Post(Notification notification) => Schedule(() =>
{ {
Schedule(() =>
{
State = Visibility.Visible;
++runningDepth; ++runningDepth;
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth; notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
@ -96,21 +105,16 @@ namespace osu.Game.Overlays
var ourType = notification.GetType(); var ourType = notification.GetType();
sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification); sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification);
updateCounts();
}); });
}
protected override void PopIn() protected override void PopIn()
{ {
base.PopIn(); base.PopIn();
scrollContainer.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
this.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint); this.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(1, TRANSITION_LENGTH / 2); this.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint);
}
private void markAllRead()
{
sections.Children.ForEach(s => s.MarkAllRead());
} }
protected override void PopOut() protected override void PopOut()
@ -120,7 +124,26 @@ namespace osu.Game.Overlays
markAllRead(); markAllRead();
this.MoveToX(width, TRANSITION_LENGTH, Easing.OutQuint); this.MoveToX(width, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(0, TRANSITION_LENGTH / 2); this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
}
private void updateCounts()
{
UnreadCount.Value = unreadCount;
}
private void markAllRead()
{
sections.Children.ForEach(s => s.MarkAllRead());
updateCounts();
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
} }
} }
} }

View File

@ -26,6 +26,8 @@ namespace osu.Game.Overlays.Notifications
public int DisplayedCount => notifications.Count(n => !n.WasClosed); public int DisplayedCount => notifications.Count(n => !n.WasClosed);
public int UnreadCount => notifications.Count(n => !n.WasClosed && !n.Read);
public void Add(Notification notification) => notifications.Add(notification); public void Add(Notification notification) => notifications.Add(notification);
public IEnumerable<Type> AcceptTypes; public IEnumerable<Type> AcceptTypes;

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
@ -94,7 +95,7 @@ namespace osu.Game.Overlays.Notifications
protected virtual void Completed() protected virtual void Completed()
{ {
Expire(); base.Close();
CompletionTarget?.Invoke(CreateCompletionNotification()); CompletionTarget?.Invoke(CreateCompletionNotification());
} }
@ -114,7 +115,7 @@ namespace osu.Game.Overlays.Notifications
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}); });
Content.Add(textDrawable = new TextFlowContainer(t => Content.Add(textDrawable = new OsuTextFlowContainer(t =>
{ {
t.TextSize = 16; t.TextSize = 16;
}) })

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using OpenTK; using OpenTK;
namespace osu.Game.Overlays.Notifications namespace osu.Game.Overlays.Notifications
@ -58,7 +59,7 @@ namespace osu.Game.Overlays.Notifications
} }
}); });
Content.Add(textDrawable = new TextFlowContainer(t => t.TextSize = 16) Content.Add(textDrawable = new OsuTextFlowContainer(t => t.TextSize = 16)
{ {
Colour = OsuColour.Gray(128), Colour = OsuColour.Gray(128),
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
@ -82,8 +83,10 @@ namespace osu.Game.Overlays.Notifications
set set
{ {
if (value == base.Read) return;
base.Read = value; base.Read = value;
Light.FadeTo(value ? 1 : 0, 100); Light.FadeTo(value ? 0 : 1, 100);
} }
} }
} }

View File

@ -14,6 +14,7 @@ using osu.Game.Graphics;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
@ -63,7 +64,7 @@ namespace osu.Game.Overlays
Width = 240, Width = 240,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
}, },
textLine1 = new SpriteText textLine1 = new OsuSpriteText
{ {
Padding = new MarginPadding(10), Padding = new MarginPadding(10),
Font = @"Exo2.0-Black", Font = @"Exo2.0-Black",
@ -72,7 +73,7 @@ namespace osu.Game.Overlays
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
}, },
textLine2 = new SpriteText textLine2 = new OsuSpriteText
{ {
TextSize = 24, TextSize = 24,
Font = @"Exo2.0-Light", Font = @"Exo2.0-Light",
@ -97,7 +98,7 @@ namespace osu.Game.Overlays
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both AutoSizeAxes = Axes.Both
}, },
textLine3 = new SpriteText textLine3 = new OsuSpriteText
{ {
Padding = new MarginPadding { Bottom = 15 }, Padding = new MarginPadding { Bottom = 15 },
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",

View File

@ -27,8 +27,10 @@ namespace osu.Game.Overlays.Profile
private readonly OsuTextFlowContainer infoTextLeft; private readonly OsuTextFlowContainer infoTextLeft;
private readonly LinkFlowContainer infoTextRight; private readonly LinkFlowContainer infoTextRight;
private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText; private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText;
private readonly RankGraph rankGraph;
private readonly Container coverContainer, chartContainer, supporterTag; public readonly SupporterIcon SupporterTag;
private readonly Container coverContainer;
private readonly Sprite levelBadge; private readonly Sprite levelBadge;
private readonly SpriteText levelText; private readonly SpriteText levelText;
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
@ -93,32 +95,13 @@ namespace osu.Game.Overlays.Profile
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
supporterTag = new CircularContainer SupporterTag = new SupporterIcon
{ {
Alpha = 0,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Y = -75, Y = -75,
Size = new Vector2(25, 25), Size = new Vector2(25, 25)
Masking = true,
BorderThickness = 3,
BorderColour = Color4.White,
Alpha = 0,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
},
new SpriteIcon
{
Icon = FontAwesome.fa_heart,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(12),
}
}
}, },
new LinkFlowContainer.ProfileLink(user) new LinkFlowContainer.ProfileLink(user)
{ {
@ -273,7 +256,7 @@ namespace osu.Game.Overlays.Profile
} }
} }
}, },
chartContainer = new Container new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
@ -285,6 +268,10 @@ namespace osu.Game.Overlays.Profile
{ {
Colour = Color4.Black.Opacity(0.25f), Colour = Color4.Black.Opacity(0.25f),
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
},
rankGraph = new RankGraph
{
RelativeSizeAxes = Axes.Both
} }
} }
} }
@ -303,11 +290,7 @@ namespace osu.Game.Overlays.Profile
public User User public User User
{ {
get get { return user; }
{
return user;
}
set set
{ {
user = value; user = value;
@ -327,7 +310,8 @@ namespace osu.Game.Overlays.Profile
Depth = float.MaxValue, Depth = float.MaxValue,
}, coverContainer.Add); }, coverContainer.Add);
if (user.IsSupporter) supporterTag.Show(); if (user.IsSupporter)
SupporterTag.Show();
if (!string.IsNullOrEmpty(user.Colour)) if (!string.IsNullOrEmpty(user.Colour))
{ {
@ -420,7 +404,7 @@ namespace osu.Game.Overlays.Profile
gradeSPlus.DisplayCount = 0; gradeSPlus.DisplayCount = 0;
gradeSSPlus.DisplayCount = 0; gradeSSPlus.DisplayCount = 0;
chartContainer.Add(new RankChart(user) { RelativeSizeAxes = Axes.Both }); rankGraph.User.Value = user;
} }
} }
@ -472,7 +456,7 @@ namespace osu.Game.Overlays.Profile
Width = width, Width = width,
Height = 26 Height = 26
}); });
Add(numberText = new SpriteText Add(numberText = new OsuSpriteText
{ {
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,

View File

@ -14,30 +14,39 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Users; using osu.Game.Users;
using System.Collections.Generic;
using osu.Framework.Configuration;
namespace osu.Game.Overlays.Profile namespace osu.Game.Overlays.Profile
{ {
public class RankChart : Container public class RankGraph : Container
{ {
private const float primary_textsize = 25;
private const float secondary_textsize = 13;
private const float padding = 10;
private const float fade_duration = 150;
private const int ranked_days = 88;
private readonly SpriteText rankText, performanceText, relativeText; private readonly SpriteText rankText, performanceText, relativeText;
private readonly RankChartLineGraph graph; private readonly RankChartLineGraph graph;
private readonly OsuSpriteText placeholder;
private readonly int[] ranks; private KeyValuePair<int, int>[] ranks;
public Bindable<User> User = new Bindable<User>();
private const float primary_textsize = 25, secondary_textsize = 13, padding = 10; public RankGraph()
private readonly User user;
public RankChart(User user)
{ {
this.user = user;
int[] userRanks = user.RankHistory?.Data ?? new[] { user.Statistics.Rank };
ranks = userRanks.SkipWhile(x => x == 0).ToArray();
Padding = new MarginPadding { Vertical = padding }; Padding = new MarginPadding { Vertical = padding };
Children = new Drawable[] Children = new Drawable[]
{ {
placeholder = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = "No recent plays",
TextSize = 14,
Font = @"Exo2.0-RegularItalic",
},
rankText = new OsuSpriteText rankText = new OsuSpriteText
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
@ -60,89 +69,103 @@ namespace osu.Game.Overlays.Profile
Font = @"Exo2.0-RegularItalic", Font = @"Exo2.0-RegularItalic",
TextSize = secondary_textsize TextSize = secondary_textsize
}, },
}; graph = new RankChartLineGraph
if (ranks.Length > 0)
{
Add(graph = new RankChartLineGraph
{ {
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = 75,
Y = -secondary_textsize, Y = -secondary_textsize,
DefaultValueCount = ranks.Length, Alpha = 0,
}); }
};
graph.OnBallMove += showHistoryRankTexts; graph.OnBallMove += showHistoryRankTexts;
}
}
private void updateRankTexts() User.ValueChanged += userChanged;
{
rankText.Text = user.Statistics.Rank > 0 ? $"#{user.Statistics.Rank:#,0}" : "no rank";
performanceText.Text = user.Statistics.PP != null ? $"{user.Statistics.PP:#,0}pp" : string.Empty;
relativeText.Text = user.CountryRank > 0 ? $"{user.Country?.FullName} #{user.CountryRank:#,0}" : $"{user.Country?.FullName}";
}
private void showHistoryRankTexts(int dayIndex)
{
rankText.Text = ranks[dayIndex] > 0 ? $"#{ranks[dayIndex]:#,0}" : "no rank";
dayIndex++;
relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago";
//plural should be handled in a general way
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{
if (graph != null)
{ {
graph.Colour = colours.Yellow; graph.Colour = colours.Yellow;
// use logarithmic coordinates }
graph.Values = ranks.Select(x => x == 0 ? float.MinValue : -(float)Math.Log(x));
private void userChanged(User user)
{
placeholder.FadeIn(fade_duration, Easing.Out);
if (user == null)
{
rankText.Text = string.Empty;
performanceText.Text = string.Empty;
relativeText.Text = string.Empty;
graph.FadeOut(fade_duration, Easing.Out);
ranks = null;
return;
}
int[] userRanks = user.RankHistory?.Data ?? new[] { user.Statistics.Rank };
ranks = userRanks.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray();
if (ranks.Length > 1)
{
placeholder.FadeOut(fade_duration, Easing.Out);
graph.DefaultValueCount = ranks.Length;
graph.Values = ranks.Select(x => -(float)Math.Log(x.Value));
graph.SetStaticBallPosition(); graph.SetStaticBallPosition();
} }
graph.FadeTo(ranks.Length > 1 ? 1 : 0, fade_duration, Easing.Out);
updateRankTexts(); updateRankTexts();
} }
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) private void updateRankTexts()
{ {
if ((invalidation & Invalidation.DrawSize) != 0) rankText.Text = User.Value.Statistics.Rank > 0 ? $"#{User.Value.Statistics.Rank:#,0}" : "no rank";
{ performanceText.Text = User.Value.Statistics.PP != null ? $"{User.Value.Statistics.PP:#,0}pp" : string.Empty;
graph.Height = DrawHeight - padding * 2 - primary_textsize - secondary_textsize * 2; relativeText.Text = $"{User.Value.Country?.FullName} #{User.Value.CountryRank:#,0}";
} }
return base.Invalidate(invalidation, source, shallPropagate); private void showHistoryRankTexts(int dayIndex)
{
rankText.Text = $"#{ranks[dayIndex].Value:#,0}";
relativeText.Text = dayIndex + 1 == ranks.Length ? "Now" : $"{ranked_days - ranks[dayIndex].Key} days ago";
} }
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
graph?.UpdateBallPosition(state.Mouse.Position.X); if (ranks?.Length > 1)
graph?.ShowBall(); {
graph.UpdateBallPosition(state.Mouse.Position.X);
graph.ShowBall();
}
return base.OnHover(state); return base.OnHover(state);
} }
protected override bool OnMouseMove(InputState state) protected override bool OnMouseMove(InputState state)
{ {
graph?.UpdateBallPosition(state.Mouse.Position.X); if (ranks?.Length > 1)
graph.UpdateBallPosition(state.Mouse.Position.X);
return base.OnMouseMove(state); return base.OnMouseMove(state);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
if (graph != null) if (ranks?.Length > 1)
{ {
graph.HideBall(); graph.HideBall();
updateRankTexts(); updateRankTexts();
} }
base.OnHoverLost(state); base.OnHoverLost(state);
} }
private class RankChartLineGraph : LineGraph private class RankChartLineGraph : LineGraph
{ {
private const double fade_duration = 200;
private readonly CircularContainer staticBall; private readonly CircularContainer staticBall;
private readonly CircularContainer movingBall; private readonly CircularContainer movingBall;

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Users; using osu.Game.Users;
@ -120,7 +121,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
} }
} }
}, },
new TextFlowContainer(t => { t.TextSize = 19; }) new OsuTextFlowContainer(t => { t.TextSize = 19; })
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,

View File

@ -0,0 +1,61 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Overlays.Profile
{
public class SupporterIcon : CircularContainer
{
private readonly Box background;
public SupporterIcon()
{
Masking = true;
Children = new Drawable[]
{
new Box { RelativeSizeAxes = Axes.Both },
new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.8f),
Masking = true,
Children = new Drawable[]
{
background = new Box { RelativeSizeAxes = Axes.Both },
new Triangles
{
TriangleScale = 0.2f,
ColourLight = OsuColour.FromHex(@"ff7db7"),
ColourDark = OsuColour.FromHex(@"de5b95"),
RelativeSizeAxes = Axes.Both,
Velocity = 0.3f,
},
}
},
new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Icon = FontAwesome.fa_heart,
Scale = new Vector2(0.45f),
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.Pink;
}
}
}

View File

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

View File

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

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
SetIcon(FontAwesome.fa_comments); SetIcon(FontAwesome.fa_comments);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader(true)]
private void load(ChatOverlay chat) private void load(ChatOverlay chat)
{ {
StateContainer = chat; StateContainer = chat;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
SetIcon(FontAwesome.fa_osu_chevron_down_o); SetIcon(FontAwesome.fa_osu_chevron_down_o);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader(true)]
private void load(DirectOverlay direct) private void load(DirectOverlay direct)
{ {
StateContainer = direct; StateContainer = direct;

View File

@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Toolbar
}; };
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader(true)]
private void load(RulesetStore rulesets, OsuGame game) private void load(RulesetStore rulesets, OsuGame game)
{ {
foreach (var r in rulesets.AvailableRulesets) foreach (var r in rulesets.AvailableRulesets)
@ -81,7 +81,10 @@ namespace osu.Game.Overlays.Toolbar
ruleset.ValueChanged += rulesetChanged; ruleset.ValueChanged += rulesetChanged;
ruleset.DisabledChanged += disabledChanged; ruleset.DisabledChanged += disabledChanged;
if (game != null)
ruleset.BindTo(game.Ruleset); ruleset.BindTo(game.Ruleset);
else
ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault();
} }
public override bool HandleInput => !ruleset.Disabled; public override bool HandleInput => !ruleset.Disabled;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
Icon = FontAwesome.fa_music; Icon = FontAwesome.fa_music;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader(true)]
private void load(MusicController music) private void load(MusicController music)
{ {
StateContainer = music; StateContainer = music;

View File

@ -2,8 +2,14 @@
// 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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Overlays.Toolbar namespace osu.Game.Overlays.Toolbar
{ {
@ -11,17 +17,96 @@ namespace osu.Game.Overlays.Toolbar
{ {
protected override Anchor TooltipAnchor => Anchor.TopRight; protected override Anchor TooltipAnchor => Anchor.TopRight;
public BindableInt NotificationCount = new BindableInt();
private readonly CountCircle countDisplay;
public ToolbarNotificationButton() public ToolbarNotificationButton()
{ {
Icon = FontAwesome.fa_bars; Icon = FontAwesome.fa_bars;
TooltipMain = "Notifications"; TooltipMain = "Notifications";
TooltipSub = "Waiting for 'ya"; TooltipSub = "Waiting for 'ya";
Add(countDisplay = new CountCircle
{
Alpha = 0,
Height = 16,
RelativePositionAxes = Axes.Both,
Origin = Anchor.Centre,
Position = new Vector2(0.7f, 0.25f),
});
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader(true)]
private void load(NotificationOverlay notificationOverlay) private void load(NotificationOverlay notificationOverlay)
{ {
StateContainer = notificationOverlay; StateContainer = notificationOverlay;
if (notificationOverlay != null)
NotificationCount.BindTo(notificationOverlay.UnreadCount);
NotificationCount.ValueChanged += count =>
{
if (count == 0)
countDisplay.FadeOut(200, Easing.OutQuint);
else
{
countDisplay.Count = count;
countDisplay.FadeIn(200, Easing.OutQuint);
}
};
}
private class CountCircle : CompositeDrawable
{
private readonly OsuSpriteText countText;
private readonly Circle circle;
private int count;
public int Count
{
get { return count; }
set
{
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");
}
}
public CountCircle()
{
AutoSizeAxes = Axes.X;
InternalChildren = new Drawable[]
{
circle = new Circle
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Red
},
countText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Y = -1,
TextSize = 14,
Padding = new MarginPadding(5),
Colour = Color4.White,
UseFullGlyphHeight = true,
Font = "Exo2.0-Bold",
}
};
}
} }
} }
} }

View File

@ -21,10 +21,13 @@ namespace osu.Game.Overlays.Toolbar
set set
{ {
stateContainer = value; stateContainer = value;
if (stateContainer != null)
{
Action = stateContainer.ToggleVisibility; Action = stateContainer.ToggleVisibility;
stateContainer.StateChanged += stateChanged; stateContainer.StateChanged += stateChanged;
} }
} }
}
public ToolbarOverlayToggleButton() public ToolbarOverlayToggleButton()
{ {

View File

@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Toolbar
TooltipSub = "Change your settings"; TooltipSub = "Change your settings";
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader(true)]
private void load(SettingsOverlay settings) private void load(SettingsOverlay settings)
{ {
StateContainer = settings; StateContainer = settings;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
Icon = FontAwesome.fa_users; Icon = FontAwesome.fa_users;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader(true)]
private void load(SocialOverlay chat) private void load(SocialOverlay chat)
{ {
StateContainer = chat; StateContainer = chat;

View File

@ -28,7 +28,7 @@ namespace osu.Game.Overlays
private ProfileSection[] sections; private ProfileSection[] sections;
private GetUserRequest userReq; private GetUserRequest userReq;
private APIAccess api; private APIAccess api;
private ProfileHeader header; protected ProfileHeader Header;
private SectionsContainer<ProfileSection> sectionsContainer; private SectionsContainer<ProfileSection> sectionsContainer;
private ProfileTabControl tabs; private ProfileTabControl tabs;
@ -113,12 +113,12 @@ namespace osu.Game.Overlays
Colour = OsuColour.Gray(0.2f) Colour = OsuColour.Gray(0.2f)
}); });
header = new ProfileHeader(user); Header = new ProfileHeader(user);
Add(sectionsContainer = new SectionsContainer<ProfileSection> Add(sectionsContainer = new SectionsContainer<ProfileSection>
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ExpandableHeader = header, ExpandableHeader = Header,
FixedHeader = tabs, FixedHeader = tabs,
HeaderBackground = new Box HeaderBackground = new Box
{ {
@ -169,7 +169,7 @@ namespace osu.Game.Overlays
private void userLoadComplete(User user) private void userLoadComplete(User user)
{ {
header.User = user; Header.User = user;
foreach (string id in user.ProfileOrder) foreach (string id in user.ProfileOrder)
{ {

View File

@ -72,6 +72,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
public IReadOnlyList<Judgement> Judgements => judgements; public IReadOnlyList<Judgement> Judgements => judgements;
protected List<SampleChannel> Samples = new List<SampleChannel>(); protected List<SampleChannel> Samples = new List<SampleChannel>();
protected virtual IEnumerable<SampleInfo> GetSamples() => HitObject.Samples;
public readonly Bindable<ArmedState> State = new Bindable<ArmedState>(); public readonly Bindable<ArmedState> State = new Bindable<ArmedState>();
@ -84,17 +85,31 @@ namespace osu.Game.Rulesets.Objects.Drawables
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {
foreach (SampleInfo sample in HitObject.Samples) var samples = GetSamples();
if (samples.Any())
{ {
SampleChannel channel = audio.Sample.Get($@"Gameplay/{sample.Bank}-{sample.Name}"); if (HitObject.SampleControlPoint == null)
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 samples)
{
SampleInfo localSampleInfo = new SampleInfo
{
Bank = s.Bank ?? HitObject.SampleControlPoint.SampleBank,
Name = s.Name,
Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume
};
SampleChannel channel = localSampleInfo.GetChannel(audio.Sample);
if (channel == null) if (channel == null)
continue; continue;
channel.Volume.Value = sample.Volume;
Samples.Add(channel); Samples.Add(channel);
} }
} }
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
@ -162,7 +177,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
{ {
judgementOccurred = false; judgementOccurred = false;
if (AllJudged || State != ArmedState.Idle) if (AllJudged)
return false; return false;
if (NestedHitObjects != null) if (NestedHitObjects != null)

Some files were not shown because too many files have changed in this diff Show More