1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 05:02:55 +08:00

Merge branch 'master' into expand-social-tab

This commit is contained in:
Aergwyn 2017-12-28 19:36:22 +01:00
commit b029f019b2
113 changed files with 1538 additions and 685 deletions

View File

@ -110,7 +110,7 @@ namespace osu.Desktop.Overlays
// only show a notification if we've previously saved a version to the config file (ie. not the first run).
if (!string.IsNullOrEmpty(lastVersion))
Scheduler.AddDelayed(() => notificationOverlay.Post(new UpdateCompleteNotification(version)), 5000);
notificationOverlay.Post(new UpdateCompleteNotification(version));
}
}

View File

@ -135,8 +135,8 @@
<HintPath>$(SolutionDir)\packages\squirrel.windows.1.7.8\lib\Net45\NuGet.Squirrel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00021\lib\net20\OpenTK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpCompress, Version=0.18.1.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">

View File

@ -6,7 +6,7 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/maste
<packages>
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net45" />
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net45" />
<package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" />
<package id="OpenTK" version="3.0.0-git00021" targetFramework="net461" />
<package id="SharpCompress" version="0.18.1" targetFramework="net461" />
<package id="Splat" version="2.0.0" targetFramework="net45" />
<package id="SQLitePCLRaw.bundle_green" version="1.1.8" targetFramework="net461" />

View File

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

View File

@ -36,8 +36,8 @@
<HintPath>$(SolutionDir)\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00021\lib\net20\OpenTK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.8.1" targetFramework="net461" />
<package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" />
<package id="OpenTK" version="3.0.0-git00021" targetFramework="net461" />
</packages>

View File

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

View File

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

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.MathUtils;
using osu.Game.Rulesets.Objects;
@ -77,7 +78,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
};
if (hold.Head.Samples == null)
hold.Head.Samples = new SampleInfoList();
hold.Head.Samples = new List<SampleInfo>();
hold.Head.Samples.Add(new SampleInfo { Name = SampleInfo.HIT_NORMAL });

View File

@ -36,8 +36,8 @@
<HintPath>$(SolutionDir)\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00021\lib\net20\OpenTK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.8.1" targetFramework="net461" />
<package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" />
<package id="OpenTK" version="3.0.0-git00021" targetFramework="net461" />
</packages>

View File

@ -117,11 +117,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
progress = slider.ProgressAt(progress);
if (repeat > currentRepeat)
{
if (repeat < slider.RepeatCount && ball.Tracking)
PlaySamples();
currentRepeat = repeat;
}
//todo: we probably want to reconsider this before adding scoring, but it looks and feels nice.
if (!initialCircle.Judgements.Any(j => j.IsHit))
@ -171,9 +167,4 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public override Vector2 SelectionPoint => ToScreenSpace(body.Position);
public override Quad SelectionQuad => body.PathDrawQuad;
}
internal interface ISliderProgress
{
void UpdateProgress(double progress, int repeat);
}
}

View File

@ -0,0 +1,10 @@
// 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.Rulesets.Osu.Objects
{
public interface ISliderProgress
{
void UpdateProgress(double progress, int repeat);
}
}

View File

@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Osu.Objects
/// </summary>
internal float LazyTravelDistance;
public List<SampleInfoList> RepeatSamples { get; set; } = new List<SampleInfoList>();
public List<List<SampleInfo>> RepeatSamples { get; set; } = new List<List<SampleInfo>>();
public int RepeatCount { get; set; } = 1;
private int stackHeight;
@ -138,7 +138,7 @@ namespace osu.Game.Rulesets.Osu.Objects
StackHeight = StackHeight,
Scale = Scale,
ComboColour = ComboColour,
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
{
Bank = s.Bank,
Name = @"slidertick",
@ -151,28 +151,22 @@ namespace osu.Game.Rulesets.Osu.Objects
private void createRepeatPoints()
{
var length = Curve.Distance;
var repeatPointDistance = Math.Min(Distance, length);
var repeatDuration = length / Velocity;
var repeatDuration = Distance / Velocity;
for (var repeat = 1; repeat < RepeatCount; repeat++)
{
for (var d = repeatPointDistance; d <= length; d += repeatPointDistance)
{
var repeatStartTime = StartTime + repeat * repeatDuration;
var distanceProgress = d / length;
var repeatStartTime = StartTime + repeat * repeatDuration;
AddNested(new RepeatPoint
{
RepeatIndex = repeat,
StartTime = repeatStartTime,
Position = Curve.PositionAt(distanceProgress),
StackHeight = StackHeight,
Scale = Scale,
ComboColour = ComboColour,
Samples = new SampleInfoList(RepeatSamples[repeat])
});
}
AddNested(new RepeatPoint
{
RepeatIndex = repeat,
StartTime = repeatStartTime,
Position = Curve.PositionAt(repeat % 2),
StackHeight = StackHeight,
Scale = Scale,
ComboColour = ComboColour,
Samples = new List<SampleInfo>(RepeatSamples[repeat])
});
}
}
}

View File

@ -0,0 +1,70 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Tests
{
[Ignore("getting CI working")]
public class TestCaseHitCircle : OsuTestCase
{
private readonly Container content;
protected override Container<Drawable> Content => content;
private bool auto;
private int depthIndex;
public TestCaseHitCircle()
{
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
AddStep("Single", () => addSingle());
AddStep("Stream", addStream);
AddToggleStep("Auto", v => auto = v);
}
private void addSingle(double timeOffset = 0, Vector2? positionOffset = null)
{
positionOffset = positionOffset ?? Vector2.Zero;
var circle = new HitCircle
{
StartTime = Time.Current + 1000 + timeOffset,
Position = positionOffset.Value
};
circle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 0 });
var drawable = new DrawableHitCircle(circle)
{
Anchor = Anchor.Centre,
Depth = depthIndex++
};
if (auto)
drawable.State.Value = ArmedState.Hit;
Add(drawable);
}
private void addStream()
{
Vector2 pos = Vector2.Zero;
for (int i = 0; i <= 1000; i += 100)
{
addSingle(i, pos);
pos += new Vector2(10);
}
}
}
}

View File

@ -1,129 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Tests
{
[TestFixture]
[Ignore("getting CI working")]
public class TestCaseHitObjects : OsuTestCase
{
private FramedClock framedClock;
private bool auto;
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{
var rateAdjustClock = new StopwatchClock(true);
framedClock = new FramedClock(rateAdjustClock);
AddStep(@"circles", () => loadHitobjects(HitObjectType.Circle));
AddStep(@"slider", () => loadHitobjects(HitObjectType.Slider));
AddStep(@"spinner", () => loadHitobjects(HitObjectType.Spinner));
AddToggleStep("Auto", state => { auto = state; loadHitobjects(mode); });
AddSliderStep("Playback speed", 0.0, 2.0, 0.5, v => rateAdjustClock.Rate = v);
framedClock.ProcessFrame();
var clockAdjustContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Clock = framedClock,
Children = new[]
{
playfieldContainer = new OsuInputManager(rulesets.GetRuleset(0)) { RelativeSizeAxes = Axes.Both },
approachContainer = new Container { RelativeSizeAxes = Axes.Both }
}
};
Add(clockAdjustContainer);
}
private HitObjectType mode = HitObjectType.Slider;
private Container playfieldContainer;
private Container approachContainer;
private void loadHitobjects(HitObjectType mode)
{
this.mode = mode;
switch (mode)
{
case HitObjectType.Circle:
const int count = 10;
for (int i = 0; i < count; i++)
{
var h = new HitCircle
{
StartTime = framedClock.CurrentTime + 600 + i * 80,
Position = new Vector2((i - count / 2) * 14),
};
add(new DrawableHitCircle(h));
}
break;
case HitObjectType.Slider:
add(new DrawableSlider(new Slider
{
StartTime = framedClock.CurrentTime + 600,
ControlPoints = new List<Vector2>
{
new Vector2(-200, 0),
new Vector2(400, 0),
},
Distance = 400,
Position = new Vector2(-200, 0),
Velocity = 1,
TickDistance = 100,
}));
break;
case HitObjectType.Spinner:
add(new DrawableSpinner(new Spinner
{
StartTime = framedClock.CurrentTime + 600,
EndTime = framedClock.CurrentTime + 1600,
Position = new Vector2(0, 0),
}));
break;
}
}
private int depth;
private void add(DrawableOsuHitObject h)
{
h.Anchor = Anchor.Centre;
h.Depth = depth++;
if (auto)
h.State.Value = ArmedState.Hit;
playfieldContainer.Add(h);
var proxyable = h as IDrawableHitObjectWithProxiedApproach;
if (proxyable != null)
approachContainer.Add(proxyable.ProxiedLayer.CreateProxy());
}
private enum HitObjectType
{
Circle,
Slider,
Spinner
}
}
}

View File

@ -0,0 +1,130 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Tests
{
[Ignore("getting CI working")]
public class TestCaseSlider : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(DrawableSlider) };
private readonly Container content;
protected override Container<Drawable> Content => content;
private double speedMultiplier = 2;
private double sliderMultiplier = 2;
private int depthIndex;
public TestCaseSlider()
{
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
AddStep("Single", () => addSingle());
AddStep("Repeated (1)", () => addRepeated(1));
AddStep("Repeated (2)", () => addRepeated(2));
AddStep("Repeated (3)", () => addRepeated(3));
AddStep("Repeated (4)", () => addRepeated(4));
AddStep("Stream", addStream);
AddSliderStep("SpeedMultiplier", 0.01, 10, 2, s => speedMultiplier = s);
AddSliderStep("SliderMultiplier", 0.01, 10, 2, s => sliderMultiplier = s);
}
private void addSingle(double timeOffset = 0, Vector2? positionOffset = null)
{
positionOffset = positionOffset ?? Vector2.Zero;
var slider = new Slider
{
StartTime = Time.Current + 1000 + timeOffset,
Position = new Vector2(-200, 0) + positionOffset.Value,
ControlPoints = new List<Vector2>
{
new Vector2(-200, 0) + positionOffset.Value,
new Vector2(400, 0) + positionOffset.Value,
},
Distance = 400,
};
var cpi = new ControlPointInfo();
cpi.DifficultyPoints.Add(new DifficultyControlPoint { SpeedMultiplier = speedMultiplier });
var difficulty = new BeatmapDifficulty
{
SliderMultiplier = (float)sliderMultiplier,
CircleSize = 0
};
slider.ApplyDefaults(cpi, difficulty);
Add(new DrawableSlider(slider)
{
Anchor = Anchor.Centre,
Depth = depthIndex++
});
}
private void addRepeated(int repeats)
{
// The first run through the slider is considered a repeat
repeats++;
var repeatSamples = new List<List<SampleInfo>>();
for (int i = 0; i < repeats; i++)
repeatSamples.Add(new List<SampleInfo>());
var slider = new Slider
{
StartTime = Time.Current + 1000,
Position = new Vector2(-200, 0),
ControlPoints = new List<Vector2>
{
new Vector2(-200, 0),
new Vector2(400, 0),
},
Distance = 400,
RepeatCount = repeats,
RepeatSamples = repeatSamples
};
var cpi = new ControlPointInfo();
cpi.DifficultyPoints.Add(new DifficultyControlPoint { SpeedMultiplier = speedMultiplier });
var difficulty = new BeatmapDifficulty
{
SliderMultiplier = (float)sliderMultiplier,
CircleSize = 0
};
slider.ApplyDefaults(cpi, difficulty);
Add(new DrawableSlider(slider)
{
Anchor = Anchor.Centre,
Depth = depthIndex++
});
}
private void addStream()
{
Vector2 pos = Vector2.Zero;
for (int i = 0; i <= 1000; i += 100)
{
addSingle(i, pos);
pos += new Vector2(10);
}
}
}
}

View File

@ -0,0 +1,45 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests
{
[Ignore("getting CI working")]
public class TestCaseSpinner : OsuTestCase
{
private readonly Container content;
protected override Container<Drawable> Content => content;
private int depthIndex;
public TestCaseSpinner()
{
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
AddStep("Single", addSingle);
}
private void addSingle()
{
var spinner = new Spinner { StartTime = Time.Current + 1000, EndTime = Time.Current + 4000 };
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = 0 });
var drawable = new DrawableSpinner(spinner)
{
Anchor = Anchor.Centre,
Depth = depthIndex++
};
Add(drawable);
}
}
}

View File

@ -37,8 +37,8 @@
<HintPath>$(SolutionDir)\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00021\lib\net20\OpenTK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
@ -75,6 +75,7 @@
<Compile Include="Objects\Drawables\Pieces\TrianglesPiece.cs" />
<Compile Include="Objects\Drawables\Pieces\SliderBall.cs" />
<Compile Include="Objects\Drawables\Pieces\SliderBody.cs" />
<Compile Include="Objects\ISliderProgress.cs" />
<Compile Include="Objects\RepeatPoint.cs" />
<Compile Include="Objects\SliderTick.cs" />
<Compile Include="OsuDifficulty\OsuDifficultyCalculator.cs" />
@ -86,8 +87,10 @@
<Compile Include="OsuDifficulty\Utils\History.cs" />
<Compile Include="OsuInputManager.cs" />
<Compile Include="Replays\OsuReplayInputHandler.cs" />
<Compile Include="Tests\TestCaseHitObjects.cs" />
<Compile Include="Tests\TestCaseHitCircle.cs" />
<Compile Include="Tests\TestCasePerformancePoints.cs" />
<Compile Include="Tests\TestCaseSlider.cs" />
<Compile Include="Tests\TestCaseSpinner.cs" />
<Compile Include="UI\Cursor\CursorTrail.cs" />
<Compile Include="UI\Cursor\GameplayCursor.cs" />
<Compile Include="UI\OsuSettings.cs" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.8.1" targetFramework="net461" />
<package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" />
<package id="OpenTK" version="3.0.0-git00021" targetFramework="net461" />
</packages>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,8 +3,6 @@
using osu.Game.Rulesets.Objects.Types;
using System;
using System.Linq;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
@ -74,13 +72,7 @@ namespace osu.Game.Rulesets.Taiko.Objects
FirstTick = first,
TickSpacing = tickSpacing,
StartTime = t,
IsStrong = IsStrong,
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
{
Bank = s.Bank,
Name = @"slidertick",
Volume = s.Volume
}))
IsStrong = IsStrong
});
first = false;

View File

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

View File

@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
{
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
{
Frames.Add(new ReplayFrame(tick.StartTime, null, null, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2));
Frames.Add(new ReplayFrame(tick.StartTime, null, null, hitButton ? ReplayButtonState.Right1 : ReplayButtonState.Right2));
hitButton = !hitButton;
}
}

View File

@ -0,0 +1,44 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using NUnit.Framework;
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Taiko.Audio;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests
{
[Ignore("getting CI working")]
public class TestCaseInputDrum : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(InputDrum),
typeof(DrumSampleMapping),
typeof(SampleInfo),
typeof(SampleControlPoint)
};
public TestCaseInputDrum()
{
Add(new TaikoInputManager(new RulesetInfo { ID = 1 })
{
RelativeSizeAxes = Axes.Both,
Child = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(200),
Child = new InputDrum(new ControlPointInfo())
}
});
}
}
}

View File

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

View File

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

View File

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

View File

@ -36,14 +36,15 @@
<HintPath>$(SolutionDir)\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00021\lib\net20\OpenTK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Audio\DrumSampleMapping.cs" />
<Compile Include="Beatmaps\TaikoBeatmapConverter.cs" />
<Compile Include="Judgements\TaikoDrumRollTickJudgement.cs" />
<Compile Include="Judgements\TaikoStrongHitJudgement.cs" />
@ -82,6 +83,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scoring\TaikoScoreProcessor.cs" />
<Compile Include="TaikoInputManager.cs" />
<Compile Include="Tests\TestCaseInputDrum.cs" />
<Compile Include="Tests\TestCasePerformancePoints.cs" />
<Compile Include="Tests\TestCaseTaikoPlayfield.cs" />
<Compile Include="UI\HitTarget.cs" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.8.1" targetFramework="net461" />
<package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" />
<package id="OpenTK" version="3.0.0-git00021" targetFramework="net461" />
</packages>

View File

@ -70,6 +70,7 @@ namespace osu.Game.Tests.Visual
testRemoveAll();
testEmptyTraversal();
testHiding();
}
private void ensureRandomFetchSuccess() =>
@ -295,6 +296,40 @@ namespace osu.Game.Tests.Visual
checkNoSelection();
}
private void testHiding()
{
var hidingSet = createTestBeatmapSet(1);
hidingSet.Beatmaps[1].Hidden = true;
AddStep("Add set with diff 2 hidden", () => carousel.UpdateBeatmapSet(hidingSet));
setSelected(1, 1);
checkVisibleItemCount(true, 2);
advanceSelection(true);
checkSelected(1, 3);
setHidden(3);
checkSelected(1, 1);
setHidden(2, false);
advanceSelection(true);
checkSelected(1, 2);
setHidden(1);
checkSelected(1, 2);
setHidden(2);
checkNoSelection();
void setHidden(int diff, bool hidden = true)
{
AddStep((hidden ? "" : "un") + $"hide diff {diff}", () =>
{
hidingSet.Beatmaps[diff - 1].Hidden = hidden;
carousel.UpdateBeatmapSet(hidingSet);
});
}
}
private BeatmapSetInfo createTestBeatmapSet(int i)
{
return new BeatmapSetInfo

View File

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

View File

@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual
{
AddStep("Show overlay", () => failOverlay.Show());
AddStep("Hover first button", () => failOverlay.Buttons.First().TriggerOnHover(null));
AddStep("Hover first button", () => failOverlay.Buttons.First().TriggerOnMouseMove(null));
AddStep("Hide overlay", () => failOverlay.Hide());
AddAssert("Overlay state is reset", () => !failOverlay.Buttons.Any(b => b.Selected));
@ -162,7 +162,7 @@ namespace osu.Game.Tests.Visual
var secondButton = pauseOverlay.Buttons.Skip(1).First();
AddStep("Down arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down }));
AddStep("Hover second button", () => secondButton.TriggerOnHover(null));
AddStep("Hover second button", () => secondButton.TriggerOnMouseMove(null));
AddAssert("First button not selected", () => !pauseOverlay.Buttons.First().Selected);
AddAssert("Second button selected", () => secondButton.Selected);
@ -178,7 +178,7 @@ namespace osu.Game.Tests.Visual
var secondButton = pauseOverlay.Buttons.Skip(1).First();
AddStep("Hover second button", () => secondButton.TriggerOnHover(null));
AddStep("Hover second button", () => secondButton.TriggerOnMouseMove(null));
AddStep("Up arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Up }));
AddAssert("Second button not selected", () => !secondButton.Selected);
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected);
@ -195,7 +195,7 @@ namespace osu.Game.Tests.Visual
var secondButton = pauseOverlay.Buttons.Skip(1).First();
AddStep("Hover second button", () => secondButton.TriggerOnHover(null));
AddStep("Hover second button", () => secondButton.TriggerOnMouseMove(null));
AddStep("Unhover second button", () => secondButton.TriggerOnHoverLost(null));
AddStep("Down arrow", () => pauseOverlay.TriggerOnKeyDown(null, new KeyDownEventArgs { Key = Key.Down }));
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected); // Initial state condition

View File

@ -1,9 +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 System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
@ -15,6 +18,16 @@ namespace osu.Game.Tests.Visual
private readonly NotificationOverlay manager;
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(NotificationSection),
typeof(SimpleNotification),
typeof(ProgressNotification),
typeof(ProgressCompletionNotification),
typeof(IHasCompletionTarget),
typeof(Notification)
};
public TestCaseNotificationOverlay()
{
progressingNotifications.Clear();
@ -25,15 +38,48 @@ namespace osu.Game.Tests.Visual
Origin = Anchor.TopRight
});
AddStep(@"toggle", manager.ToggleVisibility);
SpriteText displayedCount = new SpriteText();
Content.Add(displayedCount);
void setState(Visibility state) => AddStep(state.ToString(), () => manager.State = state);
void checkProgressingCount(int expected) => AddAssert($"progressing count is {expected}", () => progressingNotifications.Count == expected);
manager.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count}"; };
setState(Visibility.Visible);
AddStep(@"simple #1", sendHelloNotification);
AddStep(@"simple #2", sendAmazingNotification);
AddStep(@"progress #1", sendUploadProgress);
AddStep(@"progress #2", sendDownloadProgress);
AddStep(@"barrage", () => sendBarrage());
checkProgressingCount(2);
setState(Visibility.Hidden);
AddRepeatStep(@"add many simple", sendManyNotifications, 3);
AddWaitStep(5);
checkProgressingCount(0);
AddStep(@"progress #3", sendUploadProgress);
checkProgressingCount(1);
AddAssert("Displayed count is 33", () => manager.UnreadCount.Value == 33);
AddWaitStep(10);
checkProgressingCount(0);
setState(Visibility.Visible);
//AddStep(@"barrage", () => sendBarrage());
}
private void sendBarrage(int remaining = 100)
private void sendBarrage(int remaining = 10)
{
switch (RNG.Next(0, 4))
{
@ -63,7 +109,7 @@ namespace osu.Game.Tests.Visual
if (progressingNotifications.Count(n => n.State == ProgressNotificationState.Active) < 3)
{
var p = progressingNotifications.FirstOrDefault(n => n.IsAlive && n.State == ProgressNotificationState.Queued);
var p = progressingNotifications.FirstOrDefault(n => n.State == ProgressNotificationState.Queued);
if (p != null)
p.State = ProgressNotificationState.Active;
}
@ -71,7 +117,7 @@ namespace osu.Game.Tests.Visual
foreach (var n in progressingNotifications.FindAll(n => n.State == ProgressNotificationState.Active))
{
if (n.Progress < 1)
n.Progress += (float)(Time.Elapsed / 2000) * RNG.NextSingle();
n.Progress += (float)(Time.Elapsed / 400) * RNG.NextSingle();
else
n.State = ProgressNotificationState.Completed;
}
@ -108,5 +154,11 @@ namespace osu.Game.Tests.Visual
{
manager.Post(new SimpleNotification { Text = @"Welcome to osu!. Enjoy your stay!" });
}
private void sendManyNotifications()
{
for (int i = 0; i < 10; i++)
manager.Post(new SimpleNotification { Text = @"Spam incoming!!" });
}
}
}

View File

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

View File

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

View File

@ -0,0 +1,39 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays.Toolbar;
namespace osu.Game.Tests.Visual
{
public class TestCaseToolbar : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ToolbarButton),
typeof(ToolbarModeSelector),
typeof(ToolbarModeButton),
typeof(ToolbarNotificationButton),
};
public TestCaseToolbar()
{
var toolbar = new Toolbar { State = Visibility.Visible };
Add(toolbar);
var notificationButton = toolbar.Children.OfType<FillFlowContainer>().Last().Children.OfType<ToolbarNotificationButton>().First();
void setNotifications(int count) => AddStep($"set notification count to {count}", () => notificationButton.NotificationCount.Value = count);
setNotifications(1);
setNotifications(2);
setNotifications(3);
setNotifications(0);
setNotifications(144);
}
}
}

View File

@ -13,6 +13,8 @@ namespace osu.Game.Tests.Visual
{
public class TestCaseUserProfile : OsuTestCase
{
private readonly TestUserProfileOverlay profile;
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ProfileHeader),
@ -23,8 +25,12 @@ namespace osu.Game.Tests.Visual
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
{
@ -48,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",
@ -55,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",
@ -62,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;
}
}
}

View File

@ -37,8 +37,8 @@
<HintPath>$(SolutionDir)\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
<Reference Include="OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00021\lib\net20\OpenTK.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
@ -134,6 +134,7 @@
<Compile Include="Visual\TestCaseOsuGame.cs" />
<Compile Include="Visual\TestCasePlaybackControl.cs" />
<Compile Include="Visual\TestCasePlaySongSelect.cs" />
<Compile Include="Visual\TestCasePopupDialog.cs" />
<Compile Include="Visual\TestCaseRankGraph.cs" />
<Compile Include="Visual\TestCaseReplay.cs" />
<Compile Include="Visual\TestCaseReplaySettingsOverlay.cs" />
@ -148,6 +149,7 @@
<Compile Include="Visual\TestCaseStoryboard.cs" />
<Compile Include="Visual\TestCaseTabControl.cs" />
<Compile Include="Visual\TestCaseTextAwesome.cs" />
<Compile Include="Visual\TestCaseToolbar.cs" />
<Compile Include="Visual\TestCaseTwoLayerButton.cs" />
<Compile Include="Visual\TestCaseUserPanel.cs" />
<Compile Include="Visual\TestCaseUserProfile.cs" />

View File

@ -6,6 +6,6 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/maste
<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="OpenTK" version="3.0.0-git00021" targetFramework="net461" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
</packages>

View File

@ -14,10 +14,20 @@ namespace osu.Game.Audio
public const string HIT_NORMAL = @"hitnormal";
public const string HIT_CLAP = @"hitclap";
public SampleChannel GetChannel(SampleManager manager)
public SampleChannel GetChannel(SampleManager manager, string resourceNamespace = null)
{
var channel = manager.Get($"Gameplay/{Bank}-{Name}");
channel.Volume.Value = Volume / 100.0;
SampleChannel channel = null;
if (resourceNamespace != null)
channel = manager.Get($"Gameplay/{resourceNamespace}/{Bank}-{Name}");
// try without namespace as a fallback.
if (channel == null)
channel = manager.Get($"Gameplay/{Bank}-{Name}");
if (channel != null)
channel.Volume.Value = Volume / 100.0;
return channel;
}

View File

@ -1,18 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
namespace osu.Game.Audio
{
public class SampleInfoList : List<SampleInfo>
{
public SampleInfoList()
{
}
public SampleInfoList(IEnumerable<SampleInfo> elements) : base(elements)
{
}
}
}

View File

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

View File

@ -17,7 +17,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <summary>
/// The default sample volume at this control point.
/// </summary>
public int SampleVolume;
public int SampleVolume = 100;
/// <summary>
/// Create a SampleInfo based on the sample settings in this control point.

View File

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

View File

@ -16,6 +16,7 @@ using osu.Game.Screens;
using osu.Game.Screens.Menu;
using OpenTK;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Input.Bindings;
using osu.Framework.Platform;
@ -64,6 +65,8 @@ namespace osu.Game
public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight;
public readonly BindableBool ShowOverlays = new BindableBool();
private OsuScreen screenStack;
private VolumeControl volume;
@ -220,15 +223,7 @@ namespace osu.Game
Depth = -6,
}, overlayContent.Add);
Logger.NewEntry += entry =>
{
if (entry.Level < LogLevel.Important) return;
notifications.Post(new SimpleNotification
{
Text = $@"{entry.Level}: {entry.Message}"
});
};
forwardLoggedErrorsToNotifications();
dependencies.Cache(settings);
dependencies.Cache(social);
@ -272,7 +267,7 @@ namespace osu.Game
};
}
Action<Visibility> stateChanged = delegate
void updateScreenOffset()
{
float offset = 0;
@ -281,15 +276,60 @@ namespace osu.Game
if (notifications.State == Visibility.Visible)
offset -= ToolbarButton.WIDTH / 2;
intro.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
screenStack.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
}
settings.StateChanged += _ => updateScreenOffset();
notifications.StateChanged += _ => updateScreenOffset();
notifications.Enabled.BindTo(ShowOverlays);
ShowOverlays.ValueChanged += visible =>
{
//central game screen change logic.
if (!visible)
{
hideAllOverlays();
musicController.State = Visibility.Hidden;
Toolbar.State = Visibility.Hidden;
}
else
Toolbar.State = Visibility.Visible;
};
settings.StateChanged += stateChanged;
notifications.StateChanged += stateChanged;
Cursor.State = Visibility.Hidden;
}
private void forwardLoggedErrorsToNotifications()
{
int recentErrorCount = 0;
const double debounce = 5000;
Logger.NewEntry += entry =>
{
if (entry.Level < LogLevel.Error || entry.Target == null) return;
if (recentErrorCount < 2)
{
notifications.Post(new SimpleNotification
{
Icon = FontAwesome.fa_bomb,
Text = (recentErrorCount == 0 ? entry.Message : "Subsequent errors occurred and have been logged.") + "\nClick to view log files.",
Activated = () =>
{
Host.Storage.GetStorageForDirectory("logs").OpenInNativeExplorer();
return true;
}
});
}
Interlocked.Increment(ref recentErrorCount);
Scheduler.AddDelayed(() => Interlocked.Decrement(ref recentErrorCount), debounce);
};
}
private Task asyncLoadStream;
private void loadComponentSingleFile<T>(T d, Action<T> add)
@ -338,8 +378,6 @@ namespace osu.Game
public bool OnReleased(GlobalAction action) => false;
public event Action<Screen> ScreenChanged;
private Container mainContent;
private Container overlayContent;
@ -357,29 +395,6 @@ namespace osu.Game
notifications.State = Visibility.Hidden;
}
private void screenChanged(Screen newScreen)
{
currentScreen = newScreen as OsuScreen;
if (currentScreen == null)
{
Exit();
return;
}
//central game screen change logic.
if (!currentScreen.ShowOverlays)
{
hideAllOverlays();
musicController.State = Visibility.Hidden;
Toolbar.State = Visibility.Hidden;
}
else
Toolbar.State = Visibility.Visible;
ScreenChanged?.Invoke(newScreen);
}
protected override bool OnExiting()
{
if (screenStack.ChildScreen == null) return false;
@ -425,15 +440,18 @@ namespace osu.Game
private void screenAdded(Screen newScreen)
{
currentScreen = (OsuScreen)newScreen;
newScreen.ModePushed += screenAdded;
newScreen.Exited += screenRemoved;
screenChanged(newScreen);
}
private void screenRemoved(Screen newScreen)
{
screenChanged(newScreen);
currentScreen = (OsuScreen)newScreen;
if (newScreen == null)
Exit();
}
}
}

View File

@ -177,8 +177,7 @@ namespace osu.Game
}
catch (MigrationFailedException e)
{
Logger.Log((e.InnerException ?? e).ToString(), LoggingTarget.Database, LogLevel.Error);
Logger.Log("Migration failed! We'll be starting with a fresh database.", LoggingTarget.Database, LogLevel.Error);
Logger.Error(e.InnerException ?? e, "Migration failed! We'll be starting with a fresh database.", LoggingTarget.Database);
// if we failed, let's delete the database and start fresh.
// todo: we probably want a better (non-destructive) migrations/recovery process at a later point than this.

View File

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

View File

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

View File

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

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -11,6 +10,9 @@ using OpenTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers;
using System;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Threading;
namespace osu.Game.Overlays
{
@ -20,6 +22,11 @@ namespace osu.Game.Overlays
public const float TRANSITION_LENGTH = 600;
/// <summary>
/// Whether posted notifications should be processed.
/// </summary>
public readonly BindableBool Enabled = new BindableBool(true);
private FlowContainer<NotificationSection> sections;
/// <summary>
@ -27,6 +34,27 @@ namespace osu.Game.Overlays
/// </summary>
public Func<float> GetToolbarHeight;
public NotificationOverlay()
{
ScheduledDelegate notificationsEnabler = null;
Enabled.ValueChanged += v =>
{
if (!IsLoaded)
{
processingPosts = v;
return;
}
notificationsEnabler?.Cancel();
if (v)
// we want a slight delay before toggling notifications on to avoid the user becoming overwhelmed.
notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, 1000);
else
processingPosts = false;
};
}
[BackgroundDependencyLoader]
private void load()
{
@ -75,33 +103,51 @@ namespace osu.Game.Overlays
};
}
private int totalCount => sections.Select(c => c.DisplayedCount).Sum();
private int unreadCount => sections.Select(c => c.UnreadCount).Sum();
public readonly BindableInt UnreadCount = new BindableInt();
private int runningDepth;
private void notificationClosed()
{
// hide ourselves if all notifications have been dismissed.
if (sections.Select(c => c.DisplayedCount).Sum() == 0)
State = Visibility.Hidden;
}
public void Post(Notification notification)
{
Schedule(() =>
{
State = Visibility.Visible;
++runningDepth;
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
notification.Closed += notificationClosed;
var hasCompletionTarget = notification as IHasCompletionTarget;
if (hasCompletionTarget != null)
hasCompletionTarget.CompletionTarget = Post;
var ourType = notification.GetType();
sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification);
// hide ourselves if all notifications have been dismissed.
if (totalCount == 0)
State = Visibility.Hidden;
});
updateCounts();
}
private readonly Scheduler postScheduler = new Scheduler();
private bool processingPosts = true;
public void Post(Notification notification) => postScheduler.Add(() =>
{
++runningDepth;
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
notification.Closed += notificationClosed;
var hasCompletionTarget = notification as IHasCompletionTarget;
if (hasCompletionTarget != null)
hasCompletionTarget.CompletionTarget = Post;
var ourType = notification.GetType();
sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification);
updateCounts();
});
protected override void Update()
{
base.Update();
if (processingPosts)
postScheduler.Update();
}
protected override void PopIn()
@ -122,9 +168,16 @@ namespace osu.Game.Overlays
this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
}
private void updateCounts()
{
UnreadCount.Value = unreadCount;
}
private void markAllRead()
{
sections.Children.ForEach(s => s.MarkAllRead());
updateCounts();
}
protected override void UpdateAfterChildren()

View File

@ -91,7 +91,6 @@ namespace osu.Game.Overlays.Notifications
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding
{
Top = 5,
Left = 45,
Right = 30
},
@ -261,4 +260,4 @@ namespace osu.Game.Overlays.Notifications
}
}
}
}
}

View File

@ -15,7 +15,7 @@ using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.Notifications
{
public class NotificationSection : FillFlowContainer
public class NotificationSection : AlwaysUpdateFillFlowContainer<Drawable>
{
private OsuSpriteText titleText;
private OsuSpriteText countText;
@ -26,11 +26,14 @@ namespace osu.Game.Overlays.Notifications
public int DisplayedCount => notifications.Count(n => !n.WasClosed);
public int UnreadCount => notifications.Count(n => !n.WasClosed && !n.Read);
public void Add(Notification notification) => notifications.Add(notification);
public IEnumerable<Type> AcceptTypes;
private string clearText;
public string ClearText
{
get { return clearText; }
@ -108,7 +111,7 @@ namespace osu.Game.Overlays.Notifications
},
},
},
notifications = new FillFlowContainer<Notification>
notifications = new AlwaysUpdateFillFlowContainer<Notification>
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
@ -157,4 +160,13 @@ namespace osu.Game.Overlays.Notifications
notifications?.Children.ForEach(n => n.Read = true);
}
}
}
public class AlwaysUpdateFillFlowContainer<T> : FillFlowContainer<T>
where T : Drawable
{
// this is required to ensure correct layout and scheduling on children.
// the layout portion of this is being tracked as a framework issue (https://github.com/ppy/osu-framework/issues/1297).
protected override bool RequiresChildrenUpdate => true;
}
}

View File

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

View File

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

View File

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

View File

@ -29,7 +29,8 @@ namespace osu.Game.Overlays.Profile
private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText;
private readonly RankGraph rankGraph;
private readonly Container coverContainer, supporterTag;
public readonly SupporterIcon SupporterTag;
private readonly Container coverContainer;
private readonly Sprite levelBadge;
private readonly SpriteText levelText;
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
@ -94,32 +95,13 @@ namespace osu.Game.Overlays.Profile
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
supporterTag = new CircularContainer
SupporterTag = new SupporterIcon
{
Alpha = 0,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Y = -75,
Size = new Vector2(25, 25),
Masking = true,
BorderThickness = 3,
BorderColour = Color4.White,
Alpha = 0,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
},
new SpriteIcon
{
Icon = FontAwesome.fa_heart,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(12),
}
}
Size = new Vector2(25, 25)
},
new LinkFlowContainer.ProfileLink(user)
{
@ -328,7 +310,8 @@ namespace osu.Game.Overlays.Profile
Depth = float.MaxValue,
}, coverContainer.Add);
if (user.IsSupporter) supporterTag.Show();
if (user.IsSupporter)
SupporterTag.Show();
if (!string.IsNullOrEmpty(user.Colour))
{
@ -473,7 +456,7 @@ namespace osu.Game.Overlays.Profile
Width = width,
Height = 26
});
Add(numberText = new SpriteText
Add(numberText = new OsuSpriteText
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Edit
}
catch (Exception e)
{
Logger.Log($"Could not load this beatmap sucessfully ({e})!", LoggingTarget.Runtime, LogLevel.Error);
Logger.Error(e, "Could not load beatmap sucessfully!");
return;
}

View File

@ -72,6 +72,10 @@ namespace osu.Game.Rulesets.Objects.Drawables
public IReadOnlyList<Judgement> Judgements => judgements;
protected List<SampleChannel> Samples = new List<SampleChannel>();
protected virtual IEnumerable<SampleInfo> GetSamples() => HitObject.Samples;
// Todo: Rulesets should be overriding the resources instead, but we need to figure out where/when to apply overrides first
protected virtual string SampleNamespace => null;
public readonly Bindable<ArmedState> State = new Bindable<ArmedState>();
@ -84,12 +88,14 @@ namespace osu.Game.Rulesets.Objects.Drawables
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
if (HitObject.Samples != null)
var samples = GetSamples();
if (samples.Any())
{
if (HitObject.SampleControlPoint == null)
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)} must always have an attached {nameof(HitObject.SampleControlPoint)}.");
throw new ArgumentNullException(nameof(HitObject.SampleControlPoint), $"{nameof(HitObject)}s must always have an attached {nameof(HitObject.SampleControlPoint)}."
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
foreach (SampleInfo s in HitObject.Samples)
foreach (SampleInfo s in samples)
{
SampleInfo localSampleInfo = new SampleInfo
{
@ -98,7 +104,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume
};
SampleChannel channel = localSampleInfo.GetChannel(audio.Sample);
SampleChannel channel = localSampleInfo.GetChannel(audio.Sample, SampleNamespace);
if (channel == null)
continue;
@ -174,7 +180,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
judgementOccurred = false;
if (AllJudged || State != ArmedState.Idle)
if (AllJudged)
return false;
if (NestedHitObjects != null)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -38,6 +38,13 @@ namespace osu.Game.Rulesets
/// <returns>A ruleset, if available, else null.</returns>
public RulesetInfo GetRuleset(int id) => AvailableRulesets.FirstOrDefault(r => r.ID == id);
/// <summary>
/// Retrieve a ruleset using a known short name.
/// </summary>
/// <param name="shortName">The ruleset's short name.</param>
/// <returns>A ruleset, if available, else null.</returns>
public RulesetInfo GetRuleset(string shortName) => AvailableRulesets.FirstOrDefault(r => r.ShortName == shortName);
/// <summary>
/// All available rulesets.
/// </summary>

View File

@ -47,6 +47,8 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
if (Beatmap.Value == null)
return;
if (Beatmap.Value.Track.Length == double.PositiveInfinity) return;
float markerPos = MathHelper.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
seekTo(markerPos / DrawWidth * Beatmap.Value.Track.Length);
}

View File

@ -24,7 +24,7 @@ namespace osu.Game.Screens.Edit
{
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
public override bool ShowOverlays => false;
public override bool ShowOverlaysOnEnter => false;
private readonly Box bottomBackground;
private readonly Container screenContainer;

View File

@ -17,7 +17,7 @@ namespace osu.Game.Screens
{
private bool showDisclaimer;
public override bool ShowOverlays => false;
public override bool ShowOverlaysOnEnter => false;
public Loader()
{

View File

@ -11,12 +11,12 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Overlays.Toolbar;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio;
using osu.Framework.Configuration;
using osu.Framework.Threading;
namespace osu.Game.Screens.Menu
@ -25,6 +25,8 @@ namespace osu.Game.Screens.Menu
{
public event Action<MenuState> StateChanged;
private readonly BindableBool showOverlays = new BindableBool();
public Action OnEdit;
public Action OnExit;
public Action OnDirect;
@ -34,8 +36,6 @@ namespace osu.Game.Screens.Menu
public Action OnChart;
public Action OnTest;
private Toolbar toolbar;
private readonly FlowContainerWithOrigin buttonFlow;
//todo: make these non-internal somehow.
@ -131,9 +131,9 @@ namespace osu.Game.Screens.Menu
}
[BackgroundDependencyLoader(true)]
private void load(AudioManager audio, OsuGame game = null)
private void load(AudioManager audio, OsuGame game)
{
toolbar = game?.Toolbar;
if (game != null) showOverlays.BindTo(game.ShowOverlays);
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
}
@ -300,7 +300,7 @@ namespace osu.Game.Screens.Menu
logoDelayedAction = Scheduler.AddDelayed(() =>
{
toolbar?.Hide();
showOverlays.Value = false;
logo.ClearTransforms(targetMember: nameof(Position));
logo.RelativePositionAxes = Axes.Both;
@ -329,7 +329,7 @@ namespace osu.Game.Screens.Menu
logoTracking = true;
logo.Impact();
toolbar?.Show();
showOverlays.Value = true;
}, 200);
break;
default:

View File

@ -18,7 +18,7 @@ namespace osu.Game.Screens.Menu
private readonly SpriteIcon icon;
private Color4 iconColour;
public override bool ShowOverlays => false;
public override bool ShowOverlaysOnEnter => false;
public override bool HasLocalCursorDisplayed => true;

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Menu
public override bool HasLocalCursorDisplayed => true;
public override bool ShowOverlays => false;
public override bool ShowOverlaysOnEnter => false;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();

View File

@ -24,7 +24,7 @@ namespace osu.Game.Screens.Menu
{
private readonly ButtonSystem buttons;
public override bool ShowOverlays => buttons.State != MenuState.Initial;
public override bool ShowOverlaysOnEnter => buttons.State != MenuState.Initial;
private readonly BackgroundScreenDefault background;
private Screen songSelect;

View File

@ -28,7 +28,12 @@ namespace osu.Game.Screens
/// </summary>
protected virtual BackgroundScreen CreateBackground() => null;
public virtual bool ShowOverlays => true;
protected BindableBool ShowOverlays = new BindableBool();
/// <summary>
/// Whether overlays should be shown when this screen is entered or resumed.
/// </summary>
public virtual bool ShowOverlaysOnEnter => true;
protected new OsuGameBase Game => base.Game as OsuGameBase;
@ -70,7 +75,10 @@ namespace osu.Game.Screens
}
if (osuGame != null)
{
Ruleset.BindTo(osuGame.Ruleset);
ShowOverlays.BindTo(osuGame.ShowOverlays);
}
sampleExit = audio.Sample.Get(@"UI/screen-back");
}
@ -94,6 +102,8 @@ namespace osu.Game.Screens
base.OnResuming(last);
logo.AppendAnimatingAction(() => LogoArriving(logo, true), true);
sampleExit?.Play();
ShowOverlays.Value = ShowOverlaysOnEnter;
}
protected override void OnSuspending(Screen next)
@ -139,6 +149,8 @@ namespace osu.Game.Screens
logo.AppendAnimatingAction(() => LogoArriving(logo, false), true);
base.OnEntering(last);
ShowOverlays.Value = ShowOverlaysOnEnter;
}
protected override bool OnExiting(Screen next)

View File

@ -263,6 +263,14 @@ namespace osu.Game.Screens.Play
private class Button : DialogButton
{
protected override bool OnHover(InputState state) => true;
protected override bool OnMouseMove(InputState state)
{
Selected.Value = true;
return base.OnMouseMove(state);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat || args.Key != Key.Enter || !Selected)

View File

@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play
{
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
public override bool ShowOverlays => false;
public override bool ShowOverlaysOnEnter => false;
public override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && RulesetContainer.ProvidingUserCursor;
@ -46,6 +46,8 @@ namespace osu.Game.Screens.Play
public bool HasFailed { get; private set; }
public bool AllowPause { get; set; } = true;
public bool AllowLeadIn { get; set; } = true;
public bool AllowResults { get; set; } = true;
public int RestartCount;
@ -125,7 +127,7 @@ namespace osu.Game.Screens.Play
}
catch (Exception e)
{
Logger.Log($"Could not load this beatmap sucessfully ({e})!", LoggingTarget.Runtime, LogLevel.Error);
Logger.Error(e, "Could not load beatmap sucessfully!");
//couldn't load, hard abort!
Exit();
@ -136,7 +138,10 @@ namespace osu.Game.Screens.Play
decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
var firstObjectTime = RulesetContainer.Objects.First().StartTime;
decoupledClock.Seek(Math.Min(0, firstObjectTime - Math.Max(beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, beatmap.BeatmapInfo.AudioLeadIn)));
decoupledClock.Seek(AllowLeadIn
? Math.Min(0, firstObjectTime - Math.Max(beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, beatmap.BeatmapInfo.AudioLeadIn))
: firstObjectTime);
decoupledClock.ProcessFrame();
offsetClock = new FramedOffsetClock(decoupledClock);
@ -273,6 +278,8 @@ namespace osu.Game.Screens.Play
ValidForResume = false;
if (!AllowResults) return;
using (BeginDelayedSequence(1000))
{
onCompletionEvent = Schedule(delegate

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.Play
private BeatmapMetadataDisplay info;
private bool showOverlays = true;
public override bool ShowOverlays => showOverlays;
public override bool ShowOverlaysOnEnter => showOverlays;
public override bool AllowBeatmapRulesetChange => false;
@ -250,7 +250,7 @@ namespace osu.Game.Screens.Play
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
},
new MetadataLine("Mapper", metadata.Author.Username)
new MetadataLine("Mapper", metadata.AuthorString)
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,

View File

@ -17,6 +17,7 @@ using OpenTK.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Ranking
{
@ -183,7 +184,7 @@ namespace osu.Game.Screens.Ranking
Height = 50,
Margin = new MarginPadding { Bottom = 110 },
},
new SpriteText
new OsuSpriteText
{
Text = $"{score.MaxCombo}x",
TextSize = 40,
@ -194,7 +195,7 @@ namespace osu.Game.Screens.Ranking
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomCentre,
},
new SpriteText
new OsuSpriteText
{
Text = "max combo",
TextSize = 20,
@ -204,7 +205,7 @@ namespace osu.Game.Screens.Ranking
Anchor = Anchor.CentreLeft,
Origin = Anchor.TopCentre,
},
new SpriteText
new OsuSpriteText
{
Text = $"{score.Accuracy:P2}",
TextSize = 40,
@ -215,7 +216,7 @@ namespace osu.Game.Screens.Ranking
Anchor = Anchor.CentreLeft,
Origin = Anchor.BottomCentre,
},
new SpriteText
new OsuSpriteText
{
Text = "accuracy",
TextSize = 20,

View File

@ -201,14 +201,14 @@ namespace osu.Game.Screens.Ranking
{
Children = new Drawable[]
{
new SpriteText {
new OsuSpriteText {
Text = statistic.Value.ToString().PadLeft(4, '0'),
Colour = colours.Gray7,
TextSize = 30,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
new SpriteText {
new OsuSpriteText {
Text = statistic.Key,
Colour = colours.Gray7,
Font = @"Exo2.0-Bold",
@ -324,7 +324,14 @@ namespace osu.Game.Screens.Ranking
title.Colour = artist.Colour = colours.BlueDarker;
versionMapper.Colour = colours.Gray8;
versionMapper.Text = $"{beatmap.Version} - mapped by {beatmap.Metadata.Author.Username}";
var creator = beatmap.Metadata.Author?.Username;
if (!string.IsNullOrEmpty(creator)) {
versionMapper.Text = $"mapped by {creator}";
if (!string.IsNullOrEmpty(beatmap.Version))
versionMapper.Text = $"{beatmap.Version} - " + versionMapper.Text;
}
title.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title);
artist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist);
}

View File

@ -53,6 +53,11 @@ namespace osu.Game.Screens.Select
public override bool HandleInput => AllowSelection;
/// <summary>
/// Used to avoid firing null selections before the initial beatmaps have been loaded via <see cref="BeatmapSets"/>.
/// </summary>
private bool initialLoadComplete;
private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>();
public IEnumerable<BeatmapSetInfo> BeatmapSets
@ -75,7 +80,12 @@ namespace osu.Game.Screens.Select
scrollableContent.Clear(false);
itemsCache.Invalidate();
scrollPositionCache.Invalidate();
BeatmapSetsChanged?.Invoke();
Schedule(() =>
{
BeatmapSetsChanged?.Invoke();
initialLoadComplete = true;
});
}));
}
}
@ -142,7 +152,6 @@ namespace osu.Game.Screens.Select
if (newSet == null)
{
itemsCache.Invalidate();
SelectNext();
return;
}
@ -155,6 +164,7 @@ namespace osu.Game.Screens.Select
select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == selectedBeatmap?.Beatmap.ID) ?? newSet);
itemsCache.Invalidate();
Schedule(() => BeatmapSetsChanged?.Invoke());
});
}
@ -184,7 +194,14 @@ namespace osu.Game.Screens.Select
if (!Items.Any())
return;
int originalIndex = Items.IndexOf(selectedBeatmap?.Drawables.First());
DrawableCarouselItem drawable = null;
if (selectedBeatmap != null && (drawable = selectedBeatmap.Drawables.FirstOrDefault()) == null)
// if the selected beatmap isn't present yet, we can't correctly change selection.
// we can fix this by changing this method to not reference drawables / Items in the first place.
return;
int originalIndex = Items.IndexOf(drawable);
int currentIndex = originalIndex;
// local function to increment the index in the required direction, wrapping over extremities.
@ -512,7 +529,7 @@ namespace osu.Game.Screens.Select
currentY += DrawHeight / 2;
scrollableContent.Height = currentY;
if (selectedBeatmapSet != null && selectedBeatmapSet.State.Value != CarouselItemState.Selected)
if (initialLoadComplete && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
{
selectedBeatmapSet = null;
SelectionChanged?.Invoke(null);

View File

@ -17,6 +17,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Screens.Select.Details;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
namespace osu.Game.Screens.Select
{
@ -334,7 +335,7 @@ namespace osu.Game.Screens.Select
TextSize = 14,
},
},
textFlow = new TextFlowContainer
textFlow = new OsuTextFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@ -359,7 +360,7 @@ namespace osu.Game.Screens.Select
private void setTextAsync(string text)
{
LoadComponentAsync(new TextFlowContainer(s => s.TextSize = 14)
LoadComponentAsync(new OsuTextFlowContainer(s => s.TextSize = 14)
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,

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