mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:43:21 +08:00
Merge remote-tracking branch 'upstream/master' into hide-useless-beatmap-info
This commit is contained in:
commit
3182c22c7d
@ -1 +1 @@
|
||||
Subproject commit f4fde31f8c09305d2130064da2f7bae995be8286
|
||||
Subproject commit 46d4704b0a3f140fa8ad10ca0b1553b67d8385ab
|
@ -37,9 +37,9 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
/// </summary>
|
||||
public CatchHitObject HyperDashTarget;
|
||||
|
||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
Scale = 1.0f - 0.7f * (difficulty.CircleSize - 5) / 5;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
@ -25,7 +26,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||
RelativeChildSize = new Vector2(1, (float)HitObject.Duration)
|
||||
};
|
||||
|
||||
foreach (CatchHitObject tick in s.Ticks)
|
||||
foreach (CatchHitObject tick in s.NestedHitObjects.OfType<CatchHitObject>())
|
||||
{
|
||||
TinyDroplet tiny = tick as TinyDroplet;
|
||||
if (tiny != null)
|
||||
|
@ -11,7 +11,6 @@ using osu.Game.Rulesets.Catch.UI;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using OpenTK;
|
||||
using osu.Framework.Lists;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects
|
||||
{
|
||||
@ -29,9 +28,9 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
public double Velocity;
|
||||
public double TickDistance;
|
||||
|
||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
|
||||
@ -42,92 +41,94 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
TickDistance = scoringDistance / difficulty.SliderTickRate;
|
||||
}
|
||||
|
||||
public IEnumerable<CatchHitObject> Ticks
|
||||
protected override void CreateNestedHitObjects()
|
||||
{
|
||||
get
|
||||
base.CreateNestedHitObjects();
|
||||
|
||||
createTicks();
|
||||
}
|
||||
|
||||
private void createTicks()
|
||||
{
|
||||
if (TickDistance == 0)
|
||||
return;
|
||||
|
||||
var length = Curve.Distance;
|
||||
var tickDistance = Math.Min(TickDistance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
var minDistanceFromEnd = Velocity * 0.01;
|
||||
|
||||
AddNested(new Fruit
|
||||
{
|
||||
SortedList<CatchHitObject> ticks = new SortedList<CatchHitObject>((a, b) => a.StartTime.CompareTo(b.StartTime));
|
||||
Samples = Samples,
|
||||
ComboColour = ComboColour,
|
||||
StartTime = StartTime,
|
||||
X = X
|
||||
});
|
||||
|
||||
if (TickDistance == 0)
|
||||
return ticks;
|
||||
for (var repeat = 0; repeat < RepeatCount; repeat++)
|
||||
{
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var reversed = repeat % 2 == 1;
|
||||
|
||||
var length = Curve.Distance;
|
||||
var tickDistance = Math.Min(TickDistance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
var minDistanceFromEnd = Velocity * 0.01;
|
||||
|
||||
ticks.Add(new Fruit
|
||||
for (var d = tickDistance; d <= length; d += tickDistance)
|
||||
{
|
||||
Samples = Samples,
|
||||
ComboColour = ComboColour,
|
||||
StartTime = StartTime,
|
||||
X = X
|
||||
});
|
||||
if (d > length - minDistanceFromEnd)
|
||||
break;
|
||||
|
||||
for (var repeat = 0; repeat < RepeatCount; repeat++)
|
||||
{
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var reversed = repeat % 2 == 1;
|
||||
var timeProgress = d / length;
|
||||
var distanceProgress = reversed ? 1 - timeProgress : timeProgress;
|
||||
|
||||
for (var d = tickDistance; d <= length; d += tickDistance)
|
||||
var lastTickTime = repeatStartTime + timeProgress * repeatDuration;
|
||||
AddNested(new Droplet
|
||||
{
|
||||
if (d > length - minDistanceFromEnd)
|
||||
break;
|
||||
|
||||
var timeProgress = d / length;
|
||||
var distanceProgress = reversed ? 1 - timeProgress : timeProgress;
|
||||
|
||||
var lastTickTime = repeatStartTime + timeProgress * repeatDuration;
|
||||
ticks.Add(new Droplet
|
||||
{
|
||||
StartTime = lastTickTime,
|
||||
ComboColour = ComboColour,
|
||||
X = Curve.PositionAt(distanceProgress).X / CatchPlayfield.BASE_WIDTH,
|
||||
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
double tinyTickInterval = tickDistance / length * repeatDuration;
|
||||
while (tinyTickInterval > 100)
|
||||
tinyTickInterval /= 2;
|
||||
|
||||
for (double t = 0; t < repeatDuration; t += tinyTickInterval)
|
||||
{
|
||||
double progress = reversed ? 1 - t / repeatDuration : t / repeatDuration;
|
||||
|
||||
ticks.Add(new TinyDroplet
|
||||
{
|
||||
StartTime = repeatStartTime + t,
|
||||
ComboColour = ComboColour,
|
||||
X = Curve.PositionAt(progress).X / CatchPlayfield.BASE_WIDTH,
|
||||
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
ticks.Add(new Fruit
|
||||
{
|
||||
Samples = Samples,
|
||||
StartTime = lastTickTime,
|
||||
ComboColour = ComboColour,
|
||||
StartTime = repeatStartTime + repeatDuration,
|
||||
X = Curve.PositionAt(reversed ? 0 : 1).X / CatchPlayfield.BASE_WIDTH
|
||||
X = Curve.PositionAt(distanceProgress).X / CatchPlayfield.BASE_WIDTH,
|
||||
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
return ticks;
|
||||
double tinyTickInterval = tickDistance / length * repeatDuration;
|
||||
while (tinyTickInterval > 100)
|
||||
tinyTickInterval /= 2;
|
||||
|
||||
for (double t = 0; t < repeatDuration; t += tinyTickInterval)
|
||||
{
|
||||
double progress = reversed ? 1 - t / repeatDuration : t / repeatDuration;
|
||||
|
||||
AddNested(new TinyDroplet
|
||||
{
|
||||
StartTime = repeatStartTime + t,
|
||||
ComboColour = ComboColour,
|
||||
X = Curve.PositionAt(progress).X / CatchPlayfield.BASE_WIDTH,
|
||||
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
});
|
||||
}
|
||||
|
||||
AddNested(new Fruit
|
||||
{
|
||||
Samples = Samples,
|
||||
ComboColour = ComboColour,
|
||||
StartTime = repeatStartTime + repeatDuration,
|
||||
X = Curve.PositionAt(reversed ? 0 : 1).X / CatchPlayfield.BASE_WIDTH
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity;
|
||||
|
||||
public float EndX => Curve.PositionAt(ProgressAt(1)).X / CatchPlayfield.BASE_WIDTH;
|
||||
@ -146,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
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Judgements;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
@ -28,7 +29,7 @@ namespace osu.Game.Rulesets.Catch.Scoring
|
||||
AddJudgement(new CatchJudgement { Result = HitResult.Perfect });
|
||||
AddJudgement(new CatchJudgement { Result = HitResult.Perfect });
|
||||
|
||||
foreach (var unused in stream.Ticks)
|
||||
foreach (var unused in stream.NestedHitObjects.OfType<CatchHitObject>())
|
||||
AddJudgement(new CatchJudgement { Result = HitResult.Perfect });
|
||||
|
||||
continue;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
@ -76,10 +77,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
Duration = endTime - HitObject.StartTime
|
||||
};
|
||||
|
||||
hold.Head.Samples.Add(new SampleInfo
|
||||
{
|
||||
Name = SampleInfo.HIT_NORMAL
|
||||
});
|
||||
if (hold.Head.Samples == null)
|
||||
hold.Head.Samples = new List<SampleInfo>();
|
||||
|
||||
hold.Head.Samples.Add(new SampleInfo { Name = SampleInfo.HIT_NORMAL });
|
||||
|
||||
hold.Tail.Samples = HitObject.Samples;
|
||||
|
||||
|
@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var tick in HitObject.Ticks)
|
||||
foreach (var tick in HitObject.NestedHitObjects.OfType<HoldNoteTick>())
|
||||
{
|
||||
var drawableTick = new DrawableHoldNoteTick(tick)
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
@ -63,9 +62,9 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
/// </summary>
|
||||
private double tickSpacing = 50;
|
||||
|
||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
|
||||
@ -74,29 +73,27 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
Tail.ApplyDefaults(controlPointInfo, difficulty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The scoring scoring ticks of the hold note.
|
||||
/// </summary>
|
||||
public IEnumerable<HoldNoteTick> Ticks => ticks ?? (ticks = createTicks());
|
||||
private List<HoldNoteTick> ticks;
|
||||
|
||||
private List<HoldNoteTick> createTicks()
|
||||
protected override void CreateNestedHitObjects()
|
||||
{
|
||||
var ret = new List<HoldNoteTick>();
|
||||
base.CreateNestedHitObjects();
|
||||
|
||||
createTicks();
|
||||
}
|
||||
|
||||
private void createTicks()
|
||||
{
|
||||
if (tickSpacing == 0)
|
||||
return ret;
|
||||
return;
|
||||
|
||||
for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing)
|
||||
{
|
||||
ret.Add(new HoldNoteTick
|
||||
AddNested(new HoldNoteTick
|
||||
{
|
||||
StartTime = t,
|
||||
Column = Column
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -110,9 +107,9 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
/// </summary>
|
||||
private const double release_window_lenience = 1.5;
|
||||
|
||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
HitWindows *= release_window_lenience;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Mania.Judgements;
|
||||
@ -15,11 +16,12 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
/// <summary>
|
||||
/// The key-press hit window for this note.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public HitWindows HitWindows { get; protected set; } = new HitWindows();
|
||||
|
||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
HitWindows = new HitWindows(difficulty.OverallDifficulty);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Mania.Scoring
|
||||
AddJudgement(new ManiaJudgement { Result = HitResult.Perfect });
|
||||
|
||||
// Ticks
|
||||
int tickCount = holdNote.Ticks.Count();
|
||||
int tickCount = holdNote.NestedHitObjects.OfType<HoldNoteTick>().Count();
|
||||
for (int i = 0; i < tickCount; i++)
|
||||
AddJudgement(new HoldNoteTickJudgement { Result = HitResult.Perfect });
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -44,7 +43,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
// Generate the bar lines
|
||||
double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue;
|
||||
|
||||
SortedList<TimingControlPoint> timingPoints = Beatmap.ControlPointInfo.TimingPoints;
|
||||
var timingPoints = Beatmap.ControlPointInfo.TimingPoints;
|
||||
var barLines = new List<DrawableBarLine>();
|
||||
|
||||
for (int i = 0; i < timingPoints.Count; i++)
|
||||
|
@ -40,6 +40,10 @@
|
||||
<HintPath>$(SolutionDir)\packages\OpenTK.3.0.0-git00009\lib\net20\OpenTK.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>$(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
|
@ -9,5 +9,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
public class OsuEditPlayfield : OsuPlayfield
|
||||
{
|
||||
protected override CursorContainer CreateCursor() => null;
|
||||
|
||||
protected override bool ProxyApproachCircles => false;
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
Scale = s.Scale,
|
||||
ComboColour = s.ComboColour,
|
||||
Samples = s.Samples,
|
||||
SampleControlPoint = s.SampleControlPoint
|
||||
})
|
||||
};
|
||||
|
||||
@ -66,7 +67,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
AddNested(initialCircle);
|
||||
|
||||
var repeatDuration = s.Curve.Distance / s.Velocity;
|
||||
foreach (var tick in s.Ticks)
|
||||
foreach (var tick in s.NestedHitObjects.OfType<SliderTick>())
|
||||
{
|
||||
var repeatStartTime = s.StartTime + tick.RepeatIndex * repeatDuration;
|
||||
var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2);
|
||||
@ -83,7 +84,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
AddNested(drawableTick);
|
||||
}
|
||||
|
||||
foreach (var repeatPoint in s.RepeatPoints)
|
||||
foreach (var repeatPoint in s.NestedHitObjects.OfType<RepeatPoint>())
|
||||
{
|
||||
var repeatStartTime = s.StartTime + repeatPoint.RepeatIndex * repeatDuration;
|
||||
var fadeInTime = repeatStartTime + (repeatPoint.StartTime - repeatStartTime) / 2 - (repeatPoint.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2);
|
||||
|
@ -68,9 +68,9 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
return HitResult.Miss;
|
||||
}
|
||||
|
||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2;
|
||||
}
|
||||
|
@ -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;
|
||||
@ -74,9 +74,9 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
public double Velocity;
|
||||
public double TickDistance;
|
||||
|
||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
|
||||
@ -99,75 +99,79 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
public int RepeatAt(double progress) => (int)(progress * RepeatCount);
|
||||
|
||||
public IEnumerable<SliderTick> Ticks
|
||||
protected override void CreateNestedHitObjects()
|
||||
{
|
||||
get
|
||||
base.CreateNestedHitObjects();
|
||||
|
||||
createTicks();
|
||||
createRepeatPoints();
|
||||
}
|
||||
|
||||
private void createTicks()
|
||||
{
|
||||
if (TickDistance == 0) return;
|
||||
|
||||
var length = Curve.Distance;
|
||||
var tickDistance = Math.Min(TickDistance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
var minDistanceFromEnd = Velocity * 0.01;
|
||||
|
||||
for (var repeat = 0; repeat < RepeatCount; repeat++)
|
||||
{
|
||||
if (TickDistance == 0) yield break;
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var reversed = repeat % 2 == 1;
|
||||
|
||||
var length = Curve.Distance;
|
||||
var tickDistance = Math.Min(TickDistance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
var minDistanceFromEnd = Velocity * 0.01;
|
||||
|
||||
for (var repeat = 0; repeat < RepeatCount; repeat++)
|
||||
for (var d = tickDistance; d <= length; d += tickDistance)
|
||||
{
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var reversed = repeat % 2 == 1;
|
||||
if (d > length - minDistanceFromEnd)
|
||||
break;
|
||||
|
||||
for (var d = tickDistance; d <= length; d += tickDistance)
|
||||
var distanceProgress = d / length;
|
||||
var timeProgress = reversed ? 1 - distanceProgress : distanceProgress;
|
||||
|
||||
AddNested(new SliderTick
|
||||
{
|
||||
if (d > length - minDistanceFromEnd)
|
||||
break;
|
||||
|
||||
var distanceProgress = d / length;
|
||||
var timeProgress = reversed ? 1 - distanceProgress : distanceProgress;
|
||||
|
||||
yield return new SliderTick
|
||||
RepeatIndex = repeat,
|
||||
StartTime = repeatStartTime + timeProgress * repeatDuration,
|
||||
Position = Curve.PositionAt(distanceProgress),
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
RepeatIndex = repeat,
|
||||
StartTime = repeatStartTime + timeProgress * repeatDuration,
|
||||
Position = Curve.PositionAt(distanceProgress),
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
};
|
||||
}
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
Volume = s.Volume
|
||||
}))
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
public IEnumerable<RepeatPoint> RepeatPoints
|
||||
|
||||
private void createRepeatPoints()
|
||||
{
|
||||
get
|
||||
var length = Curve.Distance;
|
||||
var repeatPointDistance = Math.Min(Distance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
for (var repeat = 1; repeat < RepeatCount; repeat++)
|
||||
{
|
||||
var length = Curve.Distance;
|
||||
var repeatPointDistance = Math.Min(Distance, length);
|
||||
var repeatDuration = length / Velocity;
|
||||
|
||||
for (var repeat = 1; repeat < RepeatCount; repeat++)
|
||||
for (var d = repeatPointDistance; d <= length; d += repeatPointDistance)
|
||||
{
|
||||
for (var d = repeatPointDistance; d <= length; d += repeatPointDistance)
|
||||
{
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var distanceProgress = d / length;
|
||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||
var distanceProgress = d / length;
|
||||
|
||||
yield return new RepeatPoint
|
||||
{
|
||||
RepeatIndex = repeat,
|
||||
StartTime = repeatStartTime,
|
||||
Position = Curve.PositionAt(distanceProgress),
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
};
|
||||
}
|
||||
AddNested(new RepeatPoint
|
||||
{
|
||||
RepeatIndex = repeat,
|
||||
StartTime = repeatStartTime,
|
||||
Position = Curve.PositionAt(distanceProgress),
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
Samples = new List<SampleInfo>(RepeatSamples[repeat])
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
public override bool NewCombo => true;
|
||||
|
||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
SpinsRequired = (int)(Duration / 1000 * BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 3, 5, 7.5));
|
||||
|
||||
|
@ -107,7 +107,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
|
||||
}
|
||||
});
|
||||
|
||||
var scoringTimes = slider.Ticks.Select(t => t.StartTime).Concat(slider.RepeatPoints.Select(r => r.StartTime)).OrderBy(t => t);
|
||||
var scoringTimes = slider.NestedHitObjects.Select(t => t.StartTime);
|
||||
foreach (var time in scoringTimes)
|
||||
computeVertex(time);
|
||||
computeVertex(slider.EndTime);
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
||||
countHitCircles = Beatmap.HitObjects.Count(h => h is HitCircle);
|
||||
|
||||
beatmapMaxCombo = Beatmap.HitObjects.Count;
|
||||
beatmapMaxCombo += Beatmap.HitObjects.OfType<Slider>().Sum(s => s.RepeatCount + s.Ticks.Count());
|
||||
beatmapMaxCombo += Beatmap.HitObjects.OfType<Slider>().Sum(s => s.NestedHitObjects.Count) + 1;
|
||||
}
|
||||
|
||||
public override double Calculate(Dictionary<string, double> categoryRatings = null)
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
@ -39,11 +40,11 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
||||
AddJudgement(new OsuJudgement { Result = HitResult.Great });
|
||||
|
||||
// Ticks
|
||||
foreach (var unused in slider.Ticks)
|
||||
foreach (var unused in slider.NestedHitObjects.OfType<SliderTick>())
|
||||
AddJudgement(new OsuJudgement { Result = HitResult.Great });
|
||||
|
||||
//Repeats
|
||||
foreach (var unused in slider.RepeatPoints)
|
||||
foreach (var unused in slider.NestedHitObjects.OfType<RepeatPoint>())
|
||||
AddJudgement(new OsuJudgement { Result = HitResult.Great });
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,10 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
public override bool ProvidingUserCursor => true;
|
||||
|
||||
// Todo: This should not be a thing, but is currently required for the editor
|
||||
// https://github.com/ppy/osu-framework/issues/1283
|
||||
protected virtual bool ProxyApproachCircles => true;
|
||||
|
||||
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
|
||||
|
||||
public override Vector2 Size
|
||||
@ -80,7 +84,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
h.Depth = (float)h.HitObject.StartTime;
|
||||
|
||||
var c = h as IDrawableHitObjectWithProxiedApproach;
|
||||
if (c != null)
|
||||
if (c != null && ProxyApproachCircles)
|
||||
approachCircles.Add(c.ProxiedLayer.CreateProxy());
|
||||
|
||||
base.Add(h);
|
||||
|
47
osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs
Normal file
47
osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Audio
|
||||
{
|
||||
public class DrumSampleMapping
|
||||
{
|
||||
private readonly ControlPointInfo controlPoints;
|
||||
private readonly Dictionary<SampleControlPoint, DrumSample> mappings = new Dictionary<SampleControlPoint, DrumSample>();
|
||||
|
||||
public DrumSampleMapping(ControlPointInfo controlPoints, AudioManager audio)
|
||||
{
|
||||
this.controlPoints = controlPoints;
|
||||
|
||||
IEnumerable<SampleControlPoint> samplePoints;
|
||||
if (controlPoints.SamplePoints.Count == 0)
|
||||
// Get the default sample point
|
||||
samplePoints = new[] { controlPoints.SamplePointAt(double.MinValue) };
|
||||
else
|
||||
samplePoints = controlPoints.SamplePoints;
|
||||
|
||||
foreach (var s in samplePoints.Distinct())
|
||||
{
|
||||
mappings[s] = new DrumSample
|
||||
{
|
||||
Centre = s.GetSampleInfo().GetChannel(audio.Sample),
|
||||
Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time)];
|
||||
|
||||
public class DrumSample
|
||||
{
|
||||
public SampleChannel Centre;
|
||||
public SampleChannel Rim;
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
RelativeChildSize = new Vector2((float)HitObject.Duration, 1)
|
||||
});
|
||||
|
||||
foreach (var tick in drumRoll.Ticks)
|
||||
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
|
||||
{
|
||||
var newTick = new DrawableDrumRollTick(tick);
|
||||
newTick.OnJudgement += onTickJudgement;
|
||||
|
@ -67,6 +67,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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -6,6 +6,9 @@ using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
||||
using OpenTK;
|
||||
using System.Linq;
|
||||
using osu.Game.Audio;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
@ -35,6 +38,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
MainPiece.KiaiMode = HitObject.Kiai;
|
||||
}
|
||||
|
||||
// Normal and clap samples are handled by the drum
|
||||
protected override IEnumerable<SampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != SampleInfo.HIT_NORMAL && s.Name != SampleInfo.HIT_CLAP);
|
||||
|
||||
protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
|
||||
|
||||
public abstract bool OnPressed(TaikoAction action);
|
||||
|
@ -37,53 +37,46 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
/// </summary>
|
||||
public double RequiredGreatHits { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total number of drum roll ticks.
|
||||
/// </summary>
|
||||
public int TotalTicks => Ticks.Count();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the drum roll ticks if not initialized and returns them.
|
||||
/// </summary>
|
||||
public IEnumerable<DrumRollTick> Ticks => ticks ?? (ticks = createTicks());
|
||||
|
||||
private List<DrumRollTick> ticks;
|
||||
|
||||
/// <summary>
|
||||
/// The length (in milliseconds) between ticks of this drumroll.
|
||||
/// <para>Half of this value is the hit window of the ticks.</para>
|
||||
/// </summary>
|
||||
private double tickSpacing = 100;
|
||||
|
||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||
|
||||
tickSpacing = timingPoint.BeatLength / TickRate;
|
||||
|
||||
RequiredGoodHits = TotalTicks * Math.Min(0.15, 0.05 + 0.10 / 6 * difficulty.OverallDifficulty);
|
||||
RequiredGreatHits = TotalTicks * Math.Min(0.30, 0.10 + 0.20 / 6 * difficulty.OverallDifficulty);
|
||||
RequiredGoodHits = NestedHitObjects.Count * Math.Min(0.15, 0.05 + 0.10 / 6 * difficulty.OverallDifficulty);
|
||||
RequiredGreatHits = NestedHitObjects.Count * Math.Min(0.30, 0.10 + 0.20 / 6 * difficulty.OverallDifficulty);
|
||||
}
|
||||
|
||||
private List<DrumRollTick> createTicks()
|
||||
protected override void CreateNestedHitObjects()
|
||||
{
|
||||
var ret = new List<DrumRollTick>();
|
||||
base.CreateNestedHitObjects();
|
||||
|
||||
createTicks();
|
||||
}
|
||||
|
||||
private void createTicks()
|
||||
{
|
||||
if (tickSpacing == 0)
|
||||
return ret;
|
||||
return;
|
||||
|
||||
bool first = true;
|
||||
for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing)
|
||||
{
|
||||
ret.Add(new DrumRollTick
|
||||
AddNested(new DrumRollTick
|
||||
{
|
||||
FirstTick = first,
|
||||
TickSpacing = tickSpacing,
|
||||
StartTime = t,
|
||||
IsStrong = IsStrong,
|
||||
Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
|
||||
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
|
||||
{
|
||||
Bank = s.Bank,
|
||||
Name = @"slidertick",
|
||||
@ -93,8 +86,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
/// </summary>
|
||||
public double HitWindowMiss = 95;
|
||||
|
||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
|
||||
HitWindowGreat = BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 50, 35, 20);
|
||||
HitWindowGood = BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 120, 80, 50);
|
||||
|
@ -16,4 +16,4 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
/// </summary>
|
||||
public int RequiredHits = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
@ -83,7 +84,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
|
||||
}
|
||||
else if (drumRoll != null)
|
||||
{
|
||||
foreach (var tick in drumRoll.Ticks)
|
||||
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
|
||||
{
|
||||
Frames.Add(new ReplayFrame(tick.StartTime, null, null, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2));
|
||||
hitButton = !hitButton;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
@ -88,7 +89,7 @@ namespace osu.Game.Rulesets.Taiko.Scoring
|
||||
}
|
||||
else if (obj is DrumRoll)
|
||||
{
|
||||
for (int i = 0; i < ((DrumRoll)obj).TotalTicks; i++)
|
||||
for (int i = 0; i < ((DrumRoll)obj).NestedHitObjects.OfType<DrumRollTick>().Count(); i++)
|
||||
{
|
||||
AddJudgement(new TaikoDrumRollTickJudgement { Result = HitResult.Great });
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -16,6 +16,7 @@ using osu.Framework.Extensions.Color4Extensions;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
@ -54,7 +55,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
private readonly Box overlayBackground;
|
||||
private readonly Box background;
|
||||
|
||||
public TaikoPlayfield()
|
||||
public TaikoPlayfield(ControlPointInfo controlPoints)
|
||||
: base(Axes.X)
|
||||
{
|
||||
AddRangeInternal(new Drawable[]
|
||||
@ -149,7 +150,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new InputDrum
|
||||
new InputDrum(controlPoints)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
@ -249,7 +250,9 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
topLevelHitContainer.Add(judgedObject.CreateProxy());
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim));
|
||||
|
@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
public override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo);
|
||||
|
||||
protected override Playfield CreatePlayfield() => new TaikoPlayfield
|
||||
protected override Playfield CreatePlayfield() => new TaikoPlayfield(Beatmap.ControlPointInfo)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft
|
||||
|
@ -44,6 +44,7 @@
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Audio\DrumSampleMapping.cs" />
|
||||
<Compile Include="Beatmaps\TaikoBeatmapConverter.cs" />
|
||||
<Compile Include="Judgements\TaikoDrumRollTickJudgement.cs" />
|
||||
<Compile Include="Judgements\TaikoStrongHitJudgement.cs" />
|
||||
|
@ -146,8 +146,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.AreEqual(116999, difficultyPoint.Time);
|
||||
Assert.AreEqual(0.75000000000000189d, difficultyPoint.SpeedMultiplier);
|
||||
|
||||
Assert.AreEqual(34, controlPoints.SoundPoints.Count);
|
||||
var soundPoint = controlPoints.SoundPoints[0];
|
||||
Assert.AreEqual(34, controlPoints.SamplePoints.Count);
|
||||
var soundPoint = controlPoints.SamplePoints[0];
|
||||
Assert.AreEqual(956, soundPoint.Time);
|
||||
Assert.AreEqual("soft", soundPoint.SampleBank);
|
||||
Assert.AreEqual(60, soundPoint.SampleVolume);
|
||||
|
176
osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs
Normal file
176
osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs
Normal file
@ -0,0 +1,176 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using DeepEqual.Syntax;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.IO.Serialization;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Tests.Resources;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Beatmaps.Formats
|
||||
{
|
||||
[TestFixture]
|
||||
public class OsuJsonDecoderTest
|
||||
{
|
||||
private const string normal = "Soleily - Renatus (Gamu) [Insane].osu";
|
||||
private const string marathon = "Within Temptation - The Unforgiving (Armin) [Marathon].osu";
|
||||
private const string with_sb = "Kozato snow - Rengetsu Ouka (_Kiva) [Yuki YukI].osu";
|
||||
|
||||
[Test]
|
||||
public void TestDecodeMetadata()
|
||||
{
|
||||
var beatmap = decodeAsJson(normal);
|
||||
var meta = beatmap.BeatmapInfo.Metadata;
|
||||
Assert.AreEqual(241526, meta.OnlineBeatmapSetID);
|
||||
Assert.AreEqual("Soleily", meta.Artist);
|
||||
Assert.AreEqual("Soleily", meta.ArtistUnicode);
|
||||
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
|
||||
Assert.AreEqual("Gamu", meta.AuthorString);
|
||||
Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile);
|
||||
Assert.AreEqual(164471, meta.PreviewTime);
|
||||
Assert.AreEqual(string.Empty, meta.Source);
|
||||
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags);
|
||||
Assert.AreEqual("Renatus", meta.Title);
|
||||
Assert.AreEqual("Renatus", meta.TitleUnicode);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecodeGeneral()
|
||||
{
|
||||
var beatmap = decodeAsJson(normal);
|
||||
var beatmapInfo = beatmap.BeatmapInfo;
|
||||
Assert.AreEqual(0, beatmapInfo.AudioLeadIn);
|
||||
Assert.AreEqual(false, beatmapInfo.Countdown);
|
||||
Assert.AreEqual(0.7f, beatmapInfo.StackLeniency);
|
||||
Assert.AreEqual(false, beatmapInfo.SpecialStyle);
|
||||
Assert.IsTrue(beatmapInfo.RulesetID == 0);
|
||||
Assert.AreEqual(false, beatmapInfo.LetterboxInBreaks);
|
||||
Assert.AreEqual(false, beatmapInfo.WidescreenStoryboard);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecodeEditor()
|
||||
{
|
||||
var beatmap = decodeAsJson(normal);
|
||||
var beatmapInfo = beatmap.BeatmapInfo;
|
||||
|
||||
int[] expectedBookmarks =
|
||||
{
|
||||
11505, 22054, 32604, 43153, 53703, 64252, 74802, 85351,
|
||||
95901, 106450, 116999, 119637, 130186, 140735, 151285,
|
||||
161834, 164471, 175020, 185570, 196119, 206669, 209306
|
||||
};
|
||||
Assert.AreEqual(expectedBookmarks.Length, beatmapInfo.Bookmarks.Length);
|
||||
for (int i = 0; i < expectedBookmarks.Length; i++)
|
||||
Assert.AreEqual(expectedBookmarks[i], beatmapInfo.Bookmarks[i]);
|
||||
Assert.AreEqual(1.8, beatmapInfo.DistanceSpacing);
|
||||
Assert.AreEqual(4, beatmapInfo.BeatDivisor);
|
||||
Assert.AreEqual(4, beatmapInfo.GridSize);
|
||||
Assert.AreEqual(2, beatmapInfo.TimelineZoom);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecodeDifficulty()
|
||||
{
|
||||
var beatmap = decodeAsJson(normal);
|
||||
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
||||
Assert.AreEqual(6.5f, difficulty.DrainRate);
|
||||
Assert.AreEqual(4, difficulty.CircleSize);
|
||||
Assert.AreEqual(8, difficulty.OverallDifficulty);
|
||||
Assert.AreEqual(9, difficulty.ApproachRate);
|
||||
Assert.AreEqual(1.8f, difficulty.SliderMultiplier);
|
||||
Assert.AreEqual(2, difficulty.SliderTickRate);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecodeColors()
|
||||
{
|
||||
var beatmap = decodeAsJson(normal);
|
||||
Color4[] expected =
|
||||
{
|
||||
new Color4(142, 199, 255, 255),
|
||||
new Color4(255, 128, 128, 255),
|
||||
new Color4(128, 255, 255, 255),
|
||||
new Color4(128, 255, 128, 255),
|
||||
new Color4(255, 187, 255, 255),
|
||||
new Color4(255, 177, 140, 255),
|
||||
};
|
||||
Assert.AreEqual(expected.Length, beatmap.ComboColors.Count);
|
||||
for (int i = 0; i < expected.Length; i++)
|
||||
Assert.AreEqual(expected[i], beatmap.ComboColors[i]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecodeHitObjects()
|
||||
{
|
||||
var beatmap = decodeAsJson(normal);
|
||||
|
||||
var curveData = beatmap.HitObjects[0] as IHasCurve;
|
||||
var positionData = beatmap.HitObjects[0] as IHasPosition;
|
||||
|
||||
Assert.IsNotNull(positionData);
|
||||
Assert.IsNotNull(curveData);
|
||||
Assert.AreEqual(new Vector2(192, 168), positionData.Position);
|
||||
Assert.AreEqual(956, beatmap.HitObjects[0].StartTime);
|
||||
Assert.IsTrue(beatmap.HitObjects[0].Samples.Any(s => s.Name == SampleInfo.HIT_NORMAL));
|
||||
|
||||
positionData = beatmap.HitObjects[1] as IHasPosition;
|
||||
|
||||
Assert.IsNotNull(positionData);
|
||||
Assert.AreEqual(new Vector2(304, 56), positionData.Position);
|
||||
Assert.AreEqual(1285, beatmap.HitObjects[1].StartTime);
|
||||
Assert.IsTrue(beatmap.HitObjects[1].Samples.Any(s => s.Name == SampleInfo.HIT_CLAP));
|
||||
}
|
||||
|
||||
[TestCase(normal)]
|
||||
[TestCase(marathon)]
|
||||
// Currently fails:
|
||||
// [TestCase(with_sb)]
|
||||
public void TestParity(string beatmap)
|
||||
{
|
||||
var beatmaps = decode(beatmap);
|
||||
beatmaps.jsonDecoded.ShouldDeepEqual(beatmaps.legacyDecoded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a .osu file first with a <see cref="LegacyBeatmapDecoder"/>, serializes the resulting <see cref="Beatmap"/> to JSON
|
||||
/// and then deserializes the result back into a <see cref="Beatmap"/> through an <see cref="JsonBeatmapDecoder"/>.
|
||||
/// </summary>
|
||||
/// <param name="filename">The .osu file to decode.</param>
|
||||
/// <returns>The <see cref="Beatmap"/> after being decoded by an <see cref="LegacyBeatmapDecoder"/>.</returns>
|
||||
private Beatmap decodeAsJson(string filename) => decode(filename).jsonDecoded;
|
||||
|
||||
/// <summary>
|
||||
/// Reads a .osu file first with a <see cref="LegacyBeatmapDecoder"/>, serializes the resulting <see cref="Beatmap"/> to JSON
|
||||
/// and then deserializes the result back into a <see cref="Beatmap"/> through an <see cref="JsonBeatmapDecoder"/>.
|
||||
/// </summary>
|
||||
/// <param name="filename">The .osu file to decode.</param>
|
||||
/// <returns>The <see cref="Beatmap"/> after being decoded by an <see cref="LegacyBeatmapDecoder"/>.</returns>
|
||||
private (Beatmap legacyDecoded, Beatmap jsonDecoded) decode(string filename)
|
||||
{
|
||||
using (var stream = Resource.OpenResource(filename))
|
||||
using (var sr = new StreamReader(stream))
|
||||
{
|
||||
|
||||
var legacyDecoded = new LegacyBeatmapDecoder().DecodeBeatmap(sr);
|
||||
using (var ms = new MemoryStream())
|
||||
using (var sw = new StreamWriter(ms))
|
||||
using (var sr2 = new StreamReader(ms))
|
||||
{
|
||||
sw.Write(legacyDecoded.Serialize());
|
||||
sw.Flush();
|
||||
|
||||
ms.Position = 0;
|
||||
return (legacyDecoded, new JsonBeatmapDecoder().DecodeBeatmap(sr2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -7,13 +7,13 @@ using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Lists;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
|
@ -69,6 +69,8 @@ namespace osu.Game.Tests.Visual
|
||||
testSorting();
|
||||
|
||||
testRemoveAll();
|
||||
testEmptyTraversal();
|
||||
testHiding();
|
||||
}
|
||||
|
||||
private void ensureRandomFetchSuccess() =>
|
||||
@ -103,6 +105,8 @@ namespace osu.Game.Tests.Visual
|
||||
AddAssert($"{count} {(diff ? "diffs" : "sets")} visible", () =>
|
||||
carousel.Items.Count(s => (diff ? s.Item is CarouselBeatmap : s.Item is CarouselBeatmapSet) && s.Item.Visible) == count);
|
||||
|
||||
private void checkNoSelection() => AddAssert("Selection is null", () => currentSelection == null);
|
||||
|
||||
private void nextRandom() =>
|
||||
AddStep("select random next", () =>
|
||||
{
|
||||
@ -274,9 +278,57 @@ namespace osu.Game.Tests.Visual
|
||||
return false;
|
||||
}, "Remove all");
|
||||
|
||||
AddAssert("Selection is null", () => currentSelection == null);
|
||||
checkNoSelection();
|
||||
}
|
||||
|
||||
private void testEmptyTraversal()
|
||||
{
|
||||
advanceSelection(direction: 1, diff: false);
|
||||
checkNoSelection();
|
||||
|
||||
advanceSelection(direction: 1, diff: true);
|
||||
checkNoSelection();
|
||||
|
||||
advanceSelection(direction: -1, diff: false);
|
||||
checkNoSelection();
|
||||
|
||||
advanceSelection(direction: -1, diff: true);
|
||||
checkNoSelection();
|
||||
}
|
||||
|
||||
private 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)
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual
|
||||
b.ControlPointInfo.EffectPoints.Add(new EffectControlPoint { Time = random.Next(0, length) });
|
||||
|
||||
for (int i = 0; i < random.Next(1, 5); i++)
|
||||
b.ControlPointInfo.SoundPoints.Add(new SoundControlPoint { Time = random.Next(0, length) });
|
||||
b.ControlPointInfo.SamplePoints.Add(new SampleControlPoint { Time = random.Next(0, length) });
|
||||
|
||||
b.BeatmapInfo.Bookmarks = new int[random.Next(10, 30)];
|
||||
for (int i = 0; i < b.BeatmapInfo.Bookmarks.Length; i++)
|
||||
|
@ -36,6 +36,7 @@ namespace osu.Game.Tests.Visual
|
||||
AddStep(@"Network failure", () => leaderboard.SetRetrievalState(PlaceholderState.NetworkFailure));
|
||||
AddStep(@"No supporter", () => leaderboard.SetRetrievalState(PlaceholderState.NotSupporter));
|
||||
AddStep(@"Not logged in", () => leaderboard.SetRetrievalState(PlaceholderState.NotLoggedIn));
|
||||
AddStep(@"Unavailable", () => leaderboard.SetRetrievalState(PlaceholderState.Unavailable));
|
||||
AddStep(@"Real beatmap", realBeatmap);
|
||||
}
|
||||
|
||||
|
@ -3,19 +3,18 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
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;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCaseNotificationOverlay : OsuTestCase
|
||||
{
|
||||
private readonly NotificationOverlay manager;
|
||||
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
|
||||
|
||||
public TestCaseNotificationOverlay()
|
||||
{
|
||||
@ -24,15 +23,20 @@ namespace osu.Game.Tests.Visual
|
||||
Content.Add(manager = new NotificationOverlay
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight
|
||||
});
|
||||
|
||||
AddToggleStep(@"show", state => manager.State = state ? Visibility.Visible : Visibility.Hidden);
|
||||
SpriteText displayedCount = new SpriteText();
|
||||
|
||||
AddStep(@"simple #1", sendNotification1);
|
||||
AddStep(@"simple #2", sendNotification2);
|
||||
AddStep(@"progress #1", sendProgress1);
|
||||
AddStep(@"progress #2", sendProgress2);
|
||||
Content.Add(displayedCount);
|
||||
|
||||
manager.UnreadCount.ValueChanged += count => { displayedCount.Text = $"displayed count: {count}"; };
|
||||
|
||||
AddStep(@"toggle", manager.ToggleVisibility);
|
||||
AddStep(@"simple #1", sendHelloNotification);
|
||||
AddStep(@"simple #2", sendAmazingNotification);
|
||||
AddStep(@"progress #1", sendUploadProgress);
|
||||
AddStep(@"progress #2", sendDownloadProgress);
|
||||
AddStep(@"barrage", () => sendBarrage());
|
||||
}
|
||||
|
||||
@ -41,16 +45,16 @@ namespace osu.Game.Tests.Visual
|
||||
switch (RNG.Next(0, 4))
|
||||
{
|
||||
case 0:
|
||||
sendNotification1();
|
||||
sendHelloNotification();
|
||||
break;
|
||||
case 1:
|
||||
sendNotification2();
|
||||
sendAmazingNotification();
|
||||
break;
|
||||
case 2:
|
||||
sendProgress1();
|
||||
sendUploadProgress();
|
||||
break;
|
||||
case 3:
|
||||
sendProgress2();
|
||||
sendDownloadProgress();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -80,7 +84,7 @@ namespace osu.Game.Tests.Visual
|
||||
}
|
||||
}
|
||||
|
||||
private void sendProgress2()
|
||||
private void sendDownloadProgress()
|
||||
{
|
||||
var n = new ProgressNotification
|
||||
{
|
||||
@ -91,9 +95,7 @@ namespace osu.Game.Tests.Visual
|
||||
progressingNotifications.Add(n);
|
||||
}
|
||||
|
||||
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
|
||||
|
||||
private void sendProgress1()
|
||||
private void sendUploadProgress()
|
||||
{
|
||||
var n = new ProgressNotification
|
||||
{
|
||||
@ -104,12 +106,12 @@ namespace osu.Game.Tests.Visual
|
||||
progressingNotifications.Add(n);
|
||||
}
|
||||
|
||||
private void sendNotification2()
|
||||
private void sendAmazingNotification()
|
||||
{
|
||||
manager.Post(new SimpleNotification { Text = @"You are amazing" });
|
||||
}
|
||||
|
||||
private void sendNotification1()
|
||||
private void sendHelloNotification()
|
||||
{
|
||||
manager.Post(new SimpleNotification { Text = @"Welcome to osu!. Enjoy your stay!" });
|
||||
}
|
||||
|
@ -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; });
|
||||
|
37
osu.Game.Tests/Visual/TestCasePopupDialog.cs
Normal file
37
osu.Game.Tests/Visual/TestCasePopupDialog.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
123
osu.Game.Tests/Visual/TestCaseRankGraph.cs
Normal file
123
osu.Game.Tests/Visual/TestCaseRankGraph.cs
Normal file
@ -0,0 +1,123 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Overlays.Profile;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public class TestCaseRankGraph : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(RankGraph),
|
||||
typeof(LineGraph)
|
||||
};
|
||||
|
||||
public TestCaseRankGraph()
|
||||
{
|
||||
RankGraph graph;
|
||||
|
||||
var data = new int[89];
|
||||
var dataWithZeros = new int[89];
|
||||
var smallData = new int[89];
|
||||
|
||||
for (int i = 0; i < 89; i++)
|
||||
data[i] = dataWithZeros[i] = (i + 1) * 1000;
|
||||
|
||||
for (int i = 20; i < 60; i++)
|
||||
dataWithZeros[i] = 0;
|
||||
|
||||
for (int i = 79; i < 89; i++)
|
||||
smallData[i] = 100000 - i * 1000;
|
||||
|
||||
Add(new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(300, 150),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.Gray(0.2f)
|
||||
},
|
||||
graph = new RankGraph
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("null user", () => graph.User.Value = null);
|
||||
AddStep("rank only", () =>
|
||||
{
|
||||
graph.User.Value = new User
|
||||
{
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
Rank = 123456,
|
||||
PP = 12345,
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("with rank history", () =>
|
||||
{
|
||||
graph.User.Value = new User
|
||||
{
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
Rank = 89000,
|
||||
PP = 12345,
|
||||
},
|
||||
RankHistory = new User.RankHistoryData
|
||||
{
|
||||
Data = data,
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("with zero values", () =>
|
||||
{
|
||||
graph.User.Value = new User
|
||||
{
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
Rank = 89000,
|
||||
PP = 12345,
|
||||
},
|
||||
RankHistory = new User.RankHistoryData
|
||||
{
|
||||
Data = dataWithZeros,
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("small amount of data", () =>
|
||||
{
|
||||
graph.User.Value = new User
|
||||
{
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
Rank = 12000,
|
||||
PP = 12345,
|
||||
},
|
||||
RankHistory = new User.RankHistoryData
|
||||
{
|
||||
Data = smallData,
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
39
osu.Game.Tests/Visual/TestCaseToolbar.cs
Normal file
39
osu.Game.Tests/Visual/TestCaseToolbar.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,18 +2,35 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Profile;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public class TestCaseUserProfile : OsuTestCase
|
||||
{
|
||||
private readonly TestUserProfileOverlay profile;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ProfileHeader),
|
||||
typeof(UserProfileOverlay),
|
||||
typeof(RankGraph),
|
||||
typeof(LineGraph),
|
||||
};
|
||||
|
||||
public TestCaseUserProfile()
|
||||
{
|
||||
var profile = new UserProfileOverlay();
|
||||
Add(profile);
|
||||
Add(profile = new TestUserProfileOverlay());
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
AddStep("Show offline dummy", () => profile.ShowUser(new User
|
||||
{
|
||||
@ -37,6 +54,9 @@ namespace osu.Game.Tests.Visual
|
||||
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
|
||||
}
|
||||
}, false));
|
||||
|
||||
checkSupporterTag(false);
|
||||
|
||||
AddStep("Show ppy", () => profile.ShowUser(new User
|
||||
{
|
||||
Username = @"peppy",
|
||||
@ -44,6 +64,9 @@ namespace osu.Game.Tests.Visual
|
||||
Country = new Country { FullName = @"Australia", FlagName = @"AU" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
|
||||
}));
|
||||
|
||||
checkSupporterTag(true);
|
||||
|
||||
AddStep("Show flyte", () => profile.ShowUser(new User
|
||||
{
|
||||
Username = @"flyte",
|
||||
@ -51,8 +74,23 @@ namespace osu.Game.Tests.Visual
|
||||
Country = new Country { FullName = @"Japan", FlagName = @"JP" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
||||
}));
|
||||
|
||||
AddStep("Hide", profile.Hide);
|
||||
AddStep("Show without reload", profile.Show);
|
||||
}
|
||||
|
||||
private void checkSupporterTag(bool isSupporter)
|
||||
{
|
||||
AddUntilStep(() => profile.Header.User != null, "wait for load");
|
||||
if (isSupporter)
|
||||
AddAssert("is supporter", () => profile.Header.SupporterTag.Alpha == 1);
|
||||
else
|
||||
AddAssert("no supporter", () => profile.Header.SupporterTag.Alpha == 0);
|
||||
}
|
||||
|
||||
private class TestUserProfileOverlay : UserProfileOverlay
|
||||
{
|
||||
public new ProfileHeader Header => base.Header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,9 @@
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DeepEqual, Version=1.6.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>$(SolutionDir)\packages\DeepEqual.1.6.0.0\lib\net40\DeepEqual.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=3.8.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>$(SolutionDir)\packages\NUnit.3.8.1\lib\net45\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -83,6 +86,7 @@
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Beatmaps\Formats\OsuJsonDecoderTest.cs" />
|
||||
<Compile Include="Beatmaps\Formats\LegacyStoryboardDecoderTest.cs" />
|
||||
<Compile Include="Beatmaps\IO\OszArchiveReaderTest.cs" />
|
||||
<Compile Include="Beatmaps\IO\ImportBeatmapTest.cs" />
|
||||
@ -130,6 +134,8 @@
|
||||
<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" />
|
||||
<Compile Include="Visual\TestCaseResults.cs" />
|
||||
@ -143,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" />
|
||||
@ -152,6 +159,8 @@
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\Soleily - Renatus %28Gamu%29 [Insane].osu" />
|
||||
<EmbeddedResource Include="Resources\Himeringo - Yotsuya-san ni Yoroshiku %28RLC%29 [Winber1%27s Extreme].osu" />
|
||||
<EmbeddedResource Include="Resources\Within Temptation - The Unforgiving %28Armin%29 [Marathon].osu" />
|
||||
<EmbeddedResource Include="Resources\Kozato snow - Rengetsu Ouka %28_Kiva%29 [Yuki YukI].osu" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -4,6 +4,7 @@ Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
-->
|
||||
<packages>
|
||||
<package id="DeepEqual" version="1.6.0.0" targetFramework="net461" />
|
||||
<package id="NUnit" version="3.8.1" targetFramework="net461" />
|
||||
<package id="OpenTK" version="3.0.0-git00009" targetFramework="net461" />
|
||||
<package id="System.ValueTuple" version="4.4.0" targetFramework="net461" />
|
||||
|
@ -1,8 +1,12 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Audio.Sample;
|
||||
|
||||
namespace osu.Game.Audio
|
||||
{
|
||||
[Serializable]
|
||||
public class SampleInfo
|
||||
{
|
||||
public const string HIT_WHISTLE = @"hitwhistle";
|
||||
@ -10,6 +14,13 @@ namespace osu.Game.Audio
|
||||
public const string HIT_NORMAL = @"hitnormal";
|
||||
public const string HIT_CLAP = @"hitclap";
|
||||
|
||||
public SampleChannel GetChannel(SampleManager manager)
|
||||
{
|
||||
var channel = manager.Get($"Gameplay/{Bank}-{Name}");
|
||||
channel.Volume.Value = Volume / 100.0;
|
||||
return channel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The bank to load the sample from.
|
||||
/// </summary>
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -8,19 +8,21 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.IO.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.IO.Serialization.Converters;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
/// <summary>
|
||||
/// A Beatmap containing converted HitObjects.
|
||||
/// </summary>
|
||||
public class Beatmap<T>
|
||||
public class Beatmap<T> : IJsonSerializable
|
||||
where T : HitObject
|
||||
{
|
||||
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
|
||||
public ControlPointInfo ControlPointInfo = new ControlPointInfo();
|
||||
public List<BreakPeriod> Breaks = new List<BreakPeriod>();
|
||||
public readonly List<Color4> ComboColors = new List<Color4>
|
||||
public List<Color4> ComboColors = new List<Color4>
|
||||
{
|
||||
new Color4(17, 136, 170, 255),
|
||||
new Color4(102, 136, 0, 255),
|
||||
@ -28,16 +30,19 @@ namespace osu.Game.Beatmaps
|
||||
new Color4(121, 9, 13, 255)
|
||||
};
|
||||
|
||||
[JsonIgnore]
|
||||
public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// The HitObjects this Beatmap contains.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(TypedListConverter<HitObject>))]
|
||||
public List<T> HitObjects = new List<T>();
|
||||
|
||||
/// <summary>
|
||||
/// Total amount of break time in the beatmap.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
||||
|
||||
/// <summary>
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -13,6 +14,7 @@ namespace osu.Game.Beatmaps
|
||||
public const float DEFAULT_DIFFICULTY = 5;
|
||||
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public int ID { get; set; }
|
||||
|
||||
public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;
|
||||
|
@ -12,9 +12,11 @@ using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
[Serializable]
|
||||
public class BeatmapInfo : IEquatable<BeatmapInfo>, IJsonSerializable, IHasPrimaryKey
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public int ID { get; set; }
|
||||
|
||||
//TODO: should be in database
|
||||
@ -38,13 +40,16 @@ namespace osu.Game.Beatmaps
|
||||
set { onlineBeatmapSetID = value > 0 ? value : null; }
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public int BeatmapSetInfoID { get; set; }
|
||||
|
||||
[Required]
|
||||
[JsonIgnore]
|
||||
public BeatmapSetInfo BeatmapSet { get; set; }
|
||||
|
||||
public BeatmapMetadata Metadata { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int BaseDifficultyID { get; set; }
|
||||
|
||||
public BeatmapDifficulty BaseDifficulty { get; set; }
|
||||
@ -60,6 +65,7 @@ namespace osu.Game.Beatmaps
|
||||
[JsonProperty("file_sha2")]
|
||||
public string Hash { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool Hidden { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -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()
|
||||
|
@ -10,9 +10,11 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
[Serializable]
|
||||
public class BeatmapMetadata : IEquatable<BeatmapMetadata>
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public int ID { get; set; }
|
||||
|
||||
private int? onlineBeatmapSetID;
|
||||
@ -30,7 +32,10 @@ namespace osu.Game.Beatmaps
|
||||
public string Artist { get; set; }
|
||||
public string ArtistUnicode { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<BeatmapInfo> Beatmaps { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<BeatmapSetInfo> BeatmapSets { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -47,6 +52,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// The author of the beatmaps in this set.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public User Author;
|
||||
|
||||
public string Source { get; set; }
|
||||
@ -59,6 +65,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public override string ToString() => $"{Artist} - {Title} ({Author})";
|
||||
|
||||
[JsonIgnore]
|
||||
public string[] SearchableTerms => new[]
|
||||
{
|
||||
Author?.Username,
|
||||
|
@ -4,31 +4,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Lists;
|
||||
|
||||
namespace osu.Game.Beatmaps.ControlPoints
|
||||
{
|
||||
[Serializable]
|
||||
public class ControlPointInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// All timing points.
|
||||
/// </summary>
|
||||
public readonly SortedList<TimingControlPoint> TimingPoints = new SortedList<TimingControlPoint>(Comparer<TimingControlPoint>.Default);
|
||||
[JsonProperty]
|
||||
public SortedList<TimingControlPoint> TimingPoints { get; private set; } = new SortedList<TimingControlPoint>(Comparer<TimingControlPoint>.Default);
|
||||
|
||||
/// <summary>
|
||||
/// All difficulty points.
|
||||
/// </summary>
|
||||
public readonly SortedList<DifficultyControlPoint> DifficultyPoints = new SortedList<DifficultyControlPoint>(Comparer<DifficultyControlPoint>.Default);
|
||||
[JsonProperty]
|
||||
public SortedList<DifficultyControlPoint> DifficultyPoints { get; private set; } = new SortedList<DifficultyControlPoint>(Comparer<DifficultyControlPoint>.Default);
|
||||
|
||||
/// <summary>
|
||||
/// All sound points.
|
||||
/// </summary>
|
||||
public readonly SortedList<SoundControlPoint> SoundPoints = new SortedList<SoundControlPoint>(Comparer<SoundControlPoint>.Default);
|
||||
[JsonProperty]
|
||||
public SortedList<SampleControlPoint> SamplePoints { get; private set; } = new SortedList<SampleControlPoint>(Comparer<SampleControlPoint>.Default);
|
||||
|
||||
/// <summary>
|
||||
/// All effect points.
|
||||
/// </summary>
|
||||
public readonly SortedList<EffectControlPoint> EffectPoints = new SortedList<EffectControlPoint>(Comparer<EffectControlPoint>.Default);
|
||||
[JsonProperty]
|
||||
public SortedList<EffectControlPoint> EffectPoints { get; private set; } = new SortedList<EffectControlPoint>(Comparer<EffectControlPoint>.Default);
|
||||
|
||||
/// <summary>
|
||||
/// Finds the difficulty control point that is active at <paramref name="time"/>.
|
||||
@ -49,7 +55,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
/// </summary>
|
||||
/// <param name="time">The time to find the sound control point at.</param>
|
||||
/// <returns>The sound control point.</returns>
|
||||
public SoundControlPoint SoundPointAt(double time) => binarySearch(SoundPoints, time);
|
||||
public SampleControlPoint SamplePointAt(double time) => binarySearch(SamplePoints, time, SamplePoints.FirstOrDefault());
|
||||
|
||||
/// <summary>
|
||||
/// Finds the timing control point that is active at <paramref name="time"/>.
|
||||
@ -58,18 +64,21 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
/// <returns>The timing control point.</returns>
|
||||
public TimingControlPoint TimingPointAt(double time) => binarySearch(TimingPoints, time, TimingPoints.FirstOrDefault());
|
||||
|
||||
[JsonIgnore]
|
||||
/// <summary>
|
||||
/// Finds the maximum BPM represented by any timing control point.
|
||||
/// </summary>
|
||||
public double BPMMaximum =>
|
||||
60000 / (TimingPoints.OrderBy(c => c.BeatLength).FirstOrDefault() ?? new TimingControlPoint()).BeatLength;
|
||||
|
||||
[JsonIgnore]
|
||||
/// <summary>
|
||||
/// Finds the minimum BPM represented by any timing control point.
|
||||
/// </summary>
|
||||
public double BPMMinimum =>
|
||||
60000 / (TimingPoints.OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? new TimingControlPoint()).BeatLength;
|
||||
|
||||
[JsonIgnore]
|
||||
/// <summary>
|
||||
/// Finds the mode BPM (most common BPM) represented by the control points.
|
||||
/// </summary>
|
||||
@ -108,4 +117,4 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
return list[index - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
34
osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs
Normal file
34
osu.Game/Beatmaps/ControlPoints/SampleControlPoint.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Audio;
|
||||
|
||||
namespace osu.Game.Beatmaps.ControlPoints
|
||||
{
|
||||
public class SampleControlPoint : ControlPoint
|
||||
{
|
||||
public const string DEFAULT_BANK = "normal";
|
||||
|
||||
/// <summary>
|
||||
/// The default sample bank at this control point.
|
||||
/// </summary>
|
||||
public string SampleBank = DEFAULT_BANK;
|
||||
|
||||
/// <summary>
|
||||
/// The default sample volume at this control point.
|
||||
/// </summary>
|
||||
public int SampleVolume;
|
||||
|
||||
/// <summary>
|
||||
/// Create a SampleInfo based on the sample settings in this control point.
|
||||
/// </summary>
|
||||
/// <param name="sampleName">The name of the same.</param>
|
||||
/// <returns>A populated <see cref="SampleInfo"/>.</returns>
|
||||
public SampleInfo GetSampleInfo(string sampleName = SampleInfo.HIT_NORMAL) => new SampleInfo
|
||||
{
|
||||
Bank = SampleBank,
|
||||
Name = sampleName,
|
||||
Volume = SampleVolume,
|
||||
};
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Beatmaps.ControlPoints
|
||||
{
|
||||
public class SoundControlPoint : ControlPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// The default sample bank at this control point.
|
||||
/// </summary>
|
||||
public string SampleBank;
|
||||
|
||||
/// <summary>
|
||||
/// The default sample volume at this control point.
|
||||
/// </summary>
|
||||
public int SampleVolume;
|
||||
}
|
||||
}
|
@ -10,11 +10,12 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public abstract class Decoder
|
||||
{
|
||||
private static readonly Dictionary<string, Type> decoders = new Dictionary<string, Type>();
|
||||
private static readonly Dictionary<string, Func<string, Decoder>> decoders = new Dictionary<string, Func<string, Decoder>>();
|
||||
|
||||
static Decoder()
|
||||
{
|
||||
LegacyDecoder.Register();
|
||||
JsonBeatmapDecoder.Register();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -33,17 +34,18 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
if (line == null || !decoders.ContainsKey(line))
|
||||
throw new IOException(@"Unknown file format");
|
||||
return (Decoder)Activator.CreateInstance(decoders[line], line);
|
||||
|
||||
return decoders[line](line);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the <see cref="Decoder"/> to the list of <see cref="Beatmap"/> and <see cref="Storyboard"/> decoder.
|
||||
/// Registers an instantiation function for a <see cref="Decoder"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type to decode a <see cref="Beatmap"/> with.</typeparam>
|
||||
/// <param name="version">A string representation of the version.</param>
|
||||
protected static void AddDecoder<T>(string version) where T : Decoder
|
||||
/// <param name="magic">A string in the file which triggers this decoder to be used.</param>
|
||||
/// <param name="constructor">A function which constructs the <see cref="Decoder"/> given <paramref name="magic"/>.</param>
|
||||
protected static void AddDecoder(string magic, Func<string, Decoder> constructor)
|
||||
{
|
||||
decoders[version] = typeof(T);
|
||||
decoders[magic] = constructor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
35
osu.Game/Beatmaps/Formats/JsonBeatmapDecoder.cs
Normal file
35
osu.Game/Beatmaps/Formats/JsonBeatmapDecoder.cs
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.IO;
|
||||
using osu.Game.IO.Serialization;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public class JsonBeatmapDecoder : Decoder
|
||||
{
|
||||
public static void Register()
|
||||
{
|
||||
AddDecoder("{", m => new JsonBeatmapDecoder());
|
||||
}
|
||||
|
||||
public override Decoder GetStoryboardDecoder() => this;
|
||||
|
||||
protected override void ParseBeatmap(StreamReader stream, Beatmap beatmap)
|
||||
{
|
||||
stream.BaseStream.Position = 0;
|
||||
stream.DiscardBufferedData();
|
||||
|
||||
stream.ReadToEnd().DeserializeInto(beatmap);
|
||||
|
||||
foreach (var hitObject in beatmap.HitObjects)
|
||||
hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
|
||||
}
|
||||
|
||||
protected override void ParseStoryboard(StreamReader stream, Storyboard storyboard)
|
||||
{
|
||||
// throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -313,7 +313,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
stringSampleSet = @"normal";
|
||||
|
||||
DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(time);
|
||||
SoundControlPoint soundPoint = beatmap.ControlPointInfo.SoundPointAt(time);
|
||||
SampleControlPoint samplePoint = beatmap.ControlPointInfo.SamplePointAt(time);
|
||||
EffectControlPoint effectPoint = beatmap.ControlPointInfo.EffectPointAt(time);
|
||||
|
||||
if (timingChange)
|
||||
@ -336,9 +336,9 @@ namespace osu.Game.Beatmaps.Formats
|
||||
});
|
||||
}
|
||||
|
||||
if (stringSampleSet != soundPoint.SampleBank || sampleVolume != soundPoint.SampleVolume)
|
||||
if (stringSampleSet != samplePoint.SampleBank || sampleVolume != samplePoint.SampleVolume)
|
||||
{
|
||||
beatmap.ControlPointInfo.SoundPoints.Add(new SoundControlPoint
|
||||
beatmap.ControlPointInfo.SamplePoints.Add(new SampleControlPoint
|
||||
{
|
||||
Time = time,
|
||||
SampleBank = stringSampleSet,
|
||||
|
@ -13,18 +13,18 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public static void Register()
|
||||
{
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v14");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v13");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v12");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v11");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v10");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v9");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v8");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v7");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v6");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v5");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v4");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v3");
|
||||
AddDecoder(@"osu file format v14", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v13", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v12", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v11", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v10", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v9", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v8", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v7", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v6", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v5", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v4", m => new LegacyBeatmapDecoder(m));
|
||||
AddDecoder(@"osu file format v3", m => new LegacyBeatmapDecoder(m));
|
||||
// TODO: differences between versions
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Framework.IO.File;
|
||||
using System.IO;
|
||||
using osu.Game.IO.Serialization;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -38,6 +42,17 @@ namespace osu.Game.Beatmaps
|
||||
storyboard = new AsyncLazy<Storyboard>(populateStoryboard);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the <see cref="Beatmap"/>.
|
||||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
var path = FileSafety.GetTempPath(Guid.NewGuid().ToString().Replace("-", string.Empty) + ".json");
|
||||
using (var sw = new StreamWriter(path))
|
||||
sw.WriteLine(Beatmap.Serialize());
|
||||
Process.Start(path);
|
||||
}
|
||||
|
||||
protected abstract Beatmap GetBeatmap();
|
||||
protected abstract Texture GetBackground();
|
||||
protected abstract Track GetTrack();
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Caching;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -47,7 +48,16 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set
|
||||
{
|
||||
values = value.ToArray();
|
||||
applyPath();
|
||||
|
||||
float max = values.Max(), min = values.Min();
|
||||
if (MaxValue > max) max = MaxValue.Value;
|
||||
if (MinValue < min) min = MinValue.Value;
|
||||
|
||||
ActualMaxValue = max;
|
||||
ActualMinValue = min;
|
||||
|
||||
pathCached.Invalidate();
|
||||
|
||||
maskingContainer.Width = 0;
|
||||
maskingContainer.ResizeWidthTo(1, transform_duration, Easing.OutQuint);
|
||||
}
|
||||
@ -63,13 +73,28 @@ namespace osu.Game.Graphics.UserInterface
|
||||
});
|
||||
}
|
||||
|
||||
private bool pending;
|
||||
|
||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||
{
|
||||
if ((invalidation & Invalidation.DrawSize) != 0)
|
||||
applyPath();
|
||||
if ((invalidation & Invalidation.DrawSize) > 0)
|
||||
pathCached.Invalidate();
|
||||
|
||||
return base.Invalidate(invalidation, source, shallPropagate);
|
||||
}
|
||||
|
||||
private Cached pathCached = new Cached();
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (!pathCached.IsValid)
|
||||
{
|
||||
applyPath();
|
||||
pathCached.Validate();
|
||||
}
|
||||
}
|
||||
|
||||
private void applyPath()
|
||||
{
|
||||
path.ClearVertices();
|
||||
@ -77,13 +102,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
int count = Math.Max(values.Length, DefaultValueCount);
|
||||
|
||||
float max = values.Max(), min = values.Min();
|
||||
if (MaxValue > max) max = MaxValue.Value;
|
||||
if (MinValue < min) min = MinValue.Value;
|
||||
|
||||
ActualMaxValue = max;
|
||||
ActualMinValue = min;
|
||||
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1;
|
||||
|
100
osu.Game/IO/Serialization/Converters/TypedListConverter.cs
Normal file
100
osu.Game/IO/Serialization/Converters/TypedListConverter.cs
Normal file
@ -0,0 +1,100 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace osu.Game.IO.Serialization.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// A type of <see cref="JsonConverter"/> that serializes a <see cref="List<T>"/> alongside
|
||||
/// a lookup table for the types contained. The lookup table is used in deserialization to
|
||||
/// reconstruct the objects with their original types.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of objects contained in the <see cref="List<T>"/> this attribute is attached to.</typeparam>
|
||||
public class TypedListConverter<T> : JsonConverter
|
||||
{
|
||||
private readonly bool requiresTypeVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="TypedListConverter{T}"/>.
|
||||
/// </summary>
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public TypedListConverter()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="TypedListConverter{T}"/>.
|
||||
/// </summary>
|
||||
/// <param name="requiresTypeVersion">Whether the version of the type should be serialized.</param>
|
||||
// ReSharper disable once UnusedMember.Global (Used in Beatmap)
|
||||
public TypedListConverter(bool requiresTypeVersion)
|
||||
{
|
||||
this.requiresTypeVersion = requiresTypeVersion;
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(List<T>);
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
var list = new List<T>();
|
||||
|
||||
var obj = JObject.Load(reader);
|
||||
var lookupTable = serializer.Deserialize<List<string>>(obj["lookup_table"].CreateReader());
|
||||
|
||||
foreach (var tok in obj["items"])
|
||||
{
|
||||
var itemReader = tok.CreateReader();
|
||||
|
||||
var typeName = lookupTable[(int)tok["type"]];
|
||||
var instance = (T)Activator.CreateInstance(Type.GetType(typeName));
|
||||
serializer.Populate(itemReader, instance);
|
||||
|
||||
list.Add(instance);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
var list = (List<T>)value;
|
||||
|
||||
var lookupTable = new List<string>();
|
||||
var objects = new List<JObject>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var type = item.GetType();
|
||||
var assemblyName = type.Assembly.GetName();
|
||||
|
||||
var typeString = $"{type.FullName}, {assemblyName.Name}";
|
||||
if (requiresTypeVersion)
|
||||
typeString += $", {assemblyName.Version}";
|
||||
|
||||
int typeId = lookupTable.IndexOf(typeString);
|
||||
if (typeId == -1)
|
||||
{
|
||||
lookupTable.Add(typeString);
|
||||
typeId = lookupTable.Count - 1;
|
||||
}
|
||||
|
||||
var itemObject = JObject.FromObject(item, serializer);
|
||||
itemObject.AddFirst(new JProperty("type", typeId));
|
||||
objects.Add(itemObject);
|
||||
}
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WritePropertyName("lookup_table");
|
||||
serializer.Serialize(writer, lookupTable);
|
||||
|
||||
writer.WritePropertyName("items");
|
||||
serializer.Serialize(writer, objects);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
38
osu.Game/IO/Serialization/Converters/Vector2Converter.cs
Normal file
38
osu.Game/IO/Serialization/Converters/Vector2Converter.cs
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.IO.Serialization.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// A type of <see cref="JsonConverter"/> that serializes only the X and Y coordinates of a <see cref="Vector2"/>.
|
||||
/// </summary>
|
||||
public class Vector2Converter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(Vector2);
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
var obj = JObject.Load(reader);
|
||||
return new Vector2((float)obj["x"], (float)obj["y"]);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
var vector = (Vector2)value;
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WritePropertyName("x");
|
||||
writer.WriteValue(vector.X);
|
||||
writer.WritePropertyName("y");
|
||||
writer.WriteValue(vector.Y);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.IO.Serialization.Converters;
|
||||
|
||||
namespace osu.Game.IO.Serialization
|
||||
{
|
||||
@ -11,20 +12,26 @@ namespace osu.Game.IO.Serialization
|
||||
|
||||
public static class JsonSerializableExtensions
|
||||
{
|
||||
public static string Serialize(this IJsonSerializable obj)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
|
||||
}
|
||||
public static string Serialize(this IJsonSerializable obj) => JsonConvert.SerializeObject(obj, CreateGlobalSettings());
|
||||
|
||||
public static T Deserialize<T>(this string objString)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(objString);
|
||||
}
|
||||
public static T Deserialize<T>(this string objString) => JsonConvert.DeserializeObject<T>(objString, CreateGlobalSettings());
|
||||
|
||||
public static T DeepClone<T>(this T obj)
|
||||
where T : IJsonSerializable
|
||||
public static void DeserializeInto<T>(this string objString, T target) => JsonConvert.PopulateObject(objString, target, CreateGlobalSettings());
|
||||
|
||||
public static T DeepClone<T>(this T obj) where T : IJsonSerializable => Deserialize<T>(Serialize(obj));
|
||||
|
||||
/// <summary>
|
||||
/// Creates the default <see cref="JsonSerializerSettings"/> that should be used for all <see cref="IJsonSerializable"/>s.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static JsonSerializerSettings CreateGlobalSettings() => new JsonSerializerSettings
|
||||
{
|
||||
return Deserialize<T>(Serialize(obj));
|
||||
}
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
Formatting = Formatting.Indented,
|
||||
ObjectCreationHandling = ObjectCreationHandling.Replace,
|
||||
DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate,
|
||||
Converters = new JsonConverter[] { new Vector2Converter() },
|
||||
ContractResolver = new KeyContractResolver()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
16
osu.Game/IO/Serialization/KeyContractResolver.cs
Normal file
16
osu.Game/IO/Serialization/KeyContractResolver.cs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using Humanizer;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace osu.Game.IO.Serialization
|
||||
{
|
||||
public class KeyContractResolver : DefaultContractResolver
|
||||
{
|
||||
protected override string ResolvePropertyName(string propertyName)
|
||||
{
|
||||
return propertyName.Underscore();
|
||||
}
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ namespace osu.Game
|
||||
|
||||
private MusicController musicController;
|
||||
|
||||
private NotificationOverlay notificationOverlay;
|
||||
private NotificationOverlay notifications;
|
||||
|
||||
private DialogOverlay dialogOverlay;
|
||||
|
||||
@ -136,7 +136,7 @@ namespace osu.Game
|
||||
|
||||
if (s.Beatmap == null)
|
||||
{
|
||||
notificationOverlay.Post(new SimpleNotification
|
||||
notifications.Post(new SimpleNotification
|
||||
{
|
||||
Text = @"Tried to load a score for a beatmap we don't have!",
|
||||
Icon = FontAwesome.fa_life_saver,
|
||||
@ -154,7 +154,7 @@ namespace osu.Game
|
||||
base.LoadComplete();
|
||||
|
||||
// hook up notifications to components.
|
||||
BeatmapManager.PostNotification = n => notificationOverlay?.Post(n);
|
||||
BeatmapManager.PostNotification = n => notifications?.Post(n);
|
||||
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
|
||||
|
||||
AddRange(new Drawable[]
|
||||
@ -207,8 +207,9 @@ namespace osu.Game
|
||||
Origin = Anchor.TopRight,
|
||||
}, overlayContent.Add);
|
||||
|
||||
loadComponentSingleFile(notificationOverlay = new NotificationOverlay
|
||||
loadComponentSingleFile(notifications = new NotificationOverlay
|
||||
{
|
||||
GetToolbarHeight = () => ToolbarOffset,
|
||||
Depth = -4,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
@ -223,7 +224,7 @@ namespace osu.Game
|
||||
{
|
||||
if (entry.Level < LogLevel.Important) return;
|
||||
|
||||
notificationOverlay.Post(new SimpleNotification
|
||||
notifications.Post(new SimpleNotification
|
||||
{
|
||||
Text = $@"{entry.Level}: {entry.Message}"
|
||||
});
|
||||
@ -236,7 +237,7 @@ namespace osu.Game
|
||||
dependencies.Cache(userProfile);
|
||||
dependencies.Cache(musicController);
|
||||
dependencies.Cache(beatmapSetOverlay);
|
||||
dependencies.Cache(notificationOverlay);
|
||||
dependencies.Cache(notifications);
|
||||
dependencies.Cache(dialogOverlay);
|
||||
|
||||
// ensure only one of these overlays are open at once.
|
||||
@ -271,18 +272,20 @@ namespace osu.Game
|
||||
};
|
||||
}
|
||||
|
||||
settings.StateChanged += delegate
|
||||
void updateScreenOffset()
|
||||
{
|
||||
switch (settings.State)
|
||||
{
|
||||
case Visibility.Hidden:
|
||||
intro.MoveToX(0, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
break;
|
||||
case Visibility.Visible:
|
||||
intro.MoveToX(SettingsOverlay.SIDEBAR_WIDTH / 2, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
break;
|
||||
}
|
||||
};
|
||||
float offset = 0;
|
||||
|
||||
if (settings.State == Visibility.Visible)
|
||||
offset += ToolbarButton.WIDTH / 2;
|
||||
if (notifications.State == Visibility.Visible)
|
||||
offset -= ToolbarButton.WIDTH / 2;
|
||||
|
||||
screenStack.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
|
||||
}
|
||||
|
||||
settings.StateChanged += _ => updateScreenOffset();
|
||||
notifications.StateChanged += _ => updateScreenOffset();
|
||||
|
||||
Cursor.State = Visibility.Hidden;
|
||||
}
|
||||
@ -351,7 +354,7 @@ namespace osu.Game
|
||||
direct.State = Visibility.Hidden;
|
||||
social.State = Visibility.Hidden;
|
||||
userProfile.State = Visibility.Hidden;
|
||||
notificationOverlay.State = Visibility.Hidden;
|
||||
notifications.State = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void screenChanged(Screen newScreen)
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -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,
|
||||
|
@ -10,6 +10,8 @@ using osu.Game.Overlays.Notifications;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using System;
|
||||
using osu.Framework.Configuration;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -19,9 +21,13 @@ namespace osu.Game.Overlays
|
||||
|
||||
public const float TRANSITION_LENGTH = 600;
|
||||
|
||||
private ScrollContainer scrollContainer;
|
||||
private FlowContainer<NotificationSection> sections;
|
||||
|
||||
/// <summary>
|
||||
/// Provide a source for the toolbar height.
|
||||
/// </summary>
|
||||
public Func<float> GetToolbarHeight;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -36,12 +42,12 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.6f,
|
||||
Alpha = 0.6f
|
||||
},
|
||||
scrollContainer = new OsuScrollContainer
|
||||
new OsuScrollContainer
|
||||
{
|
||||
Masking = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Margin = new MarginPadding { Top = Toolbar.Toolbar.HEIGHT },
|
||||
Children = new[]
|
||||
{
|
||||
sections = new FillFlowContainer<NotificationSection>
|
||||
@ -55,14 +61,14 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
Title = @"Notifications",
|
||||
ClearText = @"Clear All",
|
||||
AcceptTypes = new[] { typeof(SimpleNotification) },
|
||||
AcceptTypes = new[] { typeof(SimpleNotification) }
|
||||
},
|
||||
new NotificationSection
|
||||
{
|
||||
Title = @"Running Tasks",
|
||||
ClearText = @"Cancel All",
|
||||
AcceptTypes = new[] { typeof(ProgressNotification) },
|
||||
},
|
||||
AcceptTypes = new[] { typeof(ProgressNotification) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,47 +76,45 @@ 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)
|
||||
if (totalCount == 0)
|
||||
State = Visibility.Hidden;
|
||||
|
||||
updateCounts();
|
||||
}
|
||||
|
||||
public void Post(Notification notification)
|
||||
public void Post(Notification notification) => Schedule(() =>
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
State = Visibility.Visible;
|
||||
++runningDepth;
|
||||
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
|
||||
|
||||
++runningDepth;
|
||||
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
|
||||
notification.Closed += notificationClosed;
|
||||
|
||||
notification.Closed += notificationClosed;
|
||||
var hasCompletionTarget = notification as IHasCompletionTarget;
|
||||
if (hasCompletionTarget != null)
|
||||
hasCompletionTarget.CompletionTarget = Post;
|
||||
|
||||
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);
|
||||
|
||||
var ourType = notification.GetType();
|
||||
sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification);
|
||||
});
|
||||
}
|
||||
updateCounts();
|
||||
});
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
base.PopIn();
|
||||
|
||||
scrollContainer.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
this.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
this.FadeTo(1, TRANSITION_LENGTH / 2);
|
||||
}
|
||||
|
||||
private void markAllRead()
|
||||
{
|
||||
sections.Children.ForEach(s => s.MarkAllRead());
|
||||
this.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
@ -120,7 +124,26 @@ namespace osu.Game.Overlays
|
||||
markAllRead();
|
||||
|
||||
this.MoveToX(width, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
this.FadeTo(0, TRANSITION_LENGTH / 2);
|
||||
this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void updateCounts()
|
||||
{
|
||||
UnreadCount.Value = unreadCount;
|
||||
}
|
||||
|
||||
private void markAllRead()
|
||||
{
|
||||
sections.Children.ForEach(s => s.MarkAllRead());
|
||||
|
||||
updateCounts();
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,4 +261,4 @@ namespace osu.Game.Overlays.Notifications
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ 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;
|
||||
@ -157,4 +159,4 @@ namespace osu.Game.Overlays.Notifications
|
||||
notifications?.Children.ForEach(n => n.Read = true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,7 +95,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
|
||||
protected virtual void Completed()
|
||||
{
|
||||
Expire();
|
||||
base.Close();
|
||||
CompletionTarget?.Invoke(CreateCompletionNotification());
|
||||
}
|
||||
|
||||
@ -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;
|
||||
})
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -27,8 +27,10 @@ namespace osu.Game.Overlays.Profile
|
||||
private readonly OsuTextFlowContainer infoTextLeft;
|
||||
private readonly LinkFlowContainer infoTextRight;
|
||||
private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText;
|
||||
private readonly RankGraph rankGraph;
|
||||
|
||||
private readonly Container coverContainer, chartContainer, supporterTag;
|
||||
public readonly SupporterIcon SupporterTag;
|
||||
private readonly Container coverContainer;
|
||||
private readonly Sprite levelBadge;
|
||||
private readonly SpriteText levelText;
|
||||
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
|
||||
@ -93,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)
|
||||
{
|
||||
@ -273,7 +256,7 @@ namespace osu.Game.Overlays.Profile
|
||||
}
|
||||
}
|
||||
},
|
||||
chartContainer = new Container
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
@ -285,6 +268,10 @@ namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
Colour = Color4.Black.Opacity(0.25f),
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
rankGraph = new RankGraph
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -303,11 +290,7 @@ namespace osu.Game.Overlays.Profile
|
||||
|
||||
public User User
|
||||
{
|
||||
get
|
||||
{
|
||||
return user;
|
||||
}
|
||||
|
||||
get { return user; }
|
||||
set
|
||||
{
|
||||
user = value;
|
||||
@ -327,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))
|
||||
{
|
||||
@ -420,7 +404,7 @@ namespace osu.Game.Overlays.Profile
|
||||
gradeSPlus.DisplayCount = 0;
|
||||
gradeSSPlus.DisplayCount = 0;
|
||||
|
||||
chartContainer.Add(new RankChart(user) { RelativeSizeAxes = Axes.Both });
|
||||
rankGraph.User.Value = user;
|
||||
}
|
||||
}
|
||||
|
||||
@ -472,7 +456,7 @@ namespace osu.Game.Overlays.Profile
|
||||
Width = width,
|
||||
Height = 26
|
||||
});
|
||||
Add(numberText = new SpriteText
|
||||
Add(numberText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
|
@ -14,30 +14,39 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Users;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Configuration;
|
||||
|
||||
namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
public class RankChart : Container
|
||||
public class RankGraph : Container
|
||||
{
|
||||
private const float primary_textsize = 25;
|
||||
private const float secondary_textsize = 13;
|
||||
private const float padding = 10;
|
||||
private const float fade_duration = 150;
|
||||
private const int ranked_days = 88;
|
||||
|
||||
private readonly SpriteText rankText, performanceText, relativeText;
|
||||
private readonly RankChartLineGraph graph;
|
||||
private readonly OsuSpriteText placeholder;
|
||||
|
||||
private readonly int[] ranks;
|
||||
private KeyValuePair<int, int>[] ranks;
|
||||
public Bindable<User> User = new Bindable<User>();
|
||||
|
||||
private const float primary_textsize = 25, secondary_textsize = 13, padding = 10;
|
||||
|
||||
private readonly User user;
|
||||
|
||||
public RankChart(User user)
|
||||
public RankGraph()
|
||||
{
|
||||
this.user = user;
|
||||
|
||||
int[] userRanks = user.RankHistory?.Data ?? new[] { user.Statistics.Rank };
|
||||
ranks = userRanks.SkipWhile(x => x == 0).ToArray();
|
||||
|
||||
Padding = new MarginPadding { Vertical = padding };
|
||||
Children = new Drawable[]
|
||||
{
|
||||
placeholder = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = "No recent plays",
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-RegularItalic",
|
||||
},
|
||||
rankText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
@ -60,89 +69,103 @@ namespace osu.Game.Overlays.Profile
|
||||
Font = @"Exo2.0-RegularItalic",
|
||||
TextSize = secondary_textsize
|
||||
},
|
||||
};
|
||||
|
||||
if (ranks.Length > 0)
|
||||
{
|
||||
Add(graph = new RankChartLineGraph
|
||||
graph = new RankChartLineGraph
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 75,
|
||||
Y = -secondary_textsize,
|
||||
DefaultValueCount = ranks.Length,
|
||||
});
|
||||
Alpha = 0,
|
||||
}
|
||||
};
|
||||
|
||||
graph.OnBallMove += showHistoryRankTexts;
|
||||
}
|
||||
}
|
||||
graph.OnBallMove += showHistoryRankTexts;
|
||||
|
||||
private void updateRankTexts()
|
||||
{
|
||||
rankText.Text = user.Statistics.Rank > 0 ? $"#{user.Statistics.Rank:#,0}" : "no rank";
|
||||
performanceText.Text = user.Statistics.PP != null ? $"{user.Statistics.PP:#,0}pp" : string.Empty;
|
||||
relativeText.Text = user.CountryRank > 0 ? $"{user.Country?.FullName} #{user.CountryRank:#,0}" : $"{user.Country?.FullName}";
|
||||
}
|
||||
|
||||
private void showHistoryRankTexts(int dayIndex)
|
||||
{
|
||||
rankText.Text = ranks[dayIndex] > 0 ? $"#{ranks[dayIndex]:#,0}" : "no rank";
|
||||
dayIndex++;
|
||||
relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago";
|
||||
//plural should be handled in a general way
|
||||
User.ValueChanged += userChanged;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
if (graph != null)
|
||||
graph.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
private void userChanged(User user)
|
||||
{
|
||||
placeholder.FadeIn(fade_duration, Easing.Out);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
graph.Colour = colours.Yellow;
|
||||
// use logarithmic coordinates
|
||||
graph.Values = ranks.Select(x => x == 0 ? float.MinValue : -(float)Math.Log(x));
|
||||
rankText.Text = string.Empty;
|
||||
performanceText.Text = string.Empty;
|
||||
relativeText.Text = string.Empty;
|
||||
graph.FadeOut(fade_duration, Easing.Out);
|
||||
ranks = null;
|
||||
return;
|
||||
}
|
||||
|
||||
int[] userRanks = user.RankHistory?.Data ?? new[] { user.Statistics.Rank };
|
||||
ranks = userRanks.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray();
|
||||
|
||||
if (ranks.Length > 1)
|
||||
{
|
||||
placeholder.FadeOut(fade_duration, Easing.Out);
|
||||
|
||||
graph.DefaultValueCount = ranks.Length;
|
||||
graph.Values = ranks.Select(x => -(float)Math.Log(x.Value));
|
||||
graph.SetStaticBallPosition();
|
||||
}
|
||||
|
||||
graph.FadeTo(ranks.Length > 1 ? 1 : 0, fade_duration, Easing.Out);
|
||||
|
||||
updateRankTexts();
|
||||
}
|
||||
|
||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||
private void updateRankTexts()
|
||||
{
|
||||
if ((invalidation & Invalidation.DrawSize) != 0)
|
||||
{
|
||||
graph.Height = DrawHeight - padding * 2 - primary_textsize - secondary_textsize * 2;
|
||||
}
|
||||
rankText.Text = User.Value.Statistics.Rank > 0 ? $"#{User.Value.Statistics.Rank:#,0}" : "no rank";
|
||||
performanceText.Text = User.Value.Statistics.PP != null ? $"{User.Value.Statistics.PP:#,0}pp" : string.Empty;
|
||||
relativeText.Text = $"{User.Value.Country?.FullName} #{User.Value.CountryRank:#,0}";
|
||||
}
|
||||
|
||||
return base.Invalidate(invalidation, source, shallPropagate);
|
||||
private void showHistoryRankTexts(int dayIndex)
|
||||
{
|
||||
rankText.Text = $"#{ranks[dayIndex].Value:#,0}";
|
||||
relativeText.Text = dayIndex + 1 == ranks.Length ? "Now" : $"{ranked_days - ranks[dayIndex].Key} days ago";
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
graph?.UpdateBallPosition(state.Mouse.Position.X);
|
||||
graph?.ShowBall();
|
||||
if (ranks?.Length > 1)
|
||||
{
|
||||
graph.UpdateBallPosition(state.Mouse.Position.X);
|
||||
graph.ShowBall();
|
||||
}
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(InputState state)
|
||||
{
|
||||
graph?.UpdateBallPosition(state.Mouse.Position.X);
|
||||
if (ranks?.Length > 1)
|
||||
graph.UpdateBallPosition(state.Mouse.Position.X);
|
||||
|
||||
return base.OnMouseMove(state);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
if (graph != null)
|
||||
if (ranks?.Length > 1)
|
||||
{
|
||||
graph.HideBall();
|
||||
updateRankTexts();
|
||||
}
|
||||
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
private class RankChartLineGraph : LineGraph
|
||||
{
|
||||
private const double fade_duration = 200;
|
||||
|
||||
private readonly CircularContainer staticBall;
|
||||
private readonly CircularContainer movingBall;
|
||||
|
@ -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,
|
||||
|
61
osu.Game/Overlays/Profile/SupporterIcon.cs
Normal file
61
osu.Game/Overlays/Profile/SupporterIcon.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
public const float TRANSITION_LENGTH = 600;
|
||||
|
||||
public const float SIDEBAR_WIDTH = Sidebar.DEFAULT_WIDTH;
|
||||
private const float sidebar_width = Sidebar.DEFAULT_WIDTH;
|
||||
|
||||
protected const float WIDTH = 400;
|
||||
|
||||
@ -102,7 +102,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
if (showSidebar)
|
||||
{
|
||||
AddInternal(Sidebar = new Sidebar { Width = SIDEBAR_WIDTH });
|
||||
AddInternal(Sidebar = new Sidebar { Width = sidebar_width });
|
||||
|
||||
SectionsContainer.SelectedSection.ValueChanged += section =>
|
||||
{
|
||||
@ -167,7 +167,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
ContentContainer.MoveToX(-WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
|
||||
Sidebar?.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
Sidebar?.MoveToX(-sidebar_width, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
|
||||
searchTextBox.HoldFocus = false;
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
SetIcon(FontAwesome.fa_comments);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(ChatOverlay chat)
|
||||
{
|
||||
StateContainer = chat;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Icon = FontAwesome.fa_music;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(MusicController music)
|
||||
{
|
||||
StateContainer = music;
|
||||
|
@ -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",
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
TooltipSub = "Change your settings";
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(SettingsOverlay settings)
|
||||
{
|
||||
StateContainer = settings;
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Icon = FontAwesome.fa_users;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(SocialOverlay chat)
|
||||
{
|
||||
StateContainer = chat;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user