diff --git a/osu-framework b/osu-framework index 42e26d49b9..777996fb97 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 42e26d49b9046fcb96c123b0dfb48e06d741e162 +Subproject commit 777996fb9731ba1895a5ab1323cbbc97259ff741 diff --git a/osu-resources b/osu-resources index ffccbeb98d..9f46a456dc 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit ffccbeb98dc9e8f0965520270b5885e63f244c83 +Subproject commit 9f46a456dc3a56dcbff09671a3f588b16a464106 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs new file mode 100644 index 0000000000..4cda14559f --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -0,0 +1,199 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Testing; +using osu.Game.Database; +using osu.Game.Overlays; + +namespace osu.Desktop.VisualTests.Tests +{ + public class TestCaseDirect : TestCase + { + public override string Description => @"osu!direct overlay"; + + private DirectOverlay direct; + private RulesetDatabase rulesets; + + public override void Reset() + { + base.Reset(); + + Add(direct = new DirectOverlay()); + newBeatmaps(); + + AddStep(@"toggle", direct.ToggleVisibility); + AddStep(@"result counts", () => direct.ResultAmounts = new DirectOverlay.ResultCounts(1, 4, 13)); + } + + [BackgroundDependencyLoader] + private void load(RulesetDatabase rulesets) + { + this.rulesets = rulesets; + } + + private void newBeatmaps() + { + var ruleset = rulesets.GetRuleset(0); + + direct.BeatmapSets = new[] + { + new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = @"OrVid", + Artist = @"An", + Author = @"RLC", + Source = @"", + }, + Beatmaps = new List + { + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 5.35f, + Metadata = new BeatmapMetadata(), + OnlineInfo = new BeatmapOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, + Preview = @"https://b.ppy.sh/preview/578332.mp3", + PlayCount = 97, + FavouriteCount = 72, + }, + }, + }, + }, + new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = @"tiny lamp", + Artist = @"fhana", + Author = @"Sotarks", + Source = @"ぎんぎつね", + }, + Beatmaps = new List + { + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 5.81f, + Metadata = new BeatmapMetadata(), + OnlineInfo = new BeatmapOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, + Preview = @"https//b.ppy.sh/preview/599627.mp3", + PlayCount = 3082, + FavouriteCount = 14, + }, + }, + }, + }, + new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = @"At Gwanghwamun", + Artist = @"KYUHYUN", + Author = @"Cerulean Veyron", + Source = @"", + }, + Beatmaps = new List + { + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 0.9f, + Metadata = new BeatmapMetadata(), + OnlineInfo = new BeatmapOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, + Preview = @"https//b.ppy.sh/preview/513268.mp3", + PlayCount = 2762, + FavouriteCount = 15, + }, + }, + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 1.1f, + }, + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 2.02f, + }, + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 3.49f, + }, + }, + }, + new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = @"RHAPSODY OF BLUE SKY", + Artist = @"fhana", + Author = @"[Kamiya]", + Source = @"小林さんちのメイドラゴン", + }, + Beatmaps = new List + { + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 1.26f, + Metadata = new BeatmapMetadata(), + OnlineInfo = new BeatmapOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, + Preview = @"https//b.ppy.sh/preview/586841.mp3", + PlayCount = 62317, + FavouriteCount = 161, + }, + }, + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 2.01f, + }, + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 2.87f, + }, + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 3.76f, + }, + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 3.93f, + }, + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 4.37f, + }, + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 5.13f, + }, + new BeatmapInfo + { + Ruleset = ruleset, + StarDifficulty = 5.42f, + }, + }, + }, + }; + } + } +} diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index 6bd9d35b80..e2cd2bf67b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -18,7 +18,7 @@ using osu.Game.Rulesets.Taiko.UI; using System.Collections.Generic; using osu.Desktop.VisualTests.Beatmaps; using osu.Framework.Allocation; -using osu.Game.Beatmaps.Timing; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Desktop.VisualTests.Tests { @@ -53,8 +53,8 @@ namespace osu.Desktop.VisualTests.Tests time += RNG.Next(50, 500); } - TimingInfo timing = new TimingInfo(); - timing.ControlPoints.Add(new ControlPoint + var controlPointInfo = new ControlPointInfo(); + controlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = 200 }); @@ -73,7 +73,7 @@ namespace osu.Desktop.VisualTests.Tests Author = @"peppy", }, }, - TimingInfo = timing + ControlPointInfo = controlPointInfo }); Add(new Drawable[] diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 04fcd8e94a..9dcba02849 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -7,10 +7,10 @@ using osu.Framework.Graphics; using osu.Game.Rulesets.Mania.UI; using System; using System.Collections.Generic; -using osu.Game.Beatmaps.Timing; using OpenTK; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Timing; namespace osu.Desktop.VisualTests.Tests { @@ -27,7 +27,7 @@ namespace osu.Desktop.VisualTests.Tests Action createPlayfield = (cols, pos) => { Clear(); - Add(new ManiaPlayfield(cols, new List()) + Add(new ManiaPlayfield(cols, new List()) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -41,7 +41,7 @@ namespace osu.Desktop.VisualTests.Tests Clear(); ManiaPlayfield playField; - Add(playField = new ManiaPlayfield(cols, new List { new ControlPoint { BeatLength = 200 } }) + Add(playField = new ManiaPlayfield(cols, new List { new TimingChange { BeatLength = 200 } }) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs new file mode 100644 index 0000000000..513bf24e0d --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -0,0 +1,57 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Framework.Graphics; +using osu.Game.Users; +using osu.Framework.Graphics.Containers; +using OpenTK; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseUserPanel : TestCase + { + public override string Description => @"Panels for displaying a user's status"; + + public override void Reset() + { + base.Reset(); + + UserPanel flyte; + UserPanel peppy; + Add(new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(10f), + Children = new[] + { + flyte = new UserPanel(new User + { + Username = @"flyte", + Id = 3103765, + Country = new Country { FlagName = @"JP" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/3103765/5b012e13611d5761caa7e24fecb3d3a16e1cf48fc2a3032cfd43dd444af83d82.jpeg" + }) { Width = 300 }, + peppy = new UserPanel(new User + { + Username = @"peppy", + Id = 2, + Country = new Country { FlagName = @"AU" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/2/08cad88747c235a64fca5f1b770e100f120827ded1ffe3b66bfcd19c940afa65.jpeg" + }) { Width = 300 }, + }, + }); + + flyte.Status.Value = new UserStatusOnline(); + peppy.Status.Value = new UserStatusSoloGame(); + + AddStep(@"spectating", () => { flyte.Status.Value = new UserStatusSpectating(); }); + AddStep(@"multiplaying", () => { flyte.Status.Value = new UserStatusMultiplayerGame(); }); + AddStep(@"modding", () => { flyte.Status.Value = new UserStatusModding(); }); + AddStep(@"offline", () => { flyte.Status.Value = new UserStatusOffline(); }); + AddStep(@"null status", () => { flyte.Status.Value = null; }); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index dbb1750b72..68dc8bb7b8 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -220,6 +220,8 @@ + + diff --git a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs index 8c896646bf..8772fc9f28 100644 --- a/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs +++ b/osu.Desktop/Beatmaps/IO/LegacyFilesystemReader.cs @@ -37,5 +37,7 @@ namespace osu.Desktop.Beatmaps.IO { // no-op } + + public override Stream GetUnderlyingStream() => null; } } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 0cad23304e..718e0967da 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -5,11 +5,11 @@ using System; using System.Linq; using osu.Game.Audio; using osu.Game.Beatmaps; -using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { @@ -32,11 +32,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy public DistanceObjectPatternGenerator(FastRandom random, HitObject hitObject, Beatmap beatmap, Pattern previousPattern) : base(random, hitObject, beatmap, previousPattern) { - ControlPoint overridePoint; - ControlPoint controlPoint = Beatmap.TimingInfo.TimingPointAt(hitObject.StartTime, out overridePoint); - convertType = PatternType.None; - if ((overridePoint ?? controlPoint)?.KiaiMode == false) + if (Beatmap.ControlPointInfo.EffectPointAt(hitObject.StartTime).KiaiMode) convertType = PatternType.LowProbability; var distanceData = hitObject as IHasDistance; @@ -44,13 +41,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy repeatCount = repeatsData?.RepeatCount ?? 1; - double speedAdjustment = beatmap.TimingInfo.SpeedMultiplierAt(hitObject.StartTime); - double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(hitObject.StartTime) * speedAdjustment; + TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(hitObject.StartTime); + DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(hitObject.StartTime); // The true distance, accounting for any repeats double distance = (distanceData?.Distance ?? 0) * repeatCount; // 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; + double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier / (timingPoint.BeatLength * difficultyPoint.SpeedMultiplier); // The duration of the osu! hit object double osuDuration = distance / osuVelocity; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs index d044ee8893..b1ba99d98b 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs @@ -6,7 +6,7 @@ using System.Linq; using OpenTK; using osu.Game.Audio; using osu.Game.Beatmaps; -using osu.Game.Beatmaps.Timing; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects; @@ -25,17 +25,14 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { StairType = lastStair; - ControlPoint overridePoint; - ControlPoint controlPoint = beatmap.TimingInfo.TimingPointAt(hitObject.StartTime, out overridePoint); + TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(hitObject.StartTime); + EffectControlPoint effectPoint = beatmap.ControlPointInfo.EffectPointAt(hitObject.StartTime); var positionData = hitObject as IHasPosition; float positionSeparation = ((positionData?.Position ?? Vector2.Zero) - previousPosition).Length; double timeSeparation = hitObject.StartTime - previousTime; - double beatLength = controlPoint.BeatLength; - bool kiai = (overridePoint ?? controlPoint).KiaiMode; - if (timeSeparation <= 125) { // More than 120 BPM @@ -72,12 +69,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy // More than 100 BPM stream convertType |= PatternType.ForceStack | PatternType.LowProbability; } - else if (positionSeparation < 20 && density >= beatLength / 2.5) + else if (positionSeparation < 20 && density >= timingPoint.BeatLength / 2.5) { // Low density stream convertType |= PatternType.Reverse | PatternType.LowProbability; } - else if (density < beatLength / 2.5 || kiai) + else if (density < timingPoint.BeatLength / 2.5 || effectPoint.KiaiMode) { // High density } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index d0519c61a8..42bb371975 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -1,10 +1,13 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK.Graphics; using OpenTK.Input; using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Input; +using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using osu.Game.Rulesets.Objects.Drawables; @@ -40,14 +43,53 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } } - protected override void Update() + protected override void CheckJudgement(bool userTriggered) { - if (Time.Current > HitObject.StartTime) - Colour = Color4.Green; + if (!userTriggered) + { + if (Judgement.TimeOffset > HitObject.HitWindows.Bad / 2) + Judgement.Result = HitResult.Miss; + return; + } + + double offset = Math.Abs(Judgement.TimeOffset); + + if (offset > HitObject.HitWindows.Miss / 2) + return; + + ManiaHitResult? tmpResult = HitObject.HitWindows.ResultFor(offset); + + if (tmpResult.HasValue) + { + Judgement.Result = HitResult.Hit; + Judgement.ManiaResult = tmpResult.Value; + } + else + Judgement.Result = HitResult.Miss; } protected override void UpdateState(ArmedState state) { + switch (State) + { + case ArmedState.Hit: + Colour = Color4.Green; + break; + } + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (Judgement.Result != HitResult.None) + return false; + + if (args.Key != Key) + return false; + + if (args.Repeat) + return false; + + return UpdateJudgement(true); } } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 41bbe08d56..30e71aeb5d 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Audio; -using osu.Game.Beatmaps.Timing; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Objects.Types; @@ -33,9 +33,9 @@ namespace osu.Game.Rulesets.Mania.Objects /// public HitWindows ReleaseHitWindows { get; protected set; } = new HitWindows(); - public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { - base.ApplyDefaults(timing, difficulty); + base.ApplyDefaults(controlPointInfo, difficulty); ReleaseHitWindows = HitWindows * release_window_lenience; } diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index e955f6658b..6c0cacd277 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Game.Beatmaps.Timing; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; using osu.Game.Rulesets.Mania.Judgements; @@ -17,9 +17,9 @@ namespace osu.Game.Rulesets.Mania.Objects /// public HitWindows HitWindows { get; protected set; } = new HitWindows(); - public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { - base.ApplyDefaults(timing, difficulty); + base.ApplyDefaults(controlPointInfo, difficulty); HitWindows = new HitWindows(difficulty.OverallDifficulty); } diff --git a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs index 2ff97047c0..cc8897840e 100644 --- a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs @@ -7,7 +7,7 @@ using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; -using osu.Game.Beatmaps.Timing; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Rulesets.Mania.Timing { @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mania.Timing private readonly List drawableControlPoints; - public ControlPointContainer(IEnumerable timingChanges) + public ControlPointContainer(IEnumerable timingChanges) { drawableControlPoints = timingChanges.Select(t => new DrawableControlPoint(t)).ToList(); Children = drawableControlPoints; @@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Mania.Timing /// private class DrawableControlPoint : Container { - private readonly ControlPoint timingChange; + private readonly TimingChange timingChange; protected override Container Content => content; private readonly Container content; @@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Mania.Timing /// the content container will scroll at twice the normal rate. /// /// The control point to create the drawable control point for. - public DrawableControlPoint(ControlPoint timingChange) + public DrawableControlPoint(TimingChange timingChange) { this.timingChange = timingChange; diff --git a/osu.Game.Rulesets.Mania/Timing/TimingChange.cs b/osu.Game.Rulesets.Mania/Timing/TimingChange.cs new file mode 100644 index 0000000000..9153ba6991 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Timing/TimingChange.cs @@ -0,0 +1,23 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Mania.Timing +{ + public class TimingChange + { + /// + /// The time at which this timing change happened. + /// + public double Time; + + /// + /// The beat length. + /// + public double BeatLength = 500; + + /// + /// The speed multiplier. + /// + public double SpeedMultiplier = 1; + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 72c60b28c9..c8cb5f6387 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -17,7 +17,6 @@ using System.Collections.Generic; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Judgements; -using osu.Game.Beatmaps.Timing; using System; using osu.Framework.Configuration; @@ -46,7 +45,7 @@ namespace osu.Game.Rulesets.Mania.UI public readonly ControlPointContainer ControlPointContainer; - public Column(IEnumerable timingChanges) + public Column(IEnumerable timingChanges) { RelativeSizeAxes = Axes.Y; Width = column_width; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 4d734d231f..95b7979e43 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -2,19 +2,22 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using System.Linq; using OpenTK; using OpenTK.Input; using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Lists; using osu.Game.Beatmaps; -using osu.Game.Beatmaps.Timing; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Scoring; +using osu.Game.Rulesets.Mania.Timing; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; @@ -33,22 +36,32 @@ namespace osu.Game.Rulesets.Mania.UI protected override Playfield CreatePlayfield() { - ControlPoint firstTimingChange = Beatmap.TimingInfo.ControlPoints.FirstOrDefault(t => t.TimingChange); + double lastSpeedMultiplier = 1; + double lastBeatLength = 500; - if (firstTimingChange == null) - throw new InvalidOperationException("The Beatmap contains no timing points!"); + // Merge timing + difficulty points + var allPoints = new SortedList(Comparer.Default); + allPoints.AddRange(Beatmap.ControlPointInfo.TimingPoints); + allPoints.AddRange(Beatmap.ControlPointInfo.DifficultyPoints); // Generate the timing points, making non-timing changes use the previous timing change - var timingChanges = Beatmap.TimingInfo.ControlPoints.Select(c => + var timingChanges = allPoints.Select(c => { - ControlPoint t = c.Clone(); + var timingPoint = c as TimingControlPoint; + var difficultyPoint = c as DifficultyControlPoint; - if (c.TimingChange) - firstTimingChange = c; - else - t.BeatLength = firstTimingChange.BeatLength; + if (timingPoint != null) + lastBeatLength = timingPoint.BeatLength; - return t; + if (difficultyPoint != null) + lastSpeedMultiplier = difficultyPoint.SpeedMultiplier; + + return new TimingChange + { + Time = c.Time, + BeatLength = lastBeatLength, + SpeedMultiplier = lastSpeedMultiplier + }; }); double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 70bdd3b13c..ff763f87c4 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -19,7 +19,6 @@ using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Timing; using osu.Framework.Input; -using osu.Game.Beatmaps.Timing; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; @@ -65,7 +64,7 @@ namespace osu.Game.Rulesets.Mania.UI private readonly int columnCount; - public ManiaPlayfield(int columnCount, IEnumerable timingChanges) + public ManiaPlayfield(int columnCount, IEnumerable timingChanges) { this.columnCount = columnCount; diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index a3f30acae0..9442d7cf8f 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -78,6 +78,7 @@ + diff --git a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs index 723a37ed7b..e6fd82e6c8 100644 --- a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs @@ -6,8 +6,8 @@ using OpenTK; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using OpenTK.Graphics; -using osu.Game.Beatmaps.Timing; using osu.Game.Database; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Rulesets.Osu.Objects { @@ -68,9 +68,9 @@ namespace osu.Game.Rulesets.Osu.Objects return OsuScoreResult.Miss; } - public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { - base.ApplyDefaults(timing, difficulty); + base.ApplyDefaults(controlPointInfo, difficulty); Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2; } diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index 6c0147a3de..3b44e38d5e 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Objects.Types; using System; using System.Collections.Generic; @@ -10,6 +9,7 @@ using osu.Game.Rulesets.Objects; using osu.Game.Database; using System.Linq; using osu.Game.Audio; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Rulesets.Osu.Objects { @@ -62,13 +62,16 @@ namespace osu.Game.Rulesets.Osu.Objects public double Velocity; public double TickDistance; - public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { - base.ApplyDefaults(timing, difficulty); + base.ApplyDefaults(controlPointInfo, difficulty); - double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier / timing.SpeedMultiplierAt(StartTime); + TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); + DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime); - Velocity = scoringDistance / timing.BeatLengthAt(StartTime); + double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier / difficultyPoint.SpeedMultiplier; + + Velocity = scoringDistance / timingPoint.BeatLength; TickDistance = scoringDistance / difficulty.SliderTickRate; } diff --git a/osu.Game.Rulesets.Osu/Objects/Spinner.cs b/osu.Game.Rulesets.Osu/Objects/Spinner.cs index 3761b62b65..eff60ba935 100644 --- a/osu.Game.Rulesets.Osu/Objects/Spinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Spinner.cs @@ -2,8 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Rulesets.Objects.Types; -using osu.Game.Beatmaps.Timing; using osu.Game.Database; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Rulesets.Osu.Objects { @@ -19,9 +19,9 @@ namespace osu.Game.Rulesets.Osu.Objects public override bool NewCombo => true; - public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { - base.ApplyDefaults(timing, difficulty); + base.ApplyDefaults(controlPointInfo, difficulty); SpinsRequired = (int)(Duration / 1000 * BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 3, 5, 7.5)); } diff --git a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs index a2dea3731e..5d44da78f9 100644 --- a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs +++ b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs @@ -12,6 +12,7 @@ using osu.Game.Database; using osu.Game.IO.Serialization; using osu.Game.Audio; using osu.Game.Rulesets.Beatmaps; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Rulesets.Taiko.Beatmaps { @@ -77,8 +78,11 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps { int repeats = repeatsData?.RepeatCount ?? 1; - double speedAdjustment = beatmap.TimingInfo.SpeedMultiplierAt(obj.StartTime); - double speedAdjustedBeatLength = beatmap.TimingInfo.BeatLengthAt(obj.StartTime) * speedAdjustment; + TimingControlPoint timingPoint = beatmap.ControlPointInfo.TimingPointAt(obj.StartTime); + DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(obj.StartTime); + + double speedAdjustment = difficultyPoint.SpeedMultiplier; + double speedAdjustedBeatLength = timingPoint.BeatLength * 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; diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs index 9f91488fe3..3ea05b6558 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/CirclePiece.cs @@ -7,6 +7,8 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Backgrounds; using OpenTK.Graphics; +using osu.Game.Beatmaps.ControlPoints; +using osu.Framework.Audio.Track; namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces { @@ -22,6 +24,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces public const float SYMBOL_SIZE = TaikoHitObject.DEFAULT_CIRCLE_DIAMETER * 0.45f; public const float SYMBOL_BORDER = 8; public const float SYMBOL_INNER_SIZE = SYMBOL_SIZE - 2 * SYMBOL_BORDER; + private const double pre_beat_transition_time = 80; /// /// The colour of the inner circle and outer glows. @@ -63,6 +66,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces public CirclePiece(bool isStrong = false) { + EarlyActivationMilliseconds = pre_beat_transition_time; + AddInternal(new Drawable[] { background = new CircularContainer @@ -139,14 +144,31 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces Content.Width = 1 / Content.Scale.X; } + private const float edge_alpha_kiai = 0.5f; + private void resetEdgeEffects() { background.EdgeEffect = new EdgeEffect { Type = EdgeEffectType.Glow, - Colour = AccentColour, - Radius = KiaiMode ? 50 : 8 + Colour = AccentColour.Opacity(KiaiMode ? edge_alpha_kiai : 1f), + Radius = KiaiMode ? 32 : 8 }; } + + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + if (!effectPoint.KiaiMode) + return; + + if (beatIndex % (int)timingPoint.TimeSignature != 0) + return; + + double duration = timingPoint.BeatLength * 2; + + background.FadeEdgeEffectTo(1, pre_beat_transition_time, EasingTypes.OutQuint); + using (background.BeginDelayedSequence(pre_beat_transition_time)) + background.FadeEdgeEffectTo(edge_alpha_kiai, duration, EasingTypes.OutQuint); + } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs index 83b2e59e44..5e7e9e6350 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs @@ -1,14 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; +using osu.Game.Graphics.Containers; namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces { - public class TaikoPiece : Container, IHasAccentColour + public class TaikoPiece : BeatSyncedContainer, IHasAccentColour { private Color4 accentColour; /// @@ -17,10 +17,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces public virtual Color4 AccentColour { get { return accentColour; } - set - { - accentColour = value; - } + set { accentColour = value; } } private bool kiaiMode; diff --git a/osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs index f79c01b643..18e3016fc3 100644 --- a/osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs +++ b/osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs @@ -5,9 +5,9 @@ using osu.Game.Rulesets.Objects.Types; using System; using System.Collections.Generic; using System.Linq; -using osu.Game.Beatmaps.Timing; using osu.Game.Database; using osu.Game.Audio; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Rulesets.Taiko.Objects { @@ -55,11 +55,13 @@ namespace osu.Game.Rulesets.Taiko.Objects /// private double tickSpacing = 100; - public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { - base.ApplyDefaults(timing, difficulty); + base.ApplyDefaults(controlPointInfo, difficulty); - tickSpacing = timing.BeatLengthAt(StartTime) / TickRate; + TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); + + tickSpacing = timingPoint.BeatLength / TickRate; RequiredGoodHits = TotalTicks * Math.Min(0.15, 0.05 + 0.10 / 6 * difficulty.OverallDifficulty); RequiredGreatHits = TotalTicks * Math.Min(0.30, 0.10 + 0.20 / 6 * difficulty.OverallDifficulty); diff --git a/osu.Game.Rulesets.Taiko/Objects/Hit.cs b/osu.Game.Rulesets.Taiko/Objects/Hit.cs index 136e89124c..f31472d0fd 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Hit.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Hit.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Game.Beatmaps.Timing; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; namespace osu.Game.Rulesets.Taiko.Objects @@ -23,9 +23,9 @@ namespace osu.Game.Rulesets.Taiko.Objects /// public double HitWindowMiss = 95; - public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { - base.ApplyDefaults(timing, difficulty); + base.ApplyDefaults(controlPointInfo, difficulty); HitWindowGreat = BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 50, 35, 20); HitWindowGood = BeatmapDifficulty.DifficultyRange(difficulty.OverallDifficulty, 120, 80, 50); diff --git a/osu.Game.Rulesets.Taiko/Objects/TaikoHitObject.cs b/osu.Game.Rulesets.Taiko/Objects/TaikoHitObject.cs index 6a6353fde2..79bb901112 100644 --- a/osu.Game.Rulesets.Taiko/Objects/TaikoHitObject.cs +++ b/osu.Game.Rulesets.Taiko/Objects/TaikoHitObject.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Game.Beatmaps.Timing; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Taiko.UI; @@ -13,12 +13,12 @@ namespace osu.Game.Rulesets.Taiko.Objects /// /// Diameter of a circle relative to the size of the . /// - public const float PLAYFIELD_RELATIVE_DIAMETER = 0.5f; + public const float PLAYFIELD_RELATIVE_DIAMETER = 0.45f; /// /// Scale multiplier for a strong circle. /// - public const float STRONG_CIRCLE_DIAMETER_SCALE = 1.5f; + public const float STRONG_CIRCLE_DIAMETER_SCALE = 1.4f; /// /// Default circle diameter. @@ -31,12 +31,12 @@ namespace osu.Game.Rulesets.Taiko.Objects public const float DEFAULT_STRONG_CIRCLE_DIAMETER = DEFAULT_CIRCLE_DIAMETER * STRONG_CIRCLE_DIAMETER_SCALE; /// - /// The time taken from the initial (off-screen) spawn position to the centre of the hit target for a of 1000ms. + /// The time taken from the initial (off-screen) spawn position to the centre of the hit target for a of 1000ms. /// private const double scroll_time = 6000; /// - /// Our adjusted taking into consideration local and other speed multipliers. + /// Our adjusted taking into consideration local and other speed multipliers. /// public double ScrollTime; @@ -51,17 +51,17 @@ namespace osu.Game.Rulesets.Taiko.Objects /// public bool Kiai { get; protected set; } - public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { - base.ApplyDefaults(timing, difficulty); + base.ApplyDefaults(controlPointInfo, difficulty); - ScrollTime = scroll_time * (timing.BeatLengthAt(StartTime) * timing.SpeedMultiplierAt(StartTime) / 1000) / difficulty.SliderMultiplier; + TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); + DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime); + EffectControlPoint effectPoint = controlPointInfo.EffectPointAt(StartTime); - ControlPoint overridePoint; - Kiai = timing.TimingPointAt(StartTime, out overridePoint).KiaiMode; + ScrollTime = scroll_time * (timingPoint.BeatLength * difficultyPoint.SpeedMultiplier / 1000) / difficulty.SliderMultiplier; - if (overridePoint != null) - Kiai |= overridePoint.KiaiMode; + Kiai |= effectPoint.KiaiMode; } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Taiko/UI/HitExplosion.cs b/osu.Game.Rulesets.Taiko/UI/HitExplosion.cs index 2ebdeaa5b0..c0c329c870 100644 --- a/osu.Game.Rulesets.Taiko/UI/HitExplosion.cs +++ b/osu.Game.Rulesets.Taiko/UI/HitExplosion.cs @@ -18,22 +18,23 @@ namespace osu.Game.Rulesets.Taiko.UI /// internal class HitExplosion : CircularContainer { - /// - /// The judgement this hit explosion visualises. - /// public readonly TaikoJudgement Judgement; private readonly Box innerFill; - public HitExplosion(TaikoJudgement judgement) - { - Judgement = judgement; + private readonly bool isRim; - Size = new Vector2(TaikoHitObject.DEFAULT_CIRCLE_DIAMETER); + public HitExplosion(TaikoJudgement judgement, bool isRim) + { + this.isRim = isRim; + + Judgement = judgement; Anchor = Anchor.Centre; Origin = Anchor.Centre; + Size = new Vector2(TaikoPlayfield.HIT_TARGET_OFFSET + TaikoHitObject.DEFAULT_CIRCLE_DIAMETER); + RelativePositionAxes = Axes.Both; BorderColour = Color4.White; @@ -54,22 +55,14 @@ namespace osu.Game.Rulesets.Taiko.UI [BackgroundDependencyLoader] private void load(OsuColour colours) { - switch (Judgement.TaikoResult) - { - case TaikoHitResult.Good: - innerFill.Colour = colours.Green; - break; - case TaikoHitResult.Great: - innerFill.Colour = colours.Blue; - break; - } + innerFill.Colour = isRim ? colours.BlueDarker : colours.PinkDarker; } protected override void LoadComplete() { base.LoadComplete(); - ScaleTo(5f, 1000, EasingTypes.OutQuint); + ScaleTo(3f, 1000, EasingTypes.OutQuint); FadeOut(500); Expire(); @@ -80,7 +73,7 @@ namespace osu.Game.Rulesets.Taiko.UI /// public void VisualiseSecondHit() { - ResizeTo(Size * TaikoHitObject.STRONG_CIRCLE_DIAMETER_SCALE, 50); + ResizeTo(new Vector2(TaikoPlayfield.HIT_TARGET_OFFSET + TaikoHitObject.DEFAULT_STRONG_CIRCLE_DIAMETER), 50); } } } diff --git a/osu.Game.Rulesets.Taiko/UI/KiaiHitExplosion.cs b/osu.Game.Rulesets.Taiko/UI/KiaiHitExplosion.cs new file mode 100644 index 0000000000..e0da3ed3db --- /dev/null +++ b/osu.Game.Rulesets.Taiko/UI/KiaiHitExplosion.cs @@ -0,0 +1,68 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Rulesets.Taiko.Judgements; +using osu.Game.Rulesets.Taiko.Objects; + +namespace osu.Game.Rulesets.Taiko.UI +{ + public class KiaiHitExplosion : CircularContainer + { + public readonly TaikoJudgement Judgement; + + private readonly bool isRim; + + public KiaiHitExplosion(TaikoJudgement judgement, bool isRim) + { + this.isRim = isRim; + + Judgement = judgement; + + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + + RelativeSizeAxes = Axes.Y; + Size = new Vector2(TaikoHitObject.DEFAULT_CIRCLE_DIAMETER, 1); + + Masking = true; + Alpha = 0.25f; + + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Colour = isRim ? colours.BlueDarker : colours.PinkDarker, + Radius = 60, + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + ScaleTo(new Vector2(1, 3f), 500, EasingTypes.OutQuint); + FadeOut(250); + + Expire(); + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoHitRenderer.cs b/osu.Game.Rulesets.Taiko/UI/TaikoHitRenderer.cs index 73450d576d..662cace511 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoHitRenderer.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoHitRenderer.cs @@ -17,6 +17,7 @@ using osu.Game.Rulesets.UI; using osu.Game.Rulesets.Taiko.Replays; using OpenTK; using osu.Game.Rulesets.Beatmaps; +using System.Linq; namespace osu.Game.Rulesets.Taiko.UI { @@ -43,7 +44,7 @@ namespace osu.Game.Rulesets.Taiko.UI 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); + var timingPoints = Beatmap.ControlPointInfo.TimingPoints.ToList(); if (timingPoints.Count == 0) return; @@ -68,7 +69,7 @@ namespace osu.Game.Rulesets.Taiko.UI StartTime = time, }; - barLine.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty); + barLine.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.Difficulty); bool isMajor = currentBeat % (int)currentPoint.TimeSignature == 0; taikoPlayfield.AddBarLine(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine)); diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 2278158506..c7bd4a6704 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -24,12 +24,12 @@ namespace osu.Game.Rulesets.Taiko.UI /// /// The default play field height. /// - public const float DEFAULT_PLAYFIELD_HEIGHT = 168f; + public const float DEFAULT_PLAYFIELD_HEIGHT = 178f; /// /// The offset from which the center of the hit target lies at. /// - private const float hit_target_offset = TaikoHitObject.DEFAULT_STRONG_CIRCLE_DIAMETER / 2f + 40; + public const float HIT_TARGET_OFFSET = TaikoHitObject.DEFAULT_STRONG_CIRCLE_DIAMETER / 2f + 40; /// /// The size of the left area of the playfield. This area contains the input drum. @@ -39,15 +39,18 @@ namespace osu.Game.Rulesets.Taiko.UI protected override Container Content => hitObjectContainer; private readonly Container hitExplosionContainer; + private readonly Container kiaiExplosionContainer; private readonly Container barLineContainer; private readonly Container judgementContainer; private readonly Container hitObjectContainer; private readonly Container topLevelHitContainer; - private readonly Container leftBackgroundContainer; - private readonly Container rightBackgroundContainer; - private readonly Box leftBackground; - private readonly Box rightBackground; + + private readonly Container overlayBackgroundContainer; + private readonly Container backgroundContainer; + + private readonly Box overlayBackground; + private readonly Box background; public TaikoPlayfield() { @@ -59,7 +62,7 @@ namespace osu.Game.Rulesets.Taiko.UI Height = DEFAULT_PLAYFIELD_HEIGHT, Children = new[] { - rightBackgroundContainer = new Container + backgroundContainer = new Container { Name = "Transparent playfield background", RelativeSizeAxes = Axes.Both, @@ -73,7 +76,7 @@ namespace osu.Game.Rulesets.Taiko.UI }, Children = new Drawable[] { - rightBackground = new Box + background = new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.6f @@ -82,24 +85,23 @@ namespace osu.Game.Rulesets.Taiko.UI }, new Container { - Name = "Transparent playfield elements", + Name = "Right area", RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Left = left_area_size }, + Margin = new MarginPadding { Left = left_area_size }, Children = new Drawable[] { new Container { - Name = "Hit target container", - X = hit_target_offset, + Name = "Masked elements", RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = HIT_TARGET_OFFSET }, + Masking = true, Children = new Drawable[] { hitExplosionContainer = new Container { - Anchor = Anchor.CentreLeft, - Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, - BlendingMode = BlendingMode.Additive + BlendingMode = BlendingMode.Additive, }, barLineContainer = new Container { @@ -114,23 +116,32 @@ namespace osu.Game.Rulesets.Taiko.UI { RelativeSizeAxes = Axes.Both, }, - judgementContainer = new Container - { - RelativeSizeAxes = Axes.Y, - BlendingMode = BlendingMode.Additive - }, - }, + } + }, + kiaiExplosionContainer = new Container + { + Name = "Kiai hit explosions", + RelativeSizeAxes = Axes.Y, + Margin = new MarginPadding { Left = HIT_TARGET_OFFSET }, + BlendingMode = BlendingMode.Additive + }, + judgementContainer = new Container + { + Name = "Judgements", + RelativeSizeAxes = Axes.Y, + Margin = new MarginPadding { Left = HIT_TARGET_OFFSET }, + BlendingMode = BlendingMode.Additive }, } }, - leftBackgroundContainer = new Container + overlayBackgroundContainer = new Container { Name = "Left overlay", Size = new Vector2(left_area_size, DEFAULT_PLAYFIELD_HEIGHT), BorderThickness = 1, Children = new Drawable[] { - leftBackground = new Box + overlayBackground = new Box { RelativeSizeAxes = Axes.Both, }, @@ -164,11 +175,11 @@ namespace osu.Game.Rulesets.Taiko.UI [BackgroundDependencyLoader] private void load(OsuColour colours) { - leftBackgroundContainer.BorderColour = colours.Gray0; - leftBackground.Colour = colours.Gray1; + overlayBackgroundContainer.BorderColour = colours.Gray0; + overlayBackground.Colour = colours.Gray1; - rightBackgroundContainer.BorderColour = colours.Gray1; - rightBackground.Colour = colours.Gray0; + backgroundContainer.BorderColour = colours.Gray1; + background.Colour = colours.Gray0; } public override void Add(DrawableHitObject h) @@ -204,6 +215,8 @@ namespace osu.Game.Rulesets.Taiko.UI if (!wasHit) return; + bool isRim = judgedObject.HitObject is RimHit; + if (!secondHit) { if (judgedObject.X >= -0.05f && !(judgedObject is DrawableSwell)) @@ -212,7 +225,11 @@ namespace osu.Game.Rulesets.Taiko.UI topLevelHitContainer.Add(judgedObject.CreateProxy()); } - hitExplosionContainer.Add(new HitExplosion(judgedObject.Judgement)); + hitExplosionContainer.Add(new HitExplosion(judgedObject.Judgement, isRim)); + + if (judgedObject.HitObject.Kiai) + kiaiExplosionContainer.Add(new KiaiHitExplosion(judgedObject.Judgement, isRim)); + } else hitExplosionContainer.Children.FirstOrDefault(e => e.Judgement == judgedObject.Judgement)?.VisualiseSecondHit(); @@ -221,7 +238,7 @@ namespace osu.Game.Rulesets.Taiko.UI /// /// This is a very special type of container. It serves a similar purpose to , however unlike , /// this will only adjust the scale relative to the height of its parent and will maintain the original width relative to its parent. - /// + /// /// /// By adjusting the scale relative to the height of its parent, the aspect ratio of this container's children is maintained, however this is undesirable /// in the case where the hit object container should not have its width adjusted by scale. To counteract this, another container is nested inside this diff --git a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj index 983dc72d9e..8d6fcb503c 100644 --- a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj +++ b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj @@ -87,6 +87,7 @@ + diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index 608b2fcd19..0368455b92 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -7,6 +7,7 @@ using osu.Game.Database; using osu.Game.Rulesets.Objects; using System.Collections.Generic; using System.Linq; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Beatmaps { @@ -17,7 +18,7 @@ namespace osu.Game.Beatmaps where T : HitObject { public BeatmapInfo BeatmapInfo; - public TimingInfo TimingInfo = new TimingInfo(); + public ControlPointInfo ControlPointInfo = new ControlPointInfo(); public List Breaks = new List(); public readonly List ComboColors = new List { @@ -46,7 +47,7 @@ namespace osu.Game.Beatmaps public Beatmap(Beatmap original = null) { BeatmapInfo = original?.BeatmapInfo ?? BeatmapInfo; - TimingInfo = original?.TimingInfo ?? TimingInfo; + ControlPointInfo = original?.ControlPointInfo ?? ControlPointInfo; Breaks = original?.Breaks ?? Breaks; ComboColors = original?.ComboColors ?? ComboColors; } diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs new file mode 100644 index 0000000000..0d1dc21e96 --- /dev/null +++ b/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs @@ -0,0 +1,17 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; + +namespace osu.Game.Beatmaps.ControlPoints +{ + public class ControlPoint : IComparable + { + /// + /// The time at which the control point takes effect. + /// + public double Time; + + public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time); + } +} diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs new file mode 100644 index 0000000000..acf90931ac --- /dev/null +++ b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs @@ -0,0 +1,107 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Lists; + +namespace osu.Game.Beatmaps.ControlPoints +{ + public class ControlPointInfo + { + /// + /// All timing points. + /// + public readonly SortedList TimingPoints = new SortedList(Comparer.Default); + + /// + /// All difficulty points. + /// + public readonly SortedList DifficultyPoints = new SortedList(Comparer.Default); + + /// + /// All sound points. + /// + public readonly SortedList SoundPoints = new SortedList(Comparer.Default); + + /// + /// All effect points. + /// + public readonly SortedList EffectPoints = new SortedList(Comparer.Default); + + /// + /// Finds the difficulty control point that is active at . + /// + /// The time to find the difficulty control point at. + /// The difficulty control point. + public DifficultyControlPoint DifficultyPointAt(double time) => binarySearch(DifficultyPoints, time); + + /// + /// Finds the effect control point that is active at . + /// + /// The time to find the effect control point at. + /// The effect control point. + public EffectControlPoint EffectPointAt(double time) => binarySearch(EffectPoints, time); + + /// + /// Finds the sound control point that is active at . + /// + /// The time to find the sound control point at. + /// The sound control point. + public SoundControlPoint SoundPointAt(double time) => binarySearch(SoundPoints, time); + + /// + /// Finds the timing control point that is active at . + /// + /// The time to find the timing control point at. + /// The timing control point. + public TimingControlPoint TimingPointAt(double time) => binarySearch(TimingPoints, time, TimingPoints.FirstOrDefault()); + + /// + /// Finds the maximum BPM represented by any timing control point. + /// + public double BPMMaximum => + 60000 / (TimingPoints.OrderBy(c => c.BeatLength).FirstOrDefault() ?? new TimingControlPoint()).BeatLength; + + /// + /// Finds the minimum BPM represented by any timing control point. + /// + public double BPMMinimum => + 60000 / (TimingPoints.OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? new TimingControlPoint()).BeatLength; + + /// + /// Finds the mode BPM (most common BPM) represented by the control points. + /// + public double BPMMode => + 60000 / (TimingPoints.GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).FirstOrDefault()?.FirstOrDefault() ?? new TimingControlPoint()).BeatLength; + + /// + /// Binary searches one of the control point lists to find the active control point at . + /// + /// The list to search. + /// The time to find the control point at. + /// The control point to use when is before any control points. If null, a new control point will be constructed. + /// The active control point at . + private T binarySearch(SortedList list, double time, T prePoint = null) + where T : ControlPoint, new() + { + if (list.Count == 0) + return new T(); + + if (time < list[0].Time) + return prePoint ?? new T(); + + int index = list.BinarySearch(new T() { Time = time }); + + // Check if we've found an exact match (t == time) + if (index >= 0) + return list[index]; + + index = ~index; + + // BinarySearch will return the index of the first element _greater_ than the search + // This is the inactive point - the active point is the one before it (index - 1) + return list[index - 1]; + } + } +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs new file mode 100644 index 0000000000..30c7884334 --- /dev/null +++ b/osu.Game/Beatmaps/ControlPoints/DifficultyControlPoint.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.ControlPoints +{ + public class DifficultyControlPoint : ControlPoint + { + /// + /// The speed multiplier at this control point. + /// + public double SpeedMultiplier = 1; + } +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs new file mode 100644 index 0000000000..7671739cd9 --- /dev/null +++ b/osu.Game/Beatmaps/ControlPoints/EffectControlPoint.cs @@ -0,0 +1,18 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.ControlPoints +{ + public class EffectControlPoint : ControlPoint + { + /// + /// Whether this control point enables Kiai mode. + /// + public bool KiaiMode; + + /// + /// Whether the first bar line of this control point is ignored. + /// + public bool OmitFirstBarLine; + } +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/ControlPoints/SoundControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/SoundControlPoint.cs new file mode 100644 index 0000000000..8084229382 --- /dev/null +++ b/osu.Game/Beatmaps/ControlPoints/SoundControlPoint.cs @@ -0,0 +1,18 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Beatmaps.ControlPoints +{ + public class SoundControlPoint : ControlPoint + { + /// + /// The default sample bank at this control point. + /// + public string SampleBank; + + /// + /// The default sample volume at this control point. + /// + public int SampleVolume; + } +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs b/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs new file mode 100644 index 0000000000..6f7e38c163 --- /dev/null +++ b/osu.Game/Beatmaps/ControlPoints/TimingControlPoint.cs @@ -0,0 +1,20 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps.Timing; + +namespace osu.Game.Beatmaps.ControlPoints +{ + public class TimingControlPoint : ControlPoint + { + /// + /// The time signature at this control point. + /// + public TimeSignatures TimeSignature = TimeSignatures.SimpleQuadruple; + + /// + /// The beat length at this control point. + /// + public double BeatLength = 500; + } +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/DifficultyCalculator.cs b/osu.Game/Beatmaps/DifficultyCalculator.cs index f483d1e6e3..474d38aa1b 100644 --- a/osu.Game/Beatmaps/DifficultyCalculator.cs +++ b/osu.Game/Beatmaps/DifficultyCalculator.cs @@ -37,7 +37,7 @@ namespace osu.Game.Beatmaps Objects = CreateBeatmapConverter().Convert(beatmap, true).HitObjects; foreach (var h in Objects) - h.ApplyDefaults(beatmap.TimingInfo, beatmap.BeatmapInfo.Difficulty); + h.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.Difficulty); PreprocessHitObjects(); } diff --git a/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs b/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs index 7c0aa49d2a..e91b52565a 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyColouredContainer.cs @@ -9,7 +9,7 @@ using OpenTK.Graphics; namespace osu.Game.Beatmaps.Drawables { - internal class DifficultyColouredContainer : Container, IHasAccentColour + public class DifficultyColouredContainer : Container, IHasAccentColour { public Color4 AccentColour { get; set; } diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index a8b63c2502..9df1f0f284 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -11,7 +11,7 @@ using OpenTK.Graphics; namespace osu.Game.Beatmaps.Drawables { - internal class DifficultyIcon : DifficultyColouredContainer + public class DifficultyIcon : DifficultyColouredContainer { private readonly BeatmapInfo beatmap; diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 04208337c7..cb1d9d2fcd 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -8,6 +8,7 @@ using OpenTK.Graphics; using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Legacy; using osu.Game.Rulesets.Objects.Legacy; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Beatmaps.Formats { @@ -241,6 +242,7 @@ namespace osu.Game.Beatmaps.Formats double time = double.Parse(split[0].Trim(), NumberFormatInfo.InvariantInfo); double beatLength = double.Parse(split[1].Trim(), NumberFormatInfo.InvariantInfo); + double speedMultiplier = beatLength < 0 ? -beatLength / 100.0 : 1; TimeSignatures timeSignature = TimeSignatures.SimpleQuadruple; if (split.Length >= 3) @@ -275,18 +277,48 @@ namespace osu.Game.Beatmaps.Formats if (stringSampleSet == @"none") stringSampleSet = @"normal"; - beatmap.TimingInfo.ControlPoints.Add(new ControlPoint + DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(time); + SoundControlPoint soundPoint = beatmap.ControlPointInfo.SoundPointAt(time); + EffectControlPoint effectPoint = beatmap.ControlPointInfo.EffectPointAt(time); + + if (timingChange) { - Time = time, - BeatLength = beatLength, - SpeedMultiplier = beatLength < 0 ? -beatLength / 100.0 : 1, - TimingChange = timingChange, - TimeSignature = timeSignature, - SampleBank = stringSampleSet, - SampleVolume = sampleVolume, - KiaiMode = kiaiMode, - OmitFirstBarLine = omitFirstBarSignature - }); + beatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint + { + Time = time, + BeatLength = beatLength, + TimeSignature = timeSignature + }); + } + + if (speedMultiplier != difficultyPoint.SpeedMultiplier) + { + beatmap.ControlPointInfo.DifficultyPoints.Add(new DifficultyControlPoint + { + Time = time, + SpeedMultiplier = speedMultiplier + }); + } + + if (stringSampleSet != soundPoint.SampleBank || sampleVolume != soundPoint.SampleVolume) + { + beatmap.ControlPointInfo.SoundPoints.Add(new SoundControlPoint + { + Time = time, + SampleBank = stringSampleSet, + SampleVolume = sampleVolume + }); + } + + if (kiaiMode != effectPoint.KiaiMode || omitFirstBarSignature != effectPoint.OmitFirstBarLine) + { + beatmap.ControlPointInfo.EffectPoints.Add(new EffectControlPoint + { + Time = time, + KiaiMode = kiaiMode, + OmitFirstBarLine = omitFirstBarSignature + }); + } } private void handleColours(Beatmap beatmap, string key, string val, ref bool hasCustomColours) diff --git a/osu.Game/Beatmaps/IO/ArchiveReader.cs b/osu.Game/Beatmaps/IO/ArchiveReader.cs index 9d7d67007e..7ff5668b6f 100644 --- a/osu.Game/Beatmaps/IO/ArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/ArchiveReader.cs @@ -63,5 +63,7 @@ namespace osu.Game.Beatmaps.IO return buffer; } } + + public abstract Stream GetUnderlyingStream(); } } \ No newline at end of file diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index 6c550def8d..eb9e740779 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -49,5 +49,7 @@ namespace osu.Game.Beatmaps.IO archive.Dispose(); archiveStream.Dispose(); } + + public override Stream GetUnderlyingStream() => archiveStream; } } \ No newline at end of file diff --git a/osu.Game/Beatmaps/Timing/ControlPoint.cs b/osu.Game/Beatmaps/Timing/ControlPoint.cs deleted file mode 100644 index fbae7d9614..0000000000 --- a/osu.Game/Beatmaps/Timing/ControlPoint.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -namespace osu.Game.Beatmaps.Timing -{ - public class ControlPoint - { - public string SampleBank; - public int SampleVolume; - public TimeSignatures TimeSignature = TimeSignatures.SimpleQuadruple; - public double Time; - public double BeatLength = 500; - public double SpeedMultiplier = 1; - public bool TimingChange = true; - public bool KiaiMode; - public bool OmitFirstBarLine; - - public ControlPoint Clone() => (ControlPoint)MemberwiseClone(); - } -} diff --git a/osu.Game/Beatmaps/Timing/TimingInfo.cs b/osu.Game/Beatmaps/Timing/TimingInfo.cs deleted file mode 100644 index 19cb0816ba..0000000000 --- a/osu.Game/Beatmaps/Timing/TimingInfo.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System.Collections.Generic; -using System.Linq; - -namespace osu.Game.Beatmaps.Timing -{ - public class TimingInfo - { - public readonly List ControlPoints = new List(); - - public double BPMMaximum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).FirstOrDefault() ?? new ControlPoint()).BeatLength; - public double BPMMinimum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? new ControlPoint()).BeatLength; - public double BPMMode => BPMAt(ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time); - - public double BPMAt(double time) - { - return 60000 / BeatLengthAt(time); - } - - /// - /// Finds the speed multiplier at a time. - /// - /// The time to find the speed multiplier at. - /// The speed multiplier. - public double SpeedMultiplierAt(double time) - { - ControlPoint overridePoint; - ControlPoint timingPoint = TimingPointAt(time, out overridePoint); - - return overridePoint?.SpeedMultiplier ?? timingPoint?.SpeedMultiplier ?? 1; - } - - /// - /// Finds the beat length at a time. This is expressed in milliseconds. - /// - /// The time to find the beat length at. - /// The beat length. - public double BeatLengthAt(double time) - { - ControlPoint overridePoint; - ControlPoint timingPoint = TimingPointAt(time, out overridePoint); - - return timingPoint.BeatLength; - } - - /// - /// Finds the timing point at a time. - /// - /// The time to find the timing point at. - /// The timing point containing the velocity change of the returned timing point. - /// The timing point. - public ControlPoint TimingPointAt(double time, out ControlPoint overridePoint) - { - overridePoint = null; - - ControlPoint timingPoint = null; - foreach (var controlPoint in ControlPoints) - { - // Some beatmaps have the first timingPoint (accidentally) start after the first HitObject(s). - // This null check makes it so that the first ControlPoint that makes a timing change is used as - // the timingPoint for those HitObject(s). - if (controlPoint.Time <= time || timingPoint == null) - { - if (controlPoint.TimingChange) - { - timingPoint = controlPoint; - overridePoint = null; - } - else - overridePoint = controlPoint; - } - else break; - } - - return timingPoint ?? new ControlPoint(); - } - } -} \ No newline at end of file diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index bd25ebe8a9..efd5631077 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -12,6 +12,7 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.IO; using osu.Game.IPC; +using osu.Game.Screens.Menu; using SQLite.Net; using SQLiteNetExtensions.Extensions; @@ -38,6 +39,10 @@ namespace osu.Game.Database { foreach (var b in GetAllWithChildren(b => b.DeletePending)) { + if (b.Hash == Intro.MENU_MUSIC_BEATMAP_HASH) + // this is a bit hacky, but will do for now. + continue; + try { Storage.Delete(b.Path); @@ -97,50 +102,49 @@ namespace osu.Game.Database typeof(BeatmapDifficulty), }; + public void Import(string path) + { + try + { + Import(ArchiveReader.GetReader(Storage, path)); + + // We may or may not want to delete the file depending on where it is stored. + // e.g. reconstructing/repairing database with beatmaps from default storage. + // Also, not always a single file, i.e. for LegacyFilesystemReader + // TODO: Add a check to prevent files from storage to be deleted. + try + { + File.Delete(path); + } + catch (Exception e) + { + Logger.Error(e, $@"Could not delete file at {path}"); + } + } + catch (Exception e) + { + e = e.InnerException ?? e; + Logger.Error(e, @"Could not import beatmap set"); + } + } + + public void Import(ArchiveReader archiveReader) + { + BeatmapSetInfo set = getBeatmapSet(archiveReader); + + //If we have an ID then we already exist in the database. + if (set.ID == 0) + Import(new[] { set }); + } + /// /// Import multiple from . /// /// Multiple locations on disk - public void Import(IEnumerable paths) + public void Import(params string[] paths) { foreach (string p in paths) - { - try - { - BeatmapSetInfo set = getBeatmapSet(p); - - //If we have an ID then we already exist in the database. - if (set.ID == 0) - Import(new[] { set }); - - // We may or may not want to delete the file depending on where it is stored. - // e.g. reconstructing/repairing database with beatmaps from default storage. - // Also, not always a single file, i.e. for LegacyFilesystemReader - // TODO: Add a check to prevent files from storage to be deleted. - try - { - File.Delete(p); - } - catch (Exception e) - { - Logger.Error(e, $@"Could not delete file at {p}"); - } - } - catch (Exception e) - { - e = e.InnerException ?? e; - Logger.Error(e, @"Could not import beatmap set"); - } - } - } - - /// - /// Import from . - /// - /// Location on disk - public void Import(string path) - { - Import(new[] { path }); + Import(p); } /// @@ -148,29 +152,26 @@ namespace osu.Game.Database /// /// Content location /// - private BeatmapSetInfo getBeatmapSet(string path) - { - string hash = null; + private BeatmapSetInfo getBeatmapSet(string path) => getBeatmapSet(ArchiveReader.GetReader(Storage, path)); + private BeatmapSetInfo getBeatmapSet(ArchiveReader archiveReader) + { BeatmapMetadata metadata; - using (var reader = ArchiveReader.GetReader(Storage, path)) - { - using (var stream = new StreamReader(reader.GetStream(reader.BeatmapFilenames[0]))) - metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata; - } + using (var stream = new StreamReader(archiveReader.GetStream(archiveReader.BeatmapFilenames[0]))) + metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata; - if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader + string hash; + string path; + + using (var input = archiveReader.GetUnderlyingStream()) { - using (var input = Storage.GetStream(path)) - { - hash = input.GetMd5Hash(); - input.Seek(0, SeekOrigin.Begin); - path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash); - if (!Storage.Exists(path)) - using (var output = Storage.GetStream(path, FileAccess.Write)) - input.CopyTo(output); - } + hash = input.GetMd5Hash(); + input.Seek(0, SeekOrigin.Begin); + path = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash); + if (!Storage.Exists(path)) + using (var output = Storage.GetStream(path, FileAccess.Write)) + input.CopyTo(output); } var existing = Connection.Table().FirstOrDefault(b => b.Hash == hash); diff --git a/osu.Game/Database/BeatmapInfo.cs b/osu.Game/Database/BeatmapInfo.cs index c2e35d64a8..9f253f6055 100644 --- a/osu.Game/Database/BeatmapInfo.cs +++ b/osu.Game/Database/BeatmapInfo.cs @@ -43,6 +43,9 @@ namespace osu.Game.Database [Ignore] public BeatmapMetrics Metrics { get; set; } + [Ignore] + public BeatmapOnlineInfo OnlineInfo { get; set; } + public string Path { get; set; } [JsonProperty("file_md5")] diff --git a/osu.Game/Database/BeatmapOnlineInfo.cs b/osu.Game/Database/BeatmapOnlineInfo.cs new file mode 100644 index 0000000000..bcb2ef16ac --- /dev/null +++ b/osu.Game/Database/BeatmapOnlineInfo.cs @@ -0,0 +1,38 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace osu.Game.Database +{ + /// + /// Beatmap info retrieved for previewing locally without having the beatmap downloaded. + /// + public class BeatmapOnlineInfo + { + /// + /// The different sizes of cover art for this beatmap: cover, cover@2x, card, card@2x, list, list@2x. + /// + [JsonProperty(@"covers")] + public IEnumerable Covers { get; set; } + + /// + /// A small sample clip of this beatmap's song. + /// + [JsonProperty(@"previewUrl")] + public string Preview { get; set; } + + /// + /// The amount of plays this beatmap has. + /// + [JsonProperty(@"play_count")] + public int PlayCount { get; set; } + + /// + /// The amount of people who have favourited this map. + /// + [JsonProperty(@"favourite_count")] + public int FavouriteCount { get; set; } + } +} diff --git a/osu.Game/Database/OnlineWorkingBeatmap.cs b/osu.Game/Database/OnlineWorkingBeatmap.cs new file mode 100644 index 0000000000..1465c59434 --- /dev/null +++ b/osu.Game/Database/OnlineWorkingBeatmap.cs @@ -0,0 +1,37 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using osu.Framework.Audio.Track; +using osu.Framework.Graphics.Textures; +using osu.Game.Beatmaps; + +namespace osu.Game.Database +{ + internal class OnlineWorkingBeatmap : WorkingBeatmap + { + private readonly TextureStore textures; + private readonly TrackManager tracks; + + public OnlineWorkingBeatmap(BeatmapInfo beatmapInfo, TextureStore textures, TrackManager tracks) : base(beatmapInfo) + { + this.textures = textures; + this.tracks = tracks; + } + + protected override Beatmap GetBeatmap() + { + return new Beatmap(); + } + + protected override Texture GetBackground() + { + return textures.Get(BeatmapInfo.OnlineInfo.Covers.FirstOrDefault()); + } + + protected override Track GetTrack() + { + return tracks.Get(BeatmapInfo.OnlineInfo.Preview); + } + } +} diff --git a/osu.Game/Database/RankStatus.cs b/osu.Game/Database/RankStatus.cs new file mode 100644 index 0000000000..f2a7d67a40 --- /dev/null +++ b/osu.Game/Database/RankStatus.cs @@ -0,0 +1,23 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.ComponentModel; + +namespace osu.Game.Database +{ + public enum RankStatus + { + Any = 7, + [Description("Ranked & Approved")] + RankedApproved = 0, + Approved = 1, + Loved = 8, + Favourites = 2, + [Description("Mod Requests")] + ModRequests = 3, + Pending = 4, + Graveyard = 5, + [Description("My Maps")] + MyMaps = 6, + } +} diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 830d0adc97..5cca57be8a 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -44,6 +44,11 @@ namespace osu.Game.Graphics.Backgrounds /// public bool HideAlphaDiscrepancies = true; + /// + /// The relative velocity of the triangles. Default is 1. + /// + public float Velocity = 1; + public float TriangleScale { get { return triangleScale; } @@ -78,7 +83,7 @@ namespace osu.Game.Graphics.Backgrounds foreach (var t in Children) { t.Alpha = adjustedAlpha; - t.Position -= new Vector2(0, (float)(t.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale); + t.Position -= new Vector2(0, (float)(t.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale * Velocity); if (ExpireOffScreenTriangles && t.DrawPosition.Y + t.DrawSize.Y * t.Scale.Y < 0) t.Expire(); } diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs new file mode 100644 index 0000000000..c0defceac0 --- /dev/null +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -0,0 +1,67 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Audio.Track; +using osu.Framework.Configuration; +using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.ControlPoints; + +namespace osu.Game.Graphics.Containers +{ + public class BeatSyncedContainer : Container + { + protected readonly Bindable Beatmap = new Bindable(); + + private int lastBeat; + private TimingControlPoint lastTimingPoint; + + /// + /// The amount of time before a beat we should fire . + /// This allows for adding easing to animations that may be synchronised to the beat. + /// + protected double EarlyActivationMilliseconds; + + protected override void Update() + { + if (Beatmap.Value?.Track == null) + return; + + double currentTrackTime = Beatmap.Value.Track.CurrentTime + EarlyActivationMilliseconds; + + TimingControlPoint timingPoint = Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(currentTrackTime); + EffectControlPoint effectPoint = Beatmap.Value.Beatmap.ControlPointInfo.EffectPointAt(currentTrackTime); + + if (timingPoint.BeatLength == 0) + return; + + int beatIndex = (int)((currentTrackTime - timingPoint.Time) / timingPoint.BeatLength); + + // The beats before the start of the first control point are off by 1, this should do the trick + if (currentTrackTime < timingPoint.Time) + beatIndex--; + + if (timingPoint == lastTimingPoint && beatIndex == lastBeat) + return; + + double offsetFromBeat = (timingPoint.Time - currentTrackTime) % timingPoint.BeatLength; + + using (BeginDelayedSequence(offsetFromBeat, true)) + OnNewBeat(beatIndex, timingPoint, effectPoint, Beatmap.Value.Track.CurrentAmplitudes); + + lastBeat = beatIndex; + lastTimingPoint = timingPoint; + } + + [BackgroundDependencyLoader] + private void load(OsuGameBase game) + { + Beatmap.BindTo(game.Beatmap); + } + + protected virtual void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + } + } +} diff --git a/osu.Game/Graphics/Containers/ReverseDepthFillFlowContainer.cs b/osu.Game/Graphics/Containers/ReverseDepthFillFlowContainer.cs new file mode 100644 index 0000000000..2b52b06abc --- /dev/null +++ b/osu.Game/Graphics/Containers/ReverseDepthFillFlowContainer.cs @@ -0,0 +1,16 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Graphics.Containers +{ + public class ReverseDepthFillFlowContainer : FillFlowContainer where T : Drawable + { + protected override IComparer DepthComparer => new ReverseCreationOrderDepthComparer(); + protected override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); + } +} diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 4f286ba7b5..9c1799c04c 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -113,7 +113,7 @@ namespace osu.Game.Graphics.UserInterface } } - protected class OsuDropdownHeader : DropdownHeader + public class OsuDropdownHeader : DropdownHeader { private readonly SpriteText label; protected override string Label diff --git a/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs b/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs new file mode 100644 index 0000000000..5de6507bb3 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs @@ -0,0 +1,32 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.ComponentModel; +using System.Reflection; +using System.Collections.Generic; + +namespace osu.Game.Graphics.UserInterface +{ + public class OsuEnumDropdown : OsuDropdown + { + public OsuEnumDropdown() + { + if (!typeof(T).IsEnum) + throw new InvalidOperationException("OsuEnumDropdown only supports enums as the generic type argument"); + + List> items = new List>(); + foreach(var val in (T[])Enum.GetValues(typeof(T))) + { + var field = typeof(T).GetField(Enum.GetName(typeof(T), val)); + items.Add( + new KeyValuePair( + field.GetCustomAttribute()?.Description ?? Enum.GetName(typeof(T), val), + val + ) + ); + } + Items = items; + } + } +} diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index a9fad0c739..4bbae4efd1 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -57,9 +57,9 @@ namespace osu.Game.Graphics.UserInterface } } - private class OsuTabItem : TabItem + public class OsuTabItem : TabItem { - private readonly SpriteText text; + protected readonly SpriteText Text; private readonly Box box; private Color4? accentColour; @@ -70,7 +70,7 @@ namespace osu.Game.Graphics.UserInterface { accentColour = value; if (!Active) - text.Colour = value; + Text.Colour = value; } } @@ -94,13 +94,13 @@ namespace osu.Game.Graphics.UserInterface private void fadeActive() { box.FadeIn(transition_length, EasingTypes.OutQuint); - text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint); + Text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint); } private void fadeInactive() { box.FadeOut(transition_length, EasingTypes.OutQuint); - text.FadeColour(AccentColour, transition_length, EasingTypes.OutQuint); + Text.FadeColour(AccentColour, transition_length, EasingTypes.OutQuint); } protected override bool OnHover(InputState state) @@ -130,7 +130,7 @@ namespace osu.Game.Graphics.UserInterface Children = new Drawable[] { - text = new OsuSpriteText + Text = new OsuSpriteText { Margin = new MarginPadding { Top = 5, Bottom = 5 }, Origin = Anchor.BottomLeft, diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 4cf436a8e4..886ff4f8d1 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -41,6 +41,8 @@ namespace osu.Game private DialogOverlay dialogOverlay; + private DirectOverlay direct; + private Intro intro { get @@ -70,6 +72,8 @@ namespace osu.Game public void ToggleSettings() => settings.ToggleVisibility(); + public void ToggleDirect() => direct.ToggleVisibility(); + [BackgroundDependencyLoader] private void load() { @@ -82,7 +86,7 @@ namespace osu.Game if (args?.Length > 0) { var paths = args.Where(a => !a.StartsWith(@"-")); - Task.Run(() => BeatmapDatabase.Import(paths)); + Task.Run(() => BeatmapDatabase.Import(paths.ToArray())); } Dependencies.Cache(this); @@ -160,6 +164,7 @@ namespace osu.Game }); //overlay elements + LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(settings = new SettingsOverlay { Depth = -1 }, overlayContent.Add); LoadComponentAsync(musicController = new MusicController @@ -249,6 +254,9 @@ namespace osu.Game case Key.O: settings.ToggleVisibility(); return true; + case Key.D: + direct.ToggleVisibility(); + return true; } } @@ -280,6 +288,7 @@ namespace osu.Game Toolbar.State = Visibility.Hidden; musicController.State = Visibility.Hidden; chat.State = Visibility.Hidden; + direct.State = Visibility.Hidden; } else { diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs new file mode 100644 index 0000000000..4be68157d7 --- /dev/null +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -0,0 +1,193 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Framework.Localisation; +using osu.Game.Database; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.Direct +{ + public class DirectGridPanel : DirectPanel + { + private const float horizontal_padding = 10; + private const float vertical_padding = 5; + + private FillFlowContainer bottomPanel; + + public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap) + { + Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image) + CornerRadius = 4; + Masking = true; + + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0f, 1f), + Radius = 3f, + Colour = Color4.Black.Opacity(0.25f), + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + FadeInFromZero(200, EasingTypes.Out); + bottomPanel.LayoutDuration = 200; + bottomPanel.LayoutEasing = EasingTypes.Out; + bottomPanel.Origin = Anchor.BottomLeft; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, LocalisationEngine localisation, TextureStore textures) + { + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + GetBackground(textures), + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.5f), + }, + bottomPanel = new FillFlowContainer + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopLeft, + Direction = FillDirection.Vertical, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(0f, vertical_padding), + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = horizontal_padding, Right = horizontal_padding }, + Direction = FillDirection.Vertical, + Children = new[] + { + new OsuSpriteText + { + Text = localisation.GetUnicodePreference(SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title), + TextSize = 18, + Font = @"Exo2.0-BoldItalic", + }, + new OsuSpriteText + { + Text = localisation.GetUnicodePreference(SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist), + Font = @"Exo2.0-BoldItalic", + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Padding = new MarginPadding + { + Top = vertical_padding, + Bottom = vertical_padding, + Left = horizontal_padding, + Right = horizontal_padding, + }, + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + new OsuSpriteText + { + Text = "mapped by ", + TextSize = 14, + Shadow = false, + Colour = colours.Gray5, + }, + new OsuSpriteText + { + Text = SetInfo.Metadata.Author, + TextSize = 14, + Font = @"Exo2.0-SemiBoldItalic", + Shadow = false, + Colour = colours.BlueDark, + }, + }, + }, + new Container + { + AutoSizeAxes = Axes.X, + Height = 14, + Children = new[] + { + new OsuSpriteText + { + Text = $"from {SetInfo.Metadata.Source}", + TextSize = 14, + Shadow = false, + Colour = colours.Gray5, + Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f, + }, + }, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.X, + Height = 20, + Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding }, + Children = GetDifficultyIcons(), + }, + }, + }, + }, + }, + }, + }, + new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding }, + Children = new[] + { + new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0) + { + Margin = new MarginPadding { Right = 1 }, + }, + new Statistic(FontAwesome.fa_heart, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.FavouriteCount ?? 0), + }, + }, + }; + } + } +} diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs new file mode 100644 index 0000000000..48636a5228 --- /dev/null +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -0,0 +1,197 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Colour; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Database; +using osu.Framework.Allocation; +using osu.Framework.Localisation; +using osu.Framework.Graphics.Textures; +using System.Linq; +using osu.Framework.Input; + +namespace osu.Game.Overlays.Direct +{ + public class DirectListPanel : DirectPanel + { + private const float horizontal_padding = 10; + private const float vertical_padding = 5; + private const float height = 70; + + public DirectListPanel(BeatmapSetInfo beatmap) : base(beatmap) + { + RelativeSizeAxes = Axes.X; + Height = height; + CornerRadius = 5; + Masking = true; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0f, 1f), + Radius = 3f, + Colour = Color4.Black.Opacity(0.25f), + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + FadeInFromZero(200, EasingTypes.Out); + } + + [BackgroundDependencyLoader] + private void load(LocalisationEngine localisation, TextureStore textures) + { + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + GetBackground(textures), + new Box + { + RelativeSizeAxes = Axes.Both, + ColourInfo = ColourInfo.GradientHorizontal(Color4.Black.Opacity(0.25f), Color4.Black.Opacity(0.75f)), + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding, Left = horizontal_padding, Right = vertical_padding }, + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + new OsuSpriteText + { + Current = localisation.GetUnicodePreference(SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title), + TextSize = 18, + Font = @"Exo2.0-BoldItalic", + }, + new OsuSpriteText + { + Current = localisation.GetUnicodePreference(SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist), + Font = @"Exo2.0-BoldItalic", + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.X, + Height = 20, + Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding }, + Children = GetDifficultyIcons(), + }, + }, + }, + new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Margin = new MarginPadding { Right = height - vertical_padding * 2 + vertical_padding }, + Children = new Drawable[] + { + new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0) + { + Margin = new MarginPadding { Right = 1 }, + }, + new Statistic(FontAwesome.fa_heart, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.FavouriteCount ?? 0), + new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + new OsuSpriteText + { + Text = "mapped by ", + TextSize = 14, + }, + new OsuSpriteText + { + Text = SetInfo.Metadata.Author, + TextSize = 14, + Font = @"Exo2.0-SemiBoldItalic", + }, + }, + }, + new OsuSpriteText + { + Text = $"from {SetInfo.Metadata.Source}", + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + TextSize = 14, + Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f, + }, + }, + }, + new DownloadButton + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Size = new Vector2(height - vertical_padding * 2), + }, + }, + }, + }; + } + + private class DownloadButton : ClickableContainer + { + private readonly TextAwesome icon; + + public DownloadButton() + { + Children = new Drawable[] + { + icon = new TextAwesome + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + UseFullGlyphHeight = false, + TextSize = 30, + Icon = FontAwesome.fa_osu_chevron_down_o, + }, + }; + } + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + icon.ScaleTo(0.9f, 1000, EasingTypes.Out); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + icon.ScaleTo(1f, 500, EasingTypes.OutElastic); + return base.OnMouseUp(state, args); + } + + protected override bool OnHover(InputState state) + { + icon.ScaleTo(1.1f, 500, EasingTypes.OutElastic); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + icon.ScaleTo(1f, 500, EasingTypes.OutElastic); + } + } + } +} diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs new file mode 100644 index 0000000000..8a56cf392e --- /dev/null +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -0,0 +1,88 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using System.Linq; +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Database; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.Direct +{ + public abstract class DirectPanel : Container + { + protected readonly BeatmapSetInfo SetInfo; + + protected DirectPanel(BeatmapSetInfo setInfo) + { + SetInfo = setInfo; + } + + protected IEnumerable GetDifficultyIcons() + { + var icons = new List(); + + foreach (var b in SetInfo.Beatmaps) + icons.Add(new DifficultyIcon(b)); + + return icons; + } + + protected Drawable GetBackground(TextureStore textures) + { + return new AsyncLoadWrapper(new BeatmapBackgroundSprite(new OnlineWorkingBeatmap(SetInfo.Beatmaps.FirstOrDefault(), textures, null)) + { + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), + }) { RelativeSizeAxes = Axes.Both }; + } + + public class Statistic : FillFlowContainer + { + private readonly SpriteText text; + + private int value; + public int Value + { + get { return value; } + set + { + this.value = value; + text.Text = Value.ToString(@"N0"); + } + } + + public Statistic(FontAwesome icon, int value = 0) + { + Anchor = Anchor.TopRight; + Origin = Anchor.TopRight; + AutoSizeAxes = Axes.Both; + Direction = FillDirection.Horizontal; + Spacing = new Vector2(5f, 0f); + + Children = new Drawable[] + { + text = new OsuSpriteText + { + Font = @"Exo2.0-SemiBoldItalic", + }, + new TextAwesome + { + Icon = icon, + Shadow = true, + TextSize = 14, + Margin = new MarginPadding { Top = 1 }, + }, + }; + + Value = value; + } + } + } +} diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs new file mode 100644 index 0000000000..735e14b8c1 --- /dev/null +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -0,0 +1,233 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Database; +using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Overlays.Direct +{ + public class FilterControl : Container + { + public static readonly float HEIGHT = 35 + 32 + 30 + padding * 2; // search + mode toggle buttons + sort tabs + padding + + private const float padding = 10; + + private readonly Box tabStrip; + private readonly FillFlowContainer modeButtons; + + public readonly SearchTextBox Search; + public readonly SortTabControl SortTabs; + public readonly OsuEnumDropdown RankStatusDropdown; + public readonly Bindable DisplayStyle = new Bindable(); + + protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || RankStatusDropdown.Contains(screenSpacePos); + + public FilterControl() + { + RelativeSizeAxes = Axes.X; + Height = HEIGHT; + DisplayStyle.Value = DirectOverlay.PanelDisplayStyle.Grid; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"384552"), + Alpha = 0.9f, + }, + tabStrip = new Box + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopLeft, + RelativeSizeAxes = Axes.X, + Height = 1, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Left = DirectOverlay.WIDTH_PADDING, Right = DirectOverlay.WIDTH_PADDING }, + Children = new Drawable[] + { + Search = new DirectSearchTextBox + { + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { Top = padding }, + }, + modeButtons = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(padding, 0f), + Margin = new MarginPadding { Top = padding }, + }, + SortTabs = new SortTabControl + { + RelativeSizeAxes = Axes.X, + }, + }, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Spacing = new Vector2(10f, 0f), + Direction = FillDirection.Horizontal, + Margin = new MarginPadding { Top = HEIGHT - SlimEnumDropdown.HEIGHT - padding, Right = DirectOverlay.WIDTH_PADDING }, + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5f, 0f), + Direction = FillDirection.Horizontal, + Children = new[] + { + new DisplayStyleToggleButton(FontAwesome.fa_th_large, DirectOverlay.PanelDisplayStyle.Grid, DisplayStyle), + new DisplayStyleToggleButton(FontAwesome.fa_list_ul, DirectOverlay.PanelDisplayStyle.List, DisplayStyle), + }, + }, + RankStatusDropdown = new SlimEnumDropdown + { + RelativeSizeAxes = Axes.None, + Width = 160f, + }, + }, + }, + }; + + RankStatusDropdown.Current.Value = RankStatus.RankedApproved; + SortTabs.Current.Value = SortCriteria.Title; + SortTabs.Current.TriggerChange(); + } + + [BackgroundDependencyLoader(true)] + private void load(OsuGame game, RulesetDatabase rulesets, OsuColour colours) + { + tabStrip.Colour = colours.Yellow; + RankStatusDropdown.AccentColour = colours.BlueDark; + + var b = new Bindable(); //backup bindable incase the game is null + foreach (var r in rulesets.AllRulesets) + { + modeButtons.Add(new RulesetToggleButton(game?.Ruleset ?? b, r)); + } + } + + private class DirectSearchTextBox : SearchTextBox + { + protected override Color4 BackgroundUnfocused => backgroundColour; + protected override Color4 BackgroundFocused => backgroundColour; + + private Color4 backgroundColour; + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + backgroundColour = colours.Gray2.Opacity(0.9f); + } + } + + private class RulesetToggleButton : ClickableContainer + { + private readonly TextAwesome icon; + + private RulesetInfo ruleset; + public RulesetInfo Ruleset + { + get { return ruleset; } + set + { + ruleset = value; + icon.Icon = Ruleset.CreateInstance().Icon; + } + } + + private readonly Bindable bindable; + + private void Bindable_ValueChanged(RulesetInfo obj) + { + icon.FadeTo(Ruleset.ID == obj?.ID ? 1f : 0.5f, 100); + } + + public RulesetToggleButton(Bindable bindable, RulesetInfo ruleset) + { + this.bindable = bindable; + AutoSizeAxes = Axes.Both; + + Children = new[] + { + icon = new TextAwesome + { + Origin = Anchor.TopLeft, + Anchor = Anchor.TopLeft, + TextSize = 32, + } + }; + + Ruleset = ruleset; + bindable.ValueChanged += Bindable_ValueChanged; + Bindable_ValueChanged(bindable.Value); + Action = () => bindable.Value = Ruleset; + } + + protected override void Dispose(bool isDisposing) + { + if (bindable != null) + bindable.ValueChanged -= Bindable_ValueChanged; + base.Dispose(isDisposing); + } + } + + private class DisplayStyleToggleButton : ClickableContainer + { + private readonly TextAwesome icon; + private readonly DirectOverlay.PanelDisplayStyle style; + private readonly Bindable bindable; + + public DisplayStyleToggleButton(FontAwesome icon, DirectOverlay.PanelDisplayStyle style, Bindable bindable) + { + this.bindable = bindable; + this.style = style; + Size = new Vector2(SlimEnumDropdown.HEIGHT); + + Children = new Drawable[] + { + this.icon = new TextAwesome + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = icon, + TextSize = 18, + UseFullGlyphHeight = false, + Alpha = 0.5f, + }, + }; + + bindable.ValueChanged += Bindable_ValueChanged; + Bindable_ValueChanged(bindable.Value); + Action = () => bindable.Value = this.style; + } + + private void Bindable_ValueChanged(DirectOverlay.PanelDisplayStyle style) + { + icon.FadeTo(style == this.style ? 1.0f : 0.5f, 100); + } + + protected override void Dispose(bool isDisposing) + { + bindable.ValueChanged -= Bindable_ValueChanged; + } + } + } +} diff --git a/osu.Game/Overlays/Direct/Header.cs b/osu.Game/Overlays/Direct/Header.cs new file mode 100644 index 0000000000..8e4ede48d5 --- /dev/null +++ b/osu.Game/Overlays/Direct/Header.cs @@ -0,0 +1,124 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.ComponentModel; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; + +using Container = osu.Framework.Graphics.Containers.Container; + +namespace osu.Game.Overlays.Direct +{ + public class Header : Container + { + public static readonly float HEIGHT = 90; + + private readonly Box tabStrip; + + public readonly OsuTabControl Tabs; + + public Header() + { + Height = HEIGHT; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"252f3a"), + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = DirectOverlay.WIDTH_PADDING, Right = DirectOverlay.WIDTH_PADDING }, + Children = new Drawable[] + { + new FillFlowContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.BottomLeft, + Position = new Vector2(-35f, 5f), + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(10f, 0f), + Children = new Drawable[] + { + new TextAwesome + { + TextSize = 25, + Icon = FontAwesome.fa_osu_chevron_down_o, + }, + new OsuSpriteText + { + TextSize = 25, + Text = @"osu!direct", + }, + }, + }, + tabStrip = new Box + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Width = 282, //todo: make this actually match the tab control's width instead of hardcoding + Height = 1, + }, + Tabs = new DirectTabControl + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + }, + }, + }, + }; + + Tabs.Current.Value = DirectTab.Search; + Tabs.Current.TriggerChange(); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + tabStrip.Colour = colours.Green; + } + + private class DirectTabControl : OsuTabControl + { + protected override TabItem CreateTabItem(DirectTab value) => new DirectTabItem(value); + + public DirectTabControl() + { + Height = 25; + AccentColour = Color4.White; + } + + private class DirectTabItem : OsuTabItem + { + public DirectTabItem(DirectTab value) : base(value) + { + Text.TextSize = 15; + } + } + } + } + + public enum DirectTab + { + Search, + [Description("Newest Maps")] + NewestMaps, + [Description("Top Rated")] + TopRated, + [Description("Most Played")] + MostPlayed + } +} diff --git a/osu.Game/Overlays/Direct/SlimEnumDropdown.cs b/osu.Game/Overlays/Direct/SlimEnumDropdown.cs new file mode 100644 index 0000000000..1d12b8477b --- /dev/null +++ b/osu.Game/Overlays/Direct/SlimEnumDropdown.cs @@ -0,0 +1,43 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Overlays.Direct +{ + public class SlimEnumDropdown : OsuEnumDropdown + { + public const float HEIGHT = 25; + + protected override DropdownHeader CreateHeader() => new SlimDropdownHeader { AccentColour = AccentColour }; + protected override Menu CreateMenu() => new SlimMenu(); + + private class SlimDropdownHeader : OsuDropdownHeader + { + public SlimDropdownHeader() + { + Height = HEIGHT; + Icon.TextSize = 16; + Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 8, Right = 4 }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + BackgroundColour = Color4.Black.Opacity(0.25f); + } + } + + private class SlimMenu : OsuMenu + { + public SlimMenu() + { + Background.Colour = Color4.Black.Opacity(0.25f); + } + } + } +} diff --git a/osu.Game/Overlays/Direct/SortTabControl.cs b/osu.Game/Overlays/Direct/SortTabControl.cs new file mode 100644 index 0000000000..4d4e02d875 --- /dev/null +++ b/osu.Game/Overlays/Direct/SortTabControl.cs @@ -0,0 +1,117 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Overlays.Direct +{ + public class SortTabControl : OsuTabControl + { + protected override TabItem CreateTabItem(SortCriteria value) => new SortTabItem(value); + + public SortTabControl() + { + Height = 30; + } + + private class SortTabItem : TabItem + { + private const float transition_duration = 100; + + private readonly Box box; + + public override bool Active + { + get { return base.Active; } + set + { + if (Active == value) return; + + if (value) + slideActive(); + else + slideInactive(); + base.Active = value; + } + } + + public SortTabItem(SortCriteria value) : base(value) + { + AutoSizeAxes = Axes.X; + RelativeSizeAxes = Axes.Y; + + Children = new Drawable[] + { + new OsuSpriteText + { + Margin = new MarginPadding { Top = 8, Bottom = 8 }, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Text = (value as Enum).GetDescription() ?? value.ToString(), + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + box = new Box + { + RelativeSizeAxes = Axes.X, + Height = 5, + Scale = new Vector2(1f, 0f), + Colour = Color4.White, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + box.Colour = colours.Yellow; + } + + protected override bool OnHover(InputState state) + { + if (!Active) + slideActive(); + return true; + } + + protected override void OnHoverLost(InputState state) + { + if (!Active) + slideInactive(); + } + + private void slideActive() + { + box.ScaleTo(new Vector2(1f), transition_duration); + } + + private void slideInactive() + { + box.ScaleTo(new Vector2(1f, 0f), transition_duration); + } + } + } + + public enum SortCriteria + { + Title, + Artist, + Creator, + Difficulty, + Ranked, + Rating, + } +} diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs new file mode 100644 index 0000000000..0930c825b6 --- /dev/null +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -0,0 +1,230 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using System.Linq; +using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Database; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Sprites; +using osu.Game.Overlays.Direct; + +using Container = osu.Framework.Graphics.Containers.Container; + +namespace osu.Game.Overlays +{ + public class DirectOverlay : WaveOverlayContainer + { + public static readonly int WIDTH_PADDING = 80; + private const float panel_padding = 10f; + + private readonly FilterControl filter; + private readonly FillFlowContainer resultCountsContainer; + private readonly OsuSpriteText resultCountsText; + private readonly FillFlowContainer panels; + + private IEnumerable beatmapSets; + public IEnumerable BeatmapSets + { + get { return beatmapSets; } + set + { + if (beatmapSets?.Equals(value) ?? false) return; + beatmapSets = value; + + recreatePanels(filter.DisplayStyle.Value); + } + } + + private ResultCounts resultAmounts; + public ResultCounts ResultAmounts + { + get { return resultAmounts; } + set + { + if (value == ResultAmounts) return; + resultAmounts = value; + + updateResultCounts(); + } + } + + public DirectOverlay() + { + RelativeSizeAxes = Axes.Both; + + // osu!direct colours are not part of the standard palette + + FirstWaveColour = OsuColour.FromHex(@"19b0e2"); + SecondWaveColour = OsuColour.FromHex(@"2280a2"); + ThirdWaveColour = OsuColour.FromHex(@"005774"); + FourthWaveColour = OsuColour.FromHex(@"003a4e"); + + Header header; + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"485e74"), + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Masking = true, + Children = new[] + { + new Triangles + { + RelativeSizeAxes = Axes.Both, + TriangleScale = 5, + ColourLight = OsuColour.FromHex(@"465b71"), + ColourDark = OsuColour.FromHex(@"3f5265"), + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = Header.HEIGHT + FilterControl.HEIGHT }, + Children = new[] + { + new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + ScrollDraggerVisible = false, + Children = new Drawable[] + { + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + resultCountsContainer = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Margin = new MarginPadding { Left = WIDTH_PADDING, Top = 6 }, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = "Found ", + TextSize = 15, + }, + resultCountsText = new OsuSpriteText + { + TextSize = 15, + Font = @"Exo2.0-Bold", + }, + } + }, + panels = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Top = panel_padding, Bottom = panel_padding, Left = WIDTH_PADDING, Right = WIDTH_PADDING }, + Spacing = new Vector2(panel_padding), + }, + }, + }, + }, + }, + }, + }, + filter = new FilterControl + { + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { Top = Header.HEIGHT }, + }, + header = new Header + { + RelativeSizeAxes = Axes.X, + }, + }; + + header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) filter.Search.Current.Value = string.Empty; }; + + filter.Search.Exit = Hide; + filter.Search.Current.ValueChanged += text => { if (text != string.Empty) header.Tabs.Current.Value = DirectTab.Search; }; + filter.DisplayStyle.ValueChanged += recreatePanels; + + updateResultCounts(); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + resultCountsContainer.Colour = colours.Yellow; + } + + private void updateResultCounts() + { + resultCountsContainer.FadeTo(ResultAmounts == null ? 0f : 1f, 200, EasingTypes.Out); + if (ResultAmounts == null) return; + + resultCountsText.Text = pluralize("Artist", ResultAmounts.Artists) + ", " + + pluralize("Song", ResultAmounts.Songs) + ", " + + pluralize("Tag", ResultAmounts.Tags); + } + + private string pluralize(string prefix, int value) + { + return $@"{value} {prefix}" + (value == 1 ? string.Empty : @"s"); + } + + private void recreatePanels(PanelDisplayStyle displayStyle) + { + if (BeatmapSets == null) return; + panels.Children = BeatmapSets.Select(b => displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)new DirectGridPanel(b) { Width = 400 } : new DirectListPanel(b)); + } + + protected override bool OnFocus(InputState state) + { + filter.Search.TriggerFocus(); + return false; + } + + protected override void PopIn() + { + base.PopIn(); + + filter.Search.HoldFocus = true; + } + + protected override void PopOut() + { + base.PopOut(); + + filter.Search.HoldFocus = false; + } + + public class ResultCounts + { + public readonly int Artists; + public readonly int Songs; + public readonly int Tags; + + public ResultCounts(int artists, int songs, int tags) + { + Artists = artists; + Songs = songs; + Tags = tags; + } + } + + public enum PanelDisplayStyle + { + Grid, + List, + } + } +} diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 86a47d8a95..d94388ed87 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -12,6 +12,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using OpenTK; using osu.Framework.Input; +using osu.Game.Users; namespace osu.Game.Overlays.Settings.Sections.General { @@ -73,9 +74,9 @@ namespace osu.Game.Overlays.Settings.Sections.General case APIState.Online: Children = new Drawable[] { - new OsuSpriteText + new UserPanel(api.LocalUser.Value) { - Text = $"Connected as {api.Username}!", + RelativeSizeAxes = Axes.X, }, new OsuButton { diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs index 9a5fd769cd..ea9ccd3492 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; namespace osu.Game.Overlays.Settings.Sections.Graphics { @@ -11,11 +12,12 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics { protected override string Header => "Layout"; - private SettingsSlider letterboxPositionX; - private SettingsSlider letterboxPositionY; + private FillFlowContainer letterboxSettings; private Bindable letterboxing; + private const int transition_duration = 400; + [BackgroundDependencyLoader] private void load(FrameworkConfigManager config) { @@ -33,34 +35,40 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics LabelText = "Letterboxing", Bindable = letterboxing, }, - letterboxPositionX = new SettingsSlider + letterboxSettings = new FillFlowContainer { - LabelText = "Horizontal position", - Bindable = config.GetBindable(FrameworkSetting.LetterboxPositionX) - }, - letterboxPositionY = new SettingsSlider - { - LabelText = "Vertical position", - Bindable = config.GetBindable(FrameworkSetting.LetterboxPositionY) + Direction = FillDirection.Vertical, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + AutoSizeDuration = transition_duration, + AutoSizeEasing = EasingTypes.OutQuint, + Masking = true, + + Children = new Drawable[] + { + new SettingsSlider + { + LabelText = "Horizontal position", + Bindable = config.GetBindable(FrameworkSetting.LetterboxPositionX) + }, + new SettingsSlider + { + LabelText = "Vertical position", + Bindable = config.GetBindable(FrameworkSetting.LetterboxPositionY) + }, + } }, }; - letterboxing.ValueChanged += visibilityChanged; - letterboxing.TriggerChange(); - } + letterboxing.ValueChanged += isVisible => + { + letterboxSettings.ClearTransforms(); + letterboxSettings.AutoSizeAxes = isVisible ? Axes.Y : Axes.None; - private void visibilityChanged(bool newVisibility) - { - if (newVisibility) - { - letterboxPositionX.Show(); - letterboxPositionY.Show(); - } - else - { - letterboxPositionX.Hide(); - letterboxPositionY.Hide(); - } + if(!isVisible) + letterboxSettings.ResizeHeightTo(0, transition_duration, EasingTypes.OutQuint); + }; + letterboxing.TriggerChange(); } } } diff --git a/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs b/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs index a9f0848403..5725ee8439 100644 --- a/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs +++ b/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs @@ -1,32 +1,17 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Reflection; -using System.ComponentModel; -using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Settings { public class SettingsEnumDropdown : SettingsDropdown { - public SettingsEnumDropdown() + protected override Drawable CreateControl() => new OsuEnumDropdown { - if (!typeof(T).IsEnum) - throw new InvalidOperationException("SettingsDropdown only supports enums as the generic type argument"); - - List> items = new List>(); - foreach(var val in (T[])Enum.GetValues(typeof(T))) - { - var field = typeof(T).GetField(Enum.GetName(typeof(T), val)); - items.Add( - new KeyValuePair( - field.GetCustomAttribute()?.Description ?? Enum.GetName(typeof(T), val), - val - ) - ); - } - Items = items; - } + Margin = new MarginPadding { Top = 5 }, + RelativeSizeAxes = Axes.X, + }; } } diff --git a/osu.Game/Rulesets/Beatmaps/BeatmapConverter.cs b/osu.Game/Rulesets/Beatmaps/BeatmapConverter.cs index 5342686c3f..aafa576d4b 100644 --- a/osu.Game/Rulesets/Beatmaps/BeatmapConverter.cs +++ b/osu.Game/Rulesets/Beatmaps/BeatmapConverter.cs @@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Beatmaps return new Beatmap { BeatmapInfo = original.BeatmapInfo, - TimingInfo = original.TimingInfo, + ControlPointInfo = original.ControlPointInfo, HitObjects = original.HitObjects.SelectMany(h => convert(h, original)).ToList() }; } diff --git a/osu.Game/Rulesets/Objects/HitObject.cs b/osu.Game/Rulesets/Objects/HitObject.cs index 46fb5fcf70..5592681cab 100644 --- a/osu.Game/Rulesets/Objects/HitObject.cs +++ b/osu.Game/Rulesets/Objects/HitObject.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Audio; -using osu.Game.Beatmaps.Timing; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; using osu.Game.Rulesets.Objects.Types; @@ -33,31 +33,28 @@ namespace osu.Game.Rulesets.Objects /// /// Applies default values to this HitObject. /// + /// The control points. /// The difficulty settings to use. - /// The timing settings to use. - public virtual void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + public virtual void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { - ControlPoint overridePoint; - ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint); - - ControlPoint samplePoint = overridePoint ?? timingPoint; + SoundControlPoint soundPoint = controlPointInfo.SoundPointAt(StartTime); // Initialize first sample - Samples.ForEach(s => initializeSampleInfo(s, samplePoint)); + Samples.ForEach(s => initializeSampleInfo(s, soundPoint)); // Initialize any repeat samples var repeatData = this as IHasRepeats; - repeatData?.RepeatSamples?.ForEach(r => r.ForEach(s => initializeSampleInfo(s, samplePoint))); + repeatData?.RepeatSamples?.ForEach(r => r.ForEach(s => initializeSampleInfo(s, soundPoint))); } - private void initializeSampleInfo(SampleInfo sample, ControlPoint controlPoint) + private void initializeSampleInfo(SampleInfo sample, SoundControlPoint soundPoint) { if (sample.Volume == 0) - sample.Volume = controlPoint?.SampleVolume ?? 0; + sample.Volume = soundPoint?.SampleVolume ?? 0; // If the bank is not assigned a name, assign it from the control point if (string.IsNullOrEmpty(sample.Bank)) - sample.Bank = controlPoint?.SampleBank ?? @"normal"; + sample.Bank = soundPoint?.SampleBank ?? @"normal"; } } } diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index d0cce87e43..f0dc143668 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -143,7 +143,7 @@ namespace osu.Game.Rulesets.UI // Apply defaults foreach (var h in Beatmap.HitObjects) - h.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty); + h.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.Difficulty); // Post-process the beatmap processor.PostProcess(Beatmap); diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 01659edd72..5791b7f196 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -8,7 +8,10 @@ using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Screens; using osu.Framework.Graphics; +using osu.Framework.MathUtils; +using osu.Game.Beatmaps.IO; using osu.Game.Configuration; +using osu.Game.Database; using osu.Game.Graphics.Containers; using osu.Game.Screens.Backgrounds; using OpenTK.Graphics; @@ -19,6 +22,8 @@ namespace osu.Game.Screens.Menu { private readonly OsuLogo logo; + public const string MENU_MUSIC_BEATMAP_HASH = "21c1271b91234385978b5418881fdd88"; + /// /// Whether we have loaded the menu previously. /// @@ -27,7 +32,6 @@ namespace osu.Game.Screens.Menu private MainMenu mainMenu; private SampleChannel welcome; private SampleChannel seeya; - private Track bgm; internal override bool HasLocalCursorDisplayed => true; @@ -60,15 +64,49 @@ namespace osu.Game.Screens.Menu private Bindable menuVoice; private Bindable menuMusic; + private Track track; [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuConfigManager config) + private void load(AudioManager audio, OsuConfigManager config, BeatmapDatabase beatmaps, Framework.Game game) { menuVoice = config.GetBindable(OsuSetting.MenuVoice); menuMusic = config.GetBindable(OsuSetting.MenuMusic); - bgm = audio.Track.Get(@"circles"); - bgm.Looping = true; + var trackManager = audio.Track; + + BeatmapSetInfo setInfo = null; + + if (!menuMusic) + { + var query = beatmaps.Query().Where(b => !b.DeletePending); + int count = query.Count(); + if (count > 0) + setInfo = query.ElementAt(RNG.Next(0, count - 1)); + } + + if (setInfo == null) + { + var query = beatmaps.Query().Where(b => b.Hash == MENU_MUSIC_BEATMAP_HASH); + + setInfo = query.FirstOrDefault(); + + if (setInfo == null) + { + // we need to import the default menu background beatmap + beatmaps.Import(new OszArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz"))); + + setInfo = query.First(); + + setInfo.DeletePending = true; + beatmaps.Update(setInfo, false); + } + } + + beatmaps.GetChildren(setInfo); + Beatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); + + track = Beatmap.Track; + trackManager.SetExclusive(track); welcome = audio.Sample.Get(@"welcome"); seeya = audio.Sample.Get(@"seeya"); @@ -83,8 +121,7 @@ namespace osu.Game.Screens.Menu Scheduler.AddDelayed(delegate { - if (menuMusic) - bgm.Start(); + track.Start(); LoadComponentAsync(mainMenu = new MainMenu()); diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 71d020b0f2..1a7d2d4e37 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -1,18 +1,12 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Threading.Tasks; using OpenTK; using OpenTK.Input; using osu.Framework.Allocation; -using osu.Framework.Audio.Track; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Input; -using osu.Framework.MathUtils; using osu.Framework.Screens; -using osu.Game.Configuration; -using osu.Game.Database; using osu.Game.Graphics.Containers; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Charts; @@ -54,37 +48,20 @@ namespace osu.Game.Screens.Menu OnSolo = delegate { Push(consumeSongSelect()); }, OnMulti = delegate { Push(new Lobby()); }, OnExit = delegate { Exit(); }, - } + }, + new MenuSideFlashes(), } } }; } - private Bindable menuMusic; - private TrackManager trackManager; - [BackgroundDependencyLoader] - private void load(OsuGame game, OsuConfigManager config, BeatmapDatabase beatmaps) + private void load(OsuGame game) { - menuMusic = config.GetBindable(OsuSetting.MenuMusic); LoadComponentAsync(background); - if (!menuMusic) - { - trackManager = game.Audio.Track; - - var query = beatmaps.Query().Where(b => !b.DeletePending); - int count = query.Count(); - - if (count > 0) - { - var beatmap = query.ElementAt(RNG.Next(0, count - 1)); - beatmaps.GetChildren(beatmap); - Beatmap = beatmaps.GetWorkingBeatmap(beatmap.Beatmaps[0]); - } - } - buttons.OnSettings = game.ToggleSettings; + buttons.OnDirect = game.ToggleDirect; preloadSongSelect(); } @@ -108,14 +85,13 @@ namespace osu.Game.Screens.Menu buttons.FadeInFromZero(500); if (last is Intro && Beatmap != null) { - Task.Run(() => + if (!Beatmap.Track.IsRunning) { - trackManager.SetExclusive(Beatmap.Track); Beatmap.Track.Seek(Beatmap.Metadata.PreviewTime); if (Beatmap.Metadata.PreviewTime == -1) Beatmap.Track.Seek(Beatmap.Track.Length * 0.4f); Beatmap.Track.Start(); - }); + } } } diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs new file mode 100644 index 0000000000..0cf1fa54fa --- /dev/null +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -0,0 +1,96 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Audio.Track; +using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Sprites; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using System; + +namespace osu.Game.Screens.Menu +{ + public class MenuSideFlashes : BeatSyncedContainer + { + public override bool HandleInput => false; + + private readonly Bindable beatmap = new Bindable(); + + private readonly Box leftBox; + private readonly Box rightBox; + + private const float amplitude_dead_zone = 0.25f; + private const float alpha_multiplier = (1 - amplitude_dead_zone) / 0.55f; + private const float kiai_multiplier = (1 - amplitude_dead_zone * 0.95f) / 0.8f; + + private const int box_max_alpha = 200; + private const double box_fade_in_time = 65; + private const int box_width = 200; + + public MenuSideFlashes() + { + RelativeSizeAxes = Axes.Both; + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + Children = new Drawable[] + { + leftBox = new Box + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Y, + Width = box_width, + Alpha = 0, + BlendingMode = BlendingMode.Additive, + }, + rightBox = new Box + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + RelativeSizeAxes = Axes.Y, + Width = box_width, + Alpha = 0, + BlendingMode = BlendingMode.Additive, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuGameBase game, OsuColour colours) + { + beatmap.BindTo(game.Beatmap); + + // linear colour looks better in this case, so let's use it for now. + Color4 gradientDark = colours.Blue.Opacity(0).ToLinear(); + Color4 gradientLight = colours.Blue.Opacity(0.3f).ToLinear(); + + leftBox.ColourInfo = ColourInfo.GradientHorizontal(gradientLight, gradientDark); + rightBox.ColourInfo = ColourInfo.GradientHorizontal(gradientDark, gradientLight); + } + + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + if (beatIndex < 0) + return; + + if (effectPoint.KiaiMode ? beatIndex % 2 == 0 : beatIndex % (int)timingPoint.TimeSignature == 0) + flash(leftBox, timingPoint.BeatLength, effectPoint.KiaiMode, amplitudes); + if (effectPoint.KiaiMode ? beatIndex % 2 == 1 : beatIndex % (int)timingPoint.TimeSignature == 0) + flash(rightBox, timingPoint.BeatLength, effectPoint.KiaiMode, amplitudes); + } + + private void flash(Drawable d, double beatLength, bool kiai, TrackAmplitudes amplitudes) + { + d.FadeTo(Math.Max(0, ((d.Equals(leftBox) ? amplitudes.LeftChannel : amplitudes.RightChannel) - amplitude_dead_zone) / (kiai ? kiai_multiplier : alpha_multiplier)), box_fade_in_time); + using (d.BeginDelayedSequence(box_fade_in_time)) + d.FadeOut(beatLength, EasingTypes.In); + } + } +} diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index e28adeacff..44b7b6bceb 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -5,13 +5,17 @@ using System; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Framework.Audio.Track; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Input; +using osu.Framework.MathUtils; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Containers; using OpenTK; using OpenTK.Graphics; @@ -20,19 +24,23 @@ namespace osu.Game.Screens.Menu /// /// osu! logo and its attachments (pulsing, visualiser etc.) /// - public class OsuLogo : Container + public class OsuLogo : BeatSyncedContainer { public readonly Color4 OsuPink = OsuColour.FromHex(@"e967a1"); private readonly Sprite logo; private readonly CircularContainer logoContainer; private readonly Container logoBounceContainer; + private readonly Container logoBeatContainer; + private readonly Container logoAmplitudeContainer; private readonly Container logoHoverContainer; private SampleChannel sampleClick; private readonly Container colourAndTriangles; + private readonly Triangles triangles; + public Action Action; public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.74f; @@ -67,8 +75,12 @@ namespace osu.Game.Screens.Menu private const float default_size = 480; + private const double beat_in_time = 60; + public OsuLogo() { + EarlyActivationMilliseconds = beat_in_time; + Size = new Vector2(default_size); Anchor = Anchor.Centre; @@ -78,67 +90,16 @@ namespace osu.Game.Screens.Menu Children = new Drawable[] { - logoBounceContainer = new Container + logoHoverContainer = new Container { AutoSizeAxes = Axes.Both, Children = new Drawable[] { - logoHoverContainer = new Container + logoBounceContainer = new Container { AutoSizeAxes = Axes.Both, Children = new Drawable[] { - new BufferedContainer - { - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - logoContainer = new CircularContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Scale = new Vector2(0.88f), - Masking = true, - Children = new Drawable[] - { - colourAndTriangles = new Container - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuPink, - }, - new Triangles - { - TriangleScale = 4, - ColourLight = OsuColour.FromHex(@"ff7db7"), - ColourDark = OsuColour.FromHex(@"de5b95"), - RelativeSizeAxes = Axes.Both, - }, - } - }, - flashLayer = new Box - { - RelativeSizeAxes = Axes.Both, - BlendingMode = BlendingMode.Additive, - Colour = Color4.White, - Alpha = 0, - }, - }, - }, - logo = new Sprite - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, - } - }, rippleContainer = new Container { Anchor = Anchor.Centre, @@ -151,36 +112,101 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.Centre, Origin = Anchor.Centre, BlendingMode = BlendingMode.Additive, - Alpha = 0.15f + Alpha = 0 } } }, - impactContainer = new CircularContainer + logoAmplitudeContainer = new Container { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Alpha = 0, - BorderColour = Color4.White, - RelativeSizeAxes = Axes.Both, - BorderThickness = 10, - Masking = true, + AutoSizeAxes = Axes.Both, Children = new Drawable[] { - new Box + logoBeatContainer = new Container { - RelativeSizeAxes = Axes.Both, - AlwaysPresent = true, - Alpha = 0, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new BufferedContainer + { + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + logoContainer = new CircularContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Scale = new Vector2(0.88f), + Masking = true, + Children = new Drawable[] + { + colourAndTriangles = new Container + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuPink, + }, + triangles = new Triangles + { + TriangleScale = 4, + ColourLight = OsuColour.FromHex(@"ff7db7"), + ColourDark = OsuColour.FromHex(@"de5b95"), + RelativeSizeAxes = Axes.Both, + }, + } + }, + flashLayer = new Box + { + RelativeSizeAxes = Axes.Both, + BlendingMode = BlendingMode.Additive, + Colour = Color4.White, + Alpha = 0, + }, + }, + }, + logo = new Sprite + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + } + }, + impactContainer = new CircularContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Alpha = 0, + BorderColour = Color4.White, + RelativeSizeAxes = Axes.Both, + BorderThickness = 10, + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + AlwaysPresent = true, + Alpha = 0, + } + } + }, + new MenuVisualisation + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + BlendingMode = BlendingMode.Additive, + Alpha = 0.2f, + } + } } } - }, - new MenuVisualisation - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - BlendingMode = BlendingMode.Additive, - Alpha = 0.2f, } } } @@ -197,13 +223,56 @@ namespace osu.Game.Screens.Menu ripple.Texture = textures.Get(@"Menu/logo"); } - protected override void LoadComplete() - { - base.LoadComplete(); + private int lastBeatIndex; - ripple.ScaleTo(ripple.Scale * 1.1f, 500); - ripple.FadeOut(500); - ripple.Loop(300); + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); + + lastBeatIndex = beatIndex; + + var beatLength = timingPoint.BeatLength; + + float amplitudeAdjust = Math.Min(1, 0.4f + amplitudes.Maximum); + + if (beatIndex < 0) return; + + logoBeatContainer.ScaleTo(1 - 0.02f * amplitudeAdjust, beat_in_time, EasingTypes.Out); + using (logoBeatContainer.BeginDelayedSequence(beat_in_time)) + logoBeatContainer.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint); + + ripple.ClearTransforms(); + + ripple.ScaleTo(logoAmplitudeContainer.Scale); + ripple.Alpha = 0.15f * amplitudeAdjust; + + ripple.ScaleTo(logoAmplitudeContainer.Scale * (1 + 0.04f * amplitudeAdjust), beatLength, EasingTypes.OutQuint); + ripple.FadeOut(beatLength, EasingTypes.OutQuint); + + if (effectPoint.KiaiMode && flashLayer.Alpha < 0.4f) + { + flashLayer.ClearTransforms(); + + flashLayer.FadeTo(0.2f * amplitudeAdjust, beat_in_time, EasingTypes.Out); + using (flashLayer.BeginDelayedSequence(beat_in_time)) + flashLayer.FadeOut(beatLength); + } + } + + protected override void Update() + { + base.Update(); + + const float scale_adjust_cutoff = 0.4f; + const float velocity_adjust_cutoff = 0.98f; + + var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value?.Track?.CurrentAmplitudes.Maximum ?? 0 : 0; + logoAmplitudeContainer.ScaleTo(1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.04f, 75, EasingTypes.OutQuint); + + if (maxAmplitude > velocity_adjust_cutoff) + triangles.Velocity = 1 + Math.Max(0, maxAmplitude - velocity_adjust_cutoff) * 50; + else + triangles.Velocity = (float)Interpolation.Damp(triangles.Velocity, 1, 0.995f, Time.Elapsed); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) @@ -254,4 +323,4 @@ namespace osu.Game.Screens.Menu impactContainer.ScaleTo(1.12f, 250); } } -} \ No newline at end of file +} diff --git a/osu.Game/Screens/Play/HUD/ModDisplay.cs b/osu.Game/Screens/Play/HUD/ModDisplay.cs index 92c40f6351..4a10438cdb 100644 --- a/osu.Game/Screens/Play/HUD/ModDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ModDisplay.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using System.Linq; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -12,6 +11,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using OpenTK; using osu.Framework.Input; +using osu.Game.Graphics.Containers; namespace osu.Game.Screens.Play.HUD { @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Play.HUD { Children = new Drawable[] { - iconsContainer = new IconFlow + iconsContainer = new ReverseDepthFillFlowContainer { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -93,12 +93,5 @@ namespace osu.Game.Screens.Play.HUD contract(); base.OnHoverLost(state); } - - private class IconFlow : FillFlowContainer - { - // just reverses the depth of flow contents. - protected override IComparer DepthComparer => new ReverseCreationOrderDepthComparer(); - protected override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); - } } } diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 1e57c2ba2a..115611c244 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -30,7 +30,6 @@ namespace osu.Game.Screens.Play public readonly SongProgress Progress; public readonly ModDisplay ModDisplay; - private Bindable showKeyCounter; private Bindable showHud; private static bool hasShownNotificationOnce; @@ -67,24 +66,8 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader(true)] private void load(OsuConfigManager config, NotificationManager notificationManager) { - showKeyCounter = config.GetBindable(OsuSetting.KeyOverlay); - showKeyCounter.ValueChanged += keyCounterVisibility => - { - if (keyCounterVisibility) - KeyCounter.FadeIn(duration); - else - KeyCounter.FadeOut(duration); - }; - showKeyCounter.TriggerChange(); - showHud = config.GetBindable(OsuSetting.ShowInterface); - showHud.ValueChanged += hudVisibility => - { - if (hudVisibility) - content.FadeIn(duration); - else - content.FadeOut(duration); - }; + showHud.ValueChanged += hudVisibility => content.FadeTo(hudVisibility ? 1 : 0, duration); showHud.TriggerChange(); if (!showHud && !hasShownNotificationOnce) diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index 4a561e6036..6e1c8a34e5 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -6,11 +6,18 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK.Graphics; using osu.Framework.Input; +using osu.Framework.Configuration; +using osu.Framework.Allocation; +using osu.Game.Configuration; namespace osu.Game.Screens.Play { public class KeyCounterCollection : FillFlowContainer { + private const int duration = 100; + + private Bindable showKeyCounter; + public KeyCounterCollection() { AlwaysReceiveInput = true; @@ -34,6 +41,14 @@ namespace osu.Game.Screens.Play counter.ResetCount(); } + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + showKeyCounter = config.GetBindable(OsuSetting.KeyOverlay); + showKeyCounter.ValueChanged += keyCounterVisibility => FadeTo(keyCounterVisibility ? 1 : 0, duration); + showKeyCounter.TriggerChange(); + } + //further: change default values here and in KeyCounter if needed, instead of passing them in every constructor private bool isCounting; public bool IsCounting diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3efc85d743..a39e7dbab2 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -123,7 +123,7 @@ namespace osu.Game.Screens.Play decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; var firstObjectTime = HitRenderer.Objects.First().StartTime; - decoupledClock.Seek(Math.Min(0, firstObjectTime - Math.Max(Beatmap.Beatmap.TimingInfo.BeatLengthAt(firstObjectTime) * 4, Beatmap.BeatmapInfo.AudioLeadIn))); + decoupledClock.Seek(Math.Min(0, firstObjectTime - Math.Max(Beatmap.Beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, Beatmap.BeatmapInfo.AudioLeadIn))); decoupledClock.ProcessFrame(); offsetClock = new FramedOffsetClock(decoupledClock); diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 2d6d212130..130642b9c7 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -170,8 +170,8 @@ namespace osu.Game.Screens.Select List visibleGroups = groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden).ToList(); if (visibleGroups.Count < 1) return; - BeatmapGroup group = visibleGroups[RNG.Next(visibleGroups.Count)]; + BeatmapGroup group = visibleGroups[RNG.Next(visibleGroups.Count)]; BeatmapPanel panel = group.BeatmapPanels[RNG.Next(group.BeatmapPanels.Count)]; selectGroup(group, panel); diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 2f5b35f92a..2d002597ab 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -238,12 +238,12 @@ namespace osu.Game.Screens.Select private string getBPMRange(Beatmap beatmap) { - double bpmMax = beatmap.TimingInfo.BPMMaximum; - double bpmMin = beatmap.TimingInfo.BPMMinimum; + double bpmMax = beatmap.ControlPointInfo.BPMMaximum; + double bpmMin = beatmap.ControlPointInfo.BPMMinimum; if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm"; - return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.TimingInfo.BPMMode) + "bpm)"; + return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.ControlPointInfo.BPMMode) + "bpm)"; } public class InfoLabel : Container diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs index c064a0272e..be2f5196ef 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs @@ -2,8 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; -using System.Linq; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -12,6 +10,7 @@ using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; +using osu.Game.Graphics.Containers; namespace osu.Game.Screens.Select.Options { @@ -71,7 +70,7 @@ namespace osu.Game.Screens.Select.Options Scale = new Vector2(1, 0), Colour = Color4.Black.Opacity(0.5f), }, - buttonsContainer = new ButtonFlow + buttonsContainer = new ReverseDepthFillFlowContainer { Height = height, RelativePositionAxes = Axes.X, @@ -109,16 +108,5 @@ namespace osu.Game.Screens.Select.Options HotKey = hotkey }); } - - private class ButtonFlow : FillFlowContainer - { - protected override IComparer DepthComparer => new ReverseCreationOrderDepthComparer(); - protected override IEnumerable FlowingChildren => base.FlowingChildren.Reverse(); - - public ButtonFlow() - { - Direction = FillDirection.Horizontal; - } - } } } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index e9ead7c9c0..41fa53e8a3 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -316,11 +316,12 @@ namespace osu.Game.Screens.Select /// private void selectionChanged(BeatmapInfo beatmap) { - bool beatmapSetChange = false; + selectionChangedDebounce?.Cancel(); if (beatmap.Equals(Beatmap?.BeatmapInfo)) return; + bool beatmapSetChange = false; if (beatmap.BeatmapSetInfoID == selectionChangeNoBounce?.BeatmapSetInfoID) sampleChangeDifficulty.Play(); else @@ -331,7 +332,6 @@ namespace osu.Game.Screens.Select selectionChangeNoBounce = beatmap; - selectionChangedDebounce?.Cancel(); selectionChangedDebounce = Scheduler.AddDelayed(delegate { Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap); diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs new file mode 100644 index 0000000000..c78a69dac8 --- /dev/null +++ b/osu.Game/Users/UserPanel.cs @@ -0,0 +1,209 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Users +{ + public class UserPanel : Container + { + private const float height = 100; + private const float content_padding = 10; + private const float status_height = 30; + + private OsuColour colours; + + private readonly Container statusBar; + private readonly Box statusBg; + private readonly OsuSpriteText statusMessage; + + public readonly Bindable Status = new Bindable(); + + public UserPanel(User user) + { + Height = height - status_height; + Masking = true; + CornerRadius = 5; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Radius = 4, + }; + + Children = new Drawable[] + { + new AsyncLoadWrapper(new CoverBackgroundSprite(user) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(200), + }) { RelativeSizeAxes = Axes.Both }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.7f), + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Top = content_padding, Left = content_padding, Right = content_padding }, + Children = new Drawable[] + { + new UpdateableAvatar + { + Size = new Vector2(height - status_height - content_padding * 2), + User = user, + Masking = true, + CornerRadius = 5, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Radius = 4, + }, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = height - status_height - content_padding }, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = user.Username, + TextSize = 18, + Font = @"Exo2.0-SemiBoldItalic", + }, + new FillFlowContainer + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + AutoSizeAxes = Axes.X, + Height = 20f, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5f, 0f), + Children = new Drawable[] + { + new DrawableFlag(user.Country?.FlagName ?? @"__") + { + Width = 30f, + RelativeSizeAxes = Axes.Y, + }, + new Container + { + Width = 40f, + RelativeSizeAxes = Axes.Y, + }, + new CircularContainer + { + Width = 20f, + RelativeSizeAxes = Axes.Y, + }, + }, + }, + }, + }, + }, + }, + statusBar = new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Alpha = 0f, + Children = new Drawable[] + { + statusBg = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.5f, + }, + new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5f, 0f), + Children = new[] + { + new TextAwesome + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Icon = FontAwesome.fa_circle_o, + Shadow = true, + TextSize = 14, + }, + statusMessage = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Font = @"Exo2.0-Semibold", + }, + }, + }, + }, + }, + }; + + Status.ValueChanged += displayStatus; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + this.colours = colours; + } + + private void displayStatus(UserStatus status) + { + const float transition_duration = 500; + + if (status == null) + { + statusBar.ResizeHeightTo(0f, transition_duration, EasingTypes.OutQuint); + statusBar.FadeOut(transition_duration, EasingTypes.OutQuint); + ResizeHeightTo(height - status_height, transition_duration, EasingTypes.OutQuint); + } + else + { + statusBar.ResizeHeightTo(status_height, transition_duration, EasingTypes.OutQuint); + statusBar.FadeIn(transition_duration, EasingTypes.OutQuint); + ResizeHeightTo(height, transition_duration, EasingTypes.OutQuint); + + statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint); + statusMessage.Text = status.Message; + } + } + + private class CoverBackgroundSprite : Sprite + { + private readonly User user; + + public CoverBackgroundSprite(User user) + { + this.user = user; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + if (!string.IsNullOrEmpty(user.CoverUrl)) + Texture = textures.Get(user.CoverUrl); + } + } + } +} diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs new file mode 100644 index 0000000000..dcb5ccbd8f --- /dev/null +++ b/osu.Game/Users/UserStatus.cs @@ -0,0 +1,61 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Game.Graphics; + +namespace osu.Game.Users +{ + public abstract class UserStatus + { + public abstract string Message { get; } + public abstract Color4 GetAppropriateColour(OsuColour colours); + } + + public abstract class UserStatusAvailable : UserStatus + { + public override Color4 GetAppropriateColour(OsuColour colours) => colours.BlueDarker; + } + + public abstract class UserStatusBusy : UserStatus + { + public override Color4 GetAppropriateColour(OsuColour colours) => colours.YellowDark; + } + + public class UserStatusOffline : UserStatus + { + public override string Message => @"Offline"; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray7; + } + + public class UserStatusOnline : UserStatusAvailable + { + public override string Message => @"Online"; + } + + public class UserStatusSpectating : UserStatusAvailable + { + public override string Message => @"Spectating a game"; + } + + public class UserStatusInLobby : UserStatusAvailable + { + public override string Message => @"in Multiplayer Lobby"; + } + + public class UserStatusSoloGame : UserStatusBusy + { + public override string Message => @"Solo Game"; + } + + public class UserStatusMultiplayerGame: UserStatusBusy + { + public override string Message => @"Multiplaying"; + } + + public class UserStatusModding : UserStatus + { + public override string Message => @"Modding a map"; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 99a5245bbc..98fb4b9707 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -87,10 +87,15 @@ + + + + + + - @@ -184,6 +189,7 @@ + @@ -202,7 +208,6 @@ - @@ -293,6 +298,7 @@ + @@ -426,6 +432,21 @@ + + + + + + + + + + + + + + +