mirror of
https://github.com/ppy/osu.git
synced 2025-03-21 15:07:23 +08:00
Merge branch 'master' into url-parsing-support
This commit is contained in:
commit
a30448095e
@ -1 +1 @@
|
||||
Subproject commit 5da6990a8e68dea852495950996e1362a293dbd5
|
||||
Subproject commit 08f85f9bf9a7376aec8dfcde8c7c96d267d8c295
|
@ -37,9 +37,9 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
@ -25,7 +26,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
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;
|
||||
if (tiny != null)
|
||||
|
@ -11,7 +11,6 @@ using osu.Game.Rulesets.Catch.UI;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using OpenTK;
|
||||
using osu.Framework.Lists;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
@ -29,9 +28,9 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
public double Velocity;
|
||||
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);
|
||||
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
|
||||
@ -42,92 +41,94 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
TickDistance = scoringDistance / difficulty.SliderTickRate;
|
||||
}
|
||||
|
||||
public IEnumerable<CatchHitObject> Ticks
|
||||
protected override void CreateNestedHitObjects()
|
||||
{
|
||||
get
|
||||
base.CreateNestedHitObjects();
|
||||
|
||||
createTicks();
|
||||
}
|
||||
|
||||
private void createTicks()
|
||||
{
|
||||
if (TickDistance == 0)
|
||||
return;
|
||||
|
||||
var length = Curve.Distance;
|
||||
var tickDistance = Math.Min(TickDistance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
var minDistanceFromEnd = Velocity * 0.01;
|
||||
|
||||
AddNested(new Fruit
|
||||
{
|
||||
SortedList<CatchHitObject> ticks = new SortedList<CatchHitObject>((a, b) => a.StartTime.CompareTo(b.StartTime));
|
||||
Samples = Samples,
|
||||
ComboColour = ComboColour,
|
||||
StartTime = StartTime,
|
||||
X = X
|
||||
});
|
||||
|
||||
if (TickDistance == 0)
|
||||
return ticks;
|
||||
for (var repeat = 0; repeat < RepeatCount; repeat++)
|
||||
{
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var reversed = repeat % 2 == 1;
|
||||
|
||||
var length = Curve.Distance;
|
||||
var tickDistance = Math.Min(TickDistance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
var minDistanceFromEnd = Velocity * 0.01;
|
||||
|
||||
ticks.Add(new Fruit
|
||||
for (var d = tickDistance; d <= length; d += tickDistance)
|
||||
{
|
||||
Samples = Samples,
|
||||
ComboColour = ComboColour,
|
||||
StartTime = StartTime,
|
||||
X = X
|
||||
});
|
||||
if (d > length - minDistanceFromEnd)
|
||||
break;
|
||||
|
||||
for (var repeat = 0; repeat < RepeatCount; repeat++)
|
||||
{
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var reversed = repeat % 2 == 1;
|
||||
var timeProgress = d / length;
|
||||
var distanceProgress = reversed ? 1 - timeProgress : timeProgress;
|
||||
|
||||
for (var d = tickDistance; d <= length; d += tickDistance)
|
||||
var lastTickTime = repeatStartTime + timeProgress * repeatDuration;
|
||||
AddNested(new Droplet
|
||||
{
|
||||
if (d > length - minDistanceFromEnd)
|
||||
break;
|
||||
|
||||
var timeProgress = d / length;
|
||||
var distanceProgress = reversed ? 1 - timeProgress : timeProgress;
|
||||
|
||||
var lastTickTime = repeatStartTime + timeProgress * repeatDuration;
|
||||
ticks.Add(new Droplet
|
||||
{
|
||||
StartTime = lastTickTime,
|
||||
ComboColour = ComboColour,
|
||||
X = Curve.PositionAt(distanceProgress).X / CatchPlayfield.BASE_WIDTH,
|
||||
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
double tinyTickInterval = tickDistance / length * repeatDuration;
|
||||
while (tinyTickInterval > 100)
|
||||
tinyTickInterval /= 2;
|
||||
|
||||
for (double t = 0; t < repeatDuration; t += tinyTickInterval)
|
||||
{
|
||||
double progress = reversed ? 1 - t / repeatDuration : t / repeatDuration;
|
||||
|
||||
ticks.Add(new TinyDroplet
|
||||
{
|
||||
StartTime = repeatStartTime + t,
|
||||
ComboColour = ComboColour,
|
||||
X = Curve.PositionAt(progress).X / CatchPlayfield.BASE_WIDTH,
|
||||
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
ticks.Add(new Fruit
|
||||
{
|
||||
Samples = Samples,
|
||||
StartTime = lastTickTime,
|
||||
ComboColour = ComboColour,
|
||||
StartTime = repeatStartTime + repeatDuration,
|
||||
X = Curve.PositionAt(reversed ? 0 : 1).X / CatchPlayfield.BASE_WIDTH
|
||||
X = Curve.PositionAt(distanceProgress).X / CatchPlayfield.BASE_WIDTH,
|
||||
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
return ticks;
|
||||
double tinyTickInterval = tickDistance / length * repeatDuration;
|
||||
while (tinyTickInterval > 100)
|
||||
tinyTickInterval /= 2;
|
||||
|
||||
for (double t = 0; t < repeatDuration; t += tinyTickInterval)
|
||||
{
|
||||
double progress = reversed ? 1 - t / repeatDuration : t / repeatDuration;
|
||||
|
||||
AddNested(new TinyDroplet
|
||||
{
|
||||
StartTime = repeatStartTime + t,
|
||||
ComboColour = ComboColour,
|
||||
X = Curve.PositionAt(progress).X / CatchPlayfield.BASE_WIDTH,
|
||||
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
AddNested(new Fruit
|
||||
{
|
||||
Samples = Samples,
|
||||
ComboColour = ComboColour,
|
||||
StartTime = repeatStartTime + repeatDuration,
|
||||
X = Curve.PositionAt(reversed ? 0 : 1).X / CatchPlayfield.BASE_WIDTH
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity;
|
||||
|
||||
public float EndX => Curve.PositionAt(ProgressAt(1)).X / CatchPlayfield.BASE_WIDTH;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Judgements;
|
||||
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 });
|
||||
|
||||
foreach (var unused in stream.Ticks)
|
||||
foreach (var unused in stream.NestedHitObjects.OfType<CatchHitObject>())
|
||||
AddJudgement(new CatchJudgement { Result = HitResult.Perfect });
|
||||
|
||||
continue;
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("getting CI working")]
|
||||
internal class TestCaseCatcherArea : OsuTestCase
|
||||
public class TestCaseCatcherArea : OsuTestCase
|
||||
{
|
||||
private RulesetInfo catchRuleset;
|
||||
private TestCatcherArea catcherArea;
|
||||
|
@ -76,10 +76,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
Duration = endTime - HitObject.StartTime
|
||||
};
|
||||
|
||||
hold.Head.Samples.Add(new SampleInfo
|
||||
{
|
||||
Name = SampleInfo.HIT_NORMAL
|
||||
});
|
||||
if (hold.Head.Samples == null)
|
||||
hold.Head.Samples = new SampleInfoList();
|
||||
|
||||
hold.Head.Samples.Add(new SampleInfo { Name = SampleInfo.HIT_NORMAL });
|
||||
|
||||
hold.Tail.Samples = HitObject.Samples;
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
@ -63,9 +62,9 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
/// </summary>
|
||||
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);
|
||||
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
|
||||
@ -74,29 +73,27 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
Tail.ApplyDefaults(controlPointInfo, difficulty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The scoring scoring ticks of the hold note.
|
||||
/// </summary>
|
||||
public IEnumerable<HoldNoteTick> Ticks => ticks ?? (ticks = createTicks());
|
||||
private List<HoldNoteTick> ticks;
|
||||
|
||||
private List<HoldNoteTick> createTicks()
|
||||
protected override void CreateNestedHitObjects()
|
||||
{
|
||||
var ret = new List<HoldNoteTick>();
|
||||
base.CreateNestedHitObjects();
|
||||
|
||||
createTicks();
|
||||
}
|
||||
|
||||
private void createTicks()
|
||||
{
|
||||
if (tickSpacing == 0)
|
||||
return ret;
|
||||
return;
|
||||
|
||||
for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing)
|
||||
{
|
||||
ret.Add(new HoldNoteTick
|
||||
AddNested(new HoldNoteTick
|
||||
{
|
||||
StartTime = t,
|
||||
Column = Column
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -110,9 +107,9 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Mania.Judgements;
|
||||
@ -15,11 +16,12 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
/// <summary>
|
||||
/// The key-press hit window for this note.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
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);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Mania.Scoring
|
||||
AddJudgement(new ManiaJudgement { Result = HitResult.Perfect });
|
||||
|
||||
// Ticks
|
||||
int tickCount = holdNote.Ticks.Count();
|
||||
int tickCount = holdNote.NestedHitObjects.OfType<HoldNoteTick>().Count();
|
||||
for (int i = 0; i < tickCount; i++)
|
||||
AddJudgement(new HoldNoteTickJudgement { Result = HitResult.Perfect });
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("getting CI working")]
|
||||
internal class TestCaseManiaHitObjects : OsuTestCase
|
||||
public class TestCaseManiaHitObjects : OsuTestCase
|
||||
{
|
||||
public TestCaseManiaHitObjects()
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("getting CI working")]
|
||||
internal class TestCaseManiaPlayfield : OsuTestCase
|
||||
public class TestCaseManiaPlayfield : OsuTestCase
|
||||
{
|
||||
private const double start_time = 500;
|
||||
private const double duration = 500;
|
||||
|
@ -9,7 +9,6 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -44,7 +43,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
// Generate the bar lines
|
||||
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>();
|
||||
|
||||
for (int i = 0; i < timingPoints.Count; i++)
|
||||
|
@ -40,6 +40,10 @@
|
||||
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</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.Core" />
|
||||
</ItemGroup>
|
||||
|
@ -9,5 +9,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
public class OsuEditPlayfield : OsuPlayfield
|
||||
{
|
||||
protected override CursorContainer CreateCursor() => null;
|
||||
|
||||
protected override bool ProxyApproachCircles => false;
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
Scale = s.Scale,
|
||||
ComboColour = s.ComboColour,
|
||||
Samples = s.Samples,
|
||||
SampleControlPoint = s.SampleControlPoint
|
||||
})
|
||||
};
|
||||
|
||||
@ -66,7 +67,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
AddNested(initialCircle);
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
foreach (var repeatPoint in s.RepeatPoints)
|
||||
foreach (var repeatPoint in s.NestedHitObjects.OfType<RepeatPoint>())
|
||||
{
|
||||
var repeatStartTime = s.StartTime + repeatPoint.RepeatIndex * repeatDuration;
|
||||
var fadeInTime = repeatStartTime + (repeatPoint.StartTime - repeatStartTime) / 2 - (repeatPoint.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2);
|
||||
|
@ -68,9 +68,9 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
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;
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
public double Velocity;
|
||||
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);
|
||||
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
|
||||
@ -99,75 +99,79 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
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) return;
|
||||
|
||||
var length = Curve.Distance;
|
||||
var tickDistance = Math.Min(TickDistance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
var minDistanceFromEnd = Velocity * 0.01;
|
||||
|
||||
for (var repeat = 0; repeat < RepeatCount; repeat++)
|
||||
{
|
||||
if (TickDistance == 0) yield break;
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var reversed = repeat % 2 == 1;
|
||||
|
||||
var length = Curve.Distance;
|
||||
var tickDistance = Math.Min(TickDistance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
var minDistanceFromEnd = Velocity * 0.01;
|
||||
|
||||
for (var repeat = 0; repeat < RepeatCount; repeat++)
|
||||
for (var d = tickDistance; d <= length; d += tickDistance)
|
||||
{
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var reversed = repeat % 2 == 1;
|
||||
if (d > length - minDistanceFromEnd)
|
||||
break;
|
||||
|
||||
for (var d = tickDistance; d <= length; d += tickDistance)
|
||||
var distanceProgress = d / length;
|
||||
var timeProgress = reversed ? 1 - distanceProgress : distanceProgress;
|
||||
|
||||
AddNested(new SliderTick
|
||||
{
|
||||
if (d > length - minDistanceFromEnd)
|
||||
break;
|
||||
|
||||
var distanceProgress = d / length;
|
||||
var timeProgress = reversed ? 1 - distanceProgress : distanceProgress;
|
||||
|
||||
yield return new SliderTick
|
||||
RepeatIndex = repeat,
|
||||
StartTime = repeatStartTime + timeProgress * repeatDuration,
|
||||
Position = Curve.PositionAt(distanceProgress),
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
RepeatIndex = repeat,
|
||||
StartTime = repeatStartTime + timeProgress * repeatDuration,
|
||||
Position = Curve.PositionAt(distanceProgress),
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
};
|
||||
}
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
public IEnumerable<RepeatPoint> RepeatPoints
|
||||
|
||||
private void createRepeatPoints()
|
||||
{
|
||||
get
|
||||
var length = Curve.Distance;
|
||||
var repeatPointDistance = Math.Min(Distance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
for (var repeat = 1; repeat < RepeatCount; repeat++)
|
||||
{
|
||||
var length = Curve.Distance;
|
||||
var repeatPointDistance = Math.Min(Distance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
for (var repeat = 1; repeat < RepeatCount; repeat++)
|
||||
for (var d = repeatPointDistance; d <= length; d += repeatPointDistance)
|
||||
{
|
||||
for (var d = repeatPointDistance; d <= length; d += repeatPointDistance)
|
||||
{
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var distanceProgress = d / length;
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var distanceProgress = d / length;
|
||||
|
||||
yield return new RepeatPoint
|
||||
{
|
||||
RepeatIndex = repeat,
|
||||
StartTime = repeatStartTime,
|
||||
Position = Curve.PositionAt(distanceProgress),
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
};
|
||||
}
|
||||
AddNested(new RepeatPoint
|
||||
{
|
||||
RepeatIndex = repeat,
|
||||
StartTime = repeatStartTime,
|
||||
Position = Curve.PositionAt(distanceProgress),
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
Samples = new SampleInfoList(RepeatSamples[repeat])
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
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));
|
||||
|
||||
|
@ -93,6 +93,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
|
||||
float approxFollowCircleRadius = (float)(slider.Radius * 3);
|
||||
var computeVertex = new Action<double>(t =>
|
||||
{
|
||||
// ReSharper disable once PossibleInvalidOperationException (bugged in current r# version)
|
||||
var diff = slider.PositionAt(t) - slider.LazyEndPosition.Value;
|
||||
float dist = diff.Length;
|
||||
|
||||
@ -106,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)
|
||||
computeVertex(time);
|
||||
computeVertex(slider.EndTime);
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
||||
countHitCircles = Beatmap.HitObjects.Count(h => h is HitCircle);
|
||||
|
||||
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)
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
@ -39,11 +40,11 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
||||
AddJudgement(new OsuJudgement { Result = HitResult.Great });
|
||||
|
||||
// Ticks
|
||||
foreach (var unused in slider.Ticks)
|
||||
foreach (var unused in slider.NestedHitObjects.OfType<SliderTick>())
|
||||
AddJudgement(new OsuJudgement { Result = HitResult.Great });
|
||||
|
||||
//Repeats
|
||||
foreach (var unused in slider.RepeatPoints)
|
||||
foreach (var unused in slider.NestedHitObjects.OfType<RepeatPoint>())
|
||||
AddJudgement(new OsuJudgement { Result = HitResult.Great });
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("getting CI working")]
|
||||
internal class TestCaseHitObjects : OsuTestCase
|
||||
public class TestCaseHitObjects : OsuTestCase
|
||||
{
|
||||
private FramedClock framedClock;
|
||||
|
||||
|
@ -25,6 +25,10 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
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 override Vector2 Size
|
||||
@ -80,7 +84,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
h.Depth = (float)h.HitObject.StartTime;
|
||||
|
||||
var c = h as IDrawableHitObjectWithProxiedApproach;
|
||||
if (c != null)
|
||||
if (c != null && ProxyApproachCircles)
|
||||
approachCircles.Add(c.ProxiedLayer.CreateProxy());
|
||||
|
||||
base.Add(h);
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
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);
|
||||
newTick.OnJudgement += onTickJudgement;
|
||||
|
@ -67,7 +67,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
validKeyPressed = HitActions.Contains(action);
|
||||
|
||||
return UpdateJudgement(true);
|
||||
// Only count this as handled if the new judgement is a hit
|
||||
return UpdateJudgement(true) && Judgements.LastOrDefault()?.IsHit == true;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
return false;
|
||||
|
||||
// Assume the intention was to hit the strong hit with both keys only if the first key is still being held down
|
||||
return firstKeyHeld && UpdateJudgement(true);
|
||||
return firstKeyHeld && UpdateJudgement(true) && Judgements.LastOrDefault()?.IsHit == true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -37,47 +36,40 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
/// </summary>
|
||||
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>
|
||||
/// The length (in milliseconds) between ticks of this drumroll.
|
||||
/// <para>Half of this value is the hit window of the ticks.</para>
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
tickSpacing = timingPoint.BeatLength / TickRate;
|
||||
|
||||
RequiredGoodHits = TotalTicks * Math.Min(0.15, 0.05 + 0.10 / 6 * difficulty.OverallDifficulty);
|
||||
RequiredGreatHits = TotalTicks * Math.Min(0.30, 0.10 + 0.20 / 6 * difficulty.OverallDifficulty);
|
||||
RequiredGoodHits = NestedHitObjects.Count * Math.Min(0.15, 0.05 + 0.10 / 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)
|
||||
return ret;
|
||||
return;
|
||||
|
||||
bool first = true;
|
||||
for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing)
|
||||
{
|
||||
ret.Add(new DrumRollTick
|
||||
AddNested(new DrumRollTick
|
||||
{
|
||||
FirstTick = first,
|
||||
TickSpacing = tickSpacing,
|
||||
@ -93,8 +85,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
/// </summary>
|
||||
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);
|
||||
HitWindowGood = BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 120, 80, 50);
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
@ -83,7 +84,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
|
||||
}
|
||||
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));
|
||||
hitButton = !hitButton;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
@ -88,7 +89,7 @@ namespace osu.Game.Rulesets.Taiko.Scoring
|
||||
}
|
||||
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 });
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
[Ignore("getting CI working")]
|
||||
internal class TestCaseTaikoPlayfield : OsuTestCase
|
||||
public class TestCaseTaikoPlayfield : OsuTestCase
|
||||
{
|
||||
private const double default_duration = 1000;
|
||||
private const float scroll_time = 1000;
|
||||
|
@ -16,10 +16,17 @@ using osu.Framework.Extensions.Color4Extensions;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Audio;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
public class TaikoPlayfield : ScrollingPlayfield
|
||||
public class TaikoPlayfield : ScrollingPlayfield, IKeyBindingHandler<TaikoAction>
|
||||
{
|
||||
/// <summary>
|
||||
/// Default height of a <see cref="TaikoPlayfield"/> when inside a <see cref="TaikoRulesetContainer"/>.
|
||||
@ -54,9 +61,13 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
private readonly Box overlayBackground;
|
||||
private readonly Box background;
|
||||
|
||||
public TaikoPlayfield()
|
||||
private readonly ControlPointInfo controlPointInfo;
|
||||
private Dictionary<SampleControlPoint, DrumSamples> drumSampleMappings;
|
||||
|
||||
public TaikoPlayfield(ControlPointInfo controlPointInfo)
|
||||
: base(Axes.X)
|
||||
{
|
||||
this.controlPointInfo = controlPointInfo;
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
backgroundContainer = new Container
|
||||
@ -194,8 +205,19 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OsuColour colours, AudioManager audio)
|
||||
{
|
||||
drumSampleMappings = new Dictionary<SampleControlPoint, DrumSamples>();
|
||||
foreach (var s in controlPointInfo.SamplePoints)
|
||||
{
|
||||
drumSampleMappings.Add(s,
|
||||
new DrumSamples
|
||||
{
|
||||
Centre = s.GetSampleInfo().GetChannel(audio.Sample),
|
||||
Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample)
|
||||
});
|
||||
}
|
||||
|
||||
overlayBackgroundContainer.BorderColour = colours.Gray0;
|
||||
overlayBackground.Colour = colours.Gray1;
|
||||
|
||||
@ -249,7 +271,9 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
topLevelHitContainer.Add(judgedObject.CreateProxy());
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim));
|
||||
@ -258,5 +282,28 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
kiaiExplosionContainer.Add(new KiaiHitExplosion(judgedObject, isRim));
|
||||
}
|
||||
}
|
||||
|
||||
public bool OnPressed(TaikoAction action)
|
||||
{
|
||||
var samplePoint = controlPointInfo.SamplePointAt(Clock.CurrentTime);
|
||||
|
||||
if (!drumSampleMappings.TryGetValue(samplePoint, out var samples))
|
||||
throw new InvalidOperationException("Current sample set not found.");
|
||||
|
||||
if (action == TaikoAction.LeftCentre || action == TaikoAction.RightCentre)
|
||||
samples.Centre.Play();
|
||||
else
|
||||
samples.Rim.Play();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool OnReleased(TaikoAction action) => false;
|
||||
|
||||
private class DrumSamples
|
||||
{
|
||||
public SampleChannel Centre;
|
||||
public SampleChannel Rim;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
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,
|
||||
Origin = Anchor.CentreLeft
|
||||
|
@ -146,8 +146,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.AreEqual(116999, difficultyPoint.Time);
|
||||
Assert.AreEqual(0.75000000000000189d, difficultyPoint.SpeedMultiplier);
|
||||
|
||||
Assert.AreEqual(34, controlPoints.SoundPoints.Count);
|
||||
var soundPoint = controlPoints.SoundPoints[0];
|
||||
Assert.AreEqual(34, controlPoints.SamplePoints.Count);
|
||||
var soundPoint = controlPoints.SamplePoints[0];
|
||||
Assert.AreEqual(956, soundPoint.Time);
|
||||
Assert.AreEqual("soft", soundPoint.SampleBank);
|
||||
Assert.AreEqual(60, soundPoint.SampleVolume);
|
||||
|
176
osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs
Normal file
176
osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs
Normal 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
File diff suppressed because it is too large
Load Diff
@ -7,17 +7,17 @@ using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Lists;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseBeatSyncedContainer : OsuTestCase
|
||||
public class TestCaseBeatSyncedContainer : OsuTestCase
|
||||
{
|
||||
private readonly MusicController mc;
|
||||
|
||||
|
@ -17,7 +17,7 @@ using osu.Game.Screens.Select.Filter;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseBeatmapCarousel : OsuTestCase
|
||||
public class TestCaseBeatmapCarousel : OsuTestCase
|
||||
{
|
||||
private TestBeatmapCarousel carousel;
|
||||
|
||||
@ -69,6 +69,7 @@ namespace osu.Game.Tests.Visual
|
||||
testSorting();
|
||||
|
||||
testRemoveAll();
|
||||
testEmptyTraversal();
|
||||
}
|
||||
|
||||
private void ensureRandomFetchSuccess() =>
|
||||
@ -103,6 +104,8 @@ namespace osu.Game.Tests.Visual
|
||||
AddAssert($"{count} {(diff ? "diffs" : "sets")} visible", () =>
|
||||
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() =>
|
||||
AddStep("select random next", () =>
|
||||
{
|
||||
@ -274,9 +277,23 @@ namespace osu.Game.Tests.Visual
|
||||
return false;
|
||||
}, "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 BeatmapSetInfo createTestBeatmapSet(int i)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
[System.ComponentModel.Description("PlaySongSelect leaderboard/details area")]
|
||||
internal class TestCaseBeatmapDetailArea : OsuTestCase
|
||||
public class TestCaseBeatmapDetailArea : OsuTestCase
|
||||
{
|
||||
public TestCaseBeatmapDetailArea()
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ using osu.Game.Screens.Select;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("PlaySongSelect beatmap details")]
|
||||
internal class TestCaseBeatmapDetails : OsuTestCase
|
||||
public class TestCaseBeatmapDetails : OsuTestCase
|
||||
{
|
||||
public TestCaseBeatmapDetails()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ using osu.Game.Screens.Select;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseBeatmapInfoWedge : OsuTestCase
|
||||
public class TestCaseBeatmapInfoWedge : OsuTestCase
|
||||
{
|
||||
private BeatmapManager beatmaps;
|
||||
private readonly Random random;
|
||||
|
@ -10,7 +10,7 @@ using OpenTK.Input;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("bottom beatmap details")]
|
||||
internal class TestCaseBeatmapOptionsOverlay : OsuTestCase
|
||||
public class TestCaseBeatmapOptionsOverlay : OsuTestCase
|
||||
{
|
||||
public TestCaseBeatmapOptionsOverlay()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseBeatmapSetOverlay : OsuTestCase
|
||||
public class TestCaseBeatmapSetOverlay : OsuTestCase
|
||||
{
|
||||
private readonly BeatmapSetOverlay overlay;
|
||||
|
||||
|
@ -6,7 +6,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseBreadcrumbs : OsuTestCase
|
||||
public class TestCaseBreadcrumbs : OsuTestCase
|
||||
{
|
||||
public TestCaseBreadcrumbs()
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseBreakOverlay : OsuTestCase
|
||||
public class TestCaseBreakOverlay : OsuTestCase
|
||||
{
|
||||
private readonly BreakOverlay breakOverlay;
|
||||
|
||||
|
@ -9,7 +9,7 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseButtonSystem : OsuTestCase
|
||||
public class TestCaseButtonSystem : OsuTestCase
|
||||
{
|
||||
public TestCaseButtonSystem()
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ using osu.Game.Overlays;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("Testing chat api and overlay")]
|
||||
internal class TestCaseChatDisplay : OsuTestCase
|
||||
public class TestCaseChatDisplay : OsuTestCase
|
||||
{
|
||||
private readonly BeatmapSetOverlay beatmapSetOverlay;
|
||||
private readonly ChatOverlay chat;
|
||||
|
@ -13,7 +13,7 @@ using osu.Game.Graphics.Cursor;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseContextMenu : OsuTestCase
|
||||
public class TestCaseContextMenu : OsuTestCase
|
||||
{
|
||||
private const int start_time = 0;
|
||||
private const int duration = 1000;
|
||||
|
@ -7,7 +7,7 @@ using osu.Game.Overlays.Dialog;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseDialogOverlay : OsuTestCase
|
||||
public class TestCaseDialogOverlay : OsuTestCase
|
||||
{
|
||||
public TestCaseDialogOverlay()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseDrawableRoom : OsuTestCase
|
||||
public class TestCaseDrawableRoom : OsuTestCase
|
||||
{
|
||||
private RulesetStore rulesets;
|
||||
|
||||
|
@ -9,7 +9,7 @@ using osu.Game.Screens.Tournament.Teams;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("for tournament use")]
|
||||
internal class TestCaseDrawings : OsuTestCase
|
||||
public class TestCaseDrawings : OsuTestCase
|
||||
{
|
||||
public TestCaseDrawings()
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ using osu.Framework.Configuration;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseEditorSummaryTimeline : OsuTestCase
|
||||
public class TestCaseEditorSummaryTimeline : OsuTestCase
|
||||
{
|
||||
private const int length = 60000;
|
||||
private readonly Random random;
|
||||
@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual
|
||||
b.ControlPointInfo.EffectPoints.Add(new EffectControlPoint { Time = random.Next(0, length) });
|
||||
|
||||
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)];
|
||||
for (int i = 0; i < b.BeatmapInfo.Bookmarks.Length; i++)
|
||||
|
@ -5,7 +5,7 @@ using osu.Game.Beatmaps.ControlPoints;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseGamefield : OsuTestCase
|
||||
public class TestCaseGamefield : OsuTestCase
|
||||
{
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ using osu.Game.Screens.Play;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("player pause/fail screens")]
|
||||
internal class TestCaseGameplayMenuOverlay : OsuTestCase
|
||||
public class TestCaseGameplayMenuOverlay : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(FailOverlay), typeof(PauseContainer) };
|
||||
|
||||
|
@ -8,7 +8,7 @@ using OpenTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseGraph : OsuTestCase
|
||||
public class TestCaseGraph : OsuTestCase
|
||||
{
|
||||
public TestCaseGraph()
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseHistoricalSection : OsuTestCase
|
||||
public class TestCaseHistoricalSection : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes =>
|
||||
new[]
|
||||
|
@ -8,7 +8,7 @@ using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseKeyCounter : OsuTestCase
|
||||
public class TestCaseKeyCounter : OsuTestCase
|
||||
{
|
||||
public TestCaseKeyCounter()
|
||||
{
|
||||
|
@ -6,14 +6,45 @@ using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Allocation;
|
||||
using OpenTK;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("PlaySongSelect leaderboard")]
|
||||
internal class TestCaseLeaderboard : OsuTestCase
|
||||
public class TestCaseLeaderboard : OsuTestCase
|
||||
{
|
||||
private readonly Leaderboard leaderboard;
|
||||
private RulesetStore rulesets;
|
||||
|
||||
private readonly FailableLeaderboard leaderboard;
|
||||
|
||||
public TestCaseLeaderboard()
|
||||
{
|
||||
Add(leaderboard = new FailableLeaderboard
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Size = new Vector2(550f, 450f),
|
||||
Scope = LeaderboardScope.Global,
|
||||
});
|
||||
|
||||
AddStep(@"New Scores", newScores);
|
||||
AddStep(@"Empty Scores", () => leaderboard.SetRetrievalState(PlaceholderState.NoScores));
|
||||
AddStep(@"Network failure", () => leaderboard.SetRetrievalState(PlaceholderState.NetworkFailure));
|
||||
AddStep(@"No supporter", () => leaderboard.SetRetrievalState(PlaceholderState.NotSupporter));
|
||||
AddStep(@"Not logged in", () => leaderboard.SetRetrievalState(PlaceholderState.NotLoggedIn));
|
||||
AddStep(@"Unavailable", () => leaderboard.SetRetrievalState(PlaceholderState.Unavailable));
|
||||
AddStep(@"Real beatmap", realBeatmap);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
}
|
||||
|
||||
private void newScores()
|
||||
{
|
||||
@ -204,17 +235,44 @@ namespace osu.Game.Tests.Visual
|
||||
leaderboard.Scores = scores;
|
||||
}
|
||||
|
||||
public TestCaseLeaderboard()
|
||||
private void realBeatmap()
|
||||
{
|
||||
Add(leaderboard = new Leaderboard
|
||||
leaderboard.Beatmap = new BeatmapInfo
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Size = new Vector2(550f, 450f),
|
||||
});
|
||||
StarDifficulty = 1.36,
|
||||
Version = @"BASIC",
|
||||
OnlineBeatmapID = 1113057,
|
||||
Ruleset = rulesets.GetRuleset(0),
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 4,
|
||||
DrainRate = 6.5f,
|
||||
OverallDifficulty = 6.5f,
|
||||
ApproachRate = 5,
|
||||
},
|
||||
OnlineInfo = new BeatmapOnlineInfo
|
||||
{
|
||||
Length = 115000,
|
||||
CircleCount = 265,
|
||||
SliderCount = 71,
|
||||
PlayCount = 47906,
|
||||
PassCount = 19899,
|
||||
},
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Ratings = Enumerable.Range(0, 11),
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
AddStep(@"New Scores", newScores);
|
||||
newScores();
|
||||
private class FailableLeaderboard : Leaderboard
|
||||
{
|
||||
public void SetRetrievalState(PlaceholderState state)
|
||||
{
|
||||
PlaceholderState = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseMedalOverlay : OsuTestCase
|
||||
public class TestCaseMedalOverlay : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
|
@ -8,17 +8,25 @@ using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using OpenTK;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("mod select and icon display")]
|
||||
internal class TestCaseMods : OsuTestCase
|
||||
public class TestCaseMods : OsuTestCase
|
||||
{
|
||||
private ModSelectOverlay modSelect;
|
||||
private ModDisplay modDisplay;
|
||||
private const string unranked_suffix = " (Unranked)";
|
||||
|
||||
private RulesetStore rulesets;
|
||||
|
||||
private ModDisplay modDisplay;
|
||||
private TestModSelectOverlay modSelect;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets)
|
||||
@ -30,7 +38,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Add(modSelect = new ModSelectOverlay
|
||||
Add(modSelect = new TestModSelectOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.BottomCentre,
|
||||
@ -48,9 +56,156 @@ namespace osu.Game.Tests.Visual
|
||||
modDisplay.Current.BindTo(modSelect.SelectedMods);
|
||||
|
||||
AddStep("Toggle", modSelect.ToggleVisibility);
|
||||
AddStep("Hide", modSelect.Hide);
|
||||
AddStep("Show", modSelect.Show);
|
||||
|
||||
foreach (var ruleset in rulesets.AvailableRulesets)
|
||||
AddStep(ruleset.CreateInstance().Description, () => modSelect.Ruleset.Value = ruleset);
|
||||
foreach (var rulesetInfo in rulesets.AvailableRulesets)
|
||||
{
|
||||
Ruleset ruleset = rulesetInfo.CreateInstance();
|
||||
AddStep($"switch to {ruleset.Description}", () => modSelect.Ruleset.Value = rulesetInfo);
|
||||
|
||||
switch (ruleset) {
|
||||
case OsuRuleset or:
|
||||
testOsuMods(or);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void testOsuMods(OsuRuleset ruleset)
|
||||
{
|
||||
var easierMods = ruleset.GetModsFor(ModType.DifficultyReduction);
|
||||
var harderMods = ruleset.GetModsFor(ModType.DifficultyIncrease);
|
||||
var assistMods = ruleset.GetModsFor(ModType.Special);
|
||||
|
||||
var noFailMod = easierMods.FirstOrDefault(m => m is OsuModNoFail);
|
||||
var hiddenMod = harderMods.FirstOrDefault(m => m is OsuModHidden);
|
||||
var doubleTimeMod = harderMods.OfType<MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));
|
||||
var autoPilotMod = assistMods.FirstOrDefault(m => m is OsuModAutopilot);
|
||||
|
||||
testSingleMod(noFailMod);
|
||||
testMultiMod(doubleTimeMod);
|
||||
testIncompatibleMods(noFailMod, autoPilotMod);
|
||||
testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
|
||||
testMultiplierTextColour(noFailMod, modSelect.LowMultiplierColour);
|
||||
testMultiplierTextColour(hiddenMod, modSelect.HighMultiplierColour);
|
||||
testMultiplierTextUnranked(autoPilotMod);
|
||||
}
|
||||
|
||||
private void testSingleMod(Mod mod)
|
||||
{
|
||||
selectNext(mod);
|
||||
checkSelected(mod);
|
||||
|
||||
selectPrevious(mod);
|
||||
checkNotSelected(mod);
|
||||
|
||||
selectNext(mod);
|
||||
selectNext(mod);
|
||||
checkNotSelected(mod);
|
||||
|
||||
selectPrevious(mod);
|
||||
selectPrevious(mod);
|
||||
checkNotSelected(mod);
|
||||
}
|
||||
|
||||
private void testMultiMod(MultiMod multiMod)
|
||||
{
|
||||
foreach (var mod in multiMod.Mods)
|
||||
{
|
||||
selectNext(mod);
|
||||
checkSelected(mod);
|
||||
}
|
||||
|
||||
for (int index = multiMod.Mods.Length - 1; index >= 0; index--)
|
||||
selectPrevious(multiMod.Mods[index]);
|
||||
|
||||
foreach (var mod in multiMod.Mods)
|
||||
checkNotSelected(mod);
|
||||
}
|
||||
|
||||
private void testIncompatibleMods(Mod modA, Mod modB)
|
||||
{
|
||||
selectNext(modA);
|
||||
checkSelected(modA);
|
||||
checkNotSelected(modB);
|
||||
|
||||
selectNext(modB);
|
||||
checkSelected(modB);
|
||||
checkNotSelected(modA);
|
||||
|
||||
selectPrevious(modB);
|
||||
checkNotSelected(modA);
|
||||
checkNotSelected(modB);
|
||||
}
|
||||
|
||||
private void testDeselectAll(IEnumerable<Mod> mods)
|
||||
{
|
||||
foreach (var mod in mods)
|
||||
selectNext(mod);
|
||||
|
||||
AddAssert("check for any selection", () => modSelect.SelectedMods.Value.Any());
|
||||
AddStep("deselect all", modSelect.DeselectAllButton.Action.Invoke);
|
||||
AddAssert("check for no selection", () => !modSelect.SelectedMods.Value.Any());
|
||||
}
|
||||
|
||||
private void testMultiplierTextColour(Mod mod, Color4 colour)
|
||||
{
|
||||
checkLabelColor(Color4.White);
|
||||
selectNext(mod);
|
||||
AddWaitStep(1, "wait for changing colour");
|
||||
checkLabelColor(colour);
|
||||
selectPrevious(mod);
|
||||
AddWaitStep(1, "wait for changing colour");
|
||||
checkLabelColor(Color4.White);
|
||||
}
|
||||
|
||||
private void testMultiplierTextUnranked(Mod mod)
|
||||
{
|
||||
AddAssert("check for ranked", () => !modSelect.MultiplierLabel.Text.EndsWith(unranked_suffix));
|
||||
selectNext(mod);
|
||||
AddAssert("check for unranked", () => modSelect.MultiplierLabel.Text.EndsWith(unranked_suffix));
|
||||
selectPrevious(mod);
|
||||
AddAssert("check for ranked", () => !modSelect.MultiplierLabel.Text.EndsWith(unranked_suffix));
|
||||
}
|
||||
|
||||
private void selectNext(Mod mod) => AddStep($"left click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext());
|
||||
|
||||
private void selectPrevious(Mod mod) => AddStep($"right click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectPrevious());
|
||||
|
||||
private void checkSelected(Mod mod)
|
||||
{
|
||||
AddAssert($"check {mod.Name} is selected", () =>
|
||||
{
|
||||
var button = modSelect.GetModButton(mod);
|
||||
return modSelect.SelectedMods.Value.Single(m => m.Name == mod.Name) != null && button.SelectedMod.GetType() == mod.GetType() && button.Selected;
|
||||
});
|
||||
}
|
||||
|
||||
private void checkNotSelected(Mod mod)
|
||||
{
|
||||
AddAssert($"check {mod.Name} is not selected", () =>
|
||||
{
|
||||
var button = modSelect.GetModButton(mod);
|
||||
return modSelect.SelectedMods.Value.All(m => m.GetType() != mod.GetType()) && button.SelectedMod?.GetType() != mod.GetType();
|
||||
});
|
||||
}
|
||||
|
||||
private void checkLabelColor(Color4 color) => AddAssert("check label has expected colour", () => modSelect.MultiplierLabel.Colour.AverageColour == color);
|
||||
|
||||
private class TestModSelectOverlay : ModSelectOverlay
|
||||
{
|
||||
public ModButton GetModButton(Mod mod)
|
||||
{
|
||||
var section = ModSectionsContainer.Children.Single(s => s.ModType == mod.Type);
|
||||
return section.ButtonsContainer.OfType<ModButton>().Single(b => b.Mods.Any(m => m.GetType() == mod.GetType()));
|
||||
}
|
||||
|
||||
public new OsuSpriteText MultiplierLabel => base.MultiplierLabel;
|
||||
public new TriangleButton DeselectAllButton => base.DeselectAllButton;
|
||||
|
||||
public new Color4 LowMultiplierColour => base.LowMultiplierColour;
|
||||
public new Color4 HighMultiplierColour => base.HighMultiplierColour;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseMusicController : OsuTestCase
|
||||
public class TestCaseMusicController : OsuTestCase
|
||||
{
|
||||
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
||||
|
||||
|
@ -3,19 +3,17 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
internal class TestCaseNotificationOverlay : OsuTestCase
|
||||
public class TestCaseNotificationOverlay : OsuTestCase
|
||||
{
|
||||
private readonly NotificationOverlay manager;
|
||||
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
|
||||
|
||||
public TestCaseNotificationOverlay()
|
||||
{
|
||||
@ -24,15 +22,14 @@ namespace osu.Game.Tests.Visual
|
||||
Content.Add(manager = new NotificationOverlay
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight
|
||||
});
|
||||
|
||||
AddToggleStep(@"show", state => manager.State = state ? Visibility.Visible : Visibility.Hidden);
|
||||
|
||||
AddStep(@"simple #1", sendNotification1);
|
||||
AddStep(@"simple #2", sendNotification2);
|
||||
AddStep(@"progress #1", sendProgress1);
|
||||
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());
|
||||
}
|
||||
|
||||
@ -41,16 +38,16 @@ namespace osu.Game.Tests.Visual
|
||||
switch (RNG.Next(0, 4))
|
||||
{
|
||||
case 0:
|
||||
sendNotification1();
|
||||
sendHelloNotification();
|
||||
break;
|
||||
case 1:
|
||||
sendNotification2();
|
||||
sendAmazingNotification();
|
||||
break;
|
||||
case 2:
|
||||
sendProgress1();
|
||||
sendUploadProgress();
|
||||
break;
|
||||
case 3:
|
||||
sendProgress2();
|
||||
sendDownloadProgress();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -80,28 +77,34 @@ namespace osu.Game.Tests.Visual
|
||||
}
|
||||
}
|
||||
|
||||
private void sendProgress2()
|
||||
private void sendDownloadProgress()
|
||||
{
|
||||
var n = new ProgressNotification { Text = @"Downloading Haitai..." };
|
||||
var n = new ProgressNotification
|
||||
{
|
||||
Text = @"Downloading Haitai...",
|
||||
CompletionText = "Downloaded Haitai!",
|
||||
};
|
||||
manager.Post(n);
|
||||
progressingNotifications.Add(n);
|
||||
}
|
||||
|
||||
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
|
||||
|
||||
private void sendProgress1()
|
||||
private void sendUploadProgress()
|
||||
{
|
||||
var n = new ProgressNotification { Text = @"Uploading to BSS..." };
|
||||
var n = new ProgressNotification
|
||||
{
|
||||
Text = @"Uploading to BSS...",
|
||||
CompletionText = "Uploaded to BSS!",
|
||||
};
|
||||
manager.Post(n);
|
||||
progressingNotifications.Add(n);
|
||||
}
|
||||
|
||||
private void sendNotification2()
|
||||
private void sendAmazingNotification()
|
||||
{
|
||||
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!" });
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseOnScreenDisplay : OsuTestCase
|
||||
public class TestCaseOnScreenDisplay : OsuTestCase
|
||||
{
|
||||
private FrameworkConfigManager config;
|
||||
private Bindable<FrameSync> frameSyncMode;
|
||||
|
@ -19,7 +19,7 @@ using osu.Game.Tests.Platform;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCasePlaySongSelect : OsuTestCase
|
||||
public class TestCasePlaySongSelect : OsuTestCase
|
||||
{
|
||||
private BeatmapManager manager;
|
||||
|
||||
|
123
osu.Game.Tests/Visual/TestCaseRankGraph.cs
Normal file
123
osu.Game.Tests/Visual/TestCaseRankGraph.cs
Normal 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,
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseReplay : TestCasePlayer
|
||||
public class TestCaseReplay : TestCasePlayer
|
||||
{
|
||||
protected override Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Screens.Play.ReplaySettings;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseReplaySettingsOverlay : OsuTestCase
|
||||
public class TestCaseReplaySettingsOverlay : OsuTestCase
|
||||
{
|
||||
public TestCaseReplaySettingsOverlay()
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseResults : OsuTestCase
|
||||
public class TestCaseResults : OsuTestCase
|
||||
{
|
||||
private BeatmapManager beatmaps;
|
||||
|
||||
|
@ -11,7 +11,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseRoomInspector : OsuTestCase
|
||||
public class TestCaseRoomInspector : OsuTestCase
|
||||
{
|
||||
private RulesetStore rulesets;
|
||||
|
||||
|
@ -10,7 +10,7 @@ using OpenTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseScoreCounter : OsuTestCase
|
||||
public class TestCaseScoreCounter : OsuTestCase
|
||||
{
|
||||
public TestCaseScoreCounter()
|
||||
{
|
||||
|
@ -1,23 +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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseSettings : OsuTestCase
|
||||
public class TestCaseSettings : OsuTestCase
|
||||
{
|
||||
private readonly SettingsOverlay settings;
|
||||
private readonly DialogOverlay dialogOverlay;
|
||||
|
||||
private DependencyContainer dependencies;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
|
||||
|
||||
public TestCaseSettings()
|
||||
{
|
||||
Children = new[] { settings = new MainSettings() };
|
||||
settings = new MainSettings
|
||||
{
|
||||
State = Visibility.Visible
|
||||
};
|
||||
Add(dialogOverlay = new DialogOverlay
|
||||
{
|
||||
Depth = -1
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
base.LoadComplete();
|
||||
settings.ToggleVisibility();
|
||||
dependencies.Cache(dialogOverlay);
|
||||
|
||||
Add(settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseSkipButton : OsuTestCase
|
||||
public class TestCaseSkipButton : OsuTestCase
|
||||
{
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseSongProgress : OsuTestCase
|
||||
public class TestCaseSongProgress : OsuTestCase
|
||||
{
|
||||
private readonly SongProgress progress;
|
||||
private readonly SongProgressGraph graph;
|
||||
|
@ -14,7 +14,7 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseStoryboard : OsuTestCase
|
||||
public class TestCaseStoryboard : OsuTestCase
|
||||
{
|
||||
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
||||
|
||||
|
@ -10,7 +10,7 @@ using OpenTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseTextAwesome : OsuTestCase
|
||||
public class TestCaseTextAwesome : OsuTestCase
|
||||
{
|
||||
public TestCaseTextAwesome()
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ using osu.Game.Graphics.UserInterface;
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[Description("mostly back button")]
|
||||
internal class TestCaseTwoLayerButton : OsuTestCase
|
||||
public class TestCaseTwoLayerButton : OsuTestCase
|
||||
{
|
||||
public TestCaseTwoLayerButton()
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ using OpenTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseUserPanel : OsuTestCase
|
||||
public class TestCaseUserPanel : OsuTestCase
|
||||
{
|
||||
public TestCaseUserPanel()
|
||||
{
|
||||
|
@ -2,18 +2,35 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Profile;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal 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()
|
||||
{
|
||||
var profile = new UserProfileOverlay();
|
||||
Add(profile);
|
||||
Add(profile = new TestUserProfileOverlay());
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
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()
|
||||
}
|
||||
}, false));
|
||||
|
||||
checkSupporterTag(false);
|
||||
|
||||
AddStep("Show ppy", () => profile.ShowUser(new User
|
||||
{
|
||||
Username = @"peppy",
|
||||
@ -44,6 +64,9 @@ namespace osu.Game.Tests.Visual
|
||||
Country = new Country { FullName = @"Australia", FlagName = @"AU" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
|
||||
}));
|
||||
|
||||
checkSupporterTag(true);
|
||||
|
||||
AddStep("Show flyte", () => profile.ShowUser(new User
|
||||
{
|
||||
Username = @"flyte",
|
||||
@ -51,8 +74,23 @@ namespace osu.Game.Tests.Visual
|
||||
Country = new Country { FullName = @"Japan", FlagName = @"JP" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
||||
}));
|
||||
|
||||
AddStep("Hide", profile.Hide);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseUserRanks : OsuTestCase
|
||||
public class TestCaseUserRanks : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(DrawableProfileScore), typeof(RanksSection) };
|
||||
|
||||
|
@ -15,7 +15,7 @@ using osu.Game.Screens.Edit.Screens.Compose.Timeline;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
internal class TestCaseWaveform : OsuTestCase
|
||||
public class TestCaseWaveform : OsuTestCase
|
||||
{
|
||||
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
||||
|
||||
|
@ -30,6 +30,9 @@
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<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">
|
||||
<HintPath>$(SolutionDir)\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -83,6 +86,7 @@
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Beatmaps\Formats\OsuJsonDecoderTest.cs" />
|
||||
<Compile Include="Beatmaps\Formats\LegacyStoryboardDecoderTest.cs" />
|
||||
<Compile Include="Beatmaps\IO\OszArchiveReaderTest.cs" />
|
||||
<Compile Include="Beatmaps\IO\ImportBeatmapTest.cs" />
|
||||
@ -131,6 +135,7 @@
|
||||
<Compile Include="Visual\TestCaseChatLink.cs" />
|
||||
<Compile Include="Visual\TestCasePlaybackControl.cs" />
|
||||
<Compile Include="Visual\TestCasePlaySongSelect.cs" />
|
||||
<Compile Include="Visual\TestCaseRankGraph.cs" />
|
||||
<Compile Include="Visual\TestCaseReplay.cs" />
|
||||
<Compile Include="Visual\TestCaseReplaySettingsOverlay.cs" />
|
||||
<Compile Include="Visual\TestCaseResults.cs" />
|
||||
@ -153,6 +158,8 @@
|
||||
<ItemGroup>
|
||||
<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\Within Temptation - The Unforgiving %28Armin%29 [Marathon].osu" />
|
||||
<EmbeddedResource Include="Resources\Kozato snow - Rengetsu Ouka %28_Kiva%29 [Yuki YukI].osu" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -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
|
||||
-->
|
||||
<packages>
|
||||
<package id="DeepEqual" version="1.6.0.0" targetFramework="net461" />
|
||||
<package id="NUnit" version="3.8.1" targetFramework="net461" />
|
||||
<package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" />
|
||||
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
|
||||
|
@ -1,8 +1,12 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Audio.Sample;
|
||||
|
||||
namespace osu.Game.Audio
|
||||
{
|
||||
[Serializable]
|
||||
public class SampleInfo
|
||||
{
|
||||
public const string HIT_WHISTLE = @"hitwhistle";
|
||||
@ -10,6 +14,13 @@ namespace osu.Game.Audio
|
||||
public const string HIT_NORMAL = @"hitnormal";
|
||||
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>
|
||||
/// The bank to load the sample from.
|
||||
/// </summary>
|
||||
|
@ -8,19 +8,21 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.IO.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.IO.Serialization.Converters;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
/// <summary>
|
||||
/// A Beatmap containing converted HitObjects.
|
||||
/// </summary>
|
||||
public class Beatmap<T>
|
||||
public class Beatmap<T> : IJsonSerializable
|
||||
where T : HitObject
|
||||
{
|
||||
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
|
||||
public ControlPointInfo ControlPointInfo = new ControlPointInfo();
|
||||
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(102, 136, 0, 255),
|
||||
@ -28,16 +30,19 @@ namespace osu.Game.Beatmaps
|
||||
new Color4(121, 9, 13, 255)
|
||||
};
|
||||
|
||||
[JsonIgnore]
|
||||
public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// The HitObjects this Beatmap contains.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(TypedListConverter<HitObject>))]
|
||||
public List<T> HitObjects = new List<T>();
|
||||
|
||||
/// <summary>
|
||||
/// Total amount of break time in the beatmap.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
||||
|
||||
/// <summary>
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -13,6 +14,7 @@ namespace osu.Game.Beatmaps
|
||||
public const float DEFAULT_DIFFICULTY = 5;
|
||||
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public int ID { get; set; }
|
||||
|
||||
public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;
|
||||
|
@ -12,9 +12,11 @@ using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
[Serializable]
|
||||
public class BeatmapInfo : IEquatable<BeatmapInfo>, IJsonSerializable, IHasPrimaryKey
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public int ID { get; set; }
|
||||
|
||||
//TODO: should be in database
|
||||
@ -38,13 +40,16 @@ namespace osu.Game.Beatmaps
|
||||
set { onlineBeatmapSetID = value > 0 ? value : null; }
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public int BeatmapSetInfoID { get; set; }
|
||||
|
||||
[Required]
|
||||
[JsonIgnore]
|
||||
public BeatmapSetInfo BeatmapSet { get; set; }
|
||||
|
||||
public BeatmapMetadata Metadata { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int BaseDifficultyID { get; set; }
|
||||
|
||||
public BeatmapDifficulty BaseDifficulty { get; set; }
|
||||
@ -60,6 +65,7 @@ namespace osu.Game.Beatmaps
|
||||
[JsonProperty("file_sha2")]
|
||||
public string Hash { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool Hidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -134,6 +134,7 @@ namespace osu.Game.Beatmaps
|
||||
var notification = new ProgressNotification
|
||||
{
|
||||
Text = "Beatmap import is initialising...",
|
||||
CompletionText = "Import successful!",
|
||||
Progress = 0,
|
||||
State = ProgressNotificationState.Active,
|
||||
};
|
||||
@ -245,8 +246,9 @@ namespace osu.Game.Beatmaps
|
||||
return;
|
||||
}
|
||||
|
||||
ProgressNotification downloadNotification = new ProgressNotification
|
||||
var downloadNotification = new ProgressNotification
|
||||
{
|
||||
CompletionText = $"Imported {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}!",
|
||||
Text = $"Downloading {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}",
|
||||
};
|
||||
|
||||
@ -339,6 +341,61 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
}
|
||||
|
||||
public void UndeleteAll()
|
||||
{
|
||||
var deleteMaps = QueryBeatmapSets(bs => bs.DeletePending).ToList();
|
||||
|
||||
if (!deleteMaps.Any()) return;
|
||||
|
||||
var notification = new ProgressNotification
|
||||
{
|
||||
CompletionText = "Restored all deleted beatmaps!",
|
||||
Progress = 0,
|
||||
State = ProgressNotificationState.Active,
|
||||
};
|
||||
|
||||
PostNotification?.Invoke(notification);
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (var bs in deleteMaps)
|
||||
{
|
||||
if (notification.State == ProgressNotificationState.Cancelled)
|
||||
// user requested abort
|
||||
return;
|
||||
|
||||
notification.Text = $"Restoring ({i} of {deleteMaps.Count})";
|
||||
notification.Progress = (float)++i / deleteMaps.Count;
|
||||
Undelete(bs);
|
||||
}
|
||||
|
||||
notification.State = ProgressNotificationState.Completed;
|
||||
}
|
||||
|
||||
public void Undelete(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
if (beatmapSet.Protected)
|
||||
return;
|
||||
|
||||
lock (importContext)
|
||||
{
|
||||
var context = importContext.Value;
|
||||
|
||||
using (var transaction = context.BeginTransaction())
|
||||
{
|
||||
context.ChangeTracker.AutoDetectChangesEnabled = false;
|
||||
|
||||
var iFiles = new FileStore(() => context, storage);
|
||||
var iBeatmaps = createBeatmapStore(() => context);
|
||||
|
||||
undelete(iBeatmaps, iFiles, beatmapSet);
|
||||
|
||||
context.ChangeTracker.AutoDetectChangesEnabled = true;
|
||||
context.SaveChanges(transaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a beatmap difficulty.
|
||||
/// </summary>
|
||||
@ -665,6 +722,7 @@ namespace osu.Game.Beatmaps
|
||||
var notification = new ProgressNotification
|
||||
{
|
||||
Progress = 0,
|
||||
CompletionText = "Deleted all beatmaps!",
|
||||
State = ProgressNotificationState.Active,
|
||||
};
|
||||
|
||||
|
@ -10,9 +10,11 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
[Serializable]
|
||||
public class BeatmapMetadata : IEquatable<BeatmapMetadata>
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public int ID { get; set; }
|
||||
|
||||
private int? onlineBeatmapSetID;
|
||||
@ -30,7 +32,10 @@ namespace osu.Game.Beatmaps
|
||||
public string Artist { get; set; }
|
||||
public string ArtistUnicode { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<BeatmapInfo> Beatmaps { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<BeatmapSetInfo> BeatmapSets { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -47,6 +52,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// The author of the beatmaps in this set.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public User Author;
|
||||
|
||||
public string Source { get; set; }
|
||||
@ -59,6 +65,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public override string ToString() => $"{Artist} - {Title} ({Author})";
|
||||
|
||||
[JsonIgnore]
|
||||
public string[] SearchableTerms => new[]
|
||||
{
|
||||
Author?.Username,
|
||||
|
@ -4,31 +4,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Lists;
|
||||
|
||||
namespace osu.Game.Beatmaps.ControlPoints
|
||||
{
|
||||
[Serializable]
|
||||
public class ControlPointInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// All timing points.
|
||||
/// </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>
|
||||
/// All difficulty points.
|
||||
/// </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>
|
||||
/// All sound points.
|
||||
/// </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>
|
||||
/// All effect points.
|
||||
/// </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>
|
||||
/// Finds the difficulty control point that is active at <paramref name="time"/>.
|
||||
@ -49,7 +55,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
/// </summary>
|
||||
/// <param name="time">The time to find the sound control point at.</param>
|
||||
/// <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>
|
||||
/// 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>
|
||||
public TimingControlPoint TimingPointAt(double time) => binarySearch(TimingPoints, time, TimingPoints.FirstOrDefault());
|
||||
|
||||
[JsonIgnore]
|
||||
/// <summary>
|
||||
/// Finds the maximum BPM represented by any timing control point.
|
||||
/// </summary>
|
||||
public double BPMMaximum =>
|
||||
60000 / (TimingPoints.OrderBy(c => c.BeatLength).FirstOrDefault() ?? new TimingControlPoint()).BeatLength;
|
||||
|
||||
[JsonIgnore]
|
||||
/// <summary>
|
||||
/// Finds the minimum BPM represented by any timing control point.
|
||||
/// </summary>
|
||||
public double BPMMinimum =>
|
||||
60000 / (TimingPoints.OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? new TimingControlPoint()).BeatLength;
|
||||
|
||||
[JsonIgnore]
|
||||
/// <summary>
|
||||
/// Finds the mode BPM (most common BPM) represented by the control points.
|
||||
/// </summary>
|
||||
@ -108,4 +117,4 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
return list[index - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
34
osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs
Normal file
34
osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs
Normal 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,
|
||||
};
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -10,11 +10,12 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
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()
|
||||
{
|
||||
LegacyDecoder.Register();
|
||||
JsonBeatmapDecoder.Register();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -33,17 +34,18 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
if (line == null || !decoders.ContainsKey(line))
|
||||
throw new IOException(@"Unknown file format");
|
||||
return (Decoder)Activator.CreateInstance(decoders[line], line);
|
||||
|
||||
return decoders[line](line);
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <typeparam name="T">Type to decode a <see cref="Beatmap"/> with.</typeparam>
|
||||
/// <param name="version">A string representation of the version.</param>
|
||||
protected static void AddDecoder<T>(string version) where T : Decoder
|
||||
/// <param name="magic">A string in the file which triggers this decoder to be used.</param>
|
||||
/// <param name="constructor">A function which constructs the <see cref="Decoder"/> given <paramref name="magic"/>.</param>
|
||||
protected static void AddDecoder(string magic, Func<string, Decoder> constructor)
|
||||
{
|
||||
decoders[version] = typeof(T);
|
||||
decoders[magic] = constructor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
35
osu.Game/Beatmaps/Formats/JsonBeatmapDecoder.cs
Normal file
35
osu.Game/Beatmaps/Formats/JsonBeatmapDecoder.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -313,7 +313,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
stringSampleSet = @"normal";
|
||||
|
||||
DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(time);
|
||||
SoundControlPoint soundPoint = beatmap.ControlPointInfo.SoundPointAt(time);
|
||||
SampleControlPoint samplePoint = beatmap.ControlPointInfo.SamplePointAt(time);
|
||||
EffectControlPoint effectPoint = beatmap.ControlPointInfo.EffectPointAt(time);
|
||||
|
||||
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,
|
||||
SampleBank = stringSampleSet,
|
||||
|
@ -13,18 +13,18 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public static void Register()
|
||||
{
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v14");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v13");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v12");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v11");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v10");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v9");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v8");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v7");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v6");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v5");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v4");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v3");
|
||||
AddDecoder(@"osu file format v14", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v13", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v12", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v11", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v10", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v9", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v8", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v7", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v6", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v5", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v4", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v3", m => new LegacyBeatmapDecoder(m));
|
||||
// TODO: differences between versions
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Framework.IO.File;
|
||||
using System.IO;
|
||||
using osu.Game.IO.Serialization;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -38,6 +42,17 @@ namespace osu.Game.Beatmaps
|
||||
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 Texture GetBackground();
|
||||
protected abstract Track GetTrack();
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Caching;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -47,7 +48,16 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set
|
||||
{
|
||||
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.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)
|
||||
{
|
||||
if ((invalidation & Invalidation.DrawSize) != 0)
|
||||
applyPath();
|
||||
if ((invalidation & Invalidation.DrawSize) > 0)
|
||||
pathCached.Invalidate();
|
||||
|
||||
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()
|
||||
{
|
||||
path.ClearVertices();
|
||||
@ -77,13 +102,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
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++)
|
||||
{
|
||||
float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user