From 19789840066ccc497907fd73be46b8a0c01782a9 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sun, 12 Feb 2017 17:49:30 +0100 Subject: [PATCH 01/83] mode selector line has the correct length now --- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 0ef56435e6..c8ac745bba 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -31,6 +31,10 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Y; + float length = Enum.GetValues(typeof(PlayMode)).Length * ToolbarButton.WIDTH + padding*2; + float lineLength = (padding * 2 + ToolbarButton.WIDTH) / length; + + Children = new Drawable[] { new OpaqueBackground(), @@ -41,12 +45,12 @@ namespace osu.Game.Overlays.Toolbar Direction = FlowDirection.HorizontalOnly, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Padding = new MarginPadding { Left = 10, Right = 10 }, + Padding = new MarginPadding { Left = padding, Right = padding }, }, modeButtonLine = new Container { RelativeSizeAxes = Axes.X, - Size = new Vector2(0.3f, 3), + Size = new Vector2(lineLength, 3), Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, Masking = true, From c1ba53fa093988263b7df91927e7ccf54b95a988 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 13 Feb 2017 16:56:15 +0100 Subject: [PATCH 02/83] calculation is now a 'one-liner' --- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index c8ac745bba..69e3403e4e 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -31,8 +31,7 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Y; - float length = Enum.GetValues(typeof(PlayMode)).Length * ToolbarButton.WIDTH + padding*2; - float lineLength = (padding * 2 + ToolbarButton.WIDTH) / length; + float lineLength = (padding * 2 + ToolbarButton.WIDTH) / (Enum.GetValues(typeof(PlayMode)).Length * ToolbarButton.WIDTH + padding * 2); Children = new Drawable[] From 3e7208c8a48db353182920e25b42ed799039121f Mon Sep 17 00:00:00 2001 From: Damnae Date: Sun, 12 Feb 2017 20:38:05 +0100 Subject: [PATCH 03/83] Add slider ticks. --- .../Objects/Drawables/DrawableSlider.cs | 34 ++++++- .../Objects/Drawables/DrawableSliderTick.cs | 92 +++++++++++++++++++ .../Objects/Drawables/SliderTicksRenderer.cs | 74 +++++++++++++++ osu.Game.Modes.Osu/Objects/Slider.cs | 54 ++++++++++- osu.Game.Modes.Osu/Objects/SliderTick.cs | 9 ++ osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 3 + 6 files changed, 260 insertions(+), 6 deletions(-) create mode 100644 osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs create mode 100644 osu.Game.Modes.Osu/Objects/Drawables/SliderTicksRenderer.cs create mode 100644 osu.Game.Modes.Osu/Objects/SliderTick.cs diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs index 611daad642..981da050a3 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs @@ -1,12 +1,13 @@ // 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 OpenTK; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables.Pieces; -using OpenTK; -using osu.Framework.Input; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Modes.Osu.Objects.Drawables { @@ -22,6 +23,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables SliderBall ball; SliderBouncer bouncer1, bouncer2; + SliderTicksRenderer ticks; public DrawableSlider(Slider s) : base(s) { @@ -34,6 +36,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Position = s.StackedPosition, PathWidth = s.Scale * 64, }, + ticks = new SliderTicksRenderer + { + Position = s.StackedPosition, + StartTime = s.StartTime, + RepeatDuration = s.Curve.Length / s.Velocity, + Ticks = s.Ticks, + }, bouncer1 = new SliderBouncer(s, false) { Position = s.Curve.PositionAt(1), @@ -96,6 +105,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables initialCircle.Position = slider.Curve.PositionAt(progress); components.ForEach(c => c.UpdateProgress(progress, repeat)); + ticks.ShouldHit = ball.Tracking; } protected override void CheckJudgement(bool userTriggered) @@ -105,8 +115,22 @@ namespace osu.Game.Modes.Osu.Objects.Drawables if (!userTriggered && Time.Current >= HitObject.EndTime) { - j.Score = sc.Score; - j.Result = sc.Result; + var ticksCount = ticks.Children.Count() + 1; + var ticksHit = ticks.Children.Count(t => t.Judgement.Result == HitResult.Hit); + if (sc.Result == HitResult.Hit) + ticksHit++; + + var hitFraction = (double)ticksHit / ticksCount; + if (hitFraction == 1 && sc.Score == OsuScoreResult.Hit300) + j.Score = OsuScoreResult.Hit300; + else if (hitFraction >= 0.5 && sc.Score >= OsuScoreResult.Hit100) + j.Score = OsuScoreResult.Hit100; + else if (hitFraction > 0) + j.Score = OsuScoreResult.Hit50; + else + j.Score = OsuScoreResult.Miss; + + j.Result = j.Score != OsuScoreResult.Miss ? HitResult.Hit : HitResult.Miss; } } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs new file mode 100644 index 0000000000..cd5f33a4e6 --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -0,0 +1,92 @@ +// 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.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transformations; +using osu.Game.Modes.Objects.Drawables; +using System; + +namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces +{ + public class DrawableSliderTick : DrawableOsuHitObject + { + private SliderTick sliderTick; + + public double FadeInTime; + public double FadeOutTime; + + public bool ShouldHit; + + public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick) + { + this.sliderTick = sliderTick; + + Size = new Vector2(16) * sliderTick.Scale; + + Masking = true; + CornerRadius = Size.X / 2; + + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + + BorderThickness = 2; + BorderColour = Color4.White; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = sliderTick.Colour, + Alpha = 0.3f, + } + }; + } + + protected override void CheckJudgement(bool userTriggered) + { + if (Judgement.TimeOffset >= 0) + Judgement.Result = ShouldHit ? HitResult.Hit : HitResult.Miss; + } + + protected override void UpdatePreemptState() + { + var animIn = Math.Min(150, sliderTick.StartTime - FadeInTime); + + ScaleTo(0.5f); + ScaleTo(1.2f, animIn); + FadeIn(animIn); + + Delay(animIn); + ScaleTo(1, 150, EasingTypes.Out); + + Delay(-animIn); + } + + protected override void UpdateState(ArmedState state) + { + if (!IsLoaded) return; + + base.UpdateState(state); + + switch (state) + { + case ArmedState.Idle: + Delay(FadeOutTime - sliderTick.StartTime); + FadeOut(); + break; + case ArmedState.Miss: + FadeTo(0.6f); + Delay(FadeOutTime - sliderTick.StartTime); + FadeOut(); + break; + case ArmedState.Hit: + FadeOut(); + break; + } + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksRenderer.cs b/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksRenderer.cs new file mode 100644 index 0000000000..82fa99d00a --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksRenderer.cs @@ -0,0 +1,74 @@ +// 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 System.Collections.Generic; + +namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces +{ + public class SliderTicksRenderer : Container + { + private double startTime; + public double StartTime + { + get { return startTime; } + set + { + startTime = value; + update(); + } + } + + private double repeatDuration; + public double RepeatDuration + { + get { return repeatDuration; } + set + { + repeatDuration = value; + update(); + } + } + + private IEnumerable ticks; + public IEnumerable Ticks + { + get { return ticks; } + set + { + ticks = value; + update(); + } + } + + public bool ShouldHit + { + set + { + foreach (var tick in Children) + tick.ShouldHit = value; + } + } + + private void update() + { + Clear(); + if (ticks == null || repeatDuration == 0) + return; + + foreach (var tick in ticks) + { + var repeatStartTime = startTime + tick.RepeatIndex * repeatDuration; + var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? DrawableOsuHitObject.TIME_FADEIN : DrawableOsuHitObject.TIME_FADEIN / 2); + var fadeOutTime = repeatStartTime + repeatDuration; + + Add(new DrawableSliderTick(tick) + { + FadeInTime = fadeInTime, + FadeOutTime = fadeOutTime, + Position = tick.Position, + }); + } + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index 85ee83a7f8..6f97ccf654 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -3,6 +3,9 @@ using osu.Game.Beatmaps; using OpenTK; +using System.Collections.Generic; +using System; +using osu.Game.Beatmaps.Samples; namespace osu.Game.Modes.Osu.Objects { @@ -25,17 +28,66 @@ namespace osu.Game.Modes.Osu.Objects } public double Velocity; + public double TickDistance; public override void SetDefaultsFromBeatmap(Beatmap beatmap) { base.SetDefaultsFromBeatmap(beatmap); - Velocity = 100 / beatmap.BeatLengthAt(StartTime, true) * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier; + var baseDifficulty = beatmap.BeatmapInfo.BaseDifficulty; + + var startBeatLength = beatmap.BeatLengthAt(StartTime); + var multipliedStartBeatLength = beatmap.BeatLengthAt(StartTime, true); + + Velocity = 100 / multipliedStartBeatLength * baseDifficulty.SliderMultiplier; + TickDistance = (100 * baseDifficulty.SliderMultiplier) / baseDifficulty.SliderTickRate / (multipliedStartBeatLength / startBeatLength); } public int RepeatCount; public SliderCurve Curve; + + public IEnumerable Ticks + { + get + { + var length = Curve.Length; + var tickDistance = Math.Min(TickDistance, length); + var repeatDuration = length / Velocity; + + var minDistanceFromEnd = Velocity * 0.01; + + for (var repeat = 0; repeat < RepeatCount; repeat++) + { + var repeatStartTime = StartTime + repeat * repeatDuration; + var reversed = repeat % 2 == 1; + + for (var d = tickDistance; d <= length; d += tickDistance) + { + if (d > length - minDistanceFromEnd) + break; + + var distanceProgress = d / length; + var timeProgress = reversed ? 1 - distanceProgress : distanceProgress; + + yield return new SliderTick + { + RepeatIndex = repeat, + StartTime = repeatStartTime + timeProgress * repeatDuration, + Position = Curve.PositionAt(distanceProgress) - StackedPosition, + StackHeight = StackHeight, + Scale = Scale, + Colour = Colour, + Sample = new HitSampleInfo + { + Type = SampleType.None, + Set = SampleSet.Soft, + }, + }; + } + } + } + } } public enum CurveTypes diff --git a/osu.Game.Modes.Osu/Objects/SliderTick.cs b/osu.Game.Modes.Osu/Objects/SliderTick.cs new file mode 100644 index 0000000000..de8f3f4b6f --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/SliderTick.cs @@ -0,0 +1,9 @@ +using OpenTK; + +namespace osu.Game.Modes.Osu.Objects +{ + public class SliderTick : OsuHitObject + { + public int RepeatIndex { get; set; } + } +} diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index e0b9f5c904..19f0df55b8 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -47,6 +47,7 @@ + @@ -57,6 +58,7 @@ + @@ -64,6 +66,7 @@ + From 1b08f6aca4d68f1c1e9c195545ec4e163165364a Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 14 Feb 2017 14:24:54 +0100 Subject: [PATCH 04/83] Line length is absolute now --- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 69e3403e4e..c242460cb0 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Y; - float lineLength = (padding * 2 + ToolbarButton.WIDTH) / (Enum.GetValues(typeof(PlayMode)).Length * ToolbarButton.WIDTH + padding * 2); + float lineLength = padding * 2 + ToolbarButton.WIDTH; Children = new Drawable[] @@ -48,7 +48,6 @@ namespace osu.Game.Overlays.Toolbar }, modeButtonLine = new Container { - RelativeSizeAxes = Axes.X, Size = new Vector2(lineLength, 3), Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, From 9f890139d4331f5c51560344f85c2d77521c72f1 Mon Sep 17 00:00:00 2001 From: Damnae Date: Tue, 14 Feb 2017 15:16:18 +0100 Subject: [PATCH 05/83] Cache drawable ticks. --- .../Objects/Drawables/SliderTicksRenderer.cs | 54 +++++++++++++------ 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksRenderer.cs b/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksRenderer.cs index 82fa99d00a..03ab28e495 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksRenderer.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksRenderer.cs @@ -1,6 +1,8 @@ // 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.Caching; using osu.Framework.Graphics.Containers; using System.Collections.Generic; @@ -8,6 +10,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { public class SliderTicksRenderer : Container { + private Cached drawableTicks = new Cached(); + private double startTime; public double StartTime { @@ -15,7 +19,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces set { startTime = value; - update(); + drawableTicks.Invalidate(); } } @@ -26,7 +30,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces set { repeatDuration = value; - update(); + drawableTicks.Invalidate(); } } @@ -37,7 +41,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces set { ticks = value; - update(); + drawableTicks.Invalidate(); } } @@ -50,25 +54,43 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces } } - private void update() + protected override void Update() { - Clear(); - if (ticks == null || repeatDuration == 0) + base.Update(); + updateDrawableTicks(); + } + + [BackgroundDependencyLoader] + private void load() + { + updateDrawableTicks(); + } + + private void updateDrawableTicks() + { + if (drawableTicks.EnsureValid()) return; - foreach (var tick in ticks) + drawableTicks.Refresh(delegate { - var repeatStartTime = startTime + tick.RepeatIndex * repeatDuration; - var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? DrawableOsuHitObject.TIME_FADEIN : DrawableOsuHitObject.TIME_FADEIN / 2); - var fadeOutTime = repeatStartTime + repeatDuration; + Clear(); + if (ticks == null || repeatDuration == 0) + return; - Add(new DrawableSliderTick(tick) + foreach (var tick in ticks) { - FadeInTime = fadeInTime, - FadeOutTime = fadeOutTime, - Position = tick.Position, - }); - } + var repeatStartTime = startTime + tick.RepeatIndex * repeatDuration; + var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? DrawableOsuHitObject.TIME_FADEIN : DrawableOsuHitObject.TIME_FADEIN / 2); + var fadeOutTime = repeatStartTime + repeatDuration; + + Add(new DrawableSliderTick(tick) + { + FadeInTime = fadeInTime, + FadeOutTime = fadeOutTime, + Position = tick.Position, + }); + } + }); } } } \ No newline at end of file From e717daa504b037347299626a7ef4b352b7244bbe Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 14 Feb 2017 16:05:57 +0100 Subject: [PATCH 06/83] Line length is calculated inline --- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index c242460cb0..a63fcce2dc 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -31,9 +31,6 @@ namespace osu.Game.Overlays.Toolbar { RelativeSizeAxes = Axes.Y; - float lineLength = padding * 2 + ToolbarButton.WIDTH; - - Children = new Drawable[] { new OpaqueBackground(), @@ -48,7 +45,7 @@ namespace osu.Game.Overlays.Toolbar }, modeButtonLine = new Container { - Size = new Vector2(lineLength, 3), + Size = new Vector2(padding * 2 + ToolbarButton.WIDTH, 3), Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, Masking = true, From ace7a1d0096f22dd680e3569c1209a87be909146 Mon Sep 17 00:00:00 2001 From: Damnae Date: Tue, 14 Feb 2017 16:12:35 +0100 Subject: [PATCH 07/83] Fix slider ticks expiring before scoring happens. --- osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs index cd5f33a4e6..cb32410303 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -20,6 +20,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces public bool ShouldHit; + public override bool RemoveWhenNotAlive => false; + public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick) { this.sliderTick = sliderTick; From b7fca88b4fb5504af28946ca92b48045310ea46e Mon Sep 17 00:00:00 2001 From: Damnae Date: Wed, 15 Feb 2017 18:55:49 +0100 Subject: [PATCH 08/83] Clearer slider Velocity and TickDistance calculations. --- osu.Game.Modes.Osu/Objects/Slider.cs | 11 +++++---- osu.Game/Beatmaps/Beatmap.cs | 35 ++++++++++++++++------------ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index 30ad1c0180..f64d443bcc 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -4,6 +4,7 @@ using OpenTK; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Samples; +using osu.Game.Beatmaps.Timing; using System; using System.Collections.Generic; @@ -53,11 +54,13 @@ namespace osu.Game.Modes.Osu.Objects var baseDifficulty = beatmap.BeatmapInfo.BaseDifficulty; - var startBeatLength = beatmap.BeatLengthAt(StartTime); - var multipliedStartBeatLength = beatmap.BeatLengthAt(StartTime, true); + ControlPoint overridePoint; + ControlPoint timingPoint = beatmap.TimingPointAt(StartTime, out overridePoint); + var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1; + var baseVelocity = 100 * baseDifficulty.SliderMultiplier; - Velocity = 100 / multipliedStartBeatLength * baseDifficulty.SliderMultiplier; - TickDistance = (100 * baseDifficulty.SliderMultiplier) / baseDifficulty.SliderTickRate / (multipliedStartBeatLength / startBeatLength); + Velocity = baseVelocity / (timingPoint.BeatLength * velocityAdjustment); + TickDistance = baseVelocity / (baseDifficulty.SliderTickRate * velocityAdjustment); } public int RepeatCount = 1; diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index 0914d1a2ad..d0ce290bad 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -26,26 +26,31 @@ namespace osu.Game.Beatmaps return 60000 / BeatLengthAt(time); } - public double BeatLengthAt(double time, bool applyMultipliers = false) + public double BeatLengthAt(double time) { - int point = 0; - int samplePoint = 0; + ControlPoint overridePoint; + ControlPoint timingPoint = TimingPointAt(time, out overridePoint); + return timingPoint.BeatLength; + } - for (int i = 0; i < ControlPoints.Count; i++) - if (ControlPoints[i].Time <= time) + public ControlPoint TimingPointAt(double time, out ControlPoint overridePoint) + { + overridePoint = null; + + ControlPoint timingPoint = null; + foreach (var controlPoint in ControlPoints) + if (controlPoint.Time <= time) { - if (ControlPoints[i].TimingChange) - point = i; - else - samplePoint = i; + if (controlPoint.TimingChange) + { + timingPoint = controlPoint; + overridePoint = null; + } + else overridePoint = controlPoint; } + else break; - double mult = 1; - - if (applyMultipliers && samplePoint > point) - mult = ControlPoints[samplePoint].VelocityAdjustment; - - return ControlPoints[point].BeatLength * mult; + return timingPoint; } } } From f1535363f41ead41e7173be7f7d57a9a349d1e15 Mon Sep 17 00:00:00 2001 From: Damnae Date: Wed, 15 Feb 2017 19:04:56 +0100 Subject: [PATCH 09/83] Rename SliderTicksRenderer to SliderTicksLayer. --- .../Drawables/{SliderTicksRenderer.cs => SliderTicksLayer.cs} | 0 osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename osu.Game.Modes.Osu/Objects/Drawables/{SliderTicksRenderer.cs => SliderTicksLayer.cs} (100%) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksRenderer.cs b/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksLayer.cs similarity index 100% rename from osu.Game.Modes.Osu/Objects/Drawables/SliderTicksRenderer.cs rename to osu.Game.Modes.Osu/Objects/Drawables/SliderTicksLayer.cs diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index d236497ff4..fd6a45c065 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -47,7 +47,7 @@ - + From 6c9fe544b24ecfc1b181a1d4fe583744e81ae970 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 13:20:30 +0900 Subject: [PATCH 10/83] Handle case where TickDistance is zero (don't draw ticks). --- osu.Game.Modes.Osu/Objects/Slider.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index f64d443bcc..72fdd70a70 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -71,6 +71,8 @@ namespace osu.Game.Modes.Osu.Objects { get { + if (TickDistance == 0) yield break; + var length = Curve.Length; var tickDistance = Math.Min(TickDistance, length); var repeatDuration = length / Velocity; From c90f5e247dbc24184ebe0372faabc52e95eb0746 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 13:20:40 +0900 Subject: [PATCH 11/83] Add a TickDistance to TestCaseHitObjects. --- osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index 1e3d8df6c6..6f406307c9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -75,6 +75,7 @@ namespace osu.Desktop.VisualTests.Tests Length = 400, Position = new Vector2(-200, 0), Velocity = 1, + TickDistance = 100, })); break; case HitObjectType.Spinner: From 97b782128eba2077e43a780a88e4051b13231c45 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 13:33:59 +0900 Subject: [PATCH 12/83] Adjust tick appear/disappear animations. --- .../Objects/Drawables/DrawableSliderTick.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs index cb32410303..cc6890c987 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -81,12 +81,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces FadeOut(); break; case ArmedState.Miss: - FadeTo(0.6f); - Delay(FadeOutTime - sliderTick.StartTime); - FadeOut(); + FadeOut(160); + FadeColour(Color4.Red, 80); break; case ArmedState.Hit: - FadeOut(); + FadeOut(120, EasingTypes.OutQuint); + ScaleTo(Scale * 1.5f, 120, EasingTypes.OutQuint); break; } } From 19eb58e724cfe3231b1521c96aee82d1ecb8d2e7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 13:37:08 +0900 Subject: [PATCH 13/83] Fix namespace. --- .../Objects/Drawables/DrawableSliderTick.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs index cc6890c987..9139bce248 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -1,15 +1,15 @@ // 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 System; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; using osu.Game.Modes.Objects.Drawables; -using System; +using OpenTK; +using OpenTK.Graphics; -namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces +namespace osu.Game.Modes.Osu.Objects.Drawables { public class DrawableSliderTick : DrawableOsuHitObject { From 2640c2ac43dd4e69162f2c0a64c7bf2e002815ac Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 13:39:01 +0900 Subject: [PATCH 14/83] Add tick sample. --- .../Objects/Drawables/DrawableSliderTick.cs | 20 +++++++++++++++++++ .../Objects/Drawables/DrawableHitObject.cs | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs index 9139bce248..b3479c0fae 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -2,9 +2,13 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; +using osu.Game.Beatmaps.Samples; using osu.Game.Modes.Objects.Drawables; using OpenTK; using OpenTK.Graphics; @@ -48,6 +52,22 @@ namespace osu.Game.Modes.Osu.Objects.Drawables }; } + private AudioSample sample; + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + string sampleSet = (HitObject.Sample?.Set ?? SampleSet.Normal).ToString().ToLower(); + + sample = audio.Sample.Get($@"Gameplay/{sampleSet}-slidertick"); + } + + protected override void PlaySample() + { + sample?.Play(); + } + + protected override void CheckJudgement(bool userTriggered) { if (Judgement.TimeOffset >= 0) diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index 4df49ca01f..4c707c5e62 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -66,7 +66,7 @@ namespace osu.Game.Modes.Objects.Drawables sample = audio.Sample.Get($@"Gameplay/{sampleSet}-hit{hitType}"); } - protected void PlaySample() + protected virtual void PlaySample() { sample?.Play(); } From 8bf3902cbd0b2a7ffada2df90a3df4afff6cac5a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 17:02:36 +0900 Subject: [PATCH 15/83] Add the concept of nested DrawableHitObjects. - Applies to Slider Ticks and start circle. repeat/endpoints still need addressing. - Removed SliderTicksLayer abstraction for now. --- .../Tests/TestCaseHitObjects.cs | 2 +- .../Objects/Drawables/DrawableOsuHitObject.cs | 2 + .../Objects/Drawables/DrawableSlider.cs | 36 +++++-- .../Objects/Drawables/DrawableSliderTick.cs | 10 +- .../Objects/Drawables/SliderTicksLayer.cs | 96 ------------------- osu.Game.Modes.Osu/Objects/Slider.cs | 2 +- osu.Game.Modes.Osu/OsuScoreProcessor.cs | 4 + osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 1 - .../Objects/Drawables/DrawableHitObject.cs | 22 ++++- 9 files changed, 60 insertions(+), 115 deletions(-) delete mode 100644 osu.Game.Modes.Osu/Objects/Drawables/SliderTicksLayer.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index 6f406307c9..f82ea1c98c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -37,7 +37,7 @@ namespace osu.Desktop.VisualTests.Tests playbackSpeed.ValueChanged += delegate { rateAdjustClock.Rate = playbackSpeed.Value; }; } - HitObjectType mode = HitObjectType.Spinner; + HitObjectType mode = HitObjectType.Slider; BindableNumber playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 }; private Container playfieldContainer; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs index ef153848d4..d6907474f3 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -73,5 +73,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Hit100, [Description(@"300")] Hit300, + [Description(@"10")] + SliderTick } } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs index 01ddd7a790..745c696fee 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs @@ -7,6 +7,7 @@ using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables.Pieces; using System.Collections.Generic; using System.Linq; +using osu.Framework.Graphics.Containers; namespace osu.Game.Modes.Osu.Objects.Drawables { @@ -18,11 +19,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables private List components = new List(); + private Container ticks; + SliderBody body; SliderBall ball; SliderBouncer bouncer1, bouncer2; - SliderTicksRenderer ticks; public DrawableSlider(Slider s) : base(s) { @@ -35,13 +37,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Position = s.StackedPosition, PathWidth = s.Scale * 64, }, - ticks = new SliderTicksRenderer - { - Position = s.StackedPosition, - StartTime = s.StartTime, - RepeatDuration = s.Curve.Length / s.Velocity, - Ticks = s.Ticks, - }, + ticks = new Container(), bouncer1 = new SliderBouncer(s, false) { Position = s.Curve.PositionAt(1), @@ -72,6 +68,26 @@ namespace osu.Game.Modes.Osu.Objects.Drawables components.Add(ball); components.Add(bouncer1); components.Add(bouncer2); + + AddNested(initialCircle); + + var repeatDuration = s.Curve.Length / s.Velocity; + foreach (var tick in s.Ticks) + { + var repeatStartTime = s.StartTime + tick.RepeatIndex * repeatDuration; + var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? TIME_FADEIN : TIME_FADEIN / 2); + var fadeOutTime = repeatStartTime + repeatDuration; + + var drawableTick = new DrawableSliderTick(tick) + { + FadeInTime = fadeInTime, + FadeOutTime = fadeOutTime, + Position = tick.Position, + }; + + ticks.Add(drawableTick); + AddNested(drawableTick); + } } // Since the DrawableSlider itself is just a container without a size we need to @@ -105,8 +121,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables if (initialCircle.Judgement?.Result != HitResult.Hit) initialCircle.Position = slider.Curve.PositionAt(progress); - components.ForEach(c => c.UpdateProgress(progress, repeat)); - ticks.ShouldHit = ball.Tracking; + foreach (var c in components) c.UpdateProgress(progress, repeat); + foreach (var t in ticks.Children) t.Tracking = ball.Tracking; } protected override void CheckJudgement(bool userTriggered) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs index b3479c0fae..c1c17f1c53 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -22,7 +22,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables public double FadeInTime; public double FadeOutTime; - public bool ShouldHit; + public bool Tracking; public override bool RemoveWhenNotAlive => false; @@ -35,7 +35,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Masking = true; CornerRadius = Size.X / 2; - Anchor = Anchor.Centre; Origin = Anchor.Centre; BorderThickness = 2; @@ -70,8 +69,13 @@ namespace osu.Game.Modes.Osu.Objects.Drawables protected override void CheckJudgement(bool userTriggered) { + var j = Judgement as OsuJudgementInfo; + if (Judgement.TimeOffset >= 0) - Judgement.Result = ShouldHit ? HitResult.Hit : HitResult.Miss; + { + j.Result = Tracking ? HitResult.Hit : HitResult.Miss; + j.Score = Tracking ? OsuScoreResult.SliderTick : OsuScoreResult.Miss; + } } protected override void UpdatePreemptState() diff --git a/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksLayer.cs b/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksLayer.cs deleted file mode 100644 index 03ab28e495..0000000000 --- a/osu.Game.Modes.Osu/Objects/Drawables/SliderTicksLayer.cs +++ /dev/null @@ -1,96 +0,0 @@ -// 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.Caching; -using osu.Framework.Graphics.Containers; -using System.Collections.Generic; - -namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces -{ - public class SliderTicksRenderer : Container - { - private Cached drawableTicks = new Cached(); - - private double startTime; - public double StartTime - { - get { return startTime; } - set - { - startTime = value; - drawableTicks.Invalidate(); - } - } - - private double repeatDuration; - public double RepeatDuration - { - get { return repeatDuration; } - set - { - repeatDuration = value; - drawableTicks.Invalidate(); - } - } - - private IEnumerable ticks; - public IEnumerable Ticks - { - get { return ticks; } - set - { - ticks = value; - drawableTicks.Invalidate(); - } - } - - public bool ShouldHit - { - set - { - foreach (var tick in Children) - tick.ShouldHit = value; - } - } - - protected override void Update() - { - base.Update(); - updateDrawableTicks(); - } - - [BackgroundDependencyLoader] - private void load() - { - updateDrawableTicks(); - } - - private void updateDrawableTicks() - { - if (drawableTicks.EnsureValid()) - return; - - drawableTicks.Refresh(delegate - { - Clear(); - if (ticks == null || repeatDuration == 0) - return; - - foreach (var tick in ticks) - { - var repeatStartTime = startTime + tick.RepeatIndex * repeatDuration; - var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? DrawableOsuHitObject.TIME_FADEIN : DrawableOsuHitObject.TIME_FADEIN / 2); - var fadeOutTime = repeatStartTime + repeatDuration; - - Add(new DrawableSliderTick(tick) - { - FadeInTime = fadeInTime, - FadeOutTime = fadeOutTime, - Position = tick.Position, - }); - } - }); - } - } -} \ No newline at end of file diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index 72fdd70a70..c3d8190240 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -96,7 +96,7 @@ namespace osu.Game.Modes.Osu.Objects { RepeatIndex = repeat, StartTime = repeatStartTime + timeProgress * repeatDuration, - Position = Curve.PositionAt(distanceProgress) - StackedPosition, + Position = Curve.PositionAt(distanceProgress), StackHeight = StackHeight, Scale = Scale, Colour = Colour, diff --git a/osu.Game.Modes.Osu/OsuScoreProcessor.cs b/osu.Game.Modes.Osu/OsuScoreProcessor.cs index 8a9f7d6b2e..224a669746 100644 --- a/osu.Game.Modes.Osu/OsuScoreProcessor.cs +++ b/osu.Game.Modes.Osu/OsuScoreProcessor.cs @@ -53,6 +53,10 @@ namespace osu.Game.Modes.Osu score += 300; maxScore += 300; break; + case OsuScoreResult.SliderTick: + score += 10; + maxScore += 10; + break; } } diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index f269921cac..1b1ded3d61 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -47,7 +47,6 @@ - diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index 4c707c5e62..94369d51aa 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using osu.Framework; @@ -23,8 +24,6 @@ namespace osu.Game.Modes.Objects.Drawables public bool Interactive = true; - public Container ChildObjects; - public JudgementInfo Judgement; public abstract JudgementInfo CreateJudgementInfo(); @@ -85,6 +84,19 @@ namespace osu.Game.Modes.Objects.Drawables Expire(true); } + private List nestedHitObjects; + + protected IEnumerable NestedHitObjects => nestedHitObjects; + + protected void AddNested(DrawableHitObject h) + { + if (nestedHitObjects == null) + nestedHitObjects = new List(); + + h.OnJudgement += (d, j) => { OnJudgement?.Invoke(d, j); } ; + nestedHitObjects.Add(h); + } + /// /// Process a hit of this hitobject. Carries out judgement. /// @@ -119,7 +131,11 @@ namespace osu.Game.Modes.Objects.Drawables protected virtual void CheckJudgement(bool userTriggered) { - //todo: consider making abstract. + if (NestedHitObjects != null) + { + foreach (var d in NestedHitObjects) + d.CheckJudgement(userTriggered); + } } protected override void UpdateAfterChildren() From b55d85a5c51b9ef25b996e4638c48e7b229c7e40 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 17:33:13 +0900 Subject: [PATCH 16/83] Add MaxScore to correctly account for the maximum attainable score of DrawableHitObjects. --- .../Objects/Drawables/DrawableHitCircle.cs | 10 +++--- .../Objects/Drawables/DrawableOsuHitObject.cs | 33 +++++++++++++++++-- .../Objects/Drawables/DrawableSliderTick.cs | 2 ++ osu.Game.Modes.Osu/OsuScoreProcessor.cs | 24 ++------------ 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs index 208bf15328..0e085d63b8 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -84,18 +84,18 @@ namespace osu.Game.Modes.Osu.Objects.Drawables double hitOffset = Math.Abs(Judgement.TimeOffset); + OsuJudgementInfo osuJudgement = Judgement as OsuJudgementInfo; + if (hitOffset < hit50) { Judgement.Result = HitResult.Hit; - OsuJudgementInfo osuInfo = Judgement as OsuJudgementInfo; - if (hitOffset < hit300) - osuInfo.Score = OsuScoreResult.Hit300; + osuJudgement.Score = OsuScoreResult.Hit300; else if (hitOffset < hit100) - osuInfo.Score = OsuScoreResult.Hit100; + osuJudgement.Score = OsuScoreResult.Hit100; else if (hitOffset < hit50) - osuInfo.Score = OsuScoreResult.Hit50; + osuJudgement.Score = OsuScoreResult.Hit50; } else Judgement.Result = HitResult.Miss; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs index d6907474f3..c7cc7cfdd7 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -4,7 +4,6 @@ using System.ComponentModel; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; -using osu.Framework.Graphics; namespace osu.Game.Modes.Osu.Objects.Drawables { @@ -19,7 +18,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { } - public override JudgementInfo CreateJudgementInfo() => new OsuJudgementInfo(); + public override JudgementInfo CreateJudgementInfo() => new OsuJudgementInfo { MaxScore = OsuScoreResult.Hit300 }; protected override void UpdateState(ArmedState state) { @@ -49,7 +48,37 @@ namespace osu.Game.Modes.Osu.Objects.Drawables public class OsuJudgementInfo : PositionalJudgementInfo { + /// + /// The score the user achieved. + /// public OsuScoreResult Score; + + /// + /// The score which would be achievable on a perfect hit. + /// + public OsuScoreResult MaxScore = OsuScoreResult.Hit300; + + public int ScoreValue => scoreToInt(Score); + + public int MaxScoreValue => scoreToInt(MaxScore); + + private int scoreToInt(OsuScoreResult result) + { + switch (result) + { + default: + return 0; + case OsuScoreResult.Hit50: + return 50; + case OsuScoreResult.Hit100: + return 100; + case OsuScoreResult.Hit300: + return 300; + case OsuScoreResult.SliderTick: + return 10; + } + } + public ComboResult Combo; } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs index c1c17f1c53..7380871583 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -26,6 +26,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables public override bool RemoveWhenNotAlive => false; + public override JudgementInfo CreateJudgementInfo() => new OsuJudgementInfo { MaxScore = OsuScoreResult.SliderTick }; + public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick) { this.sliderTick = sliderTick; diff --git a/osu.Game.Modes.Osu/OsuScoreProcessor.cs b/osu.Game.Modes.Osu/OsuScoreProcessor.cs index 224a669746..9493259558 100644 --- a/osu.Game.Modes.Osu/OsuScoreProcessor.cs +++ b/osu.Game.Modes.Osu/OsuScoreProcessor.cs @@ -36,28 +36,8 @@ namespace osu.Game.Modes.Osu foreach (OsuJudgementInfo j in Judgements) { - switch (j.Score) - { - case OsuScoreResult.Miss: - maxScore += 300; - break; - case OsuScoreResult.Hit50: - score += 50; - maxScore += 300; - break; - case OsuScoreResult.Hit100: - score += 100; - maxScore += 300; - break; - case OsuScoreResult.Hit300: - score += 300; - maxScore += 300; - break; - case OsuScoreResult.SliderTick: - score += 10; - maxScore += 10; - break; - } + score += j.ScoreValue; + maxScore += j.MaxScoreValue; } TotalScore.Value = score; From 3068fa1a620c04e0bde7d464ca225a4eb75c8d01 Mon Sep 17 00:00:00 2001 From: Nabile Rahmani Date: Thu, 16 Feb 2017 11:30:31 +0100 Subject: [PATCH 17/83] Namespace does not correspond to file location. --- osu-framework | 2 +- osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBody.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index a766d283f4..7a0fb64b3d 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a766d283f4d628736db784001cc1f11d065cab9d +Subproject commit 7a0fb64b3dc46651113c1b15bfec8e941e97a146 diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBody.cs index 173bf2c060..7f7d558294 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -8,7 +8,7 @@ using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.OpenGL.Textures; -using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Lines; using osu.Framework.Graphics.Textures; using osu.Game.Configuration; using OpenTK; From 1cdd2a60723c140499d0634d9bf7f6e8e55d7692 Mon Sep 17 00:00:00 2001 From: Nabile Rahmani Date: Thu, 16 Feb 2017 13:09:42 +0100 Subject: [PATCH 18/83] Updated submodule. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 7a0fb64b3d..4a58484532 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 7a0fb64b3dc46651113c1b15bfec8e941e97a146 +Subproject commit 4a5848453240326ba08b09a33a2467af8c174b6a From 04346dbb92fe2138656f3f072c8341342febbe6d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 22:23:03 +0900 Subject: [PATCH 19/83] Make osu! logo at song select correctly handle mouse focus. --- osu.Game/Screens/Menu/OsuLogo.cs | 3 ++- osu.Game/Screens/Select/Footer.cs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 225b15c57e..3a1a37fdcc 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -195,11 +195,12 @@ namespace osu.Game.Screens.Menu protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { - logoBounceContainer.ScaleTo(1f, 500, EasingTypes.OutElastic); return true; } + protected override bool OnDragStart(InputState state) => true; + protected override bool OnClick(InputState state) { if (!Interactive) return false; diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 55fb36f144..df926c0778 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -25,6 +25,8 @@ namespace osu.Game.Screens.Select private const float padding = 80; + public override bool Contains(Vector2 screenSpacePos) => true; + public Action OnBack; public Action OnStart; From 9a2beb5979f6ac1a6e5b62b92e1d967a689280e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 22:43:49 +0900 Subject: [PATCH 20/83] Update Key Counter font. --- osu.Game/Screens/Play/KeyCounter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Play/KeyCounter.cs b/osu.Game/Screens/Play/KeyCounter.cs index cadc06f561..00dd2393d1 100644 --- a/osu.Game/Screens/Play/KeyCounter.cs +++ b/osu.Game/Screens/Play/KeyCounter.cs @@ -89,6 +89,8 @@ namespace osu.Game.Screens.Play new OsuSpriteText { Text = Name, + Font = @"Venera", + TextSize = 12, Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativePositionAxes = Axes.Both, From ca6946c7a29c44caab61e4755231f3971ac5c6bf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 22:44:21 +0900 Subject: [PATCH 21/83] Update Health display design. --- osu.Game/Modes/UI/HealthDisplay.cs | 45 +++++++++++++++++++++++------- osu.Game/Modes/UI/ScoreOverlay.cs | 4 +-- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/osu.Game/Modes/UI/HealthDisplay.cs b/osu.Game/Modes/UI/HealthDisplay.cs index 1771edb1d8..27734cea15 100644 --- a/osu.Game/Modes/UI/HealthDisplay.cs +++ b/osu.Game/Modes/UI/HealthDisplay.cs @@ -1,23 +1,29 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE -using OpenTK; -using OpenTK.Graphics; +using System; +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transformations; -using System; +using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; namespace osu.Game.Modes.UI { public class HealthDisplay : Container { private Box background; - private Box fill; + private Container fill; - public BindableDouble Current = new BindableDouble() { MinValue = 0, MaxValue = 1 }; + public BindableDouble Current = new BindableDouble() + { + MinValue = 0, + MaxValue = 1 + }; public HealthDisplay() { @@ -26,19 +32,38 @@ namespace osu.Game.Modes.UI background = new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.Gray, + Colour = Color4.Black, }, - fill = new Box + fill = new Container { RelativeSizeAxes = Axes.Both, - Colour = Color4.White, Scale = new Vector2(0, 1), - }, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + } + } + }, }; Current.ValueChanged += current_ValueChanged; } + [BackgroundDependencyLoader] + private void laod(OsuColour colours) + { + fill.Colour = colours.BlueLighter; + fill.EdgeEffect = new EdgeEffect + { + Colour = colours.BlueDarker.Opacity(0.6f), + Radius = 8, + Type= EdgeEffectType.Glow + }; + } + private void current_ValueChanged(object sender, EventArgs e) { fill.ScaleTo(new Vector2((float)Current, 1), 200, EasingTypes.OutQuint); diff --git a/osu.Game/Modes/UI/ScoreOverlay.cs b/osu.Game/Modes/UI/ScoreOverlay.cs index 7268b5a3b5..7be6af5c6a 100644 --- a/osu.Game/Modes/UI/ScoreOverlay.cs +++ b/osu.Game/Modes/UI/ScoreOverlay.cs @@ -27,9 +27,9 @@ namespace osu.Game.Modes.UI protected abstract ScoreCounter CreateScoreCounter(); protected virtual HealthDisplay CreateHealthDisplay() => new HealthDisplay { - Size = new Vector2(0.5f, 20), + Size = new Vector2(1, 5), RelativeSizeAxes = Axes.X, - Padding = new MarginPadding(5) + Margin = new MarginPadding { Top = 20 } }; public virtual void OnHit(HitObject h) From 53e40804ab70c712f56936823ddfbcedd474ae3b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 22:44:41 +0900 Subject: [PATCH 22/83] Move other score components to centre alignment (and switch font). --- osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs | 14 ++++++++------ osu.Game/Graphics/UserInterface/RollingCounter.cs | 5 ++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs b/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs index ba996be326..eb5aaa97c9 100644 --- a/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs +++ b/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs @@ -15,17 +15,19 @@ namespace osu.Game.Modes.Osu.UI { protected override ScoreCounter CreateScoreCounter() => new ScoreCounter() { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - TextSize = 60, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + TextSize = 40, + Position = new Vector2(0, 30), Margin = new MarginPadding { Right = 5 }, }; protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter() { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Position = new Vector2(0, 55), + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Position = new Vector2(0, 65), + TextSize = 20, Margin = new MarginPadding { Right = 5 }, }; diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index fd1022e546..e0a5d8ed2d 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -107,7 +107,10 @@ namespace osu.Game.Graphics.UserInterface { Children = new Drawable[] { - DisplayedCountSpriteText = new OsuSpriteText(), + DisplayedCountSpriteText = new OsuSpriteText() + { + Font = @"Venera" + }, }; TextSize = 40; From aaed7141609a5dbfbf448c371e7f8dc1717a7931 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Feb 2017 22:48:47 +0900 Subject: [PATCH 23/83] Adjust Explode alpha slightly. --- osu.Game.Modes.Osu/Objects/Drawables/Pieces/ExplodePiece.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ExplodePiece.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ExplodePiece.cs index 08c7423c23..97228f610f 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ExplodePiece.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ExplodePiece.cs @@ -25,7 +25,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { BlendingMode = BlendingMode.Additive, RelativeSizeAxes = Axes.Both, - Alpha = 0.1f, + Alpha = 0.2f, } }; } From 0b922365bb58ec3834f9163d2843daacde8eb89d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2017 15:27:42 +0900 Subject: [PATCH 24/83] Fix nullref due to missing controlPoints. --- osu.Game.Modes.Osu/Objects/Slider.cs | 2 +- osu.Game/Beatmaps/Beatmap.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index c3d8190240..daf4fd7138 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -59,7 +59,7 @@ namespace osu.Game.Modes.Osu.Objects var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1; var baseVelocity = 100 * baseDifficulty.SliderMultiplier; - Velocity = baseVelocity / (timingPoint.BeatLength * velocityAdjustment); + Velocity = baseVelocity / ((timingPoint?.BeatLength ?? 500) * velocityAdjustment); TickDistance = baseVelocity / (baseDifficulty.SliderTickRate * velocityAdjustment); } diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index d0ce290bad..5ddfadbc96 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -39,7 +39,7 @@ namespace osu.Game.Beatmaps ControlPoint timingPoint = null; foreach (var controlPoint in ControlPoints) - if (controlPoint.Time <= time) + if (controlPoint.Time <= time || timingPoint == null) { if (controlPoint.TimingChange) { From 9e8b4d43dddc87e3a72b76542d8b9cdef7daa3b8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2017 15:33:08 +0900 Subject: [PATCH 25/83] Improve exit procedure. --- osu.Game/OsuGame.cs | 7 ++----- osu.Game/Screens/Menu/ButtonSystem.cs | 22 +++++++--------------- osu.Game/Screens/Menu/Intro.cs | 5 ++++- osu.Game/Screens/Menu/MainMenu.cs | 2 +- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 2cce0aa0ce..691ff285db 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -235,17 +235,14 @@ namespace osu.Game ModeChanged?.Invoke(newMode); if (newMode == null) - Host.Exit(); + Exit(); } protected override bool OnExiting() { if (!intro.DidLoadMenu || intro.ChildGameMode != null) { - Scheduler.Add(delegate - { - intro.MakeCurrent(); - }); + Scheduler.Add(intro.MakeCurrent); return true; } diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 9a84a79333..fe3a45d33a 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -218,6 +218,7 @@ namespace osu.Game.Screens.Menu switch (state) { + case MenuState.Exit: case MenuState.Initial: toolbar?.Hide(); @@ -233,6 +234,12 @@ namespace osu.Game.Screens.Menu foreach (Button b in buttonsPlay) b.State = ButtonState.Contracted; + + if (state == MenuState.Exit) + { + osuLogo.RotateTo(20, EXIT_DELAY * 1.5f); + osuLogo.FadeOut(EXIT_DELAY); + } break; case MenuState.TopLevel: buttonArea.Flush(true); @@ -276,21 +283,6 @@ namespace osu.Game.Screens.Menu foreach (Button b in buttonsPlay) b.State = ButtonState.Contracted; break; - case MenuState.Exit: - buttonArea.FadeOut(200); - - foreach (Button b in buttonsTopLevel) - b.State = ButtonState.Contracted; - - foreach (Button b in buttonsPlay) - b.State = ButtonState.Contracted; - - osuLogo.Delay(150); - - osuLogo.ScaleTo(1f, EXIT_DELAY * 1.5f); - osuLogo.RotateTo(20, EXIT_DELAY * 1.5f); - osuLogo.FadeOut(EXIT_DELAY); - break; } backButton.State = state == MenuState.Play ? ButtonState.Expanded : ButtonState.Contracted; diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index cb3cfe0208..d3d376e4b0 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -109,10 +109,13 @@ namespace osu.Game.Screens.Menu protected override void OnResuming(GameMode last) { + if (!(last is MainMenu)) + Content.FadeIn(300); + //we also handle the exit transition. seeya.Play(); - double fadeOutTime = (last.LifetimeEnd - Time.Current) + 100; + double fadeOutTime = 2000; Scheduler.AddDelayed(Exit, fadeOutTime); diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index f672a3998b..8db6b6c8d8 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -95,7 +95,7 @@ namespace osu.Game.Screens.Menu protected override bool OnExiting(GameMode next) { buttons.State = MenuState.Exit; - Content.FadeOut(ButtonSystem.EXIT_DELAY); + Content.FadeOut(3000); return base.OnExiting(next); } } From 366e95dd4fa9526036d86722e41096783e953ec7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2017 17:33:41 +0900 Subject: [PATCH 26/83] Remove outdated comment. --- osu.Game/OsuGame.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 691ff285db..87f10fedf4 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -214,10 +214,6 @@ namespace osu.Game private void modeChanged(GameMode newMode) { - // - Ability to change window size - // - Ability to adjust music playback - // - Frame limiter changes - //central game mode change logic. if ((newMode as OsuGameMode)?.ShowOverlays != true) { From e6ef9f67aa813dd2ea5a49f1db39b4f07e0415a5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2017 18:59:30 +0900 Subject: [PATCH 27/83] GameMode -> Screen. --- osu-framework | 2 +- osu.Desktop.VisualTests/Benchmark.cs | 2 +- .../Tests/TestCaseChatDisplay.cs | 2 +- .../Tests/TestCaseGamefield.cs | 2 +- .../Tests/TestCaseHitObjects.cs | 2 +- .../Tests/TestCaseKeyCounter.cs | 2 +- .../Tests/TestCaseMenuButtonSystem.cs | 2 +- .../Tests/TestCaseMusicController.cs | 2 +- .../Tests/TestCaseNotificationManager.cs | 2 +- .../Tests/TestCaseOptions.cs | 2 +- .../Tests/TestCasePauseOverlay.cs | 2 +- .../Tests/TestCasePlaySongSelect.cs | 2 +- .../Tests/TestCasePlayer.cs | 2 +- .../Tests/TestCaseScoreCounter.cs | 2 +- .../Tests/TestCaseTextAwesome.cs | 2 +- .../Tests/TestCaseTwoLayerButton.cs | 2 +- osu.Desktop.VisualTests/VisualTestGame.cs | 4 +- osu.Desktop/OsuGameDesktop.cs | 4 +- osu.Desktop/Overlays/VersionManager.cs | 9 ++-- osu.Game/OsuGame.cs | 44 +++++++++---------- ...{BackgroundMode.cs => BackgroundScreen.cs} | 24 +++++----- ...eBeatmap.cs => BackgroundScreenBeatmap.cs} | 8 ++-- ...odeCustom.cs => BackgroundScreenCustom.cs} | 8 ++-- ...eDefault.cs => BackgroundScreenDefault.cs} | 2 +- ...dModeEmpty.cs => BackgroundScreenEmpty.cs} | 2 +- osu.Game/Screens/Charts/ChartInfo.cs | 2 +- osu.Game/Screens/Charts/ChartListing.cs | 2 +- osu.Game/Screens/Direct/OnlineListing.cs | 2 +- osu.Game/Screens/Edit/Editor.cs | 10 ++--- ...eModeWhiteBox.cs => GameScreenWhiteBox.cs} | 18 ++++---- osu.Game/Screens/Menu/Intro.cs | 19 ++++---- osu.Game/Screens/Menu/MainMenu.cs | 20 ++++----- osu.Game/Screens/Multiplayer/Lobby.cs | 2 +- osu.Game/Screens/Multiplayer/Match.cs | 10 ++--- osu.Game/Screens/Multiplayer/MatchCreate.cs | 2 +- .../{OsuGameMode.cs => OsuGameScreen.cs} | 24 +++++----- osu.Game/Screens/Play/FailDialog.cs | 12 ++--- osu.Game/Screens/Play/ModSelect.cs | 10 ++--- osu.Game/Screens/Play/Player.cs | 12 ++--- osu.Game/Screens/Ranking/Results.cs | 12 ++--- osu.Game/Screens/Select/EditSongSelect.cs | 4 +- osu.Game/Screens/Select/MatchSongSelect.cs | 4 +- osu.Game/Screens/Select/PlaySongSelect.cs | 16 +++---- osu.Game/osu.Game.csproj | 14 +++--- 44 files changed, 168 insertions(+), 164 deletions(-) rename osu.Game/Screens/{BackgroundMode.cs => BackgroundScreen.cs} (74%) rename osu.Game/Screens/Backgrounds/{BackgroundModeBeatmap.cs => BackgroundScreenBeatmap.cs} (89%) rename osu.Game/Screens/Backgrounds/{BackgroundModeCustom.cs => BackgroundScreenCustom.cs} (67%) rename osu.Game/Screens/Backgrounds/{BackgroundModeDefault.cs => BackgroundScreenDefault.cs} (85%) rename osu.Game/Screens/Backgrounds/{BackgroundModeEmpty.cs => BackgroundScreenEmpty.cs} (75%) rename osu.Game/Screens/{GameModeWhiteBox.cs => GameScreenWhiteBox.cs} (89%) rename osu.Game/Screens/{OsuGameMode.cs => OsuGameScreen.cs} (81%) diff --git a/osu-framework b/osu-framework index 4a58484532..596a39e8cf 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 4a5848453240326ba08b09a33a2467af8c174b6a +Subproject commit 596a39e8cfef8661efa2110a83648cdb754d7b4c diff --git a/osu.Desktop.VisualTests/Benchmark.cs b/osu.Desktop.VisualTests/Benchmark.cs index 506788e93c..9584dc52a4 100644 --- a/osu.Desktop.VisualTests/Benchmark.cs +++ b/osu.Desktop.VisualTests/Benchmark.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Desktop.Platform; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Game; using osu.Game.Modes; using osu.Game.Modes.Catch; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 54f3957014..d977e9cede 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using osu.Framework; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index cf0b6cd7ce..70abd6d8c4 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics; using osu.Framework.MathUtils; using osu.Framework.Timing; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index f82ea1c98c..7a46ea5ded 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using osu.Framework; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics; using osu.Framework.Timing; using OpenTK; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs index c5ecdfa936..c33a4001de 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.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.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; using OpenTK.Input; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs b/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs index 511f8568db..069cf39164 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.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.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Sprites; using osu.Game.Screens.Menu; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs index 67bea2454f..1a811a8588 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.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.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics; using osu.Framework.Timing; using osu.Game.Overlays; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs index 0b84eeaa30..e3457939f2 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using osu.Framework.Graphics; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.MathUtils; using osu.Framework.Timing; using osu.Game.Overlays; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs b/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs index 1fed512fc5..92a10cc649 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseOptions.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseOptions.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.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; using OpenTK.Input; diff --git a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs index 81825681f9..9d94189885 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs @@ -9,7 +9,7 @@ using osu.Game.Overlays.Pause; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Colour; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics.UserInterface; namespace osu.Desktop.VisualTests.Tests diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index 47fac4d339..274eeb9440 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using osu.Desktop.VisualTests.Platform; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Game.Database; using osu.Game.Modes; using osu.Game.Screens.Select; diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index c6baa0a4f0..e8b152dfd7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using osu.Framework.Allocation; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.MathUtils; using osu.Framework.Timing; using osu.Game.Beatmaps; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 891e888d76..d4ac16b86f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs b/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs index 301cf3dd8f..7502c623fe 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.MathUtils; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs b/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs index 2fbc9c811d..33ae728fd7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.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.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.UserInterface; diff --git a/osu.Desktop.VisualTests/VisualTestGame.cs b/osu.Desktop.VisualTests/VisualTestGame.cs index 51fcffce57..81b00d4ab2 100644 --- a/osu.Desktop.VisualTests/VisualTestGame.cs +++ b/osu.Desktop.VisualTests/VisualTestGame.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics.Cursor; using osu.Game.Database; using osu.Game; @@ -21,7 +21,7 @@ namespace osu.Desktop.VisualTests { base.LoadComplete(); - (new BackgroundModeDefault() { Depth = 10 }).Preload(this, AddInternal); + (new BackgroundScreenDefault() { Depth = 10 }).Preload(this, AddInternal); // Have to construct this here, rather than in the constructor, because // we depend on some dependencies to be loaded within OsuGameBase.load(). diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 167d4644b7..473dce62e9 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -29,7 +29,9 @@ namespace osu.Desktop { base.LoadComplete(); - (new VersionManager()).Preload(this, Add); + VersionManager versionManager; + (versionManager = new VersionManager()).Preload(this, Add); + Dependencies.Cache(versionManager); } public override void SetHost(BasicGameHost host) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 6c34838130..25f8dd97fd 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -23,6 +23,10 @@ namespace osu.Desktop.Overlays private UpdateManager updateManager; private NotificationManager notification; + AssemblyName assembly = Assembly.GetEntryAssembly().GetName(); + + public bool IsReleaseBuild => assembly.Version.Major > 0; + protected override bool HideOnEscape => false; public override bool HandleInput => false; @@ -40,14 +44,13 @@ namespace osu.Desktop.Overlays bool isDebug = false; Debug.Assert(isDebug = true); - var asm = Assembly.GetEntryAssembly().GetName(); string version; - if (asm.Version.Major == 0) + if (!IsReleaseBuild) { version = @"local " + (isDebug ? @"debug" : @"release"); } else - version = $@"{asm.Version.Major}.{asm.Version.Minor}.{asm.Version.Build}"; + version = $@"{assembly.Version.Major}.{assembly.Version.Minor}.{assembly.Version.Build}"; Children = new Drawable[] { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 87f10fedf4..03be28eff6 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -3,7 +3,7 @@ using System; using osu.Framework.Configuration; -using osu.Framework.GameModes; +using osu.Framework.Screens; using osu.Game.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -39,10 +39,10 @@ namespace osu.Game private NotificationManager notificationManager; - private MainMenu mainMenu => modeStack?.ChildGameMode as MainMenu; - private Intro intro => modeStack as Intro; + private MainMenu mainMenu => screenStack?.ChildGameScreen as MainMenu; + private Intro intro => screenStack as Intro; - private OsuGameMode modeStack; + private OsuScreen screenStack; private VolumeControl volume; @@ -106,11 +106,11 @@ namespace osu.Game } }); - (modeStack = new Intro()).Preload(this, d => + (screenStack = new Intro()).Preload(this, d => { - modeStack.ModePushed += modeAdded; - modeStack.Exited += modeRemoved; - mainContent.Add(modeStack); + screenStack.ModePushed += screenAdded; + screenStack.Exited += screenRemoved; + mainContent.Add(screenStack); }); //overlay elements @@ -206,16 +206,16 @@ namespace osu.Game return base.OnKeyDown(state, args); } - public Action ModeChanged; + public Action ModeChanged; private Container mainContent; private Container overlayContent; - private void modeChanged(GameMode newMode) + private void modeChanged(Screen newScreen) { //central game mode change logic. - if ((newMode as OsuGameMode)?.ShowOverlays != true) + if ((newScreen as OsuScreen)?.ShowOverlays != true) { Toolbar.State = Visibility.Hidden; musicController.State = Visibility.Hidden; @@ -228,15 +228,15 @@ namespace osu.Game Cursor.FadeIn(100); - ModeChanged?.Invoke(newMode); + ModeChanged?.Invoke(newScreen); - if (newMode == null) + if (newScreen == null) Exit(); } protected override bool OnExiting() { - if (!intro.DidLoadMenu || intro.ChildGameMode != null) + if (!intro.DidLoadMenu || intro.ChildScreen != null) { Scheduler.Add(intro.MakeCurrent); return true; @@ -249,21 +249,21 @@ namespace osu.Game { base.UpdateAfterChildren(); - if (modeStack.ChildGameMode != null) - modeStack.ChildGameMode.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight }; + if (screenStack.ChildScreen != null) + screenStack.ChildScreen.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight }; } - private void modeAdded(GameMode newMode) + private void screenAdded(Screen newScreen) { - newMode.ModePushed += modeAdded; - newMode.Exited += modeRemoved; + newScreen.ModePushed += screenAdded; + newScreen.Exited += screenRemoved; - modeChanged(newMode); + modeChanged(newScreen); } - private void modeRemoved(GameMode newMode) + private void screenRemoved(Screen newScreen) { - modeChanged(newMode); + modeChanged(newScreen); } } } diff --git a/osu.Game/Screens/BackgroundMode.cs b/osu.Game/Screens/BackgroundScreen.cs similarity index 74% rename from osu.Game/Screens/BackgroundMode.cs rename to osu.Game/Screens/BackgroundScreen.cs index 45931b7e18..0bce73b92f 100644 --- a/osu.Game/Screens/BackgroundMode.cs +++ b/osu.Game/Screens/BackgroundScreen.cs @@ -5,7 +5,7 @@ using System; using System.Threading; using osu.Framework; using osu.Framework.Allocation; -using osu.Framework.GameModes; +using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; using osu.Framework.Input; @@ -13,9 +13,9 @@ using OpenTK; namespace osu.Game.Screens { - public abstract class BackgroundMode : GameMode, IEquatable + public abstract class BackgroundScreen : Screen, IEquatable { - public virtual bool Equals(BackgroundMode other) + public virtual bool Equals(BackgroundScreen other) { return other?.GetType() == GetType(); } @@ -37,21 +37,21 @@ namespace osu.Game.Screens this.game = game; } - public override bool Push(GameMode mode) + public override bool Push(Screen screen) { // When trying to push a non-loaded GameMode, load it asynchronously and re-invoke Push // once it's done. - if (mode.LoadState == LoadState.NotLoaded) + if (screen.LoadState == LoadState.NotLoaded) { - mode.Preload(game, d => Push((BackgroundMode)d)); + screen.Preload(game, d => Push((BackgroundScreen)d)); return true; } // Make sure the in-progress loading is complete before pushing the GameMode. - while (mode.LoadState < LoadState.Loaded) + while (screen.LoadState < LoadState.Loaded) Thread.Sleep(1); - base.Push(mode); + base.Push(screen); return true; } @@ -62,7 +62,7 @@ namespace osu.Game.Screens Content.Scale = new Vector2(1 + (x_movement_amount / DrawSize.X) * 2); } - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { Content.FadeOut(); Content.MoveToX(x_movement_amount); @@ -73,13 +73,13 @@ namespace osu.Game.Screens base.OnEntering(last); } - protected override void OnSuspending(GameMode next) + protected override void OnSuspending(Screen next) { Content.MoveToX(-x_movement_amount, transition_length, EasingTypes.InOutQuart); base.OnSuspending(next); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { Content.FadeOut(transition_length, EasingTypes.OutExpo); Content.MoveToX(x_movement_amount, transition_length, EasingTypes.OutExpo); @@ -87,7 +87,7 @@ namespace osu.Game.Screens return base.OnExiting(next); } - protected override void OnResuming(GameMode last) + protected override void OnResuming(Screen last) { Content.MoveToX(0, transition_length, EasingTypes.OutExpo); base.OnResuming(last); diff --git a/osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs similarity index 89% rename from osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs rename to osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index e7b0ba1566..a003fa2d57 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundModeBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -9,7 +9,7 @@ using osu.Game.Graphics.Backgrounds; namespace osu.Game.Screens.Backgrounds { - public class BackgroundModeBeatmap : BackgroundMode + public class BackgroundScreenBeatmap : BackgroundScreen { private Background background; @@ -55,7 +55,7 @@ namespace osu.Game.Screens.Backgrounds } } - public BackgroundModeBeatmap(WorkingBeatmap beatmap) + public BackgroundScreenBeatmap(WorkingBeatmap beatmap) { Beatmap = beatmap; } @@ -66,9 +66,9 @@ namespace osu.Game.Screens.Backgrounds blurTarget = sigma; } - public override bool Equals(BackgroundMode other) + public override bool Equals(BackgroundScreen other) { - return base.Equals(other) && beatmap == ((BackgroundModeBeatmap)other).Beatmap; + return base.Equals(other) && beatmap == ((BackgroundScreenBeatmap)other).Beatmap; } class BeatmapBackground : Background diff --git a/osu.Game/Screens/Backgrounds/BackgroundModeCustom.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs similarity index 67% rename from osu.Game/Screens/Backgrounds/BackgroundModeCustom.cs rename to osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs index 14c6a520ea..9ec8628c5f 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundModeCustom.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenCustom.cs @@ -5,19 +5,19 @@ using osu.Game.Graphics.Backgrounds; namespace osu.Game.Screens.Backgrounds { - public class BackgroundModeCustom : BackgroundMode + public class BackgroundScreenCustom : BackgroundScreen { private readonly string textureName; - public BackgroundModeCustom(string textureName) + public BackgroundScreenCustom(string textureName) { this.textureName = textureName; Add(new Background(textureName)); } - public override bool Equals(BackgroundMode other) + public override bool Equals(BackgroundScreen other) { - return base.Equals(other) && textureName == ((BackgroundModeCustom)other).textureName; + return base.Equals(other) && textureName == ((BackgroundScreenCustom)other).textureName; } } } \ No newline at end of file diff --git a/osu.Game/Screens/Backgrounds/BackgroundModeDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs similarity index 85% rename from osu.Game/Screens/Backgrounds/BackgroundModeDefault.cs rename to osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index 765afb905f..6807085061 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundModeDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -7,7 +7,7 @@ using osu.Game.Graphics.Backgrounds; namespace osu.Game.Screens.Backgrounds { - public class BackgroundModeDefault : BackgroundMode + public class BackgroundScreenDefault : BackgroundScreen { [BackgroundDependencyLoader] private void load(BaseGame game) diff --git a/osu.Game/Screens/Backgrounds/BackgroundModeEmpty.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenEmpty.cs similarity index 75% rename from osu.Game/Screens/Backgrounds/BackgroundModeEmpty.cs rename to osu.Game/Screens/Backgrounds/BackgroundScreenEmpty.cs index 7bc7c2226c..15aa8d10fe 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundModeEmpty.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenEmpty.cs @@ -3,7 +3,7 @@ namespace osu.Game.Screens.Backgrounds { - public class BackgroundModeEmpty : BackgroundMode + public class BackgroundScreenEmpty : BackgroundScreen { } diff --git a/osu.Game/Screens/Charts/ChartInfo.cs b/osu.Game/Screens/Charts/ChartInfo.cs index 036f0fb441..f85d3acb69 100644 --- a/osu.Game/Screens/Charts/ChartInfo.cs +++ b/osu.Game/Screens/Charts/ChartInfo.cs @@ -3,7 +3,7 @@ namespace osu.Game.Screens.Charts { - class ChartInfo : GameModeWhiteBox + class ChartInfo : ScreenWhiteBox { } } diff --git a/osu.Game/Screens/Charts/ChartListing.cs b/osu.Game/Screens/Charts/ChartListing.cs index 20972550ec..b570b63c06 100644 --- a/osu.Game/Screens/Charts/ChartListing.cs +++ b/osu.Game/Screens/Charts/ChartListing.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; namespace osu.Game.Screens.Charts { - class ChartListing : GameModeWhiteBox + class ChartListing : ScreenWhiteBox { protected override IEnumerable PossibleChildren => new[] { typeof(ChartInfo) diff --git a/osu.Game/Screens/Direct/OnlineListing.cs b/osu.Game/Screens/Direct/OnlineListing.cs index f7358a1a69..28de1c58d9 100644 --- a/osu.Game/Screens/Direct/OnlineListing.cs +++ b/osu.Game/Screens/Direct/OnlineListing.cs @@ -3,7 +3,7 @@ namespace osu.Game.Screens.Direct { - class OnlineListing : GameModeWhiteBox + class OnlineListing : ScreenWhiteBox { } } diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 7050a50bee..284a7f6f94 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -1,23 +1,23 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.GameModes; +using osu.Framework.Screens; using osu.Game.Screens.Backgrounds; using OpenTK.Graphics; namespace osu.Game.Screens.Edit { - class Editor : GameModeWhiteBox + class Editor : ScreenWhiteBox { - protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { base.OnEntering(last); Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500)); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { Background.Schedule(() => Background.FadeColour(Color4.White, 500)); return base.OnExiting(next); diff --git a/osu.Game/Screens/GameModeWhiteBox.cs b/osu.Game/Screens/GameScreenWhiteBox.cs similarity index 89% rename from osu.Game/Screens/GameModeWhiteBox.cs rename to osu.Game/Screens/GameScreenWhiteBox.cs index dce33eefb0..360dec504c 100644 --- a/osu.Game/Screens/GameModeWhiteBox.cs +++ b/osu.Game/Screens/GameScreenWhiteBox.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using osu.Framework.GameModes; +using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -17,7 +17,7 @@ using OpenTK.Graphics; namespace osu.Game.Screens { - public class GameModeWhiteBox : OsuGameMode + public class ScreenWhiteBox : OsuScreen { private BackButton popButton; @@ -29,9 +29,9 @@ namespace osu.Game.Screens private Container textContainer; private Box box; - protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg2"); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2"); - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { base.OnEntering(last); @@ -54,7 +54,7 @@ namespace osu.Game.Screens Content.FadeIn(transition_time, EasingTypes.OutExpo); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { textContainer.MoveTo(new Vector2((DrawSize.X / 16), 0), transition_time, EasingTypes.OutExpo); Content.FadeOut(transition_time, EasingTypes.OutExpo); @@ -62,7 +62,7 @@ namespace osu.Game.Screens return base.OnExiting(next); } - protected override void OnSuspending(GameMode next) + protected override void OnSuspending(Screen next) { base.OnSuspending(next); @@ -70,7 +70,7 @@ namespace osu.Game.Screens Content.FadeOut(transition_time, EasingTypes.OutExpo); } - protected override void OnResuming(GameMode last) + protected override void OnResuming(Screen last) { base.OnResuming(last); @@ -78,7 +78,7 @@ namespace osu.Game.Screens Content.FadeIn(transition_time, EasingTypes.OutExpo); } - public GameModeWhiteBox() + public ScreenWhiteBox() { Children = new Drawable[] { @@ -148,7 +148,7 @@ namespace osu.Game.Screens BackgroundColour = getColourFor(t), Action = delegate { - Push(Activator.CreateInstance(t) as GameMode); + Push(Activator.CreateInstance(t) as Screen); } }); } diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index d3d376e4b0..3b2444e231 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -5,7 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; -using osu.Framework.GameModes; +using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; using osu.Game.Graphics.Containers; @@ -14,7 +14,7 @@ using OpenTK.Graphics; namespace osu.Game.Screens.Menu { - class Intro : OsuGameMode + class Intro : OsuScreen { private OsuLogo logo; @@ -28,9 +28,9 @@ namespace osu.Game.Screens.Menu private AudioSample seeya; private AudioTrack bgm; - internal override bool ShowOverlays => (ParentGameMode as OsuGameMode)?.ShowOverlays ?? false; + internal override bool ShowOverlays => (ParentScreen as OsuScreen)?.ShowOverlays ?? false; - protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty(); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty(); public Intro() { @@ -65,7 +65,7 @@ namespace osu.Game.Screens.Menu bgm.Looping = true; } - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { base.OnEntering(last); @@ -77,8 +77,7 @@ namespace osu.Game.Screens.Menu { bgm.Start(); - mainMenu = new MainMenu(); - mainMenu.Preload(Game); + (mainMenu = new MainMenu()).Preload(Game); Scheduler.AddDelayed(delegate { @@ -95,19 +94,19 @@ namespace osu.Game.Screens.Menu logo.FadeIn(20000, EasingTypes.OutQuint); } - protected override void OnSuspending(GameMode next) + protected override void OnSuspending(Screen next) { Content.FadeOut(300); base.OnSuspending(next); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { //cancel exiting if we haven't loaded the menu yet. return !DidLoadMenu; } - protected override void OnResuming(GameMode last) + protected override void OnResuming(Screen last) { if (!(last is MainMenu)) Content.FadeIn(300); diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 8db6b6c8d8..29fc44d673 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -2,8 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.GameModes; -using osu.Framework.GameModes.Testing; +using osu.Framework.Screens; +using osu.Framework.Screens.Testing; using osu.Framework.Graphics; using osu.Framework.Graphics.Transformations; using osu.Game.Graphics.Containers; @@ -16,20 +16,20 @@ using osu.Game.Screens.Select; namespace osu.Game.Screens.Menu { - public class MainMenu : OsuGameMode + public class MainMenu : OsuScreen { private ButtonSystem buttons; public override string Name => @"Main Menu"; internal override bool ShowOverlays => buttons.State != MenuState.Initial; - private BackgroundMode background; + private BackgroundScreen background; - protected override BackgroundMode CreateBackground() => background; + protected override BackgroundScreen CreateBackground() => background; public MainMenu() { - background = new BackgroundModeDefault(); + background = new BackgroundScreenDefault(); Children = new Drawable[] { @@ -62,13 +62,13 @@ namespace osu.Game.Screens.Menu } - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { base.OnEntering(last); buttons.FadeInFromZero(500); } - protected override void OnSuspending(GameMode next) + protected override void OnSuspending(Screen next) { base.OnSuspending(next); @@ -80,7 +80,7 @@ namespace osu.Game.Screens.Menu Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine); } - protected override void OnResuming(GameMode last) + protected override void OnResuming(Screen last) { base.OnResuming(last); @@ -92,7 +92,7 @@ namespace osu.Game.Screens.Menu Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { buttons.State = MenuState.Exit; Content.FadeOut(3000); diff --git a/osu.Game/Screens/Multiplayer/Lobby.cs b/osu.Game/Screens/Multiplayer/Lobby.cs index c3b4938232..c6d59000d3 100644 --- a/osu.Game/Screens/Multiplayer/Lobby.cs +++ b/osu.Game/Screens/Multiplayer/Lobby.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; namespace osu.Game.Screens.Multiplayer { - class Lobby : GameModeWhiteBox + class Lobby : ScreenWhiteBox { protected override IEnumerable PossibleChildren => new[] { typeof(MatchCreate), diff --git a/osu.Game/Screens/Multiplayer/Match.cs b/osu.Game/Screens/Multiplayer/Match.cs index 10de1655f3..e4edcb5d7d 100644 --- a/osu.Game/Screens/Multiplayer/Match.cs +++ b/osu.Game/Screens/Multiplayer/Match.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using osu.Framework.GameModes; +using osu.Framework.Screens; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Play; using OpenTK.Graphics; @@ -11,23 +11,23 @@ using osu.Game.Screens.Select; namespace osu.Game.Screens.Multiplayer { - class Match : GameModeWhiteBox + class Match : ScreenWhiteBox { protected override IEnumerable PossibleChildren => new[] { typeof(MatchSongSelect), typeof(Player), }; - protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { base.OnEntering(last); Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500)); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { Background.Schedule(() => Background.FadeColour(Color4.White, 500)); return base.OnExiting(next); diff --git a/osu.Game/Screens/Multiplayer/MatchCreate.cs b/osu.Game/Screens/Multiplayer/MatchCreate.cs index b0c0456635..57dc0bcf4b 100644 --- a/osu.Game/Screens/Multiplayer/MatchCreate.cs +++ b/osu.Game/Screens/Multiplayer/MatchCreate.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; namespace osu.Game.Screens.Multiplayer { - class MatchCreate : GameModeWhiteBox + class MatchCreate : ScreenWhiteBox { protected override IEnumerable PossibleChildren => new[] { typeof(Match) diff --git a/osu.Game/Screens/OsuGameMode.cs b/osu.Game/Screens/OsuGameScreen.cs similarity index 81% rename from osu.Game/Screens/OsuGameMode.cs rename to osu.Game/Screens/OsuGameScreen.cs index 3134640a60..7aa3d5a5d0 100644 --- a/osu.Game/Screens/OsuGameMode.cs +++ b/osu.Game/Screens/OsuGameScreen.cs @@ -4,21 +4,21 @@ using System; using osu.Framework.Allocation; using osu.Framework.Configuration; -using osu.Framework.GameModes; +using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics.Containers; namespace osu.Game.Screens { - public abstract class OsuGameMode : GameMode + public abstract class OsuScreen : Screen { - internal BackgroundMode Background { get; private set; } + internal BackgroundScreen Background { get; private set; } /// /// Override to create a BackgroundMode for the current GameMode. /// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause. /// - protected virtual BackgroundMode CreateBackground() => null; + protected virtual BackgroundScreen CreateBackground() => null; internal virtual bool ShowOverlays => true; @@ -73,15 +73,15 @@ namespace osu.Game.Screens beatmap = game?.Beatmap; } - public override bool Push(GameMode mode) + public override bool Push(Screen screen) { - OsuGameMode nextOsu = mode as OsuGameMode; + OsuScreen nextOsu = screen as OsuScreen; if (nextOsu != null) { nextOsu.beatmap = beatmap; } - return base.Push(mode); + return base.Push(screen); } protected virtual void OnBeatmapChanged(WorkingBeatmap beatmap) @@ -89,11 +89,11 @@ namespace osu.Game.Screens } - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { - OsuGameMode lastOsu = last as OsuGameMode; + OsuScreen lastOsu = last as OsuScreen; - BackgroundMode bg = CreateBackground(); + BackgroundScreen bg = CreateBackground(); if (lastOsu?.Background != null) { @@ -120,9 +120,9 @@ namespace osu.Game.Screens base.OnEntering(last); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { - OsuGameMode nextOsu = next as OsuGameMode; + OsuScreen nextOsu = next as OsuScreen; if (Background != null && !Background.Equals(nextOsu?.Background)) { diff --git a/osu.Game/Screens/Play/FailDialog.cs b/osu.Game/Screens/Play/FailDialog.cs index a275a87626..622dd0a44a 100644 --- a/osu.Game/Screens/Play/FailDialog.cs +++ b/osu.Game/Screens/Play/FailDialog.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.Framework.GameModes; +using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -14,9 +14,9 @@ using OpenTK.Graphics; namespace osu.Game.Screens.Play { - class FailDialog : OsuGameMode + class FailDialog : OsuScreen { - protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); private static readonly Vector2 background_blur = new Vector2(20); @@ -31,13 +31,13 @@ namespace osu.Game.Screens.Play }); } - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { base.OnEntering(last); - Background.Schedule(() => (Background as BackgroundModeBeatmap)?.BlurTo(background_blur, 1000)); + Background.Schedule(() => (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 1000)); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { Background.Schedule(() => Background.FadeColour(Color4.White, 500)); return base.OnExiting(next); diff --git a/osu.Game/Screens/Play/ModSelect.cs b/osu.Game/Screens/Play/ModSelect.cs index 917fc1ad23..9d3db0221d 100644 --- a/osu.Game/Screens/Play/ModSelect.cs +++ b/osu.Game/Screens/Play/ModSelect.cs @@ -1,23 +1,23 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.GameModes; +using osu.Framework.Screens; using osu.Game.Screens.Backgrounds; using OpenTK.Graphics; namespace osu.Game.Screens.Play { - class ModSelect : GameModeWhiteBox + class ModSelect : ScreenWhiteBox { - protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { base.OnEntering(last); Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500)); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { Background.Schedule(() => Background.FadeColour(Color4.White, 500)); return base.OnExiting(next); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 650568f60b..87f07b2766 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -12,7 +12,7 @@ using osu.Game.Modes; using osu.Game.Modes.Objects.Drawables; using osu.Game.Screens.Backgrounds; using OpenTK; -using osu.Framework.GameModes; +using osu.Framework.Screens; using osu.Game.Modes.UI; using osu.Game.Screens.Ranking; using osu.Game.Configuration; @@ -27,11 +27,11 @@ using osu.Framework.Logging; namespace osu.Game.Screens.Play { - public class Player : OsuGameMode + public class Player : OsuScreen { public bool Autoplay; - protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); internal override bool ShowOverlays => false; @@ -281,18 +281,18 @@ namespace osu.Game.Screens.Play }); } - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { base.OnEntering(last); - (Background as BackgroundModeBeatmap)?.BlurTo(Vector2.Zero, 1000); + (Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1000); Background?.FadeTo((100f - dimLevel) / 100, 1000); Content.Alpha = 0; dimLevel.ValueChanged += dimChanged; } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { if (pauseOverlay == null) return false; diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 5e61f381e9..119bc49e1a 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.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.Framework.GameModes; +using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -14,21 +14,21 @@ using OpenTK.Graphics; namespace osu.Game.Screens.Ranking { - class Results : OsuGameMode + class Results : OsuScreen { - protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); private static readonly Vector2 background_blur = new Vector2(20); ScoreDisplay scoreDisplay; - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { base.OnEntering(last); - Background.Schedule(() => (Background as BackgroundModeBeatmap)?.BlurTo(background_blur, 1000)); + Background.Schedule(() => (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 1000)); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { Background.Schedule(() => Background.FadeColour(Color4.White, 500)); return base.OnExiting(next); diff --git a/osu.Game/Screens/Select/EditSongSelect.cs b/osu.Game/Screens/Select/EditSongSelect.cs index 35c212bece..5eaaf1be64 100644 --- a/osu.Game/Screens/Select/EditSongSelect.cs +++ b/osu.Game/Screens/Select/EditSongSelect.cs @@ -8,12 +8,12 @@ using osu.Game.Screens.Edit; namespace osu.Game.Screens.Select { - class EditSongSelect : GameModeWhiteBox + class EditSongSelect : ScreenWhiteBox { protected override IEnumerable PossibleChildren => new[] { typeof(Editor) }; - protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); } } diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index de250197e7..4c9e7c9d37 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -5,8 +5,8 @@ using osu.Game.Screens.Backgrounds; namespace osu.Game.Screens.Select { - class MatchSongSelect : GameModeWhiteBox + class MatchSongSelect : ScreenWhiteBox { - protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4"); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); } } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index e206c5d5fa..3b36c86731 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -9,7 +9,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Track; using osu.Framework.Configuration; -using osu.Framework.GameModes; +using osu.Framework.Screens; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Game.Beatmaps; @@ -32,11 +32,11 @@ using osu.Framework.Threading; namespace osu.Game.Screens.Select { - public class PlaySongSelect : OsuGameMode + public class PlaySongSelect : OsuScreen { private Bindable playMode; private BeatmapDatabase database; - protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap); + protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); private CarouselContainer carousel; private TrackManager trackManager; @@ -203,7 +203,7 @@ namespace osu.Game.Screens.Select Schedule(() => addBeatmapSet(s, Game, true)); } - protected override void OnEntering(GameMode last) + protected override void OnEntering(Screen last) { base.OnEntering(last); ensurePlayingSelected(); @@ -218,7 +218,7 @@ namespace osu.Game.Screens.Select filter.Activate(); } - protected override void OnResuming(GameMode last) + protected override void OnResuming(Screen last) { player = null; @@ -233,7 +233,7 @@ namespace osu.Game.Screens.Select filter.Activate(); } - protected override void OnSuspending(GameMode next) + protected override void OnSuspending(Screen next) { Content.ScaleTo(1.1f, 250, EasingTypes.InSine); @@ -243,7 +243,7 @@ namespace osu.Game.Screens.Select base.OnSuspending(next); } - protected override bool OnExiting(GameMode next) + protected override bool OnExiting(Screen next) { beatmapInfoWedge.MoveToX(-100, 800, EasingTypes.InQuint); beatmapInfoWedge.RotateTo(10, 800, EasingTypes.InQuint); @@ -271,7 +271,7 @@ namespace osu.Game.Screens.Select private void changeBackground(WorkingBeatmap beatmap) { - var backgroundModeBeatmap = Background as BackgroundModeBeatmap; + var backgroundModeBeatmap = Background as BackgroundScreenBeatmap; if (backgroundModeBeatmap != null) { backgroundModeBeatmap.Beatmap = beatmap; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index ed49590dbd..1086aaf0ff 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -123,14 +123,14 @@ - - - - - + + + + + - + @@ -146,7 +146,7 @@ - + From fe3a6248ecf60a025ba645a29eca84c84f6449d6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 Feb 2017 20:07:11 +0900 Subject: [PATCH 28/83] Add better screen hierarchy and placeholder for dev build disclaimer. --- osu.Desktop/OsuGameDesktop.cs | 10 ++++--- osu.Desktop/Overlays/VersionManager.cs | 4 +-- osu.Game/OsuGame.cs | 25 ++++++++++++----- osu.Game/Screens/Loader.cs | 28 +++++++++++++++++++ osu.Game/Screens/Menu/Disclaimer.cs | 38 ++++++++++++++++++++++++++ osu.Game/Screens/Menu/Intro.cs | 2 +- osu.Game/osu.Game.csproj | 2 ++ 7 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 osu.Game/Screens/Loader.cs create mode 100644 osu.Game/Screens/Menu/Disclaimer.cs diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 473dce62e9..309d784438 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -19,19 +19,21 @@ namespace osu.Desktop { class OsuGameDesktop : OsuGame { + private VersionManager versionManager; + + public override bool IsDeployedBuild => versionManager.IsDeployedBuild; + public OsuGameDesktop(string[] args = null) : base(args) { - + versionManager = new VersionManager(); } protected override void LoadComplete() { base.LoadComplete(); - VersionManager versionManager; - (versionManager = new VersionManager()).Preload(this, Add); - Dependencies.Cache(versionManager); + versionManager.Preload(this, Add); } public override void SetHost(BasicGameHost host) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 25f8dd97fd..716ec91155 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -25,7 +25,7 @@ namespace osu.Desktop.Overlays AssemblyName assembly = Assembly.GetEntryAssembly().GetName(); - public bool IsReleaseBuild => assembly.Version.Major > 0; + public bool IsDeployedBuild => assembly.Version.Major > 0; protected override bool HideOnEscape => false; @@ -45,7 +45,7 @@ namespace osu.Desktop.Overlays Debug.Assert(isDebug = true); string version; - if (!IsReleaseBuild) + if (!IsDeployedBuild) { version = @"local " + (isDebug ? @"debug" : @"release"); } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 03be28eff6..43196431f2 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -31,6 +31,8 @@ namespace osu.Game { public class OsuGame : OsuGameBase { + public virtual bool IsDeployedBuild => false; + public Toolbar Toolbar; private ChatOverlay chat; @@ -39,8 +41,16 @@ namespace osu.Game private NotificationManager notificationManager; - private MainMenu mainMenu => screenStack?.ChildGameScreen as MainMenu; - private Intro intro => screenStack as Intro; + private Intro intro + { + get + { + Screen s = screenStack; + while (s != null && !(s is Intro)) + s = s.ChildScreen; + return s as Intro; + } + } private OsuScreen screenStack; @@ -106,7 +116,7 @@ namespace osu.Game } }); - (screenStack = new Intro()).Preload(this, d => + (screenStack = new Loader()).Preload(this, d => { screenStack.ModePushed += screenAdded; screenStack.Exited += screenRemoved; @@ -148,7 +158,7 @@ namespace osu.Game (Toolbar = new Toolbar { Depth = -3, - OnHome = delegate { mainMenu?.MakeCurrent(); }, + OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); }, OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; }, }).Preload(this, t => { @@ -226,7 +236,8 @@ namespace osu.Game Toolbar.State = Visibility.Visible; } - Cursor.FadeIn(100); + if (newScreen is MainMenu) + Cursor.FadeIn(100); ModeChanged?.Invoke(newScreen); @@ -249,8 +260,8 @@ namespace osu.Game { base.UpdateAfterChildren(); - if (screenStack.ChildScreen != null) - screenStack.ChildScreen.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight }; + if (intro?.ChildScreen != null) + intro.ChildScreen.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight }; } private void screenAdded(Screen newScreen) diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs new file mode 100644 index 0000000000..33094b7098 --- /dev/null +++ b/osu.Game/Screens/Loader.cs @@ -0,0 +1,28 @@ +// 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.Screens; +using osu.Game.Screens.Menu; + +namespace osu.Game.Screens +{ + class Loader : OsuScreen + { + internal override bool ShowOverlays => false; + + public Loader() + { + ValidForResume = false; + } + + [BackgroundDependencyLoader] + private void load(OsuGame game) + { + if (game.IsDeployedBuild) + new Disclaimer().Preload(game, d => Push((Screen)d)); + else + new Intro().Preload(game, d => Push((Screen)d)); + } + } +} diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs new file mode 100644 index 0000000000..c801f225b2 --- /dev/null +++ b/osu.Game/Screens/Menu/Disclaimer.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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Allocation; +using osu.Framework.Screens; + +namespace osu.Game.Screens.Menu +{ + class Disclaimer : OsuScreen + { + private Intro intro; + internal override bool ShowOverlays => false; + + [BackgroundDependencyLoader] + private void load(OsuGame game) + { + (intro = new Intro()).Preload(game); + } + + protected override void OnEntering(Screen last) + { + base.OnEntering(last); + + FadeInFromZero(100); + + Delay(5000); + + FadeOut(100); + + Push(intro); + } + } +} diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 3b2444e231..11f120e481 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -28,7 +28,7 @@ namespace osu.Game.Screens.Menu private AudioSample seeya; private AudioTrack bgm; - internal override bool ShowOverlays => (ParentScreen as OsuScreen)?.ShowOverlays ?? false; + internal override bool ShowOverlays => false; protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1086aaf0ff..632e35037b 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -131,7 +131,9 @@ + + From 72306e8757fb158aa0ef28c548611bc61d5ef5f9 Mon Sep 17 00:00:00 2001 From: Shadoxfix Date: Fri, 17 Feb 2017 17:36:00 +0100 Subject: [PATCH 29/83] Fix beatmap import crash when the first timingPoint starts later than a slider --- osu.Game/Beatmaps/Beatmap.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index d0ce290bad..cd99710db2 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -39,6 +39,7 @@ namespace osu.Game.Beatmaps ControlPoint timingPoint = null; foreach (var controlPoint in ControlPoints) + { if (controlPoint.Time <= time) { if (controlPoint.TimingChange) @@ -48,7 +49,15 @@ namespace osu.Game.Beatmaps } else overridePoint = controlPoint; } - else break; + else if (timingPoint == null && controlPoint.TimingChange) + { + timingPoint = controlPoint; + } + else + { + break; + } + } return timingPoint; } From 7a45ea58b2fbe5177c90966d58e8e89abdb5367a Mon Sep 17 00:00:00 2001 From: Shadoxfix Date: Fri, 17 Feb 2017 18:17:18 +0100 Subject: [PATCH 30/83] Add comment explaining why the branch is necessary --- osu.Game/Beatmaps/Beatmap.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index cd99710db2..af55caf3b7 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -49,6 +49,8 @@ namespace osu.Game.Beatmaps } else overridePoint = controlPoint; } + // Some beatmaps have the first timingPoint (accidentally) start after the first HitObject(s). + // This branch makes it so that the first ControlPoint that makes a timing change is used as the timingPoint for the HitObject(s). else if (timingPoint == null && controlPoint.TimingChange) { timingPoint = controlPoint; From 2f4855b00ffc4cb89cd79d4fc132be86f9bf47ba Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Fri, 17 Feb 2017 21:07:59 +0300 Subject: [PATCH 31/83] Added exception --- osu.Desktop/Overlays/VersionManager.cs | 45 +++++++++++++++----------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 6c34838130..d7e5454b6a 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -15,6 +15,7 @@ using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; +using System; namespace osu.Desktop.Overlays { @@ -112,27 +113,35 @@ namespace osu.Desktop.Overlays private async void updateChecker() { - updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); - - if (!updateManager.IsInstalledApp) - return; - - var info = await updateManager.CheckForUpdate(); - if (info.ReleasesToApply.Count > 0) + try { - ProgressNotification n = new UpdateProgressNotification - { - Text = @"Downloading update..." - }; - Schedule(() => notification.Post(n)); - Schedule(() => n.State = ProgressNotificationState.Active); - await updateManager.DownloadReleases(info.ReleasesToApply, (int p) => Schedule(() => n.Progress = p / 100f)); - Schedule(() => n.Text = @"Installing update..."); - await updateManager.ApplyReleases(info, (int p) => Schedule(() => n.Progress = p / 100f)); - Schedule(() => n.State = ProgressNotificationState.Completed); + updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); + if (!updateManager.IsInstalledApp) + return; + + var info = await updateManager.CheckForUpdate(); + if (info.ReleasesToApply.Count > 0) + { + ProgressNotification n = new UpdateProgressNotification + { + Text = @"Downloading update..." + }; + Schedule(() => notification.Post(n)); + Schedule(() => n.State = ProgressNotificationState.Active); + await updateManager.DownloadReleases(info.ReleasesToApply, (int p) => Schedule(() => n.Progress = p / 100f)); + Schedule(() => n.Text = @"Installing update..."); + await updateManager.ApplyReleases(info, (int p) => Schedule(() => n.Progress = p / 100f)); + Schedule(() => n.State = ProgressNotificationState.Completed); + + } + else + { + //check again every 30 minutes. + Scheduler.AddDelayed(updateChecker, 60000 * 30); + } } - else + catch(Exception e) { //check again every 30 minutes. Scheduler.AddDelayed(updateChecker, 60000 * 30); From 4b0d6cd26bdd5cff522e3fc1c7a44739ba8b85b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 17 Feb 2017 20:08:28 +0100 Subject: [PATCH 32/83] Don't rely on default relative size of ScrollContainer. --- osu.Game/Online/Chat/Drawables/ChannelDisplay.cs | 1 + osu.Game/Overlays/NotificationManager.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/Chat/Drawables/ChannelDisplay.cs b/osu.Game/Online/Chat/Drawables/ChannelDisplay.cs index 08630a25aa..cc60706831 100644 --- a/osu.Game/Online/Chat/Drawables/ChannelDisplay.cs +++ b/osu.Game/Online/Chat/Drawables/ChannelDisplay.cs @@ -38,6 +38,7 @@ namespace osu.Game.Online.Chat.Drawables }, new ScrollContainer { + RelativeSizeAxes = Axes.Both, Children = new Drawable[] { flow = new FlowContainer diff --git a/osu.Game/Overlays/NotificationManager.cs b/osu.Game/Overlays/NotificationManager.cs index cb2025c576..5e37ede783 100644 --- a/osu.Game/Overlays/NotificationManager.cs +++ b/osu.Game/Overlays/NotificationManager.cs @@ -38,8 +38,9 @@ namespace osu.Game.Overlays Colour = Color4.Black, Alpha = 0.6f, }, - scrollContainer = new ScrollContainer() + scrollContainer = new ScrollContainer { + RelativeSizeAxes = Axes.Both, Margin = new MarginPadding { Top = Toolbar.Toolbar.HEIGHT }, Children = new[] { From ef775458ddeaf8da5d67f4df63a3029d17d282f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 17 Feb 2017 21:27:17 +0100 Subject: [PATCH 33/83] Fix compilation error introduced in merge conflict resolution. --- osu.Game/Beatmaps/Beatmap.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index c251943fa7..f9bc865860 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -39,6 +39,7 @@ namespace osu.Game.Beatmaps 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). From 76cab600d9a7e41d455ba55f167dc1d20eab7b8a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 18 Feb 2017 13:23:53 +0900 Subject: [PATCH 34/83] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 596a39e8cf..b62e49ecb0 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 596a39e8cfef8661efa2110a83648cdb754d7b4c +Subproject commit b62e49ecb06c4a5b6fb304568e03b0689a8bdac3 From bf33cc6f5301753c63f50216b644cb76dc4982ee Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 18 Feb 2017 14:16:46 +0900 Subject: [PATCH 35/83] Make disclaimer actually be a thing. --- osu.Desktop/OsuGameDesktop.cs | 10 +++- osu.Game/OsuGame.cs | 6 +- osu.Game/Screens/Menu/Disclaimer.cs | 91 +++++++++++++++++++++++++++-- osu.Game/Screens/Menu/Intro.cs | 2 +- 4 files changed, 100 insertions(+), 9 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 309d784438..3111d72662 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -14,6 +14,7 @@ using osu.Game.Database; using osu.Desktop.Overlays; using System.Reflection; using System.Drawing; +using osu.Game.Screens.Menu; namespace osu.Desktop { @@ -26,14 +27,19 @@ namespace osu.Desktop public OsuGameDesktop(string[] args = null) : base(args) { - versionManager = new VersionManager(); + versionManager = new VersionManager { Depth = int.MinValue }; } protected override void LoadComplete() { base.LoadComplete(); - versionManager.Preload(this, Add); + versionManager.Preload(this); + ModeChanged += m => + { + if (!versionManager.IsAlive && m is Intro) + Add(versionManager); + }; } public override void SetHost(BasicGameHost host) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 43196431f2..1a0f08ffb8 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -216,7 +216,7 @@ namespace osu.Game return base.OnKeyDown(state, args); } - public Action ModeChanged; + public event Action ModeChanged; private Container mainContent; @@ -247,6 +247,10 @@ namespace osu.Game protected override bool OnExiting() { + if (screenStack.ChildScreen == null) return false; + + if (intro == null) return true; + if (!intro.DidLoadMenu || intro.ChildScreen != null) { Scheduler.Add(intro.MakeCurrent); diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index c801f225b2..c5c00d5037 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -7,32 +7,113 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; using osu.Framework.Screens; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; namespace osu.Game.Screens.Menu { class Disclaimer : OsuScreen { private Intro intro; + private TextAwesome icon; + private Color4 iconColour; + internal override bool ShowOverlays => false; + public Disclaimer() + { + ValidForResume = false; + + Children = new Drawable[] + { + new FlowContainer + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Direction = FlowDirections.Vertical, + Spacing = new Vector2(0, 2), + Children = new Drawable[] + { + icon = new TextAwesome + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Icon = FontAwesome.fa_warning, + TextSize = 30, + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + TextSize = 30, + Text = "This is a development build", + Margin = new MarginPadding + { + Bottom = 20 + }, + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = "Don't expect shit to work perfectly as this is very much a work in progress." + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = "Don't report bugs because we are aware. Don't complain about missing features because we are adding them." + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = "Sit back and enjoy. Visit discord.gg/ppy if you want to help out!", + Margin = new MarginPadding { Bottom = 20 }, + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + TextSize = 12, + Text = "oh and yes, you will get seizures.", + }, + } + } + }; + } + [BackgroundDependencyLoader] - private void load(OsuGame game) + private void load(OsuGame game, OsuColour colours) { (intro = new Intro()).Preload(game); + + iconColour = colours.Yellow; } protected override void OnEntering(Screen last) { base.OnEntering(last); - FadeInFromZero(100); + Content.FadeInFromZero(500); - Delay(5000); + icon.Delay(1500); + icon.FadeColour(iconColour, 200); - FadeOut(100); + Delay(6000, true); - Push(intro); + Content.FadeOut(250); + + Delay(250); + + Schedule(() => Push(intro)); } } } diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 11f120e481..91a1bd33f7 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -14,7 +14,7 @@ using OpenTK.Graphics; namespace osu.Game.Screens.Menu { - class Intro : OsuScreen + public class Intro : OsuScreen { private OsuLogo logo; From 94dd268fd2aa204630d98b10919f71008787545b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 18 Feb 2017 15:54:16 +0900 Subject: [PATCH 36/83] Move constant for default ControlPoint out of Slider. --- osu.Game.Modes.Osu/Objects/Slider.cs | 6 +++--- osu.Game/Beatmaps/Beatmap.cs | 2 +- osu.Game/Beatmaps/Timing/ControlPoint.cs | 13 +++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index daf4fd7138..819e227606 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -57,10 +57,10 @@ namespace osu.Game.Modes.Osu.Objects ControlPoint overridePoint; ControlPoint timingPoint = beatmap.TimingPointAt(StartTime, out overridePoint); var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1; - var baseVelocity = 100 * baseDifficulty.SliderMultiplier; + var baseVelocity = 100 * baseDifficulty.SliderMultiplier / velocityAdjustment; - Velocity = baseVelocity / ((timingPoint?.BeatLength ?? 500) * velocityAdjustment); - TickDistance = baseVelocity / (baseDifficulty.SliderTickRate * velocityAdjustment); + Velocity = baseVelocity / timingPoint.BeatLength; + TickDistance = baseVelocity / baseDifficulty.SliderTickRate; } public int RepeatCount = 1; diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index f9bc865860..a55e9fa80d 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -55,7 +55,7 @@ namespace osu.Game.Beatmaps else break; } - return timingPoint; + return timingPoint ?? ControlPoint.Default; } } } diff --git a/osu.Game/Beatmaps/Timing/ControlPoint.cs b/osu.Game/Beatmaps/Timing/ControlPoint.cs index 27cc7244fb..88e2c2d0f4 100644 --- a/osu.Game/Beatmaps/Timing/ControlPoint.cs +++ b/osu.Game/Beatmaps/Timing/ControlPoint.cs @@ -1,20 +1,21 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace osu.Game.Beatmaps.Timing { public class ControlPoint { + public static ControlPoint Default = new ControlPoint + { + BeatLength = 500, + TimingChange = true, + }; + public double Time; public double BeatLength; public double VelocityAdjustment; public bool TimingChange; + } internal enum TimeSignatures From cf8b6c0697c6cb7cdb27423a9ff591e3a497793b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 18 Feb 2017 15:54:26 +0900 Subject: [PATCH 37/83] Fix backgrounds in TestCasePlayer dimming to gray instead of black. --- osu.Desktop.VisualTests/Tests/TestCasePlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index e8b152dfd7..2f8c37f1bb 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -71,7 +71,7 @@ namespace osu.Desktop.VisualTests.Tests Add(new Box { RelativeSizeAxes = Framework.Graphics.Axes.Both, - Colour = Color4.Gray, + Colour = Color4.Black, }); Add(new Player From 32ce8cf72356b5730992f6bc3853f6e3a6e46462 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 18 Feb 2017 17:35:04 +0900 Subject: [PATCH 38/83] Audio class renames in line with framework changes. --- osu-framework | 2 +- osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 6 +++--- osu.Game/Graphics/UserInterface/OsuCheckbox.cs | 4 ++-- osu.Game/Graphics/UserInterface/OsuSliderBar.cs | 2 +- osu.Game/Graphics/UserInterface/TwoLayerButton.cs | 2 +- osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs | 2 +- osu.Game/Overlays/Pause/PauseButton.cs | 2 +- osu.Game/Overlays/Toolbar/ToolbarButton.cs | 2 +- osu.Game/Screens/Menu/Button.cs | 2 +- osu.Game/Screens/Menu/ButtonSystem.cs | 2 +- osu.Game/Screens/Menu/Intro.cs | 6 +++--- osu.Game/Screens/Menu/OsuLogo.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 6 +++--- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/osu-framework b/osu-framework index b62e49ecb0..3f0753c62c 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit b62e49ecb06c4a5b6fb304568e03b0689a8bdac3 +Subproject commit 3f0753c62c82532bbb384e4e3726dcdb715a0614 diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs index 7380871583..47ffe513c1 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -53,7 +53,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables }; } - private AudioSample sample; + private SampleChannel sample; [BackgroundDependencyLoader] private void load(AudioManager audio) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 62223ec879..676bf2821b 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -83,9 +83,9 @@ namespace osu.Game.Beatmaps } private ArchiveReader trackReader; - private AudioTrack track; + private Track track; private object trackLock = new object(); - public AudioTrack Track + public Track Track { get { @@ -99,7 +99,7 @@ namespace osu.Game.Beatmaps trackReader = getReader(); var trackData = trackReader?.GetStream(BeatmapInfo.Metadata.AudioFile); if (trackData != null) - track = new AudioTrackBass(trackData); + track = new TrackBass(trackData); } catch { } diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index 206b0dc09d..b05d005a1b 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -71,8 +71,8 @@ namespace osu.Game.Graphics.UserInterface private Nub nub; private SpriteText labelSpriteText; - private AudioSample sampleChecked; - private AudioSample sampleUnchecked; + private SampleChannel sampleChecked; + private SampleChannel sampleUnchecked; public OsuCheckbox() { diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index 229d510688..63c8749f00 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface { public class OsuSliderBar : SliderBar where U : struct { - private AudioSample sample; + private SampleChannel sample; private double lastSampleTime; private Nub nub; diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 54277bd7ff..294d8533e4 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -28,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface public static readonly Vector2 SIZE_EXTENDED = new Vector2(140, 50); public static readonly Vector2 SIZE_RETRACTED = new Vector2(100, 50); - public AudioSample ActivationSound; + public SampleChannel ActivationSound; private SpriteText text; public Color4 HoverColour; diff --git a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs index 94369d51aa..173176d8b4 100644 --- a/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Modes/Objects/Drawables/DrawableHitObject.cs @@ -54,7 +54,7 @@ namespace osu.Game.Modes.Objects.Drawables } } - AudioSample sample; + SampleChannel sample; [BackgroundDependencyLoader] private void load(AudioManager audio) diff --git a/osu.Game/Overlays/Pause/PauseButton.cs b/osu.Game/Overlays/Pause/PauseButton.cs index 1a1ba4f527..08ded6fbd1 100644 --- a/osu.Game/Overlays/Pause/PauseButton.cs +++ b/osu.Game/Overlays/Pause/PauseButton.cs @@ -55,7 +55,7 @@ namespace osu.Game.Overlays.Pause } } - public AudioSample SampleClick, SampleHover; + public SampleChannel SampleClick, SampleHover; private Container backgroundContainer, colourContainer, glowContainer; private Box leftGlow, centerGlow, rightGlow; diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index 1b8e68151c..8b8010821d 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -66,7 +66,7 @@ namespace osu.Game.Overlays.Toolbar private SpriteText tooltip1; private SpriteText tooltip2; protected FlowContainer Flow; - private AudioSample sampleClick; + private SampleChannel sampleClick; public ToolbarButton() { diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 14d957733a..0c4c6fc1e8 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -37,7 +37,7 @@ namespace osu.Game.Screens.Menu private readonly float extraWidth; private Key triggerKey; private string text; - private AudioSample sampleClick; + private SampleChannel sampleClick; public override bool Contains(Vector2 screenSpacePos) { diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index fe3a45d33a..8464ca92ef 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Menu public Action OnChart; public Action OnTest; - private AudioSample sampleOsuClick; + private SampleChannel sampleOsuClick; private Toolbar toolbar; diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 91a1bd33f7..c69dfff7db 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -24,9 +24,9 @@ namespace osu.Game.Screens.Menu internal bool DidLoadMenu; MainMenu mainMenu; - private AudioSample welcome; - private AudioSample seeya; - private AudioTrack bgm; + private SampleChannel welcome; + private SampleChannel seeya; + private Track bgm; internal override bool ShowOverlays => false; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 3a1a37fdcc..2035ec17ce 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -33,7 +33,7 @@ namespace osu.Game.Screens.Menu private Container logoBounceContainer; private Container logoHoverContainer; - private AudioSample sampleClick; + private SampleChannel sampleClick; private Container colourAndTriangles; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 87f07b2766..23341ec0d4 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -89,7 +89,7 @@ namespace osu.Game.Screens.Play return; } - AudioTrack track = Beatmap.Track; + Track track = Beatmap.Track; if (track != null) { diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 3b36c86731..706a71b2b6 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -47,8 +47,8 @@ namespace osu.Game.Screens.Select private static readonly Vector2 background_blur = new Vector2(20); private CancellationTokenSource initialAddSetsTask; - private AudioSample sampleChangeDifficulty; - private AudioSample sampleChangeBeatmap; + private SampleChannel sampleChangeDifficulty; + private SampleChannel sampleChangeBeatmap; private List beatmapGroups; @@ -317,7 +317,7 @@ namespace osu.Game.Screens.Select private void ensurePlayingSelected(bool preview = false) { - AudioTrack track = Beatmap?.Track; + Track track = Beatmap?.Track; if (track != null) { From 1a31589abd275d445b5140c86691ee9ed02c75c7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 18 Feb 2017 17:35:37 +0900 Subject: [PATCH 39/83] Add padding zeroes to score display (and fix not being applied initially). --- osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs | 2 +- osu.Game/Graphics/UserInterface/RollingCounter.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs b/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs index eb5aaa97c9..c7791ab8b4 100644 --- a/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs +++ b/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs @@ -13,7 +13,7 @@ namespace osu.Game.Modes.Osu.UI { public class OsuScoreOverlay : ScoreOverlay { - protected override ScoreCounter CreateScoreCounter() => new ScoreCounter() + protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index e0a5d8ed2d..1c287e2a30 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -117,10 +117,6 @@ namespace osu.Game.Graphics.UserInterface AutoSizeAxes = Axes.Both; DisplayedCount = Count; - - DisplayedCountSpriteText.Text = FormatCount(count); - DisplayedCountSpriteText.Anchor = Anchor; - DisplayedCountSpriteText.Origin = Origin; } protected override void LoadComplete() @@ -128,6 +124,10 @@ namespace osu.Game.Graphics.UserInterface base.LoadComplete(); Flush(false, TransformType); + + DisplayedCountSpriteText.Text = FormatCount(count); + DisplayedCountSpriteText.Anchor = Anchor; + DisplayedCountSpriteText.Origin = Origin; } /// From 78c9348b5a03958003f4b7d1b1940c70688de5b2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 18 Feb 2017 17:35:54 +0900 Subject: [PATCH 40/83] Make accuracy fixed width and improve feel. --- osu.Game/Graphics/UserInterface/PercentageCounter.cs | 4 ++-- osu.Game/Graphics/UserInterface/RollingCounter.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs index 399082a9bd..6b48dff26e 100644 --- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs +++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs @@ -20,8 +20,7 @@ namespace osu.Game.Graphics.UserInterface { protected override Type TransformType => typeof(TransformAccuracy); - protected override double RollingDuration => 150; - protected override bool IsRollingProportional => true; + protected override double RollingDuration => 750; private float epsilon => 1e-10f; @@ -32,6 +31,7 @@ namespace osu.Game.Graphics.UserInterface public PercentageCounter() { + DisplayedCountSpriteText.FixedWidth = true; Count = 1.0f; } diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 1c287e2a30..3d7a4ad8d7 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -38,7 +38,7 @@ namespace osu.Game.Graphics.UserInterface /// /// Easing for the counter rollover animation. /// - protected virtual EasingTypes RollingEasing => EasingTypes.Out; + protected virtual EasingTypes RollingEasing => EasingTypes.OutQuint; private T displayedCount; From 1524b89753406d9a7ca204de026f98283895e9af Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 18 Feb 2017 17:44:49 +0900 Subject: [PATCH 41/83] Bump framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 3f0753c62c..28c4acbb81 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 3f0753c62c82532bbb384e4e3726dcdb715a0614 +Subproject commit 28c4acbb818d7be0ff66c600daacde9d91a99c6e From e803564b5a07ae5426f9f1dbd16c47b7cae6cc3f Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Sat, 18 Feb 2017 13:46:47 +0300 Subject: [PATCH 42/83] Added the specific exception --- osu.Desktop/Overlays/VersionManager.cs | 53 +++++++++++++------------- osu.Desktop/osu.Desktop.csproj | 19 ++++++++- osu.Desktop/packages.config | 3 ++ 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index d7e5454b6a..1b72e85289 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -15,7 +15,7 @@ using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; -using System; +using System.Net.Http; namespace osu.Desktop.Overlays { @@ -116,32 +116,33 @@ namespace osu.Desktop.Overlays try { updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); - - if (!updateManager.IsInstalledApp) - return; - - var info = await updateManager.CheckForUpdate(); - if (info.ReleasesToApply.Count > 0) - { - ProgressNotification n = new UpdateProgressNotification - { - Text = @"Downloading update..." - }; - Schedule(() => notification.Post(n)); - Schedule(() => n.State = ProgressNotificationState.Active); - await updateManager.DownloadReleases(info.ReleasesToApply, (int p) => Schedule(() => n.Progress = p / 100f)); - Schedule(() => n.Text = @"Installing update..."); - await updateManager.ApplyReleases(info, (int p) => Schedule(() => n.Progress = p / 100f)); - Schedule(() => n.State = ProgressNotificationState.Completed); - - } - else - { - //check again every 30 minutes. - Scheduler.AddDelayed(updateChecker, 60000 * 30); - } } - catch(Exception e) + catch(HttpRequestException) + { + //check again every 30 minutes. + Scheduler.AddDelayed(updateChecker, 60000 * 30); + return; + } + + if (!updateManager.IsInstalledApp) + return; + + var info = await updateManager.CheckForUpdate(); + if (info.ReleasesToApply.Count > 0) + { + ProgressNotification n = new UpdateProgressNotification + { + Text = @"Downloading update..." + }; + Schedule(() => notification.Post(n)); + Schedule(() => n.State = ProgressNotificationState.Active); + await updateManager.DownloadReleases(info.ReleasesToApply, (int p) => Schedule(() => n.Progress = p / 100f)); + Schedule(() => n.Text = @"Installing update..."); + await updateManager.ApplyReleases(info, (int p) => Schedule(() => n.Progress = p / 100f)); + Schedule(() => n.State = ProgressNotificationState.Completed); + + } + else { //check again every 30 minutes. Scheduler.AddDelayed(updateChecker, 60000 * 30); diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 2ab913d706..603ae53174 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -137,6 +137,16 @@ + + + ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll + True + + + ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll + True + + @@ -219,7 +229,9 @@ - + + + + + + From ebc38917dcab14c8e74874f0a838ff4b26b1ab27 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 18 Feb 2017 22:29:20 +0900 Subject: [PATCH 43/83] Fix options sidebar not displaying correclty. --- osu.Game/Overlays/Options/Sidebar.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/Options/Sidebar.cs b/osu.Game/Overlays/Options/Sidebar.cs index f3fe3e1683..ffc3d04756 100644 --- a/osu.Game/Overlays/Options/Sidebar.cs +++ b/osu.Game/Overlays/Options/Sidebar.cs @@ -74,6 +74,7 @@ namespace osu.Game.Overlays.Options { Content.Anchor = Anchor.CentreLeft; Content.Origin = Anchor.CentreLeft; + RelativeSizeAxes = Axes.Both; } } } From c1194102b1716800d2b00bbbaa8ef8f330b442ed Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 18 Feb 2017 22:33:24 +0900 Subject: [PATCH 44/83] Remove second sample playback when clicking osu! logo. --- osu.Game/Screens/Menu/ButtonSystem.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 8464ca92ef..a203638478 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -32,8 +32,6 @@ namespace osu.Game.Screens.Menu public Action OnChart; public Action OnTest; - private SampleChannel sampleOsuClick; - private Toolbar toolbar; private FlowContainerWithOrigin buttonFlow; @@ -122,7 +120,6 @@ namespace osu.Game.Screens.Menu [BackgroundDependencyLoader(true)] private void load(AudioManager audio, OsuGame game = null) { - sampleOsuClick = audio.Sample.Get(@"Menu/menuhit"); toolbar = game?.Toolbar; } @@ -181,7 +178,6 @@ namespace osu.Game.Screens.Menu switch (state) { case MenuState.Initial: - sampleOsuClick.Play(); State = MenuState.TopLevel; return; case MenuState.TopLevel: From 837992d11225229dd24ded485b04bc809a0d3f24 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 Feb 2017 00:27:00 +0900 Subject: [PATCH 45/83] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 28c4acbb81..697d8b7e95 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 28c4acbb818d7be0ff66c600daacde9d91a99c6e +Subproject commit 697d8b7e9530ba7914d9c78012329ce1559e3681 From a48e4a31a79615928aba74c2d7eb85d43c371d40 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 18 Feb 2017 21:34:21 +0100 Subject: [PATCH 46/83] Parallax Option works now --- osu.Game/Configuration/OsuConfigManager.cs | 2 +- .../Graphics/Containers/ParallaxContainer.cs | 28 ++++++++++++++++--- osu.Game/Screens/Menu/MainMenu.cs | 1 - 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 381bca2a71..1562571efc 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -31,6 +31,7 @@ namespace osu.Game.Configuration Set(OsuConfig.SnakingInSliders, true); Set(OsuConfig.SnakingOutSliders, false); + Set(OsuConfig.MenuParallax, true); //todo: implement all settings below this line (remove the Disabled set when doing so). Set(OsuConfig.MouseSpeed, 1.0).Disabled = true; @@ -143,7 +144,6 @@ namespace osu.Game.Configuration Set(OsuConfig.DetectPerformanceIssues, true).Disabled = true; Set(OsuConfig.MenuMusic, true).Disabled = true; Set(OsuConfig.MenuVoice, true).Disabled = true; - Set(OsuConfig.MenuParallax, true).Disabled = true; Set(OsuConfig.RawInput, false).Disabled = true; Set(OsuConfig.AbsoluteToOsuWindow, Get(OsuConfig.RawInput)).Disabled = true; Set(OsuConfig.ShowMenuTips, true).Disabled = true; diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index fe3601a5f2..7513961574 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -8,12 +8,26 @@ using OpenTK; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics.Transformations; +using osu.Game.Configuration; namespace osu.Game.Graphics.Containers { class ParallaxContainer : Container { - public float ParallaxAmount = 0.02f; + public float ParallaxAmount + { + get + { + return defaultParallaxAmount; + } + + set + { + defaultParallaxAmount = value; + } + } + private float parallaxAmount; + private float defaultParallaxAmount = 0.02f; public override bool Contains(Vector2 screenSpacePos) => true; @@ -34,9 +48,15 @@ namespace osu.Game.Graphics.Containers protected override Container Content => content; [BackgroundDependencyLoader] - private void load(UserInputManager input) + private void load(UserInputManager input, OsuConfigManager config) { this.input = input; + + config.GetBindable(OsuConfig.MenuParallax).ValueChanged += delegate + { + parallaxAmount = config.GetBindable(OsuConfig.MenuParallax) ? defaultParallaxAmount : 0; + }; + parallaxAmount = config.GetBindable(OsuConfig.MenuParallax) ? defaultParallaxAmount : 0; } bool firstUpdate = true; @@ -46,8 +66,8 @@ namespace osu.Game.Graphics.Containers base.Update(); Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2; - content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); - content.Scale = new Vector2(1 + ParallaxAmount); + content.MoveTo(offset * parallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); + content.Scale = new Vector2(1 + parallaxAmount); firstUpdate = false; } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 29fc44d673..1a6310ea4e 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -59,7 +59,6 @@ namespace osu.Game.Screens.Menu background.Preload(game); buttons.OnSettings = game.ToggleOptions; - } protected override void OnEntering(Screen last) From 77bfe57d8cd6c49064162234f221b8dcc869d488 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 18 Feb 2017 22:00:07 +0100 Subject: [PATCH 47/83] compacted code, made public bool to disable it --- .../Graphics/Containers/ParallaxContainer.cs | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 7513961574..328d74994e 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -14,20 +14,8 @@ namespace osu.Game.Graphics.Containers { class ParallaxContainer : Container { - public float ParallaxAmount - { - get - { - return defaultParallaxAmount; - } - - set - { - defaultParallaxAmount = value; - } - } - private float parallaxAmount; - private float defaultParallaxAmount = 0.02f; + public float ParallaxAmount = 0.02f; + public bool ParallaxEnabled = true; public override bool Contains(Vector2 screenSpacePos) => true; @@ -54,9 +42,13 @@ namespace osu.Game.Graphics.Containers config.GetBindable(OsuConfig.MenuParallax).ValueChanged += delegate { - parallaxAmount = config.GetBindable(OsuConfig.MenuParallax) ? defaultParallaxAmount : 0; + ParallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); + if (!ParallaxEnabled) + { + content.MoveTo(Vector2.Zero, 1000, EasingTypes.OutQuint); + content.Scale = Vector2.One; + } }; - parallaxAmount = config.GetBindable(OsuConfig.MenuParallax) ? defaultParallaxAmount : 0; } bool firstUpdate = true; @@ -65,9 +57,11 @@ namespace osu.Game.Graphics.Containers { base.Update(); - Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2; - content.MoveTo(offset * parallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); - content.Scale = new Vector2(1 + parallaxAmount); + if (ParallaxEnabled) { + Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2; + content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); + content.Scale = new Vector2(1 + ParallaxAmount); + } firstUpdate = false; } From f166bb0f96b28e0b269326aae4cf4c7888bd97b6 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 18 Feb 2017 22:26:48 +0100 Subject: [PATCH 48/83] Moved movement to the default position to property --- .../Graphics/Containers/ParallaxContainer.cs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 328d74994e..3cf2e0f413 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -15,7 +15,24 @@ namespace osu.Game.Graphics.Containers class ParallaxContainer : Container { public float ParallaxAmount = 0.02f; - public bool ParallaxEnabled = true; + + private bool parallaxEnabled = true; + public bool ParallaxEnabled + { + get + { + return parallaxEnabled; + } + set + { + parallaxEnabled = value; + if (!parallaxEnabled) + { + content.MoveTo(Vector2.Zero, 1000, EasingTypes.OutQuint); + content.Scale = Vector2.One; + } + } + } public override bool Contains(Vector2 screenSpacePos) => true; @@ -43,11 +60,6 @@ namespace osu.Game.Graphics.Containers config.GetBindable(OsuConfig.MenuParallax).ValueChanged += delegate { ParallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); - if (!ParallaxEnabled) - { - content.MoveTo(Vector2.Zero, 1000, EasingTypes.OutQuint); - content.Scale = Vector2.One; - } }; } From 0da0ef5a1bf6ae26fc5586e2e1627b5ddd3b1b60 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 Feb 2017 17:06:41 +0900 Subject: [PATCH 49/83] Fix padding, fonts and alignment of chat display. --- osu.Game/Online/Chat/Drawables/ChatLine.cs | 13 ++++++++----- .../{ChannelDisplay.cs => DrawableChannel.cs} | 4 ++-- osu.Game/Overlays/ChatOverlay.cs | 4 ++-- osu.Game/osu.Game.csproj | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) rename osu.Game/Online/Chat/Drawables/{ChannelDisplay.cs => DrawableChannel.cs} (93%) diff --git a/osu.Game/Online/Chat/Drawables/ChatLine.cs b/osu.Game/Online/Chat/Drawables/ChatLine.cs index 21c6659e78..3780f68615 100644 --- a/osu.Game/Online/Chat/Drawables/ChatLine.cs +++ b/osu.Game/Online/Chat/Drawables/ChatLine.cs @@ -4,7 +4,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; @@ -15,7 +14,7 @@ namespace osu.Game.Online.Chat.Drawables { public readonly Message Message; - const float padding = 200; + const float padding = 250; const float text_size = 20; public ChatLine(Message message) @@ -25,6 +24,8 @@ namespace osu.Game.Online.Chat.Drawables RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; + Padding = new MarginPadding { Left = 15, Right = 15 }; + Children = new Drawable[] { new Container @@ -34,13 +35,15 @@ namespace osu.Game.Online.Chat.Drawables { new OsuSpriteText { - Text = Message.Timestamp.LocalDateTime.ToLongTimeString(), + Text = $@"{Message.Timestamp.LocalDateTime:hh:mm:ss}", + FixedWidth = true, TextSize = text_size, Colour = Color4.Gray }, new OsuSpriteText { - Text = Message.User.Name, + Font = @"Exo2.0-BoldItalic", + Text = $@"{Message.User.Name}:", TextSize = text_size, Origin = Anchor.TopRight, Anchor = Anchor.TopRight, @@ -51,7 +54,7 @@ namespace osu.Game.Online.Chat.Drawables { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Left = padding + 10 }, + Padding = new MarginPadding { Left = padding + 15 }, Children = new Drawable[] { new OsuSpriteText diff --git a/osu.Game/Online/Chat/Drawables/ChannelDisplay.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs similarity index 93% rename from osu.Game/Online/Chat/Drawables/ChannelDisplay.cs rename to osu.Game/Online/Chat/Drawables/DrawableChannel.cs index cc60706831..d2968a732b 100644 --- a/osu.Game/Online/Chat/Drawables/ChannelDisplay.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -13,12 +13,12 @@ using OpenTK; namespace osu.Game.Online.Chat.Drawables { - public class ChannelDisplay : Container + public class DrawableChannel : Container { private readonly Channel channel; private FlowContainer flow; - public ChannelDisplay(Channel channel) + public DrawableChannel(Channel channel) { this.channel = channel; newMessages(channel.Messages); diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index f99936763f..b9ac55bff0 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -24,7 +24,7 @@ namespace osu.Game.Overlays { public class ChatOverlay : OverlayContainer, IOnlineComponent { - private ChannelDisplay channelDisplay; + private DrawableChannel channelDisplay; private ScheduledDelegate messageRequest; @@ -69,7 +69,7 @@ namespace osu.Game.Overlays private void addChannel(Channel channel) { - Add(channelDisplay = new ChannelDisplay(channel)); + Add(channelDisplay = new DrawableChannel(channel)); careChannels.Add(channel); } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 632e35037b..55eee483bd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -189,7 +189,7 @@ - + From 2a099bb56cbb4d60d94cf9de05f96521ac6f469f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 Feb 2017 17:06:51 +0900 Subject: [PATCH 50/83] Stop TestCaseChatDisplay basically reimplementing ChatOverlay. --- .../Tests/TestCaseChatDisplay.cs | 110 +----------------- 1 file changed, 4 insertions(+), 106 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index d977e9cede..4e27788d67 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -17,6 +17,7 @@ using osu.Game.Online.Chat; using OpenTK; using osu.Framework.Allocation; using osu.Game.Online.Chat.Drawables; +using osu.Game.Overlays; namespace osu.Desktop.VisualTests.Tests { @@ -25,119 +26,16 @@ namespace osu.Desktop.VisualTests.Tests private ScheduledDelegate messageRequest; public override string Name => @"Chat"; - public override string Description => @"Testing API polling"; - - FlowContainer flow; - - private Scheduler scheduler = new Scheduler(); - - private APIAccess api; - - private ChannelDisplay channelDisplay; - - [BackgroundDependencyLoader] - private void load(APIAccess api) - { - this.api = api; - } + public override string Description => @"Testing chat api and overlay"; public override void Reset() { base.Reset(); - if (api.State != APIState.Online) - api.OnStateChange += delegate { initializeChannels(); }; - else - initializeChannels(); - } - - protected override void Update() - { - scheduler.Update(); - base.Update(); - } - - private long? lastMessageId; - - List careChannels; - - private void initializeChannels() - { - careChannels = new List(); - - if (api.State != APIState.Online) - return; - - Add(flow = new FlowContainer + Add(new ChatOverlay() { - RelativeSizeAxes = Axes.Both, - Direction = FlowDirections.Vertical + State = Visibility.Visible }); - - SpriteText loading; - Add(loading = new SpriteText - { - Text = @"Loading available channels...", - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - TextSize = 40, - }); - - messageRequest?.Cancel(); - - ListChannelsRequest req = new ListChannelsRequest(); - req.Success += delegate (List channels) - { - Scheduler.Add(delegate - { - loading.FadeOut(100); - }); - - addChannel(channels.Find(c => c.Name == @"#osu")); - addChannel(channels.Find(c => c.Name == @"#lobby")); - addChannel(channels.Find(c => c.Name == @"#english")); - - messageRequest = scheduler.AddDelayed(() => FetchNewMessages(api), 1000, true); - }; - api.Queue(req); - } - - private void addChannel(Channel channel) - { - flow.Add(channelDisplay = new ChannelDisplay(channel) - { - Size = new Vector2(1, 0.3f) - }); - - careChannels.Add(channel); - } - - GetMessagesRequest fetchReq; - - public void FetchNewMessages(APIAccess api) - { - if (fetchReq != null) return; - - fetchReq = new GetMessagesRequest(careChannels, lastMessageId); - fetchReq.Success += delegate (List messages) - { - foreach (Message m in messages) - { - careChannels.Find(c => c.Id == m.ChannelId).AddNewMessages(m); - } - - lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId; - - Debug.Write("success!"); - fetchReq = null; - }; - fetchReq.Failure += delegate - { - Debug.Write("failure!"); - fetchReq = null; - }; - - api.Queue(fetchReq); } } } From 520e04039688374e5b1f2863ca5a25dd5bfba4ef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 Feb 2017 17:59:22 +0900 Subject: [PATCH 51/83] Add FocusedTextBox abstraction. --- .../Graphics/UserInterface/FocusedTextBox.cs | 49 +++++++++++++++++++ osu.Game/Graphics/UserInterface/OsuTextBox.cs | 1 - osu.Game/Screens/Select/FilterControl.cs | 17 ++++--- osu.Game/Screens/Select/SearchTextBox.cs | 39 +-------------- osu.Game/osu.Game.csproj | 1 + 5 files changed, 60 insertions(+), 47 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/FocusedTextBox.cs diff --git a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs new file mode 100644 index 0000000000..f657ffe330 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs @@ -0,0 +1,49 @@ +using OpenTK.Graphics; +using OpenTK.Input; +using osu.Framework.Input; +using System; +using System.Linq; + +namespace osu.Game.Graphics.UserInterface +{ + public class FocusedTextBox : OsuTextBox + { + protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255); + protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255); + + public Action Exit; + + private bool focus; + public bool HoldFocus + { + get { return focus; } + set + { + focus = value; + if (!focus) + TriggerFocusLost(); + } + } + + protected override bool OnFocus(InputState state) + { + var result = base.OnFocus(state); + BorderThickness = 0; + return result; + } + + protected override void OnFocusLost(InputState state) + { + if (state.Keyboard.Keys.Any(key => key == Key.Escape)) + { + if (Text.Length > 0) + Text = string.Empty; + else + Exit?.Invoke(); + } + base.OnFocusLost(state); + } + + public override bool RequestingFocus => HoldFocus; + } +} diff --git a/osu.Game/Graphics/UserInterface/OsuTextBox.cs b/osu.Game/Graphics/UserInterface/OsuTextBox.cs index 0e551380ed..d7bc245027 100644 --- a/osu.Game/Graphics/UserInterface/OsuTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTextBox.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Game.Graphics.Sprites; -using osu.Game.Overlays; using OpenTK.Graphics; namespace osu.Game.Graphics.UserInterface diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 975a3f9ca3..23a61459ea 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -47,18 +47,19 @@ namespace osu.Game.Screens.Select Direction = FlowDirections.Vertical, Children = new Drawable[] { - searchTextBox = new SearchTextBox { RelativeSizeAxes = Axes.X }, + searchTextBox = new SearchTextBox { + RelativeSizeAxes = Axes.X, + OnChange = (TextBox sender, bool newText) => + { + if (newText) + FilterChanged?.Invoke(); + }, + Exit = () => Exit?.Invoke(), + }, new GroupSortTabs() } } }; - - searchTextBox.OnChange += (TextBox sender, bool newText) => - { - if (newText) - FilterChanged?.Invoke(); - }; - searchTextBox.Exit = () => Exit?.Invoke(); } public void Deactivate() diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index 4cd5353712..aeb9db75db 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -16,26 +16,8 @@ namespace osu.Game.Screens.Select /// /// A textbox which holds focus eagerly. /// - public class SearchTextBox : OsuTextBox + public class SearchTextBox : FocusedTextBox { - protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255); - protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255); - public Action Exit; - - private bool focus; - public bool HoldFocus - { - get { return focus; } - set - { - focus = value; - if (!focus) - TriggerFocusLost(); - } - } - - public override bool RequestingFocus => HoldFocus; - public SearchTextBox() { Height = 35; @@ -53,25 +35,6 @@ namespace osu.Game.Screens.Select PlaceholderText = "type to search"; } - protected override bool OnFocus(InputState state) - { - var result = base.OnFocus(state); - BorderThickness = 0; - return result; - } - - protected override void OnFocusLost(InputState state) - { - if (state.Keyboard.Keys.Any(key => key == Key.Escape)) - { - if (Text.Length > 0) - Text = string.Empty; - else - Exit?.Invoke(); - } - base.OnFocusLost(state); - } - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (HandlePendingText(state)) return true; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 55eee483bd..42461d0bdd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -70,6 +70,7 @@ + From aac4ba2baacb78c2c998f98f23e3fa7f9e997176 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 Feb 2017 18:02:25 +0900 Subject: [PATCH 52/83] Add input box to ChatOverlay. --- .../Online/Chat/Drawables/DrawableChannel.cs | 10 +++--- osu.Game/Overlays/ChatOverlay.cs | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index d2968a732b..07d5638766 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -21,8 +21,8 @@ namespace osu.Game.Online.Chat.Drawables public DrawableChannel(Channel channel) { this.channel = channel; - newMessages(channel.Messages); - channel.NewMessagesArrived += newMessages; + newMessagesArrived(channel.Messages); + channel.NewMessagesArrived += newMessagesArrived; RelativeSizeAxes = Axes.Both; @@ -56,16 +56,16 @@ namespace osu.Game.Online.Chat.Drawables protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); - channel.NewMessagesArrived -= newMessages; + channel.NewMessagesArrived -= newMessagesArrived; } [BackgroundDependencyLoader] private void load() { - newMessages(channel.Messages); + newMessagesArrived(channel.Messages); } - private void newMessages(IEnumerable newMessages) + private void newMessagesArrived(IEnumerable newMessages) { if (!IsLoaded) return; diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index b9ac55bff0..3088b5e7a1 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -19,6 +19,10 @@ using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.Chat; using osu.Game.Online.Chat.Drawables; +using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Select; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.UserInterface; namespace osu.Game.Overlays { @@ -32,6 +36,8 @@ namespace osu.Game.Overlays protected override Container Content => content; + private FocusedTextBox inputTextBox; + private APIAccess api; public ChatOverlay() @@ -52,10 +58,38 @@ namespace osu.Game.Overlays content = new Container { RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Bottom = 50 }, + }, + new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = 50, + Padding = new MarginPadding(5), + Children = new Drawable[] + { + inputTextBox = new FocusedTextBox + { + RelativeSizeAxes = Axes.X, + PlaceholderText = "type your message", + Exit = () => State = Visibility.Hidden, + OnCommit = postMessage, + HoldFocus = true, + } + } } }); } + private void postMessage(TextBox sender, bool newText) + { + var postText = sender.Text; + //todo: do something with postText. + + sender.Text = string.Empty; + } + [BackgroundDependencyLoader] private void load(APIAccess api) { From cde660a8efe801633cbf6df60f86ea6aa643b798 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 Feb 2017 18:07:35 +0900 Subject: [PATCH 53/83] Scroll to bottom. --- osu.Game/Online/Chat/Drawables/DrawableChannel.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index 07d5638766..e382b61452 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -17,6 +17,7 @@ namespace osu.Game.Online.Chat.Drawables { private readonly Channel channel; private FlowContainer flow; + private ScrollContainer scroll; public DrawableChannel(Channel channel) { @@ -36,7 +37,7 @@ namespace osu.Game.Online.Chat.Drawables Anchor = Anchor.Centre, Origin = Anchor.Centre }, - new ScrollContainer + scroll = new ScrollContainer { RelativeSizeAxes = Axes.Both, Children = new Drawable[] @@ -77,6 +78,8 @@ namespace osu.Game.Online.Chat.Drawables while (flow.Children.Count() > Channel.MAX_HISTORY) flow.Remove(flow.Children.First()); + + scroll.ScrollTo(flow.DrawHeight, false); } } } \ No newline at end of file From de87141e907672edf3531e51b561208e294c1909 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 Feb 2017 18:39:54 +0900 Subject: [PATCH 54/83] Remove unused using statements. --- osu.Game/Overlays/ChatOverlay.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 3088b5e7a1..e1593f1654 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -1,12 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using OpenTK; -using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -20,7 +18,6 @@ using osu.Game.Online.API.Requests; using osu.Game.Online.Chat; using osu.Game.Online.Chat.Drawables; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Select; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; From c6fa5cc80393537788f8d919288f4bd7d3abb5d3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 Feb 2017 18:46:19 +0900 Subject: [PATCH 55/83] Fix order of execution when populating initial messages. --- osu.Game/Online/Chat/Drawables/DrawableChannel.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index e382b61452..2042d7454b 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -22,8 +22,6 @@ namespace osu.Game.Online.Chat.Drawables public DrawableChannel(Channel channel) { this.channel = channel; - newMessagesArrived(channel.Messages); - channel.NewMessagesArrived += newMessagesArrived; RelativeSizeAxes = Axes.Both; @@ -52,6 +50,9 @@ namespace osu.Game.Online.Chat.Drawables } } }; + + channel.NewMessagesArrived += newMessagesArrived; + newMessagesArrived(channel.Messages); } protected override void Dispose(bool isDisposing) @@ -60,12 +61,6 @@ namespace osu.Game.Online.Chat.Drawables channel.NewMessagesArrived -= newMessagesArrived; } - [BackgroundDependencyLoader] - private void load() - { - newMessagesArrived(channel.Messages); - } - private void newMessagesArrived(IEnumerable newMessages) { if (!IsLoaded) return; From 3106c5209874aeb7bffc298f31d2ea2a4819a78a Mon Sep 17 00:00:00 2001 From: Andrey Zavadskiy Date: Sun, 19 Feb 2017 13:25:41 +0300 Subject: [PATCH 56/83] Removed unnecessary references --- osu.Desktop/osu.Desktop.csproj | 8 -------- osu.Desktop/packages.config | 2 -- 2 files changed, 10 deletions(-) diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 603ae53174..d85671f5be 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -229,9 +229,6 @@ - - - - - From e83ac8b04c6f50a256819a8c2698dab77933781e Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sun, 19 Feb 2017 13:47:26 +0100 Subject: [PATCH 57/83] Removed public ParallaxEnabled property --- .../Graphics/Containers/ParallaxContainer.cs | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 3cf2e0f413..7696e82009 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -17,22 +17,6 @@ namespace osu.Game.Graphics.Containers public float ParallaxAmount = 0.02f; private bool parallaxEnabled = true; - public bool ParallaxEnabled - { - get - { - return parallaxEnabled; - } - set - { - parallaxEnabled = value; - if (!parallaxEnabled) - { - content.MoveTo(Vector2.Zero, 1000, EasingTypes.OutQuint); - content.Scale = Vector2.One; - } - } - } public override bool Contains(Vector2 screenSpacePos) => true; @@ -59,7 +43,12 @@ namespace osu.Game.Graphics.Containers config.GetBindable(OsuConfig.MenuParallax).ValueChanged += delegate { - ParallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); + parallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); + if (!parallaxEnabled) + { + content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); + content.Scale = Vector2.One; + } }; } @@ -69,7 +58,7 @@ namespace osu.Game.Graphics.Containers { base.Update(); - if (ParallaxEnabled) { + if (parallaxEnabled) { Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2; content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); content.Scale = new Vector2(1 + ParallaxAmount); From d13b82d073d1783ed180990adec9f8c1b71a9341 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 19 Feb 2017 23:04:21 +0900 Subject: [PATCH 58/83] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 697d8b7e95..1654acef1c 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 697d8b7e9530ba7914d9c78012329ce1559e3681 +Subproject commit 1654acef1ca9b9f203bfef1b507f3515b41a4d84 From 7f751d365338b7bde8fd733bbf632a2ac4ee281a Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sun, 19 Feb 2017 16:54:00 +0100 Subject: [PATCH 59/83] Update ParallaxContainer.cs --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 7696e82009..9208c5008a 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -58,7 +58,8 @@ namespace osu.Game.Graphics.Containers { base.Update(); - if (parallaxEnabled) { + if (parallaxEnabled) + { Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2; content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); content.Scale = new Vector2(1 + ParallaxAmount); From 1e0a694ff86dc9e942d2adc125b20621e041fb3d Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sun, 19 Feb 2017 17:11:31 +0100 Subject: [PATCH 60/83] replaced bool with Bindable Also accounted for the ParallaxAmount when moving to default position --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 9208c5008a..bc54fd8fdc 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -9,6 +9,7 @@ using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics.Transformations; using osu.Game.Configuration; +using osu.Framework.Configuration; namespace osu.Game.Graphics.Containers { @@ -16,7 +17,7 @@ namespace osu.Game.Graphics.Containers { public float ParallaxAmount = 0.02f; - private bool parallaxEnabled = true; + private Bindable parallaxEnabled; public override bool Contains(Vector2 screenSpacePos) => true; @@ -40,14 +41,13 @@ namespace osu.Game.Graphics.Containers private void load(UserInputManager input, OsuConfigManager config) { this.input = input; - - config.GetBindable(OsuConfig.MenuParallax).ValueChanged += delegate + parallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); + parallaxEnabled.ValueChanged += delegate { - parallaxEnabled = config.GetBindable(OsuConfig.MenuParallax); if (!parallaxEnabled) { content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, EasingTypes.OutQuint); - content.Scale = Vector2.One; + content.Scale = new Vector2(1 + ParallaxAmount); } }; } From 417f14638646e47dbbe7a99a99a0af4f2454393e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 19 Feb 2017 17:41:51 +0100 Subject: [PATCH 61/83] Add difficulty calculation Adds base classes for difficulty calculations, hooks them up with carousel container, and adds a port of the osu difficulty calculator. --- osu-framework | 2 +- .../CatchDifficultyCalculator.cs | 27 +++ osu.Game.Modes.Catch/CatchRuleset.cs | 5 +- .../osu.Game.Modes.Catch.csproj | 1 + .../ManiaDifficultyCalculator.cs | 30 +++ osu.Game.Modes.Mania/ManiaRuleset.cs | 6 +- .../osu.Game.Modes.Mania.csproj | 1 + .../Objects/Drawables/DrawableSpinner.cs | 2 +- osu.Game.Modes.Osu/Objects/HitCircle.cs | 3 + osu.Game.Modes.Osu/Objects/OsuHitObject.cs | 16 +- .../Objects/OsuHitObjectDifficulty.cs | 200 ++++++++++++++++++ osu.Game.Modes.Osu/Objects/Slider.cs | 2 + osu.Game.Modes.Osu/Objects/SliderTick.cs | 2 + osu.Game.Modes.Osu/Objects/Spinner.cs | 2 + osu.Game.Modes.Osu/OsuDifficultyCalculator.cs | 193 +++++++++++++++++ osu.Game.Modes.Osu/OsuRuleset.cs | 2 + osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 2 + .../TaikoDifficultyCalculator.cs | 27 +++ osu.Game.Modes.Taiko/TaikoRuleset.cs | 4 +- .../osu.Game.Modes.Taiko.csproj | 1 + .../Beatmaps/Formats/OsuLegacyDecoderTest.cs | 3 - osu.Game/Beatmaps/DifficultyCalculator.cs | 50 +++++ osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 4 +- osu.Game/Beatmaps/Timing/TimingChange.cs | 6 - osu.Game/Beatmaps/WorkingBeatmap.cs | 1 - osu.Game/Database/BeatmapInfo.cs | 19 +- osu.Game/Modes/Ruleset.cs | 2 + osu.Game/Screens/Select/PlaySongSelect.cs | 4 +- osu.Game/osu.Game.csproj | 1 + 29 files changed, 587 insertions(+), 31 deletions(-) create mode 100644 osu.Game.Modes.Catch/CatchDifficultyCalculator.cs create mode 100644 osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs create mode 100644 osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs create mode 100644 osu.Game.Modes.Osu/OsuDifficultyCalculator.cs create mode 100644 osu.Game.Modes.Taiko/TaikoDifficultyCalculator.cs create mode 100644 osu.Game/Beatmaps/DifficultyCalculator.cs diff --git a/osu-framework b/osu-framework index 697d8b7e95..f370d4d6ef 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 697d8b7e9530ba7914d9c78012329ce1559e3681 +Subproject commit f370d4d6ef9f975932324d30272dfffc929a6622 diff --git a/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs b/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs new file mode 100644 index 0000000000..47fe1774bd --- /dev/null +++ b/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps; +using osu.Game.Modes.Catch.Objects; +using osu.Game.Modes.Objects; +using System; +using System.Collections.Generic; + +namespace osu.Game.Modes.Catch +{ + public class CatchDifficultyCalculator : DifficultyCalculator + { + protected override PlayMode PlayMode => PlayMode.Catch; + + public CatchDifficultyCalculator(Beatmap beatmap) : base(beatmap) + { + } + + protected override HitObjectConverter Converter => new CatchConverter(); + + protected override double ComputeDifficulty(Dictionary categoryDifficulty) + { + return 0; + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 5db11737f4..48a84617da 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -1,14 +1,13 @@ // 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.Game.Graphics; using osu.Game.Modes.Catch.UI; using osu.Game.Modes.Objects; -using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; using osu.Game.Beatmaps; +using System; namespace osu.Game.Modes.Catch { @@ -25,5 +24,7 @@ namespace osu.Game.Modes.Catch public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null; public override HitObjectParser CreateHitObjectParser() => new NullHitObjectParser(); + + public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new CatchDifficultyCalculator(beatmap); } } diff --git a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj index 8d32c23b9b..5e3f0f1d96 100644 --- a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj +++ b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj @@ -47,6 +47,7 @@ + diff --git a/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs b/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs new file mode 100644 index 0000000000..5075c44db6 --- /dev/null +++ b/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs @@ -0,0 +1,30 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps; +using osu.Game.Modes.Mania.Objects; +using osu.Game.Modes.Objects; +using System; +using System.Collections.Generic; + +namespace osu.Game.Modes.Mania +{ + public class ManiaDifficultyCalculator : DifficultyCalculator + { + protected override PlayMode PlayMode => PlayMode.Mania; + + private int columns; + + public ManiaDifficultyCalculator(Beatmap beatmap, int columns = 5) : base(beatmap) + { + this.columns = columns; + } + + protected override HitObjectConverter Converter => new ManiaConverter(columns); + + protected override double ComputeDifficulty(Dictionary categoryDifficulty) + { + return 0; + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 654a4ddaa6..28c298be95 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -1,15 +1,13 @@ // 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.Game.Graphics; using osu.Game.Modes.Mania.UI; using osu.Game.Modes.Objects; -using osu.Game.Modes.Osu; -using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; using osu.Game.Beatmaps; +using System; namespace osu.Game.Modes.Mania { @@ -26,5 +24,7 @@ namespace osu.Game.Modes.Mania public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null; public override HitObjectParser CreateHitObjectParser() => new NullHitObjectParser(); + + public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new ManiaDifficultyCalculator(beatmap); } } diff --git a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj index 7ff501c86d..ecd3fe6423 100644 --- a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj +++ b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj @@ -47,6 +47,7 @@ + diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs index cd72483d1e..2f6322a046 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs @@ -108,7 +108,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables } } - private Vector2 scaleToCircle => new Vector2(circle.Scale * circle.DrawWidth / DrawWidth) * 0.95f; + private Vector2 scaleToCircle => (circle.Scale * circle.DrawWidth / DrawWidth) * 0.95f; private float spinsPerMinuteNeeded = 100 + (5 * 15); //TODO: read per-map OD and place it on the 5 diff --git a/osu.Game.Modes.Osu/Objects/HitCircle.cs b/osu.Game.Modes.Osu/Objects/HitCircle.cs index aa45ac7fb9..0eaf5abdff 100644 --- a/osu.Game.Modes.Osu/Objects/HitCircle.cs +++ b/osu.Game.Modes.Osu/Objects/HitCircle.cs @@ -1,9 +1,12 @@ // 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.Modes.Osu.Objects { public class HitCircle : OsuHitObject { + public override HitObjectType Type => HitObjectType.Circle; } } diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs index c23c9a0b64..f454ebc470 100644 --- a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs @@ -25,6 +25,8 @@ namespace osu.Game.Modes.Osu.Objects public float Scale { get; set; } = 1; + public abstract HitObjectType Type { get; } + public override void SetDefaultsFromBeatmap(Beatmap beatmap) { base.SetDefaultsFromBeatmap(beatmap); @@ -36,14 +38,12 @@ namespace osu.Game.Modes.Osu.Objects [Flags] public enum HitObjectType { - Circle = 1, - Slider = 2, - NewCombo = 4, - CircleNewCombo = 5, - SliderNewCombo = 6, - Spinner = 8, + Circle = 1 << 0, + Slider = 1 << 1, + NewCombo = 1 << 2, + Spinner = 1 << 3, ColourHax = 122, - Hold = 128, - ManiaLong = 128, + Hold = 1 << 7, + SliderTick = 1 << 8, } } diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs b/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs new file mode 100644 index 0000000000..637c754ac4 --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs @@ -0,0 +1,200 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using System; +using System.Diagnostics; +using System.Linq; + +namespace osu.Game.Modes.Osu.Objects +{ + class OsuHitObjectDifficulty + { + /// + /// Factor by how much speed / aim strain decays per second. + /// + /// + /// These values are results of tweaking a lot and taking into account general feedback. + /// Opinionated observation: Speed is easier to maintain than accurate jumps. + /// + internal static readonly double[] DECAY_BASE = { 0.3, 0.15 }; + + /// + /// Pseudo threshold values to distinguish between "singles" and "streams" + /// + /// + /// Of course the border can not be defined clearly, therefore the algorithm has a smooth transition between those values. + /// They also are based on tweaking and general feedback. + /// + private const double STREAM_SPACING_TRESHOLD = 110, + SINGLE_SPACING_TRESHOLD = 125; + + /// + /// Scaling values for weightings to keep aim and speed difficulty in balance. + /// + /// + /// Found from testing a very large map pool (containing all ranked maps) and keeping the average values the same. + /// + private static readonly double[] SPACING_WEIGHT_SCALING = { 1400, 26.25 }; + + /// + /// Almost the normed diameter of a circle (104 osu pixel). That is -after- position transforming. + /// + private const double ALMOST_DIAMETER = 90; + + internal OsuHitObject BaseHitObject; + internal double[] Strains = { 1, 1 }; + + internal int MaxCombo = 1; + + private Vector2 normalizedStartPosition; + private Vector2 normalizedEndPosition; + private float lazySliderLength; + + internal OsuHitObjectDifficulty(OsuHitObject baseHitObject) + { + BaseHitObject = baseHitObject; + float circleRadius = baseHitObject.Scale * 64; + + Slider slider = BaseHitObject as Slider; + if (slider != null) + MaxCombo += slider.Ticks.Count(); + + // We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps. + float scalingFactor = (52.0f / circleRadius); + if (circleRadius < 30) + { + float smallCircleBonus = Math.Min(30.0f - circleRadius, 5.0f) / 50.0f; + scalingFactor *= 1.0f + smallCircleBonus; + } + + normalizedStartPosition = BaseHitObject.StackedPosition * scalingFactor; + + lazySliderLength = 0; + + // Calculate approximation of lazy movement on the slider + if (slider != null) + { + float sliderFollowCircleRadius = circleRadius * 3; // Not sure if this is correct, but here we do not need 100% exact values. This comes pretty darn close in my tests. + + // For simplifying this step we use actual osu! coordinates and simply scale the length, that we obtain by the ScalingFactor later + Vector2 cursorPos = baseHitObject.StackedPosition; + + Action addSliderVertex = delegate (Vector2 pos) + { + Vector2 difference = pos - cursorPos; + float distance = difference.Length; + + // Did we move away too far? + if (distance > sliderFollowCircleRadius) + { + // Yep, we need to move the cursor + difference.Normalize(); // Obtain the direction of difference. We do no longer need the actual difference + distance -= sliderFollowCircleRadius; + cursorPos += difference * distance; // We move the cursor just as far as needed to stay in the follow circle + lazySliderLength += distance; + } + }; + + // Actual computation of the first lazy curve + foreach (var tick in slider.Ticks) + addSliderVertex(tick.StackedPosition); + + addSliderVertex(baseHitObject.StackedEndPosition); + + lazySliderLength *= scalingFactor; + normalizedEndPosition = cursorPos * scalingFactor; + } + // We have a normal HitCircle or a spinner + else + normalizedEndPosition = normalizedStartPosition; + } + + internal void CalculateStrains(OsuHitObjectDifficulty previousHitObject, double timeRate) + { + calculateSpecificStrain(previousHitObject, OsuDifficultyCalculator.DifficultyType.Speed, timeRate); + calculateSpecificStrain(previousHitObject, OsuDifficultyCalculator.DifficultyType.Aim, timeRate); + } + + // Caution: The subjective values are strong with this one + private static double spacingWeight(double distance, OsuDifficultyCalculator.DifficultyType type) + { + switch (type) + { + case OsuDifficultyCalculator.DifficultyType.Speed: + if (distance > SINGLE_SPACING_TRESHOLD) + return 2.5; + else if (distance > STREAM_SPACING_TRESHOLD) + return 1.6 + 0.9 * (distance - STREAM_SPACING_TRESHOLD) / (SINGLE_SPACING_TRESHOLD - STREAM_SPACING_TRESHOLD); + else if (distance > ALMOST_DIAMETER) + return 1.2 + 0.4 * (distance - ALMOST_DIAMETER) / (STREAM_SPACING_TRESHOLD - ALMOST_DIAMETER); + else if (distance > ALMOST_DIAMETER / 2) + return 0.95 + 0.25 * (distance - (ALMOST_DIAMETER / 2)) / (ALMOST_DIAMETER / 2); + else + return 0.95; + + case OsuDifficultyCalculator.DifficultyType.Aim: + return Math.Pow(distance, 0.99); + } + + Debug.Assert(false, "Invalid osu difficulty hit object type."); + return 0; + } + + private void calculateSpecificStrain(OsuHitObjectDifficulty previousHitObject, OsuDifficultyCalculator.DifficultyType type, double timeRate) + { + double addition = 0; + double timeElapsed = (BaseHitObject.StartTime - previousHitObject.BaseHitObject.StartTime) / timeRate; + double decay = Math.Pow(DECAY_BASE[(int)type], timeElapsed / 1000); + + if (BaseHitObject.Type == HitObjectType.Spinner) + { + // Do nothing for spinners + } + else if (BaseHitObject.Type == HitObjectType.Slider) + { + switch (type) + { + case OsuDifficultyCalculator.DifficultyType.Speed: + + // For speed strain we treat the whole slider as a single spacing entity, since "Speed" is about how hard it is to click buttons fast. + // The spacing weight exists to differentiate between being able to easily alternate or having to single. + addition = + spacingWeight(previousHitObject.lazySliderLength + + DistanceTo(previousHitObject), type) * + SPACING_WEIGHT_SCALING[(int)type]; + + break; + case OsuDifficultyCalculator.DifficultyType.Aim: + + // For Aim strain we treat each slider segment and the jump after the end of the slider as separate jumps, since movement-wise there is no difference + // to multiple jumps. + addition = + ( + spacingWeight(previousHitObject.lazySliderLength, type) + + spacingWeight(DistanceTo(previousHitObject), type) + ) * + SPACING_WEIGHT_SCALING[(int)type]; + + break; + } + } + else if (BaseHitObject.Type == HitObjectType.Circle) + { + addition = spacingWeight(DistanceTo(previousHitObject), type) * SPACING_WEIGHT_SCALING[(int)type]; + } + + // Scale addition by the time, that elapsed. Filter out HitObjects that are too close to be played anyway to avoid crazy values by division through close to zero. + // You will never find maps that require this amongst ranked maps. + addition /= Math.Max(timeElapsed, 50); + + Strains[(int)type] = previousHitObject.Strains[(int)type] * decay + addition; + } + + internal double DistanceTo(OsuHitObjectDifficulty other) + { + // Scale the distance by circle size. + return (normalizedStartPosition - other.normalizedEndPosition).Length; + } + } +} diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index 819e227606..5f6c50fd72 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -110,6 +110,8 @@ namespace osu.Game.Modes.Osu.Objects } } } + + public override HitObjectType Type => HitObjectType.Slider; } public enum CurveTypes diff --git a/osu.Game.Modes.Osu/Objects/SliderTick.cs b/osu.Game.Modes.Osu/Objects/SliderTick.cs index de8f3f4b6f..392b1f99ca 100644 --- a/osu.Game.Modes.Osu/Objects/SliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/SliderTick.cs @@ -5,5 +5,7 @@ namespace osu.Game.Modes.Osu.Objects public class SliderTick : OsuHitObject { public int RepeatIndex { get; set; } + + public override HitObjectType Type => HitObjectType.SliderTick; } } diff --git a/osu.Game.Modes.Osu/Objects/Spinner.cs b/osu.Game.Modes.Osu/Objects/Spinner.cs index fa1bddf760..095705eb1f 100644 --- a/osu.Game.Modes.Osu/Objects/Spinner.cs +++ b/osu.Game.Modes.Osu/Objects/Spinner.cs @@ -10,5 +10,7 @@ namespace osu.Game.Modes.Osu.Objects public double Length; public override double EndTime => StartTime + Length; + + public override HitObjectType Type => HitObjectType.Spinner; } } diff --git a/osu.Game.Modes.Osu/OsuDifficultyCalculator.cs b/osu.Game.Modes.Osu/OsuDifficultyCalculator.cs new file mode 100644 index 0000000000..07449f8b6d --- /dev/null +++ b/osu.Game.Modes.Osu/OsuDifficultyCalculator.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 osu.Game.Beatmaps; +using osu.Game.Modes.Osu.Objects; +using System; +using System.Collections.Generic; +using osu.Game.Modes.Objects; + +namespace osu.Game.Modes.Osu +{ + public class OsuDifficultyCalculator : DifficultyCalculator + { + private const double STAR_SCALING_FACTOR = 0.0675; + private const double EXTREME_SCALING_FACTOR = 0.5; + + protected override PlayMode PlayMode => PlayMode.Osu; + + /// + /// HitObjects are stored as a member variable. + /// + internal List DifficultyHitObjects = new List(); + + public OsuDifficultyCalculator(Beatmap beatmap) : base(beatmap) + { + } + + protected override HitObjectConverter Converter => new OsuHitObjectConverter(); + + protected override void PreprocessHitObjects() + { + foreach (var h in Objects) + if (h.Type == HitObjectType.Slider) + ((Slider)h).Curve.Calculate(); + } + + protected override double ComputeDifficulty(Dictionary categoryDifficulty) + { + // Fill our custom DifficultyHitObject class, that carries additional information + DifficultyHitObjects.Clear(); + + foreach (var hitObject in Objects) + DifficultyHitObjects.Add(new OsuHitObjectDifficulty(hitObject)); + + // Sort DifficultyHitObjects by StartTime of the HitObjects - just to make sure. + DifficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime)); + + if (!CalculateStrainValues()) return 0; + + double speedDifficulty = CalculateDifficulty(DifficultyType.Speed); + double aimDifficulty = CalculateDifficulty(DifficultyType.Aim); + + // OverallDifficulty is not considered in this algorithm and neither is HpDrainRate. That means, that in this form the algorithm determines how hard it physically is + // to play the map, assuming, that too much of an error will not lead to a death. + // It might be desirable to include OverallDifficulty into map difficulty, but in my personal opinion it belongs more to the weighting of the actual peformance + // and is superfluous in the beatmap difficulty rating. + // If it were to be considered, then I would look at the hit window of normal HitCircles only, since Sliders and Spinners are (almost) "free" 300s and take map length + // into account as well. + + // The difficulty can be scaled by any desired metric. + // In osu!tp it gets squared to account for the rapid increase in difficulty as the limit of a human is approached. (Of course it also gets scaled afterwards.) + // It would not be suitable for a star rating, therefore: + + // The following is a proposal to forge a star rating from 0 to 5. It consists of taking the square root of the difficulty, since by simply scaling the easier + // 5-star maps would end up with one star. + double speedStars = Math.Sqrt(speedDifficulty) * STAR_SCALING_FACTOR; + double aimStars = Math.Sqrt(aimDifficulty) * STAR_SCALING_FACTOR; + + if (categoryDifficulty != null) + { + categoryDifficulty.Add("Aim", aimStars.ToString("0.00")); + categoryDifficulty.Add("Speed", speedStars.ToString("0.00")); + + double hitWindow300 = 30/*HitObjectManager.HitWindow300*/ / TimeRate; + double preEmpt = 450/*HitObjectManager.PreEmpt*/ / TimeRate; + + categoryDifficulty.Add("OD", (-(hitWindow300 - 80.0) / 6.0).ToString("0.00")); + categoryDifficulty.Add("AR", (preEmpt > 1200.0 ? -(preEmpt - 1800.0) / 120.0 : -(preEmpt - 1200.0) / 150.0 + 5.0).ToString("0.00")); + + int maxCombo = 0; + foreach (OsuHitObjectDifficulty hitObject in DifficultyHitObjects) + maxCombo += hitObject.MaxCombo; + + categoryDifficulty.Add("Max combo", maxCombo.ToString()); + } + + // Again, from own observations and from the general opinion of the community a map with high speed and low aim (or vice versa) difficulty is harder, + // than a map with mediocre difficulty in both. Therefore we can not just add both difficulties together, but will introduce a scaling that favors extremes. + double starRating = speedStars + aimStars + Math.Abs(speedStars - aimStars) * EXTREME_SCALING_FACTOR; + // Another approach to this would be taking Speed and Aim separately to a chosen power, which again would be equivalent. This would be more convenient if + // the hit window size is to be considered as well. + + // Note: The star rating is tuned extremely tight! Airman (/b/104229) and Freedom Dive (/b/126645), two of the hardest ranked maps, both score ~4.66 stars. + // Expect the easier kind of maps that officially get 5 stars to obtain around 2 by this metric. The tutorial still scores about half a star. + // Tune by yourself as you please. ;) + + return starRating; + } + + protected bool CalculateStrainValues() + { + // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment. + List.Enumerator hitObjectsEnumerator = DifficultyHitObjects.GetEnumerator(); + + if (!hitObjectsEnumerator.MoveNext()) return false; + + OsuHitObjectDifficulty currentHitObject = hitObjectsEnumerator.Current; + OsuHitObjectDifficulty nextHitObject; + + // First hitObject starts at strain 1. 1 is the default for strain values, so we don't need to set it here. See DifficultyHitObject. + while (hitObjectsEnumerator.MoveNext()) + { + nextHitObject = hitObjectsEnumerator.Current; + nextHitObject.CalculateStrains(currentHitObject, TimeRate); + currentHitObject = nextHitObject; + } + + return true; + } + + /// + /// In milliseconds. For difficulty calculation we will only look at the highest strain value in each time interval of size STRAIN_STEP. + /// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain. + /// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage. + /// + protected const double STRAIN_STEP = 400; + + /// + /// The weighting of each strain value decays to this number * it's previous value + /// + protected const double DECAY_WEIGHT = 0.9; + + protected double CalculateDifficulty(DifficultyType type) + { + double actualStrainStep = STRAIN_STEP * TimeRate; + + // Find the highest strain value within each strain step + List highestStrains = new List(); + double intervalEndTime = actualStrainStep; + double maximumStrain = 0; // We need to keep track of the maximum strain in the current interval + + OsuHitObjectDifficulty previousHitObject = null; + foreach (OsuHitObjectDifficulty hitObject in DifficultyHitObjects) + { + // While we are beyond the current interval push the currently available maximum to our strain list + while (hitObject.BaseHitObject.StartTime > intervalEndTime) + { + highestStrains.Add(maximumStrain); + + // The maximum strain of the next interval is not zero by default! We need to take the last hitObject we encountered, take its strain and apply the decay + // until the beginning of the next interval. + if (previousHitObject == null) + { + maximumStrain = 0; + } + else + { + double decay = Math.Pow(OsuHitObjectDifficulty.DECAY_BASE[(int)type], (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000); + maximumStrain = previousHitObject.Strains[(int)type] * decay; + } + + // Go to the next time interval + intervalEndTime += actualStrainStep; + } + + // Obtain maximum strain + maximumStrain = Math.Max(hitObject.Strains[(int)type], maximumStrain); + + previousHitObject = hitObject; + } + + // Build the weighted sum over the highest strains for each interval + double difficulty = 0; + double weight = 1; + highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. + + foreach (double strain in highestStrains) + { + difficulty += weight * strain; + weight *= DECAY_WEIGHT; + } + + return difficulty; + } + + // Those values are used as array indices. Be careful when changing them! + public enum DifficultyType : int + { + Speed = 0, + Aim, + }; + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index 398060aa73..d05c8193cc 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -40,6 +40,8 @@ namespace osu.Game.Modes.Osu public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => new OsuScoreProcessor(hitObjectCount); + public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap); + protected override PlayMode PlayMode => PlayMode.Osu; } } diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index 1b1ded3d61..ffe408ad59 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -66,9 +66,11 @@ + + diff --git a/osu.Game.Modes.Taiko/TaikoDifficultyCalculator.cs b/osu.Game.Modes.Taiko/TaikoDifficultyCalculator.cs new file mode 100644 index 0000000000..69b86a86af --- /dev/null +++ b/osu.Game.Modes.Taiko/TaikoDifficultyCalculator.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps; +using osu.Game.Modes.Objects; +using osu.Game.Modes.Taiko.Objects; +using System; +using System.Collections.Generic; + +namespace osu.Game.Modes.Taiko +{ + public class TaikoDifficultyCalculator : DifficultyCalculator + { + protected override PlayMode PlayMode => PlayMode.Taiko; + + public TaikoDifficultyCalculator(Beatmap beatmap) : base(beatmap) + { + } + + protected override HitObjectConverter Converter => new TaikoConverter(); + + protected override double ComputeDifficulty(Dictionary categoryDifficulty) + { + return 0; + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index bd20608d57..01e1598e20 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -2,10 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; using osu.Game.Graphics; using osu.Game.Modes.Objects; -using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.Taiko.UI; using osu.Game.Modes.UI; @@ -26,5 +24,7 @@ namespace osu.Game.Modes.Taiko public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null; public override HitObjectParser CreateHitObjectParser() => new NullHitObjectParser(); + + public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new TaikoDifficultyCalculator(beatmap); } } diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index 47c71ce09b..6d09463d93 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -47,6 +47,7 @@ + diff --git a/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs index 6613b5c370..e0d17badcd 100644 --- a/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs @@ -1,18 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.IO; using NUnit.Framework; using OpenTK; using OpenTK.Graphics; -using osu.Game.Beatmaps; using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Samples; using osu.Game.Modes; using osu.Game.Modes.Osu; using osu.Game.Modes.Osu.Objects; -using osu.Game.Screens.Play; using osu.Game.Tests.Resources; namespace osu.Game.Tests.Beatmaps.Formats diff --git a/osu.Game/Beatmaps/DifficultyCalculator.cs b/osu.Game/Beatmaps/DifficultyCalculator.cs new file mode 100644 index 0000000000..14b6ce3e96 --- /dev/null +++ b/osu.Game/Beatmaps/DifficultyCalculator.cs @@ -0,0 +1,50 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Modes; +using osu.Game.Modes.Objects; +using System; +using System.Collections.Generic; + +namespace osu.Game.Beatmaps +{ + public abstract class DifficultyCalculator + { + protected abstract PlayMode PlayMode { get; } + + protected double TimeRate = 1; + + protected abstract double ComputeDifficulty(Dictionary categoryDifficulty); + + private void loadTiming() + { + // TODO: Handle mods + int audioRate = 100; + TimeRate = audioRate / 100.0; + } + + public double GetDifficulty(Dictionary categoryDifficulty = null) + { + loadTiming(); + double difficulty = ComputeDifficulty(categoryDifficulty); + return difficulty; + } + } + + public abstract class DifficultyCalculator : DifficultyCalculator where T : HitObject + { + protected List Objects; + + protected abstract HitObjectConverter Converter { get; } + + public DifficultyCalculator(Beatmap beatmap) + { + Objects = Converter.Convert(beatmap); + PreprocessHitObjects(); + } + + protected virtual void PreprocessHitObjects() + { + } + } +} diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 9729ddf257..14aff0e7ba 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -60,7 +60,7 @@ namespace osu.Game.Beatmaps.Drawables } } - public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null) + public BeatmapGroup(WorkingBeatmap beatmap) { Header = new BeatmapSetHeader(beatmap) { @@ -68,6 +68,7 @@ namespace osu.Game.Beatmaps.Drawables RelativeSizeAxes = Axes.X, }; + BeatmapSet = beatmap.BeatmapSetInfo; BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b) { Alpha = 0, @@ -76,7 +77,6 @@ namespace osu.Game.Beatmaps.Drawables RelativeSizeAxes = Axes.X, }).ToList(); - BeatmapSet = set; Header.AddDifficultyIcons(BeatmapPanels); } diff --git a/osu.Game/Beatmaps/Timing/TimingChange.cs b/osu.Game/Beatmaps/Timing/TimingChange.cs index e86373f157..10a68bb540 100644 --- a/osu.Game/Beatmaps/Timing/TimingChange.cs +++ b/osu.Game/Beatmaps/Timing/TimingChange.cs @@ -1,12 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace osu.Game.Beatmaps.Timing { class TimingChange : ControlPoint diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 676bf2821b..28c2c5f0e2 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -68,7 +68,6 @@ namespace osu.Game.Beatmaps beatmap = decoder?.Decode(stream); } - if (WithStoryboard && beatmap != null && BeatmapSetInfo.StoryboardFile != null) using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile))) decoder?.Decode(stream, beatmap); diff --git a/osu.Game/Database/BeatmapInfo.cs b/osu.Game/Database/BeatmapInfo.cs index b2787dcae3..ec797d518e 100644 --- a/osu.Game/Database/BeatmapInfo.cs +++ b/osu.Game/Database/BeatmapInfo.cs @@ -8,6 +8,7 @@ using osu.Game.Modes; using osu.Game.Screens.Play; using SQLite.Net.Attributes; using SQLiteNetExtensions.Attributes; +using osu.Game.Beatmaps; namespace osu.Game.Database { @@ -73,7 +74,23 @@ namespace osu.Game.Database // Metadata public string Version { get; set; } - public float StarDifficulty => BaseDifficulty?.OverallDifficulty ?? 5; //todo: implement properly + //todo: background threaded computation of this + private float starDifficulty = -1; + public float StarDifficulty + { + get + { + return (starDifficulty < 0) ? (BaseDifficulty?.OverallDifficulty ?? 5) : starDifficulty; + } + + set { starDifficulty = value; } + } + + internal void ComputeDifficulty(BeatmapDatabase database) + { + WorkingBeatmap wb = new WorkingBeatmap(this, BeatmapSet, database); + StarDifficulty = (float)Ruleset.GetRuleset(Mode).CreateDifficultyCalculator(wb.Beatmap).GetDifficulty(); + } public bool Equals(BeatmapInfo other) { diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index 5b9373c10b..851e144408 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -32,6 +32,8 @@ namespace osu.Game.Modes public abstract HitObjectParser CreateHitObjectParser(); + public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap); + public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType()); protected abstract PlayMode PlayMode { get; } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 706a71b2b6..2dcd957950 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -337,11 +337,13 @@ namespace osu.Game.Screens.Select if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; }); + foreach (var b in beatmapSet.Beatmaps) + b.ComputeDifficulty(database); beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList(); var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database); - var group = new BeatmapGroup(beatmap, beatmapSet) + var group = new BeatmapGroup(beatmap) { SelectionChanged = selectionChanged, StartRequested = b => start() diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 632e35037b..39e2bfcd03 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -66,6 +66,7 @@ + From 502ad4aa538efdc7873236c491e406bc87a9a4a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 19 Feb 2017 18:11:14 +0100 Subject: [PATCH 62/83] Fix incorrect naming scheme --- .../Objects/OsuHitObjectDifficulty.cs | 28 +++++++++---------- osu.Game.Modes.Osu/OsuDifficultyCalculator.cs | 10 +++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs b/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs index 637c754ac4..003011c1ec 100644 --- a/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs +++ b/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs @@ -26,8 +26,8 @@ namespace osu.Game.Modes.Osu.Objects /// Of course the border can not be defined clearly, therefore the algorithm has a smooth transition between those values. /// They also are based on tweaking and general feedback. /// - private const double STREAM_SPACING_TRESHOLD = 110, - SINGLE_SPACING_TRESHOLD = 125; + private const double stream_spacing_threshold = 110, + single_spacing_threshold = 125; /// /// Scaling values for weightings to keep aim and speed difficulty in balance. @@ -35,12 +35,12 @@ namespace osu.Game.Modes.Osu.Objects /// /// Found from testing a very large map pool (containing all ranked maps) and keeping the average values the same. /// - private static readonly double[] SPACING_WEIGHT_SCALING = { 1400, 26.25 }; + private static readonly double[] spacing_weight_scaling = { 1400, 26.25 }; /// /// Almost the normed diameter of a circle (104 osu pixel). That is -after- position transforming. /// - private const double ALMOST_DIAMETER = 90; + private const double almost_diameter = 90; internal OsuHitObject BaseHitObject; internal double[] Strains = { 1, 1 }; @@ -122,14 +122,14 @@ namespace osu.Game.Modes.Osu.Objects switch (type) { case OsuDifficultyCalculator.DifficultyType.Speed: - if (distance > SINGLE_SPACING_TRESHOLD) + if (distance > single_spacing_threshold) return 2.5; - else if (distance > STREAM_SPACING_TRESHOLD) - return 1.6 + 0.9 * (distance - STREAM_SPACING_TRESHOLD) / (SINGLE_SPACING_TRESHOLD - STREAM_SPACING_TRESHOLD); - else if (distance > ALMOST_DIAMETER) - return 1.2 + 0.4 * (distance - ALMOST_DIAMETER) / (STREAM_SPACING_TRESHOLD - ALMOST_DIAMETER); - else if (distance > ALMOST_DIAMETER / 2) - return 0.95 + 0.25 * (distance - (ALMOST_DIAMETER / 2)) / (ALMOST_DIAMETER / 2); + else if (distance > stream_spacing_threshold) + return 1.6 + 0.9 * (distance - stream_spacing_threshold) / (single_spacing_threshold - stream_spacing_threshold); + else if (distance > almost_diameter) + return 1.2 + 0.4 * (distance - almost_diameter) / (stream_spacing_threshold - almost_diameter); + else if (distance > almost_diameter / 2) + return 0.95 + 0.25 * (distance - (almost_diameter / 2)) / (almost_diameter / 2); else return 0.95; @@ -162,7 +162,7 @@ namespace osu.Game.Modes.Osu.Objects addition = spacingWeight(previousHitObject.lazySliderLength + DistanceTo(previousHitObject), type) * - SPACING_WEIGHT_SCALING[(int)type]; + spacing_weight_scaling[(int)type]; break; case OsuDifficultyCalculator.DifficultyType.Aim: @@ -174,14 +174,14 @@ namespace osu.Game.Modes.Osu.Objects spacingWeight(previousHitObject.lazySliderLength, type) + spacingWeight(DistanceTo(previousHitObject), type) ) * - SPACING_WEIGHT_SCALING[(int)type]; + spacing_weight_scaling[(int)type]; break; } } else if (BaseHitObject.Type == HitObjectType.Circle) { - addition = spacingWeight(DistanceTo(previousHitObject), type) * SPACING_WEIGHT_SCALING[(int)type]; + addition = spacingWeight(DistanceTo(previousHitObject), type) * spacing_weight_scaling[(int)type]; } // Scale addition by the time, that elapsed. Filter out HitObjects that are too close to be played anyway to avoid crazy values by division through close to zero. diff --git a/osu.Game.Modes.Osu/OsuDifficultyCalculator.cs b/osu.Game.Modes.Osu/OsuDifficultyCalculator.cs index 07449f8b6d..24648b1726 100644 --- a/osu.Game.Modes.Osu/OsuDifficultyCalculator.cs +++ b/osu.Game.Modes.Osu/OsuDifficultyCalculator.cs @@ -11,8 +11,8 @@ namespace osu.Game.Modes.Osu { public class OsuDifficultyCalculator : DifficultyCalculator { - private const double STAR_SCALING_FACTOR = 0.0675; - private const double EXTREME_SCALING_FACTOR = 0.5; + private const double star_scaling_factor = 0.0675; + private const double extreme_scaling_factor = 0.5; protected override PlayMode PlayMode => PlayMode.Osu; @@ -63,8 +63,8 @@ namespace osu.Game.Modes.Osu // The following is a proposal to forge a star rating from 0 to 5. It consists of taking the square root of the difficulty, since by simply scaling the easier // 5-star maps would end up with one star. - double speedStars = Math.Sqrt(speedDifficulty) * STAR_SCALING_FACTOR; - double aimStars = Math.Sqrt(aimDifficulty) * STAR_SCALING_FACTOR; + double speedStars = Math.Sqrt(speedDifficulty) * star_scaling_factor; + double aimStars = Math.Sqrt(aimDifficulty) * star_scaling_factor; if (categoryDifficulty != null) { @@ -86,7 +86,7 @@ namespace osu.Game.Modes.Osu // Again, from own observations and from the general opinion of the community a map with high speed and low aim (or vice versa) difficulty is harder, // than a map with mediocre difficulty in both. Therefore we can not just add both difficulties together, but will introduce a scaling that favors extremes. - double starRating = speedStars + aimStars + Math.Abs(speedStars - aimStars) * EXTREME_SCALING_FACTOR; + double starRating = speedStars + aimStars + Math.Abs(speedStars - aimStars) * extreme_scaling_factor; // Another approach to this would be taking Speed and Aim separately to a chosen power, which again would be equivalent. This would be more convenient if // the hit window size is to be considered as well. From 7a0cea332fc3b12b441bf64ffbbcbfb5353050b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 19 Feb 2017 18:21:45 +0100 Subject: [PATCH 63/83] Add support for varying circle size --- .../Objects/OsuHitObjectDifficulty.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs b/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs index 003011c1ec..4f0dac7407 100644 --- a/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs +++ b/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs @@ -47,10 +47,12 @@ namespace osu.Game.Modes.Osu.Objects internal int MaxCombo = 1; - private Vector2 normalizedStartPosition; - private Vector2 normalizedEndPosition; + private float scalingFactor; private float lazySliderLength; + private Vector2 startPosition; + private Vector2 endPosition; + internal OsuHitObjectDifficulty(OsuHitObject baseHitObject) { BaseHitObject = baseHitObject; @@ -61,16 +63,15 @@ namespace osu.Game.Modes.Osu.Objects MaxCombo += slider.Ticks.Count(); // We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps. - float scalingFactor = (52.0f / circleRadius); + scalingFactor = (52.0f / circleRadius); if (circleRadius < 30) { float smallCircleBonus = Math.Min(30.0f - circleRadius, 5.0f) / 50.0f; scalingFactor *= 1.0f + smallCircleBonus; } - normalizedStartPosition = BaseHitObject.StackedPosition * scalingFactor; - lazySliderLength = 0; + startPosition = baseHitObject.StackedPosition; // Calculate approximation of lazy movement on the slider if (slider != null) @@ -78,7 +79,7 @@ namespace osu.Game.Modes.Osu.Objects float sliderFollowCircleRadius = circleRadius * 3; // Not sure if this is correct, but here we do not need 100% exact values. This comes pretty darn close in my tests. // For simplifying this step we use actual osu! coordinates and simply scale the length, that we obtain by the ScalingFactor later - Vector2 cursorPos = baseHitObject.StackedPosition; + Vector2 cursorPos = startPosition; Action addSliderVertex = delegate (Vector2 pos) { @@ -103,11 +104,11 @@ namespace osu.Game.Modes.Osu.Objects addSliderVertex(baseHitObject.StackedEndPosition); lazySliderLength *= scalingFactor; - normalizedEndPosition = cursorPos * scalingFactor; + endPosition = cursorPos; } // We have a normal HitCircle or a spinner else - normalizedEndPosition = normalizedStartPosition; + endPosition = startPosition; } internal void CalculateStrains(OsuHitObjectDifficulty previousHitObject, double timeRate) @@ -194,7 +195,7 @@ namespace osu.Game.Modes.Osu.Objects internal double DistanceTo(OsuHitObjectDifficulty other) { // Scale the distance by circle size. - return (normalizedStartPosition - other.normalizedEndPosition).Length; + return (startPosition - other.endPosition).Length * scalingFactor; } } } From 737bd62c30c6c1f2b29cf7d4e11a8f7c56bbfd27 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Feb 2017 15:27:48 +0900 Subject: [PATCH 64/83] Fix GlobalHotkeys not working (regression due to masking rules). --- osu.Game/Input/GlobalHotkeys.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Input/GlobalHotkeys.cs b/osu.Game/Input/GlobalHotkeys.cs index 96f8036aed..b1b22f7069 100644 --- a/osu.Game/Input/GlobalHotkeys.cs +++ b/osu.Game/Input/GlobalHotkeys.cs @@ -13,6 +13,11 @@ namespace osu.Game.Input public override bool HandleInput => true; + public GlobalHotkeys() + { + RelativeSizeAxes = Axes.Both; + } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { return Handler(state, args); From 7d08ccaae483e8685aafc2c40d7881d9a174eb4a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Feb 2017 15:30:58 +0900 Subject: [PATCH 65/83] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 697d8b7e95..b3f409ffb0 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 697d8b7e9530ba7914d9c78012329ce1559e3681 +Subproject commit b3f409ffb027f1b16c639c7ce3bb9dc4f215f79b From a621a65eb56449a031247ef8a6bf0e0448e5a2a3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Feb 2017 15:27:48 +0900 Subject: [PATCH 66/83] Fix GlobalHotkeys not working (regression due to masking rules). --- osu.Game/Input/GlobalHotkeys.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Input/GlobalHotkeys.cs b/osu.Game/Input/GlobalHotkeys.cs index 96f8036aed..b1b22f7069 100644 --- a/osu.Game/Input/GlobalHotkeys.cs +++ b/osu.Game/Input/GlobalHotkeys.cs @@ -13,6 +13,11 @@ namespace osu.Game.Input public override bool HandleInput => true; + public GlobalHotkeys() + { + RelativeSizeAxes = Axes.Both; + } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { return Handler(state, args); From 729f2eec8db0e220520b9bc081f26211fbd1a36c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Feb 2017 21:07:44 +0900 Subject: [PATCH 67/83] Increase maximum chat history. --- osu.Game/Online/Chat/Channel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index e67bfabc2e..9060bcd4f1 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -30,7 +30,7 @@ namespace osu.Game.Online.Chat //internal bool Joined; - public const int MAX_HISTORY = 100; + public const int MAX_HISTORY = 300; [JsonConstructor] public Channel() From 7a2eedbd7eee0d75ff43c77a96db99fa55bdb47f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Feb 2017 21:09:34 +0900 Subject: [PATCH 68/83] Add message batching per-channel. --- osu.Game/Online/Chat/Channel.cs | 9 ++------- osu.Game/Overlays/ChatOverlay.cs | 9 +++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/osu.Game/Online/Chat/Channel.cs b/osu.Game/Online/Chat/Channel.cs index 9060bcd4f1..d895b93336 100644 --- a/osu.Game/Online/Chat/Channel.cs +++ b/osu.Game/Online/Chat/Channel.cs @@ -3,12 +3,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; using Newtonsoft.Json; -using osu.Framework.Configuration; -using osu.Game.Online.API; -using osu.Game.Online.API.Requests; namespace osu.Game.Online.Chat { @@ -37,9 +32,9 @@ namespace osu.Game.Online.Chat { } - public event Action NewMessagesArrived; + public event Action> NewMessagesArrived; - public void AddNewMessages(params Message[] messages) + public void AddNewMessages(IEnumerable messages) { Messages.AddRange(messages); purgeOldMessages(); diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index e1593f1654..40226eb1cf 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -113,10 +113,11 @@ namespace osu.Game.Overlays fetchReq = new GetMessagesRequest(careChannels, lastMessageId); fetchReq.Success += delegate (List messages) { - foreach (Message m in messages) - { - careChannels.Find(c => c.Id == m.ChannelId).AddNewMessages(m); - } + var ids = messages.Select(m => m.ChannelId).Distinct(); + + //batch messages per channel. + foreach (var id in ids) + careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.ChannelId == id)); lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId; From 75b66871dd65cefd29f510a9736f532b8e8f8cfe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Feb 2017 21:09:56 +0900 Subject: [PATCH 69/83] Add colourised usernames. --- osu.Game/Online/Chat/Drawables/ChatLine.cs | 57 ++++++++++++++++++++-- osu.Game/Online/Chat/Message.cs | 1 + 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/Chat/Drawables/ChatLine.cs b/osu.Game/Online/Chat/Drawables/ChatLine.cs index 3780f68615..7c6b079eb0 100644 --- a/osu.Game/Online/Chat/Drawables/ChatLine.cs +++ b/osu.Game/Online/Chat/Drawables/ChatLine.cs @@ -1,9 +1,12 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; @@ -14,7 +17,51 @@ namespace osu.Game.Online.Chat.Drawables { public readonly Message Message; - const float padding = 250; + private static readonly Color4[] username_colours = { + OsuColour.FromHex("588c7e"), + OsuColour.FromHex("b2a367"), + OsuColour.FromHex("c98f65"), + OsuColour.FromHex("bc5151"), + OsuColour.FromHex("5c8bd6"), + OsuColour.FromHex("7f6ab7"), + OsuColour.FromHex("a368ad"), + OsuColour.FromHex("aa6880"), + + OsuColour.FromHex("6fad9b"), + OsuColour.FromHex("f2e394"), + OsuColour.FromHex("f2ae72"), + OsuColour.FromHex("f98f8a"), + OsuColour.FromHex("7daef4"), + OsuColour.FromHex("a691f2"), + OsuColour.FromHex("c894d3"), + OsuColour.FromHex("d895b0"), + + OsuColour.FromHex("53c4a1"), + OsuColour.FromHex("eace5c"), + OsuColour.FromHex("ea8c47"), + OsuColour.FromHex("fc4f4f"), + OsuColour.FromHex("3d94ea"), + OsuColour.FromHex("7760ea"), + OsuColour.FromHex("af52c6"), + OsuColour.FromHex("e25696"), + + OsuColour.FromHex("677c66"), + OsuColour.FromHex("9b8732"), + OsuColour.FromHex("8c5129"), + OsuColour.FromHex("8c3030"), + OsuColour.FromHex("1f5d91"), + OsuColour.FromHex("4335a5"), + OsuColour.FromHex("812a96"), + OsuColour.FromHex("992861"), + }; + + private Color4 getUsernameColour(Message message) + { + //todo: use User instead of Message when user_id is correctly populated. + return username_colours[message.UserId % username_colours.Length]; + } + + const float padding = 200; const float text_size = 20; public ChatLine(Message message) @@ -35,15 +82,19 @@ namespace osu.Game.Online.Chat.Drawables { new OsuSpriteText { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Font = @"Exo2.0-SemiBold", Text = $@"{Message.Timestamp.LocalDateTime:hh:mm:ss}", FixedWidth = true, - TextSize = text_size, - Colour = Color4.Gray + TextSize = text_size * 0.75f, + Alpha = 0.4f, }, new OsuSpriteText { Font = @"Exo2.0-BoldItalic", Text = $@"{Message.User.Name}:", + Colour = getUsernameColour(Message), TextSize = text_size, Origin = Anchor.TopRight, Anchor = Anchor.TopRight, diff --git a/osu.Game/Online/Chat/Message.cs b/osu.Game/Online/Chat/Message.cs index d412650176..3081653c34 100644 --- a/osu.Game/Online/Chat/Message.cs +++ b/osu.Game/Online/Chat/Message.cs @@ -11,6 +11,7 @@ namespace osu.Game.Online.Chat [JsonProperty(@"message_id")] public long Id; + //todo: this should be inside sender. [JsonProperty(@"user_id")] public int UserId; From 4afa434962ca08ab0be8730de65afd6389e9bc85 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Feb 2017 21:10:23 +0900 Subject: [PATCH 70/83] Maintain a scroll position when scrolled to the bottom of a chat channel. --- .../Online/Chat/Drawables/DrawableChannel.cs | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index 2042d7454b..8697d2749e 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -52,7 +52,14 @@ namespace osu.Game.Online.Chat.Drawables }; channel.NewMessagesArrived += newMessagesArrived; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + newMessagesArrived(channel.Messages); + scrollToEnd(); } protected override void Dispose(bool isDisposing) @@ -67,14 +74,25 @@ namespace osu.Game.Online.Chat.Drawables var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY)); + if (scroll.IsScrolledToEnd || !flow.Children.Any()) + scrollToEnd(); + //up to last Channel.MAX_HISTORY messages foreach (Message m in displayMessages) - flow.Add(new ChatLine(m)); + { + var d = new ChatLine(m); + flow.Add(d); + } - while (flow.Children.Count() > Channel.MAX_HISTORY) - flow.Remove(flow.Children.First()); - - scroll.ScrollTo(flow.DrawHeight, false); + while (flow.Children.Count(c => c.LifetimeEnd == double.MaxValue) > Channel.MAX_HISTORY) + { + var d = flow.Children.First(c => c.LifetimeEnd == double.MaxValue); + if (!scroll.IsScrolledToEnd) + scroll.OffsetScrollPosition(-d.DrawHeight); + d.Expire(); + } } + + private void scrollToEnd() => Scheduler.AddDelayed(() => scroll.ScrollToEnd(), 50); } } \ No newline at end of file From e3fa49dda7ad911731b08c71b1f2baa52f0d81a7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Feb 2017 21:10:43 +0900 Subject: [PATCH 71/83] Naively "send" messages that the user types (doesn't arrive yet). --- osu.Game/Overlays/ChatOverlay.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 40226eb1cf..b93acc46cb 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -82,7 +82,20 @@ namespace osu.Game.Overlays private void postMessage(TextBox sender, bool newText) { var postText = sender.Text; - //todo: do something with postText. + + if (!string.IsNullOrEmpty(postText)) + { + //todo: actually send to server + careChannels.FirstOrDefault()?.AddNewMessages(new[] + { + new Message + { + User = api.LocalUser.Value, + Timestamp = DateTimeOffset.Now, + Content = postText + } + }); + } sender.Text = string.Empty; } From 6a836205891e7de103f23f3d8433d8cf3771eaf1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 Feb 2017 21:11:09 +0900 Subject: [PATCH 72/83] Add better focus handling and padding/margin updates. --- .../Online/Chat/Drawables/DrawableChannel.cs | 7 ++++--- osu.Game/Overlays/ChatOverlay.cs | 20 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index 8697d2749e..ef1e7ca5df 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -4,10 +4,11 @@ using System; using System.Collections.Generic; using System.Linq; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Primitives; +using osu.Framework.MathUtils; +using osu.Framework.Threading; using osu.Game.Graphics.Sprites; using OpenTK; @@ -45,7 +46,7 @@ namespace osu.Game.Online.Chat.Drawables Direction = FlowDirections.Vertical, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Spacing = new Vector2(1, 1) + Padding = new MarginPadding { Left = 20, Right = 20 } } } } diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index b93acc46cb..6bfd9730f0 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -20,10 +21,12 @@ using osu.Game.Online.Chat.Drawables; using osu.Game.Graphics.UserInterface; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; +using OpenTK.Graphics; +using osu.Framework.Input; namespace osu.Game.Overlays { - public class ChatOverlay : OverlayContainer, IOnlineComponent + public class ChatOverlay : FocusedOverlayContainer, IOnlineComponent { private DrawableChannel channelDisplay; @@ -50,7 +53,8 @@ namespace osu.Game.Overlays { Depth = float.MaxValue, RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(0.1f).Opacity(0.4f), + Colour = Color4.Black, + Alpha = 0.9f, }, content = new Container { @@ -62,13 +66,14 @@ namespace osu.Game.Overlays Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, - Height = 50, + Height = 40, Padding = new MarginPadding(5), Children = new Drawable[] { inputTextBox = new FocusedTextBox { - RelativeSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Both, + Height = 1, PlaceholderText = "type your message", Exit = () => State = Visibility.Hidden, OnCommit = postMessage, @@ -79,6 +84,13 @@ namespace osu.Game.Overlays }); } + protected override bool OnFocus(InputState state) + { + //this is necessary as inputTextBox is masked away and therefore can't get focus :( + inputTextBox.TriggerFocus(); + return false; + } + private void postMessage(TextBox sender, bool newText) { var postText = sender.Text; From bc032aa0a6472a3ae0c77bfd4a5085ab96638ff9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 Feb 2017 12:58:56 +0900 Subject: [PATCH 73/83] Catch http errors in full update process (could happen during downloads too). --- osu.Desktop/Overlays/VersionManager.cs | 50 +++++++++++++------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index f33cd6eac2..388020dd27 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -119,33 +119,35 @@ namespace osu.Desktop.Overlays try { updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); - } - catch(HttpRequestException) - { - //check again every 30 minutes. - Scheduler.AddDelayed(updateChecker, 60000 * 30); - return; - } - - if (!updateManager.IsInstalledApp) - return; - - var info = await updateManager.CheckForUpdate(); - if (info.ReleasesToApply.Count > 0) - { - ProgressNotification n = new UpdateProgressNotification + var info = await updateManager.CheckForUpdate(); + if (info.ReleasesToApply.Count > 0) { - Text = @"Downloading update..." - }; - Schedule(() => notification.Post(n)); - Schedule(() => n.State = ProgressNotificationState.Active); - await updateManager.DownloadReleases(info.ReleasesToApply, (int p) => Schedule(() => n.Progress = p / 100f)); - Schedule(() => n.Text = @"Installing update..."); - await updateManager.ApplyReleases(info, (int p) => Schedule(() => n.Progress = p / 100f)); - Schedule(() => n.State = ProgressNotificationState.Completed); + ProgressNotification n = new UpdateProgressNotification + { + Text = @"Downloading update..." + }; + Schedule(() => + { + notification.Post(n); + n.State = ProgressNotificationState.Active; + }); + await updateManager.DownloadReleases(info.ReleasesToApply, p => Schedule(() => n.Progress = p / 100f)); + Schedule(() => + { + n.Progress = 0; + n.Text = @"Installing update..."; + }); + await updateManager.ApplyReleases(info, p => Schedule(() => n.Progress = p / 100f)); + Schedule(() => n.State = ProgressNotificationState.Completed); + } + else + { + //check again every 30 minutes. + Scheduler.AddDelayed(updateChecker, 60000 * 30); + } } - else + catch (HttpRequestException) { //check again every 30 minutes. Scheduler.AddDelayed(updateChecker, 60000 * 30); From cbd061d5731c089e7b3042697607c25349d16328 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 Feb 2017 13:52:30 +0900 Subject: [PATCH 74/83] Improve appearance of notifications. --- osu.Desktop/Overlays/VersionManager.cs | 20 +++++++++++++++++++ .../Overlays/Notifications/Notification.cs | 1 - .../ProgressCompletionNotification.cs | 10 ++++++++++ .../Notifications/SimpleNotification.cs | 8 +++++--- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 388020dd27..c06b4cce10 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; @@ -174,6 +175,25 @@ namespace osu.Desktop.Overlays return true; } }; + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + IconContent.Add(new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + ColourInfo = ColourInfo.GradientVertical(colours.YellowDark, colours.Yellow) + }, + new TextAwesome + { + Anchor = Anchor.Centre, + Icon = FontAwesome.fa_upload, + Colour = Color4.White, + } + }); + } } } } diff --git a/osu.Game/Overlays/Notifications/Notification.cs b/osu.Game/Overlays/Notifications/Notification.cs index 6faa79433e..6ad0fde419 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -89,7 +89,6 @@ namespace osu.Game.Overlays.Notifications IconContent = new Container { Size = new Vector2(40), - Colour = Color4.DarkGray, Masking = true, CornerRadius = 5, }, diff --git a/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs b/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs index a5ec9a3545..61525ed019 100644 --- a/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressCompletionNotification.cs @@ -1,7 +1,11 @@ // 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.Game.Graphics; +using osu.Framework.Graphics.Colour; +using OpenTK.Graphics; + namespace osu.Game.Overlays.Notifications { @@ -14,5 +18,11 @@ namespace osu.Game.Overlays.Notifications this.progressNotification = progressNotification; Icon = FontAwesome.fa_check; } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + IconBackgound.ColourInfo = ColourInfo.GradientVertical(colours.GreenDark, colours.GreenLight); + } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Notifications/SimpleNotification.cs b/osu.Game/Overlays/Notifications/SimpleNotification.cs index 24f347eee3..c9c56e8d4a 100644 --- a/osu.Game/Overlays/Notifications/SimpleNotification.cs +++ b/osu.Game/Overlays/Notifications/SimpleNotification.cs @@ -37,19 +37,21 @@ namespace osu.Game.Overlays.Notifications private SpriteText textDrawable; private TextAwesome iconDrawable; + protected Box IconBackgound; + public SimpleNotification() { IconContent.Add(new Drawable[] { - new Box + IconBackgound = new Box { RelativeSizeAxes = Axes.Both, - ColourInfo = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.5f)) + ColourInfo = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.6f)) }, iconDrawable = new TextAwesome { Anchor = Anchor.Centre, - Icon = icon , + Icon = icon, } }); From 461a22bccb43263cfbf5674fe635f768735fdf86 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 Feb 2017 13:52:52 +0900 Subject: [PATCH 75/83] Add resiliency to update process when delta patching fails. --- osu.Desktop/Overlays/VersionManager.cs | 57 +++++++++++++++++--------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index c06b4cce10..a853c375ca 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.ComponentModel; using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -23,7 +24,7 @@ namespace osu.Desktop.Overlays public class VersionManager : OverlayContainer { private UpdateManager updateManager; - private NotificationManager notification; + private NotificationManager notificationManager; AssemblyName assembly = Assembly.GetEntryAssembly().GetName(); @@ -36,7 +37,7 @@ namespace osu.Desktop.Overlays [BackgroundDependencyLoader] private void load(NotificationManager notification, OsuColour colours, TextureStore textures) { - this.notification = notification; + this.notificationManager = notification; AutoSizeAxes = Axes.Both; Anchor = Anchor.BottomCentre; @@ -115,43 +116,59 @@ namespace osu.Desktop.Overlays updateManager?.Dispose(); } - private async void updateChecker() + private async void updateChecker(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { try { - updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); - var info = await updateManager.CheckForUpdate(); + if (updateManager == null) updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); + + var info = await updateManager.CheckForUpdate(!useDeltaPatching); if (info.ReleasesToApply.Count > 0) { - ProgressNotification n = new UpdateProgressNotification + if (notification == null) { - Text = @"Downloading update..." - }; + notification = new UpdateProgressNotification { State = ProgressNotificationState.Active }; + Schedule(() => notificationManager.Post(notification)); + } + Schedule(() => { - notification.Post(n); - n.State = ProgressNotificationState.Active; - }); - await updateManager.DownloadReleases(info.ReleasesToApply, p => Schedule(() => n.Progress = p / 100f)); - Schedule(() => - { - n.Progress = 0; - n.Text = @"Installing update..."; + notification.Progress = 0; + notification.Text = @"Downloading update..."; }); - await updateManager.ApplyReleases(info, p => Schedule(() => n.Progress = p / 100f)); - Schedule(() => n.State = ProgressNotificationState.Completed); + await updateManager.DownloadReleases(info.ReleasesToApply, p => Schedule(() => notification.Progress = p / 100f)); + + Schedule(() => + { + notification.Progress = 0; + notification.Text = @"Installing update..."; + }); + + try + { + await updateManager.ApplyReleases(info, p => Schedule(() => notification.Progress = p / 100f)); + } + catch (Win32Exception) + { + //could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959) + //try again without deltas. + updateChecker(false, notification); + return; + } + + Schedule(() => notification.State = ProgressNotificationState.Completed); } else { //check again every 30 minutes. - Scheduler.AddDelayed(updateChecker, 60000 * 30); + Scheduler.AddDelayed(() => updateChecker(), 60000 * 30); } } catch (HttpRequestException) { //check again every 30 minutes. - Scheduler.AddDelayed(updateChecker, 60000 * 30); + Scheduler.AddDelayed(() => updateChecker(), 60000 * 30); } } From b744f3a3a79ab4543b9b8e2128e03bdf8d76fc94 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 Feb 2017 14:15:46 +0900 Subject: [PATCH 76/83] Re-nest code and handle even more potential exceptions. --- osu.Desktop/Overlays/VersionManager.cs | 66 ++++++++++++++++---------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index a853c375ca..a2dc0cb5c3 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -1,6 +1,7 @@ // 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.Diagnostics; using osu.Framework.Allocation; @@ -18,6 +19,7 @@ using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; using System.Net.Http; +using osu.Framework.Logging; namespace osu.Desktop.Overlays { @@ -118,25 +120,32 @@ namespace osu.Desktop.Overlays private async void updateChecker(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { + //should we schedule a retry on completion of this check? + bool scheduleRetry = true; + try { if (updateManager == null) updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); var info = await updateManager.CheckForUpdate(!useDeltaPatching); - if (info.ReleasesToApply.Count > 0) + if (info.ReleasesToApply.Count == 0) + //no updates available. bail and retry later. + return; + + if (notification == null) { - if (notification == null) - { - notification = new UpdateProgressNotification { State = ProgressNotificationState.Active }; - Schedule(() => notificationManager.Post(notification)); - } + notification = new UpdateProgressNotification { State = ProgressNotificationState.Active }; + Schedule(() => notificationManager.Post(notification)); + } - Schedule(() => - { - notification.Progress = 0; - notification.Text = @"Downloading update..."; - }); + Schedule(() => + { + notification.Progress = 0; + notification.Text = @"Downloading update..."; + }); + try + { await updateManager.DownloadReleases(info.ReleasesToApply, p => Schedule(() => notification.Progress = p / 100f)); Schedule(() => @@ -145,30 +154,35 @@ namespace osu.Desktop.Overlays notification.Text = @"Installing update..."; }); - try - { - await updateManager.ApplyReleases(info, p => Schedule(() => notification.Progress = p / 100f)); - } - catch (Win32Exception) + await updateManager.ApplyReleases(info, p => Schedule(() => notification.Progress = p / 100f)); + + Schedule(() => notification.State = ProgressNotificationState.Completed); + } + catch (Exception) + { + if (useDeltaPatching) { //could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959) //try again without deltas. updateChecker(false, notification); - return; + scheduleRetry = false; } - - Schedule(() => notification.State = ProgressNotificationState.Completed); - } - else - { - //check again every 30 minutes. - Scheduler.AddDelayed(() => updateChecker(), 60000 * 30); } } catch (HttpRequestException) { - //check again every 30 minutes. - Scheduler.AddDelayed(() => updateChecker(), 60000 * 30); + //likely have no internet connection. + //we'll ignore this and retry later. + } + finally + { + if (scheduleRetry) + { + //check again in 30 minutes. + Scheduler.AddDelayed(() => updateChecker(), 60000 * 30); + if (notification != null) + notification.State = ProgressNotificationState.Cancelled; + } } } From 5f29b0dc4f92dd3a5b8a757c2dce99e83dbaec26 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 Feb 2017 15:46:04 +0900 Subject: [PATCH 77/83] Update in line with framework changes. --- osu-framework | 2 +- osu.Game/Online/Chat/Drawables/DrawableChannel.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu-framework b/osu-framework index 1654acef1c..de1568254c 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 1654acef1ca9b9f203bfef1b507f3515b41a4d84 +Subproject commit de1568254c4c9a4ea540ccad94700c5c51f70dc2 diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index ef1e7ca5df..5b8d034e9d 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -75,7 +75,7 @@ namespace osu.Game.Online.Chat.Drawables var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY)); - if (scroll.IsScrolledToEnd || !flow.Children.Any()) + if (scroll.IsScrolledToEnd(10) || !flow.Children.Any()) scrollToEnd(); //up to last Channel.MAX_HISTORY messages @@ -88,7 +88,7 @@ namespace osu.Game.Online.Chat.Drawables while (flow.Children.Count(c => c.LifetimeEnd == double.MaxValue) > Channel.MAX_HISTORY) { var d = flow.Children.First(c => c.LifetimeEnd == double.MaxValue); - if (!scroll.IsScrolledToEnd) + if (!scroll.IsScrolledToEnd(10)) scroll.OffsetScrollPosition(-d.DrawHeight); d.Expire(); } From b7a9fd85eae6fdd36f071ff11df1b7385a5797b4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 Feb 2017 13:38:10 +0900 Subject: [PATCH 78/83] Assert single channel support for now. --- osu.Game/Overlays/ChatOverlay.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 6bfd9730f0..71fe754f77 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -208,6 +208,8 @@ namespace osu.Game.Overlays ListChannelsRequest req = new ListChannelsRequest(); req.Success += delegate (List channels) { + Debug.Assert(careChannels.Count == 0); + Scheduler.Add(delegate { loading.FadeOut(100); From 190bed893972180fa28777d986814901d4ff7036 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 Feb 2017 13:38:22 +0900 Subject: [PATCH 79/83] Add top padding. --- osu.Game/Overlays/ChatOverlay.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 71fe754f77..e0e43fbe64 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -28,6 +28,8 @@ namespace osu.Game.Overlays { public class ChatOverlay : FocusedOverlayContainer, IOnlineComponent { + const float textbox_height = 40; + private DrawableChannel channelDisplay; private ScheduledDelegate messageRequest; @@ -59,14 +61,14 @@ namespace osu.Game.Overlays content = new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Bottom = 50 }, + Padding = new MarginPadding { Top = 5, Bottom = textbox_height + 5 }, }, new Container { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, - Height = 40, + Height = textbox_height, Padding = new MarginPadding(5), Children = new Drawable[] { From 00ddcb11b4a26fd9e8cb6f59a8d3642002d5b8e0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 Feb 2017 13:51:40 +0900 Subject: [PATCH 80/83] Fix sliders playing hitsound twice at end. --- osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs index 745c696fee..907ce8da63 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs @@ -107,7 +107,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables if (repeat > currentRepeat) { - if (ball.Tracking) + if (repeat < slider.RepeatCount && ball.Tracking) PlaySample(); currentRepeat = repeat; } From d00ea4564f321a84e1a7116a6e0a2af4776b964d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 Feb 2017 14:09:48 +0900 Subject: [PATCH 81/83] Fix API coming online too early in race scenarios. --- osu.Game/Online/API/APIAccess.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 71671d09fb..a9e0b2163b 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -196,7 +196,10 @@ namespace osu.Game.Online.API Logger.Log($@"Performing request {req}", LoggingTarget.Network); req.Perform(this); - State = APIState.Online; + //we could still be in initialisation, at which point we don't want to say we're Online yet. + if (LocalUser.Value != null) + State = APIState.Online; + failureCount = 0; return true; } From 2d2660c1c5ea0275d256dafa51fcf3a820906398 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 22 Feb 2017 14:14:37 +0900 Subject: [PATCH 82/83] Improve transition when retrying a beatmap. --- osu.Game/Screens/Play/Player.cs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 23341ec0d4..3d21e9cd40 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -240,21 +240,6 @@ namespace osu.Game.Screens.Play }); } - protected override void LoadComplete() - { - base.LoadComplete(); - - Content.Delay(250); - Content.FadeIn(250); - - Delay(750); - Schedule(() => - { - sourceClock.Start(); - initializeSkipButton(); - }); - } - private void onPass() { Delay(1000); @@ -290,6 +275,22 @@ namespace osu.Game.Screens.Play Content.Alpha = 0; dimLevel.ValueChanged += dimChanged; + + Content.Delay(250); + Content.FadeIn(250); + + Delay(750); + Schedule(() => + { + sourceClock.Start(); + initializeSkipButton(); + }); + } + + protected override void OnSuspending(Screen next) + { + Content.FadeOut(350); + base.OnSuspending(next); } protected override bool OnExiting(Screen next) From 74ea5e73432c7f45fe9e71d7e373fb52c9790172 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Feb 2017 00:41:04 +0900 Subject: [PATCH 83/83] Fix updates downloading in non-deploy builds. --- osu.Desktop/Overlays/VersionManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index a2dc0cb5c3..c3f31414de 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -103,7 +103,8 @@ namespace osu.Desktop.Overlays } }; - updateChecker(); + if (IsDeployedBuild) + updateChecker(); } protected override void LoadComplete()