Merge remote-tracking branch 'refs/remotes/ppy/master' into pause_buttons_refactor

This commit is contained in:
Andrey Zavadskiy
2017-04-04 18:41:37 +03:00
93 changed files with 1203 additions and 855 deletions

View File

@ -3,15 +3,12 @@
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Threading;
using osu.Game.Overlays; using osu.Game.Overlays;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
internal class TestCaseChatDisplay : TestCase internal class TestCaseChatDisplay : TestCase
{ {
private ScheduledDelegate messageRequest;
public override string Description => @"Testing chat api and overlay"; public override string Description => @"Testing chat api and overlay";
public override void Reset() public override void Reset()

View File

@ -112,7 +112,7 @@ namespace osu.Desktop.VisualTests.Tests
Width = 150, Width = 150,
Height = 10, Height = 10,
SelectionColor = Color4.Orange, SelectionColor = Color4.Orange,
Bindable = playbackSpeed Value = playbackSpeed
} }
} }
}); });

View File

@ -57,7 +57,7 @@ namespace osu.Desktop.VisualTests.Tests
Width = 150, Width = 150,
Height = 10, Height = 10,
SelectionColor = Color4.Orange, SelectionColor = Color4.Orange,
Bindable = bindable Value = bindable
} }
} }
}); });

View File

@ -14,7 +14,7 @@ namespace osu.Desktop.VisualTests.Tests
{ {
internal class TestCasePlaySongSelect : TestCase internal class TestCasePlaySongSelect : TestCase
{ {
private BeatmapDatabase db, oldDb; private BeatmapDatabase db;
private TestStorage storage; private TestStorage storage;
private PlaySongSelect songSelect; private PlaySongSelect songSelect;
@ -44,13 +44,13 @@ namespace osu.Desktop.VisualTests.Tests
AddStep(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; }); AddStep(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; });
} }
protected override void Dispose(bool isDisposing) //protected override void Dispose(bool isDisposing)
{ //{
if (oldDb != null) // if (oldDb != null)
db = null; // db = null;
base.Dispose(isDisposing); // base.Dispose(isDisposing);
} //}
private BeatmapSetInfo createTestBeatmapSet(int i) private BeatmapSetInfo createTestBeatmapSet(int i)
{ {

View File

@ -1,24 +1,15 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Input.Handlers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Modes.Mods; using osu.Game.Modes.Mods;
using osu.Game.Modes.Osu.Mods; using osu.Game.Modes.Osu.Mods;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using System;
using System.IO;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
internal class TestCaseReplay : TestCasePlayer internal class TestCaseReplay : TestCasePlayer
{ {
private WorkingBeatmap beatmap;
private InputHandler replay;
private Func<Stream> getReplayStream;
public override string Description => @"Testing replay playback."; public override string Description => @"Testing replay playback.";
protected override Player CreatePlayer(WorkingBeatmap beatmap) protected override Player CreatePlayer(WorkingBeatmap beatmap)

View File

@ -22,8 +22,6 @@ namespace osu.Desktop.VisualTests.Tests
int numerator = 0, denominator = 0; int numerator = 0, denominator = 0;
bool maniaHold = false;
ScoreCounter score = new ScoreCounter(7) ScoreCounter score = new ScoreCounter(7)
{ {
Origin = Anchor.TopRight, Origin = Anchor.TopRight,

View File

@ -36,9 +36,9 @@ namespace osu.Desktop.VisualTests.Tests
filter.PinItem(GroupMode.All); filter.PinItem(GroupMode.All);
filter.PinItem(GroupMode.RecentlyPlayed); filter.PinItem(GroupMode.RecentlyPlayed);
filter.ItemChanged += (sender, mode) => filter.SelectedItem.ValueChanged += newFilter =>
{ {
text.Text = "Currently Selected: " + mode.ToString(); text.Text = "Currently Selected: " + newFilter.ToString();
}; };
} }
} }

View File

@ -1,13 +1,12 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Graphics; using osu.Game.Modes.Taiko.Objects.Drawables.Pieces;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
@ -24,7 +23,7 @@ namespace osu.Desktop.VisualTests.Tests
AddToggleStep("Kiai", b => AddToggleStep("Kiai", b =>
{ {
kiai = !kiai; kiai = !kiai;
Reset(); updateKiaiState();
}); });
Add(new CirclePiece Add(new CirclePiece
@ -87,37 +86,27 @@ namespace osu.Desktop.VisualTests.Tests
} }
}); });
Add(new DrumRollCircle(new CirclePiece Add(new CirclePiece
{ {
KiaiMode = kiai Position = new Vector2(575, 100),
}) Width = 0.25f,
{ AccentColour = Color4.Orange,
Width = 250, KiaiMode = kiai,
Position = new Vector2(575, 100)
}); });
Add(new DrumRollCircle(new StrongCirclePiece Add(new StrongCirclePiece
{ {
Position = new Vector2(575, 300),
Width = 0.25f,
AccentColour = Color4.Orange,
KiaiMode = kiai KiaiMode = kiai
})
{
Width = 250,
Position = new Vector2(575, 300)
}); });
} }
private class DrumRollCircle : BaseCircle private void updateKiaiState()
{ {
public DrumRollCircle(CirclePiece piece) foreach (var c in Children.OfType<CirclePiece>())
: base(piece) c.KiaiMode = kiai;
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Piece.AccentColour = colours.YellowDark;
}
} }
private abstract class BaseCircle : Container private abstract class BaseCircle : Container

View File

@ -3,13 +3,12 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements; using osu.Game.Modes.Taiko.Judgements;
using osu.Game.Modes.Taiko.Objects; using osu.Game.Modes.Taiko.Objects;
using osu.Game.Modes.Taiko.Objects.Drawable; using osu.Game.Modes.Taiko.Objects.Drawables;
using osu.Game.Modes.Taiko.UI; using osu.Game.Modes.Taiko.UI;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
@ -20,23 +19,28 @@ namespace osu.Desktop.VisualTests.Tests
private TaikoPlayfield playfield; private TaikoPlayfield playfield;
protected override double TimePerAction => 500;
public override void Reset() public override void Reset()
{ {
base.Reset(); base.Reset();
AddStep("Hit!", addHitJudgement); AddStep("Hit!", addHitJudgement);
AddStep("Miss :(", addMissJudgement); AddStep("Miss :(", addMissJudgement);
AddStep("DrumRoll", () => addDrumRoll(false));
AddStep("Strong DrumRoll", () => addDrumRoll(true));
AddStep("Swell", addSwell); AddStep("Swell", addSwell);
AddStep("Centre", () => addCentreHit(false)); AddStep("Centre", () => addCentreHit(false));
AddStep("Strong Centre", () => addCentreHit(true)); AddStep("Strong Centre", () => addCentreHit(true));
AddStep("Rim", () => addRimHit(false)); AddStep("Rim", () => addRimHit(false));
AddStep("Strong Rim", () => addRimHit(true)); AddStep("Strong Rim", () => addRimHit(true));
AddStep("Add bar line", () => addBarLine(false));
AddStep("Add major bar line", () => addBarLine(true));
Add(new Container Add(new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Y = 200, Y = 200,
Padding = new MarginPadding { Left = 200 },
Children = new[] Children = new[]
{ {
playfield = new TaikoPlayfield() playfield = new TaikoPlayfield()
@ -73,16 +77,39 @@ namespace osu.Desktop.VisualTests.Tests
}); });
} }
private void addBarLine(bool major)
{
BarLine bl = new BarLine
{
StartTime = Time.Current + 1000,
PreEmpt = 1000
};
playfield.AddBarLine(major ? new DrawableMajorBarLine(bl) : new DrawableBarLine(bl));
}
private void addSwell() private void addSwell()
{ {
playfield.Add(new DrawableSwell(new Swell playfield.Add(new DrawableSwell(new Swell
{ {
StartTime = Time.Current + 1000, StartTime = Time.Current + 1000,
EndTime = Time.Current + 5000, EndTime = Time.Current + 1000,
PreEmpt = 1000 PreEmpt = 1000
})); }));
} }
private void addDrumRoll(bool strong)
{
var d = new DrumRoll
{
StartTime = Time.Current + 1000,
Distance = 1000,
PreEmpt = 1000,
};
playfield.Add(strong ? new DrawableStrongDrumRoll(d) : new DrawableDrumRoll(d));
}
private void addCentreHit(bool strong) private void addCentreHit(bool strong)
{ {
Hit h = new Hit Hit h = new Hit

View File

@ -14,7 +14,7 @@ namespace osu.Desktop.VisualTests
{ {
base.LoadComplete(); base.LoadComplete();
new BackgroundScreenDefault { Depth = 10 }.LoadAsync(this, AddInternal); LoadComponentAsync(new BackgroundScreenDefault { Depth = 10 }, AddInternal);
// Have to construct this here, rather than in the constructor, because // Have to construct this here, rather than in the constructor, because
// we depend on some dependencies to be loaded within OsuGameBase.load(). // we depend on some dependencies to be loaded within OsuGameBase.load().

View File

@ -3,10 +3,7 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using osu.Game.Beatmaps.Formats;
using osu.Game.Beatmaps.IO; using osu.Game.Beatmaps.IO;
using osu.Game.Beatmaps;
using osu.Game.Database;
namespace osu.Desktop.Beatmaps.IO namespace osu.Desktop.Beatmaps.IO
{ {
@ -18,20 +15,17 @@ namespace osu.Desktop.Beatmaps.IO
public static void Register() => AddReader<LegacyFilesystemReader>((storage, path) => Directory.Exists(path)); public static void Register() => AddReader<LegacyFilesystemReader>((storage, path) => Directory.Exists(path));
private string basePath { get; } private string basePath { get; }
private Beatmap firstMap { get; }
public LegacyFilesystemReader(string path) public LegacyFilesystemReader(string path)
{ {
basePath = path; basePath = path;
BeatmapFilenames = Directory.GetFiles(basePath, @"*.osu").Select(Path.GetFileName).ToArray(); BeatmapFilenames = Directory.GetFiles(basePath, @"*.osu").Select(Path.GetFileName).ToArray();
if (BeatmapFilenames.Length == 0) if (BeatmapFilenames.Length == 0)
throw new FileNotFoundException(@"This directory contains no beatmaps"); throw new FileNotFoundException(@"This directory contains no beatmaps");
StoryboardFilename = Directory.GetFiles(basePath, @"*.osb").Select(Path.GetFileName).FirstOrDefault(); StoryboardFilename = Directory.GetFiles(basePath, @"*.osb").Select(Path.GetFileName).FirstOrDefault();
using (var stream = new StreamReader(GetStream(BeatmapFilenames[0])))
{
var decoder = BeatmapDecoder.GetDecoder(stream);
firstMap = decoder.Decode(stream);
}
} }
public override Stream GetStream(string name) public override Stream GetStream(string name)
@ -39,11 +33,6 @@ namespace osu.Desktop.Beatmaps.IO
return File.OpenRead(Path.Combine(basePath, name)); return File.OpenRead(Path.Combine(basePath, name));
} }
public override BeatmapMetadata ReadMetadata()
{
return firstMap.BeatmapInfo.Metadata;
}
public override void Dispose() public override void Dispose()
{ {
// no-op // no-op

View File

@ -29,7 +29,7 @@ namespace osu.Desktop
{ {
base.LoadComplete(); base.LoadComplete();
versionManager.LoadAsync(this); LoadComponentAsync(versionManager);
ScreenChanged += s => ScreenChanged += s =>
{ {
if (!versionManager.IsAlive && s is Intro) if (!versionManager.IsAlive && s is Intro)

View File

@ -14,6 +14,11 @@ namespace osu.Game.Modes.Osu.Objects
{ {
public class Slider : OsuHitObject, IHasCurve public class Slider : OsuHitObject, IHasCurve
{ {
/// <summary>
/// Scoring distance with a speed-adjusted beat length of 1 second.
/// </summary>
private const float base_scoring_distance = 100;
public IHasCurve CurveObject { get; set; } public IHasCurve CurveObject { get; set; }
public SliderCurve Curve => CurveObject.Curve; public SliderCurve Curve => CurveObject.Curve;
@ -51,13 +56,10 @@ namespace osu.Game.Modes.Osu.Objects
{ {
base.ApplyDefaults(timing, difficulty); base.ApplyDefaults(timing, difficulty);
ControlPoint overridePoint; double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier / timing.SpeedMultiplierAt(StartTime);
ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint);
var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1;
var baseVelocity = 100 * difficulty.SliderMultiplier / velocityAdjustment;
Velocity = baseVelocity / timingPoint.BeatLength; Velocity = scoringDistance / timing.BeatLengthAt(StartTime);
TickDistance = baseVelocity / difficulty.SliderTickRate; TickDistance = scoringDistance / difficulty.SliderTickRate;
} }
public IEnumerable<SliderTick> Ticks public IEnumerable<SliderTick> Ticks

View File

@ -2,96 +2,160 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Legacy;
using osu.Game.Beatmaps.Samples; using osu.Game.Beatmaps.Samples;
using osu.Game.Modes.Objects; using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Types; using osu.Game.Modes.Objects.Types;
using osu.Game.Modes.Taiko.Objects; using osu.Game.Modes.Taiko.Objects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Game.Database;
namespace osu.Game.Modes.Taiko.Beatmaps namespace osu.Game.Modes.Taiko.Beatmaps
{ {
internal class TaikoBeatmapConverter : IBeatmapConverter<TaikoHitObject> internal class TaikoBeatmapConverter : IBeatmapConverter<TaikoHitObject>
{ {
private const float legacy_velocity_scale = 1.4f; /// <summary>
private const float bash_convert_factor = 1.65f; /// osu! is generally slower than taiko, so a factor is added to increase
/// speed. This must be used everywhere slider length or beat length is used.
/// </summary>
private const float legacy_velocity_multiplier = 1.4f;
/// <summary>
/// Because swells are easier in taiko than spinners are in osu!,
/// legacy taiko multiplies a factor when converting the number of required hits.
/// </summary>
private const float swell_hit_multiplier = 1.65f;
/// <summary>
/// Base osu! slider scoring distance.
/// </summary>
private const float osu_base_scoring_distance = 100;
/// <summary>
/// Drum roll distance that results in a duration of 1 speed-adjusted beat length.
/// </summary>
private const float taiko_base_distance = 100;
public Beatmap<TaikoHitObject> Convert(Beatmap original) public Beatmap<TaikoHitObject> Convert(Beatmap original)
{ {
if (original is LegacyBeatmap)
original.TimingInfo.ControlPoints.ForEach(c => c.VelocityAdjustment /= legacy_velocity_scale);
return new Beatmap<TaikoHitObject>(original) return new Beatmap<TaikoHitObject>(original)
{ {
HitObjects = convertHitObjects(original.HitObjects) HitObjects = original.HitObjects.SelectMany(h => convertHitObject(h, original)).ToList()
}; };
} }
private List<TaikoHitObject> convertHitObjects(List<HitObject> hitObjects) private IEnumerable<TaikoHitObject> convertHitObject(HitObject obj, Beatmap beatmap)
{
return hitObjects.Select(convertHitObject).ToList();
}
private TaikoHitObject convertHitObject(HitObject original)
{ {
// Check if this HitObject is already a TaikoHitObject, and return it if so // Check if this HitObject is already a TaikoHitObject, and return it if so
TaikoHitObject originalTaiko = original as TaikoHitObject; var originalTaiko = obj as TaikoHitObject;
if (originalTaiko != null) if (originalTaiko != null)
return originalTaiko; yield return originalTaiko;
IHasDistance distanceData = original as IHasDistance; var distanceData = obj as IHasDistance;
IHasRepeats repeatsData = original as IHasRepeats; var repeatsData = obj as IHasRepeats;
IHasEndTime endTimeData = original as IHasEndTime; var endTimeData = obj as IHasEndTime;
// Old osu! used hit sounding to determine various hit type information // Old osu! used hit sounding to determine various hit type information
SampleType sample = original.Sample?.Type ?? SampleType.None; SampleType sample = obj.Sample?.Type ?? SampleType.None;
bool strong = (sample & SampleType.Finish) > 0; bool strong = (sample & SampleType.Finish) > 0;
if (distanceData != null) if (distanceData != null)
{ {
return new DrumRoll int repeats = repeatsData?.RepeatCount ?? 1;
{
StartTime = original.StartTime,
Sample = original.Sample,
IsStrong = strong,
Distance = distanceData.Distance * (repeatsData?.RepeatCount ?? 1) double speedAdjustment = beatmap.TimingInfo.SpeedMultiplierAt(obj.StartTime);
double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(obj.StartTime) * speedAdjustment;
// The true distance, accounting for any repeats. This ends up being the drum roll distance later
double distance = distanceData.Distance * repeats * legacy_velocity_multiplier;
// The velocity of the taiko hit object - calculated as the velocity of a drum roll
double taikoVelocity = taiko_base_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier / speedAdjustedBeatLength * legacy_velocity_multiplier;
// The duration of the taiko hit object
double taikoDuration = distance / taikoVelocity;
// For some reason, old osu! always uses speedAdjustment to determine the taiko velocity, but
// only uses it to determine osu! velocity if beatmap version < 8. Let's account for that here.
if (beatmap.BeatmapInfo.BeatmapVersion >= 8)
speedAdjustedBeatLength /= speedAdjustment;
// The velocity of the osu! hit object - calculated as the velocity of a slider
double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier / speedAdjustedBeatLength * legacy_velocity_multiplier;
// The duration of the osu! hit object
double osuDuration = distance / osuVelocity;
// If the drum roll is to be split into hit circles, assume the ticks are 1/8 spaced within the duration of one beat
double tickSpacing = Math.Min(speedAdjustedBeatLength / beatmap.BeatmapInfo.Difficulty.SliderTickRate, taikoDuration / repeats) / 8;
if (tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
{
for (double j = obj.StartTime; j <= distanceData.EndTime + tickSpacing; j += tickSpacing)
{
// Todo: This should generate different type of hits (including strongs)
// depending on hitobject sound additions (not implemented fully yet)
yield return new CentreHit
{
StartTime = j,
Sample = obj.Sample,
IsStrong = strong,
VelocityMultiplier = legacy_velocity_multiplier
}; };
} }
}
if (endTimeData != null) else
{ {
// We compute the end time manually to add in the Bash convert factor yield return new DrumRoll
return new Swell
{ {
StartTime = original.StartTime, StartTime = obj.StartTime,
Sample = original.Sample, Sample = obj.Sample,
IsStrong = strong, IsStrong = strong,
Distance = distance,
EndTime = original.StartTime + endTimeData.Duration * bash_convert_factor TickRate = beatmap.BeatmapInfo.Difficulty.SliderTickRate == 3 ? 3 : 4,
VelocityMultiplier = legacy_velocity_multiplier
}; };
} }
}
else if (endTimeData != null)
{
double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.Difficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier;
yield return new Swell
{
StartTime = obj.StartTime,
Sample = obj.Sample,
IsStrong = strong,
EndTime = endTimeData.EndTime,
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier),
VelocityMultiplier = legacy_velocity_multiplier
};
}
else
{
bool isCentre = (sample & ~(SampleType.Finish | SampleType.Normal)) == 0; bool isCentre = (sample & ~(SampleType.Finish | SampleType.Normal)) == 0;
if (isCentre) if (isCentre)
{ {
return new CentreHit yield return new CentreHit
{ {
StartTime = original.StartTime, StartTime = obj.StartTime,
Sample = original.Sample, Sample = obj.Sample,
IsStrong = strong IsStrong = strong,
VelocityMultiplier = legacy_velocity_multiplier
}; };
} }
else
return new RimHit
{ {
StartTime = original.StartTime, yield return new RimHit
Sample = original.Sample, {
StartTime = obj.StartTime,
Sample = obj.Sample,
IsStrong = strong, IsStrong = strong,
VelocityMultiplier = legacy_velocity_multiplier
}; };
} }
} }
}
}
} }

View File

@ -43,7 +43,7 @@ namespace osu.Game.Modes.Taiko.Judgements
public override string MaxResultString => MAX_HIT_RESULT.GetDescription(); public override string MaxResultString => MAX_HIT_RESULT.GetDescription();
/// <summary> /// <summary>
/// Whether this Judgement has a secondary hit in the case of finishers. /// Whether this Judgement has a secondary hit in the case of strong hits.
/// </summary> /// </summary>
public virtual bool SecondHit { get; set; } public virtual bool SecondHit { get; set; }

View File

@ -0,0 +1,26 @@
// 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.Beatmaps.Timing;
using osu.Game.Database;
namespace osu.Game.Modes.Taiko.Objects
{
public class BarLine
{
/// <summary>
/// The start time of the control point this bar line represents.
/// </summary>
public double StartTime;
/// <summary>
/// The time to scroll in the bar line.
/// </summary>
public double PreEmpt;
public void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
{
PreEmpt = TaikoHitObject.BASE_SCROLL_TIME / difficulty.SliderMultiplier * timing.BeatLengthAt(StartTime) * timing.SpeedMultiplierAt(StartTime) / 1000;
}
}
}

View File

@ -1,57 +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 osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements;
using System.Linq;
namespace osu.Game.Modes.Taiko.Objects.Drawable
{
public class DrawableDrumRoll : DrawableTaikoHitObject
{
private readonly DrumRoll drumRoll;
public DrawableDrumRoll(DrumRoll drumRoll)
: base(drumRoll)
{
this.drumRoll = drumRoll;
int tickIndex = 0;
foreach (var tick in drumRoll.Ticks)
{
var newTick = new DrawableDrumRollTick(tick)
{
Depth = tickIndex,
X = (float)((tick.StartTime - HitObject.StartTime) / drumRoll.Duration)
};
AddNested(newTick);
tickIndex++;
}
}
protected override void UpdateState(ArmedState state)
{
}
protected override void CheckJudgement(bool userTriggered)
{
if (userTriggered)
return;
if (Judgement.TimeOffset < 0)
return;
int countHit = NestedHitObjects.Count(o => o.Judgement.Result == HitResult.Hit);
if (countHit > drumRoll.RequiredGoodHits)
{
Judgement.Result = HitResult.Hit;
Judgement.TaikoResult = countHit >= drumRoll.RequiredGreatHits ? TaikoHitResult.Great : TaikoHitResult.Good;
}
else
Judgement.Result = HitResult.Miss;
}
}
}

View File

@ -1,53 +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 OpenTK.Input;
using osu.Game.Modes.Taiko.Judgements;
using System;
using osu.Game.Modes.Objects.Drawables;
namespace osu.Game.Modes.Taiko.Objects.Drawable
{
public class DrawableDrumRollTick : DrawableTaikoHitObject
{
private readonly DrumRollTick tick;
public DrawableDrumRollTick(DrumRollTick tick)
: base(tick)
{
this.tick = tick;
}
protected override TaikoJudgement CreateJudgement() => new TaikoDrumRollTickJudgement();
protected override void CheckJudgement(bool userTriggered)
{
if (!userTriggered)
{
if (Judgement.TimeOffset > tick.HitWindow)
Judgement.Result = HitResult.Miss;
return;
}
if (Math.Abs(Judgement.TimeOffset) < tick.HitWindow)
{
Judgement.Result = HitResult.Hit;
Judgement.TaikoResult = TaikoHitResult.Great;
}
}
protected override void UpdateState(ArmedState state)
{
}
protected override void UpdateScrollPosition(double time)
{
// Drum roll ticks shouldn't move
}
protected override bool HandleKeyPress(Key key)
{
return Judgement.Result == HitResult.None && UpdateJudgement(true);
}
}
}

View File

@ -0,0 +1,81 @@
// 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.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawables
{
/// <summary>
/// A line that scrolls alongside hit objects in the playfield and visualises control points.
/// </summary>
public class DrawableBarLine : Container
{
/// <summary>
/// The width of the line tracker.
/// </summary>
private const float tracker_width = 2f;
/// <summary>
/// Fade out time calibrated to a pre-empt of 1000ms.
/// </summary>
private const float base_fadeout_time = 100f;
/// <summary>
/// The visual line tracker.
/// </summary>
protected Box Tracker;
/// <summary>
/// The bar line.
/// </summary>
protected readonly BarLine BarLine;
public DrawableBarLine(BarLine barLine)
{
BarLine = barLine;
Anchor = Anchor.CentreLeft;
Origin = Anchor.Centre;
RelativePositionAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
Width = tracker_width;
Children = new[]
{
Tracker = new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
EdgeSmoothness = new Vector2(0.5f, 0),
Alpha = 0.75f
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
LifetimeStart = BarLine.StartTime - BarLine.PreEmpt * 2;
LifetimeEnd = BarLine.StartTime + BarLine.PreEmpt;
Delay(BarLine.StartTime - Time.Current);
FadeOut(base_fadeout_time * BarLine.PreEmpt / 1000);
}
private void updateScrollPosition(double time) => MoveToX((float)((BarLine.StartTime - time) / BarLine.PreEmpt));
protected override void Update()
{
base.Update();
updateScrollPosition(Time.Current);
}
}
}

View File

@ -1,35 +1,31 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
using osu.Game.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Modes.Taiko.Objects.Drawables.Pieces;
using OpenTK.Input;
namespace osu.Game.Modes.Taiko.Objects.Drawable namespace osu.Game.Modes.Taiko.Objects.Drawables
{ {
public class DrawableCentreHit : DrawableHit public class DrawableCentreHit : DrawableHit
{ {
protected override Key[] HitKeys { get; } = { Key.F, Key.J }; protected override Key[] HitKeys { get; } = { Key.F, Key.J };
private readonly CirclePiece circlePiece;
public DrawableCentreHit(Hit hit) public DrawableCentreHit(Hit hit)
: base(hit) : base(hit)
{ {
Add(circlePiece = new CirclePiece
{
Children = new[]
{
new CentreHitSymbolPiece()
}
});
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
circlePiece.AccentColour = colours.PinkDarker; Circle.AccentColour = colours.PinkDarker;
} }
protected override CirclePiece CreateCirclePiece() => new CirclePiece
{
Children = new[] { new CentreHitSymbolPiece() }
};
} }
} }

View File

@ -0,0 +1,116 @@
// 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.Allocation;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements;
using osu.Game.Modes.Taiko.Objects.Drawables.Pieces;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawables
{
public class DrawableDrumRoll : DrawableTaikoHitObject
{
/// <summary>
/// Number of rolling hits required to reach the dark/final accent colour.
/// </summary>
private const int rolling_hits_for_dark_accent = 5;
private readonly DrumRoll drumRoll;
private readonly CirclePiece circle;
private Color4 accentDarkColour;
/// <summary>
/// Rolling number of tick hits. This increases for hits and decreases for misses.
/// </summary>
private int rollingHits;
public DrawableDrumRoll(DrumRoll drumRoll)
: base(drumRoll)
{
this.drumRoll = drumRoll;
RelativeSizeAxes = Axes.X;
Width = (float)(drumRoll.Duration / drumRoll.PreEmpt);
Add(circle = CreateCirclePiece());
circle.KiaiMode = HitObject.Kiai;
foreach (var tick in drumRoll.Ticks)
{
var newTick = new DrawableDrumRollTick(tick)
{
X = (float)((tick.StartTime - HitObject.StartTime) / drumRoll.Duration)
};
newTick.OnJudgement += onTickJudgement;
AddNested(newTick);
Add(newTick);
}
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
circle.AccentColour = AccentColour = colours.YellowDark;
accentDarkColour = colours.YellowDarker;
}
protected override void LoadComplete()
{
base.LoadComplete();
// This is naive, however it's based on the reasoning that the hit target
// is further than mid point of the play field, so the time taken to scroll in should always
// be greater than the time taken to scroll out to the left of the screen.
// Thus, using PreEmpt here is enough for the drum roll to completely scroll out.
LifetimeEnd = drumRoll.EndTime + drumRoll.PreEmpt;
}
private void onTickJudgement(DrawableHitObject<TaikoHitObject, TaikoJudgement> obj)
{
if (obj.Judgement.Result == HitResult.Hit)
rollingHits++;
else
rollingHits--;
rollingHits = MathHelper.Clamp(rollingHits, 0, rolling_hits_for_dark_accent);
Color4 newAccent = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_dark_accent, AccentColour, accentDarkColour, 0, 1);
circle.FadeAccent(newAccent, 100);
}
protected override void CheckJudgement(bool userTriggered)
{
if (userTriggered)
return;
if (Judgement.TimeOffset < 0)
return;
int countHit = NestedHitObjects.Count(o => o.Judgement.Result == HitResult.Hit);
if (countHit > drumRoll.RequiredGoodHits)
{
Judgement.Result = HitResult.Hit;
Judgement.TaikoResult = countHit >= drumRoll.RequiredGreatHits ? TaikoHitResult.Great : TaikoHitResult.Good;
}
else
Judgement.Result = HitResult.Miss;
}
protected override void UpdateState(ArmedState state)
{
}
protected virtual CirclePiece CreateCirclePiece() => new CirclePiece();
}
}

View File

@ -0,0 +1,105 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
namespace osu.Game.Modes.Taiko.Objects.Drawables
{
public class DrawableDrumRollTick : DrawableTaikoHitObject
{
/// <summary>
/// The size of a tick.
/// </summary>
private const float tick_size = TaikoHitObject.CIRCLE_RADIUS / 2;
/// <summary>
/// Any tick that is not the first for a drumroll is not filled, but is instead displayed
/// as a hollow circle. This is what controls the border width of that circle.
/// </summary>
private const float tick_border_width = tick_size / 4;
private readonly DrumRollTick tick;
private readonly CircularContainer bodyContainer;
public DrawableDrumRollTick(DrumRollTick tick)
: base(tick)
{
this.tick = tick;
Anchor = Anchor.CentreLeft;
Origin = Anchor.Centre;
RelativePositionAxes = Axes.X;
Size = new Vector2(tick_size);
Children = new[]
{
bodyContainer = new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = tick_border_width,
BorderColour = Color4.White,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = tick.FirstTick ? 1 : 0,
AlwaysPresent = true
}
}
}
};
}
protected override TaikoJudgement CreateJudgement() => new TaikoDrumRollTickJudgement { SecondHit = tick.IsStrong };
protected override void CheckJudgement(bool userTriggered)
{
if (!userTriggered)
{
if (Judgement.TimeOffset > tick.HitWindow)
Judgement.Result = HitResult.Miss;
return;
}
if (Math.Abs(Judgement.TimeOffset) < tick.HitWindow)
{
Judgement.Result = HitResult.Hit;
Judgement.TaikoResult = TaikoHitResult.Great;
}
}
protected override void UpdateState(ArmedState state)
{
switch (state)
{
case ArmedState.Hit:
bodyContainer.ScaleTo(0, 100, EasingTypes.OutQuint);
break;
}
}
protected override void UpdateScrollPosition(double time)
{
// Ticks don't move
}
protected override bool HandleKeyPress(Key key)
{
return Judgement.Result == HitResult.None && UpdateJudgement(true);
}
}
}

View File

@ -1,15 +1,16 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input; using System;
using System.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements; using osu.Game.Modes.Taiko.Judgements;
using System; using osu.Game.Modes.Taiko.Objects.Drawables.Pieces;
using System.Linq; using OpenTK.Input;
namespace osu.Game.Modes.Taiko.Objects.Drawable namespace osu.Game.Modes.Taiko.Objects.Drawables
{ {
public abstract class DrawableHit : DrawableTaikoHitObject public abstract class DrawableHit : DrawableTaikoHitObject
{ {
@ -18,17 +19,19 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
/// </summary> /// </summary>
protected abstract Key[] HitKeys { get; } protected abstract Key[] HitKeys { get; }
protected override Container<Framework.Graphics.Drawable> Content => bodyContainer; protected override Container<Drawable> Content => bodyContainer;
protected readonly CirclePiece Circle;
private readonly Hit hit; private readonly Hit hit;
private readonly Container bodyContainer;
/// <summary> /// <summary>
/// Whether the last key pressed is a valid hit key. /// Whether the last key pressed is a valid hit key.
/// </summary> /// </summary>
private bool validKeyPressed; private bool validKeyPressed;
private readonly Container bodyContainer;
protected DrawableHit(Hit hit) protected DrawableHit(Hit hit)
: base(hit) : base(hit)
{ {
@ -38,7 +41,13 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Children = new[]
{
Circle = CreateCirclePiece()
}
}); });
Circle.KiaiMode = HitObject.Kiai;
} }
protected override void CheckJudgement(bool userTriggered) protected override void CheckJudgement(bool userTriggered)
@ -100,5 +109,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
Expire(); Expire();
} }
protected abstract CirclePiece CreateCirclePiece();
} }
} }

View File

@ -0,0 +1,57 @@
// 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.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawables
{
public class DrawableMajorBarLine : DrawableBarLine
{
/// <summary>
/// The vertical offset of the triangles from the line tracker.
/// </summary>
private const float triangle_offfset = 10f;
/// <summary>
/// The size of the triangles.
/// </summary>
private const float triangle_size = 20f;
public DrawableMajorBarLine(BarLine barLine)
: base(barLine)
{
Add(new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Children = new[]
{
new EquilateralTriangle
{
Name = "Top",
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, -triangle_offfset),
Size = new Vector2(-triangle_size),
EdgeSmoothness = new Vector2(1),
},
new EquilateralTriangle
{
Name = "Bottom",
Anchor = Anchor.BottomCentre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, triangle_offfset),
Size = new Vector2(triangle_size),
EdgeSmoothness = new Vector2(1),
}
}
});
Tracker.Alpha = 1f;
}
}
}

View File

@ -3,33 +3,29 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes.Taiko.Objects.Drawables.Pieces;
using OpenTK.Input; using OpenTK.Input;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
namespace osu.Game.Modes.Taiko.Objects.Drawable namespace osu.Game.Modes.Taiko.Objects.Drawables
{ {
public class DrawableRimHit : DrawableHit public class DrawableRimHit : DrawableHit
{ {
protected override Key[] HitKeys { get; } = { Key.D, Key.K }; protected override Key[] HitKeys { get; } = { Key.D, Key.K };
private readonly CirclePiece circlePiece;
public DrawableRimHit(Hit hit) public DrawableRimHit(Hit hit)
: base(hit) : base(hit)
{ {
Add(circlePiece = new CirclePiece
{
Children = new[]
{
new RimHitSymbolPiece()
}
});
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
circlePiece.AccentColour = colours.BlueDarker; Circle.AccentColour = colours.BlueDarker;
} }
protected override CirclePiece CreateCirclePiece() => new CirclePiece
{
Children = new[] { new RimHitSymbolPiece() }
};
} }
} }

View File

@ -1,35 +1,31 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes.Taiko.Objects.Drawables.Pieces;
using OpenTK.Input;
namespace osu.Game.Modes.Taiko.Objects.Drawable namespace osu.Game.Modes.Taiko.Objects.Drawables
{ {
public class DrawableStrongCentreHit : DrawableStrongHit public class DrawableStrongCentreHit : DrawableStrongHit
{ {
protected override Key[] HitKeys { get; } = { Key.F, Key.J }; protected override Key[] HitKeys { get; } = { Key.F, Key.J };
private readonly CirclePiece circlePiece;
public DrawableStrongCentreHit(Hit hit) public DrawableStrongCentreHit(Hit hit)
: base(hit) : base(hit)
{ {
Add(circlePiece = new StrongCirclePiece
{
Children = new []
{
new CentreHitSymbolPiece()
}
});
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
circlePiece.AccentColour = colours.PinkDarker; Circle.AccentColour = colours.PinkDarker;
} }
protected override CirclePiece CreateCirclePiece() => new StrongCirclePiece
{
Children = new[] { new CentreHitSymbolPiece() }
};
} }
} }

View File

@ -0,0 +1,20 @@
// 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.Modes.Taiko.Judgements;
using osu.Game.Modes.Taiko.Objects.Drawables.Pieces;
namespace osu.Game.Modes.Taiko.Objects.Drawables
{
public class DrawableStrongDrumRoll : DrawableDrumRoll
{
public DrawableStrongDrumRoll(DrumRoll drumRoll)
: base(drumRoll)
{
}
protected override TaikoJudgement CreateJudgement() => new TaikoJudgement { SecondHit = true };
protected override CirclePiece CreateCirclePiece() => new StrongCirclePiece();
}
}

View File

@ -1,14 +1,14 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input;
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements; using osu.Game.Modes.Taiko.Judgements;
using OpenTK.Input;
namespace osu.Game.Modes.Taiko.Objects.Drawable namespace osu.Game.Modes.Taiko.Objects.Drawables
{ {
public abstract class DrawableStrongHit : DrawableHit public abstract class DrawableStrongHit : DrawableHit
{ {

View File

@ -3,33 +3,29 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes.Taiko.Objects.Drawables.Pieces;
using OpenTK.Input; using OpenTK.Input;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
namespace osu.Game.Modes.Taiko.Objects.Drawable namespace osu.Game.Modes.Taiko.Objects.Drawables
{ {
public class DrawableStrongRimHit : DrawableStrongHit public class DrawableStrongRimHit : DrawableStrongHit
{ {
protected override Key[] HitKeys { get; } = { Key.D, Key.K }; protected override Key[] HitKeys { get; } = { Key.D, Key.K };
private readonly CirclePiece circlePiece;
public DrawableStrongRimHit(Hit hit) public DrawableStrongRimHit(Hit hit)
: base(hit) : base(hit)
{ {
Add(circlePiece = new StrongCirclePiece
{
Children = new[]
{
new RimHitSymbolPiece()
}
});
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
circlePiece.AccentColour = colours.BlueDarker; Circle.AccentColour = colours.BlueDarker;
} }
protected override CirclePiece CreateCirclePiece() => new StrongCirclePiece
{
Children = new[] { new RimHitSymbolPiece() }
};
} }
} }

View File

@ -1,9 +1,8 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK; using System;
using OpenTK.Graphics; using System.Linq;
using OpenTK.Input;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -12,11 +11,12 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements; using osu.Game.Modes.Taiko.Judgements;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces; using osu.Game.Modes.Taiko.Objects.Drawables.Pieces;
using System; using OpenTK;
using System.Linq; using OpenTK.Graphics;
using OpenTK.Input;
namespace osu.Game.Modes.Taiko.Objects.Drawable namespace osu.Game.Modes.Taiko.Objects.Drawables
{ {
public class DrawableSwell : DrawableTaikoHitObject public class DrawableSwell : DrawableTaikoHitObject
{ {
@ -56,11 +56,11 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
{ {
this.swell = swell; this.swell = swell;
Children = new Framework.Graphics.Drawable[] Children = new Drawable[]
{ {
bodyContainer = new Container bodyContainer = new Container
{ {
Children = new Framework.Graphics.Drawable[] Children = new Drawable[]
{ {
expandingRing = new CircularContainer expandingRing = new CircularContainer
{ {
@ -89,7 +89,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
Masking = true, Masking = true,
BorderThickness = target_ring_thick_border, BorderThickness = target_ring_thick_border,
BlendingMode = BlendingMode.Additive, BlendingMode = BlendingMode.Additive,
Children = new Framework.Graphics.Drawable[] Children = new Drawable[]
{ {
new Box new Box
{ {
@ -128,6 +128,8 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
} }
} }
}; };
circlePiece.KiaiMode = HitObject.Kiai;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -1,14 +1,14 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Input; using System.Collections.Generic;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements; using osu.Game.Modes.Taiko.Judgements;
using System.Collections.Generic; using OpenTK.Input;
using osu.Framework.Input;
namespace osu.Game.Modes.Taiko.Objects.Drawable namespace osu.Game.Modes.Taiko.Objects.Drawables
{ {
public abstract class DrawableTaikoHitObject : DrawableHitObject<TaikoHitObject, TaikoJudgement> public abstract class DrawableTaikoHitObject : DrawableHitObject<TaikoHitObject, TaikoJudgement>
{ {
@ -22,7 +22,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
: base(hitObject) : base(hitObject)
{ {
Anchor = Anchor.CentreLeft; Anchor = Anchor.CentreLeft;
Origin = Anchor.Centre; Origin = Anchor.CentreLeft;
RelativePositionAxes = Axes.X; RelativePositionAxes = Axes.X;
} }

View File

@ -1,12 +1,12 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using OpenTK; using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces namespace osu.Game.Modes.Taiko.Objects.Drawables.Pieces
{ {
/// <summary> /// <summary>
/// The symbol used for centre hit pieces. /// The symbol used for centre hit pieces.

View File

@ -1,16 +1,16 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
using OpenTK.Graphics; using OpenTK.Graphics;
using System;
using osu.Game.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces namespace osu.Game.Modes.Taiko.Objects.Drawables.Pieces
{ {
/// <summary> /// <summary>
/// A circle piece which is used uniformly through osu!taiko to visualise hitobjects. /// A circle piece which is used uniformly through osu!taiko to visualise hitobjects.
@ -36,10 +36,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{ {
accentColour = value; accentColour = value;
innerBackground.Colour = AccentColour; background.Colour = AccentColour;
triangles.ColourLight = AccentColour;
triangles.ColourDark = AccentColour.Darken(0.1f);
resetEdgeEffects(); resetEdgeEffects();
} }
@ -66,13 +63,11 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
set { throw new InvalidOperationException($"{nameof(CirclePiece)} must always use CentreLeft origin."); } set { throw new InvalidOperationException($"{nameof(CirclePiece)} must always use CentreLeft origin."); }
} }
protected override Container<Framework.Graphics.Drawable> Content => SymbolContainer; protected override Container<Drawable> Content => SymbolContainer;
protected readonly Container SymbolContainer; protected readonly Container SymbolContainer;
private readonly Container background;
private readonly Container innerLayer; private readonly Container innerLayer;
private readonly Container innerCircleContainer;
private readonly Box innerBackground;
private readonly Triangles triangles;
public CirclePiece() public CirclePiece()
{ {
@ -86,28 +81,30 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Children = new Framework.Graphics.Drawable[] Children = new Drawable[]
{ {
innerCircleContainer = new CircularContainer background = new CircularContainer
{ {
Name = "Inner Circle", Name = "Background",
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true, Masking = true,
Children = new Framework.Graphics.Drawable[] Children = new Drawable[]
{ {
innerBackground = new Box new Box
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
triangles = new Triangles new Triangles
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ColourLight = Color4.White,
ColourDark = Color4.White.Darken(0.1f)
} }
} }
}, },
@ -150,7 +147,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
private void resetEdgeEffects() private void resetEdgeEffects()
{ {
innerCircleContainer.EdgeEffect = new EdgeEffect background.EdgeEffect = new EdgeEffect
{ {
Type = EdgeEffectType.Glow, Type = EdgeEffectType.Glow,
Colour = AccentColour, Colour = AccentColour,

View File

@ -1,13 +1,13 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces namespace osu.Game.Modes.Taiko.Objects.Drawables.Pieces
{ {
/// <summary> /// <summary>
/// The symbol used for rim hit pieces. /// The symbol used for rim hit pieces.

View File

@ -3,7 +3,7 @@
using OpenTK; using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces namespace osu.Game.Modes.Taiko.Objects.Drawables.Pieces
{ {
/// <summary> /// <summary>
/// A type of circle piece which is drawn at a higher scale to represent a "strong" piece. /// A type of circle piece which is drawn at a higher scale to represent a "strong" piece.

View File

@ -1,10 +1,10 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Graphics;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces namespace osu.Game.Modes.Taiko.Objects.Drawables.Pieces
{ {
/// <summary> /// <summary>
/// The symbol used for swell pieces. /// The symbol used for swell pieces.

View File

@ -13,6 +13,11 @@ namespace osu.Game.Modes.Taiko.Objects
{ {
public class DrumRoll : TaikoHitObject, IHasDistance public class DrumRoll : TaikoHitObject, IHasDistance
{ {
/// <summary>
/// Drum roll distance that results in a duration of 1 speed-adjusted beat length.
/// </summary>
private const float base_distance = 100;
public double EndTime => StartTime + Distance / Velocity; public double EndTime => StartTime + Distance / Velocity;
public double Duration => EndTime - StartTime; public double Duration => EndTime - StartTime;
@ -25,13 +30,12 @@ namespace osu.Game.Modes.Taiko.Objects
/// <summary> /// <summary>
/// Velocity of the drum roll in positional length units per millisecond. /// Velocity of the drum roll in positional length units per millisecond.
/// </summary> /// </summary>
public double Velocity { get; protected set; } public double Velocity { get; protected set; } = 5;
/// <summary> /// <summary>
/// The distance between ticks of this drumroll. /// Numer of ticks per beat length.
/// <para>Half of this value is the hit window of the ticks.</para>
/// </summary> /// </summary>
public double TickTimeDistance { get; protected set; } public int TickRate = 1;
/// <summary> /// <summary>
/// Number of drum roll ticks required for a "Good" hit. /// Number of drum roll ticks required for a "Good" hit.
@ -55,18 +59,20 @@ namespace osu.Game.Modes.Taiko.Objects
private List<DrumRollTick> ticks; 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(TimingInfo timing, BeatmapDifficulty difficulty) public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
{ {
base.ApplyDefaults(timing, difficulty); base.ApplyDefaults(timing, difficulty);
Velocity = timing.SliderVelocityAt(StartTime) * difficulty.SliderMultiplier / 1000; double speedAdjutedBeatLength = timing.SpeedMultiplierAt(StartTime) * timing.BeatLengthAt(StartTime);
TickTimeDistance = timing.BeatLengthAt(StartTime);
//TODO: move this to legacy conversion code to allow for direct division without special case. Velocity = base_distance * difficulty.SliderMultiplier / speedAdjutedBeatLength * VelocityMultiplier;
if (difficulty.SliderTickRate == 3) tickSpacing = timing.BeatLengthAt(StartTime) / TickRate;
TickTimeDistance /= 3;
else
TickTimeDistance /= 4;
RequiredGoodHits = TotalTicks * Math.Min(0.15, 0.05 + 0.10 / 6 * difficulty.OverallDifficulty); 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); RequiredGreatHits = TotalTicks * Math.Min(0.30, 0.10 + 0.20 / 6 * difficulty.OverallDifficulty);
@ -76,18 +82,19 @@ namespace osu.Game.Modes.Taiko.Objects
{ {
var ret = new List<DrumRollTick>(); var ret = new List<DrumRollTick>();
if (TickTimeDistance == 0) if (tickSpacing == 0)
return ret; return ret;
bool first = true; bool first = true;
for (double t = StartTime; t < EndTime + (int)TickTimeDistance; t += TickTimeDistance) for (double t = StartTime; t < EndTime + (int)tickSpacing; t += tickSpacing)
{ {
ret.Add(new DrumRollTick ret.Add(new DrumRollTick
{ {
FirstTick = first, FirstTick = first,
PreEmpt = PreEmpt, PreEmpt = PreEmpt,
TickTimeDistance = TickTimeDistance, TickSpacing = tickSpacing,
StartTime = t, StartTime = t,
IsStrong = IsStrong,
Sample = new HitSampleInfo Sample = new HitSampleInfo
{ {
Type = SampleType.None, Type = SampleType.None,

View File

@ -11,14 +11,14 @@ namespace osu.Game.Modes.Taiko.Objects
public bool FirstTick; public bool FirstTick;
/// <summary> /// <summary>
/// The distance between this tick and the next in milliseconds. /// The length (in milliseconds) between this tick and the next.
/// <para>Half of this value is the hit window of the tick.</para> /// <para>Half of this value is the hit window of the tick.</para>
/// </summary> /// </summary>
public double TickTimeDistance; public double TickSpacing;
/// <summary> /// <summary>
/// The time allowed to hit this tick. /// The time allowed to hit this tick.
/// </summary> /// </summary>
public double HitWindow => TickTimeDistance / 2; public double HitWindow => TickSpacing / 2;
} }
} }

View File

@ -1,9 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Game.Beatmaps.Timing;
using osu.Game.Database;
using osu.Game.Modes.Objects.Types; using osu.Game.Modes.Objects.Types;
namespace osu.Game.Modes.Taiko.Objects namespace osu.Game.Modes.Taiko.Objects
@ -17,14 +14,6 @@ namespace osu.Game.Modes.Taiko.Objects
/// <summary> /// <summary>
/// The number of hits required to complete the swell successfully. /// The number of hits required to complete the swell successfully.
/// </summary> /// </summary>
public int RequiredHits { get; protected set; } = 10; public int RequiredHits = 10;
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
{
base.ApplyDefaults(timing, difficulty);
double spinnerRotationRatio = BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 3, 5, 7.5);
RequiredHits = (int)Math.Max(1, Duration / 1000f * spinnerRotationRatio);
}
} }
} }

View File

@ -14,6 +14,16 @@ namespace osu.Game.Modes.Taiko.Objects
/// </summary> /// </summary>
public const float CIRCLE_RADIUS = 42f; public const float CIRCLE_RADIUS = 42f;
/// <summary>
/// Time (in milliseconds) to scroll in the hit object with a speed-adjusted beat length of 1 second.
/// </summary>
public const double BASE_SCROLL_TIME = 6000;
/// <summary>
/// The velocity multiplier applied to this hit object.
/// </summary>
public float VelocityMultiplier = 1;
/// <summary> /// <summary>
/// The time to scroll in the HitObject. /// The time to scroll in the HitObject.
/// </summary> /// </summary>
@ -34,7 +44,7 @@ namespace osu.Game.Modes.Taiko.Objects
{ {
base.ApplyDefaults(timing, difficulty); base.ApplyDefaults(timing, difficulty);
PreEmpt = 600 / (timing.SliderVelocityAt(StartTime) * difficulty.SliderMultiplier) * 1000; PreEmpt = BASE_SCROLL_TIME / difficulty.SliderMultiplier * timing.BeatLengthAt(StartTime) * timing.SpeedMultiplierAt(StartTime) / VelocityMultiplier / 1000;
ControlPoint overridePoint; ControlPoint overridePoint;
Kiai = timing.TimingPointAt(StartTime, out overridePoint).KiaiMode; Kiai = timing.TimingPointAt(StartTime, out overridePoint).KiaiMode;

View File

@ -72,14 +72,9 @@ namespace osu.Game.Modes.Taiko.Replays
} }
else if (drumRoll != null) else if (drumRoll != null)
{ {
double delay = drumRoll.TickTimeDistance; foreach (var tick in drumRoll.Ticks)
double time = drumRoll.StartTime;
for (int j = 0; j < drumRoll.TotalTicks; j++)
{ {
Frames.Add(new ReplayFrame((int)time, 0, 0, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2)); Frames.Add(new ReplayFrame(tick.StartTime, 0, 0, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2));
time += delay;
hitButton = !hitButton; hitButton = !hitButton;
} }
} }

View File

@ -18,12 +18,21 @@ namespace osu.Game.Modes.Taiko.UI
/// </summary> /// </summary>
internal class HitExplosion : CircularContainer internal class HitExplosion : CircularContainer
{ {
private readonly TaikoJudgement judgement; /// <summary>
/// The size multiplier of a hit explosion if a hit object has been hit with the second key.
/// </summary>
private const float secondhit_size_multiplier = 1.5f;
/// <summary>
/// The judgement this hit explosion visualises.
/// </summary>
public readonly TaikoJudgement Judgement;
private readonly Box innerFill; private readonly Box innerFill;
public HitExplosion(TaikoJudgement judgement) public HitExplosion(TaikoJudgement judgement)
{ {
this.judgement = judgement; Judgement = judgement;
Size = new Vector2(TaikoHitObject.CIRCLE_RADIUS * 2); Size = new Vector2(TaikoHitObject.CIRCLE_RADIUS * 2);
@ -50,10 +59,7 @@ namespace osu.Game.Modes.Taiko.UI
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
if (judgement.SecondHit) switch (Judgement.TaikoResult)
Size *= 1.5f;
switch (judgement.TaikoResult)
{ {
case TaikoHitResult.Good: case TaikoHitResult.Good:
innerFill.Colour = colours.Green; innerFill.Colour = colours.Green;
@ -73,5 +79,13 @@ namespace osu.Game.Modes.Taiko.UI
Expire(); Expire();
} }
/// <summary>
/// Transforms this hit explosion to visualise a secondary hit.
/// </summary>
public void VisualiseSecondHit()
{
ResizeTo(Size * secondhit_size_multiplier, 50);
}
} }
} }

View File

@ -21,9 +21,9 @@ namespace osu.Game.Modes.Taiko.UI
private const float normal_diameter = TaikoHitObject.CIRCLE_RADIUS * 2; private const float normal_diameter = TaikoHitObject.CIRCLE_RADIUS * 2;
/// <summary> /// <summary>
/// Diameter of finisher hit object circles. /// Diameter of strong hit object circles.
/// </summary> /// </summary>
private const float finisher_diameter = normal_diameter * 1.5f; private const float strong_hit_diameter = normal_diameter * 1.5f;
/// <summary> /// <summary>
/// The 1px inner border of the taiko playfield. /// The 1px inner border of the taiko playfield.
@ -47,15 +47,15 @@ namespace osu.Game.Modes.Taiko.UI
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Y = border_offset, Y = border_offset,
Size = new Vector2(border_thickness, (TaikoPlayfield.PLAYFIELD_HEIGHT - finisher_diameter) / 2f - border_offset), Size = new Vector2(border_thickness, (TaikoPlayfield.PLAYFIELD_HEIGHT - strong_hit_diameter) / 2f - border_offset),
Alpha = 0.1f Alpha = 0.1f
}, },
new CircularContainer new CircularContainer
{ {
Name = "Finisher Ring", Name = "Strong Hit Ring",
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(finisher_diameter), Size = new Vector2(strong_hit_diameter),
Masking = true, Masking = true,
BorderColour = Color4.White, BorderColour = Color4.White,
BorderThickness = border_thickness, BorderThickness = border_thickness,
@ -72,7 +72,7 @@ namespace osu.Game.Modes.Taiko.UI
}, },
new CircularContainer new CircularContainer
{ {
Name = "Normal Ring", Name = "Normal Hit Ring",
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(normal_diameter), Size = new Vector2(normal_diameter),
@ -96,7 +96,7 @@ namespace osu.Game.Modes.Taiko.UI
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
Y = -border_offset, Y = -border_offset,
Size = new Vector2(border_thickness, (TaikoPlayfield.PLAYFIELD_HEIGHT - finisher_diameter) / 2f - border_offset), Size = new Vector2(border_thickness, (TaikoPlayfield.PLAYFIELD_HEIGHT - strong_hit_diameter) / 2f - border_offset),
Alpha = 0.1f Alpha = 0.1f
}, },
}; };

View File

@ -1,16 +1,22 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.MathUtils;
using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Timing;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Objects.Types;
using osu.Game.Modes.Replays; using osu.Game.Modes.Replays;
using osu.Game.Modes.Scoring; using osu.Game.Modes.Scoring;
using osu.Game.Modes.Taiko.Beatmaps; using osu.Game.Modes.Taiko.Beatmaps;
using osu.Game.Modes.Taiko.Judgements; using osu.Game.Modes.Taiko.Judgements;
using osu.Game.Modes.Taiko.Objects; using osu.Game.Modes.Taiko.Objects;
using osu.Game.Modes.Taiko.Replays; using osu.Game.Modes.Taiko.Objects.Drawables;
using osu.Game.Modes.Taiko.Scoring; using osu.Game.Modes.Taiko.Scoring;
using osu.Game.Modes.UI; using osu.Game.Modes.UI;
using osu.Game.Modes.Taiko.Replays;
namespace osu.Game.Modes.Taiko.UI namespace osu.Game.Modes.Taiko.UI
{ {
@ -21,15 +27,123 @@ namespace osu.Game.Modes.Taiko.UI
{ {
} }
[BackgroundDependencyLoader]
private void load()
{
loadBarLines();
}
private void loadBarLines()
{
var taikoPlayfield = Playfield as TaikoPlayfield;
if (taikoPlayfield == null)
return;
TaikoHitObject lastObject = Beatmap.HitObjects[Beatmap.HitObjects.Count - 1];
double lastHitTime = 1 + (lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime;
var timingPoints = Beatmap.TimingInfo.ControlPoints.FindAll(cp => cp.TimingChange);
if (timingPoints.Count == 0)
return;
int currentIndex = 0;
while (currentIndex < timingPoints.Count && Precision.AlmostEquals(timingPoints[currentIndex].BeatLength, 0))
currentIndex++;
double time = timingPoints[currentIndex].Time;
double measureLength = timingPoints[currentIndex].BeatLength * (int)timingPoints[currentIndex].TimeSignature;
// Find the bar line time closest to 0
time -= measureLength * (int)(time / measureLength);
// Always start barlines from a positive time
while (time < 0)
time += measureLength;
int currentBeat = 0;
while (time <= lastHitTime)
{
ControlPoint current = timingPoints[currentIndex];
if (time > current.Time || current.OmitFirstBarLine)
{
bool isMajor = currentBeat % (int)current.TimeSignature == 0;
var barLine = new BarLine
{
StartTime = time,
};
barLine.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty);
taikoPlayfield.AddBarLine(isMajor ? new DrawableMajorBarLine(barLine) : new DrawableBarLine(barLine));
currentBeat++;
}
double bl = current.BeatLength;
if (bl < 800)
bl *= (int)current.TimeSignature;
time += bl;
if (currentIndex + 1 >= timingPoints.Count || time < timingPoints[currentIndex + 1].Time)
continue;
currentBeat = 0;
currentIndex++;
time = timingPoints[currentIndex].Time;
}
}
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this); public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);
protected override IBeatmapConverter<TaikoHitObject> CreateBeatmapConverter() => new TaikoBeatmapConverter(); protected override IBeatmapConverter<TaikoHitObject> CreateBeatmapConverter() => new TaikoBeatmapConverter();
protected override IBeatmapProcessor<TaikoHitObject> CreateBeatmapProcessor() => new TaikoBeatmapProcessor(); protected override IBeatmapProcessor<TaikoHitObject> CreateBeatmapProcessor() => new TaikoBeatmapProcessor();
protected override Playfield<TaikoHitObject, TaikoJudgement> CreatePlayfield() => new TaikoPlayfield(); protected override Playfield<TaikoHitObject, TaikoJudgement> CreatePlayfield() => new TaikoPlayfield
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft
};
protected override DrawableHitObject<TaikoHitObject, TaikoJudgement> GetVisualRepresentation(TaikoHitObject h) => null; protected override DrawableHitObject<TaikoHitObject, TaikoJudgement> GetVisualRepresentation(TaikoHitObject h)
{
var centreHit = h as CentreHit;
if (centreHit != null)
{
if (h.IsStrong)
return new DrawableStrongCentreHit(centreHit);
return new DrawableCentreHit(centreHit);
}
var rimHit = h as RimHit;
if (rimHit != null)
{
if (h.IsStrong)
return new DrawableStrongRimHit(rimHit);
return new DrawableRimHit(rimHit);
}
var drumRoll = h as DrumRoll;
if (drumRoll != null)
{
if (h.IsStrong)
return new DrawableStrongDrumRoll(drumRoll);
return new DrawableDrumRoll(drumRoll);
}
var swell = h as Swell;
if (swell != null)
return new DrawableSwell(swell);
return null;
}
protected override FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new TaikoFramedReplayInputHandler(replay); protected override FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new TaikoFramedReplayInputHandler(replay);
} }

View File

@ -14,7 +14,8 @@ using osu.Game.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Game.Modes.Taiko.Objects.Drawable; using System.Linq;
using osu.Game.Modes.Taiko.Objects.Drawables;
namespace osu.Game.Modes.Taiko.UI namespace osu.Game.Modes.Taiko.UI
{ {
@ -22,7 +23,7 @@ namespace osu.Game.Modes.Taiko.UI
{ {
/// <summary> /// <summary>
/// The play field height. This is relative to the size of hit objects /// The play field height. This is relative to the size of hit objects
/// such that the playfield is just a bit larger than finishers. /// such that the playfield is just a bit larger than strong hits.
/// </summary> /// </summary>
public const float PLAYFIELD_HEIGHT = TaikoHitObject.CIRCLE_RADIUS * 2 * 2; public const float PLAYFIELD_HEIGHT = TaikoHitObject.CIRCLE_RADIUS * 2 * 2;
@ -39,7 +40,7 @@ namespace osu.Game.Modes.Taiko.UI
protected override Container<Drawable> Content => hitObjectContainer; protected override Container<Drawable> Content => hitObjectContainer;
private readonly Container<HitExplosion> hitExplosionContainer; private readonly Container<HitExplosion> hitExplosionContainer;
//private Container<DrawableBarLine> barLineContainer; private readonly Container<DrawableBarLine> barLineContainer;
private readonly Container<DrawableTaikoJudgement> judgementContainer; private readonly Container<DrawableTaikoJudgement> judgementContainer;
private readonly Container hitObjectContainer; private readonly Container hitObjectContainer;
@ -95,10 +96,10 @@ namespace osu.Game.Modes.Taiko.UI
Size = new Vector2(TaikoHitObject.CIRCLE_RADIUS * 2), Size = new Vector2(TaikoHitObject.CIRCLE_RADIUS * 2),
BlendingMode = BlendingMode.Additive BlendingMode = BlendingMode.Additive
}, },
//barLineContainer = new Container<DrawableBarLine> barLineContainer = new Container<DrawableBarLine>
//{ {
// RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
//}, },
new HitTarget new HitTarget
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
@ -173,12 +174,15 @@ namespace osu.Game.Modes.Taiko.UI
swell.OnStart += () => topLevelHitContainer.Add(swell.CreateProxy()); swell.OnStart += () => topLevelHitContainer.Add(swell.CreateProxy());
} }
public void AddBarLine(DrawableBarLine barLine)
{
barLineContainer.Add(barLine);
}
public override void OnJudgement(DrawableHitObject<TaikoHitObject, TaikoJudgement> judgedObject) public override void OnJudgement(DrawableHitObject<TaikoHitObject, TaikoJudgement> judgedObject)
{ {
bool wasHit = judgedObject.Judgement.Result == HitResult.Hit; bool wasHit = judgedObject.Judgement.Result == HitResult.Hit;
bool secondHit = judgedObject.Judgement.SecondHit;
if (wasHit)
hitExplosionContainer.Add(new HitExplosion(judgedObject.Judgement));
judgementContainer.Add(new DrawableTaikoJudgement(judgedObject.Judgement) judgementContainer.Add(new DrawableTaikoJudgement(judgedObject.Judgement)
{ {
@ -187,6 +191,22 @@ namespace osu.Game.Modes.Taiko.UI
RelativePositionAxes = Axes.X, RelativePositionAxes = Axes.X,
X = wasHit ? judgedObject.Position.X : 0, X = wasHit ? judgedObject.Position.X : 0,
}); });
if (!wasHit)
return;
if (!secondHit)
{
if (judgedObject.X >= -0.05f && !(judgedObject is DrawableSwell))
{
// If we're far enough away from the left stage, we should bring outselves in front of it
topLevelHitContainer.Add(judgedObject.CreateProxy());
}
hitExplosionContainer.Add(new HitExplosion(judgedObject.Judgement));
}
else
hitExplosionContainer.Children.FirstOrDefault(e => e.Judgement == judgedObject.Judgement)?.VisualiseSecondHit();
} }
} }
} }

View File

@ -53,22 +53,26 @@
<Compile Include="Judgements\TaikoStrongHitJudgement.cs" /> <Compile Include="Judgements\TaikoStrongHitJudgement.cs" />
<Compile Include="Judgements\TaikoJudgement.cs" /> <Compile Include="Judgements\TaikoJudgement.cs" />
<Compile Include="Judgements\TaikoHitResult.cs" /> <Compile Include="Judgements\TaikoHitResult.cs" />
<Compile Include="Objects\BarLine.cs" />
<Compile Include="Objects\Drawables\DrawableBarLine.cs" />
<Compile Include="Objects\Drawables\DrawableMajorBarLine.cs" />
<Compile Include="Objects\CentreHit.cs" /> <Compile Include="Objects\CentreHit.cs" />
<Compile Include="Objects\Drawable\DrawableRimHit.cs" /> <Compile Include="Objects\Drawables\DrawableRimHit.cs" />
<Compile Include="Objects\Drawable\DrawableStrongRimHit.cs" /> <Compile Include="Objects\Drawables\DrawableStrongRimHit.cs" />
<Compile Include="Objects\Drawable\DrawableCentreHit.cs" /> <Compile Include="Objects\Drawables\DrawableCentreHit.cs" />
<Compile Include="Objects\Drawable\DrawableHit.cs" /> <Compile Include="Objects\Drawables\DrawableHit.cs" />
<Compile Include="Objects\Drawable\DrawableStrongCentreHit.cs" /> <Compile Include="Objects\Drawables\DrawableStrongDrumRoll.cs" />
<Compile Include="Objects\Drawable\DrawableStrongHit.cs" /> <Compile Include="Objects\Drawables\DrawableStrongCentreHit.cs" />
<Compile Include="Objects\Drawable\Pieces\CentreHitSymbolPiece.cs" /> <Compile Include="Objects\Drawables\DrawableStrongHit.cs" />
<Compile Include="Objects\Drawable\DrawableDrumRoll.cs" /> <Compile Include="Objects\Drawables\Pieces\CentreHitSymbolPiece.cs" />
<Compile Include="Objects\Drawable\DrawableDrumRollTick.cs" /> <Compile Include="Objects\Drawables\DrawableDrumRoll.cs" />
<Compile Include="Objects\Drawable\DrawableSwell.cs" /> <Compile Include="Objects\Drawables\DrawableDrumRollTick.cs" />
<Compile Include="Objects\Drawable\DrawableTaikoHitObject.cs" /> <Compile Include="Objects\Drawables\DrawableSwell.cs" />
<Compile Include="Objects\Drawable\Pieces\RimHitSymbolPiece.cs" /> <Compile Include="Objects\Drawables\DrawableTaikoHitObject.cs" />
<Compile Include="Objects\Drawable\Pieces\StrongCirclePiece.cs" /> <Compile Include="Objects\Drawables\Pieces\RimHitSymbolPiece.cs" />
<Compile Include="Objects\Drawable\Pieces\CirclePiece.cs" /> <Compile Include="Objects\Drawables\Pieces\StrongCirclePiece.cs" />
<Compile Include="Objects\Drawable\Pieces\SwellSymbolPiece.cs" /> <Compile Include="Objects\Drawables\Pieces\CirclePiece.cs" />
<Compile Include="Objects\Drawables\Pieces\SwellSymbolPiece.cs" />
<Compile Include="Objects\DrumRoll.cs" /> <Compile Include="Objects\DrumRoll.cs" />
<Compile Include="Objects\DrumRollTick.cs" /> <Compile Include="Objects\DrumRollTick.cs" />
<Compile Include="Objects\Hit.cs" /> <Compile Include="Objects\Hit.cs" />

View File

@ -7,6 +7,8 @@ using osu.Game.Beatmaps.IO;
using osu.Game.Modes; using osu.Game.Modes;
using osu.Game.Modes.Osu; using osu.Game.Modes.Osu;
using osu.Game.Tests.Resources; using osu.Game.Tests.Resources;
using osu.Game.Beatmaps.Formats;
using osu.Game.Database;
namespace osu.Game.Tests.Beatmaps.IO namespace osu.Game.Tests.Beatmaps.IO
{ {
@ -53,7 +55,11 @@ namespace osu.Game.Tests.Beatmaps.IO
using (var osz = Resource.OpenResource("Beatmaps.241526 Soleily - Renatus.osz")) using (var osz = Resource.OpenResource("Beatmaps.241526 Soleily - Renatus.osz"))
{ {
var reader = new OszArchiveReader(osz); var reader = new OszArchiveReader(osz);
var meta = reader.ReadMetadata();
BeatmapMetadata meta;
using (var stream = new StreamReader(reader.GetStream("Soleily - Renatus (Deif) [Platter].osu")))
meta = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata;
Assert.AreEqual(241526, meta.OnlineBeatmapSetID); Assert.AreEqual(241526, meta.OnlineBeatmapSetID);
Assert.AreEqual("Soleily", meta.Artist); Assert.AreEqual("Soleily", meta.Artist);
Assert.AreEqual("Soleily", meta.ArtistUnicode); Assert.AreEqual("Soleily", meta.ArtistUnicode);

View File

@ -22,8 +22,9 @@ namespace osu.Game.Beatmaps.Drawables
public Action<BeatmapSetHeader> GainedSelection; public Action<BeatmapSetHeader> GainedSelection;
private readonly SpriteText title; private readonly SpriteText title;
private readonly SpriteText artist; private readonly SpriteText artist;
private OsuConfigManager config;
private Bindable<bool> preferUnicode; private Bindable<bool> preferUnicode;
private readonly WorkingBeatmap beatmap; private readonly WorkingBeatmap beatmap;
private readonly FillFlowContainer difficultyIcons; private readonly FillFlowContainer difficultyIcons;
@ -33,19 +34,15 @@ namespace osu.Game.Beatmaps.Drawables
Children = new Drawable[] Children = new Drawable[]
{ {
new DelayedLoadContainer new DelayedLoadWrapper(
{
RelativeSizeAxes = Axes.Both,
TimeBeforeLoad = 300,
FinishedLoading = d => d.FadeInFromZero(400, EasingTypes.Out),
Children = new[]
{
new PanelBackground(beatmap) new PanelBackground(beatmap)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Depth = 1, OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out),
}
} }
)
{
TimeBeforeLoad = 300,
}, },
new FillFlowContainer new FillFlowContainer
{ {
@ -87,24 +84,13 @@ namespace osu.Game.Beatmaps.Drawables
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config) private void load(OsuConfigManager config)
{ {
this.config = config;
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode); preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode.ValueChanged += preferUnicode_changed; preferUnicode.ValueChanged += unicode =>
preferUnicode_changed(preferUnicode, null);
}
private void preferUnicode_changed(object sender, EventArgs e)
{ {
title.Text = config.GetUnicodeString(beatmap.BeatmapSetInfo.Metadata.Title, beatmap.BeatmapSetInfo.Metadata.TitleUnicode); title.Text = unicode ? beatmap.BeatmapSetInfo.Metadata.TitleUnicode : beatmap.BeatmapSetInfo.Metadata.Title;
artist.Text = config.GetUnicodeString(beatmap.BeatmapSetInfo.Metadata.Artist, beatmap.BeatmapSetInfo.Metadata.ArtistUnicode); artist.Text = unicode ? beatmap.BeatmapSetInfo.Metadata.ArtistUnicode : beatmap.BeatmapSetInfo.Metadata.Artist;
} };
preferUnicode.TriggerChange();
protected override void Dispose(bool isDisposing)
{
if (preferUnicode != null)
preferUnicode.ValueChanged -= preferUnicode_changed;
base.Dispose(isDisposing);
} }
private class PanelBackground : BufferedContainer private class PanelBackground : BufferedContainer

View File

@ -13,13 +13,13 @@ namespace osu.Game.Beatmaps.Formats
{ {
private static Dictionary<string, Type> decoders { get; } = new Dictionary<string, Type>(); private static Dictionary<string, Type> decoders { get; } = new Dictionary<string, Type>();
public static BeatmapDecoder GetDecoder(TextReader stream) public static BeatmapDecoder GetDecoder(StreamReader stream)
{ {
var line = stream.ReadLine()?.Trim(); string line = stream.ReadLine()?.Trim();
if (line == null || !decoders.ContainsKey(line)) if (line == null || !decoders.ContainsKey(line))
throw new IOException(@"Unknown file format"); throw new IOException(@"Unknown file format");
return (BeatmapDecoder)Activator.CreateInstance(decoders[line]); return (BeatmapDecoder)Activator.CreateInstance(decoders[line], line);
} }
protected static void AddDecoder<T>(string magic) where T : BeatmapDecoder protected static void AddDecoder<T>(string magic) where T : BeatmapDecoder
@ -27,17 +27,17 @@ namespace osu.Game.Beatmaps.Formats
decoders[magic] = typeof(T); decoders[magic] = typeof(T);
} }
public virtual Beatmap Decode(TextReader stream) public virtual Beatmap Decode(StreamReader stream)
{ {
return ParseFile(stream); return ParseFile(stream);
} }
public virtual void Decode(TextReader stream, Beatmap beatmap) public virtual void Decode(StreamReader stream, Beatmap beatmap)
{ {
ParseFile(stream, beatmap); ParseFile(stream, beatmap);
} }
protected virtual Beatmap ParseFile(TextReader stream) protected virtual Beatmap ParseFile(StreamReader stream)
{ {
var beatmap = new Beatmap var beatmap = new Beatmap
{ {
@ -48,9 +48,11 @@ namespace osu.Game.Beatmaps.Formats
Difficulty = new BeatmapDifficulty(), Difficulty = new BeatmapDifficulty(),
}, },
}; };
ParseFile(stream, beatmap); ParseFile(stream, beatmap);
return beatmap; return beatmap;
} }
protected abstract void ParseFile(TextReader stream, Beatmap beatmap);
protected abstract void ParseFile(StreamReader stream, Beatmap beatmap);
} }
} }

View File

@ -1,16 +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;
using System.IO;
namespace osu.Game.Beatmaps.Formats
{
public class ConstructableBeatmapDecoder : BeatmapDecoder
{
protected override void ParseFile(TextReader stream, Beatmap beatmap)
{
throw new NotImplementedException();
}
}
}

View File

@ -31,6 +31,17 @@ namespace osu.Game.Beatmaps.Formats
// TODO: Not sure how far back to go, or differences between versions // TODO: Not sure how far back to go, or differences between versions
} }
private readonly int beatmapVersion;
public OsuLegacyDecoder()
{
}
public OsuLegacyDecoder(string header)
{
beatmapVersion = int.Parse(header.Substring(17));
}
private enum Section private enum Section
{ {
None, None,
@ -246,32 +257,36 @@ namespace osu.Game.Beatmaps.Formats
} }
} }
protected override Beatmap ParseFile(TextReader stream) protected override Beatmap ParseFile(StreamReader stream)
{ {
return new LegacyBeatmap(base.ParseFile(stream)); return new LegacyBeatmap(base.ParseFile(stream));
} }
public override Beatmap Decode(TextReader stream) public override Beatmap Decode(StreamReader stream)
{ {
return new LegacyBeatmap(base.Decode(stream)); return new LegacyBeatmap(base.Decode(stream));
} }
protected override void ParseFile(TextReader stream, Beatmap beatmap) protected override void ParseFile(StreamReader stream, Beatmap beatmap)
{ {
beatmap.BeatmapInfo.BeatmapVersion = beatmapVersion;
HitObjectParser parser = null; HitObjectParser parser = null;
Section section = Section.None;
bool hasCustomColours = false; bool hasCustomColours = false;
var section = Section.None; string line;
while (true) while ((line = stream.ReadLine()) != null)
{ {
var line = stream.ReadLine();
if (line == null)
break;
if (string.IsNullOrEmpty(line)) if (string.IsNullOrEmpty(line))
continue; continue;
if (line.StartsWith(@"osu file format v")) if (line.StartsWith(@"osu file format v"))
{
beatmap.BeatmapInfo.BeatmapVersion = int.Parse(line.Substring(17));
continue; continue;
}
if (line.StartsWith(@"[") && line.EndsWith(@"]")) if (line.StartsWith(@"[") && line.EndsWith(@"]"))
{ {

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Database;
namespace osu.Game.Beatmaps.IO namespace osu.Game.Beatmaps.IO
{ {
@ -35,11 +34,6 @@ namespace osu.Game.Beatmaps.IO
readers.Add(new Reader { Test = test, Type = typeof(T) }); readers.Add(new Reader { Test = test, Type = typeof(T) });
} }
/// <summary>
/// Reads the beatmap metadata from this archive.
/// </summary>
public abstract BeatmapMetadata ReadMetadata();
/// <summary> /// <summary>
/// Gets a list of beatmap file names. /// Gets a list of beatmap file names.
/// </summary> /// </summary>

View File

@ -5,7 +5,6 @@ using System.IO;
using System.Linq; using System.Linq;
using Ionic.Zip; using Ionic.Zip;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osu.Game.Database;
namespace osu.Game.Beatmaps.IO namespace osu.Game.Beatmaps.IO
{ {
@ -23,23 +22,18 @@ namespace osu.Game.Beatmaps.IO
private readonly Stream archiveStream; private readonly Stream archiveStream;
private readonly ZipFile archive; private readonly ZipFile archive;
private readonly Beatmap firstMap;
public OszArchiveReader(Stream archiveStream) public OszArchiveReader(Stream archiveStream)
{ {
this.archiveStream = archiveStream; this.archiveStream = archiveStream;
archive = ZipFile.Read(archiveStream); archive = ZipFile.Read(archiveStream);
BeatmapFilenames = archive.Entries.Where(e => e.FileName.EndsWith(@".osu"))
.Select(e => e.FileName).ToArray(); BeatmapFilenames = archive.Entries.Where(e => e.FileName.EndsWith(@".osu")).Select(e => e.FileName).ToArray();
if (BeatmapFilenames.Length == 0) if (BeatmapFilenames.Length == 0)
throw new FileNotFoundException(@"This directory contains no beatmaps"); throw new FileNotFoundException(@"This directory contains no beatmaps");
StoryboardFilename = archive.Entries.Where(e => e.FileName.EndsWith(@".osb"))
.Select(e => e.FileName).FirstOrDefault(); StoryboardFilename = archive.Entries.Where(e => e.FileName.EndsWith(@".osb")).Select(e => e.FileName).FirstOrDefault();
using (var stream = new StreamReader(GetStream(BeatmapFilenames[0])))
{
var decoder = BeatmapDecoder.GetDecoder(stream);
firstMap = decoder.Decode(stream);
}
} }
public override Stream GetStream(string name) public override Stream GetStream(string name)
@ -50,11 +44,6 @@ namespace osu.Game.Beatmaps.IO
return entry.OpenReader(); return entry.OpenReader();
} }
public override BeatmapMetadata ReadMetadata()
{
return firstMap.BeatmapInfo.Metadata;
}
public override void Dispose() public override void Dispose()
{ {
archive.Dispose(); archive.Dispose();

View File

@ -20,11 +20,11 @@ namespace osu.Game.Beatmaps.Timing
} }
/// <summary> /// <summary>
/// Finds the BPM multiplier at a time. /// Finds the speed multiplier at a time.
/// </summary> /// </summary>
/// <param name="time">The time to find the BPM multiplier at.</param> /// <param name="time">The time to find the speed multiplier at.</param>
/// <returns>The BPM multiplier.</returns> /// <returns>The speed multiplier.</returns>
public double BPMMultiplierAt(double time) public double SpeedMultiplierAt(double time)
{ {
ControlPoint overridePoint; ControlPoint overridePoint;
ControlPoint timingPoint = TimingPointAt(time, out overridePoint); ControlPoint timingPoint = TimingPointAt(time, out overridePoint);
@ -33,10 +33,10 @@ namespace osu.Game.Beatmaps.Timing
} }
/// <summary> /// <summary>
/// Finds the beat length at a time. /// Finds the beat length at a time. This is expressed in milliseconds.
/// </summary> /// </summary>
/// <param name="time">The time to find the beat length at.</param> /// <param name="time">The time to find the beat length at.</param>
/// <returns>The beat length in milliseconds.</returns> /// <returns>The beat length.</returns>
public double BeatLengthAt(double time) public double BeatLengthAt(double time)
{ {
ControlPoint overridePoint; ControlPoint overridePoint;
@ -45,32 +45,6 @@ namespace osu.Game.Beatmaps.Timing
return timingPoint.BeatLength; return timingPoint.BeatLength;
} }
/// <summary>
/// Finds the beat velocity at a time.
/// </summary>
/// <param name="time">The time to find the velocity at.</param>
/// <returns>The velocity.</returns>
public double BeatVelocityAt(double time)
{
ControlPoint overridePoint;
ControlPoint timingPoint = TimingPointAt(time, out overridePoint);
return overridePoint?.VelocityAdjustment ?? timingPoint?.VelocityAdjustment ?? 1;
}
/// <summary>
/// Finds the beat length at a time.
/// </summary>
/// <param name="time">The time to find the beat length at.</param>
/// <returns>The beat length in positional length units.</returns>
public double BeatDistanceAt(double time)
{
ControlPoint overridePoint;
ControlPoint timingPoint = TimingPointAt(time, out overridePoint);
return (timingPoint?.BeatLength ?? 1) * (overridePoint?.VelocityAdjustment ?? timingPoint?.VelocityAdjustment ?? 1);
}
/// <summary> /// <summary>
/// Finds the timing point at a time. /// Finds the timing point at a time.
/// </summary> /// </summary>
@ -102,21 +76,5 @@ namespace osu.Game.Beatmaps.Timing
return timingPoint ?? ControlPoint.Default; return timingPoint ?? ControlPoint.Default;
} }
/// <summary>
/// Finds the slider velocity at a time.
/// </summary>
/// <param name="time">The time to find the slider velocity at.</param>
/// <returns>The slider velocity in milliseconds.</returns>
public double SliderVelocityAt(double time)
{
const double base_scoring_distance = 100;
double beatDistance = BeatDistanceAt(time);
if (beatDistance > 0)
return base_scoring_distance / beatDistance * 1000;
return base_scoring_distance;
}
} }
} }

View File

@ -187,10 +187,6 @@ namespace osu.Game.Configuration
#pragma warning restore CS0612 // Type or member is obsolete #pragma warning restore CS0612 // Type or member is obsolete
} }
//todo: make a UnicodeString class/struct rather than requiring this helper method.
public string GetUnicodeString(string nonunicode, string unicode)
=> Get<bool>(OsuConfig.ShowUnicode) ? unicode ?? nonunicode : nonunicode ?? unicode;
public OsuConfigManager(Storage storage) : base(storage) public OsuConfigManager(Storage storage) : base(storage)
{ {
} }

View File

@ -175,7 +175,10 @@ namespace osu.Game.Database
BeatmapMetadata metadata; BeatmapMetadata metadata;
using (var reader = ArchiveReader.GetReader(storage, path)) using (var reader = ArchiveReader.GetReader(storage, path))
metadata = reader.ReadMetadata(); {
using (var stream = new StreamReader(reader.GetStream(reader.BeatmapFilenames[0])))
metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata;
}
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
{ {

View File

@ -15,6 +15,8 @@ namespace osu.Game.Database
[PrimaryKey, AutoIncrement] [PrimaryKey, AutoIncrement]
public int ID { get; set; } public int ID { get; set; }
public int BeatmapVersion;
public int? OnlineBeatmapID { get; set; } public int? OnlineBeatmapID { get; set; }
public int? OnlineBeatmapSetID { get; set; } public int? OnlineBeatmapSetID { get; set; }

View File

@ -34,10 +34,12 @@ namespace osu.Game.Database
using (var stream = new StreamReader(reader.GetStream(BeatmapInfo.Path))) using (var stream = new StreamReader(reader.GetStream(BeatmapInfo.Path)))
{ {
decoder = BeatmapDecoder.GetDecoder(stream); decoder = BeatmapDecoder.GetDecoder(stream);
beatmap = decoder?.Decode(stream); beatmap = decoder.Decode(stream);
} }
if (WithStoryboard && beatmap != null && BeatmapSetInfo.StoryboardFile != null) if (beatmap == null || !WithStoryboard || BeatmapSetInfo.StoryboardFile == null)
return beatmap;
using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile))) using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile)))
decoder.Decode(stream, beatmap); decoder.Decode(stream, beatmap);
} }

View File

@ -12,7 +12,6 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Configuration; using osu.Game.Configuration;
using System;
namespace osu.Game.Graphics.Cursor namespace osu.Game.Graphics.Cursor
{ {
@ -116,14 +115,9 @@ namespace osu.Game.Graphics.Cursor
}; };
cursorScale = config.GetBindable<double>(OsuConfig.GameplayCursorSize); cursorScale = config.GetBindable<double>(OsuConfig.GameplayCursorSize);
cursorScale.ValueChanged += scaleChanged; cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)cursorScale);
cursorScale.TriggerChange(); cursorScale.TriggerChange();
} }
private void scaleChanged(object sender, EventArgs e)
{
cursorContainer.Scale = new Vector2((float)cursorScale);
}
} }
} }
} }

View File

@ -131,14 +131,9 @@ namespace osu.Game.Graphics.Cursor
}; };
cursorScale = config.GetBindable<double>(OsuConfig.MenuCursorSize); cursorScale = config.GetBindable<double>(OsuConfig.MenuCursorSize);
cursorScale.ValueChanged += scaleChanged; cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)newScale);
cursorScale.TriggerChange(); cursorScale.TriggerChange();
} }
private void scaleChanged(object sender, EventArgs e)
{
cursorContainer.Scale = new Vector2((float)cursorScale);
}
} }
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
@ -86,9 +85,9 @@ namespace osu.Game.Graphics.UserInterface
}; };
} }
private void bindableValueChanged(object sender, EventArgs e) private void bindableValueChanged(bool isChecked)
{ {
State = bindable.Value ? CheckboxState.Checked : CheckboxState.Unchecked; State = isChecked ? CheckboxState.Checked : CheckboxState.Unchecked;
} }
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)

View File

@ -21,7 +21,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown(); protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown();
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem { Value = value }; protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown.Contains(screenSpacePos); protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown.Contains(screenSpacePos);
@ -75,16 +75,6 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
public new T Value
{
get { return base.Value; }
set
{
base.Value = value;
text.Text = (value as Enum)?.GetDescription();
}
}
public override bool Active public override bool Active
{ {
get { return base.Active; } get { return base.Active; }
@ -134,7 +124,7 @@ namespace osu.Game.Graphics.UserInterface
AccentColour = colours.Blue; AccentColour = colours.Blue;
} }
public OsuTabItem() public OsuTabItem(T value) : base(value)
{ {
AutoSizeAxes = Axes.X; AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y; RelativeSizeAxes = Axes.Y;
@ -146,6 +136,7 @@ namespace osu.Game.Graphics.UserInterface
Margin = new MarginPadding { Top = 5, Bottom = 5 }, Margin = new MarginPadding { Top = 5, Bottom = 5 },
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Text = (value as Enum)?.GetDescription(),
TextSize = 14, TextSize = 14,
Font = @"Exo2.0-Bold", // Font should only turn bold when active? Font = @"Exo2.0-Bold", // Font should only turn bold when active?
}, },

View File

@ -98,13 +98,10 @@ namespace osu.Game.Graphics.UserInterface
DisplayedCount = Current; DisplayedCount = Current;
Current.ValueChanged += currentChanged; Current.ValueChanged += newValue =>
}
private void currentChanged(object sender, EventArgs e)
{ {
if (IsLoaded) if (IsLoaded) TransformCount(displayedCount, newValue);
TransformCount(displayedCount, Current); };
} }
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input; using osu.Framework.Input;
@ -19,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
protected override bool HideOnEscape => false; protected override bool HideOnEscape => false;
private void volumeChanged(object sender, EventArgs e) private void volumeChanged(double newVolume)
{ {
Show(); Show();
schedulePopOut(); schedulePopOut();

View File

@ -66,12 +66,7 @@ namespace osu.Game.Modes.UI
TextSize = 80; TextSize = 80;
Current.ValueChanged += comboChanged; Current.ValueChanged += newValue => updateCount(newValue == 0);
}
private void comboChanged(object sender, System.EventArgs e)
{
updateCount(Current.Value == 0);
} }
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -16,7 +16,7 @@ namespace osu.Game.Modes.UI
protected HealthDisplay() protected HealthDisplay()
{ {
Current.ValueChanged += (s, e) => SetHealth((float)Current); Current.ValueChanged += newValue => SetHealth((float)newValue);
} }
protected abstract void SetHealth(float value); protected abstract void SetHealth(float value);

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using System;
using osu.Game.Modes.Scoring; using osu.Game.Modes.Scoring;
namespace osu.Game.Modes.UI namespace osu.Game.Modes.UI
@ -47,22 +46,18 @@ namespace osu.Game.Modes.UI
private void load(OsuConfigManager config) private void load(OsuConfigManager config)
{ {
showKeyCounter = config.GetBindable<bool>(OsuConfig.KeyOverlay); showKeyCounter = config.GetBindable<bool>(OsuConfig.KeyOverlay);
showKeyCounter.ValueChanged += visibilityChanged; showKeyCounter.ValueChanged += visibility =>
showKeyCounter.TriggerChange();
}
private void visibilityChanged(object sender, EventArgs e)
{ {
if (showKeyCounter) if (visibility)
KeyCounter.Show(); KeyCounter.Show();
else else
KeyCounter.Hide(); KeyCounter.Hide();
};
showKeyCounter.TriggerChange();
} }
public void BindProcessor(ScoreProcessor processor) public void BindProcessor(ScoreProcessor processor)
{ {
//bind processor bindables to combocounter, score display etc.
//TODO: these should be bindable binds, not events!
ScoreCounter?.Current.BindTo(processor.TotalScore); ScoreCounter?.Current.BindTo(processor.TotalScore);
AccuracyCounter?.Current.BindTo(processor.Accuracy); AccuracyCounter?.Current.BindTo(processor.Accuracy);
ComboCounter?.Current.BindTo(processor.Combo); ComboCounter?.Current.BindTo(processor.Combo);

View File

@ -150,7 +150,7 @@ namespace osu.Game
} }
}); });
(screenStack = new Loader()).LoadAsync(this, d => LoadComponentAsync(screenStack = new Loader(), d =>
{ {
screenStack.ModePushed += screenAdded; screenStack.ModePushed += screenAdded;
screenStack.Exited += screenRemoved; screenStack.Exited += screenRemoved;
@ -158,27 +158,27 @@ namespace osu.Game
}); });
//overlay elements //overlay elements
(chat = new ChatOverlay { Depth = 0 }).LoadAsync(this, overlayContent.Add); LoadComponentAsync(chat = new ChatOverlay { Depth = 0 }, overlayContent.Add);
(options = new OptionsOverlay { Depth = -1 }).LoadAsync(this, overlayContent.Add); LoadComponentAsync(options = new OptionsOverlay { Depth = -1 }, overlayContent.Add);
(musicController = new MusicController LoadComponentAsync(musicController = new MusicController
{ {
Depth = -2, Depth = -2,
Position = new Vector2(0, Toolbar.HEIGHT), Position = new Vector2(0, Toolbar.HEIGHT),
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}).LoadAsync(this, overlayContent.Add); }, overlayContent.Add);
(notificationManager = new NotificationManager LoadComponentAsync(notificationManager = new NotificationManager
{ {
Depth = -2, Depth = -2,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}).LoadAsync(this, overlayContent.Add); }, overlayContent.Add);
(dialogOverlay = new DialogOverlay LoadComponentAsync(dialogOverlay = new DialogOverlay
{ {
Depth = -4, Depth = -4,
}).LoadAsync(this, overlayContent.Add); }, overlayContent.Add);
Logger.NewEntry += entry => Logger.NewEntry += entry =>
{ {
@ -195,12 +195,12 @@ namespace osu.Game
Dependencies.Cache(notificationManager); Dependencies.Cache(notificationManager);
Dependencies.Cache(dialogOverlay); Dependencies.Cache(dialogOverlay);
(Toolbar = new Toolbar LoadComponentAsync(Toolbar = new Toolbar
{ {
Depth = -3, Depth = -3,
OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); }, OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
OnPlayModeChange = m => PlayMode.Value = m, OnPlayModeChange = m => PlayMode.Value = m,
}).LoadAsync(this, t => }, t =>
{ {
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); }; PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
PlayMode.TriggerChange(); PlayMode.TriggerChange();

View File

@ -92,7 +92,10 @@ namespace osu.Game
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Basic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Hangul"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Basic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Compatibility"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic")); Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic"));

View File

@ -39,9 +39,9 @@ namespace osu.Game.Overlays.Mods
public readonly Bindable<PlayMode> PlayMode = new Bindable<PlayMode>(); public readonly Bindable<PlayMode> PlayMode = new Bindable<PlayMode>();
private void modeChanged(object sender, EventArgs eventArgs) private void modeChanged(PlayMode newMode)
{ {
var ruleset = Ruleset.GetRuleset(PlayMode); var ruleset = Ruleset.GetRuleset(newMode);
foreach (ModSection section in modSectionsContainer.Children) foreach (ModSection section in modSectionsContainer.Children)
section.Buttons = ruleset.GetModsFor(section.ModType).Select(m => new ModButton(m)).ToArray(); section.Buttons = ruleset.GetModsFor(section.ModType).Select(m => new ModButton(m)).ToArray();
refreshSelectedMods(); refreshSelectedMods();
@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Mods
if (osu != null) if (osu != null)
PlayMode.BindTo(osu.PlayMode); PlayMode.BindTo(osu.PlayMode);
PlayMode.ValueChanged += modeChanged; PlayMode.ValueChanged += modeChanged;
modeChanged(null, null); PlayMode.TriggerChange();
} }
protected override void PopOut() protected override void PopOut()

View File

@ -78,8 +78,6 @@ namespace osu.Game.Overlays
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuGameBase game, OsuConfigManager config, BeatmapDatabase beatmaps, OsuColour colours) private void load(OsuGameBase game, OsuConfigManager config, BeatmapDatabase beatmaps, OsuColour colours)
{ {
unicodeString = config.GetUnicodeString;
Children = new Drawable[] Children = new Drawable[]
{ {
dragContainer = new Container dragContainer = new Container
@ -210,7 +208,7 @@ namespace osu.Game.Overlays
this.beatmaps = beatmaps; this.beatmaps = beatmaps;
trackManager = game.Audio.Track; trackManager = game.Audio.Track;
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode); preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode.ValueChanged += preferUnicode_changed; preferUnicode.ValueChanged += unicode => updateDisplay(current, TransformDirection.None);
beatmapSource = game.Beatmap ?? new Bindable<WorkingBeatmap>(); beatmapSource = game.Beatmap ?? new Bindable<WorkingBeatmap>();
playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>(); playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>();
@ -222,7 +220,8 @@ namespace osu.Game.Overlays
protected override void LoadComplete() protected override void LoadComplete()
{ {
beatmapSource.ValueChanged += workingChanged; beatmapSource.ValueChanged += workingChanged;
workingChanged(); beatmapSource.TriggerChange();
base.LoadComplete(); base.LoadComplete();
} }
@ -247,17 +246,12 @@ namespace osu.Game.Overlays
playButton.Icon = FontAwesome.fa_play_circle_o; playButton.Icon = FontAwesome.fa_play_circle_o;
} }
private void preferUnicode_changed(object sender, EventArgs e) private void workingChanged(WorkingBeatmap beatmap)
{ {
updateDisplay(current, TransformDirection.None); progress.IsEnabled = beatmap != null;
} if (beatmap == current) return;
bool audioEquals = current?.BeatmapInfo?.AudioEquals(beatmap?.BeatmapInfo) ?? false;
private void workingChanged(object sender = null, EventArgs e = null) current = beatmap;
{
progress.IsEnabled = beatmapSource.Value != null;
if (beatmapSource.Value == current) return;
bool audioEquals = current?.BeatmapInfo?.AudioEquals(beatmapSource?.Value?.BeatmapInfo) ?? false;
current = beatmapSource.Value;
updateDisplay(current, audioEquals ? TransformDirection.None : TransformDirection.Next); updateDisplay(current, audioEquals ? TransformDirection.None : TransformDirection.Next);
appendToHistory(current?.BeatmapInfo); appendToHistory(current?.BeatmapInfo);
} }
@ -342,17 +336,14 @@ namespace osu.Game.Overlays
else else
{ {
BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
title.Text = unicodeString(metadata.Title, metadata.TitleUnicode); title.Text = preferUnicode ? metadata.TitleUnicode : metadata.Title;
artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode); artist.Text = preferUnicode ? metadata.ArtistUnicode : metadata.Artist;
} }
}); });
dragContainer.Add(new AsyncLoadContainer dragContainer.Add(new AsyncLoadWrapper(new MusicControllerBackground(beatmap)
{ {
RelativeSizeAxes = Axes.Both, OnLoadComplete = d =>
Depth = float.MaxValue,
Children = new[] { new MusicControllerBackground(beatmap) },
FinishedLoading = d =>
{ {
switch (direction) switch (direction)
{ {
@ -370,25 +361,19 @@ namespace osu.Game.Overlays
currentBackground.Expire(); currentBackground.Expire();
currentBackground = d; currentBackground = d;
} }
})
{
Depth = float.MaxValue,
}); });
}; };
} }
private Func<string, string, string> unicodeString;
private void seek(float position) private void seek(float position)
{ {
current?.Track?.Seek(current.Track.Length * position); current?.Track?.Seek(current.Track.Length * position);
current?.Track?.Start(); current?.Track?.Start();
} }
protected override void Dispose(bool isDisposing)
{
if (preferUnicode != null)
preferUnicode.ValueChanged -= preferUnicode_changed;
base.Dispose(isDisposing);
}
private const float transition_length = 800; private const float transition_length = 800;
protected override void PopIn() protected override void PopIn()

View File

@ -29,10 +29,10 @@ namespace osu.Game.Overlays.Options
public BindableNumber<T> Bindable public BindableNumber<T> Bindable
{ {
get { return slider.Bindable; } get { return slider.Value; }
set set
{ {
slider.Bindable = value; slider.Value = value;
if (value?.Disabled ?? true) if (value?.Disabled ?? true)
Alpha = 0.3f; Alpha = 0.3f;
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -41,10 +40,7 @@ namespace osu.Game.Overlays.Options
bindable.Value = Text; bindable.Value = Text;
} }
private void bindableValueChanged(object sender, EventArgs e) private void bindableValueChanged(string newValue) => Text = newValue;
{
Text = bindable.Value;
}
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {

View File

@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using System;
namespace osu.Game.Overlays.Options.Sections.Graphics namespace osu.Game.Overlays.Options.Sections.Graphics
{ {
@ -52,9 +51,9 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
letterboxing.TriggerChange(); letterboxing.TriggerChange();
} }
private void visibilityChanged(object sender, EventArgs e) private void visibilityChanged(bool newVisibility)
{ {
if (letterboxing) if (newVisibility)
{ {
letterboxPositionX.Show(); letterboxPositionX.Show();
letterboxPositionY.Show(); letterboxPositionY.Show();

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Threading; using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input; using osu.Framework.Input;
@ -27,21 +26,13 @@ namespace osu.Game.Screens
return false; return false;
} }
private Framework.Game game;
[BackgroundDependencyLoader]
private void load(Framework.Game game)
{
this.game = game;
}
public override bool Push(Screen screen) public override bool Push(Screen screen)
{ {
// When trying to push a non-loaded GameMode, load it asynchronously and re-invoke Push // When trying to push a non-loaded GameMode, load it asynchronously and re-invoke Push
// once it's done. // once it's done.
if (screen.LoadState == LoadState.NotLoaded) if (screen.LoadState == LoadState.NotLoaded)
{ {
screen.LoadAsync(game, d => Push((BackgroundScreen)d)); LoadComponentAsync(screen, d => Push((BackgroundScreen)d));
return true; return true;
} }

View File

@ -32,7 +32,7 @@ namespace osu.Game.Screens.Backgrounds
{ {
var newBackground = beatmap == null ? new Background(@"Backgrounds/bg1") : new BeatmapBackground(beatmap); var newBackground = beatmap == null ? new Background(@"Backgrounds/bg1") : new BeatmapBackground(beatmap);
newBackground.LoadAsync(Game, delegate LoadComponentAsync(newBackground, delegate
{ {
float newDepth = 0; float newDepth = 0;
if (background != null) if (background != null)

View File

@ -20,9 +20,9 @@ namespace osu.Game.Screens
private void load(OsuGame game) private void load(OsuGame game)
{ {
if (game.IsDeployedBuild) if (game.IsDeployedBuild)
new Disclaimer().LoadAsync(game, d => Push((Screen)d)); LoadComponentAsync(new Disclaimer(), d => Push((Screen)d));
else else
new Intro().LoadAsync(game, d => Push((Screen)d)); LoadComponentAsync(new Intro(), d => Push((Screen)d));
} }
} }
} }

View File

@ -88,9 +88,9 @@ namespace osu.Game.Screens.Menu
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuGame game, OsuColour colours) private void load(OsuColour colours)
{ {
(intro = new Intro()).LoadAsync(game); LoadComponentAsync(intro = new Intro());
iconColour = colours.Yellow; iconColour = colours.Yellow;
} }

View File

@ -76,7 +76,7 @@ namespace osu.Game.Screens.Menu
{ {
bgm.Start(); bgm.Start();
(mainMenu = new MainMenu()).LoadAsync(Game); LoadComponentAsync(mainMenu = new MainMenu());
Scheduler.AddDelayed(delegate Scheduler.AddDelayed(delegate
{ {

View File

@ -57,7 +57,7 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuGame game) private void load(OsuGame game)
{ {
background.LoadAsync(game); LoadComponentAsync(background);
buttons.OnSettings = game.ToggleOptions; buttons.OnSettings = game.ToggleOptions;
@ -67,10 +67,7 @@ namespace osu.Game.Screens.Menu
private void preloadSongSelect() private void preloadSongSelect()
{ {
if (songSelect == null) if (songSelect == null)
{ LoadComponentAsync(songSelect = new PlaySongSelect());
songSelect = new PlaySongSelect();
songSelect.LoadAsync(Game);
}
} }
private Screen consumeSongSelect() private Screen consumeSongSelect()

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Screens; using osu.Framework.Screens;
@ -40,11 +39,6 @@ namespace osu.Game.Screens
} }
} }
private void beatmap_ValueChanged(object sender, EventArgs e)
{
OnBeatmapChanged(beatmap.Value);
}
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuGameBase game) private void load(OsuGameBase game)
{ {
@ -57,7 +51,7 @@ namespace osu.Game.Screens
beatmap.Value = localMap; beatmap.Value = localMap;
} }
beatmap.ValueChanged += beatmap_ValueChanged; beatmap.ValueChanged += OnBeatmapChanged;
} }
protected virtual void OnBeatmapChanged(WorkingBeatmap beatmap) protected virtual void OnBeatmapChanged(WorkingBeatmap beatmap)

View File

@ -66,7 +66,7 @@ namespace osu.Game.Screens.Play
{ {
var beatmap = Beatmap.Beatmap; var beatmap = Beatmap.Beatmap;
if (beatmap.BeatmapInfo?.Mode > PlayMode.Osu) if (beatmap.BeatmapInfo?.Mode > PlayMode.Taiko)
{ {
//we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor. //we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor.
Exit(); Exit();
@ -235,7 +235,7 @@ namespace osu.Game.Screens.Play
var newPlayer = new Player(); var newPlayer = new Player();
newPlayer.LoadAsync(Game, delegate LoadComponentAsync(newPlayer, delegate
{ {
newPlayer.RestartCount = RestartCount + 1; newPlayer.RestartCount = RestartCount + 1;
ValidForResume = false; ValidForResume = false;
@ -283,7 +283,8 @@ namespace osu.Game.Screens.Play
Background?.FadeTo((100f - dimLevel) / 100, 1500, EasingTypes.OutQuint); Background?.FadeTo((100f - dimLevel) / 100, 1500, EasingTypes.OutQuint);
Content.Alpha = 0; Content.Alpha = 0;
dimLevel.ValueChanged += dimChanged;
dimLevel.ValueChanged += newDim => Background?.FadeTo((100f - newDim) / 100, 800);
Content.ScaleTo(0.7f); Content.ScaleTo(0.7f);
@ -326,18 +327,11 @@ namespace osu.Game.Screens.Play
{ {
FadeOut(250); FadeOut(250);
Content.ScaleTo(0.7f, 750, EasingTypes.InQuint); Content.ScaleTo(0.7f, 750, EasingTypes.InQuint);
dimLevel.ValueChanged -= dimChanged;
Background?.FadeTo(1f, 200); Background?.FadeTo(1f, 200);
return base.OnExiting(next); return base.OnExiting(next);
} }
} }
private void dimChanged(object sender, EventArgs e)
{
Background?.FadeTo((100f - dimLevel) / 100, 800);
}
private Bindable<bool> mouseWheelDisabled; private Bindable<bool> mouseWheelDisabled;
protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused; protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused;

View File

@ -50,7 +50,7 @@ namespace osu.Game.Screens.Play
Origin = Anchor.Centre, Origin = Anchor.Centre,
}); });
player.LoadAsync(Game); LoadComponentAsync(player);
} }
protected override void OnEntering(Screen last) protected override void OnEntering(Screen last)

View File

@ -61,10 +61,10 @@ namespace osu.Game.Screens.Select
}, },
}; };
tabs.ItemChanged += (sender, e) => invokeOnFilter(); tabs.SelectedItem.ValueChanged += item => invokeOnFilter();
modsCheckbox.Action += (sender, e) => invokeOnFilter(); modsCheckbox.Action += (sender, e) => invokeOnFilter();
tabs.SelectedItem = BeatmapDetailTab.Global; tabs.SelectedItem.Value = BeatmapDetailTab.Global;
} }
} }

View File

@ -103,21 +103,18 @@ namespace osu.Game.Screens.Select
labels.AddRange(Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s))); labels.AddRange(Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
} }
Add(beatmapInfoContainer = new AsyncLoadContainer AlwaysPresent = true;
Add(beatmapInfoContainer = new AsyncLoadWrapper(
new BufferedContainer
{ {
FinishedLoading = d => OnLoadComplete = d =>
{ {
FadeIn(250); FadeIn(250);
lastContainer?.FadeOut(250); lastContainer?.FadeOut(250);
lastContainer?.Expire(); lastContainer?.Expire();
}, },
Depth = newDepth,
RelativeSizeAxes = Axes.Both,
Children = new[]
{
new BufferedContainer
{
PixelSnapping = true, PixelSnapping = true,
CacheDrawnFrameBuffer = true, CacheDrawnFrameBuffer = true,
Shear = -Shear, Shear = -Shear,
@ -206,8 +203,9 @@ namespace osu.Game.Screens.Select
} }
}, },
} }
} })
} {
Depth = newDepth,
}); });
} }

View File

@ -151,8 +151,8 @@ namespace osu.Game.Screens.Select
groupTabs.PinItem(GroupMode.All); groupTabs.PinItem(GroupMode.All);
groupTabs.PinItem(GroupMode.RecentlyPlayed); groupTabs.PinItem(GroupMode.RecentlyPlayed);
groupTabs.ItemChanged += (sender, value) => Group = value; groupTabs.SelectedItem.ValueChanged += val => Group = val;
sortTabs.ItemChanged += (sender, value) => Sort = value; sortTabs.SelectedItem.ValueChanged += val => Sort = val;
} }
public void Deactivate() public void Deactivate()
@ -175,7 +175,7 @@ namespace osu.Game.Screens.Select
if (osu != null) if (osu != null)
playMode.BindTo(osu.PlayMode); playMode.BindTo(osu.PlayMode);
playMode.ValueChanged += (s, e) => FilterChanged?.Invoke(CreateCriteria()); playMode.ValueChanged += val => FilterChanged?.Invoke(CreateCriteria());
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;

View File

@ -141,26 +141,24 @@ namespace osu.Game.Screens.Select.Leaderboards
Padding = new MarginPadding(edge_margin), Padding = new MarginPadding(edge_margin),
Children = new Drawable[] Children = new Drawable[]
{ {
avatar = new DelayedLoadContainer avatar = new DelayedLoadWrapper(
{
TimeBeforeLoad = 500,
FinishedLoading = d => d.FadeInFromZero(200),
Size = new Vector2(HEIGHT - edge_margin * 2, HEIGHT - edge_margin * 2),
Children = new Drawable[]
{
new Avatar(Score.User ?? new User { Id = Score.UserID }) new Avatar(Score.User ?? new User { Id = Score.UserID })
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
CornerRadius = corner_radius, CornerRadius = corner_radius,
Masking = true, Masking = true,
OnLoadComplete = d => d.FadeInFromZero(200),
EdgeEffect = new EdgeEffect EdgeEffect = new EdgeEffect
{ {
Type = EdgeEffectType.Shadow, Type = EdgeEffectType.Shadow,
Radius = 1, Radius = 1,
Colour = Color4.Black.Opacity(0.2f), Colour = Color4.Black.Opacity(0.2f),
}, },
}, })
} {
TimeBeforeLoad = 500,
RelativeSizeAxes = Axes.None,
Size = new Vector2(HEIGHT - edge_margin * 2, HEIGHT - edge_margin * 2),
}, },
new Container new Container
{ {

View File

@ -81,10 +81,10 @@ namespace osu.Game.Screens.Select
{ {
if (player != null) return; if (player != null) return;
(player = new PlayerLoader(new Player LoadComponentAsync(player = new PlayerLoader(new Player
{ {
Beatmap = Beatmap, //eagerly set this so it's present before push. Beatmap = Beatmap, //eagerly set this so it's present before push.
})).LoadAsync(Game, l => Push(player)); }), l => Push(player));
} }
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using OpenTK; using OpenTK;
@ -170,7 +169,7 @@ namespace osu.Game.Screens.Select
if (osu != null) if (osu != null)
playMode.BindTo(osu.PlayMode); playMode.BindTo(osu.PlayMode);
playMode.ValueChanged += playMode_ValueChanged; playMode.ValueChanged += val => Beatmap.PreferredPlayMode = val;
if (database == null) if (database == null)
database = beatmaps; database = beatmaps;
@ -276,8 +275,6 @@ namespace osu.Game.Screens.Select
initialAddSetsTask.Cancel(); initialAddSetsTask.Cancel();
} }
private void playMode_ValueChanged(object sender, EventArgs e) => Beatmap.PreferredPlayMode = playMode;
private void changeBackground(WorkingBeatmap beatmap) private void changeBackground(WorkingBeatmap beatmap)
{ {
var backgroundModeBeatmap = Background as BackgroundScreenBeatmap; var backgroundModeBeatmap = Background as BackgroundScreenBeatmap;

View File

@ -40,15 +40,11 @@ namespace osu.Game.Users
{ {
displayedAvatar?.FadeOut(300); displayedAvatar?.FadeOut(300);
displayedAvatar?.Expire(); displayedAvatar?.Expire();
Add(displayedAvatar = new AsyncLoadContainer Add(displayedAvatar = new AsyncLoadWrapper(new Avatar(user)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
FinishedLoading = d => d.FadeInFromZero(200), OnLoadComplete = d => d.FadeInFromZero(200),
Children = new[] }));
{
new Avatar(user) { RelativeSizeAxes = Axes.Both }
}
});
} }
} }
} }

View File

@ -142,7 +142,6 @@
<Compile Include="Overlays\LoginOverlay.cs" /> <Compile Include="Overlays\LoginOverlay.cs" />
<Compile Include="Overlays\MusicController.cs" /> <Compile Include="Overlays\MusicController.cs" />
<Compile Include="Beatmaps\Beatmap.cs" /> <Compile Include="Beatmaps\Beatmap.cs" />
<Compile Include="Beatmaps\Formats\ConstructableBeatmapDecoder.cs" />
<Compile Include="Beatmaps\WorkingBeatmap.cs" /> <Compile Include="Beatmaps\WorkingBeatmap.cs" />
<Compile Include="Beatmaps\Drawables\BeatmapSetHeader.cs" /> <Compile Include="Beatmaps\Drawables\BeatmapSetHeader.cs" />
<Compile Include="Beatmaps\Drawables\DifficultyIcon.cs" /> <Compile Include="Beatmaps\Drawables\DifficultyIcon.cs" />