From 0ec7c11a90f6ec343752ea786a5adf4078c06f7c Mon Sep 17 00:00:00 2001
From: unknown
Date: Fri, 10 May 2019 19:44:22 +0200
Subject: [PATCH 001/901] implement CatchModRelax
---
osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs | 44 +++++++++++++++++--
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
index 0454bc969d..47e32b1292 100644
--- a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
+++ b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
@@ -1,12 +1,48 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Input;
+using osu.Framework.Input.Bindings;
+using osu.Framework.Input.Events;
+using osu.Game.Rulesets.Catch.Objects;
+using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Mods;
+using osu.Game.Rulesets.UI;
+using osuTK;
+using System;
-namespace osu.Game.Rulesets.Catch.Mods
-{
- public class CatchModRelax : ModRelax
- {
+namespace osu.Game.Rulesets.Catch.Mods {
+ public class CatchModRelax : ModRelax, IApplicableToDrawableRuleset {
public override string Description => @"Use the mouse to control the catcher.";
+
+ public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) =>
+ (drawableRuleset.Playfield.Parent as Container).Add(new CatchModRelaxHelper(drawableRuleset.Playfield as CatchPlayfield));
+
+ private class CatchModRelaxHelper : Drawable, IKeyBindingHandler, IRequireHighFrequencyMousePosition {
+ private CatcherArea.Catcher catcher;
+
+ public CatchModRelaxHelper(CatchPlayfield catchPlayfield) {
+ catcher = catchPlayfield.CatcherArea.MovableCatcher;
+ RelativeSizeAxes = Axes.Both;
+ }
+
+ //disable keyboard controls
+ public bool OnPressed(CatchAction action) => true;
+ public bool OnReleased(CatchAction action) => true;
+
+ protected override bool OnMouseMove(MouseMoveEvent e) {
+ //lock catcher to mouse position horizontally
+ catcher.X = e.MousePosition.X / DrawSize.X;
+
+ //make Yuzu face the direction he's moving
+ var direction = Math.Sign(e.Delta.X);
+ if (direction != 0)
+ catcher.Scale = new Vector2(Math.Abs(catcher.Scale.X) * direction, catcher.Scale.Y);
+
+ return base.OnMouseMove(e);
+ }
+ }
}
}
From 6739238a0dd3620805943806f99637210f9138ca Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 11 May 2019 10:03:59 +0200
Subject: [PATCH 002/901] formatting
---
osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
index 47e32b1292..5fa22f8bdb 100644
--- a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
+++ b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
@@ -13,17 +13,21 @@ using osu.Game.Rulesets.UI;
using osuTK;
using System;
-namespace osu.Game.Rulesets.Catch.Mods {
- public class CatchModRelax : ModRelax, IApplicableToDrawableRuleset {
+namespace osu.Game.Rulesets.Catch.Mods
+{
+ public class CatchModRelax : ModRelax, IApplicableToDrawableRuleset
+ {
public override string Description => @"Use the mouse to control the catcher.";
public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) =>
(drawableRuleset.Playfield.Parent as Container).Add(new CatchModRelaxHelper(drawableRuleset.Playfield as CatchPlayfield));
- private class CatchModRelaxHelper : Drawable, IKeyBindingHandler, IRequireHighFrequencyMousePosition {
+ private class CatchModRelaxHelper : Drawable, IKeyBindingHandler, IRequireHighFrequencyMousePosition
+ {
private CatcherArea.Catcher catcher;
- public CatchModRelaxHelper(CatchPlayfield catchPlayfield) {
+ public CatchModRelaxHelper(CatchPlayfield catchPlayfield)
+ {
catcher = catchPlayfield.CatcherArea.MovableCatcher;
RelativeSizeAxes = Axes.Both;
}
@@ -32,7 +36,8 @@ namespace osu.Game.Rulesets.Catch.Mods {
public bool OnPressed(CatchAction action) => true;
public bool OnReleased(CatchAction action) => true;
- protected override bool OnMouseMove(MouseMoveEvent e) {
+ protected override bool OnMouseMove(MouseMoveEvent e)
+ {
//lock catcher to mouse position horizontally
catcher.X = e.MousePosition.X / DrawSize.X;
From cf192c84a8d528f23c949aa70210e1c300fa53e2 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 11 May 2019 10:26:24 +0200
Subject: [PATCH 003/901] make catcher field readonly
---
osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
index 5fa22f8bdb..9852e753c5 100644
--- a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
+++ b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
@@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Catch.Mods
private class CatchModRelaxHelper : Drawable, IKeyBindingHandler, IRequireHighFrequencyMousePosition
{
- private CatcherArea.Catcher catcher;
+ private readonly CatcherArea.Catcher catcher;
public CatchModRelaxHelper(CatchPlayfield catchPlayfield)
{
From b87478f6e2c3f245c34a5c11e714a74d4c90e9e9 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 11 May 2019 11:25:29 +0200
Subject: [PATCH 004/901] replace 'as' with direct cast to avoid possible
nullref
---
osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
index 9852e753c5..062c0f8b26 100644
--- a/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
+++ b/osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
@@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Catch.Mods
public override string Description => @"Use the mouse to control the catcher.";
public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) =>
- (drawableRuleset.Playfield.Parent as Container).Add(new CatchModRelaxHelper(drawableRuleset.Playfield as CatchPlayfield));
+ ((Container)drawableRuleset.Playfield.Parent).Add(new CatchModRelaxHelper(drawableRuleset.Playfield as CatchPlayfield));
private class CatchModRelaxHelper : Drawable, IKeyBindingHandler, IRequireHighFrequencyMousePosition
{
From b3a95cac84e2f30bcc4acfb5eb8e4b030f9ad7d3 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sun, 12 May 2019 20:20:11 +0200
Subject: [PATCH 005/901] add invisible cursor for ctb
---
osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs | 14 ++++++++++++++
osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs | 3 +++
2 files changed, 17 insertions(+)
create mode 100644 osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
diff --git a/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs b/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
new file mode 100644
index 0000000000..073f2e05b2
--- /dev/null
+++ b/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
@@ -0,0 +1,14 @@
+using osu.Framework.Graphics;
+using osu.Game.Rulesets.UI;
+
+namespace osu.Game.Rulesets.Catch.UI {
+ class CatchCursorContainer : GameplayCursorContainer
+ {
+ protected override Drawable CreateCursor() => new InvisibleCursor();
+
+ private class InvisibleCursor : Drawable
+ {
+
+ }
+ }
+}
diff --git a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs
index b6d8cf9cbe..7741096da2 100644
--- a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs
@@ -9,6 +9,7 @@ using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawable;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
+using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.Catch.UI
@@ -19,6 +20,8 @@ namespace osu.Game.Rulesets.Catch.UI
internal readonly CatcherArea CatcherArea;
+ protected override GameplayCursorContainer CreateCursor() => new CatchCursorContainer();
+
public CatchPlayfield(BeatmapDifficulty difficulty, Func> createDrawableRepresentation)
{
Container explodingFruitContainer;
From 9079d7a7d83962ae058e33ad75f4ba19bab02f53 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sun, 12 May 2019 21:01:51 +0200
Subject: [PATCH 006/901] add license header
---
osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs b/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
index 073f2e05b2..072c5d4fdf 100644
--- a/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
@@ -1,4 +1,7 @@
-using osu.Framework.Graphics;
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Catch.UI {
From cadf0eb228d41b1ed941aef9d6ec11963a625639 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sun, 12 May 2019 21:14:27 +0200
Subject: [PATCH 007/901] formatting
---
osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs b/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
index 072c5d4fdf..642e0bb9de 100644
--- a/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
@@ -4,7 +4,8 @@
using osu.Framework.Graphics;
using osu.Game.Rulesets.UI;
-namespace osu.Game.Rulesets.Catch.UI {
+namespace osu.Game.Rulesets.Catch.UI
+{
class CatchCursorContainer : GameplayCursorContainer
{
protected override Drawable CreateCursor() => new InvisibleCursor();
From 3aa95f216284ddcc3f39c31dac000aba559903d8 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sun, 12 May 2019 21:17:06 +0200
Subject: [PATCH 008/901] add missing access modifier
---
osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs b/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
index 642e0bb9de..d4ac4b2f2e 100644
--- a/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
@@ -6,7 +6,7 @@ using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Catch.UI
{
- class CatchCursorContainer : GameplayCursorContainer
+ public class CatchCursorContainer : GameplayCursorContainer
{
protected override Drawable CreateCursor() => new InvisibleCursor();
From 69f9d003829c98fd858f9dc0ac458dc64e7c3697 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sun, 12 May 2019 21:23:59 +0200
Subject: [PATCH 009/901] more formatting
---
osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs b/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
index d4ac4b2f2e..03bfad7e8c 100644
--- a/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
+++ b/osu.Game.Rulesets.Catch/UI/CatchCursorContainer.cs
@@ -10,9 +10,6 @@ namespace osu.Game.Rulesets.Catch.UI
{
protected override Drawable CreateCursor() => new InvisibleCursor();
- private class InvisibleCursor : Drawable
- {
-
- }
+ private class InvisibleCursor : Drawable { }
}
}
From 651706b10e4ba85bea3faba3ccf70c2736cbf5aa Mon Sep 17 00:00:00 2001
From: Dean Herbert
Date: Tue, 26 Mar 2019 16:17:20 +0900
Subject: [PATCH 010/901] Account for user/system offsets when deciding on an
initial seek time
Closes #3043
Remove "AllowLeadIn" flag
---
osu.Game/Screens/Play/GameplayClockContainer.cs | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs
index c151e598f7..f6a23575e9 100644
--- a/osu.Game/Screens/Play/GameplayClockContainer.cs
+++ b/osu.Game/Screens/Play/GameplayClockContainer.cs
@@ -26,6 +26,10 @@ namespace osu.Game.Screens.Play
private readonly WorkingBeatmap beatmap;
private readonly IReadOnlyList mods;
+ private readonly bool allowLeadIn;
+
+ private readonly double gameplayStartTime;
+
///
/// The original source (usually a 's track).
///
@@ -60,6 +64,8 @@ namespace osu.Game.Screens.Play
private readonly FramedOffsetClock platformOffsetClock;
+ private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset;
+
public GameplayClockContainer(WorkingBeatmap beatmap, IReadOnlyList mods, double gameplayStartTime)
{
this.beatmap = beatmap;
@@ -93,6 +99,9 @@ namespace osu.Game.Screens.Play
userAudioOffset = config.GetBindable(OsuSetting.AudioOffset);
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
+ adjustableClock.Seek(Math.Min(0, gameplayStartTime - totalOffset - (allowLeadIn ? beatmap.BeatmapInfo.AudioLeadIn : 0)));
+ adjustableClock.ProcessFrame();
+
UserPlaybackRate.ValueChanged += _ => updateRate();
Seek(Math.Min(-beatmap.BeatmapInfo.AudioLeadIn, gameplayStartTime));
From d1d1c4ee7a5df46e20330b28b293dc700c9da7e4 Mon Sep 17 00:00:00 2001
From: Dean Herbert
Date: Tue, 26 Mar 2019 16:13:58 +0900
Subject: [PATCH 011/901] Add lead-in tests
---
.../Visual/Gameplay/TestCaseLeadIn.cs | 88 +++++++++++++++++++
1 file changed, 88 insertions(+)
create mode 100644 osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs
diff --git a/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs b/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs
new file mode 100644
index 0000000000..0186ba1da1
--- /dev/null
+++ b/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs
@@ -0,0 +1,88 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System.Linq;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Beatmaps;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Rulesets;
+using osu.Game.Screens.Play;
+using osu.Game.Tests.Beatmaps;
+using osuTK.Graphics;
+
+namespace osu.Game.Tests.Visual.Gameplay
+{
+ public class TestCaseLeadIn : RateAdjustedBeatmapTestCase
+ {
+ private Ruleset ruleset;
+
+ private LeadInPlayer player;
+
+ [BackgroundDependencyLoader]
+ private void load(RulesetStore rulesets)
+ {
+ Add(new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4.Black,
+ Depth = int.MaxValue
+ });
+
+ ruleset = rulesets.AvailableRulesets.First().CreateInstance();
+ }
+
+ [Test]
+ public void TestShortLeadIn()
+ {
+ AddStep("create player", () => loadPlayerWithBeatmap(new TestBeatmap(ruleset.RulesetInfo) { BeatmapInfo = { AudioLeadIn = 1000 } }));
+ AddUntilStep("correct lead-in", () => player.FirstFrameClockTime == 0);
+ }
+
+ [Test]
+ public void TestLongLeadIn()
+ {
+ AddStep("create player", () => loadPlayerWithBeatmap(new TestBeatmap(ruleset.RulesetInfo) { BeatmapInfo = { AudioLeadIn = 10000 } }));
+ AddUntilStep("correct lead-in", () => player.FirstFrameClockTime == player.GameplayStartTime - 10000);
+ }
+
+ private void loadPlayerWithBeatmap(IBeatmap beatmap)
+ {
+ Beatmap.Value = new TestWorkingBeatmap(beatmap, Clock);
+
+ LoadScreen(player = new LeadInPlayer
+ {
+ AllowPause = false,
+ AllowResults = false,
+ });
+ }
+
+ private class LeadInPlayer : Player
+ {
+ public double? FirstFrameClockTime;
+
+ public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
+
+ public double GameplayStartTime => DrawableRuleset.GameplayStartTime;
+
+ public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
+
+ protected override void UpdateAfterChildren()
+ {
+ base.UpdateAfterChildren();
+ if (!FirstFrameClockTime.HasValue)
+ {
+ FirstFrameClockTime = GameplayClockContainer.GameplayClock.CurrentTime;
+ AddInternal(new OsuSpriteText
+ {
+ Text = $"GameplayStartTime: {DrawableRuleset.GameplayStartTime} "
+ + $"LeadInTime: {Beatmap.Value.BeatmapInfo.AudioLeadIn} "
+ + $"FirstFrameClockTime: {FirstFrameClockTime}"
+ });
+ }
+ }
+ }
+ }
+}
From e03a664970e39158396b478dfef1f6aa7e0574b3 Mon Sep 17 00:00:00 2001
From: Dean Herbert
Date: Tue, 26 Mar 2019 16:18:15 +0900
Subject: [PATCH 012/901] Fix lead-in logic to match stable
Also adds storyboard event priority support.
---
osu.Game/Screens/Play/GameplayClock.cs | 1 -
osu.Game/Screens/Play/GameplayClockContainer.cs | 8 +++++++-
osu.Game/Storyboards/Storyboard.cs | 2 ++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/osu.Game/Screens/Play/GameplayClock.cs b/osu.Game/Screens/Play/GameplayClock.cs
index b1948d02d5..6c9dacfc39 100644
--- a/osu.Game/Screens/Play/GameplayClock.cs
+++ b/osu.Game/Screens/Play/GameplayClock.cs
@@ -34,7 +34,6 @@ namespace osu.Game.Screens.Play
public void ProcessFrame()
{
// we do not want to process the underlying clock.
- // this is handled by PauseContainer.
}
public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime;
diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs
index f6a23575e9..7abdc8ef66 100644
--- a/osu.Game/Screens/Play/GameplayClockContainer.cs
+++ b/osu.Game/Screens/Play/GameplayClockContainer.cs
@@ -99,7 +99,13 @@ namespace osu.Game.Screens.Play
userAudioOffset = config.GetBindable(OsuSetting.AudioOffset);
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
- adjustableClock.Seek(Math.Min(0, gameplayStartTime - totalOffset - (allowLeadIn ? beatmap.BeatmapInfo.AudioLeadIn : 0)));
+ double startTime = -beatmap.BeatmapInfo.AudioLeadIn;
+
+ startTime = Math.Min(startTime, beatmap.Storyboard.FirstEventTime);
+ startTime = Math.Min(startTime, gameplayStartTime);
+ startTime = Math.Min(startTime, 0);
+
+ Seek(startTime);
adjustableClock.ProcessFrame();
UserPlaybackRate.ValueChanged += _ => updateRate();
diff --git a/osu.Game/Storyboards/Storyboard.cs b/osu.Game/Storyboards/Storyboard.cs
index 3d988c5fe3..401a7ce25a 100644
--- a/osu.Game/Storyboards/Storyboard.cs
+++ b/osu.Game/Storyboards/Storyboard.cs
@@ -17,6 +17,8 @@ namespace osu.Game.Storyboards
public bool HasDrawable => Layers.Any(l => l.Elements.Any(e => e.IsDrawable));
+ public double FirstEventTime => Layers.Min(l => l.Elements.FirstOrDefault()?.StartTime ?? 0);
+
public Storyboard()
{
layers.Add("Background", new StoryboardLayer("Background", 3));
From a2fbcb2bd39e756503d6e98a9cf25fb57dba021e Mon Sep 17 00:00:00 2001
From: Dean Herbert
Date: Fri, 31 May 2019 15:58:46 +0900
Subject: [PATCH 013/901] Fix rebase regressions
---
osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs | 14 ++++++++------
osu.Game/Screens/Play/GameplayClockContainer.cs | 6 ------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs b/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs
index 0186ba1da1..33f1e4062f 100644
--- a/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs
+++ b/osu.Game.Tests/Visual/Gameplay/TestCaseLeadIn.cs
@@ -15,7 +15,7 @@ using osuTK.Graphics;
namespace osu.Game.Tests.Visual.Gameplay
{
- public class TestCaseLeadIn : RateAdjustedBeatmapTestCase
+ public class TestCaseLeadIn : RateAdjustedBeatmapTestScene
{
private Ruleset ruleset;
@@ -52,15 +52,16 @@ namespace osu.Game.Tests.Visual.Gameplay
{
Beatmap.Value = new TestWorkingBeatmap(beatmap, Clock);
- LoadScreen(player = new LeadInPlayer
- {
- AllowPause = false,
- AllowResults = false,
- });
+ LoadScreen(player = new LeadInPlayer());
}
private class LeadInPlayer : Player
{
+ public LeadInPlayer()
+ : base(false, false)
+ {
+ }
+
public double? FirstFrameClockTime;
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
@@ -72,6 +73,7 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
+
if (!FirstFrameClockTime.HasValue)
{
FirstFrameClockTime = GameplayClockContainer.GameplayClock.CurrentTime;
diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs
index 7abdc8ef66..d718424b29 100644
--- a/osu.Game/Screens/Play/GameplayClockContainer.cs
+++ b/osu.Game/Screens/Play/GameplayClockContainer.cs
@@ -26,10 +26,6 @@ namespace osu.Game.Screens.Play
private readonly WorkingBeatmap beatmap;
private readonly IReadOnlyList mods;
- private readonly bool allowLeadIn;
-
- private readonly double gameplayStartTime;
-
///
/// The original source (usually a 's track).
///
@@ -91,8 +87,6 @@ namespace osu.Game.Screens.Play
GameplayClock.IsPaused.BindTo(IsPaused);
}
- private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset;
-
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
From 1b5a9aecffdef0b307c3712d0d85992928b0d894 Mon Sep 17 00:00:00 2001
From: DTSDAO
Date: Fri, 2 Aug 2019 23:34:25 +0800
Subject: [PATCH 014/901] Add iOS URL Scheme support
---
.../Graphics/Containers/LinkFlowContainer.cs | 47 +---------------
osu.Game/Online/Chat/MessageFormatter.cs | 54 ++++++++++++++++++-
osu.Game/OsuGame.cs | 22 ++++++++
osu.iOS/AppDelegate.cs | 7 ++-
osu.iOS/Info.plist | 14 +++++
5 files changed, 93 insertions(+), 51 deletions(-)
diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
index 15068d81c0..51a842fc84 100644
--- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs
+++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
@@ -86,52 +86,7 @@ namespace osu.Game.Graphics.Containers
{
RelativeSizeAxes = Axes.Both,
TooltipText = tooltipText ?? (url != text ? url : string.Empty),
- Action = action ?? (() =>
- {
- switch (linkType)
- {
- case LinkAction.OpenBeatmap:
- // TODO: proper query params handling
- if (linkArgument != null && int.TryParse(linkArgument.Contains('?') ? linkArgument.Split('?')[0] : linkArgument, out int beatmapId))
- game?.ShowBeatmap(beatmapId);
- break;
-
- case LinkAction.OpenBeatmapSet:
- if (int.TryParse(linkArgument, out int setId))
- game?.ShowBeatmapSet(setId);
- break;
-
- case LinkAction.OpenChannel:
- try
- {
- channelManager?.OpenChannel(linkArgument);
- }
- catch (ChannelNotFoundException)
- {
- Logger.Log($"The requested channel \"{linkArgument}\" does not exist");
- }
-
- break;
-
- case LinkAction.OpenEditorTimestamp:
- case LinkAction.JoinMultiplayerMatch:
- case LinkAction.Spectate:
- showNotImplementedError?.Invoke();
- break;
-
- case LinkAction.External:
- game?.OpenUrlExternally(url);
- break;
-
- case LinkAction.OpenUserProfile:
- if (long.TryParse(linkArgument, out long userId))
- game?.ShowUser(userId);
- break;
-
- default:
- throw new NotImplementedException($"This {nameof(LinkAction)} ({linkType.ToString()}) is missing an associated action.");
- }
- }),
+ Action = action ?? (() => LinkUtils.HandleLink(url, linkType, linkArgument, game, channelManager, showNotImplementedError)),
});
return drawables;
diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs
index 4aaffdd161..ee8f45803b 100644
--- a/osu.Game/Online/Chat/MessageFormatter.cs
+++ b/osu.Game/Online/Chat/MessageFormatter.cs
@@ -3,7 +3,9 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Text.RegularExpressions;
+using osu.Framework.Logging;
namespace osu.Game.Online.Chat
{
@@ -98,7 +100,7 @@ namespace osu.Game.Online.Chat
}
}
- private static LinkDetails getLinkDetails(string url)
+ public static LinkDetails getLinkDetails(string url)
{
var args = url.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
args[0] = args[0].TrimEnd(':');
@@ -288,4 +290,54 @@ namespace osu.Game.Online.Chat
public int CompareTo(Link otherLink) => Index > otherLink.Index ? 1 : -1;
}
+
+ public static class LinkUtils
+ {
+ public static void HandleLink(string url, LinkAction linkType, string linkArgument, OsuGame game, ChannelManager channelManager = null, Action showNotImplementedError = null)
+ {
+ switch (linkType)
+ {
+ case LinkAction.OpenBeatmap:
+ // TODO: proper query params handling
+ if (linkArgument != null && int.TryParse(linkArgument.Contains('?') ? linkArgument.Split('?')[0] : linkArgument, out int beatmapId))
+ game?.ShowBeatmap(beatmapId);
+ break;
+
+ case LinkAction.OpenBeatmapSet:
+ if (int.TryParse(linkArgument, out int setId))
+ game?.ShowBeatmapSet(setId);
+ break;
+
+ case LinkAction.OpenChannel:
+ try
+ {
+ channelManager?.OpenChannel(linkArgument);
+ }
+ catch (ChannelNotFoundException)
+ {
+ Logger.Log($"The requested channel \"{linkArgument}\" does not exist");
+ }
+
+ break;
+
+ case LinkAction.OpenEditorTimestamp:
+ case LinkAction.JoinMultiplayerMatch:
+ case LinkAction.Spectate:
+ showNotImplementedError?.Invoke();
+ break;
+
+ case LinkAction.External:
+ game?.OpenUrlExternally(url);
+ break;
+
+ case LinkAction.OpenUserProfile:
+ if (long.TryParse(linkArgument, out long userId))
+ game?.ShowUser(userId);
+ break;
+
+ default:
+ throw new NotImplementedException($"This {nameof(LinkAction)} ({linkType.ToString()}) is missing an associated action.");
+ }
+ }
+ }
}
diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index e71dd67bf2..5dea67253d 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -43,6 +43,7 @@ using osu.Game.Scoring;
using osu.Game.Screens.Select;
using osu.Game.Utils;
using LogLevel = osu.Framework.Logging.LogLevel;
+using static osu.Game.Online.Chat.MessageFormatter;
namespace osu.Game
{
@@ -90,6 +91,8 @@ namespace osu.Game
private IntroScreen introScreen;
+ private bool loaded = false;
+
private Bindable configRuleset;
private Bindable configSkin;
@@ -190,10 +193,29 @@ namespace osu.Game
Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade);
Beatmap.BindValueChanged(beatmapChanged, true);
+
+ loaded = true;
}
private ExternalLinkOpener externalLinkOpener;
+ public void HandleUrl(string url)
+ {
+ Logger.Log($"Request to handle url: {url}");
+ if (loaded)
+ {
+ Action showNotImplementedError = () => notifications?.Post(new SimpleNotification
+ {
+ Text = @"This link type is not yet supported!",
+ Icon = FontAwesome.Solid.LifeRing,
+ });
+ LinkDetails linkDetails = getLinkDetails(url);
+ Schedule(() => LinkUtils.HandleLink(url, linkDetails.Action, linkDetails.Argument, this, channelManager, showNotImplementedError));
+ }
+ else
+ Scheduler.AddDelayed(() => HandleUrl(url), 1000);
+ }
+
public void OpenUrlExternally(string url)
{
if (url.StartsWith("/"))
diff --git a/osu.iOS/AppDelegate.cs b/osu.iOS/AppDelegate.cs
index 9ef21e014c..e727305997 100644
--- a/osu.iOS/AppDelegate.cs
+++ b/osu.iOS/AppDelegate.cs
@@ -1,10 +1,9 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using System.Threading.Tasks;
using Foundation;
using osu.Framework.iOS;
-using osu.Game;
+using osu.Framework.Threading;
using UIKit;
namespace osu.iOS
@@ -16,9 +15,9 @@ namespace osu.iOS
protected override Framework.Game CreateGame() => game = new OsuGameIOS();
- public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
+ public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
- Task.Run(() => game.Import(url.Path));
+ game.HandleUrl(url.AbsoluteString);
return true;
}
}
diff --git a/osu.iOS/Info.plist b/osu.iOS/Info.plist
index 4fbc67e27b..5fe8cd6d5b 100644
--- a/osu.iOS/Info.plist
+++ b/osu.iOS/Info.plist
@@ -107,5 +107,19 @@
+ UIFileSharingEnabled
+
+ CFBundleURLTypes
+
+
+ CFBundleURLSchemes
+
+ osu
+ osump
+
+ CFBundleTypeRole
+ Editor
+
+
From 471103fd101180e78f2d54fc34d96cb5198dcada Mon Sep 17 00:00:00 2001
From: DTSDAO
Date: Sat, 3 Aug 2019 00:00:22 +0800
Subject: [PATCH 015/901] Fix code format
---
osu.Game/Graphics/Containers/LinkFlowContainer.cs | 1 -
osu.Game/Online/Chat/MessageFormatter.cs | 2 +-
osu.Game/OsuGame.cs | 8 +++++---
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
index 51a842fc84..ab4629cfff 100644
--- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs
+++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
@@ -8,7 +8,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using System.Collections.Generic;
using osu.Framework.Graphics;
-using osu.Framework.Logging;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Users;
diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs
index ee8f45803b..347139975e 100644
--- a/osu.Game/Online/Chat/MessageFormatter.cs
+++ b/osu.Game/Online/Chat/MessageFormatter.cs
@@ -100,7 +100,7 @@ namespace osu.Game.Online.Chat
}
}
- public static LinkDetails getLinkDetails(string url)
+ public static LinkDetails GetLinkDetails(string url)
{
var args = url.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
args[0] = args[0].TrimEnd(':');
diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index 5dea67253d..fa68142fea 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -91,7 +91,7 @@ namespace osu.Game
private IntroScreen introScreen;
- private bool loaded = false;
+ private bool loaded;
private Bindable configRuleset;
@@ -193,8 +193,6 @@ namespace osu.Game
Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade);
Beatmap.BindValueChanged(beatmapChanged, true);
-
- loaded = true;
}
private ExternalLinkOpener externalLinkOpener;
@@ -202,6 +200,7 @@ namespace osu.Game
public void HandleUrl(string url)
{
Logger.Log($"Request to handle url: {url}");
+
if (loaded)
{
Action showNotImplementedError = () => notifications?.Post(new SimpleNotification
@@ -402,6 +401,8 @@ namespace osu.Game
protected override void LoadComplete()
{
+ loaded = false;
+
base.LoadComplete();
// The next time this is updated is in UpdateAfterChildren, which occurs too late and results
@@ -597,6 +598,7 @@ namespace osu.Game
settings.State.ValueChanged += _ => updateScreenOffset();
notifications.State.ValueChanged += _ => updateScreenOffset();
+ loaded = true;
}
public class GameIdleTracker : IdleTracker
From c9e14c8f063afae562789111864fc094601a9202 Mon Sep 17 00:00:00 2001
From: DTSDAO
Date: Sat, 3 Aug 2019 19:46:57 +0800
Subject: [PATCH 016/901] Fix typo
---
osu.Game/Online/Chat/MessageFormatter.cs | 4 ++--
osu.Game/OsuGame.cs | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs
index 347139975e..73396ce4d2 100644
--- a/osu.Game/Online/Chat/MessageFormatter.cs
+++ b/osu.Game/Online/Chat/MessageFormatter.cs
@@ -78,7 +78,7 @@ namespace osu.Game.Online.Chat
//since we just changed the line display text, offset any already processed links.
result.Links.ForEach(l => l.Index -= l.Index > index ? m.Length - displayText.Length : 0);
- var details = getLinkDetails(linkText);
+ var details = GetLinkDetails(linkText);
result.Links.Add(new Link(linkText, index, displayText.Length, linkActionOverride ?? details.Action, details.Argument));
//adjust the offset for processing the current matches group.
@@ -95,7 +95,7 @@ namespace osu.Game.Online.Chat
var link = m.Groups["link"].Value;
var indexLength = link.Length;
- var details = getLinkDetails(link);
+ var details = GetLinkDetails(link);
result.Links.Add(new Link(link, index, indexLength, details.Action, details.Argument));
}
}
diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index fa68142fea..c478ad0a57 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -208,7 +208,7 @@ namespace osu.Game
Text = @"This link type is not yet supported!",
Icon = FontAwesome.Solid.LifeRing,
});
- LinkDetails linkDetails = getLinkDetails(url);
+ LinkDetails linkDetails = GetLinkDetails(url);
Schedule(() => LinkUtils.HandleLink(url, linkDetails.Action, linkDetails.Argument, this, channelManager, showNotImplementedError));
}
else
From 0fe6585975a7efdf6b00a73f7be41593c7ea6e20 Mon Sep 17 00:00:00 2001
From: DTSDAO
Date: Mon, 5 Aug 2019 22:30:35 +0800
Subject: [PATCH 017/901] Fix iOS importing
---
osu.Game/Database/ArchiveModelManager.cs | 2 +-
osu.Game/OsuGame.cs | 24 ++++++++----------------
osu.iOS/AppDelegate.cs | 6 +++++-
osu.iOS/Info.plist | 2 ++
osu.iOS/OsuGameIOS.cs | 2 ++
5 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs
index efb76deff8..37ea7b2ca9 100644
--- a/osu.Game/Database/ArchiveModelManager.cs
+++ b/osu.Game/Database/ArchiveModelManager.cs
@@ -54,7 +54,7 @@ namespace osu.Game.Database
public virtual string[] HandledExtensions => new[] { ".zip" };
- public virtual bool SupportsImportFromStable => RuntimeInfo.IsDesktop;
+ public virtual bool SupportsImportFromStable => (RuntimeInfo.IsDesktop || RuntimeInfo.OS == RuntimeInfo.Platform.iOS);
protected readonly FileStore Files;
diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index b64f04de2a..846677a0a9 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -91,8 +91,6 @@ namespace osu.Game
private IntroScreen introScreen;
- private bool loaded;
-
private Bindable configRuleset;
private Bindable configSkin;
@@ -201,18 +199,15 @@ namespace osu.Game
{
Logger.Log($"Request to handle url: {url}");
- if (loaded)
+ Action showNotImplementedError = () => notifications?.Post(new SimpleNotification
{
- Action showNotImplementedError = () => notifications?.Post(new SimpleNotification
- {
- Text = @"This link type is not yet supported!",
- Icon = FontAwesome.Solid.LifeRing,
- });
- LinkDetails linkDetails = GetLinkDetails(url);
- Schedule(() => LinkUtils.HandleLink(url, linkDetails.Action, linkDetails.Argument, this, channelManager, showNotImplementedError));
- }
- else
- Scheduler.AddDelayed(() => HandleUrl(url), 1000);
+ Text = @"This link type is not yet supported!",
+ Icon = FontAwesome.Solid.LifeRing,
+ });
+
+ LinkDetails linkDetails = GetLinkDetails(url);
+
+ Schedule(() => LinkUtils.HandleLink(url, linkDetails.Action, linkDetails.Argument, this, channelManager, showNotImplementedError));
}
public void OpenUrlExternally(string url)
@@ -403,8 +398,6 @@ namespace osu.Game
protected override void LoadComplete()
{
- loaded = false;
-
base.LoadComplete();
// The next time this is updated is in UpdateAfterChildren, which occurs too late and results
@@ -600,7 +593,6 @@ namespace osu.Game
settings.State.ValueChanged += _ => updateScreenOffset();
notifications.State.ValueChanged += _ => updateScreenOffset();
- loaded = true;
}
public class GameIdleTracker : IdleTracker
diff --git a/osu.iOS/AppDelegate.cs b/osu.iOS/AppDelegate.cs
index e727305997..07e0245195 100644
--- a/osu.iOS/AppDelegate.cs
+++ b/osu.iOS/AppDelegate.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Threading.Tasks;
using Foundation;
using osu.Framework.iOS;
using osu.Framework.Threading;
@@ -17,7 +18,10 @@ namespace osu.iOS
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
- game.HandleUrl(url.AbsoluteString);
+ if (url.IsFileUrl)
+ Task.Run(() => game.Import(url.Path));
+ else
+ Task.Run(() => game.HandleUrl(url.AbsoluteString));
return true;
}
}
diff --git a/osu.iOS/Info.plist b/osu.iOS/Info.plist
index f3067bdcec..5fe8cd6d5b 100644
--- a/osu.iOS/Info.plist
+++ b/osu.iOS/Info.plist
@@ -14,6 +14,8 @@
0.1.0
LSRequiresIPhoneOS
+ LSSupportsOpeningDocumentsInPlace
+
MinimumOSVersion
10.0
UIDeviceFamily
diff --git a/osu.iOS/OsuGameIOS.cs b/osu.iOS/OsuGameIOS.cs
index 6cf18df9a6..ac66357fc9 100644
--- a/osu.iOS/OsuGameIOS.cs
+++ b/osu.iOS/OsuGameIOS.cs
@@ -3,12 +3,14 @@
using System;
using Foundation;
+using osu.Framework.Platform;
using osu.Game;
namespace osu.iOS
{
public class OsuGameIOS : OsuGame
{
+ public override Storage GetStorageForStableInstall() => Storage;
public override Version AssemblyVersion => new Version(NSBundle.MainBundle.InfoDictionary["CFBundleVersion"].ToString());
}
}
From 87974850ddcfdbd55cb332b72016c21f880c91a6 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 7 Aug 2019 08:42:43 +0300
Subject: [PATCH 018/901] Initial implementation
---
.../Online/TestSceneLeaderboardModSelector.cs | 63 ++++++++
.../BeatmapSet/LeaderboardModSelector.cs | 136 ++++++++++++++++++
osu.Game/Overlays/Mods/ModButton.cs | 2 +-
osu.Game/Rulesets/Mods/ModType.cs | 3 +-
osu.Game/Rulesets/UI/ModIcon.cs | 27 ++--
5 files changed, 213 insertions(+), 18 deletions(-)
create mode 100644 osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs
create mode 100644 osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs
new file mode 100644
index 0000000000..eb7fe5591d
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs
@@ -0,0 +1,63 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Overlays.BeatmapSet;
+using System;
+using System.Collections.Generic;
+using osu.Framework.Graphics;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Rulesets.Mania;
+using osu.Game.Rulesets.Taiko;
+using osu.Game.Rulesets.Catch;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Sprites;
+using osu.Framework.Bindables;
+using osu.Game.Rulesets;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ public class TestSceneLeaderboardModSelector : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(LeaderboardModSelector),
+ };
+
+ public TestSceneLeaderboardModSelector()
+ {
+ LeaderboardModSelector modSelector;
+ FillFlowContainer selectedMods;
+ Bindable ruleset = new Bindable();
+
+ Add(selectedMods = new FillFlowContainer
+ {
+ Anchor = Anchor.TopLeft,
+ Origin = Anchor.TopLeft,
+ });
+
+ Add(modSelector = new LeaderboardModSelector
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Ruleset = { BindTarget = ruleset }
+ });
+
+ modSelector.SelectedMods.BindValueChanged(mods =>
+ {
+ selectedMods.Clear();
+
+ foreach (var mod in mods.NewValue)
+ selectedMods.Add(new SpriteText
+ {
+ Text = mod.Acronym,
+ });
+ });
+
+ AddStep("osu mods", () => ruleset.Value = new OsuRuleset().RulesetInfo);
+ AddStep("mania mods", () => ruleset.Value = new ManiaRuleset().RulesetInfo);
+ AddStep("taiko mods", () => ruleset.Value = new TaikoRuleset().RulesetInfo);
+ AddStep("catch mods", () => ruleset.Value = new CatchRuleset().RulesetInfo);
+ AddStep("Deselect all", () => modSelector.DeselectAll());
+ }
+ }
+}
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
new file mode 100644
index 0000000000..99c51813c5
--- /dev/null
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -0,0 +1,136 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics;
+using osu.Game.Rulesets.Mods;
+using osu.Framework.Bindables;
+using System.Collections.Generic;
+using osu.Game.Rulesets;
+using osuTK;
+using osu.Game.Rulesets.UI;
+using osu.Framework.Input.Events;
+using osu.Game.Graphics.UserInterface;
+using osuTK.Graphics;
+using System;
+using System.Linq;
+using osu.Framework.Extensions.IEnumerableExtensions;
+using osu.Framework.Graphics.Sprites;
+
+namespace osu.Game.Overlays.BeatmapSet
+{
+ public class LeaderboardModSelector : Container
+ {
+ public readonly Bindable> SelectedMods = new Bindable>();
+ public readonly Bindable Ruleset = new Bindable();
+
+ private readonly FillFlowContainer modsContainer;
+
+ public LeaderboardModSelector()
+ {
+ AutoSizeAxes = Axes.Y;
+ RelativeSizeAxes = Axes.X;
+ Child = modsContainer = new FillFlowContainer
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Full,
+ Spacing = new Vector2(4),
+ };
+
+ Ruleset.BindValueChanged(onRulesetChanged);
+ }
+
+ private void onRulesetChanged(ValueChangedEvent ruleset)
+ {
+ SelectedMods.Value = new List();
+
+ modsContainer.Clear();
+
+ if (ruleset.NewValue == null)
+ return;
+
+ modsContainer.Add(new ModButton(new NoMod()));
+
+ foreach (var mod in ruleset.NewValue.CreateInstance().GetAllMods())
+ if (mod.Ranked)
+ modsContainer.Add(new ModButton(mod));
+
+ foreach (var mod in modsContainer)
+ mod.OnSelectionChanged += selectionChanged;
+ }
+
+ private void selectionChanged(Mod mod, bool selected)
+ {
+ var mods = SelectedMods.Value.ToList();
+
+ if (selected)
+ mods.Add(mod);
+ else
+ mods.Remove(mod);
+
+ SelectedMods.Value = mods;
+ }
+
+ public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false);
+
+ private class ModButton : ModIcon
+ {
+ private const float mod_scale = 0.4f;
+ private const int duration = 200;
+
+ public readonly BindableBool Selected = new BindableBool();
+ public Action OnSelectionChanged;
+
+ public ModButton(Mod mod)
+ : base(mod)
+ {
+ Scale = new Vector2(mod_scale);
+ Add(new HoverClickSounds());
+
+ Selected.BindValueChanged(selected =>
+ {
+ updateState();
+ OnSelectionChanged?.Invoke(mod, selected.NewValue);
+ }, true);
+ }
+
+ protected override bool OnClick(ClickEvent e)
+ {
+ Selected.Value = !Selected.Value;
+ return base.OnClick(e);
+ }
+
+ protected override bool OnHover(HoverEvent e)
+ {
+ updateState();
+ return base.OnHover(e);
+ }
+
+ protected override void OnHoverLost(HoverLostEvent e)
+ {
+ base.OnHoverLost(e);
+ updateState();
+ }
+
+ private void updateState()
+ {
+ this.FadeColour(IsHovered || Selected.Value ? Color4.White : Color4.Gray, duration, Easing.OutQuint);
+ }
+ }
+
+ private class NoMod : Mod
+ {
+ public override string Name => "NoMod";
+
+ public override string Acronym => "NM";
+
+ public override double ScoreMultiplier => 1;
+
+ public override IconUsage Icon => FontAwesome.Solid.Ban;
+
+ public override ModType Type => ModType.Custom;
+ }
+ }
+}
diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs
index fa1ee500a8..7b8745cf42 100644
--- a/osu.Game/Overlays/Mods/ModButton.cs
+++ b/osu.Game/Overlays/Mods/ModButton.cs
@@ -96,7 +96,7 @@ namespace osu.Game.Overlays.Mods
}
}
- foregroundIcon.Highlighted = Selected;
+ foregroundIcon.Highlighted.Value = Selected;
SelectionChanged?.Invoke(SelectedMod);
return true;
diff --git a/osu.Game/Rulesets/Mods/ModType.cs b/osu.Game/Rulesets/Mods/ModType.cs
index e3c82e42f5..1cdc4415ac 100644
--- a/osu.Game/Rulesets/Mods/ModType.cs
+++ b/osu.Game/Rulesets/Mods/ModType.cs
@@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
Conversion,
Automation,
Fun,
- System
+ System,
+ Custom
}
}
diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs
index 86feea09a8..962263adba 100644
--- a/osu.Game/Rulesets/UI/ModIcon.cs
+++ b/osu.Game/Rulesets/UI/ModIcon.cs
@@ -11,11 +11,14 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mods;
using osuTK;
+using osu.Framework.Bindables;
namespace osu.Game.Rulesets.UI
{
public class ModIcon : Container, IHasTooltip
{
+ public readonly BindableBool Highlighted = new BindableBool();
+
private readonly SpriteIcon modIcon;
private readonly SpriteIcon background;
@@ -96,27 +99,19 @@ namespace osu.Game.Rulesets.UI
backgroundColour = colours.Pink;
highlightedColour = colours.PinkLight;
break;
- }
- applyStyle();
- }
-
- private bool highlighted;
-
- public bool Highlighted
- {
- get => highlighted;
-
- set
- {
- highlighted = value;
- applyStyle();
+ case ModType.Custom:
+ backgroundColour = colours.Gray6;
+ highlightedColour = colours.Gray7;
+ modIcon.Colour = colours.Yellow;
+ break;
}
}
- private void applyStyle()
+ protected override void LoadComplete()
{
- background.Colour = highlighted ? highlightedColour : backgroundColour;
+ base.LoadComplete();
+ Highlighted.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true);
}
}
}
From 411916d4a31b39725b58cbc549fd0a9001e691f5 Mon Sep 17 00:00:00 2001
From: DTSDAO
Date: Wed, 7 Aug 2019 19:32:48 +0800
Subject: [PATCH 019/901] Move static method to Game class
---
.../Graphics/Containers/LinkFlowContainer.cs | 2 +-
osu.Game/Online/Chat/MessageFormatter.cs | 52 ------------------
osu.Game/OsuGame.cs | 55 +++++++++++++++++--
3 files changed, 52 insertions(+), 57 deletions(-)
diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
index ab4629cfff..ca9ffd06c6 100644
--- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs
+++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
@@ -85,7 +85,7 @@ namespace osu.Game.Graphics.Containers
{
RelativeSizeAxes = Axes.Both,
TooltipText = tooltipText ?? (url != text ? url : string.Empty),
- Action = action ?? (() => LinkUtils.HandleLink(url, linkType, linkArgument, game, channelManager, showNotImplementedError)),
+ Action = action ?? (() => game.HandleLink(url, linkType, linkArgument)),
});
return drawables;
diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs
index 73396ce4d2..c875150091 100644
--- a/osu.Game/Online/Chat/MessageFormatter.cs
+++ b/osu.Game/Online/Chat/MessageFormatter.cs
@@ -3,9 +3,7 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text.RegularExpressions;
-using osu.Framework.Logging;
namespace osu.Game.Online.Chat
{
@@ -290,54 +288,4 @@ namespace osu.Game.Online.Chat
public int CompareTo(Link otherLink) => Index > otherLink.Index ? 1 : -1;
}
-
- public static class LinkUtils
- {
- public static void HandleLink(string url, LinkAction linkType, string linkArgument, OsuGame game, ChannelManager channelManager = null, Action showNotImplementedError = null)
- {
- switch (linkType)
- {
- case LinkAction.OpenBeatmap:
- // TODO: proper query params handling
- if (linkArgument != null && int.TryParse(linkArgument.Contains('?') ? linkArgument.Split('?')[0] : linkArgument, out int beatmapId))
- game?.ShowBeatmap(beatmapId);
- break;
-
- case LinkAction.OpenBeatmapSet:
- if (int.TryParse(linkArgument, out int setId))
- game?.ShowBeatmapSet(setId);
- break;
-
- case LinkAction.OpenChannel:
- try
- {
- channelManager?.OpenChannel(linkArgument);
- }
- catch (ChannelNotFoundException)
- {
- Logger.Log($"The requested channel \"{linkArgument}\" does not exist");
- }
-
- break;
-
- case LinkAction.OpenEditorTimestamp:
- case LinkAction.JoinMultiplayerMatch:
- case LinkAction.Spectate:
- showNotImplementedError?.Invoke();
- break;
-
- case LinkAction.External:
- game?.OpenUrlExternally(url);
- break;
-
- case LinkAction.OpenUserProfile:
- if (long.TryParse(linkArgument, out long userId))
- game?.ShowUser(userId);
- break;
-
- default:
- throw new NotImplementedException($"This {nameof(LinkAction)} ({linkType.ToString()}) is missing an associated action.");
- }
- }
- }
}
diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index 846677a0a9..43f3f1f5b5 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -195,19 +195,66 @@ namespace osu.Game
private ExternalLinkOpener externalLinkOpener;
- public void HandleUrl(string url)
+ public void HandleLink(string url, LinkAction linkType, string linkArgument)
{
- Logger.Log($"Request to handle url: {url}");
-
Action showNotImplementedError = () => notifications?.Post(new SimpleNotification
{
Text = @"This link type is not yet supported!",
Icon = FontAwesome.Solid.LifeRing,
});
+ switch (linkType)
+ {
+ case LinkAction.OpenBeatmap:
+ // TODO: proper query params handling
+ if (linkArgument != null && int.TryParse(linkArgument.Contains('?') ? linkArgument.Split('?')[0] : linkArgument, out int beatmapId))
+ ShowBeatmap(beatmapId);
+ break;
+
+ case LinkAction.OpenBeatmapSet:
+ if (int.TryParse(linkArgument, out int setId))
+ ShowBeatmapSet(setId);
+ break;
+
+ case LinkAction.OpenChannel:
+ try
+ {
+ channelManager.OpenChannel(linkArgument);
+ }
+ catch (ChannelNotFoundException)
+ {
+ Logger.Log($"The requested channel \"{linkArgument}\" does not exist");
+ }
+
+ break;
+
+ case LinkAction.OpenEditorTimestamp:
+ case LinkAction.JoinMultiplayerMatch:
+ case LinkAction.Spectate:
+ showNotImplementedError?.Invoke();
+ break;
+
+ case LinkAction.External:
+ OpenUrlExternally(url);
+ break;
+
+ case LinkAction.OpenUserProfile:
+ if (long.TryParse(linkArgument, out long userId))
+ ShowUser(userId);
+ break;
+
+ default:
+ throw new NotImplementedException($"This {nameof(LinkAction)} ({linkType.ToString()}) is missing an associated action.");
+ }
+ }
+
+ public void HandleUrl(string url)
+ {
+ Logger.Log($"Request to handle url: {url}");
+
LinkDetails linkDetails = GetLinkDetails(url);
- Schedule(() => LinkUtils.HandleLink(url, linkDetails.Action, linkDetails.Argument, this, channelManager, showNotImplementedError));
+ Schedule(() => HandleLink(url, linkDetails.Action, linkDetails.Argument));
}
public void OpenUrlExternally(string url)
From 37e430177384e047ce2ce932b280a22583c7d223 Mon Sep 17 00:00:00 2001
From: DTSDAO
Date: Wed, 7 Aug 2019 20:16:22 +0800
Subject: [PATCH 020/901] Fix code format
---
osu.Game/Graphics/Containers/LinkFlowContainer.cs | 11 +----------
osu.Game/OsuGame.cs | 2 +-
2 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
index ca9ffd06c6..b03bc4e3aa 100644
--- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs
+++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
@@ -22,21 +22,12 @@ namespace osu.Game.Graphics.Containers
}
private OsuGame game;
- private ChannelManager channelManager;
- private Action showNotImplementedError;
[BackgroundDependencyLoader(true)]
- private void load(OsuGame game, NotificationOverlay notifications, ChannelManager channelManager)
+ private void load(OsuGame game)
{
// will be null in tests
this.game = game;
- this.channelManager = channelManager;
-
- showNotImplementedError = () => notifications?.Post(new SimpleNotification
- {
- Text = @"This link type is not yet supported!",
- Icon = FontAwesome.Solid.LifeRing,
- });
}
public void AddLinks(string text, List links)
diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index 43f3f1f5b5..82bf8abf94 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -231,7 +231,7 @@ namespace osu.Game
case LinkAction.OpenEditorTimestamp:
case LinkAction.JoinMultiplayerMatch:
case LinkAction.Spectate:
- showNotImplementedError?.Invoke();
+ showNotImplementedError.Invoke();
break;
case LinkAction.External:
From 9f72e92e0e35dc4c71ba7d6d184334fbd5b732ca Mon Sep 17 00:00:00 2001
From: DTSDAO
Date: Wed, 7 Aug 2019 20:27:39 +0800
Subject: [PATCH 021/901] Fix code format
---
osu.Game/Graphics/Containers/LinkFlowContainer.cs | 2 --
1 file changed, 2 deletions(-)
diff --git a/osu.Game/Graphics/Containers/LinkFlowContainer.cs b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
index b03bc4e3aa..66911d9615 100644
--- a/osu.Game/Graphics/Containers/LinkFlowContainer.cs
+++ b/osu.Game/Graphics/Containers/LinkFlowContainer.cs
@@ -8,8 +8,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using System.Collections.Generic;
using osu.Framework.Graphics;
-using osu.Game.Overlays;
-using osu.Game.Overlays.Notifications;
using osu.Game.Users;
namespace osu.Game.Graphics.Containers
From e3d52d8d7171076a28ddb67feaf130cf62a7ea3a Mon Sep 17 00:00:00 2001
From: Lucas A
Date: Sat, 10 Aug 2019 12:22:45 +0200
Subject: [PATCH 022/901] Add NewsOverlay class
---
osu.Game/Overlays/NewsOverlay.cs | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 osu.Game/Overlays/NewsOverlay.cs
diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs
new file mode 100644
index 0000000000..76040a6086
--- /dev/null
+++ b/osu.Game/Overlays/NewsOverlay.cs
@@ -0,0 +1,23 @@
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Graphics;
+
+namespace osu.Game.Overlays
+{
+ public class NewsOverlay : FullscreenOverlay
+ {
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = colours.PurpleLightAlternative
+ }
+ };
+ }
+ }
+}
From 4b0ac381b7372a0ba2f6238e2890509c158debb2 Mon Sep 17 00:00:00 2001
From: Lucas A
Date: Sat, 10 Aug 2019 12:26:54 +0200
Subject: [PATCH 023/901] Add visual tests.
---
.../Visual/Online/TestSceneNewsOverlay.cs | 17 +++++++++++++++++
osu.Game/Overlays/NewsOverlay.cs | 2 +-
2 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
new file mode 100644
index 0000000000..3362d4700f
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
@@ -0,0 +1,17 @@
+using osu.Game.Overlays;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ public class TestSceneNewsOverlay : OsuTestScene
+ {
+ private NewsOverlay news;
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+ Add(news = new NewsOverlay());
+ AddStep(@"Show", news.Show);
+ AddStep(@"Hide", news.Hide);
+ }
+ }
+}
diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs
index 76040a6086..76b917b65d 100644
--- a/osu.Game/Overlays/NewsOverlay.cs
+++ b/osu.Game/Overlays/NewsOverlay.cs
@@ -15,7 +15,7 @@ namespace osu.Game.Overlays
new Box
{
RelativeSizeAxes = Axes.Both,
- Colour = colours.PurpleLightAlternative
+ Colour = colours.PurpleDarkAlternative
}
};
}
From b19c378fc8a7e5b571ed0e288b79c6e2ac628941 Mon Sep 17 00:00:00 2001
From: Lucas A
Date: Sat, 10 Aug 2019 12:53:34 +0200
Subject: [PATCH 024/901] Add NewsHeader class
---
osu.Game/Overlays/News/NewsHeader.cs | 71 ++++++++++++++++++++++++++++
osu.Game/Overlays/NewsOverlay.cs | 21 +++++++-
2 files changed, 91 insertions(+), 1 deletion(-)
create mode 100644 osu.Game/Overlays/News/NewsHeader.cs
diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs
new file mode 100644
index 0000000000..43a514cdc6
--- /dev/null
+++ b/osu.Game/Overlays/News/NewsHeader.cs
@@ -0,0 +1,71 @@
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Sprites;
+using osu.Framework.Graphics.Textures;
+using osu.Game.Graphics;
+using osu.Game.Graphics.UserInterface;
+
+namespace osu.Game.Overlays.News
+{
+ public class NewsHeader : OverlayHeader
+ {
+ private const string front_page_string = "Front Page";
+
+ private NewsHeaderTitle title;
+
+ public NewsHeader()
+ {
+ TabControl.AddItem(front_page_string);
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colour)
+ {
+ TabControl.AccentColour = colour.Violet;
+ }
+
+ protected override Drawable CreateBackground() => new NewsHeaderBackground();
+
+ protected override Drawable CreateContent() => new Container();
+
+ protected override ScreenTitle CreateTitle() => title = new NewsHeaderTitle();
+
+ private class NewsHeaderBackground : Sprite
+ {
+ public NewsHeaderBackground()
+ {
+ RelativeSizeAxes = Axes.Both;
+ FillMode = FillMode.Fill;
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(TextureStore textures)
+ {
+ Texture = textures.Get(@"Headers/changelog"); //using changelog bg until corresponding osu-resources pr is merged.
+ }
+ }
+
+ private class NewsHeaderTitle : ScreenTitle
+ {
+ private const string article_string = "Article";
+
+ public bool IsReadingArticle
+ {
+ set => Section = value ? article_string : front_page_string;
+ }
+
+ public NewsHeaderTitle()
+ {
+ Title = "News";
+ IsReadingArticle = false;
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ AccentColour = colours.Violet;
+ }
+ }
+ }
+}
diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs
index 76b917b65d..80088a25bc 100644
--- a/osu.Game/Overlays/NewsOverlay.cs
+++ b/osu.Game/Overlays/NewsOverlay.cs
@@ -1,12 +1,17 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
+using osu.Game.Graphics.Containers;
+using osu.Game.Overlays.News;
namespace osu.Game.Overlays
{
public class NewsOverlay : FullscreenOverlay
{
+ private NewsHeader header;
+
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@@ -16,7 +21,21 @@ namespace osu.Game.Overlays
{
RelativeSizeAxes = Axes.Both,
Colour = colours.PurpleDarkAlternative
- }
+ },
+ new OsuScrollContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Child = new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical,
+ Children = new Drawable[]
+ {
+ header = new NewsHeader()
+ },
+ },
+ },
};
}
}
From 0e5561c783344856d751338f32e876cb373cb4a0 Mon Sep 17 00:00:00 2001
From: Lucas A
Date: Sat, 10 Aug 2019 16:12:42 +0200
Subject: [PATCH 025/901] Use News overlay resources
---
osu.Game/Overlays/News/NewsHeader.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs
index 43a514cdc6..fb02f7f105 100644
--- a/osu.Game/Overlays/News/NewsHeader.cs
+++ b/osu.Game/Overlays/News/NewsHeader.cs
@@ -42,7 +42,7 @@ namespace osu.Game.Overlays.News
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
- Texture = textures.Get(@"Headers/changelog"); //using changelog bg until corresponding osu-resources pr is merged.
+ Texture = textures.Get(@"Headers/news");
}
}
@@ -61,6 +61,8 @@ namespace osu.Game.Overlays.News
IsReadingArticle = false;
}
+ protected override Drawable CreateIcon() => new ScreenTitleIcon(@"Icons/news");
+
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
From b92e331730f2971c5fbe7b5afe0031e781c2c494 Mon Sep 17 00:00:00 2001
From: Lucas A
Date: Sat, 10 Aug 2019 17:06:52 +0200
Subject: [PATCH 026/901] Add tabcontrol logic to news overlay
---
.../Visual/Online/TestSceneNewsOverlay.cs | 3 ++
osu.Game/Overlays/News/NewsHeader.cs | 35 ++++++++++++++++++-
osu.Game/Overlays/NewsOverlay.cs | 13 +++++++
3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
index 3362d4700f..d5273801d8 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
@@ -12,6 +12,9 @@ namespace osu.Game.Tests.Visual.Online
Add(news = new NewsOverlay());
AddStep(@"Show", news.Show);
AddStep(@"Hide", news.Hide);
+
+ AddStep(@"Show front page", () => news.ShowFrontPage());
+ AddStep(@"Custom article", () => news.Current.Value = "Test Article 101");
}
}
}
diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs
index fb02f7f105..e887d48456 100644
--- a/osu.Game/Overlays/News/NewsHeader.cs
+++ b/osu.Game/Overlays/News/NewsHeader.cs
@@ -1,10 +1,12 @@
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
+using System;
namespace osu.Game.Overlays.News
{
@@ -14,9 +16,21 @@ namespace osu.Game.Overlays.News
private NewsHeaderTitle title;
+ public readonly Bindable Current = new Bindable(null);
+
+ public Action ShowFrontPage;
+
public NewsHeader()
{
TabControl.AddItem(front_page_string);
+
+ TabControl.Current.ValueChanged += e =>
+ {
+ if (e.NewValue == front_page_string)
+ ShowFrontPage?.Invoke();
+ };
+
+ Current.ValueChanged += showArticle;
}
[BackgroundDependencyLoader]
@@ -25,6 +39,25 @@ namespace osu.Game.Overlays.News
TabControl.AccentColour = colour.Violet;
}
+ private void showArticle(ValueChangedEvent e)
+ {
+ if (e.OldValue != null)
+ TabControl.RemoveItem(e.OldValue);
+
+ if (e.NewValue != null)
+ {
+ TabControl.AddItem(e.NewValue);
+ TabControl.Current.Value = e.NewValue;
+
+ title.IsReadingArticle = true;
+ }
+ else
+ {
+ TabControl.Current.Value = front_page_string;
+ title.IsReadingArticle = false;
+ }
+ }
+
protected override Drawable CreateBackground() => new NewsHeaderBackground();
protected override Drawable CreateContent() => new Container();
@@ -52,7 +85,7 @@ namespace osu.Game.Overlays.News
public bool IsReadingArticle
{
- set => Section = value ? article_string : front_page_string;
+ set => Section = value ? article_string : front_page_string;
}
public NewsHeaderTitle()
diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs
index 80088a25bc..1506cbb288 100644
--- a/osu.Game/Overlays/NewsOverlay.cs
+++ b/osu.Game/Overlays/NewsOverlay.cs
@@ -1,4 +1,5 @@
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@@ -12,6 +13,8 @@ namespace osu.Game.Overlays
{
private NewsHeader header;
+ public readonly Bindable Current = new Bindable(null);
+
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@@ -37,6 +40,16 @@ namespace osu.Game.Overlays
},
},
};
+
+ header.Current.BindTo(Current);
+ header.ShowFrontPage = ShowFrontPage;
+ Current.TriggerChange();
+ }
+
+ public void ShowFrontPage()
+ {
+ Current.Value = null;
+ Show();
}
}
}
From 0070f6b26072b391e3989eb880261bc632ce41fb Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 12 Aug 2019 14:49:08 +0300
Subject: [PATCH 027/901] Use CompositeDrawable as a parent class
---
osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
index 99c51813c5..399cd4a49a 100644
--- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -19,7 +19,7 @@ using osu.Framework.Graphics.Sprites;
namespace osu.Game.Overlays.BeatmapSet
{
- public class LeaderboardModSelector : Container
+ public class LeaderboardModSelector : CompositeDrawable
{
public readonly Bindable> SelectedMods = new Bindable>();
public readonly Bindable Ruleset = new Bindable();
@@ -30,7 +30,7 @@ namespace osu.Game.Overlays.BeatmapSet
{
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
- Child = modsContainer = new FillFlowContainer
+ InternalChild = modsContainer = new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
From 21af39032749fdb8da92fd773a5063f03ab955c6 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 12 Aug 2019 14:57:16 +0300
Subject: [PATCH 028/901] Move binding to LoadComplete
---
osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
index 399cd4a49a..99c1b54467 100644
--- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -38,8 +38,12 @@ namespace osu.Game.Overlays.BeatmapSet
Direction = FillDirection.Full,
Spacing = new Vector2(4),
};
+ }
- Ruleset.BindValueChanged(onRulesetChanged);
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+ Ruleset.BindValueChanged(onRulesetChanged, true);
}
private void onRulesetChanged(ValueChangedEvent ruleset)
From 62a91e4aaab46c458152233ef4208278dc635e4b Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 12 Aug 2019 15:20:21 +0300
Subject: [PATCH 029/901] Add the ability to override Highlighted action to the
ModIcon
---
.../Overlays/BeatmapSet/LeaderboardModSelector.cs | 14 ++++++++++++--
osu.Game/Rulesets/UI/ModIcon.cs | 13 +++++++++++--
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
index 99c1b54467..03d2e6ce4b 100644
--- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -92,11 +92,16 @@ namespace osu.Game.Overlays.BeatmapSet
{
Scale = new Vector2(mod_scale);
Add(new HoverClickSounds());
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
Selected.BindValueChanged(selected =>
{
updateState();
- OnSelectionChanged?.Invoke(mod, selected.NewValue);
+ OnSelectionChanged?.Invoke(Mod, selected.NewValue);
}, true);
}
@@ -120,7 +125,12 @@ namespace osu.Game.Overlays.BeatmapSet
private void updateState()
{
- this.FadeColour(IsHovered || Selected.Value ? Color4.White : Color4.Gray, duration, Easing.OutQuint);
+ Highlighted.Value = (IsHovered || Selected.Value) ? true : false;
+ }
+
+ protected override void OnHighlightedChange(ValueChangedEvent highlighted)
+ {
+ this.FadeColour(highlighted.NewValue ? Color4.White : Color4.Gray, duration, Easing.OutQuint);
}
}
diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs
index 962263adba..e713216f35 100644
--- a/osu.Game/Rulesets/UI/ModIcon.cs
+++ b/osu.Game/Rulesets/UI/ModIcon.cs
@@ -34,9 +34,11 @@ namespace osu.Game.Rulesets.UI
public virtual string TooltipText { get; }
+ protected Mod Mod { get; private set; }
+
public ModIcon(Mod mod)
{
- if (mod == null) throw new ArgumentNullException(nameof(mod));
+ Mod = mod ?? throw new ArgumentNullException(nameof(mod));
type = mod.Type;
@@ -106,12 +108,19 @@ namespace osu.Game.Rulesets.UI
modIcon.Colour = colours.Yellow;
break;
}
+
+ background.Colour = backgroundColour;
}
protected override void LoadComplete()
{
base.LoadComplete();
- Highlighted.BindValueChanged(highlighted => background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour, true);
+ Highlighted.BindValueChanged(OnHighlightedChange, true);
+ }
+
+ protected virtual void OnHighlightedChange(ValueChangedEvent highlighted)
+ {
+ background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour;
}
}
}
From b71c776e65c291df39a45a175bc8301d6e3661d7 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 12 Aug 2019 16:20:36 +0300
Subject: [PATCH 030/901] Add web-like hover behavior
---
.../BeatmapSet/LeaderboardModSelector.cs | 39 +++++++++++++++++--
osu.Game/Rulesets/UI/ModIcon.cs | 2 +-
2 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
index 03d2e6ce4b..1e10c41478 100644
--- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -57,12 +57,13 @@ namespace osu.Game.Overlays.BeatmapSet
modsContainer.Add(new ModButton(new NoMod()));
- foreach (var mod in ruleset.NewValue.CreateInstance().GetAllMods())
+ ruleset.NewValue.CreateInstance().GetAllMods().ForEach(mod =>
+ {
if (mod.Ranked)
modsContainer.Add(new ModButton(mod));
+ });
- foreach (var mod in modsContainer)
- mod.OnSelectionChanged += selectionChanged;
+ modsContainer.ForEach(button => button.OnSelectionChanged += selectionChanged);
}
private void selectionChanged(Mod mod, bool selected)
@@ -74,11 +75,39 @@ namespace osu.Game.Overlays.BeatmapSet
else
mods.Remove(mod);
+ if (!mods.Any() && !IsHovered)
+ modsContainer.ForEach(button => button.Highlighted.Value = true);
+
SelectedMods.Value = mods;
}
+ protected override bool OnHover(HoverEvent e)
+ {
+ if (!SelectedMods.Value.Any())
+ dehighlightAll();
+
+ return base.OnHover(e);
+ }
+
+ protected override void OnHoverLost(HoverLostEvent e)
+ {
+ base.OnHoverLost(e);
+
+ if (!SelectedMods.Value.Any())
+ modsContainer.ForEach(mod => mod.Highlighted.Value = true);
+ }
+
public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false);
+ private void dehighlightAll()
+ {
+ modsContainer.ForEach(button =>
+ {
+ if (!button.IsHovered)
+ button.Highlighted.Value = false;
+ });
+ }
+
private class ModButton : ModIcon
{
private const float mod_scale = 0.4f;
@@ -98,11 +127,13 @@ namespace osu.Game.Overlays.BeatmapSet
{
base.LoadComplete();
+ Highlighted.Value = true;
+
Selected.BindValueChanged(selected =>
{
updateState();
OnSelectionChanged?.Invoke(Mod, selected.NewValue);
- }, true);
+ });
}
protected override bool OnClick(ClickEvent e)
diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs
index e713216f35..1bcd2dc780 100644
--- a/osu.Game/Rulesets/UI/ModIcon.cs
+++ b/osu.Game/Rulesets/UI/ModIcon.cs
@@ -115,7 +115,7 @@ namespace osu.Game.Rulesets.UI
protected override void LoadComplete()
{
base.LoadComplete();
- Highlighted.BindValueChanged(OnHighlightedChange, true);
+ Highlighted.BindValueChanged(OnHighlightedChange);
}
protected virtual void OnHighlightedChange(ValueChangedEvent highlighted)
From 86c9d5251faea12d24347dc68ae1c94ea3c738db Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 12 Aug 2019 16:28:53 +0300
Subject: [PATCH 031/901] Remove unused function
---
.../Overlays/BeatmapSet/LeaderboardModSelector.cs | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
index 1e10c41478..fffbc400b1 100644
--- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -84,7 +84,11 @@ namespace osu.Game.Overlays.BeatmapSet
protected override bool OnHover(HoverEvent e)
{
if (!SelectedMods.Value.Any())
- dehighlightAll();
+ modsContainer.ForEach(button =>
+ {
+ if (!button.IsHovered)
+ button.Highlighted.Value = false;
+ });
return base.OnHover(e);
}
@@ -99,15 +103,6 @@ namespace osu.Game.Overlays.BeatmapSet
public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false);
- private void dehighlightAll()
- {
- modsContainer.ForEach(button =>
- {
- if (!button.IsHovered)
- button.Highlighted.Value = false;
- });
- }
-
private class ModButton : ModIcon
{
private const float mod_scale = 0.4f;
From cf92d6b1b01174666b484580242ad99891a839e0 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 12 Aug 2019 16:32:04 +0300
Subject: [PATCH 032/901] Add highlightAll function to avoid duplication
---
osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
index fffbc400b1..1489907589 100644
--- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -76,7 +76,7 @@ namespace osu.Game.Overlays.BeatmapSet
mods.Remove(mod);
if (!mods.Any() && !IsHovered)
- modsContainer.ForEach(button => button.Highlighted.Value = true);
+ highlightAll();
SelectedMods.Value = mods;
}
@@ -98,11 +98,13 @@ namespace osu.Game.Overlays.BeatmapSet
base.OnHoverLost(e);
if (!SelectedMods.Value.Any())
- modsContainer.ForEach(mod => mod.Highlighted.Value = true);
+ highlightAll();
}
public void DeselectAll() => modsContainer.ForEach(mod => mod.Selected.Value = false);
+ private void highlightAll() => modsContainer.ForEach(mod => mod.Highlighted.Value = true);
+
private class ModButton : ModIcon
{
private const float mod_scale = 0.4f;
From 1bfb87fcdd01536874269a16ffcf13d6e7ffcc7c Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 12 Aug 2019 16:41:35 +0300
Subject: [PATCH 033/901] Remove redundant conditional ternary expression
---
osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
index 1489907589..66d78f927a 100644
--- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -28,8 +28,7 @@ namespace osu.Game.Overlays.BeatmapSet
public LeaderboardModSelector()
{
- AutoSizeAxes = Axes.Y;
- RelativeSizeAxes = Axes.X;
+ AutoSizeAxes = Axes.Both;
InternalChild = modsContainer = new FillFlowContainer
{
Anchor = Anchor.Centre,
@@ -151,10 +150,7 @@ namespace osu.Game.Overlays.BeatmapSet
updateState();
}
- private void updateState()
- {
- Highlighted.Value = (IsHovered || Selected.Value) ? true : false;
- }
+ private void updateState() => Highlighted.Value = IsHovered || Selected.Value;
protected override void OnHighlightedChange(ValueChangedEvent highlighted)
{
From 87811afade5abfdbf6dc3a2503242f2be4be076b Mon Sep 17 00:00:00 2001
From: Lucas A
Date: Mon, 12 Aug 2019 20:16:41 +0200
Subject: [PATCH 034/901] Add missing licence headers to added files.
---
osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs | 5 ++++-
osu.Game/Overlays/News/NewsHeader.cs | 5 ++++-
osu.Game/Overlays/NewsOverlay.cs | 5 ++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
index d5273801d8..546f6ac182 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
@@ -1,4 +1,7 @@
-using osu.Game.Overlays;
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.Online
{
diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs
index e887d48456..6a14828473 100644
--- a/osu.Game/Overlays/News/NewsHeader.cs
+++ b/osu.Game/Overlays/News/NewsHeader.cs
@@ -1,4 +1,7 @@
-using osu.Framework.Allocation;
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs
index 1506cbb288..b509204c58 100644
--- a/osu.Game/Overlays/NewsOverlay.cs
+++ b/osu.Game/Overlays/NewsOverlay.cs
@@ -1,4 +1,7 @@
-using osu.Framework.Allocation;
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
From 840d4741daf285b0c2541997f39b6fda309a492b Mon Sep 17 00:00:00 2001
From: Lucas A
Date: Wed, 14 Aug 2019 20:24:36 +0200
Subject: [PATCH 035/901] Add NewsContent class and fix broken reference.
---
osu.Game/Overlays/News/NewsContent.cs | 16 ++++++++++++++++
osu.Game/Overlays/News/NewsHeader.cs | 2 +-
osu.Game/Overlays/NewsOverlay.cs | 10 +++++++++-
3 files changed, 26 insertions(+), 2 deletions(-)
create mode 100644 osu.Game/Overlays/News/NewsContent.cs
diff --git a/osu.Game/Overlays/News/NewsContent.cs b/osu.Game/Overlays/News/NewsContent.cs
new file mode 100644
index 0000000000..f0763285eb
--- /dev/null
+++ b/osu.Game/Overlays/News/NewsContent.cs
@@ -0,0 +1,16 @@
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+
+namespace osu.Game.Overlays.News
+{
+ public abstract class NewsContent : FillFlowContainer
+ {
+ public NewsContent()
+ {
+ RelativeSizeAxes = Axes.X;
+ AutoSizeAxes = Axes.Y;
+ Direction = FillDirection.Vertical;
+ Padding = new MarginPadding { Bottom = 100 };
+ }
+ }
+}
diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs
index 6a14828473..27620ab523 100644
--- a/osu.Game/Overlays/News/NewsHeader.cs
+++ b/osu.Game/Overlays/News/NewsHeader.cs
@@ -97,7 +97,7 @@ namespace osu.Game.Overlays.News
IsReadingArticle = false;
}
- protected override Drawable CreateIcon() => new ScreenTitleIcon(@"Icons/news");
+ protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/news");
[BackgroundDependencyLoader]
private void load(OsuColour colours)
diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs
index b509204c58..b341321a46 100644
--- a/osu.Game/Overlays/NewsOverlay.cs
+++ b/osu.Game/Overlays/NewsOverlay.cs
@@ -15,6 +15,7 @@ namespace osu.Game.Overlays
public class NewsOverlay : FullscreenOverlay
{
private NewsHeader header;
+ private Container content;
public readonly Bindable Current = new Bindable(null);
@@ -39,13 +40,20 @@ namespace osu.Game.Overlays
Children = new Drawable[]
{
header = new NewsHeader()
+ {
+ ShowFrontPage = ShowFrontPage
+ },
+ content = new Container()
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ }
},
},
},
};
header.Current.BindTo(Current);
- header.ShowFrontPage = ShowFrontPage;
Current.TriggerChange();
}
From 46e71e9ead75227f63080ed4751e3f61228d1f40 Mon Sep 17 00:00:00 2001
From: Lucas A
Date: Wed, 14 Aug 2019 21:34:29 +0200
Subject: [PATCH 036/901] Add missing licence header
---
osu.Game/Overlays/News/NewsContent.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/News/NewsContent.cs b/osu.Game/Overlays/News/NewsContent.cs
index f0763285eb..26f92b3825 100644
--- a/osu.Game/Overlays/News/NewsContent.cs
+++ b/osu.Game/Overlays/News/NewsContent.cs
@@ -1,4 +1,7 @@
-using osu.Framework.Graphics;
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Overlays.News
From 4d1b1a4022d530d5c7fff5ceec3d04ffca641543 Mon Sep 17 00:00:00 2001
From: Lucas A
Date: Wed, 14 Aug 2019 21:52:36 +0200
Subject: [PATCH 037/901] Fix CI inspections
---
osu.Game/Overlays/News/NewsContent.cs | 2 +-
osu.Game/Overlays/NewsOverlay.cs | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/osu.Game/Overlays/News/NewsContent.cs b/osu.Game/Overlays/News/NewsContent.cs
index 26f92b3825..16a8ed84b8 100644
--- a/osu.Game/Overlays/News/NewsContent.cs
+++ b/osu.Game/Overlays/News/NewsContent.cs
@@ -8,7 +8,7 @@ namespace osu.Game.Overlays.News
{
public abstract class NewsContent : FillFlowContainer
{
- public NewsContent()
+ protected NewsContent()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs
index b341321a46..aadca8883e 100644
--- a/osu.Game/Overlays/NewsOverlay.cs
+++ b/osu.Game/Overlays/NewsOverlay.cs
@@ -15,6 +15,8 @@ namespace osu.Game.Overlays
public class NewsOverlay : FullscreenOverlay
{
private NewsHeader header;
+
+ //ReSharper disable NotAccessedField.Local
private Container content;
public readonly Bindable Current = new Bindable(null);
@@ -39,11 +41,11 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
- header = new NewsHeader()
+ header = new NewsHeader
{
ShowFrontPage = ShowFrontPage
},
- content = new Container()
+ content = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
From af2ffac03a5fe99a4d62e0508e3e0f1e215d2be3 Mon Sep 17 00:00:00 2001
From: Lucas A
Date: Sun, 18 Aug 2019 14:52:26 +0200
Subject: [PATCH 038/901] Add global Top and Horizontal padding to NewsContent
---
osu.Game/Overlays/News/NewsContent.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/News/NewsContent.cs b/osu.Game/Overlays/News/NewsContent.cs
index 16a8ed84b8..5ff210f9f5 100644
--- a/osu.Game/Overlays/News/NewsContent.cs
+++ b/osu.Game/Overlays/News/NewsContent.cs
@@ -13,7 +13,7 @@ namespace osu.Game.Overlays.News
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
- Padding = new MarginPadding { Bottom = 100 };
+ Padding = new MarginPadding { Bottom = 100, Top = 20, Horizontal = 50 };
}
}
}
From 0cf4db899ff94292bac6945e8296c93931f64769 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Thu, 19 Sep 2019 17:03:52 +0300
Subject: [PATCH 039/901] Few cleanups
---
.../Visual/Online/TestSceneLeaderboardModSelector.cs | 9 +++++----
.../Overlays/BeatmapSet/LeaderboardModSelector.cs | 11 ++++-------
osu.Game/Rulesets/UI/ModIcon.cs | 4 ++--
3 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs
index eb7fe5591d..3a64ac79f6 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs
@@ -53,11 +53,12 @@ namespace osu.Game.Tests.Visual.Online
});
});
- AddStep("osu mods", () => ruleset.Value = new OsuRuleset().RulesetInfo);
- AddStep("mania mods", () => ruleset.Value = new ManiaRuleset().RulesetInfo);
- AddStep("taiko mods", () => ruleset.Value = new TaikoRuleset().RulesetInfo);
- AddStep("catch mods", () => ruleset.Value = new CatchRuleset().RulesetInfo);
+ AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo);
+ AddStep("mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo);
+ AddStep("taiko ruleset", () => ruleset.Value = new TaikoRuleset().RulesetInfo);
+ AddStep("catch ruleset", () => ruleset.Value = new CatchRuleset().RulesetInfo);
AddStep("Deselect all", () => modSelector.DeselectAll());
+ AddStep("null ruleset", () => ruleset.Value = null);
}
}
}
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
index 66d78f927a..d09464aba6 100644
--- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -74,10 +74,10 @@ namespace osu.Game.Overlays.BeatmapSet
else
mods.Remove(mod);
+ SelectedMods.Value = mods;
+
if (!mods.Any() && !IsHovered)
highlightAll();
-
- SelectedMods.Value = mods;
}
protected override bool OnHover(HoverEvent e)
@@ -116,6 +116,7 @@ namespace osu.Game.Overlays.BeatmapSet
: base(mod)
{
Scale = new Vector2(mod_scale);
+ Highlighted.Value = true;
Add(new HoverClickSounds());
}
@@ -123,8 +124,6 @@ namespace osu.Game.Overlays.BeatmapSet
{
base.LoadComplete();
- Highlighted.Value = true;
-
Selected.BindValueChanged(selected =>
{
updateState();
@@ -152,10 +151,8 @@ namespace osu.Game.Overlays.BeatmapSet
private void updateState() => Highlighted.Value = IsHovered || Selected.Value;
- protected override void OnHighlightedChange(ValueChangedEvent highlighted)
- {
+ protected override void OnHighlightedChanged(ValueChangedEvent highlighted) =>
this.FadeColour(highlighted.NewValue ? Color4.White : Color4.Gray, duration, Easing.OutQuint);
- }
}
private class NoMod : Mod
diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs
index d3607757ab..b54ddf8f12 100644
--- a/osu.Game/Rulesets/UI/ModIcon.cs
+++ b/osu.Game/Rulesets/UI/ModIcon.cs
@@ -114,10 +114,10 @@ namespace osu.Game.Rulesets.UI
protected override void LoadComplete()
{
base.LoadComplete();
- Highlighted.BindValueChanged(OnHighlightedChange);
+ Highlighted.BindValueChanged(OnHighlightedChanged, true);
}
- protected virtual void OnHighlightedChange(ValueChangedEvent highlighted)
+ protected virtual void OnHighlightedChanged(ValueChangedEvent highlighted)
{
background.Colour = highlighted.NewValue ? highlightedColour : backgroundColour;
}
From e7118a9272600b7e4ac2ffddef8bbecab336d12d Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Fri, 20 Sep 2019 23:47:21 +0300
Subject: [PATCH 040/901] Use System mod type for NoMod
---
osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs | 2 +-
osu.Game/Rulesets/Mods/ModType.cs | 3 +--
osu.Game/Rulesets/UI/ModIcon.cs | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
index d09464aba6..4b6fd5bfc2 100644
--- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs
@@ -165,7 +165,7 @@ namespace osu.Game.Overlays.BeatmapSet
public override IconUsage Icon => FontAwesome.Solid.Ban;
- public override ModType Type => ModType.Custom;
+ public override ModType Type => ModType.System;
}
}
}
diff --git a/osu.Game/Rulesets/Mods/ModType.cs b/osu.Game/Rulesets/Mods/ModType.cs
index 1cdc4415ac..e3c82e42f5 100644
--- a/osu.Game/Rulesets/Mods/ModType.cs
+++ b/osu.Game/Rulesets/Mods/ModType.cs
@@ -10,7 +10,6 @@ namespace osu.Game.Rulesets.Mods
Conversion,
Automation,
Fun,
- System,
- Custom
+ System
}
}
diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs
index b54ddf8f12..19211e0c80 100644
--- a/osu.Game/Rulesets/UI/ModIcon.cs
+++ b/osu.Game/Rulesets/UI/ModIcon.cs
@@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.UI
highlightedColour = colours.PinkLight;
break;
- case ModType.Custom:
+ case ModType.System:
backgroundColour = colours.Gray6;
highlightedColour = colours.Gray7;
modIcon.Colour = colours.Yellow;
From b8d147a3b41586c2e10556145a04aea69193e57a Mon Sep 17 00:00:00 2001
From: LeNitrous
Date: Tue, 24 Sep 2019 17:42:06 +0800
Subject: [PATCH 041/901] introduce main menu background modes
---
osu.Game/Configuration/BackgroundMode.cs | 12 +++++++
osu.Game/Configuration/OsuConfigManager.cs | 5 ++-
.../Graphics/Backgrounds/BeatmapBackground.cs | 28 ++++++++++++++++
.../Sections/Audio/MainMenuSettings.cs | 6 ++++
.../Backgrounds/BackgroundScreenBeatmap.cs | 17 ----------
.../Backgrounds/BackgroundScreenDefault.cs | 33 +++++++++++++++++--
6 files changed, 80 insertions(+), 21 deletions(-)
create mode 100644 osu.Game/Configuration/BackgroundMode.cs
create mode 100644 osu.Game/Graphics/Backgrounds/BeatmapBackground.cs
diff --git a/osu.Game/Configuration/BackgroundMode.cs b/osu.Game/Configuration/BackgroundMode.cs
new file mode 100644
index 0000000000..21554891ca
--- /dev/null
+++ b/osu.Game/Configuration/BackgroundMode.cs
@@ -0,0 +1,12 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+namespace osu.Game.Configuration
+{
+ public enum BackgroundMode
+ {
+ Default,
+ Seasonal,
+ Beatmap
+ }
+}
diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs
index 64b1f2d7bc..9b964e8893 100644
--- a/osu.Game/Configuration/OsuConfigManager.cs
+++ b/osu.Game/Configuration/OsuConfigManager.cs
@@ -117,6 +117,8 @@ namespace osu.Game.Configuration
Set(OsuSetting.UIHoldActivationDelay, 200, 0, 500);
Set(OsuSetting.IntroSequence, IntroSequence.Triangles);
+
+ Set(OsuSetting.BackgroundMode, BackgroundMode.Default);
}
public OsuConfigManager(Storage storage)
@@ -186,6 +188,7 @@ namespace osu.Game.Configuration
UIScale,
IntroSequence,
UIHoldActivationDelay,
- HitLighting
+ HitLighting,
+ BackgroundMode
}
}
diff --git a/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs b/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs
new file mode 100644
index 0000000000..40c6dae43c
--- /dev/null
+++ b/osu.Game/Graphics/Backgrounds/BeatmapBackground.cs
@@ -0,0 +1,28 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Graphics.Textures;
+using osu.Game.Beatmaps;
+
+namespace osu.Game.Graphics.Backgrounds
+{
+ public class BeatmapBackground : Background
+ {
+ public readonly WorkingBeatmap Beatmap;
+
+ private readonly string fallbackTextureName;
+
+ public BeatmapBackground(WorkingBeatmap beatmap, string fallbackTextureName = @"Backgrounds/bg1")
+ {
+ Beatmap = beatmap;
+ this.fallbackTextureName = fallbackTextureName;
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(TextureStore textures)
+ {
+ Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs b/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs
index 5ccdc952ba..76a6aafe45 100644
--- a/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs
+++ b/osu.Game/Overlays/Settings/Sections/Audio/MainMenuSettings.cs
@@ -34,6 +34,12 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
Bindable = config.GetBindable(OsuSetting.IntroSequence),
Items = Enum.GetValues(typeof(IntroSequence)).Cast()
},
+ new SettingsDropdown
+ {
+ LabelText = "Background",
+ Bindable = config.GetBindable(OsuSetting.BackgroundMode),
+ Items = Enum.GetValues(typeof(BackgroundMode)).Cast()
+ }
};
}
}
diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs
index 2730b0b90d..3de0ab191c 100644
--- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs
+++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs
@@ -6,7 +6,6 @@ using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
-using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.Backgrounds;
@@ -107,22 +106,6 @@ namespace osu.Game.Screens.Backgrounds
return base.Equals(other) && beatmap == otherBeatmapBackground.Beatmap;
}
- protected class BeatmapBackground : Background
- {
- public readonly WorkingBeatmap Beatmap;
-
- public BeatmapBackground(WorkingBeatmap beatmap)
- {
- Beatmap = beatmap;
- }
-
- [BackgroundDependencyLoader]
- private void load(TextureStore textures)
- {
- Sprite.Texture = Beatmap?.Background ?? textures.Get(@"Backgrounds/bg1");
- }
- }
-
public class DimmableBackground : UserDimContainer
{
///
diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs
index 2d7fe6a6a3..a8ba17ef49 100644
--- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs
+++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs
@@ -6,6 +6,8 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Threading;
+using osu.Game.Beatmaps;
+using osu.Game.Configuration;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Online.API;
using osu.Game.Skinning;
@@ -24,6 +26,10 @@ namespace osu.Game.Screens.Backgrounds
private Bindable user;
private Bindable skin;
+ private Bindable mode;
+
+ [Resolved]
+ private IBindable beatmap { get; set; }
public BackgroundScreenDefault(bool animateOnEnter = true)
: base(animateOnEnter)
@@ -31,13 +37,15 @@ namespace osu.Game.Screens.Backgrounds
}
[BackgroundDependencyLoader]
- private void load(IAPIProvider api, SkinManager skinManager)
+ private void load(IAPIProvider api, SkinManager skinManager, OsuConfigManager config)
{
user = api.LocalUser.GetBoundCopy();
skin = skinManager.CurrentSkin.GetBoundCopy();
+ mode = config.GetBindable(OsuSetting.BackgroundMode);
user.ValueChanged += _ => Next();
skin.ValueChanged += _ => Next();
+ mode.ValueChanged += _ => Next();
currentDisplay = RNG.Next(0, background_count);
@@ -66,9 +74,28 @@ namespace osu.Game.Screens.Backgrounds
Background newBackground;
if (user.Value?.IsSupporter ?? false)
- newBackground = new SkinnedBackground(skin.Value, backgroundName);
+ {
+ switch (mode.Value)
+ {
+ case BackgroundMode.Beatmap:
+ newBackground = new BeatmapBackground(beatmap.Value, backgroundName);
+ break;
+
+ default:
+ newBackground = new SkinnedBackground(skin.Value, backgroundName);
+ break;
+ }
+ }
else
- newBackground = new Background(backgroundName);
+ {
+ switch (mode.Value)
+ {
+ case BackgroundMode.Seasonal:
+ default:
+ newBackground = new Background(backgroundName);
+ break;
+ }
+ }
newBackground.Depth = currentDisplay;
From 03947e5b8532b21f52dcc73f755b2d31c64c000b Mon Sep 17 00:00:00 2001
From: LeNitrous
Date: Tue, 24 Sep 2019 19:49:46 +0800
Subject: [PATCH 042/901] change background for ScalingContainer
---
osu.Game/Graphics/Containers/ScalingContainer.cs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/osu.Game/Graphics/Containers/ScalingContainer.cs b/osu.Game/Graphics/Containers/ScalingContainer.cs
index 8f07c3a656..84053ee5d9 100644
--- a/osu.Game/Graphics/Containers/ScalingContainer.cs
+++ b/osu.Game/Graphics/Containers/ScalingContainer.cs
@@ -6,6 +6,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
+using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Screens;
using osu.Game.Screens.Backgrounds;
@@ -154,6 +155,15 @@ namespace osu.Game.Graphics.Containers
private class ScalingBackgroundScreen : BackgroundScreenDefault
{
+ private Bindable beatmap;
+
+ [BackgroundDependencyLoader]
+ private void load(IBindable beatmap)
+ {
+ this.beatmap = (Bindable)beatmap;
+ this.beatmap.ValueChanged += _ => Next();
+ }
+
public override void OnEntering(IScreen last)
{
this.FadeInFromZero(4000, Easing.OutQuint);
From 0bc59e17dc30cfd240407cc3d9fc4928c55b6daa Mon Sep 17 00:00:00 2001
From: LeNitrous
Date: Tue, 24 Sep 2019 21:56:32 +0800
Subject: [PATCH 043/901] remove Seasonal and apply suggestions
---
osu.Game/Configuration/BackgroundMode.cs | 1 -
osu.Game/Graphics/Containers/ScalingContainer.cs | 4 +---
.../Screens/Backgrounds/BackgroundScreenDefault.cs | 10 +---------
3 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/osu.Game/Configuration/BackgroundMode.cs b/osu.Game/Configuration/BackgroundMode.cs
index 21554891ca..50d54f1eb2 100644
--- a/osu.Game/Configuration/BackgroundMode.cs
+++ b/osu.Game/Configuration/BackgroundMode.cs
@@ -6,7 +6,6 @@ namespace osu.Game.Configuration
public enum BackgroundMode
{
Default,
- Seasonal,
Beatmap
}
}
diff --git a/osu.Game/Graphics/Containers/ScalingContainer.cs b/osu.Game/Graphics/Containers/ScalingContainer.cs
index 84053ee5d9..1701223f44 100644
--- a/osu.Game/Graphics/Containers/ScalingContainer.cs
+++ b/osu.Game/Graphics/Containers/ScalingContainer.cs
@@ -155,13 +155,11 @@ namespace osu.Game.Graphics.Containers
private class ScalingBackgroundScreen : BackgroundScreenDefault
{
- private Bindable beatmap;
[BackgroundDependencyLoader]
private void load(IBindable beatmap)
{
- this.beatmap = (Bindable)beatmap;
- this.beatmap.ValueChanged += _ => Next();
+ beatmap.ValueChanged += _ => Next();
}
public override void OnEntering(IScreen last)
diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs
index a8ba17ef49..93590b0543 100644
--- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs
+++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs
@@ -87,15 +87,7 @@ namespace osu.Game.Screens.Backgrounds
}
}
else
- {
- switch (mode.Value)
- {
- case BackgroundMode.Seasonal:
- default:
- newBackground = new Background(backgroundName);
- break;
- }
- }
+ newBackground = new Background(backgroundName);
newBackground.Depth = currentDisplay;
From 851e42a444d642ed08e3505f5314398db8401a67 Mon Sep 17 00:00:00 2001
From: LeNitrous
Date: Tue, 24 Sep 2019 22:57:29 +0800
Subject: [PATCH 044/901] avoid memory leak
---
osu.Game/Graphics/Containers/ScalingContainer.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Graphics/Containers/ScalingContainer.cs b/osu.Game/Graphics/Containers/ScalingContainer.cs
index 1701223f44..023d295b08 100644
--- a/osu.Game/Graphics/Containers/ScalingContainer.cs
+++ b/osu.Game/Graphics/Containers/ScalingContainer.cs
@@ -155,11 +155,13 @@ namespace osu.Game.Graphics.Containers
private class ScalingBackgroundScreen : BackgroundScreenDefault
{
+ private IBindable beatmap;
[BackgroundDependencyLoader]
private void load(IBindable beatmap)
{
- beatmap.ValueChanged += _ => Next();
+ this.beatmap = beatmap.GetBoundCopy();
+ this.beatmap.ValueChanged += _ => Next();
}
public override void OnEntering(IScreen last)
From 2a395956aa4278f7eca532049c88947599f8171e Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Fri, 27 Sep 2019 19:00:17 +0300
Subject: [PATCH 045/901] Merge dependencies
---
.../UserInterface/TestSceneMetricNumbers.cs | 58 +++++++++++++++++++
.../API/Requests/GetCountryRankingsRequest.cs | 18 ++++++
.../Online/API/Requests/GetRankingsRequest.cs | 34 +++++++++++
.../API/Requests/GetUserRankingsRequest.cs | 40 +++++++++++++
.../Requests/Responses/APICountryRankings.cs | 14 +++++
.../API/Requests/Responses/APIUserRankings.cs | 14 +++++
osu.Game/Users/CountryStatistics.cs | 25 ++++++++
osu.Game/Utils/HumanizerUtils.cs | 27 +++++++++
8 files changed, 230 insertions(+)
create mode 100644 osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs
create mode 100644 osu.Game/Online/API/Requests/GetCountryRankingsRequest.cs
create mode 100644 osu.Game/Online/API/Requests/GetRankingsRequest.cs
create mode 100644 osu.Game/Online/API/Requests/GetUserRankingsRequest.cs
create mode 100644 osu.Game/Online/API/Requests/Responses/APICountryRankings.cs
create mode 100644 osu.Game/Online/API/Requests/Responses/APIUserRankings.cs
create mode 100644 osu.Game/Users/CountryStatistics.cs
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs
new file mode 100644
index 0000000000..74470f22fc
--- /dev/null
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs
@@ -0,0 +1,58 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Cursor;
+using osu.Framework.Graphics.Sprites;
+using osu.Game.Utils;
+
+namespace osu.Game.Tests.Visual.UserInterface
+{
+ public class TestSceneMetricNumbers : OsuTestScene
+ {
+ public TestSceneMetricNumbers()
+ {
+ Child = new FillFlowContainer
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Vertical,
+ Children = new Drawable[]
+ {
+ new DrawableNumber(0),
+ new DrawableNumber(1001),
+ new DrawableNumber(999_999),
+ new DrawableNumber(1_000_000),
+ new DrawableNumber(845_006_456),
+ new DrawableNumber(999_999_999),
+ new DrawableNumber(1_000_000_000),
+ new DrawableNumber(7_875_454_545),
+ new DrawableNumber(999_999_999_999),
+ new DrawableNumber(1_000_000_000_000),
+ new DrawableNumber(687_545_454_554_545),
+ new DrawableNumber(999_999_999_999_999),
+ new DrawableNumber(1_000_000_000_000_000),
+ new DrawableNumber(587_545_454_554_545_455),
+ new DrawableNumber(999_999_999_999_999_999),
+ new DrawableNumber(1_000_000_000_000_000_000),
+ new DrawableNumber(long.MaxValue),
+ }
+ };
+ }
+
+ private class DrawableNumber : SpriteText, IHasTooltip
+ {
+ public string TooltipText => value.ToString("F0");
+
+ private readonly long value;
+
+ public DrawableNumber(long value)
+ {
+ this.value = value;
+ Text = HumanizerUtils.ToMetric(value);
+ }
+ }
+ }
+}
diff --git a/osu.Game/Online/API/Requests/GetCountryRankingsRequest.cs b/osu.Game/Online/API/Requests/GetCountryRankingsRequest.cs
new file mode 100644
index 0000000000..3bd772732f
--- /dev/null
+++ b/osu.Game/Online/API/Requests/GetCountryRankingsRequest.cs
@@ -0,0 +1,18 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Rulesets;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class GetCountryRankingsRequest : GetRankingsRequest
+ {
+ public GetCountryRankingsRequest(RulesetInfo ruleset, int page = 1)
+ : base(ruleset, page)
+ {
+ }
+
+ protected override string TargetPostfix() => "country";
+ }
+}
diff --git a/osu.Game/Online/API/Requests/GetRankingsRequest.cs b/osu.Game/Online/API/Requests/GetRankingsRequest.cs
new file mode 100644
index 0000000000..efaaa2cb40
--- /dev/null
+++ b/osu.Game/Online/API/Requests/GetRankingsRequest.cs
@@ -0,0 +1,34 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.IO.Network;
+using osu.Game.Rulesets;
+using System.Collections.Generic;
+
+namespace osu.Game.Online.API.Requests
+{
+ public abstract class GetRankingsRequest : APIRequest>
+ {
+ private readonly RulesetInfo ruleset;
+ private readonly int page;
+
+ protected GetRankingsRequest(RulesetInfo ruleset, int page = 1)
+ {
+ this.ruleset = ruleset;
+ this.page = page;
+ }
+
+ protected override WebRequest CreateWebRequest()
+ {
+ var req = base.CreateWebRequest();
+
+ req.AddParameter("page", page.ToString());
+
+ return req;
+ }
+
+ protected override string Target => $"rankings/{ruleset.ShortName}/{TargetPostfix()}";
+
+ protected abstract string TargetPostfix();
+ }
+}
diff --git a/osu.Game/Online/API/Requests/GetUserRankingsRequest.cs b/osu.Game/Online/API/Requests/GetUserRankingsRequest.cs
new file mode 100644
index 0000000000..bbba6a210d
--- /dev/null
+++ b/osu.Game/Online/API/Requests/GetUserRankingsRequest.cs
@@ -0,0 +1,40 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.IO.Network;
+using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Rulesets;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class GetUserRankingsRequest : GetRankingsRequest
+ {
+ private readonly string country;
+ private readonly UserRankingsType type;
+
+ public GetUserRankingsRequest(RulesetInfo ruleset, UserRankingsType type = UserRankingsType.Performance, int page = 1, string country = null)
+ : base(ruleset, page)
+ {
+ this.type = type;
+ this.country = country;
+ }
+
+ protected override WebRequest CreateWebRequest()
+ {
+ var req = base.CreateWebRequest();
+
+ if (country != null)
+ req.AddParameter("country", country);
+
+ return req;
+ }
+
+ protected override string TargetPostfix() => type.ToString().ToLowerInvariant();
+ }
+
+ public enum UserRankingsType
+ {
+ Performance,
+ Score
+ }
+}
diff --git a/osu.Game/Online/API/Requests/Responses/APICountryRankings.cs b/osu.Game/Online/API/Requests/Responses/APICountryRankings.cs
new file mode 100644
index 0000000000..91086876a9
--- /dev/null
+++ b/osu.Game/Online/API/Requests/Responses/APICountryRankings.cs
@@ -0,0 +1,14 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using Newtonsoft.Json;
+using osu.Game.Users;
+
+namespace osu.Game.Online.API.Requests.Responses
+{
+ public class APICountryRankings : CountryStatistics
+ {
+ [JsonProperty]
+ public Country Country;
+ }
+}
diff --git a/osu.Game/Online/API/Requests/Responses/APIUserRankings.cs b/osu.Game/Online/API/Requests/Responses/APIUserRankings.cs
new file mode 100644
index 0000000000..1cdb6ecb8c
--- /dev/null
+++ b/osu.Game/Online/API/Requests/Responses/APIUserRankings.cs
@@ -0,0 +1,14 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using Newtonsoft.Json;
+using osu.Game.Users;
+
+namespace osu.Game.Online.API.Requests.Responses
+{
+ public class APIUserRankings : UserStatistics
+ {
+ [JsonProperty]
+ public User User;
+ }
+}
diff --git a/osu.Game/Users/CountryStatistics.cs b/osu.Game/Users/CountryStatistics.cs
new file mode 100644
index 0000000000..53fa70f0d4
--- /dev/null
+++ b/osu.Game/Users/CountryStatistics.cs
@@ -0,0 +1,25 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using Newtonsoft.Json;
+
+namespace osu.Game.Users
+{
+ public class CountryStatistics
+ {
+ [JsonProperty(@"code")]
+ public string FlagName;
+
+ [JsonProperty(@"active_users")]
+ public long ActiveUsers;
+
+ [JsonProperty(@"play_count")]
+ public long PlayCount;
+
+ [JsonProperty(@"ranked_score")]
+ public long RankedScore;
+
+ [JsonProperty(@"performance")]
+ public long Performance;
+ }
+}
diff --git a/osu.Game/Utils/HumanizerUtils.cs b/osu.Game/Utils/HumanizerUtils.cs
index 5b7c3630d9..ee6f6f95a3 100644
--- a/osu.Game/Utils/HumanizerUtils.cs
+++ b/osu.Game/Utils/HumanizerUtils.cs
@@ -26,5 +26,32 @@ namespace osu.Game.Utils
return input.Humanize(culture: new CultureInfo("en-US"));
}
}
+
+ ///
+ /// Turns the current or provided big number into a readable string.
+ ///
+ /// The number to be humanized.
+ /// Simplified number with a suffix.
+ public static string ToMetric(long input)
+ {
+ const int k = 1000;
+
+ if (input < k)
+ return input.ToString();
+
+ int i = (int)Math.Floor(Math.Round(Math.Log(input, k)));
+ return $"{input / Math.Pow(k, i):F} {suffixes[i]}";
+ }
+
+ private static readonly string[] suffixes = new[]
+ {
+ "",
+ "k",
+ "million",
+ "billion",
+ "trillion",
+ "quadrillion",
+ "quintillion",
+ };
}
}
From bbaf21a69d0d025019e8cd9035485e473e0006d4 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Fri, 27 Sep 2019 19:33:52 +0300
Subject: [PATCH 046/901] Tables implementation
---
.../Visual/Online/TestSceneRankingsTables.cs | 148 ++++++++++++++++++
.../Rankings/Tables/CountriesTable.cs | 88 +++++++++++
.../Rankings/Tables/PerformanceTable.cs | 102 ++++++++++++
.../Overlays/Rankings/Tables/RankingsTable.cs | 128 +++++++++++++++
.../Overlays/Rankings/Tables/ScoresTable.cs | 108 +++++++++++++
.../Rankings/Tables/TableRowBackground.cs | 56 +++++++
6 files changed, 630 insertions(+)
create mode 100644 osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs
create mode 100644 osu.Game/Overlays/Rankings/Tables/CountriesTable.cs
create mode 100644 osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs
create mode 100644 osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
create mode 100644 osu.Game/Overlays/Rankings/Tables/ScoresTable.cs
create mode 100644 osu.Game/Overlays/Rankings/Tables/TableRowBackground.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs b/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs
new file mode 100644
index 0000000000..08a6da734f
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs
@@ -0,0 +1,148 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Overlays.Rankings.Tables;
+using osu.Framework.Graphics;
+using osu.Game.Online.API.Requests;
+using osu.Game.Rulesets;
+using osu.Game.Graphics.UserInterface;
+using System.Threading;
+using osu.Game.Online.API;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Rulesets.Mania;
+using osu.Game.Rulesets.Taiko;
+using osu.Game.Rulesets.Catch;
+using osu.Framework.Allocation;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ public class TestSceneRankingsTables : OsuTestScene
+ {
+ protected override bool UseOnlineAPI => true;
+
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(PerformanceTable),
+ typeof(ScoresTable),
+ typeof(CountriesTable),
+ typeof(TableRowBackground),
+ };
+
+ [Resolved]
+ private IAPIProvider api { get; set; }
+
+ private readonly BasicScrollContainer scrollFlow;
+ private readonly DimmedLoadingLayer loading;
+ private CancellationTokenSource cancellationToken;
+ private APIRequest request;
+
+ public TestSceneRankingsTables()
+ {
+ Children = new Drawable[]
+ {
+ scrollFlow = new BasicScrollContainer
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ RelativeSizeAxes = Axes.Both,
+ Width = 0.8f,
+ },
+ loading = new DimmedLoadingLayer(),
+ };
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ AddStep("Osu performance", () => createPerformanceTable(new OsuRuleset().RulesetInfo, null));
+ AddStep("Mania scores", () => createScoreTable(new ManiaRuleset().RulesetInfo));
+ AddStep("Taiko country scores", () => createCountryTable(new TaikoRuleset().RulesetInfo));
+ AddStep("Catch US performance page 10", () => createPerformanceTable(new CatchRuleset().RulesetInfo, "US", 10));
+ }
+
+ private void createCountryTable(RulesetInfo ruleset, int page = 1)
+ {
+ loading.Show();
+
+ request?.Cancel();
+ cancellationToken?.Cancel();
+ cancellationToken = new CancellationTokenSource();
+
+ request = new GetCountryRankingsRequest(ruleset, page);
+ ((GetCountryRankingsRequest)request).Success += rankings => Schedule(() =>
+ {
+ var table = new CountriesTable(page)
+ {
+ Rankings = rankings,
+ };
+
+ LoadComponentAsync(table, t =>
+ {
+ scrollFlow.Clear();
+ scrollFlow.Add(t);
+ loading.Hide();
+ }, cancellationToken.Token);
+ });
+
+ api.Queue(request);
+ }
+
+ private void createPerformanceTable(RulesetInfo ruleset, string country, int page = 1)
+ {
+ loading.Show();
+
+ request?.Cancel();
+ cancellationToken?.Cancel();
+ cancellationToken = new CancellationTokenSource();
+
+ request = new GetUserRankingsRequest(ruleset, country: country, page: page);
+ ((GetUserRankingsRequest)request).Success += rankings => Schedule(() =>
+ {
+ var table = new PerformanceTable(page)
+ {
+ Rankings = rankings,
+ };
+
+ LoadComponentAsync(table, t =>
+ {
+ scrollFlow.Clear();
+ scrollFlow.Add(t);
+ loading.Hide();
+ }, cancellationToken.Token);
+ });
+
+ api.Queue(request);
+ }
+
+ private void createScoreTable(RulesetInfo ruleset, int page = 1)
+ {
+ loading.Show();
+
+ request?.Cancel();
+ cancellationToken?.Cancel();
+ cancellationToken = new CancellationTokenSource();
+
+ request = new GetUserRankingsRequest(ruleset, UserRankingsType.Score, page);
+ ((GetUserRankingsRequest)request).Success += rankings => Schedule(() =>
+ {
+ var table = new ScoresTable(page)
+ {
+ Rankings = rankings,
+ };
+
+ LoadComponentAsync(table, t =>
+ {
+ scrollFlow.Clear();
+ scrollFlow.Add(t);
+ loading.Hide();
+ }, cancellationToken.Token);
+ });
+
+ api.Queue(request);
+ }
+ }
+}
diff --git a/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs b/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs
new file mode 100644
index 0000000000..cfd404ff07
--- /dev/null
+++ b/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs
@@ -0,0 +1,88 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Graphics;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Users.Drawables;
+using osuTK;
+using osu.Game.Online.API.Requests.Responses;
+using System;
+
+namespace osu.Game.Overlays.Rankings.Tables
+{
+ public class CountriesTable : RankingsTable
+ {
+ public CountriesTable(int page = 1)
+ : base(page)
+ {
+ }
+
+ protected override TableColumn[] CreateHeaders() => new[]
+ {
+ new TableColumn("", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)), // place
+ new TableColumn("", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed)), // flag and country name
+ new TableColumn("Active Users", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 100)),
+ new TableColumn("Play Count", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 100)),
+ new TableColumn("Ranked Score", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 100)),
+ new TableColumn("Avg. Score", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 100)),
+ new TableColumn("Performance", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 80)),
+ new TableColumn("Avg. Perf.", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)),
+ };
+
+ protected override Drawable[] CreateContent(int index, APICountryRankings item) => new Drawable[]
+ {
+ new OsuSpriteText
+ {
+ Text = $"#{index + 1}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold)
+ },
+ new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(7, 0),
+ Children = new Drawable[]
+ {
+ new UpdateableFlag(item.Country)
+ {
+ Size = new Vector2(20, 13),
+ ShowPlaceholderOnNull = false,
+ },
+ new OsuSpriteText
+ {
+ Text = $@"{item.Country.FullName}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ }
+ }
+ },
+ new ColoredText
+ {
+ Text = $@"{item.ActiveUsers:N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredMetricNumber(item.PlayCount)
+ {
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredMetricNumber(item.RankedScore)
+ {
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredMetricNumber(item.RankedScore / Math.Max(item.ActiveUsers, 1))
+ {
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new MetricNumber(item.Performance)
+ {
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredText
+ {
+ Text = $@"{item.Performance / Math.Max(item.ActiveUsers, 1):N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ }
+ };
+ }
+}
diff --git a/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs b/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs
new file mode 100644
index 0000000000..eab3e67f39
--- /dev/null
+++ b/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs
@@ -0,0 +1,102 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using System.Collections.Generic;
+using osu.Game.Graphics;
+using osu.Game.Graphics.Containers;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Users.Drawables;
+using osuTK;
+using osu.Game.Online.API.Requests.Responses;
+
+namespace osu.Game.Overlays.Rankings.Tables
+{
+ public class PerformanceTable : RankingsTable
+ {
+ public PerformanceTable(int page = 1)
+ : base(page)
+ {
+ }
+
+ protected override TableColumn[] CreateHeaders() => new[]
+ {
+ new TableColumn("", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)), // place
+ new TableColumn("", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed)), // flag and username
+ new TableColumn("Accuracy", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 80)),
+ new TableColumn("Play Count", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 80)),
+ new TableColumn("Performance", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 80)),
+ new TableColumn("SS", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)),
+ new TableColumn("S", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)),
+ new TableColumn("A", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)),
+ };
+
+ protected override Drawable[] CreateContent(int index, APIUserRankings item)
+ {
+ var content = new List
+ {
+ new OsuSpriteText
+ {
+ Text = $"#{index + 1}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold)
+ },
+ };
+
+ var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE)) { AutoSizeAxes = Axes.Both };
+ username.AddUserLink(item.User);
+
+ content.Add(new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(7, 0),
+ Children = new Drawable[]
+ {
+ new UpdateableFlag(item.User.Country)
+ {
+ Size = new Vector2(20, 13),
+ ShowPlaceholderOnNull = false,
+ },
+ username
+ }
+ });
+
+ content.AddRange(new Drawable[]
+ {
+ new ColoredText
+ {
+ Text = $@"{item.Accuracy:F2}%",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredText
+ {
+ Text = $@"{item.PlayCount:N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new OsuSpriteText
+ {
+ Text = $@"{item.PP:N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredText
+ {
+ Text = $@"{item.GradesCount.SS + item.GradesCount.SSPlus:N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredText
+ {
+ Text = $@"{item.GradesCount.S + item.GradesCount.SPlus:N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredText
+ {
+ Text = $@"{item.GradesCount.A:N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ });
+
+ return content.ToArray();
+ }
+ }
+}
diff --git a/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs b/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
new file mode 100644
index 0000000000..0734004913
--- /dev/null
+++ b/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
@@ -0,0 +1,128 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using System.Collections.Generic;
+using System.Linq;
+using osu.Framework.Allocation;
+using osu.Framework.Extensions;
+using osu.Game.Graphics;
+using osu.Game.Graphics.Sprites;
+using osu.Framework.Extensions.IEnumerableExtensions;
+using osu.Framework.Graphics.Cursor;
+using osu.Game.Utils;
+
+namespace osu.Game.Overlays.Rankings.Tables
+{
+ public abstract class RankingsTable : TableContainer
+ {
+ protected const int TEXT_SIZE = 14;
+ private const float horizontal_inset = 20;
+ private const float row_height = 25;
+ private const int items_per_page = 50;
+
+ private readonly int page;
+ private readonly FillFlowContainer backgroundFlow;
+
+ public IReadOnlyList Rankings
+ {
+ set
+ {
+ Content = null;
+ backgroundFlow.Clear();
+
+ if (value?.Any() != true)
+ return;
+
+ value.ForEach(_ => backgroundFlow.Add(new TableRowBackground()));
+
+ Columns = CreateHeaders();
+ Content = value.Select((s, i) => CreateContent(page * items_per_page - (items_per_page - i), s)).ToArray().ToRectangular();
+ }
+ }
+
+ protected RankingsTable(int page)
+ {
+ this.page = page;
+
+ RelativeSizeAxes = Axes.X;
+ AutoSizeAxes = Axes.Y;
+
+ Padding = new MarginPadding { Horizontal = horizontal_inset };
+ RowSize = new Dimension(GridSizeMode.Absolute, row_height);
+
+ AddInternal(backgroundFlow = new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Depth = 1f,
+ Margin = new MarginPadding { Top = row_height }
+ });
+ }
+
+ protected abstract TableColumn[] CreateHeaders();
+
+ protected abstract Drawable[] CreateContent(int index, TModel item);
+
+ protected override Drawable CreateHeader(int index, TableColumn column) => new HeaderText(column?.Header ?? string.Empty, HighlightedColumn());
+
+ protected virtual string HighlightedColumn() => @"Performance";
+
+ private class HeaderText : OsuSpriteText
+ {
+ private readonly string highlighted;
+
+ public HeaderText(string text, string highlighted)
+ {
+ this.highlighted = highlighted;
+
+ Text = text;
+ Font = OsuFont.GetFont(size: 12);
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ if (Text != highlighted)
+ Colour = colours.GreySeafoamLighter;
+ }
+ }
+
+ protected class MetricNumber : OsuSpriteText, IHasTooltip
+ {
+ public string TooltipText => $"{value:N0}";
+
+ private readonly long value;
+
+ public MetricNumber(long value)
+ {
+ this.value = value;
+
+ Text = HumanizerUtils.ToMetric(value);
+ }
+ }
+
+ protected class ColoredMetricNumber : MetricNumber
+ {
+ public ColoredMetricNumber(long value)
+ : base(value)
+ {
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ Colour = colours.GreySeafoamLighter;
+ }
+ }
+
+ protected class ColoredText : OsuSpriteText
+ {
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ Colour = colours.GreySeafoamLighter;
+ }
+ }
+ }
+}
diff --git a/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs b/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs
new file mode 100644
index 0000000000..561b08472b
--- /dev/null
+++ b/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs
@@ -0,0 +1,108 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Graphics;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Users.Drawables;
+using osuTK;
+using osu.Game.Online.API.Requests.Responses;
+using System.Collections.Generic;
+using osu.Game.Graphics.Containers;
+
+namespace osu.Game.Overlays.Rankings.Tables
+{
+ public class ScoresTable : RankingsTable
+ {
+ public ScoresTable(int page = 1)
+ : base(page)
+ {
+ }
+
+ protected override TableColumn[] CreateHeaders() => new[]
+ {
+ new TableColumn("", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)), // place
+ new TableColumn("", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed)), // flag and username
+ new TableColumn("Accuracy", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 80)),
+ new TableColumn("Play Count", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 80)),
+ new TableColumn("Total Score", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 100)),
+ new TableColumn("Ranked Score", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 100)),
+ new TableColumn("SS", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 70)),
+ new TableColumn("S", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 70)),
+ new TableColumn("A", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 70)),
+ };
+
+ protected override Drawable[] CreateContent(int index, APIUserRankings item)
+ {
+ var content = new List
+ {
+ new OsuSpriteText
+ {
+ Text = $"#{index + 1}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold)
+ },
+ };
+
+ var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE)) { AutoSizeAxes = Axes.Both };
+ username.AddUserLink(item.User);
+
+ content.Add(new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(7, 0),
+ Children = new Drawable[]
+ {
+ new UpdateableFlag(item.User.Country)
+ {
+ Size = new Vector2(20, 13),
+ ShowPlaceholderOnNull = false,
+ },
+ username
+ }
+ });
+
+ content.AddRange(new Drawable[]
+ {
+ new ColoredText
+ {
+ Text = $@"{item.Accuracy:F2}%",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredText
+ {
+ Text = $@"{item.PlayCount:N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredMetricNumber(item.TotalScore)
+ {
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new MetricNumber(item.RankedScore)
+ {
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredText
+ {
+ Text = $@"{item.GradesCount.SS + item.GradesCount.SSPlus:N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredText
+ {
+ Text = $@"{item.GradesCount.S + item.GradesCount.SPlus:N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ new ColoredText
+ {
+ Text = $@"{item.GradesCount.A:N0}",
+ Font = OsuFont.GetFont(size: TEXT_SIZE),
+ },
+ });
+
+ return content.ToArray();
+ }
+
+ protected override string HighlightedColumn() => @"Ranked Score";
+ }
+}
diff --git a/osu.Game/Overlays/Rankings/Tables/TableRowBackground.cs b/osu.Game/Overlays/Rankings/Tables/TableRowBackground.cs
new file mode 100644
index 0000000000..04e1c22dae
--- /dev/null
+++ b/osu.Game/Overlays/Rankings/Tables/TableRowBackground.cs
@@ -0,0 +1,56 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Framework.Input.Events;
+using osu.Game.Graphics;
+using osuTK.Graphics;
+
+namespace osu.Game.Overlays.Rankings.Tables
+{
+ public class TableRowBackground : CompositeDrawable
+ {
+ private const int fade_duration = 100;
+
+ private readonly Box background;
+
+ private Color4 idleColour;
+ private Color4 hoverColour;
+
+ public TableRowBackground()
+ {
+ RelativeSizeAxes = Axes.X;
+ Height = 25;
+
+ CornerRadius = 3;
+ Masking = true;
+
+ InternalChild = background = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ };
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ background.Colour = idleColour = colours.GreySeafoam;
+ hoverColour = colours.GreySeafoamLight;
+ }
+
+ protected override bool OnHover(HoverEvent e)
+ {
+ background.FadeColour(hoverColour, fade_duration, Easing.OutQuint);
+ return base.OnHover(e);
+ }
+
+ protected override void OnHoverLost(HoverLostEvent e)
+ {
+ background.FadeColour(idleColour, fade_duration, Easing.OutQuint);
+ base.OnHoverLost(e);
+ }
+ }
+}
From 883ee9851af74ae0695e9731df269685f9a7ad70 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Sun, 29 Sep 2019 15:02:33 +0300
Subject: [PATCH 047/901] Update dependencies
---
.../Visual/UserInterface/TestSceneMetricNumbers.cs | 2 +-
osu.Game/Overlays/Rankings/Tables/RankingsTable.cs | 2 +-
osu.Game/Utils/HumanizerUtils.cs | 5 ++---
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs
index 74470f22fc..8e3924e1fb 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs
@@ -51,7 +51,7 @@ namespace osu.Game.Tests.Visual.UserInterface
public DrawableNumber(long value)
{
this.value = value;
- Text = HumanizerUtils.ToMetric(value);
+ Text = HumanizerUtils.ToReadableString(value);
}
}
}
diff --git a/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs b/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
index 0734004913..d05d642051 100644
--- a/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
+++ b/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
@@ -98,7 +98,7 @@ namespace osu.Game.Overlays.Rankings.Tables
{
this.value = value;
- Text = HumanizerUtils.ToMetric(value);
+ Text = HumanizerUtils.ToReadableString(value);
}
}
diff --git a/osu.Game/Utils/HumanizerUtils.cs b/osu.Game/Utils/HumanizerUtils.cs
index ee6f6f95a3..bc710a799d 100644
--- a/osu.Game/Utils/HumanizerUtils.cs
+++ b/osu.Game/Utils/HumanizerUtils.cs
@@ -32,7 +32,7 @@ namespace osu.Game.Utils
///
/// The number to be humanized.
/// Simplified number with a suffix.
- public static string ToMetric(long input)
+ public static string ToReadableString(long input)
{
const int k = 1000;
@@ -42,8 +42,7 @@ namespace osu.Game.Utils
int i = (int)Math.Floor(Math.Round(Math.Log(input, k)));
return $"{input / Math.Pow(k, i):F} {suffixes[i]}";
}
-
- private static readonly string[] suffixes = new[]
+ private static readonly string[] suffixes =
{
"",
"k",
From 138e65d7a49c0d9df0c5648148bc8e490b40542f Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Sun, 29 Sep 2019 15:15:41 +0300
Subject: [PATCH 048/901] Add missing blank line
---
osu.Game/Utils/HumanizerUtils.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/osu.Game/Utils/HumanizerUtils.cs b/osu.Game/Utils/HumanizerUtils.cs
index bc710a799d..9920f7d127 100644
--- a/osu.Game/Utils/HumanizerUtils.cs
+++ b/osu.Game/Utils/HumanizerUtils.cs
@@ -42,6 +42,7 @@ namespace osu.Game.Utils
int i = (int)Math.Floor(Math.Round(Math.Log(input, k)));
return $"{input / Math.Pow(k, i):F} {suffixes[i]}";
}
+
private static readonly string[] suffixes =
{
"",
From febe0175cd6f6c3b594e2cf2b8dd2e1b1c59f0e0 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Sun, 29 Sep 2019 15:27:29 +0300
Subject: [PATCH 049/901] Small cleanups
---
.../Rankings/Tables/CountriesTable.cs | 22 ++-------
.../Rankings/Tables/PerformanceTable.cs | 36 ++++++---------
.../Overlays/Rankings/Tables/RankingsTable.cs | 6 +++
.../Overlays/Rankings/Tables/ScoresTable.cs | 46 +++++++------------
4 files changed, 42 insertions(+), 68 deletions(-)
diff --git a/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs b/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs
index cfd404ff07..96ff506814 100644
--- a/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs
+++ b/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs
@@ -60,28 +60,14 @@ namespace osu.Game.Overlays.Rankings.Tables
new ColoredText
{
Text = $@"{item.ActiveUsers:N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
- },
- new ColoredMetricNumber(item.PlayCount)
- {
- Font = OsuFont.GetFont(size: TEXT_SIZE),
- },
- new ColoredMetricNumber(item.RankedScore)
- {
- Font = OsuFont.GetFont(size: TEXT_SIZE),
- },
- new ColoredMetricNumber(item.RankedScore / Math.Max(item.ActiveUsers, 1))
- {
- Font = OsuFont.GetFont(size: TEXT_SIZE),
- },
- new MetricNumber(item.Performance)
- {
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
+ new ColoredMetricNumber(item.PlayCount),
+ new ColoredMetricNumber(item.RankedScore),
+ new ColoredMetricNumber(item.RankedScore / Math.Max(item.ActiveUsers, 1)),
+ new MetricNumber(item.Performance),
new ColoredText
{
Text = $@"{item.Performance / Math.Max(item.ActiveUsers, 1):N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
}
};
}
diff --git a/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs b/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs
index eab3e67f39..c79553a3be 100644
--- a/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs
+++ b/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs
@@ -46,33 +46,30 @@ namespace osu.Game.Overlays.Rankings.Tables
var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE)) { AutoSizeAxes = Axes.Both };
username.AddUserLink(item.User);
- content.Add(new FillFlowContainer
- {
- AutoSizeAxes = Axes.Both,
- Direction = FillDirection.Horizontal,
- Spacing = new Vector2(7, 0),
- Children = new Drawable[]
- {
- new UpdateableFlag(item.User.Country)
- {
- Size = new Vector2(20, 13),
- ShowPlaceholderOnNull = false,
- },
- username
- }
- });
-
content.AddRange(new Drawable[]
{
+ new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(7, 0),
+ Children = new Drawable[]
+ {
+ new UpdateableFlag(item.User.Country)
+ {
+ Size = new Vector2(20, 13),
+ ShowPlaceholderOnNull = false,
+ },
+ username
+ }
+ },
new ColoredText
{
Text = $@"{item.Accuracy:F2}%",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
new ColoredText
{
Text = $@"{item.PlayCount:N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
new OsuSpriteText
{
@@ -82,17 +79,14 @@ namespace osu.Game.Overlays.Rankings.Tables
new ColoredText
{
Text = $@"{item.GradesCount.SS + item.GradesCount.SSPlus:N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
new ColoredText
{
Text = $@"{item.GradesCount.S + item.GradesCount.SPlus:N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
new ColoredText
{
Text = $@"{item.GradesCount.A:N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
});
diff --git a/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs b/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
index d05d642051..6c53a9fa74 100644
--- a/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
+++ b/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
@@ -99,6 +99,7 @@ namespace osu.Game.Overlays.Rankings.Tables
this.value = value;
Text = HumanizerUtils.ToReadableString(value);
+ Font = OsuFont.GetFont(size: TEXT_SIZE);
}
}
@@ -118,6 +119,11 @@ namespace osu.Game.Overlays.Rankings.Tables
protected class ColoredText : OsuSpriteText
{
+ public ColoredText()
+ {
+ Font = OsuFont.GetFont(size: TEXT_SIZE);
+ }
+
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
diff --git a/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs b/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs
index 561b08472b..1c8b474689 100644
--- a/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs
+++ b/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs
@@ -47,56 +47,44 @@ namespace osu.Game.Overlays.Rankings.Tables
var username = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: TEXT_SIZE)) { AutoSizeAxes = Axes.Both };
username.AddUserLink(item.User);
- content.Add(new FillFlowContainer
- {
- AutoSizeAxes = Axes.Both,
- Direction = FillDirection.Horizontal,
- Spacing = new Vector2(7, 0),
- Children = new Drawable[]
- {
- new UpdateableFlag(item.User.Country)
- {
- Size = new Vector2(20, 13),
- ShowPlaceholderOnNull = false,
- },
- username
- }
- });
-
content.AddRange(new Drawable[]
{
+ new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(7, 0),
+ Children = new Drawable[]
+ {
+ new UpdateableFlag(item.User.Country)
+ {
+ Size = new Vector2(20, 13),
+ ShowPlaceholderOnNull = false,
+ },
+ username
+ }
+ },
new ColoredText
{
Text = $@"{item.Accuracy:F2}%",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
new ColoredText
{
Text = $@"{item.PlayCount:N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
- },
- new ColoredMetricNumber(item.TotalScore)
- {
- Font = OsuFont.GetFont(size: TEXT_SIZE),
- },
- new MetricNumber(item.RankedScore)
- {
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
+ new ColoredMetricNumber(item.TotalScore),
+ new MetricNumber(item.RankedScore),
new ColoredText
{
Text = $@"{item.GradesCount.SS + item.GradesCount.SSPlus:N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
new ColoredText
{
Text = $@"{item.GradesCount.S + item.GradesCount.SPlus:N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
new ColoredText
{
Text = $@"{item.GradesCount.A:N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
});
From 42d1379848fa03611cda80eb2336838ddf3165d3 Mon Sep 17 00:00:00 2001
From: miterosan
Date: Sun, 29 Sep 2019 20:40:10 +0200
Subject: [PATCH 050/901] Load the rulesets lasily
---
osu.Game/Rulesets/RulesetStore.cs | 95 ++++++++++++++++---------------
1 file changed, 49 insertions(+), 46 deletions(-)
diff --git a/osu.Game/Rulesets/RulesetStore.cs b/osu.Game/Rulesets/RulesetStore.cs
index 2d8c9f5b49..6392f982fb 100644
--- a/osu.Game/Rulesets/RulesetStore.cs
+++ b/osu.Game/Rulesets/RulesetStore.cs
@@ -16,17 +16,11 @@ namespace osu.Game.Rulesets
///
public class RulesetStore : DatabaseBackedStore
{
- private static readonly Dictionary loaded_assemblies = new Dictionary();
+ private static readonly Lazy> loaded_assemblies = new Lazy>(() => loadRulesets());
static RulesetStore()
{
AppDomain.CurrentDomain.AssemblyResolve += currentDomain_AssemblyResolve;
-
- // On android in release configuration assemblies are loaded from the apk directly into memory.
- // We cannot read assemblies from cwd, so should check loaded assemblies instead.
- loadFromAppDomain();
-
- loadFromDisk();
}
public RulesetStore(IDatabaseContextFactory factory)
@@ -54,7 +48,7 @@ namespace osu.Game.Rulesets
///
public IEnumerable AvailableRulesets { get; private set; }
- private static Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args) => loaded_assemblies.Keys.FirstOrDefault(a => a.FullName == args.Name);
+ private static Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args) => loaded_assemblies.Value.Keys.FirstOrDefault(a => a.FullName == args.Name);
private const string ruleset_library_prefix = "osu.Game.Rulesets";
@@ -64,7 +58,7 @@ namespace osu.Game.Rulesets
{
var context = usage.Context;
- var instances = loaded_assemblies.Values.Select(r => (Ruleset)Activator.CreateInstance(r, (RulesetInfo)null)).ToList();
+ var instances = loaded_assemblies.Value.Values.Select(r => (Ruleset)Activator.CreateInstance(r, (RulesetInfo)null)).ToList();
//add all legacy modes in correct order
foreach (var r in instances.Where(r => r.LegacyID != null).OrderBy(r => r.LegacyID))
@@ -113,8 +107,39 @@ namespace osu.Game.Rulesets
}
}
- private static void loadFromAppDomain()
+ ///
+ /// Loads the rulesets that are in the current appdomain an in the current directory.
+ ///
+ /// The rulesets that were loaded.
+ private static Dictionary loadRulesets()
{
+ var rulesets = new Dictionary();
+
+ foreach (var rulesetAssembly in getRulesetAssemblies())
+ {
+ try
+ {
+ rulesets[rulesetAssembly] = rulesetAssembly.GetTypes().First(t => t.IsPublic && t.IsSubclassOf(typeof(Ruleset)));
+ }
+ catch (Exception e)
+ {
+ Logger.Error(e, $"Failed to add ruleset {rulesetAssembly}");
+ }
+ }
+
+ return rulesets;
+ }
+
+ ///
+ /// Scans the current appdomain and current directory for ruleset assemblies.
+ /// Rulesets that were found in the current directory are automaticly loaded.
+ ///
+ /// The ruleset assemblies that were found in the current appdomain or in the current directory.
+ private static IEnumerable getRulesetAssemblies()
+ {
+ var rulesetAssemblies = new HashSet();
+
+ // load from appdomain
foreach (var ruleset in AppDomain.CurrentDomain.GetAssemblies())
{
string rulesetName = ruleset.GetName().Name;
@@ -122,55 +147,33 @@ namespace osu.Game.Rulesets
if (!rulesetName.StartsWith(ruleset_library_prefix, StringComparison.InvariantCultureIgnoreCase) || ruleset.GetName().Name.Contains("Tests"))
continue;
- addRuleset(ruleset);
+ rulesetAssemblies.Add(ruleset);
}
- }
- private static void loadFromDisk()
- {
+ // load from current directory
try
{
string[] files = Directory.GetFiles(Environment.CurrentDirectory, $"{ruleset_library_prefix}.*.dll");
foreach (string file in files.Where(f => !Path.GetFileName(f).Contains("Tests")))
- loadRulesetFromFile(file);
+ {
+ try
+ {
+ rulesetAssemblies.Add(Assembly.LoadFrom(file));
+ }
+ catch (Exception e)
+ {
+ Logger.Error(e, $"Failed to load ruleset assembly {Path.GetFileNameWithoutExtension(file)}");
+ return null;
+ }
+ }
}
catch
{
Logger.Log($"Could not load rulesets from directory {Environment.CurrentDirectory}");
}
- }
- private static void loadRulesetFromFile(string file)
- {
- var filename = Path.GetFileNameWithoutExtension(file);
-
- if (loaded_assemblies.Values.Any(t => t.Namespace == filename))
- return;
-
- try
- {
- addRuleset(Assembly.LoadFrom(file));
- }
- catch (Exception e)
- {
- Logger.Error(e, $"Failed to load ruleset {filename}");
- }
- }
-
- private static void addRuleset(Assembly assembly)
- {
- if (loaded_assemblies.ContainsKey(assembly))
- return;
-
- try
- {
- loaded_assemblies[assembly] = assembly.GetTypes().First(t => t.IsPublic && t.IsSubclassOf(typeof(Ruleset)));
- }
- catch (Exception e)
- {
- Logger.Error(e, $"Failed to add ruleset {assembly}");
- }
+ return rulesetAssemblies;
}
}
}
From ff477cd56c36eb99a8e238dd0de607fc5f3a6222 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 1 Oct 2019 14:12:03 +0300
Subject: [PATCH 051/901] Remove humanized number dependency
---
.../UserInterface/TestSceneMetricNumbers.cs | 58 -------------------
.../Rankings/Tables/CountriesTable.cs | 27 ++++++---
.../Rankings/Tables/PerformanceTable.cs | 13 ++---
.../Overlays/Rankings/Tables/RankingsTable.cs | 34 +----------
.../Overlays/Rankings/Tables/ScoresTable.cs | 20 ++++---
osu.Game/Utils/HumanizerUtils.cs | 27 ---------
6 files changed, 41 insertions(+), 138 deletions(-)
delete mode 100644 osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs
deleted file mode 100644
index 8e3924e1fb..0000000000
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneMetricNumbers.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
-// See the LICENCE file in the repository root for full licence text.
-
-using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Cursor;
-using osu.Framework.Graphics.Sprites;
-using osu.Game.Utils;
-
-namespace osu.Game.Tests.Visual.UserInterface
-{
- public class TestSceneMetricNumbers : OsuTestScene
- {
- public TestSceneMetricNumbers()
- {
- Child = new FillFlowContainer
- {
- Anchor = Anchor.Centre,
- Origin = Anchor.Centre,
- AutoSizeAxes = Axes.Both,
- Direction = FillDirection.Vertical,
- Children = new Drawable[]
- {
- new DrawableNumber(0),
- new DrawableNumber(1001),
- new DrawableNumber(999_999),
- new DrawableNumber(1_000_000),
- new DrawableNumber(845_006_456),
- new DrawableNumber(999_999_999),
- new DrawableNumber(1_000_000_000),
- new DrawableNumber(7_875_454_545),
- new DrawableNumber(999_999_999_999),
- new DrawableNumber(1_000_000_000_000),
- new DrawableNumber(687_545_454_554_545),
- new DrawableNumber(999_999_999_999_999),
- new DrawableNumber(1_000_000_000_000_000),
- new DrawableNumber(587_545_454_554_545_455),
- new DrawableNumber(999_999_999_999_999_999),
- new DrawableNumber(1_000_000_000_000_000_000),
- new DrawableNumber(long.MaxValue),
- }
- };
- }
-
- private class DrawableNumber : SpriteText, IHasTooltip
- {
- public string TooltipText => value.ToString("F0");
-
- private readonly long value;
-
- public DrawableNumber(long value)
- {
- this.value = value;
- Text = HumanizerUtils.ToReadableString(value);
- }
- }
- }
-}
diff --git a/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs b/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs
index 96ff506814..8e0e55595d 100644
--- a/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs
+++ b/osu.Game/Overlays/Rankings/Tables/CountriesTable.cs
@@ -50,22 +50,33 @@ namespace osu.Game.Overlays.Rankings.Tables
Size = new Vector2(20, 13),
ShowPlaceholderOnNull = false,
},
- new OsuSpriteText
+ new RowText
{
Text = $@"{item.Country.FullName}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
}
}
},
- new ColoredText
+ new ColoredRowText
{
Text = $@"{item.ActiveUsers:N0}",
},
- new ColoredMetricNumber(item.PlayCount),
- new ColoredMetricNumber(item.RankedScore),
- new ColoredMetricNumber(item.RankedScore / Math.Max(item.ActiveUsers, 1)),
- new MetricNumber(item.Performance),
- new ColoredText
+ new ColoredRowText
+ {
+ Text = $@"{item.PlayCount:N0}",
+ },
+ new ColoredRowText
+ {
+ Text = $@"{item.RankedScore:N0}",
+ },
+ new ColoredRowText
+ {
+ Text = $@"{item.RankedScore / Math.Max(item.ActiveUsers, 1):N0}",
+ },
+ new RowText
+ {
+ Text = $@"{item.Performance:N0}",
+ },
+ new ColoredRowText
{
Text = $@"{item.Performance / Math.Max(item.ActiveUsers, 1):N0}",
}
diff --git a/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs b/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs
index c79553a3be..2d582f4321 100644
--- a/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs
+++ b/osu.Game/Overlays/Rankings/Tables/PerformanceTable.cs
@@ -63,28 +63,27 @@ namespace osu.Game.Overlays.Rankings.Tables
username
}
},
- new ColoredText
+ new ColoredRowText
{
Text = $@"{item.Accuracy:F2}%",
},
- new ColoredText
+ new ColoredRowText
{
Text = $@"{item.PlayCount:N0}",
},
- new OsuSpriteText
+ new RowText
{
Text = $@"{item.PP:N0}",
- Font = OsuFont.GetFont(size: TEXT_SIZE),
},
- new ColoredText
+ new ColoredRowText
{
Text = $@"{item.GradesCount.SS + item.GradesCount.SSPlus:N0}",
},
- new ColoredText
+ new ColoredRowText
{
Text = $@"{item.GradesCount.S + item.GradesCount.SPlus:N0}",
},
- new ColoredText
+ new ColoredRowText
{
Text = $@"{item.GradesCount.A:N0}",
},
diff --git a/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs b/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
index 6c53a9fa74..a04e8be9d0 100644
--- a/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
+++ b/osu.Game/Overlays/Rankings/Tables/RankingsTable.cs
@@ -10,8 +10,6 @@ using osu.Framework.Extensions;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Framework.Extensions.IEnumerableExtensions;
-using osu.Framework.Graphics.Cursor;
-using osu.Game.Utils;
namespace osu.Game.Overlays.Rankings.Tables
{
@@ -88,42 +86,16 @@ namespace osu.Game.Overlays.Rankings.Tables
}
}
- protected class MetricNumber : OsuSpriteText, IHasTooltip
+ protected class RowText : OsuSpriteText
{
- public string TooltipText => $"{value:N0}";
-
- private readonly long value;
-
- public MetricNumber(long value)
+ public RowText()
{
- this.value = value;
-
- Text = HumanizerUtils.ToReadableString(value);
Font = OsuFont.GetFont(size: TEXT_SIZE);
}
}
- protected class ColoredMetricNumber : MetricNumber
+ protected class ColoredRowText : RowText
{
- public ColoredMetricNumber(long value)
- : base(value)
- {
- }
-
- [BackgroundDependencyLoader]
- private void load(OsuColour colours)
- {
- Colour = colours.GreySeafoamLighter;
- }
- }
-
- protected class ColoredText : OsuSpriteText
- {
- public ColoredText()
- {
- Font = OsuFont.GetFont(size: TEXT_SIZE);
- }
-
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
diff --git a/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs b/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs
index 1c8b474689..5d572a6af0 100644
--- a/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs
+++ b/osu.Game/Overlays/Rankings/Tables/ScoresTable.cs
@@ -64,25 +64,31 @@ namespace osu.Game.Overlays.Rankings.Tables
username
}
},
- new ColoredText
+ new ColoredRowText
{
Text = $@"{item.Accuracy:F2}%",
},
- new ColoredText
+ new ColoredRowText
{
Text = $@"{item.PlayCount:N0}",
},
- new ColoredMetricNumber(item.TotalScore),
- new MetricNumber(item.RankedScore),
- new ColoredText
+ new ColoredRowText
+ {
+ Text = $@"{item.TotalScore:N0}",
+ },
+ new RowText
+ {
+ Text = $@"{item.RankedScore:N0}",
+ },
+ new ColoredRowText
{
Text = $@"{item.GradesCount.SS + item.GradesCount.SSPlus:N0}",
},
- new ColoredText
+ new ColoredRowText
{
Text = $@"{item.GradesCount.S + item.GradesCount.SPlus:N0}",
},
- new ColoredText
+ new ColoredRowText
{
Text = $@"{item.GradesCount.A:N0}",
},
diff --git a/osu.Game/Utils/HumanizerUtils.cs b/osu.Game/Utils/HumanizerUtils.cs
index 9920f7d127..5b7c3630d9 100644
--- a/osu.Game/Utils/HumanizerUtils.cs
+++ b/osu.Game/Utils/HumanizerUtils.cs
@@ -26,32 +26,5 @@ namespace osu.Game.Utils
return input.Humanize(culture: new CultureInfo("en-US"));
}
}
-
- ///
- /// Turns the current or provided big number into a readable string.
- ///
- /// The number to be humanized.
- /// Simplified number with a suffix.
- public static string ToReadableString(long input)
- {
- const int k = 1000;
-
- if (input < k)
- return input.ToString();
-
- int i = (int)Math.Floor(Math.Round(Math.Log(input, k)));
- return $"{input / Math.Pow(k, i):F} {suffixes[i]}";
- }
-
- private static readonly string[] suffixes =
- {
- "",
- "k",
- "million",
- "billion",
- "trillion",
- "quadrillion",
- "quintillion",
- };
}
}
From 7b414092afd261c953fd9f51f9bdf93632021523 Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Fri, 4 Oct 2019 17:35:41 +0300
Subject: [PATCH 052/901] Implement beatmap ruleset selector
---
.../BeatmapSet/BeatmapRulesetSelector.cs | 50 ++++++
.../BeatmapSet/BeatmapRulesetTabItem.cs | 148 ++++++++++++++++++
2 files changed, 198 insertions(+)
create mode 100644 osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
create mode 100644 osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs
diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
new file mode 100644
index 0000000000..0847272e1f
--- /dev/null
+++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
@@ -0,0 +1,50 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.UserInterface;
+using osu.Game.Beatmaps;
+using osu.Game.Rulesets;
+using osuTK;
+using System.Linq;
+
+namespace osu.Game.Overlays.BeatmapSet
+{
+ public class BeatmapRulesetSelector : RulesetSelector
+ {
+ private BeatmapSetInfo beatmapSet;
+
+ public BeatmapSetInfo BeatmapSet
+ {
+ get => beatmapSet;
+ set
+ {
+ if (value == beatmapSet)
+ return;
+
+ beatmapSet = value;
+
+ foreach (BeatmapRulesetTabItem tab in TabContainer.TabItems)
+ tab.SetBeatmaps(beatmapSet?.Beatmaps.FindAll(b => b.Ruleset.Equals(tab.Value)));
+
+ var firstRuleset = beatmapSet?.Beatmaps.OrderBy(b => b.Ruleset.ID).FirstOrDefault()?.Ruleset;
+ SelectTab(TabContainer.TabItems.FirstOrDefault(t => t.Value.Equals(firstRuleset)));
+ }
+ }
+
+ public BeatmapRulesetSelector()
+ {
+ AutoSizeAxes = Axes.Both;
+ TabContainer.Spacing = new Vector2(10, 0);
+ }
+
+ protected override TabItem CreateTabItem(RulesetInfo value) => new BeatmapRulesetTabItem(value);
+
+ protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
+ {
+ Direction = FillDirection.Horizontal,
+ AutoSizeAxes = Axes.Both,
+ };
+ }
+}
diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs
new file mode 100644
index 0000000000..19c9af13d5
--- /dev/null
+++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs
@@ -0,0 +1,148 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Extensions.Color4Extensions;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Framework.Graphics.UserInterface;
+using osu.Framework.Input.Events;
+using osu.Game.Beatmaps;
+using osu.Game.Graphics;
+using osu.Game.Graphics.Sprites;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Rulesets;
+using osuTK;
+using osuTK.Graphics;
+using System.Collections.Generic;
+using System.Diagnostics;
+
+namespace osu.Game.Overlays.BeatmapSet
+{
+ public class BeatmapRulesetTabItem : TabItem
+ {
+ private readonly OsuSpriteText name, count;
+ private readonly Box bar;
+
+ public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree;
+
+ public BeatmapRulesetTabItem(RulesetInfo value)
+ : base(value)
+ {
+ AutoSizeAxes = Axes.Both;
+ Masking = true;
+
+ FillFlowContainer nameContainer;
+
+ Children = new Drawable[]
+ {
+ nameContainer = new FillFlowContainer
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Margin = new MarginPadding { Bottom = 7.5f },
+ Spacing = new Vector2(2.5f),
+ Children = new Drawable[]
+ {
+ name = new OsuSpriteText
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Text = value.Name,
+ Font = OsuFont.Default.With(size: 18),
+ },
+ new Container
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ AutoSizeAxes = Axes.Both,
+ Masking = true,
+ CornerRadius = 4f,
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4.Black.Opacity(0.5f),
+ },
+ count = new OsuSpriteText
+ {
+ Alpha = 0,
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Margin = new MarginPadding { Horizontal = 5f },
+ Font = OsuFont.Default.With(weight: FontWeight.SemiBold),
+ }
+ }
+ }
+ }
+ },
+ bar = new Box
+ {
+ Anchor = Anchor.BottomCentre,
+ Origin = Anchor.BottomCentre,
+ RelativeSizeAxes = Axes.X,
+ Height = 4f,
+ },
+ new HoverClickSounds(),
+ };
+
+ Enabled.BindValueChanged(v => nameContainer.Alpha = v.NewValue ? 1f : 0.5f, true);
+ }
+
+ [Resolved]
+ private OsuColour colour { get; set; }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ count.Colour = colour.Gray9;
+ bar.Colour = colour.Blue;
+
+ updateState();
+ }
+
+ public void SetBeatmaps(List beatmaps)
+ {
+ Trace.Assert(beatmaps?.TrueForAll(b => b.Ruleset.Equals(Value)) ?? true, "A beatmap has a ruleset not of this tab value");
+
+ count.Text = beatmaps?.Count.ToString();
+
+ var hasBeatmaps = (beatmaps?.Count ?? 0) > 0;
+ count.Alpha = hasBeatmaps ? 1f : 0f;
+ Enabled.Value = hasBeatmaps;
+ }
+
+ private void updateState()
+ {
+ var isHoveredOrActive = IsHovered || Active.Value;
+ name.Colour = isHoveredOrActive ? colour.GrayE : colour.GrayC;
+ bar.MoveToY(isHoveredOrActive ? 0f : bar.Height, 120);
+
+ name.Font = name.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Regular);
+ }
+
+ #region Hovering and activation logic
+
+ protected override void OnActivated() => updateState();
+
+ protected override void OnDeactivated() => updateState();
+
+ protected override bool OnHover(HoverEvent e)
+ {
+ updateState();
+ return false;
+ }
+
+ protected override void OnHoverLost(HoverLostEvent e)
+ {
+ updateState();
+ }
+
+ #endregion
+ }
+}
From edddbdb7845a250002ee5dd111750b3290a29401 Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Fri, 4 Oct 2019 17:37:09 +0300
Subject: [PATCH 053/901] Add tests for beatmap ruleset selector
---
.../Online/TestSceneBeatmapRulesetSelector.cs | 102 ++++++++++++++++++
1 file changed, 102 insertions(+)
create mode 100644 osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs
new file mode 100644
index 0000000000..1f8df438fb
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs
@@ -0,0 +1,102 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics.UserInterface;
+using osu.Game.Beatmaps;
+using osu.Game.Overlays.BeatmapSet;
+using osu.Game.Rulesets;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ public class TestSceneBeatmapRulesetSelector : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(BeatmapRulesetSelector),
+ typeof(BeatmapRulesetTabItem),
+ };
+
+ private readonly TestRulesetSelector selector;
+
+ public TestSceneBeatmapRulesetSelector()
+ {
+ Add(selector = new TestRulesetSelector());
+ }
+
+ [Resolved]
+ private RulesetStore rulesets { get; set; }
+
+ [Test]
+ public void TestMultipleRulesetsBeatmapSet()
+ {
+ var enabledRulesets = rulesets.AvailableRulesets.Skip(1).Take(2);
+
+ AddStep("load multiple rulesets beatmapset", () =>
+ {
+ selector.BeatmapSet = new BeatmapSetInfo
+ {
+ Beatmaps = enabledRulesets.Select(r => new BeatmapInfo { Ruleset = r }).ToList()
+ };
+ });
+
+ var tabItems = selector.TabContainer.TabItems;
+ AddAssert("other rulesets disabled", () => tabItems.Except(tabItems.Where(t => enabledRulesets.Any(r => r.Equals(t.Value)))).All(t => !t.Enabled.Value));
+ AddAssert("left-most ruleset selected", () => tabItems.First(t => t.Enabled.Value).Active.Value);
+ }
+
+ [Test]
+ public void TestSingleRulesetBeatmapSet()
+ {
+ var enabledRuleset = rulesets.AvailableRulesets.Last();
+
+ AddStep("load single ruleset beatmapset", () =>
+ {
+ selector.BeatmapSet = new BeatmapSetInfo
+ {
+ Beatmaps = new List
+ {
+ new BeatmapInfo
+ {
+ Ruleset = enabledRuleset
+ }
+ }
+ };
+ });
+
+ AddAssert("single ruleset selected", () => selector.SelectedTab.Value.Equals(enabledRuleset));
+ }
+
+ [Test]
+ public void TestEmptyBeatmapSet()
+ {
+ AddStep("load empty beatmapset", () => selector.BeatmapSet = new BeatmapSetInfo
+ {
+ Beatmaps = new List()
+ });
+
+ AddAssert("no ruleset selected", () => selector.SelectedTab == null);
+ AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value));
+ }
+
+ [Test]
+ public void TestNullBeatmapSet()
+ {
+ AddStep("load null beatmapset", () => selector.BeatmapSet = null);
+
+ AddAssert("no ruleset selected", () => selector.SelectedTab == null);
+ AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value));
+ }
+
+ private class TestRulesetSelector : BeatmapRulesetSelector
+ {
+ public new TabItem SelectedTab => base.SelectedTab;
+
+ public new TabFillFlowContainer TabContainer => base.TabContainer;
+ }
+ }
+}
From 7d5f5d2fd9272e207bc26860e76f613ce01e38ec Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Fri, 4 Oct 2019 17:55:33 +0300
Subject: [PATCH 054/901] Add ruleset selector to the beatmap overlay header
---
osu.Game/Overlays/BeatmapSet/Header.cs | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs
index 260a989628..0e3d29c25b 100644
--- a/osu.Game/Overlays/BeatmapSet/Header.cs
+++ b/osu.Game/Overlays/BeatmapSet/Header.cs
@@ -3,6 +3,7 @@
using System.Linq;
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
@@ -16,6 +17,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
using osu.Game.Overlays.BeatmapSet.Buttons;
using osu.Game.Overlays.Direct;
+using osu.Game.Rulesets;
using osuTK;
using osuTK.Graphics;
@@ -39,6 +41,7 @@ namespace osu.Game.Overlays.BeatmapSet
public bool DownloadButtonsVisible => downloadButtonsContainer.Any();
+ public readonly BeatmapRulesetSelector RulesetSelector;
public readonly BeatmapPicker Picker;
private readonly FavouriteButton favouriteButton;
@@ -69,12 +72,17 @@ namespace osu.Game.Overlays.BeatmapSet
{
RelativeSizeAxes = Axes.X,
Height = tabs_height,
- Children = new[]
+ Children = new Drawable[]
{
tabsBg = new Box
{
RelativeSizeAxes = Axes.Both,
},
+ RulesetSelector = new BeatmapRulesetSelector
+ {
+ Anchor = Anchor.BottomCentre,
+ Origin = Anchor.BottomCentre,
+ }
},
},
new Container
@@ -214,6 +222,13 @@ namespace osu.Game.Overlays.BeatmapSet
};
}
+ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
+ {
+ var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
+ dependencies.CacheAs>(RulesetSelector.Current);
+ return dependencies;
+ }
+
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@@ -223,7 +238,7 @@ namespace osu.Game.Overlays.BeatmapSet
BeatmapSet.BindValueChanged(setInfo =>
{
- Picker.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue;
+ Picker.BeatmapSet = RulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue;
cover.BeatmapSet = setInfo.NewValue;
if (setInfo.NewValue == null)
From 555c82e9c9077f8e363aebb12e73ff07127aa97f Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Fri, 4 Oct 2019 17:56:42 +0300
Subject: [PATCH 055/901] Filter beatmap difficulties by current ruleset
---
osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs | 25 ++++++++++++-------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs
index 28947b6f22..e7a3d15401 100644
--- a/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs
+++ b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs
@@ -17,6 +17,7 @@ using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
+using osu.Game.Rulesets;
using osuTK;
using osuTK.Graphics;
@@ -27,10 +28,11 @@ namespace osu.Game.Overlays.BeatmapSet
private const float tile_icon_padding = 7;
private const float tile_spacing = 2;
- private readonly DifficultiesContainer difficulties;
private readonly OsuSpriteText version, starRating;
private readonly Statistic plays, favourites;
+ public readonly DifficultiesContainer Difficulties;
+
public readonly Bindable Beatmap = new Bindable();
private BeatmapSetInfo beatmapSet;
@@ -50,11 +52,11 @@ namespace osu.Game.Overlays.BeatmapSet
private void updateDisplay()
{
- difficulties.Clear();
+ Difficulties.Clear();
if (BeatmapSet != null)
{
- difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.OrderBy(beatmap => beatmap.StarDifficulty).Select(b => new DifficultySelectorButton(b)
+ Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.FindAll(b => b.Ruleset.Equals(ruleset.Value)).OrderBy(b => b.StarDifficulty).Select(b => new DifficultySelectorButton(b)
{
State = DifficultySelectorState.NotSelected,
OnHovered = beatmap =>
@@ -68,7 +70,7 @@ namespace osu.Game.Overlays.BeatmapSet
}
starRating.FadeOut(100);
- Beatmap.Value = BeatmapSet?.Beatmaps.FirstOrDefault();
+ Beatmap.Value = Difficulties.FirstOrDefault()?.Beatmap;
plays.Value = BeatmapSet?.OnlineInfo.PlayCount ?? 0;
favourites.Value = BeatmapSet?.OnlineInfo.FavouriteCount ?? 0;
@@ -89,7 +91,7 @@ namespace osu.Game.Overlays.BeatmapSet
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
- difficulties = new DifficultiesContainer
+ Difficulties = new DifficultiesContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@@ -147,6 +149,9 @@ namespace osu.Game.Overlays.BeatmapSet
};
}
+ [Resolved]
+ private IBindable ruleset { get; set; }
+
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@@ -158,6 +163,8 @@ namespace osu.Game.Overlays.BeatmapSet
{
base.LoadComplete();
+ ruleset.ValueChanged += r => updateDisplay();
+
// done here so everything can bind in intialization and get the first trigger
Beatmap.TriggerChange();
}
@@ -169,10 +176,10 @@ namespace osu.Game.Overlays.BeatmapSet
private void updateDifficultyButtons()
{
- difficulties.Children.ToList().ForEach(diff => diff.State = diff.Beatmap == Beatmap.Value ? DifficultySelectorState.Selected : DifficultySelectorState.NotSelected);
+ Difficulties.Children.ToList().ForEach(diff => diff.State = diff.Beatmap == Beatmap.Value ? DifficultySelectorState.Selected : DifficultySelectorState.NotSelected);
}
- private class DifficultiesContainer : FillFlowContainer
+ public class DifficultiesContainer : FillFlowContainer
{
public Action OnLostHover;
@@ -183,7 +190,7 @@ namespace osu.Game.Overlays.BeatmapSet
}
}
- private class DifficultySelectorButton : OsuClickableContainer, IStateful
+ public class DifficultySelectorButton : OsuClickableContainer, IStateful
{
private const float transition_duration = 100;
private const float size = 52;
@@ -320,7 +327,7 @@ namespace osu.Game.Overlays.BeatmapSet
}
}
- private enum DifficultySelectorState
+ public enum DifficultySelectorState
{
Selected,
NotSelected,
From 4f40a044258b392f8c0d42a672d5d492ab11779e Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Fri, 4 Oct 2019 17:57:39 +0300
Subject: [PATCH 056/901] Add tests ensuring correct behaviour with ruleset
selection
---
.../Online/TestSceneBeatmapSetOverlay.cs | 70 +++++++++++++++----
1 file changed, 57 insertions(+), 13 deletions(-)
diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
index 9f03d947b9..6c7a3e4108 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs
@@ -3,6 +3,7 @@
using NUnit.Framework;
using osu.Framework.Allocation;
+using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapSet;
@@ -40,24 +41,19 @@ namespace osu.Game.Tests.Visual.Online
typeof(PreviewButton),
typeof(SuccessRate),
typeof(BeatmapAvailability),
+ typeof(BeatmapRulesetSelector),
+ typeof(BeatmapRulesetTabItem),
};
protected override bool UseOnlineAPI => true;
- private RulesetInfo taikoRuleset;
- private RulesetInfo maniaRuleset;
-
public TestSceneBeatmapSetOverlay()
{
Add(overlay = new TestBeatmapSetOverlay());
}
- [BackgroundDependencyLoader]
- private void load(RulesetStore rulesets)
- {
- taikoRuleset = rulesets.GetRuleset(1);
- maniaRuleset = rulesets.GetRuleset(3);
- }
+ [Resolved]
+ private RulesetStore rulesets { get; set; }
[Test]
public void TestLoading()
@@ -111,7 +107,7 @@ namespace osu.Game.Tests.Visual.Online
StarDifficulty = 9.99,
Version = @"TEST",
Length = 456000,
- Ruleset = maniaRuleset,
+ Ruleset = rulesets.GetRuleset(3),
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 1,
@@ -189,7 +185,7 @@ namespace osu.Game.Tests.Visual.Online
StarDifficulty = 5.67,
Version = @"ANOTHER TEST",
Length = 123000,
- Ruleset = taikoRuleset,
+ Ruleset = rulesets.GetRuleset(1),
BaseDifficulty = new BeatmapDifficulty
{
CircleSize = 9,
@@ -217,6 +213,54 @@ namespace osu.Game.Tests.Visual.Online
downloadAssert(false);
}
+ [Test]
+ public void TestMultipleRulesets()
+ {
+ AddStep("show multiple rulesets beatmap", () =>
+ {
+ var beatmaps = new List();
+
+ foreach (var ruleset in rulesets.AvailableRulesets.Skip(1))
+ {
+ beatmaps.Add(new BeatmapInfo
+ {
+ Version = ruleset.Name,
+ Ruleset = ruleset,
+ BaseDifficulty = new BeatmapDifficulty(),
+ OnlineInfo = new BeatmapOnlineInfo(),
+ Metrics = new BeatmapMetrics
+ {
+ Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
+ Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
+ },
+ });
+ }
+
+ overlay.ShowBeatmapSet(new BeatmapSetInfo
+ {
+ Metadata = new BeatmapMetadata
+ {
+ Title = @"multiple rulesets beatmap",
+ Artist = @"none",
+ Author = new User
+ {
+ Username = "BanchoBot",
+ Id = 3,
+ }
+ },
+ OnlineInfo = new BeatmapSetOnlineInfo
+ {
+ Covers = new BeatmapSetOnlineCovers(),
+ },
+ Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
+ Beatmaps = beatmaps
+ });
+ });
+
+ AddAssert("shown beatmaps of current ruleset", () => overlay.Header.Picker.Difficulties.All(b => b.Beatmap.Ruleset.Equals(overlay.Header.RulesetSelector.Current.Value)));
+ AddAssert("left-most beatmap selected", () => overlay.Header.Picker.Difficulties.First().State == BeatmapPicker.DifficultySelectorState.Selected);
+ }
+
[Test]
public void TestHide()
{
@@ -281,12 +325,12 @@ namespace osu.Game.Tests.Visual.Online
private void downloadAssert(bool shown)
{
- AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.DownloadButtonsVisible == shown);
+ AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.DownloadButtonsVisible == shown);
}
private class TestBeatmapSetOverlay : BeatmapSetOverlay
{
- public bool DownloadButtonsVisible => Header.DownloadButtonsVisible;
+ public new Header Header => base.Header;
}
}
}
From 0c4f24825969c64775705b8feb9297af2f4fc9ac Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Fri, 4 Oct 2019 18:02:13 +0300
Subject: [PATCH 057/901] Fix CI issues
---
osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
index 0847272e1f..1abe103fc8 100644
--- a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
@@ -25,7 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet
beatmapSet = value;
- foreach (BeatmapRulesetTabItem tab in TabContainer.TabItems)
+ foreach (var tab in TabContainer.TabItems.OfType())
tab.SetBeatmaps(beatmapSet?.Beatmaps.FindAll(b => b.Ruleset.Equals(tab.Value)));
var firstRuleset = beatmapSet?.Beatmaps.OrderBy(b => b.Ruleset.ID).FirstOrDefault()?.Ruleset;
From 6985249d90e63e8e18ca92dd31c056eed82f35af Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Fri, 4 Oct 2019 21:18:03 +0300
Subject: [PATCH 058/901] Simplify properties
---
osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
index 1abe103fc8..bfb188a83b 100644
--- a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
@@ -36,15 +36,15 @@ namespace osu.Game.Overlays.BeatmapSet
public BeatmapRulesetSelector()
{
AutoSizeAxes = Axes.Both;
- TabContainer.Spacing = new Vector2(10, 0);
}
protected override TabItem CreateTabItem(RulesetInfo value) => new BeatmapRulesetTabItem(value);
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
- Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(10, 0),
};
}
}
From ba1a8547011d721f61ef1798b6dab6ed6d0e083e Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Sat, 5 Oct 2019 10:30:32 +0300
Subject: [PATCH 059/901] Use IEnumerable.Where<>() rather than List.FindAll()
Saves a whole list allocation
---
osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs
index e7a3d15401..bffe779da1 100644
--- a/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs
+++ b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs
@@ -56,7 +56,7 @@ namespace osu.Game.Overlays.BeatmapSet
if (BeatmapSet != null)
{
- Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.FindAll(b => b.Ruleset.Equals(ruleset.Value)).OrderBy(b => b.StarDifficulty).Select(b => new DifficultySelectorButton(b)
+ Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.Where(b => b.Ruleset.Equals(ruleset.Value)).OrderBy(b => b.StarDifficulty).Select(b => new DifficultySelectorButton(b)
{
State = DifficultySelectorState.NotSelected,
OnHovered = beatmap =>
From 2d707b2b65bb4baa189e4cb68c3e9d3bbbfeff54 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 7 Oct 2019 15:36:23 +0300
Subject: [PATCH 060/901] Implement PostBeatmapFavouriteRequest
---
.../Requests/PostBeatmapFavouriteRequest.cs | 36 +++++++++++++++++++
.../BeatmapSet/Buttons/FavouriteButton.cs | 24 ++++++++++++-
2 files changed, 59 insertions(+), 1 deletion(-)
create mode 100644 osu.Game/Online/API/Requests/PostBeatmapFavouriteRequest.cs
diff --git a/osu.Game/Online/API/Requests/PostBeatmapFavouriteRequest.cs b/osu.Game/Online/API/Requests/PostBeatmapFavouriteRequest.cs
new file mode 100644
index 0000000000..f3724230cb
--- /dev/null
+++ b/osu.Game/Online/API/Requests/PostBeatmapFavouriteRequest.cs
@@ -0,0 +1,36 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.IO.Network;
+using System.Net.Http;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class PostBeatmapFavouriteRequest : APIRequest
+ {
+ private readonly int id;
+ private readonly BeatmapFavouriteAction action;
+
+ public PostBeatmapFavouriteRequest(int id, BeatmapFavouriteAction action)
+ {
+ this.id = id;
+ this.action = action;
+ }
+
+ protected override WebRequest CreateWebRequest()
+ {
+ var req = base.CreateWebRequest();
+ req.Method = HttpMethod.Post;
+ req.AddParameter(@"action", action.ToString().ToLowerInvariant());
+ return req;
+ }
+
+ protected override string Target => $@"beatmapsets/{id}/favourites";
+ }
+
+ public enum BeatmapFavouriteAction
+ {
+ Favourite,
+ UnFavourite
+ }
+}
diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs
index 11f56bc163..23325b8765 100644
--- a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs
+++ b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs
@@ -10,6 +10,9 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
+using osu.Game.Graphics.UserInterface;
+using osu.Game.Online.API;
+using osu.Game.Online.API.Requests;
using osuTK;
namespace osu.Game.Overlays.BeatmapSet.Buttons
@@ -20,8 +23,11 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
private readonly Bindable favourited = new Bindable();
+ private PostBeatmapFavouriteRequest request;
+ private DimmedLoadingLayer loading;
+
[BackgroundDependencyLoader]
- private void load()
+ private void load(IAPIProvider api)
{
Container pink;
SpriteIcon icon;
@@ -55,6 +61,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
Size = new Vector2(18),
Shadow = false,
},
+ loading = new DimmedLoadingLayer(),
});
BeatmapSet.BindValueChanged(setInfo =>
@@ -67,6 +74,8 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
favourited.ValueChanged += favourited =>
{
+ loading.Hide();
+
if (favourited.NewValue)
{
pink.FadeIn(200);
@@ -78,6 +87,19 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
icon.Icon = FontAwesome.Regular.Heart;
}
};
+
+ Action = () =>
+ {
+ if (loading.State.Value == Visibility.Visible)
+ return;
+
+ loading.Show();
+
+ request?.Cancel();
+ request = new PostBeatmapFavouriteRequest(BeatmapSet.Value?.OnlineBeatmapSetID ?? 0, favourited.Value ? BeatmapFavouriteAction.UnFavourite : BeatmapFavouriteAction.Favourite);
+ request.Success += () => favourited.Value = !favourited.Value;
+ api.Queue(request);
+ };
}
protected override void UpdateAfterChildren()
From a7dc9bb582682c0b87ea047f1da9aa6b40a45ea0 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 7 Oct 2019 15:41:05 +0300
Subject: [PATCH 061/901] Add tooltip and remove pink layer
---
.../BeatmapSet/Buttons/FavouriteButton.cs | 40 +++----------------
1 file changed, 5 insertions(+), 35 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs
index 23325b8765..fcea20ef11 100644
--- a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs
+++ b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs
@@ -5,11 +5,9 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
-using osu.Framework.Graphics.Shapes;
+using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps;
-using osu.Game.Graphics;
-using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
@@ -17,7 +15,7 @@ using osuTK;
namespace osu.Game.Overlays.BeatmapSet.Buttons
{
- public class FavouriteButton : HeaderButton
+ public class FavouriteButton : HeaderButton, IHasTooltip
{
public readonly Bindable BeatmapSet = new Bindable();
@@ -26,33 +24,14 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
private PostBeatmapFavouriteRequest request;
private DimmedLoadingLayer loading;
+ public string TooltipText => (favourited.Value ? "Unfavourite" : "Favourite") + " this beatmapset";
+
[BackgroundDependencyLoader]
private void load(IAPIProvider api)
{
- Container pink;
SpriteIcon icon;
AddRange(new Drawable[]
{
- pink = new Container
- {
- RelativeSizeAxes = Axes.Both,
- Alpha = 0f,
- Children = new Drawable[]
- {
- new Box
- {
- RelativeSizeAxes = Axes.Both,
- Colour = OsuColour.FromHex(@"9f015f"),
- },
- new Triangles
- {
- RelativeSizeAxes = Axes.Both,
- ColourLight = OsuColour.FromHex(@"cb2187"),
- ColourDark = OsuColour.FromHex(@"9f015f"),
- TriangleScale = 1.5f,
- },
- },
- },
icon = new SpriteIcon
{
Anchor = Anchor.Centre,
@@ -76,16 +55,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
{
loading.Hide();
- if (favourited.NewValue)
- {
- pink.FadeIn(200);
- icon.Icon = FontAwesome.Solid.Heart;
- }
- else
- {
- pink.FadeOut(200);
- icon.Icon = FontAwesome.Regular.Heart;
- }
+ icon.Icon = favourited.NewValue ? FontAwesome.Solid.Heart : FontAwesome.Regular.Heart;
};
Action = () =>
From 76db200bd3efd8f3f1a93820e852cbdb9e54fdc8 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 7 Oct 2019 16:48:05 +0300
Subject: [PATCH 062/901] Implement GetCommentsRequest
---
.../Online/API/Requests/GetCommentsRequest.cs | 53 ++++++++++++++++++
.../API/Requests/Responses/APIComments.cs | 36 ++++++++++++
.../Online/API/Requests/Responses/Comment.cs | 56 +++++++++++++++++++
3 files changed, 145 insertions(+)
create mode 100644 osu.Game/Online/API/Requests/GetCommentsRequest.cs
create mode 100644 osu.Game/Online/API/Requests/Responses/APIComments.cs
create mode 100644 osu.Game/Online/API/Requests/Responses/Comment.cs
diff --git a/osu.Game/Online/API/Requests/GetCommentsRequest.cs b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
new file mode 100644
index 0000000000..279a1905da
--- /dev/null
+++ b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
@@ -0,0 +1,53 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.IO.Network;
+using Humanizer;
+using osu.Game.Online.API.Requests.Responses;
+
+namespace osu.Game.Online.API.Requests
+{
+ public class GetCommentsRequest : APIRequest
+ {
+ private readonly long id;
+ private readonly int page;
+ private readonly CommentableType type;
+ private readonly SortCommentsBy sort;
+
+ public GetCommentsRequest(CommentableType type, long id, SortCommentsBy sort = SortCommentsBy.New, int page = 1)
+ {
+ this.type = type;
+ this.sort = sort;
+ this.id = id;
+ this.page = page;
+ }
+
+ protected override WebRequest CreateWebRequest()
+ {
+ var req = base.CreateWebRequest();
+
+ req.AddParameter("commentable_type", type.ToString().Underscore().ToLowerInvariant());
+ req.AddParameter("commentable_id", id.ToString());
+ req.AddParameter("sort", sort.ToString());
+ req.AddParameter("page", page.ToString());
+
+ return req;
+ }
+
+ protected override string Target => "comments";
+ }
+
+ public enum CommentableType
+ {
+ Build,
+ Beatmapset,
+ NewsPost
+ }
+
+ public enum SortCommentsBy
+ {
+ New,
+ Old,
+ Top
+ }
+}
diff --git a/osu.Game/Online/API/Requests/Responses/APIComments.cs b/osu.Game/Online/API/Requests/Responses/APIComments.cs
new file mode 100644
index 0000000000..158430a5b6
--- /dev/null
+++ b/osu.Game/Online/API/Requests/Responses/APIComments.cs
@@ -0,0 +1,36 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using Newtonsoft.Json;
+using osu.Game.Users;
+using System.Collections.Generic;
+
+namespace osu.Game.Online.API.Requests.Responses
+{
+ public class APIComments
+ {
+ [JsonProperty(@"comments")]
+ public List Comments { get; set; }
+
+ [JsonProperty(@"has_more")]
+ public bool HasMore { get; set; }
+
+ [JsonProperty(@"has_more_id")]
+ public long HasMoreId { get; set; }
+
+ [JsonProperty(@"user_follow")]
+ public bool UserFollow { get; set; }
+
+ [JsonProperty(@"included_comments")]
+ public List IncludedComments { get; set; }
+
+ [JsonProperty(@"users")]
+ public List Users { get; set; }
+
+ [JsonProperty(@"total")]
+ public int Total { get; set; }
+
+ [JsonProperty(@"top_level_count")]
+ public int TopLevelCount { get; set; }
+ }
+}
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
new file mode 100644
index 0000000000..e157a10f8a
--- /dev/null
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -0,0 +1,56 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using Newtonsoft.Json;
+using System;
+
+namespace osu.Game.Online.API.Requests.Responses
+{
+ public class Comment
+ {
+ [JsonProperty(@"id")]
+ public long Id { get; set; }
+
+ [JsonProperty(@"parent_id")]
+ public long ParentId { get; set; }
+
+ [JsonProperty(@"user_id")]
+ public long UserId { get; set; }
+
+ [JsonProperty(@"message")]
+ public string Message { get; set; }
+
+ [JsonProperty(@"message_html")]
+ public string MessageHTML { get; set; }
+
+ [JsonProperty(@"replies_count")]
+ public int RepliesCount { get; set; }
+
+ [JsonProperty(@"votes_count")]
+ public int VotesCount { get; set; }
+
+ [JsonProperty(@"commenatble_type")]
+ public string CommentableType { get; set; }
+
+ [JsonProperty(@"commentable_id")]
+ public int CommentableId { get; set; }
+
+ [JsonProperty(@"legacy_name")]
+ public string LegacyName { get; set; }
+
+ [JsonProperty(@"created_at")]
+ public DateTimeOffset CreatedAt { get; set; }
+
+ [JsonProperty(@"updated_at")]
+ public DateTimeOffset UpdatedAt { get; set; }
+
+ [JsonProperty(@"deleted_at")]
+ public DateTimeOffset DeletedAt { get; set; }
+
+ [JsonProperty(@"edited_at")]
+ public DateTimeOffset EditedAt { get; set; }
+
+ [JsonProperty(@"edited_by_id")]
+ public long EditedById { get; set; }
+ }
+}
From 738580ec617a23789236575f2525606a6a4d227e Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 7 Oct 2019 16:58:24 +0300
Subject: [PATCH 063/901] Add IsTopLevel property
---
osu.Game/Online/API/Requests/Responses/Comment.cs | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index e157a10f8a..6edf13d2da 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -11,8 +11,18 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"id")]
public long Id { get; set; }
+ private long? parentId;
+
[JsonProperty(@"parent_id")]
- public long ParentId { get; set; }
+ public long? ParentId
+ {
+ get => parentId;
+ set
+ {
+ parentId = value;
+ IsTopLevel = value != null;
+ }
+ }
[JsonProperty(@"user_id")]
public long UserId { get; set; }
@@ -52,5 +62,7 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"edited_by_id")]
public long EditedById { get; set; }
+
+ public bool IsTopLevel { get; set; }
}
}
From e772822bd5ee46afddc5bc14398e73f84ff84564 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 7 Oct 2019 17:49:20 +0300
Subject: [PATCH 064/901] Basic implementation
---
.../Online/TestSceneCommentsContainer.cs | 29 +++++
osu.Game/Overlays/CommentsContainer.cs | 110 ++++++++++++++++++
2 files changed, 139 insertions(+)
create mode 100644 osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
create mode 100644 osu.Game/Overlays/CommentsContainer.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
new file mode 100644
index 0000000000..c99062d59b
--- /dev/null
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -0,0 +1,29 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using osu.Game.Overlays;
+using osu.Game.Online.API.Requests;
+
+namespace osu.Game.Tests.Visual.Online
+{
+ [TestFixture]
+ public class TestSceneCommentsContainer : OsuTestScene
+ {
+ public override IReadOnlyList RequiredTypes => new[]
+ {
+ typeof(CommentsContainer),
+ };
+
+ public TestSceneCommentsContainer()
+ {
+ AddStep("Big Black comments", () =>
+ {
+ Clear();
+ Add(new CommentsContainer(CommentableType.Beatmapset, 41823));
+ });
+ }
+ }
+}
diff --git a/osu.Game/Overlays/CommentsContainer.cs b/osu.Game/Overlays/CommentsContainer.cs
new file mode 100644
index 0000000000..8ed6fd0878
--- /dev/null
+++ b/osu.Game/Overlays/CommentsContainer.cs
@@ -0,0 +1,110 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Online.API;
+using osu.Game.Online.API.Requests;
+using osu.Framework.Graphics;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Graphics;
+using osu.Framework.Graphics.Sprites;
+using osuTK;
+
+namespace osu.Game.Overlays
+{
+ public class CommentsContainer : CompositeDrawable
+ {
+ private readonly CommentableType type;
+ private readonly long id;
+
+ public readonly Bindable Sort = new Bindable();
+
+ [Resolved]
+ private IAPIProvider api { get; set; }
+
+ private readonly CommentsHeader header;
+ private readonly Box background;
+
+ public CommentsContainer(CommentableType type, long id)
+ {
+ this.type = type;
+ this.id = id;
+
+ RelativeSizeAxes = Axes.X;
+ AutoSizeAxes = Axes.Y;
+ AddRangeInternal(new Drawable[]
+ {
+ background = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ },
+ header = new CommentsHeader
+ {
+ Sort = { BindTarget = Sort }
+ }
+ });
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ background.Colour = colours.Gray3;
+ }
+
+ private class CommentsHeader : CompositeDrawable
+ {
+ private const int height = 40;
+ private const int spacing = 10;
+ private const int padding = 50;
+
+ public readonly Bindable Sort = new Bindable();
+
+ private readonly Box background;
+
+ public CommentsHeader()
+ {
+ RelativeSizeAxes = Axes.X;
+ Height = height;
+ AddRangeInternal(new Drawable[]
+ {
+ background = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ },
+ new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ Padding = new MarginPadding { Horizontal = padding },
+ Children = new Drawable[]
+ {
+ new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(spacing, 0),
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Children = new Drawable[]
+ {
+ new SpriteText
+ {
+ Font = OsuFont.GetFont(size: 14),
+ Text = @"Sort by"
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ background.Colour = colours.Gray4;
+ }
+ }
+ }
+}
From aa8df0fa20426b0beec6997a2f2a07895cdddbaf Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 7 Oct 2019 18:26:07 +0300
Subject: [PATCH 065/901] Hook up api and implement some visual comments
representation
---
.../Online/TestSceneCommentsContainer.cs | 15 +++-
.../API/Requests/Responses/APIComments.cs | 2 +-
.../Online/API/Requests/Responses/Comment.cs | 8 +-
osu.Game/Overlays/CommentsContainer.cs | 84 ++++++++++++++++++-
4 files changed, 99 insertions(+), 10 deletions(-)
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index c99062d59b..bf4117189a 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -6,6 +6,8 @@ using System.Collections.Generic;
using NUnit.Framework;
using osu.Game.Overlays;
using osu.Game.Online.API.Requests;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics;
namespace osu.Game.Tests.Visual.Online
{
@@ -17,12 +19,21 @@ namespace osu.Game.Tests.Visual.Online
typeof(CommentsContainer),
};
+ protected override bool UseOnlineAPI => true;
+
public TestSceneCommentsContainer()
{
+ BasicScrollContainer scrollFlow;
+
+ Add(scrollFlow = new BasicScrollContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ });
+
AddStep("Big Black comments", () =>
{
- Clear();
- Add(new CommentsContainer(CommentableType.Beatmapset, 41823));
+ scrollFlow.Clear();
+ scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 41823));
});
}
}
diff --git a/osu.Game/Online/API/Requests/Responses/APIComments.cs b/osu.Game/Online/API/Requests/Responses/APIComments.cs
index 158430a5b6..af7650e512 100644
--- a/osu.Game/Online/API/Requests/Responses/APIComments.cs
+++ b/osu.Game/Online/API/Requests/Responses/APIComments.cs
@@ -16,7 +16,7 @@ namespace osu.Game.Online.API.Requests.Responses
public bool HasMore { get; set; }
[JsonProperty(@"has_more_id")]
- public long HasMoreId { get; set; }
+ public long? HasMoreId { get; set; }
[JsonProperty(@"user_follow")]
public bool UserFollow { get; set; }
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 6edf13d2da..df5c812fa0 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -52,16 +52,16 @@ namespace osu.Game.Online.API.Requests.Responses
public DateTimeOffset CreatedAt { get; set; }
[JsonProperty(@"updated_at")]
- public DateTimeOffset UpdatedAt { get; set; }
+ public DateTimeOffset? UpdatedAt { get; set; }
[JsonProperty(@"deleted_at")]
- public DateTimeOffset DeletedAt { get; set; }
+ public DateTimeOffset? DeletedAt { get; set; }
[JsonProperty(@"edited_at")]
- public DateTimeOffset EditedAt { get; set; }
+ public DateTimeOffset? EditedAt { get; set; }
[JsonProperty(@"edited_by_id")]
- public long EditedById { get; set; }
+ public long? EditedById { get; set; }
public bool IsTopLevel { get; set; }
}
diff --git a/osu.Game/Overlays/CommentsContainer.cs b/osu.Game/Overlays/CommentsContainer.cs
index 8ed6fd0878..fce9b3f03b 100644
--- a/osu.Game/Overlays/CommentsContainer.cs
+++ b/osu.Game/Overlays/CommentsContainer.cs
@@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osuTK;
+using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays
{
@@ -24,8 +25,14 @@ namespace osu.Game.Overlays
[Resolved]
private IAPIProvider api { get; set; }
+ [Resolved]
+ private OsuColour colours { get; set; }
+
+ private GetCommentsRequest request;
+
private readonly CommentsHeader header;
private readonly Box background;
+ private readonly FillFlowContainer content;
public CommentsContainer(CommentableType type, long id)
{
@@ -40,15 +47,86 @@ namespace osu.Game.Overlays
{
RelativeSizeAxes = Axes.Both,
},
- header = new CommentsHeader
+ new FillFlowContainer
{
- Sort = { BindTarget = Sort }
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical,
+ Children = new Drawable[]
+ {
+ header = new CommentsHeader
+ {
+ Sort = { BindTarget = Sort }
+ },
+ content = new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical,
+ }
+ }
+ }
+ });
+ }
+
+ protected override void LoadComplete()
+ {
+ Sort.BindValueChanged(onSortChanged, true);
+ base.LoadComplete();
+ }
+
+ private void onSortChanged(ValueChangedEvent sort) => getComments();
+
+ private void getComments()
+ {
+ request?.Cancel();
+ request = new GetCommentsRequest(type, id, Sort.Value);
+ request.Success += onSuccess;
+ api.Queue(request);
+ }
+
+ private void onSuccess(APIComments response)
+ {
+ content.Clear();
+
+ foreach (var c in response.Comments)
+ {
+ createDrawableComment(c);
+ }
+ }
+
+ private void createDrawableComment(Comment comment)
+ {
+ content.Add(new Container
+ {
+ RelativeSizeAxes = Axes.X,
+ Height = 70,
+ Children = new Drawable[]
+ {
+ new SpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Text = comment.MessageHTML,
+ },
+ new Container
+ {
+ Anchor = Anchor.BottomCentre,
+ Origin = Anchor.BottomCentre,
+ RelativeSizeAxes = Axes.X,
+ Height = 1,
+ Child = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = colours.Gray1,
+ }
+ }
}
});
}
[BackgroundDependencyLoader]
- private void load(OsuColour colours)
+ private void load()
{
background.Colour = colours.Gray3;
}
From cc6bf2f173b4d53c9fb568963c4685e133417254 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 7 Oct 2019 18:45:22 +0300
Subject: [PATCH 066/901] Add IsDeleted property
---
.../Online/API/Requests/Responses/Comment.cs | 16 ++++++++++++++--
osu.Game/Overlays/CommentsContainer.cs | 6 +++---
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index df5c812fa0..e4b66ddeee 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -20,7 +20,7 @@ namespace osu.Game.Online.API.Requests.Responses
set
{
parentId = value;
- IsTopLevel = value != null;
+ IsTopLevel = value == null;
}
}
@@ -54,8 +54,18 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"updated_at")]
public DateTimeOffset? UpdatedAt { get; set; }
+ private DateTimeOffset? deletedAt;
+
[JsonProperty(@"deleted_at")]
- public DateTimeOffset? DeletedAt { get; set; }
+ public DateTimeOffset? DeletedAt
+ {
+ get => deletedAt;
+ set
+ {
+ deletedAt = value;
+ IsDeleted = value != null;
+ }
+ }
[JsonProperty(@"edited_at")]
public DateTimeOffset? EditedAt { get; set; }
@@ -64,5 +74,7 @@ namespace osu.Game.Online.API.Requests.Responses
public long? EditedById { get; set; }
public bool IsTopLevel { get; set; }
+
+ public bool IsDeleted { get; set; }
}
}
diff --git a/osu.Game/Overlays/CommentsContainer.cs b/osu.Game/Overlays/CommentsContainer.cs
index fce9b3f03b..b22fefb3de 100644
--- a/osu.Game/Overlays/CommentsContainer.cs
+++ b/osu.Game/Overlays/CommentsContainer.cs
@@ -30,7 +30,6 @@ namespace osu.Game.Overlays
private GetCommentsRequest request;
- private readonly CommentsHeader header;
private readonly Box background;
private readonly FillFlowContainer content;
@@ -54,7 +53,7 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
- header = new CommentsHeader
+ new CommentsHeader
{
Sort = { BindTarget = Sort }
},
@@ -91,7 +90,8 @@ namespace osu.Game.Overlays
foreach (var c in response.Comments)
{
- createDrawableComment(c);
+ if (!c.IsDeleted)
+ createDrawableComment(c);
}
}
From 4b1a40dabaebadb49d07cbc077d71709714fe6d8 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 13:31:49 +0300
Subject: [PATCH 067/901] Implement temp fix to get the actual message
---
osu.Game/Online/API/Requests/Responses/Comment.cs | 6 ++++++
osu.Game/Overlays/CommentsContainer.cs | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index e4b66ddeee..ba71faa843 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -76,5 +76,11 @@ namespace osu.Game.Online.API.Requests.Responses
public bool IsTopLevel { get; set; }
public bool IsDeleted { get; set; }
+
+ public string GetMessage()
+ {
+ //temporary fix until HTML parsing will be implemented
+ return MessageHTML.Remove(MessageHTML.LastIndexOf("
")).Substring(65);
+ }
}
}
diff --git a/osu.Game/Overlays/CommentsContainer.cs b/osu.Game/Overlays/CommentsContainer.cs
index b22fefb3de..1b4bbee6a1 100644
--- a/osu.Game/Overlays/CommentsContainer.cs
+++ b/osu.Game/Overlays/CommentsContainer.cs
@@ -107,7 +107,7 @@ namespace osu.Game.Overlays
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
- Text = comment.MessageHTML,
+ Text = comment.GetMessage(),
},
new Container
{
From 801b5b474e300343bafc0defc0a8818e3516919d Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 13:45:13 +0300
Subject: [PATCH 068/901] Add a User property to the comment for easy access
---
.../API/Requests/Responses/APIComments.cs | 20 ++++++++++++++++-
.../Online/API/Requests/Responses/Comment.cs | 3 +++
osu.Game/Overlays/CommentsContainer.cs | 22 +++++++++++++++++--
3 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/osu.Game/Online/API/Requests/Responses/APIComments.cs b/osu.Game/Online/API/Requests/Responses/APIComments.cs
index af7650e512..86bbf0358a 100644
--- a/osu.Game/Online/API/Requests/Responses/APIComments.cs
+++ b/osu.Game/Online/API/Requests/Responses/APIComments.cs
@@ -24,8 +24,26 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"included_comments")]
public List IncludedComments { get; set; }
+ private List users;
+
[JsonProperty(@"users")]
- public List Users { get; set; }
+ public List Users
+ {
+ get => users;
+ set
+ {
+ users = value;
+
+ value.ForEach(u =>
+ {
+ Comments.ForEach(c =>
+ {
+ if (c.UserId == u.Id)
+ c.User = u;
+ });
+ });
+ }
+ }
[JsonProperty(@"total")]
public int Total { get; set; }
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index ba71faa843..46212dd50f 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using Newtonsoft.Json;
+using osu.Game.Users;
using System;
namespace osu.Game.Online.API.Requests.Responses
@@ -27,6 +28,8 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"user_id")]
public long UserId { get; set; }
+ public User User { get; set; }
+
[JsonProperty(@"message")]
public string Message { get; set; }
diff --git a/osu.Game/Overlays/CommentsContainer.cs b/osu.Game/Overlays/CommentsContainer.cs
index 1b4bbee6a1..c871810d8a 100644
--- a/osu.Game/Overlays/CommentsContainer.cs
+++ b/osu.Game/Overlays/CommentsContainer.cs
@@ -103,11 +103,29 @@ namespace osu.Game.Overlays
Height = 70,
Children = new Drawable[]
{
- new SpriteText
+ new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
- Text = comment.GetMessage(),
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical,
+ Spacing = new Vector2(0, 3),
+ Children = new[]
+ {
+ new SpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Text = $"user: {comment.User.Username}",
+ },
+ new SpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Text = $"message: {comment.GetMessage()}",
+ },
+ }
},
new Container
{
From 1c89841949e025fe693aab73a97dd9a93c78b85b Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 14:51:12 +0300
Subject: [PATCH 069/901] Move all the logic to it's own namespace
---
.../Online/TestSceneCommentsContainer.cs | 2 +-
.../{ => Comments}/CommentsContainer.cs | 67 +++----------
osu.Game/Overlays/Comments/DrawableComment.cs | 99 +++++++++++++++++++
3 files changed, 116 insertions(+), 52 deletions(-)
rename osu.Game/Overlays/{ => Comments}/CommentsContainer.cs (73%)
create mode 100644 osu.Game/Overlays/Comments/DrawableComment.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index bf4117189a..e6f9582910 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -4,10 +4,10 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
-using osu.Game.Overlays;
using osu.Game.Online.API.Requests;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
+using osu.Game.Overlays.Comments;
namespace osu.Game.Tests.Visual.Online
{
diff --git a/osu.Game/Overlays/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
similarity index 73%
rename from osu.Game/Overlays/CommentsContainer.cs
rename to osu.Game/Overlays/Comments/CommentsContainer.cs
index c871810d8a..60b22428f0 100644
--- a/osu.Game/Overlays/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -13,7 +13,7 @@ using osu.Framework.Graphics.Sprites;
using osuTK;
using osu.Game.Online.API.Requests.Responses;
-namespace osu.Game.Overlays
+namespace osu.Game.Overlays.Comments
{
public class CommentsContainer : CompositeDrawable
{
@@ -90,59 +90,24 @@ namespace osu.Game.Overlays
foreach (var c in response.Comments)
{
- if (!c.IsDeleted)
- createDrawableComment(c);
+ if (!c.IsDeleted && c.IsTopLevel)
+ content.AddRange(new Drawable[]
+ {
+ new DrawableComment(c),
+ new Container
+ {
+ RelativeSizeAxes = Axes.X,
+ Height = 1,
+ Child = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = colours.Gray1,
+ }
+ }
+ });
}
}
- private void createDrawableComment(Comment comment)
- {
- content.Add(new Container
- {
- RelativeSizeAxes = Axes.X,
- Height = 70,
- Children = new Drawable[]
- {
- new FillFlowContainer
- {
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Direction = FillDirection.Vertical,
- Spacing = new Vector2(0, 3),
- Children = new[]
- {
- new SpriteText
- {
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- Text = $"user: {comment.User.Username}",
- },
- new SpriteText
- {
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- Text = $"message: {comment.GetMessage()}",
- },
- }
- },
- new Container
- {
- Anchor = Anchor.BottomCentre,
- Origin = Anchor.BottomCentre,
- RelativeSizeAxes = Axes.X,
- Height = 1,
- Child = new Box
- {
- RelativeSizeAxes = Axes.Both,
- Colour = colours.Gray1,
- }
- }
- }
- });
- }
-
[BackgroundDependencyLoader]
private void load()
{
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
new file mode 100644
index 0000000000..bbb804dc5b
--- /dev/null
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -0,0 +1,99 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics;
+using osu.Game.Graphics;
+using osu.Framework.Graphics.Sprites;
+using osuTK;
+using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Users.Drawables;
+using osu.Game.Graphics.Containers;
+using osu.Game.Utils;
+
+namespace osu.Game.Overlays.Comments
+{
+ public class DrawableComment : CompositeDrawable
+ {
+ private const int avatar_size = 40;
+ private const int margin = 10;
+
+ public DrawableComment(Comment comment)
+ {
+ LinkFlowContainer username;
+
+ RelativeSizeAxes = Axes.X;
+ AutoSizeAxes = Axes.Y;
+ InternalChild = new GridContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Margin = new MarginPadding(margin),
+ ColumnDimensions = new[]
+ {
+ new Dimension(GridSizeMode.AutoSize),
+ new Dimension(),
+ },
+ RowDimensions = new[]
+ {
+ new Dimension(GridSizeMode.AutoSize),
+ new Dimension(GridSizeMode.AutoSize)
+ },
+ Content = new[]
+ {
+ new Drawable[]
+ {
+ new UpdateableAvatar(comment.User)
+ {
+ Size = new Vector2(avatar_size),
+ Margin = new MarginPadding { Horizontal = margin },
+ Masking = true,
+ CornerRadius = avatar_size / 2,
+ },
+ new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Spacing = new Vector2(0, 2),
+ Children = new Drawable[]
+ {
+ username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ AutoSizeAxes = Axes.Both,
+ },
+ new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 18))
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Text = comment.GetMessage()
+ }
+ }
+ }
+ },
+ new Drawable[]
+ {
+ new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ },
+ new SpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Font = OsuFont.GetFont(size: 12),
+ Text = HumanizerUtils.Humanize(comment.CreatedAt)
+ }
+ }
+ }
+ };
+
+ username.AddUserLink(comment.User);
+ }
+ }
+}
From 2564214a72b70007368fa3c5763c407fab2192ac Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 15:01:18 +0300
Subject: [PATCH 070/901] Fix some padding issues with the big comments
---
osu.Game/Overlays/Comments/DrawableComment.cs | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index bbb804dc5b..6f3d92c7fd 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -54,21 +54,16 @@ namespace osu.Game.Overlays.Comments
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
+ Margin = new MarginPadding { Top = margin / 2 },
Spacing = new Vector2(0, 2),
Children = new Drawable[]
{
username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
{
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
},
- new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 18))
+ new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
{
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Text = comment.GetMessage()
From 451a7342ce7459ae42562521e549af8e7e8a1d5b Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 15:39:03 +0300
Subject: [PATCH 071/901] Parse child comments
---
.../API/Requests/Responses/APIComments.cs | 22 +++-
.../Online/API/Requests/Responses/Comment.cs | 3 +
.../Overlays/Comments/CommentsContainer.cs | 4 +-
osu.Game/Overlays/Comments/DrawableComment.cs | 106 +++++++++++-------
4 files changed, 92 insertions(+), 43 deletions(-)
diff --git a/osu.Game/Online/API/Requests/Responses/APIComments.cs b/osu.Game/Online/API/Requests/Responses/APIComments.cs
index 86bbf0358a..9a12fb613e 100644
--- a/osu.Game/Online/API/Requests/Responses/APIComments.cs
+++ b/osu.Game/Online/API/Requests/Responses/APIComments.cs
@@ -9,8 +9,28 @@ namespace osu.Game.Online.API.Requests.Responses
{
public class APIComments
{
+ private List comments;
+
[JsonProperty(@"comments")]
- public List Comments { get; set; }
+ public List Comments
+ {
+ get => comments;
+ set
+ {
+ comments = value;
+ comments.ForEach(child =>
+ {
+ if (child.ParentId != null)
+ {
+ comments.ForEach(parent =>
+ {
+ if (parent.Id == child.ParentId)
+ parent.ChildComments.Add(child);
+ });
+ }
+ });
+ }
+ }
[JsonProperty(@"has_more")]
public bool HasMore { get; set; }
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 46212dd50f..cdc3c3204b 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -4,6 +4,7 @@
using Newtonsoft.Json;
using osu.Game.Users;
using System;
+using System.Collections.Generic;
namespace osu.Game.Online.API.Requests.Responses
{
@@ -25,6 +26,8 @@ namespace osu.Game.Online.API.Requests.Responses
}
}
+ public List ChildComments = new List();
+
[JsonProperty(@"user_id")]
public long UserId { get; set; }
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 60b22428f0..d02e74a5a4 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -17,6 +17,8 @@ namespace osu.Game.Overlays.Comments
{
public class CommentsContainer : CompositeDrawable
{
+ private const float separator_height = 1.5f;
+
private readonly CommentableType type;
private readonly long id;
@@ -97,7 +99,7 @@ namespace osu.Game.Overlays.Comments
new Container
{
RelativeSizeAxes = Axes.X,
- Height = 1,
+ Height = separator_height,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 6f3d92c7fd..53366be878 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -17,78 +17,102 @@ namespace osu.Game.Overlays.Comments
{
private const int avatar_size = 40;
private const int margin = 10;
+ private const int child_margin = 20;
public DrawableComment(Comment comment)
{
LinkFlowContainer username;
+ FillFlowContainer childCommentsContainer;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
- InternalChild = new GridContainer
+ InternalChild = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Margin = new MarginPadding(margin),
- ColumnDimensions = new[]
+ Direction = FillDirection.Vertical,
+ Children = new Drawable[]
{
- new Dimension(GridSizeMode.AutoSize),
- new Dimension(),
- },
- RowDimensions = new[]
- {
- new Dimension(GridSizeMode.AutoSize),
- new Dimension(GridSizeMode.AutoSize)
- },
- Content = new[]
- {
- new Drawable[]
+ new GridContainer
{
- new UpdateableAvatar(comment.User)
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Margin = new MarginPadding(margin),
+ ColumnDimensions = new[]
{
- Size = new Vector2(avatar_size),
- Margin = new MarginPadding { Horizontal = margin },
- Masking = true,
- CornerRadius = avatar_size / 2,
+ new Dimension(GridSizeMode.AutoSize),
+ new Dimension(),
},
- new FillFlowContainer
+ RowDimensions = new[]
{
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Margin = new MarginPadding { Top = margin / 2 },
- Spacing = new Vector2(0, 2),
- Children = new Drawable[]
+ new Dimension(GridSizeMode.AutoSize),
+ new Dimension(GridSizeMode.AutoSize)
+ },
+ Content = new[]
+ {
+ new Drawable[]
{
- username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
+ new UpdateableAvatar(comment.User)
{
- AutoSizeAxes = Axes.Both,
+ Size = new Vector2(avatar_size),
+ Margin = new MarginPadding { Horizontal = margin },
+ Masking = true,
+ CornerRadius = avatar_size / 2,
},
- new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
+ new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Text = comment.GetMessage()
+ Margin = new MarginPadding { Top = margin / 2 },
+ Spacing = new Vector2(0, 2),
+ Children = new Drawable[]
+ {
+ username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
+ {
+ AutoSizeAxes = Axes.Both,
+ },
+ new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Text = comment.GetMessage()
+ }
+ }
+ }
+ },
+ new Drawable[]
+ {
+ new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ },
+ new SpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Font = OsuFont.GetFont(size: 12),
+ Text = HumanizerUtils.Humanize(comment.CreatedAt)
}
}
}
},
- new Drawable[]
+ childCommentsContainer = new FillFlowContainer
{
- new Container
- {
- RelativeSizeAxes = Axes.Both,
- },
- new SpriteText
- {
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- Font = OsuFont.GetFont(size: 12),
- Text = HumanizerUtils.Humanize(comment.CreatedAt)
- }
+ Margin = new MarginPadding { Left = child_margin },
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical
}
}
};
username.AddUserLink(comment.User);
+
+ comment.ChildComments.ForEach(c =>
+ {
+ if (!c.IsDeleted)
+ childCommentsContainer.Add(new DrawableComment(c));
+ });
}
}
}
From 9c7e403cf8ca62b83ded5505c030b77f8ee0a81b Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 16:00:34 +0300
Subject: [PATCH 072/901] Implement replies button
---
osu.Game/Overlays/Comments/DrawableComment.cs | 98 +++++++++++++++++--
1 file changed, 90 insertions(+), 8 deletions(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 53366be878..9879995b00 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -10,6 +10,8 @@ using osu.Game.Online.API.Requests.Responses;
using osu.Game.Users.Drawables;
using osu.Game.Graphics.Containers;
using osu.Game.Utils;
+using osu.Framework.Input.Events;
+using System;
namespace osu.Game.Overlays.Comments
{
@@ -18,11 +20,39 @@ namespace osu.Game.Overlays.Comments
private const int avatar_size = 40;
private const int margin = 10;
private const int child_margin = 20;
+ private const int duration = 200;
+
+ private bool childExpanded = true;
+
+ public bool ChildExpanded
+ {
+ get => childExpanded;
+ set
+ {
+ if (childExpanded == value)
+ return;
+
+ childExpanded = value;
+
+ childCommentsVisibilityContainer.ClearTransforms();
+
+ if (childExpanded)
+ childCommentsVisibilityContainer.AutoSizeAxes = Axes.Y;
+ else
+ {
+ childCommentsVisibilityContainer.AutoSizeAxes = Axes.None;
+ childCommentsVisibilityContainer.ResizeHeightTo(0, duration, Easing.OutQuint);
+ }
+ }
+ }
+
+ private readonly Container childCommentsVisibilityContainer;
public DrawableComment(Comment comment)
{
LinkFlowContainer username;
FillFlowContainer childCommentsContainer;
+ RepliesButton replies;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@@ -86,22 +116,40 @@ namespace osu.Game.Overlays.Comments
{
RelativeSizeAxes = Axes.Both,
},
- new SpriteText
+ new FillFlowContainer
{
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- Font = OsuFont.GetFont(size: 12),
- Text = HumanizerUtils.Humanize(comment.CreatedAt)
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(5, 0),
+ Children = new Drawable[]
+ {
+ new SpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Font = OsuFont.GetFont(size: 12),
+ Text = HumanizerUtils.Humanize(comment.CreatedAt)
+ },
+ replies = new RepliesButton(comment.RepliesCount),
+ }
}
}
}
},
- childCommentsContainer = new FillFlowContainer
+ childCommentsVisibilityContainer = new Container
{
- Margin = new MarginPadding { Left = child_margin },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Direction = FillDirection.Vertical
+ AutoSizeDuration = duration,
+ AutoSizeEasing = Easing.OutQuint,
+ Masking = true,
+ Child = childCommentsContainer = new FillFlowContainer
+ {
+ Margin = new MarginPadding { Left = child_margin },
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical
+ }
}
}
};
@@ -113,6 +161,40 @@ namespace osu.Game.Overlays.Comments
if (!c.IsDeleted)
childCommentsContainer.Add(new DrawableComment(c));
});
+
+ replies.Action += expanded => ChildExpanded = expanded;
+ }
+
+ private class RepliesButton : Container
+ {
+ private readonly SpriteText text;
+ private bool expanded;
+ private readonly int count;
+
+ public Action Action;
+
+ public RepliesButton(int count)
+ {
+ this.count = count;
+
+ AutoSizeAxes = Axes.Both;
+ Alpha = count == 0 ? 0 : 1;
+ Child = text = new SpriteText
+ {
+ Font = OsuFont.GetFont(size: 12),
+ Text = $@"[-] replies ({count})"
+ };
+
+ expanded = true;
+ }
+
+ protected override bool OnClick(ClickEvent e)
+ {
+ text.Text = $@"{(expanded ? "[+]" : "[-]")} replies ({count})";
+ expanded = !expanded;
+ Action?.Invoke(expanded);
+ return base.OnClick(e);
+ }
}
}
}
From 3f8fecbc5034d2b601ea6e6bc3643e25b8e13fc6 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 16:04:52 +0300
Subject: [PATCH 073/901] Adjust spacing
---
osu.Game/Overlays/Comments/DrawableComment.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 9879995b00..f3d8d2f577 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -120,7 +120,7 @@ namespace osu.Game.Overlays.Comments
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
- Spacing = new Vector2(5, 0),
+ Spacing = new Vector2(10, 0),
Children = new Drawable[]
{
new SpriteText
From 000e4a563cf4389d9fc86683838ece2e8251230b Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 19:09:02 +0300
Subject: [PATCH 074/901] Parse parent comments
---
.../API/Requests/Responses/APIComments.cs | 3 ++
.../Online/API/Requests/Responses/Comment.cs | 2 +
osu.Game/Overlays/Comments/DrawableComment.cs | 45 ++++++++++++++++++-
3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Online/API/Requests/Responses/APIComments.cs b/osu.Game/Online/API/Requests/Responses/APIComments.cs
index 9a12fb613e..f454d4052f 100644
--- a/osu.Game/Online/API/Requests/Responses/APIComments.cs
+++ b/osu.Game/Online/API/Requests/Responses/APIComments.cs
@@ -25,7 +25,10 @@ namespace osu.Game.Online.API.Requests.Responses
comments.ForEach(parent =>
{
if (parent.Id == child.ParentId)
+ {
parent.ChildComments.Add(child);
+ child.ParentComment = parent;
+ }
});
}
});
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index cdc3c3204b..e5d3f14d27 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -28,6 +28,8 @@ namespace osu.Game.Online.API.Requests.Responses
public List ChildComments = new List();
+ public Comment ParentComment { get; set; }
+
[JsonProperty(@"user_id")]
public long UserId { get; set; }
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index f3d8d2f577..dea14f22c8 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -12,6 +12,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Utils;
using osu.Framework.Input.Events;
using System;
+using osu.Framework.Graphics.Cursor;
namespace osu.Game.Overlays.Comments
{
@@ -97,9 +98,19 @@ namespace osu.Game.Overlays.Comments
Spacing = new Vector2(0, 2),
Children = new Drawable[]
{
- username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
+ new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(7, 0),
+ Children = new Drawable[]
+ {
+ username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
+ {
+ AutoSizeAxes = Axes.Both,
+ },
+ new ParentUsername(comment)
+ }
},
new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
{
@@ -196,5 +207,37 @@ namespace osu.Game.Overlays.Comments
return base.OnClick(e);
}
}
+
+ private class ParentUsername : FillFlowContainer, IHasTooltip
+ {
+ private const int spacing = 3;
+
+ public string TooltipText => comment.ParentComment?.GetMessage() ?? "";
+
+ private readonly Comment comment;
+
+ public ParentUsername(Comment comment)
+ {
+ this.comment = comment;
+
+ AutoSizeAxes = Axes.Both;
+ Direction = FillDirection.Horizontal;
+ Spacing = new Vector2(spacing, 0);
+ Alpha = comment.ParentId == null ? 0 : 1;
+ Children = new Drawable[]
+ {
+ new SpriteIcon
+ {
+ Icon = FontAwesome.Solid.Reply,
+ Size = new Vector2(14),
+ },
+ new SpriteText
+ {
+ Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
+ Text = comment.ParentComment?.User?.Username
+ }
+ };
+ }
+ }
}
}
From 341702b91d084207316711e6f43e33afa3fadcc6 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 19:18:46 +0300
Subject: [PATCH 075/901] Use Bindable for expansion logic
---
osu.Game/Overlays/Comments/DrawableComment.cs | 68 +++++++++----------
1 file changed, 34 insertions(+), 34 deletions(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index dea14f22c8..bf24cbb70d 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -11,8 +11,8 @@ using osu.Game.Users.Drawables;
using osu.Game.Graphics.Containers;
using osu.Game.Utils;
using osu.Framework.Input.Events;
-using System;
using osu.Framework.Graphics.Cursor;
+using osu.Framework.Bindables;
namespace osu.Game.Overlays.Comments
{
@@ -23,29 +23,7 @@ namespace osu.Game.Overlays.Comments
private const int child_margin = 20;
private const int duration = 200;
- private bool childExpanded = true;
-
- public bool ChildExpanded
- {
- get => childExpanded;
- set
- {
- if (childExpanded == value)
- return;
-
- childExpanded = value;
-
- childCommentsVisibilityContainer.ClearTransforms();
-
- if (childExpanded)
- childCommentsVisibilityContainer.AutoSizeAxes = Axes.Y;
- else
- {
- childCommentsVisibilityContainer.AutoSizeAxes = Axes.None;
- childCommentsVisibilityContainer.ResizeHeightTo(0, duration, Easing.OutQuint);
- }
- }
- }
+ private readonly BindableBool childExpanded = new BindableBool(true);
private readonly Container childCommentsVisibilityContainer;
@@ -53,7 +31,6 @@ namespace osu.Game.Overlays.Comments
{
LinkFlowContainer username;
FillFlowContainer childCommentsContainer;
- RepliesButton replies;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@@ -141,7 +118,8 @@ namespace osu.Game.Overlays.Comments
Font = OsuFont.GetFont(size: 12),
Text = HumanizerUtils.Humanize(comment.CreatedAt)
},
- replies = new RepliesButton(comment.RepliesCount),
+ new RepliesButton(comment.RepliesCount)
+ { Expanded = { BindTarget = childExpanded } },
}
}
}
@@ -172,17 +150,33 @@ namespace osu.Game.Overlays.Comments
if (!c.IsDeleted)
childCommentsContainer.Add(new DrawableComment(c));
});
+ }
- replies.Action += expanded => ChildExpanded = expanded;
+ protected override void LoadComplete()
+ {
+ childExpanded.BindValueChanged(onChildExpandedChanged, true);
+ base.LoadComplete();
+ }
+
+ private void onChildExpandedChanged(ValueChangedEvent expanded)
+ {
+ childCommentsVisibilityContainer.ClearTransforms();
+
+ if (expanded.NewValue)
+ childCommentsVisibilityContainer.AutoSizeAxes = Axes.Y;
+ else
+ {
+ childCommentsVisibilityContainer.AutoSizeAxes = Axes.None;
+ childCommentsVisibilityContainer.ResizeHeightTo(0, duration, Easing.OutQuint);
+ }
}
private class RepliesButton : Container
{
private readonly SpriteText text;
- private bool expanded;
private readonly int count;
- public Action Action;
+ public readonly BindableBool Expanded = new BindableBool(true);
public RepliesButton(int count)
{
@@ -193,17 +187,23 @@ namespace osu.Game.Overlays.Comments
Child = text = new SpriteText
{
Font = OsuFont.GetFont(size: 12),
- Text = $@"[-] replies ({count})"
};
+ }
- expanded = true;
+ protected override void LoadComplete()
+ {
+ Expanded.BindValueChanged(onExpandedChanged, true);
+ base.LoadComplete();
+ }
+
+ private void onExpandedChanged(ValueChangedEvent expanded)
+ {
+ text.Text = $@"{(expanded.NewValue ? "[+]" : "[-]")} replies ({count})";
}
protected override bool OnClick(ClickEvent e)
{
- text.Text = $@"{(expanded ? "[+]" : "[-]")} replies ({count})";
- expanded = !expanded;
- Action?.Invoke(expanded);
+ Expanded.Value = !Expanded.Value;
return base.OnClick(e);
}
}
From 4230b00110768023bd1cf9d0e1fc098d5b273224 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 19:22:23 +0300
Subject: [PATCH 076/901] Rename APIComments to APICommentsController
---
osu.Game/Online/API/Requests/GetCommentsRequest.cs | 2 +-
.../Responses/{APIComments.cs => APICommentsController.cs} | 2 +-
osu.Game/Overlays/Comments/CommentsContainer.cs | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
rename osu.Game/Online/API/Requests/Responses/{APIComments.cs => APICommentsController.cs} (98%)
diff --git a/osu.Game/Online/API/Requests/GetCommentsRequest.cs b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
index 279a1905da..5a2b61b4d0 100644
--- a/osu.Game/Online/API/Requests/GetCommentsRequest.cs
+++ b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
@@ -7,7 +7,7 @@ using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.API.Requests
{
- public class GetCommentsRequest : APIRequest
+ public class GetCommentsRequest : APIRequest
{
private readonly long id;
private readonly int page;
diff --git a/osu.Game/Online/API/Requests/Responses/APIComments.cs b/osu.Game/Online/API/Requests/Responses/APICommentsController.cs
similarity index 98%
rename from osu.Game/Online/API/Requests/Responses/APIComments.cs
rename to osu.Game/Online/API/Requests/Responses/APICommentsController.cs
index f454d4052f..cf2e5e8a35 100644
--- a/osu.Game/Online/API/Requests/Responses/APIComments.cs
+++ b/osu.Game/Online/API/Requests/Responses/APICommentsController.cs
@@ -7,7 +7,7 @@ using System.Collections.Generic;
namespace osu.Game.Online.API.Requests.Responses
{
- public class APIComments
+ public class APICommentsController
{
private List comments;
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index d02e74a5a4..abbd2cdbde 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -86,7 +86,7 @@ namespace osu.Game.Overlays.Comments
api.Queue(request);
}
- private void onSuccess(APIComments response)
+ private void onSuccess(APICommentsController response)
{
content.Clear();
From 35cfb16c8d21594237251fbf63d4fd69491efc3f Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 19:56:43 +0300
Subject: [PATCH 077/901] Implement VotePill component
---
osu.Game/Overlays/Comments/DrawableComment.cs | 55 +++++++++++++++++--
1 file changed, 51 insertions(+), 4 deletions(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index bf24cbb70d..ce60d905ad 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -13,6 +13,8 @@ using osu.Game.Utils;
using osu.Framework.Input.Events;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Bindables;
+using osu.Framework.Graphics.Shapes;
+using osuTK.Graphics;
namespace osu.Game.Overlays.Comments
{
@@ -60,12 +62,28 @@ namespace osu.Game.Overlays.Comments
{
new Drawable[]
{
- new UpdateableAvatar(comment.User)
+ new FillFlowContainer
{
- Size = new Vector2(avatar_size),
+ AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Horizontal = margin },
- Masking = true,
- CornerRadius = avatar_size / 2,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(5, 0),
+ Children = new Drawable[]
+ {
+ new VotePill(comment.VotesCount)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ },
+ new UpdateableAvatar(comment.User)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Size = new Vector2(avatar_size),
+ Masking = true,
+ CornerRadius = avatar_size / 2,
+ },
+ }
},
new FillFlowContainer
{
@@ -239,5 +257,34 @@ namespace osu.Game.Overlays.Comments
};
}
}
+
+ private class VotePill : CircularContainer
+ {
+ private const int height = 20;
+ private const int margin = 10;
+
+ public VotePill(int count)
+ {
+ AutoSizeAxes = Axes.X;
+ Height = height;
+ Masking = true;
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4.Black
+ },
+ new SpriteText
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Margin = new MarginPadding { Horizontal = margin },
+ Font = OsuFont.GetFont(size: 14),
+ Text = $"+{count}"
+ }
+ };
+ }
+ }
}
}
From b6047e46135cd099a1d21ebcd492d38cac7f5a3b Mon Sep 17 00:00:00 2001
From: HoLLy-HaCKeR
Date: Tue, 8 Oct 2019 19:39:54 +0200
Subject: [PATCH 078/901] Move OsuCursor resize logic to OsuCursorContainer
---
osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs | 36 ++-----------------
.../UI/Cursor/OsuCursorContainer.cs | 34 ++++++++++++++++--
2 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs
index 41a02deaca..0aa8661fd3 100644
--- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs
+++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs
@@ -2,14 +2,11 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
-using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
-using osu.Game.Beatmaps;
-using osu.Game.Configuration;
using osu.Game.Rulesets.Osu.Skinning;
using osu.Game.Skinning;
using osuTK;
@@ -23,12 +20,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
private bool cursorExpand;
- private Bindable cursorScale;
- private Bindable autoCursorScale;
- private readonly IBindable beatmap = new Bindable();
-
private Container expandTarget;
- private Drawable scaleTarget;
public OsuCursor()
{
@@ -43,43 +35,19 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
}
[BackgroundDependencyLoader]
- private void load(OsuConfigManager config, IBindable beatmap)
+ private void load()
{
InternalChild = expandTarget = new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
- Child = scaleTarget = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
+ Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
}
};
-
- this.beatmap.BindTo(beatmap);
- this.beatmap.ValueChanged += _ => calculateScale();
-
- cursorScale = config.GetBindable(OsuSetting.GameplayCursorSize);
- cursorScale.ValueChanged += _ => calculateScale();
-
- autoCursorScale = config.GetBindable(OsuSetting.AutoCursorSize);
- autoCursorScale.ValueChanged += _ => calculateScale();
-
- calculateScale();
- }
-
- private void calculateScale()
- {
- float scale = cursorScale.Value;
-
- if (autoCursorScale.Value && beatmap.Value != null)
- {
- // if we have a beatmap available, let's get its circle size to figure out an automatic cursor scale modifier.
- scale *= 1f - 0.7f * (1f + beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY;
- }
-
- scaleTarget.Scale = new Vector2(scale);
}
private const float pressed_scale = 1.2f;
diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
index 6dbdf0114d..e24ab3a7cb 100644
--- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
+++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
@@ -8,6 +8,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Bindings;
+using osu.Game.Beatmaps;
+using osu.Game.Configuration;
using osu.Game.Rulesets.Osu.Configuration;
using osu.Game.Rulesets.UI;
using osu.Game.Skinning;
@@ -27,6 +29,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
private readonly Drawable cursorTrail;
+ private Bindable cursorScale;
+ private Bindable autoCursorScale;
+ private readonly IBindable beatmap = new Bindable();
+
public OsuCursorContainer()
{
InternalChild = fadeContainer = new Container
@@ -37,9 +43,33 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
}
[BackgroundDependencyLoader(true)]
- private void load(OsuRulesetConfigManager config)
+ private void load(OsuConfigManager config, OsuRulesetConfigManager rulesetConfig, IBindable beatmap)
{
- config?.BindWith(OsuRulesetSetting.ShowCursorTrail, showTrail);
+ rulesetConfig?.BindWith(OsuRulesetSetting.ShowCursorTrail, showTrail);
+
+ this.beatmap.BindTo(beatmap);
+ this.beatmap.ValueChanged += _ => calculateScale();
+
+ cursorScale = config.GetBindable(OsuSetting.GameplayCursorSize);
+ cursorScale.ValueChanged += _ => calculateScale();
+
+ autoCursorScale = config.GetBindable(OsuSetting.AutoCursorSize);
+ autoCursorScale.ValueChanged += _ => calculateScale();
+
+ calculateScale();
+ }
+
+ private void calculateScale()
+ {
+ float scale = cursorScale.Value;
+
+ if (autoCursorScale.Value && beatmap.Value != null)
+ {
+ // if we have a beatmap available, let's get its circle size to figure out an automatic cursor scale modifier.
+ scale *= 1f - 0.7f * (1f + beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY;
+ }
+
+ ActiveCursor.Scale = new Vector2(scale);
}
protected override void LoadComplete()
From 1c22fb485fa2cc8b75f230c5a5ddcd40fa090534 Mon Sep 17 00:00:00 2001
From: HoLLy-HaCKeR
Date: Tue, 8 Oct 2019 19:40:46 +0200
Subject: [PATCH 079/901] Scale cursortrail along with cursor
---
osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
index e24ab3a7cb..371c2983fc 100644
--- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
+++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
@@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
scale *= 1f - 0.7f * (1f + beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY;
}
- ActiveCursor.Scale = new Vector2(scale);
+ ActiveCursor.Scale = cursorTrail.Scale = new Vector2(scale);
}
protected override void LoadComplete()
From 9ab309fc0ef387e2226991c7f010e75f52fe1a19 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 20:44:01 +0300
Subject: [PATCH 080/901] Use bold font for replies button
---
osu.Game/Overlays/Comments/DrawableComment.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index ce60d905ad..ce78dfec9f 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -204,7 +204,7 @@ namespace osu.Game.Overlays.Comments
Alpha = count == 0 ? 0 : 1;
Child = text = new SpriteText
{
- Font = OsuFont.GetFont(size: 12),
+ Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
};
}
From b9ad079bf8b077ae7a9aa53bdb2da1e6dcc0993e Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 20:57:55 +0300
Subject: [PATCH 081/901] Move CommentsHeader to it's own file
---
.../Online/TestSceneCommentsContainer.cs | 2 +
.../Overlays/Comments/CommentsContainer.cs | 56 ---------------
osu.Game/Overlays/Comments/CommentsHeader.cs | 69 +++++++++++++++++++
3 files changed, 71 insertions(+), 56 deletions(-)
create mode 100644 osu.Game/Overlays/Comments/CommentsHeader.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index e6f9582910..c8d16bdf21 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -17,6 +17,8 @@ namespace osu.Game.Tests.Visual.Online
public override IReadOnlyList RequiredTypes => new[]
{
typeof(CommentsContainer),
+ typeof(CommentsHeader),
+ typeof(DrawableComment),
};
protected override bool UseOnlineAPI => true;
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index abbd2cdbde..f8783952d1 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -9,8 +9,6 @@ using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
-using osu.Framework.Graphics.Sprites;
-using osuTK;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Comments
@@ -115,59 +113,5 @@ namespace osu.Game.Overlays.Comments
{
background.Colour = colours.Gray3;
}
-
- private class CommentsHeader : CompositeDrawable
- {
- private const int height = 40;
- private const int spacing = 10;
- private const int padding = 50;
-
- public readonly Bindable Sort = new Bindable();
-
- private readonly Box background;
-
- public CommentsHeader()
- {
- RelativeSizeAxes = Axes.X;
- Height = height;
- AddRangeInternal(new Drawable[]
- {
- background = new Box
- {
- RelativeSizeAxes = Axes.Both,
- },
- new Container
- {
- RelativeSizeAxes = Axes.Both,
- Padding = new MarginPadding { Horizontal = padding },
- Children = new Drawable[]
- {
- new FillFlowContainer
- {
- AutoSizeAxes = Axes.Both,
- Direction = FillDirection.Horizontal,
- Spacing = new Vector2(spacing, 0),
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- Children = new Drawable[]
- {
- new SpriteText
- {
- Font = OsuFont.GetFont(size: 14),
- Text = @"Sort by"
- }
- }
- }
- }
- }
- });
- }
-
- [BackgroundDependencyLoader]
- private void load(OsuColour colours)
- {
- background.Colour = colours.Gray4;
- }
- }
}
}
diff --git a/osu.Game/Overlays/Comments/CommentsHeader.cs b/osu.Game/Overlays/Comments/CommentsHeader.cs
new file mode 100644
index 0000000000..9ebd257a5d
--- /dev/null
+++ b/osu.Game/Overlays/Comments/CommentsHeader.cs
@@ -0,0 +1,69 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Graphics.Containers;
+using osu.Game.Online.API.Requests;
+using osu.Framework.Graphics;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Graphics;
+using osu.Framework.Graphics.Sprites;
+using osuTK;
+
+namespace osu.Game.Overlays.Comments
+{
+ public class CommentsHeader : CompositeDrawable
+ {
+ private const int height = 40;
+ private const int spacing = 10;
+ private const int padding = 50;
+
+ public readonly Bindable Sort = new Bindable();
+
+ private readonly Box background;
+
+ public CommentsHeader()
+ {
+ RelativeSizeAxes = Axes.X;
+ Height = height;
+ AddRangeInternal(new Drawable[]
+ {
+ background = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ },
+ new Container
+ {
+ RelativeSizeAxes = Axes.Both,
+ Padding = new MarginPadding { Horizontal = padding },
+ Children = new Drawable[]
+ {
+ new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(spacing, 0),
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Children = new Drawable[]
+ {
+ new SpriteText
+ {
+ Font = OsuFont.GetFont(size: 14),
+ Text = @"Sort by"
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ background.Colour = colours.Gray4;
+ }
+ }
+}
From 574170124cff05070833415e324f77a2e5fe88ef Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 21:38:19 +0300
Subject: [PATCH 082/901] Implement HeaderButton component
---
.../Online/TestSceneCommentsContainer.cs | 1 +
osu.Game/Overlays/Comments/CommentsHeader.cs | 63 ++++++++++++++++-
osu.Game/Overlays/Comments/HeaderButton.cs | 68 +++++++++++++++++++
3 files changed, 131 insertions(+), 1 deletion(-)
create mode 100644 osu.Game/Overlays/Comments/HeaderButton.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index c8d16bdf21..f5205552e0 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -19,6 +19,7 @@ namespace osu.Game.Tests.Visual.Online
typeof(CommentsContainer),
typeof(CommentsHeader),
typeof(DrawableComment),
+ typeof(HeaderButton),
};
protected override bool UseOnlineAPI => true;
diff --git a/osu.Game/Overlays/Comments/CommentsHeader.cs b/osu.Game/Overlays/Comments/CommentsHeader.cs
index 9ebd257a5d..b9dee7935e 100644
--- a/osu.Game/Overlays/Comments/CommentsHeader.cs
+++ b/osu.Game/Overlays/Comments/CommentsHeader.cs
@@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osuTK;
+using osu.Framework.Input.Events;
namespace osu.Game.Overlays.Comments
{
@@ -18,8 +19,10 @@ namespace osu.Game.Overlays.Comments
private const int height = 40;
private const int spacing = 10;
private const int padding = 50;
+ private const int text_size = 14;
public readonly Bindable Sort = new Bindable();
+ public readonly BindableBool ShowDeleted = new BindableBool();
private readonly Box background;
@@ -50,10 +53,16 @@ namespace osu.Game.Overlays.Comments
{
new SpriteText
{
- Font = OsuFont.GetFont(size: 14),
+ Font = OsuFont.GetFont(size: text_size),
Text = @"Sort by"
}
}
+ },
+ new ShowDeletedButton
+ {
+ Anchor = Anchor.CentreRight,
+ Origin = Anchor.CentreRight,
+ Checked = { BindTarget = ShowDeleted }
}
}
}
@@ -65,5 +74,57 @@ namespace osu.Game.Overlays.Comments
{
background.Colour = colours.Gray4;
}
+
+ private class ShowDeletedButton : HeaderButton
+ {
+ private const int spacing = 5;
+
+ public readonly BindableBool Checked = new BindableBool();
+
+ private readonly SpriteIcon checkboxIcon;
+
+ public ShowDeletedButton()
+ {
+ Add(new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(spacing, 0),
+ Children = new Drawable[]
+ {
+ checkboxIcon = new SpriteIcon
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Size = new Vector2(10),
+ },
+ new SpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Font = OsuFont.GetFont(size: text_size),
+ Text = @"Show deleted"
+ }
+ },
+ });
+ }
+
+ protected override void LoadComplete()
+ {
+ Checked.BindValueChanged(onCheckedChanged, true);
+ base.LoadComplete();
+ }
+
+ private void onCheckedChanged(ValueChangedEvent isChecked)
+ {
+ checkboxIcon.Icon = isChecked.NewValue ? FontAwesome.Solid.CheckSquare : FontAwesome.Regular.Square;
+ }
+
+ protected override bool OnClick(ClickEvent e)
+ {
+ Checked.Value = !Checked.Value;
+ return base.OnClick(e);
+ }
+ }
}
}
diff --git a/osu.Game/Overlays/Comments/HeaderButton.cs b/osu.Game/Overlays/Comments/HeaderButton.cs
new file mode 100644
index 0000000000..db8ea92a1a
--- /dev/null
+++ b/osu.Game/Overlays/Comments/HeaderButton.cs
@@ -0,0 +1,68 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Graphics;
+using osu.Framework.Input.Events;
+using osu.Game.Graphics.UserInterface;
+
+namespace osu.Game.Overlays.Comments
+{
+ public class HeaderButton : Container
+ {
+ private const int height = 20;
+ private const int corner_radius = 3;
+ private const int margin = 10;
+ private const int duration = 200;
+
+ protected override Container Content => content;
+
+ private readonly Box background;
+ private readonly Container content;
+
+ public HeaderButton()
+ {
+ AutoSizeAxes = Axes.X;
+ Height = height;
+ Masking = true;
+ CornerRadius = corner_radius;
+ AddRangeInternal(new Drawable[]
+ {
+ background = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Alpha = 0,
+ },
+ content = new Container
+ {
+ AutoSizeAxes = Axes.Both,
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Margin = new MarginPadding { Horizontal = margin }
+ },
+ new HoverClickSounds(),
+ });
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ background.Colour = colours.Gray6;
+ }
+
+ protected override bool OnHover(HoverEvent e)
+ {
+ background.FadeIn(duration, Easing.OutQuint);
+ return base.OnHover(e);
+ }
+
+ protected override void OnHoverLost(HoverLostEvent e)
+ {
+ base.OnHoverLost(e);
+ background.FadeOut(duration, Easing.OutQuint);
+ }
+ }
+}
From 29b0eacc821b5091c0251d6066e2e52296d8c279 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 8 Oct 2019 22:46:42 +0300
Subject: [PATCH 083/901] Implement SortSelector component
---
.../Online/TestSceneCommentsContainer.cs | 1 +
.../Online/API/Requests/GetCommentsRequest.cs | 2 +-
.../Online/API/Requests/Responses/Comment.cs | 2 +-
.../Overlays/Comments/CommentsContainer.cs | 3 +-
osu.Game/Overlays/Comments/CommentsHeader.cs | 8 ++
osu.Game/Overlays/Comments/DrawableComment.cs | 9 ++-
osu.Game/Overlays/Comments/HeaderButton.cs | 8 +-
osu.Game/Overlays/Comments/SortSelector.cs | 75 +++++++++++++++++++
8 files changed, 101 insertions(+), 7 deletions(-)
create mode 100644 osu.Game/Overlays/Comments/SortSelector.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index f5205552e0..7fbe9d7e8b 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -20,6 +20,7 @@ namespace osu.Game.Tests.Visual.Online
typeof(CommentsHeader),
typeof(DrawableComment),
typeof(HeaderButton),
+ typeof(SortSelector)
};
protected override bool UseOnlineAPI => true;
diff --git a/osu.Game/Online/API/Requests/GetCommentsRequest.cs b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
index 5a2b61b4d0..02a36f7aa2 100644
--- a/osu.Game/Online/API/Requests/GetCommentsRequest.cs
+++ b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
@@ -28,7 +28,7 @@ namespace osu.Game.Online.API.Requests
req.AddParameter("commentable_type", type.ToString().Underscore().ToLowerInvariant());
req.AddParameter("commentable_id", id.ToString());
- req.AddParameter("sort", sort.ToString());
+ req.AddParameter("sort", sort.ToString().ToLowerInvariant());
req.AddParameter("page", page.ToString());
return req;
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index e5d3f14d27..30aca3c2ea 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -31,7 +31,7 @@ namespace osu.Game.Online.API.Requests.Responses
public Comment ParentComment { get; set; }
[JsonProperty(@"user_id")]
- public long UserId { get; set; }
+ public long? UserId { get; set; }
public User User { get; set; }
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index f8783952d1..5be1b6c1c4 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -79,6 +79,7 @@ namespace osu.Game.Overlays.Comments
private void getComments()
{
request?.Cancel();
+ content.Clear();
request = new GetCommentsRequest(type, id, Sort.Value);
request.Success += onSuccess;
api.Queue(request);
@@ -86,8 +87,6 @@ namespace osu.Game.Overlays.Comments
private void onSuccess(APICommentsController response)
{
- content.Clear();
-
foreach (var c in response.Comments)
{
if (!c.IsDeleted && c.IsTopLevel)
diff --git a/osu.Game/Overlays/Comments/CommentsHeader.cs b/osu.Game/Overlays/Comments/CommentsHeader.cs
index b9dee7935e..90a6f44d6b 100644
--- a/osu.Game/Overlays/Comments/CommentsHeader.cs
+++ b/osu.Game/Overlays/Comments/CommentsHeader.cs
@@ -53,8 +53,16 @@ namespace osu.Game.Overlays.Comments
{
new SpriteText
{
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: text_size),
Text = @"Sort by"
+ },
+ new SortSelector
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Current = { BindTarget = Sort }
}
}
},
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index ce78dfec9f..41b30513a1 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -161,7 +161,14 @@ namespace osu.Game.Overlays.Comments
}
};
- username.AddUserLink(comment.User);
+ if (comment.UserId == null)
+ {
+ username.AddText(comment.LegacyName);
+ }
+ else
+ {
+ username.AddUserLink(comment.User);
+ }
comment.ChildComments.ForEach(c =>
{
diff --git a/osu.Game/Overlays/Comments/HeaderButton.cs b/osu.Game/Overlays/Comments/HeaderButton.cs
index db8ea92a1a..e3729b3b05 100644
--- a/osu.Game/Overlays/Comments/HeaderButton.cs
+++ b/osu.Game/Overlays/Comments/HeaderButton.cs
@@ -55,14 +55,18 @@ namespace osu.Game.Overlays.Comments
protected override bool OnHover(HoverEvent e)
{
- background.FadeIn(duration, Easing.OutQuint);
+ FadeInBackground();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
- background.FadeOut(duration, Easing.OutQuint);
+ FadeOutBackground();
}
+
+ public void FadeInBackground() => background.FadeIn(duration, Easing.OutQuint);
+
+ public void FadeOutBackground() => background.FadeOut(duration, Easing.OutQuint);
}
}
diff --git a/osu.Game/Overlays/Comments/SortSelector.cs b/osu.Game/Overlays/Comments/SortSelector.cs
new file mode 100644
index 0000000000..4425145c3e
--- /dev/null
+++ b/osu.Game/Overlays/Comments/SortSelector.cs
@@ -0,0 +1,75 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Online.API.Requests;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.UserInterface;
+using osu.Framework.Graphics.Sprites;
+using osu.Game.Graphics;
+using osuTK;
+using osu.Game.Graphics.UserInterface;
+using osu.Framework.Input.Events;
+using osu.Framework.Bindables;
+
+namespace osu.Game.Overlays.Comments
+{
+ public class SortSelector : OsuTabControl
+ {
+ private const int spacing = 5;
+
+ protected override Dropdown CreateDropdown() => null;
+
+ protected override TabItem CreateTabItem(SortCommentsBy value) => new SortTabItem(value);
+
+ protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(spacing, 0),
+ };
+
+ public SortSelector()
+ {
+ AutoSizeAxes = Axes.Both;
+ }
+
+ private class SortTabItem : TabItem
+ {
+ private readonly TabContent content;
+
+ public SortTabItem(SortCommentsBy value)
+ : base(value)
+ {
+ AutoSizeAxes = Axes.Both;
+ Child = content = new TabContent(value)
+ { Active = { BindTarget = Active } };
+ }
+
+ protected override void OnActivated() => content.FadeInBackground();
+
+ protected override void OnDeactivated() => content.FadeOutBackground();
+
+ private class TabContent : HeaderButton
+ {
+ private const int text_size = 14;
+
+ public readonly BindableBool Active = new BindableBool();
+
+ public TabContent(SortCommentsBy value)
+ {
+ Add(new SpriteText
+ {
+ Font = OsuFont.GetFont(size: text_size),
+ Text = value.ToString()
+ });
+ }
+
+ protected override void OnHoverLost(HoverLostEvent e)
+ {
+ if (!Active.Value) base.OnHoverLost(e);
+ }
+ }
+ }
+ }
+}
From faef4d932d08cc7ef5fde89d88953b3c21cd7ac6 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 9 Oct 2019 10:17:14 +0300
Subject: [PATCH 084/901] Improve message parsing
---
osu.Game/Online/API/Requests/Responses/Comment.cs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 30aca3c2ea..fb0aad0e0b 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -87,8 +87,7 @@ namespace osu.Game.Online.API.Requests.Responses
public string GetMessage()
{
- //temporary fix until HTML parsing will be implemented
- return MessageHTML.Remove(MessageHTML.LastIndexOf("")).Substring(65);
+ return MessageHTML.Replace("", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace("
", "");
}
}
}
From 4462d454e87fba91a25b92b3bc4fef0a9ba6007c Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 9 Oct 2019 10:34:17 +0300
Subject: [PATCH 085/901] Message padding improvements
---
osu.Game/Overlays/Comments/CommentsContainer.cs | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 5be1b6c1c4..b9effb39e8 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -16,6 +16,7 @@ namespace osu.Game.Overlays.Comments
public class CommentsContainer : CompositeDrawable
{
private const float separator_height = 1.5f;
+ private const int padding = 40;
private readonly CommentableType type;
private readonly long id;
@@ -92,7 +93,13 @@ namespace osu.Game.Overlays.Comments
if (!c.IsDeleted && c.IsTopLevel)
content.AddRange(new Drawable[]
{
- new DrawableComment(c),
+ new Container
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Padding = new MarginPadding { Right = padding },
+ Child = new DrawableComment(c)
+ },
new Container
{
RelativeSizeAxes = Axes.X,
From 0a56b041fdf7116ceb72d8a7251383f912961f5f Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 9 Oct 2019 11:07:56 +0300
Subject: [PATCH 086/901] Implement ShowChildsButton
---
.../Online/TestSceneCommentsContainer.cs | 3 +-
.../Online/API/Requests/Responses/Comment.cs | 2 +-
.../Overlays/Comments/CommentsContainer.cs | 9 +--
osu.Game/Overlays/Comments/DrawableComment.cs | 72 ++++++++++++-------
.../Overlays/Comments/ShowChildsButton.cs | 34 +++++++++
5 files changed, 85 insertions(+), 35 deletions(-)
create mode 100644 osu.Game/Overlays/Comments/ShowChildsButton.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index 7fbe9d7e8b..4187771963 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -20,7 +20,8 @@ namespace osu.Game.Tests.Visual.Online
typeof(CommentsHeader),
typeof(DrawableComment),
typeof(HeaderButton),
- typeof(SortSelector)
+ typeof(SortSelector),
+ typeof(ShowChildsButton)
};
protected override bool UseOnlineAPI => true;
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index fb0aad0e0b..9a3dee30b4 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -87,7 +87,7 @@ namespace osu.Game.Online.API.Requests.Responses
public string GetMessage()
{
- return MessageHTML.Replace("", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace("
", "");
+ return MessageHTML.Replace("", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace(""", "\"");
}
}
}
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index b9effb39e8..5be1b6c1c4 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -16,7 +16,6 @@ namespace osu.Game.Overlays.Comments
public class CommentsContainer : CompositeDrawable
{
private const float separator_height = 1.5f;
- private const int padding = 40;
private readonly CommentableType type;
private readonly long id;
@@ -93,13 +92,7 @@ namespace osu.Game.Overlays.Comments
if (!c.IsDeleted && c.IsTopLevel)
content.AddRange(new Drawable[]
{
- new Container
- {
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Padding = new MarginPadding { Right = padding },
- Child = new DrawableComment(c)
- },
+ new DrawableComment(c),
new Container
{
RelativeSizeAxes = Axes.X,
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 41b30513a1..a66b8fcd44 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -10,11 +10,11 @@ using osu.Game.Online.API.Requests.Responses;
using osu.Game.Users.Drawables;
using osu.Game.Graphics.Containers;
using osu.Game.Utils;
-using osu.Framework.Input.Events;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
+using System.Linq;
namespace osu.Game.Overlays.Comments
{
@@ -23,6 +23,8 @@ namespace osu.Game.Overlays.Comments
private const int avatar_size = 40;
private const int margin = 10;
private const int child_margin = 20;
+ private const int chevron_margin = 30;
+ private const int message_padding = 40;
private const int duration = 200;
private readonly BindableBool childExpanded = new BindableBool(true);
@@ -93,25 +95,41 @@ namespace osu.Game.Overlays.Comments
Spacing = new Vector2(0, 2),
Children = new Drawable[]
{
- new FillFlowContainer
+ new Container
{
- AutoSizeAxes = Axes.Both,
- Direction = FillDirection.Horizontal,
- Spacing = new Vector2(7, 0),
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
- username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
+ new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(7, 0),
+ Children = new Drawable[]
+ {
+ username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
+ {
+ AutoSizeAxes = Axes.Both,
+ },
+ new ParentUsername(comment)
+ }
},
- new ParentUsername(comment)
+ new ChevronButton(comment)
+ {
+ Anchor = Anchor.TopRight,
+ Origin = Anchor.TopRight,
+ Margin = new MarginPadding { Right = chevron_margin },
+ Expanded = { BindTarget = childExpanded }
+ }
}
},
new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Text = comment.GetMessage()
+ Text = comment.GetMessage(),
+ Padding = new MarginPadding { Right = message_padding }
}
}
}
@@ -196,18 +214,34 @@ namespace osu.Game.Overlays.Comments
}
}
- private class RepliesButton : Container
+ private class ChevronButton : ShowChildsButton
+ {
+ private readonly SpriteIcon icon;
+
+ public ChevronButton(Comment comment)
+ {
+ Alpha = comment.IsTopLevel && comment.ChildComments.Any() ? 1 : 0;
+ Child = icon = new SpriteIcon
+ {
+ Size = new Vector2(12),
+ };
+ }
+
+ protected override void OnExpandedChanged(ValueChangedEvent expanded)
+ {
+ icon.Icon = expanded.NewValue ? FontAwesome.Solid.ChevronUp : FontAwesome.Solid.ChevronDown;
+ }
+ }
+
+ private class RepliesButton : ShowChildsButton
{
private readonly SpriteText text;
private readonly int count;
- public readonly BindableBool Expanded = new BindableBool(true);
-
public RepliesButton(int count)
{
this.count = count;
- AutoSizeAxes = Axes.Both;
Alpha = count == 0 ? 0 : 1;
Child = text = new SpriteText
{
@@ -215,22 +249,10 @@ namespace osu.Game.Overlays.Comments
};
}
- protected override void LoadComplete()
- {
- Expanded.BindValueChanged(onExpandedChanged, true);
- base.LoadComplete();
- }
-
- private void onExpandedChanged(ValueChangedEvent expanded)
+ protected override void OnExpandedChanged(ValueChangedEvent expanded)
{
text.Text = $@"{(expanded.NewValue ? "[+]" : "[-]")} replies ({count})";
}
-
- protected override bool OnClick(ClickEvent e)
- {
- Expanded.Value = !Expanded.Value;
- return base.OnClick(e);
- }
}
private class ParentUsername : FillFlowContainer, IHasTooltip
diff --git a/osu.Game/Overlays/Comments/ShowChildsButton.cs b/osu.Game/Overlays/Comments/ShowChildsButton.cs
new file mode 100644
index 0000000000..81280a71b5
--- /dev/null
+++ b/osu.Game/Overlays/Comments/ShowChildsButton.cs
@@ -0,0 +1,34 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics;
+using osu.Game.Graphics.Containers;
+using osu.Framework.Input.Events;
+using osu.Framework.Bindables;
+
+namespace osu.Game.Overlays.Comments
+{
+ public abstract class ShowChildsButton : OsuHoverContainer
+ {
+ public readonly BindableBool Expanded = new BindableBool(true);
+
+ public ShowChildsButton()
+ {
+ AutoSizeAxes = Axes.Both;
+ }
+
+ protected override void LoadComplete()
+ {
+ Expanded.BindValueChanged(OnExpandedChanged, true);
+ base.LoadComplete();
+ }
+
+ protected abstract void OnExpandedChanged(ValueChangedEvent expanded);
+
+ protected override bool OnClick(ClickEvent e)
+ {
+ Expanded.Value = !Expanded.Value;
+ return base.OnClick(e);
+ }
+ }
+}
From a0dfbfe1488e9cbb66ad068828fdbf88069b24ec Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 9 Oct 2019 11:18:26 +0300
Subject: [PATCH 087/901] Handle parent usernames for legacy comments
---
osu.Game/Overlays/Comments/DrawableComment.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index a66b8fcd44..6215f5e108 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -281,7 +281,7 @@ namespace osu.Game.Overlays.Comments
new SpriteText
{
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
- Text = comment.ParentComment?.User?.Username
+ Text = comment.ParentComment?.User?.Username ?? comment.ParentComment?.LegacyName
}
};
}
From ad99a3236f052d2f2130a8c3559093f5c3c3699d Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 9 Oct 2019 11:32:17 +0300
Subject: [PATCH 088/901] Handle edited comments
---
.../Requests/Responses/APICommentsController.cs | 3 +++
osu.Game/Online/API/Requests/Responses/Comment.cs | 2 ++
osu.Game/Overlays/Comments/DrawableComment.cs | 14 +++++++++++++-
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Online/API/Requests/Responses/APICommentsController.cs b/osu.Game/Online/API/Requests/Responses/APICommentsController.cs
index cf2e5e8a35..ca6062e371 100644
--- a/osu.Game/Online/API/Requests/Responses/APICommentsController.cs
+++ b/osu.Game/Online/API/Requests/Responses/APICommentsController.cs
@@ -63,6 +63,9 @@ namespace osu.Game.Online.API.Requests.Responses
{
if (c.UserId == u.Id)
c.User = u;
+
+ if (c.EditedById == u.Id)
+ c.EditedUser = u;
});
});
}
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 9a3dee30b4..e420a585fe 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -81,6 +81,8 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"edited_by_id")]
public long? EditedById { get; set; }
+ public User EditedUser { get; set; }
+
public bool IsTopLevel { get; set; }
public bool IsDeleted { get; set; }
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 6215f5e108..92b59a985b 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -35,6 +35,7 @@ namespace osu.Game.Overlays.Comments
{
LinkFlowContainer username;
FillFlowContainer childCommentsContainer;
+ FillFlowContainer info;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@@ -140,7 +141,7 @@ namespace osu.Game.Overlays.Comments
{
RelativeSizeAxes = Axes.Both,
},
- new FillFlowContainer
+ info = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
@@ -188,6 +189,17 @@ namespace osu.Game.Overlays.Comments
username.AddUserLink(comment.User);
}
+ if (comment.EditedAt.HasValue)
+ {
+ info.Add(new SpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Font = OsuFont.GetFont(size: 12),
+ Text = $@"edited {HumanizerUtils.Humanize(comment.EditedAt.Value)} by {comment.EditedUser.Username}"
+ });
+ }
+
comment.ChildComments.ForEach(c =>
{
if (!c.IsDeleted)
From b2bd78308dc4473d89d89244b873e5bd97b9f54f Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 9 Oct 2019 12:18:49 +0300
Subject: [PATCH 089/901] Handle deleted comments
---
.../Online/API/Requests/Responses/Comment.cs | 2 +-
.../Overlays/Comments/CommentsContainer.cs | 24 +--
osu.Game/Overlays/Comments/DrawableComment.cs | 150 +++++++++++-------
3 files changed, 98 insertions(+), 78 deletions(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index e420a585fe..76a322e5c9 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -89,7 +89,7 @@ namespace osu.Game.Online.API.Requests.Responses
public string GetMessage()
{
- return MessageHTML.Replace("", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace(""", "\"");
+ return IsDeleted ? @"deleted" : MessageHTML.Replace("", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace(""", "\"");
}
}
}
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 5be1b6c1c4..fb97f08a6e 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -15,12 +15,11 @@ namespace osu.Game.Overlays.Comments
{
public class CommentsContainer : CompositeDrawable
{
- private const float separator_height = 1.5f;
-
private readonly CommentableType type;
private readonly long id;
public readonly Bindable Sort = new Bindable();
+ public readonly BindableBool ShowDeleted = new BindableBool();
[Resolved]
private IAPIProvider api { get; set; }
@@ -55,7 +54,8 @@ namespace osu.Game.Overlays.Comments
{
new CommentsHeader
{
- Sort = { BindTarget = Sort }
+ Sort = { BindTarget = Sort },
+ ShowDeleted = { BindTarget = ShowDeleted }
},
content = new FillFlowContainer
{
@@ -89,21 +89,9 @@ namespace osu.Game.Overlays.Comments
{
foreach (var c in response.Comments)
{
- if (!c.IsDeleted && c.IsTopLevel)
- content.AddRange(new Drawable[]
- {
- new DrawableComment(c),
- new Container
- {
- RelativeSizeAxes = Axes.X,
- Height = separator_height,
- Child = new Box
- {
- RelativeSizeAxes = Axes.Both,
- Colour = colours.Gray1,
- }
- }
- });
+ if (c.IsTopLevel)
+ content.Add(new DrawableComment(c)
+ { ShowDeleted = { BindTarget = ShowDeleted } });
}
}
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 92b59a985b..4092cbb177 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -26,19 +26,29 @@ namespace osu.Game.Overlays.Comments
private const int chevron_margin = 30;
private const int message_padding = 40;
private const int duration = 200;
+ private const float separator_height = 1.5f;
+
+ public readonly BindableBool ShowDeleted = new BindableBool();
private readonly BindableBool childExpanded = new BindableBool(true);
private readonly Container childCommentsVisibilityContainer;
+ private readonly Comment comment;
public DrawableComment(Comment comment)
{
LinkFlowContainer username;
FillFlowContainer childCommentsContainer;
FillFlowContainer info;
+ TextFlowContainer message;
+ GridContainer content;
+ VotePill votePill;
+
+ this.comment = comment;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
+ Masking = true;
InternalChild = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
@@ -46,7 +56,7 @@ namespace osu.Game.Overlays.Comments
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
- new GridContainer
+ content = new GridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@@ -58,7 +68,6 @@ namespace osu.Game.Overlays.Comments
},
RowDimensions = new[]
{
- new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize)
},
Content = new[]
@@ -73,10 +82,11 @@ namespace osu.Game.Overlays.Comments
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{
- new VotePill(comment.VotesCount)
+ votePill = new VotePill(comment.VotesCount)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
+ AlwaysPresent = true,
},
new UpdateableAvatar(comment.User)
{
@@ -92,71 +102,53 @@ namespace osu.Game.Overlays.Comments
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Margin = new MarginPadding { Top = margin / 2 },
- Spacing = new Vector2(0, 2),
+ Spacing = new Vector2(0, 3),
Children = new Drawable[]
{
- new Container
+ new FillFlowContainer
{
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(7, 0),
Children = new Drawable[]
{
- new FillFlowContainer
+ username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
{
AutoSizeAxes = Axes.Both,
- Direction = FillDirection.Horizontal,
- Spacing = new Vector2(7, 0),
- Children = new Drawable[]
- {
- username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
- {
- AutoSizeAxes = Axes.Both,
- },
- new ParentUsername(comment)
- }
},
- new ChevronButton(comment)
+ new ParentUsername(comment),
+ new SpriteText
{
- Anchor = Anchor.TopRight,
- Origin = Anchor.TopRight,
- Margin = new MarginPadding { Right = chevron_margin },
- Expanded = { BindTarget = childExpanded }
+ Alpha = comment.IsDeleted? 1 : 0,
+ Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
+ Text = @"deleted",
}
}
},
- new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
+ message = new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Text = comment.GetMessage(),
Padding = new MarginPadding { Right = message_padding }
- }
- }
- }
- },
- new Drawable[]
- {
- new Container
- {
- RelativeSizeAxes = Axes.Both,
- },
- info = new FillFlowContainer
- {
- AutoSizeAxes = Axes.Both,
- Direction = FillDirection.Horizontal,
- Spacing = new Vector2(10, 0),
- Children = new Drawable[]
- {
- new SpriteText
- {
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- Font = OsuFont.GetFont(size: 12),
- Text = HumanizerUtils.Humanize(comment.CreatedAt)
},
- new RepliesButton(comment.RepliesCount)
- { Expanded = { BindTarget = childExpanded } },
+ info = new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(10, 0),
+ Children = new Drawable[]
+ {
+ new SpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Font = OsuFont.GetFont(size: 12),
+ Text = HumanizerUtils.Humanize(comment.CreatedAt)
+ },
+ new RepliesButton(comment.RepliesCount)
+ { Expanded = { BindTarget = childExpanded } },
+ }
+ }
}
}
}
@@ -181,13 +173,9 @@ namespace osu.Game.Overlays.Comments
};
if (comment.UserId == null)
- {
username.AddText(comment.LegacyName);
- }
else
- {
username.AddUserLink(comment.User);
- }
if (comment.EditedAt.HasValue)
{
@@ -200,15 +188,45 @@ namespace osu.Game.Overlays.Comments
});
}
- comment.ChildComments.ForEach(c =>
+ if (!comment.IsDeleted)
+ message.Text = comment.GetMessage();
+ else
{
- if (!c.IsDeleted)
- childCommentsContainer.Add(new DrawableComment(c));
- });
+ content.FadeColour(OsuColour.Gray(0.5f));
+ votePill.Hide();
+ }
+
+ if (comment.IsTopLevel)
+ {
+ AddInternal(new Container
+ {
+ RelativeSizeAxes = Axes.X,
+ Height = separator_height,
+ Child = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = OsuColour.Gray(0.1f)
+ }
+ });
+
+ if (comment.ChildComments.Any())
+ {
+ AddInternal(new ChevronButton(comment)
+ {
+ Anchor = Anchor.TopRight,
+ Origin = Anchor.TopRight,
+ Margin = new MarginPadding { Right = chevron_margin, Top = margin },
+ Expanded = { BindTarget = childExpanded }
+ });
+ }
+ }
+
+ comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c)));
}
protected override void LoadComplete()
{
+ ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
childExpanded.BindValueChanged(onChildExpandedChanged, true);
base.LoadComplete();
}
@@ -226,6 +244,20 @@ namespace osu.Game.Overlays.Comments
}
}
+ private void onShowDeletedChanged(ValueChangedEvent show)
+ {
+ if (comment.IsDeleted)
+ {
+ if (show.NewValue)
+ AutoSizeAxes = Axes.Y;
+ else
+ {
+ AutoSizeAxes = Axes.None;
+ this.ResizeHeightTo(0);
+ }
+ }
+ }
+
private class ChevronButton : ShowChildsButton
{
private readonly SpriteIcon icon;
From 7e3c97f4962e0503b16527d13cc2fb545a3dc659 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 9 Oct 2019 13:37:07 +0300
Subject: [PATCH 090/901] Implement DeletedChildsPlaceholder component
---
.../Online/TestSceneCommentsContainer.cs | 6 ++
.../Online/API/Requests/Responses/Comment.cs | 18 +++++
osu.Game/Overlays/Comments/DrawableComment.cs | 66 +++++++++++++++++--
3 files changed, 86 insertions(+), 4 deletions(-)
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index 4187771963..8a6ec81d8e 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -40,6 +40,12 @@ namespace osu.Game.Tests.Visual.Online
scrollFlow.Clear();
scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 41823));
});
+
+ AddStep("Airman comments", () =>
+ {
+ scrollFlow.Clear();
+ scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 24313));
+ });
}
}
}
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 76a322e5c9..6fea994cb9 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -5,6 +5,7 @@ using Newtonsoft.Json;
using osu.Game.Users;
using System;
using System.Collections.Generic;
+using System.Linq;
namespace osu.Game.Online.API.Requests.Responses
{
@@ -91,5 +92,22 @@ namespace osu.Game.Online.API.Requests.Responses
{
return IsDeleted ? @"deleted" : MessageHTML.Replace("", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace(""", "\"");
}
+
+ public int GetDeletedChildsCount()
+ {
+ int count = 0;
+
+ if (ChildComments.Any())
+ ChildComments.ForEach(child =>
+ {
+ if (child.IsDeleted)
+ count++;
+ });
+
+ if (IsDeleted)
+ count++;
+
+ return count;
+ }
}
}
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 4092cbb177..60cae8c62a 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -27,6 +27,7 @@ namespace osu.Game.Overlays.Comments
private const int message_padding = 40;
private const int duration = 200;
private const float separator_height = 1.5f;
+ private const int deleted_placeholder_margin = 80;
public readonly BindableBool ShowDeleted = new BindableBool();
@@ -161,12 +162,26 @@ namespace osu.Game.Overlays.Comments
AutoSizeDuration = duration,
AutoSizeEasing = Easing.OutQuint,
Masking = true,
- Child = childCommentsContainer = new FillFlowContainer
+ Child = new FillFlowContainer
{
- Margin = new MarginPadding { Left = child_margin },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Direction = FillDirection.Vertical
+ Direction = FillDirection.Vertical,
+ Children = new Drawable[]
+ {
+ childCommentsContainer = new FillFlowContainer
+ {
+ Margin = new MarginPadding { Left = child_margin },
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical
+ },
+ new DeletedChildsPlaceholder(comment.GetDeletedChildsCount())
+ {
+ Margin = new MarginPadding { Bottom = margin, Left = deleted_placeholder_margin },
+ ShowDeleted = { BindTarget = ShowDeleted }
+ }
+ }
}
}
}
@@ -221,7 +236,8 @@ namespace osu.Game.Overlays.Comments
}
}
- comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c)));
+ comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c)
+ { ShowDeleted = { BindTarget = ShowDeleted } }));
}
protected override void LoadComplete()
@@ -258,6 +274,48 @@ namespace osu.Game.Overlays.Comments
}
}
+ private class DeletedChildsPlaceholder : FillFlowContainer
+ {
+ public readonly BindableBool ShowDeleted = new BindableBool();
+
+ private readonly bool canBeVisible;
+
+ public DeletedChildsPlaceholder(int count)
+ {
+ canBeVisible = count != 0;
+
+ AutoSizeAxes = Axes.Both;
+ Direction = FillDirection.Horizontal;
+ Spacing = new Vector2(3, 0);
+ Alpha = 0;
+ Children = new Drawable[]
+ {
+ new SpriteIcon
+ {
+ Icon = FontAwesome.Solid.Trash,
+ Size = new Vector2(14),
+ },
+ new SpriteText
+ {
+ Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
+ Text = $@"{count} deleted comments"
+ }
+ };
+ }
+
+ protected override void LoadComplete()
+ {
+ ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
+ base.LoadComplete();
+ }
+
+ private void onShowDeletedChanged(ValueChangedEvent showDeleted)
+ {
+ if (canBeVisible)
+ this.FadeTo(showDeleted.NewValue ? 0 : 1);
+ }
+ }
+
private class ChevronButton : ShowChildsButton
{
private readonly SpriteIcon icon;
From c9d5bea0f1bd1a8a01c4fe2f08242e8292dffe22 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 9 Oct 2019 13:45:14 +0300
Subject: [PATCH 091/901] Remove animations
---
osu.Game/Overlays/Comments/DrawableComment.cs | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 60cae8c62a..94ec7a861a 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -25,7 +25,6 @@ namespace osu.Game.Overlays.Comments
private const int child_margin = 20;
private const int chevron_margin = 30;
private const int message_padding = 40;
- private const int duration = 200;
private const float separator_height = 1.5f;
private const int deleted_placeholder_margin = 80;
@@ -159,8 +158,6 @@ namespace osu.Game.Overlays.Comments
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- AutoSizeDuration = duration,
- AutoSizeEasing = Easing.OutQuint,
Masking = true,
Child = new FillFlowContainer
{
@@ -249,14 +246,12 @@ namespace osu.Game.Overlays.Comments
private void onChildExpandedChanged(ValueChangedEvent expanded)
{
- childCommentsVisibilityContainer.ClearTransforms();
-
if (expanded.NewValue)
childCommentsVisibilityContainer.AutoSizeAxes = Axes.Y;
else
{
childCommentsVisibilityContainer.AutoSizeAxes = Axes.None;
- childCommentsVisibilityContainer.ResizeHeightTo(0, duration, Easing.OutQuint);
+ childCommentsVisibilityContainer.ResizeHeightTo(0);
}
}
From 107d39c3e97edb17e56bc9377d7e6cf76574ed43 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 9 Oct 2019 14:10:05 +0300
Subject: [PATCH 092/901] Add DeletedChildsPlaceholder to the bottom of the
comments container
---
.../Online/TestSceneCommentsContainer.cs | 3 +-
.../Online/API/Requests/Responses/Comment.cs | 3 -
.../Overlays/Comments/CommentsContainer.cs | 13 +++++
.../Comments/DeletedChildsPlaceholder.cs | 58 +++++++++++++++++++
osu.Game/Overlays/Comments/DrawableComment.cs | 46 +--------------
5 files changed, 75 insertions(+), 48 deletions(-)
create mode 100644 osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index 8a6ec81d8e..342ba487f0 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -21,7 +21,8 @@ namespace osu.Game.Tests.Visual.Online
typeof(DrawableComment),
typeof(HeaderButton),
typeof(SortSelector),
- typeof(ShowChildsButton)
+ typeof(ShowChildsButton),
+ typeof(DeletedChildsPlaceholder)
};
protected override bool UseOnlineAPI => true;
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 6fea994cb9..2334c86519 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -104,9 +104,6 @@ namespace osu.Game.Online.API.Requests.Responses
count++;
});
- if (IsDeleted)
- count++;
-
return count;
}
}
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index fb97f08a6e..bf68457988 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -93,6 +93,19 @@ namespace osu.Game.Overlays.Comments
content.Add(new DrawableComment(c)
{ ShowDeleted = { BindTarget = ShowDeleted } });
}
+
+ int deletedComments = 0;
+
+ response.Comments.ForEach(comment =>
+ {
+ if (comment.IsDeleted && comment.IsTopLevel)
+ deletedComments++;
+ });
+
+ content.Add(new DeletedChildsPlaceholder(deletedComments)
+ {
+ ShowDeleted = { BindTarget = ShowDeleted }
+ });
}
[BackgroundDependencyLoader]
diff --git a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs b/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
new file mode 100644
index 0000000000..d0e6c17ccb
--- /dev/null
+++ b/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
@@ -0,0 +1,58 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics;
+using osu.Game.Graphics;
+using osu.Framework.Graphics.Sprites;
+using osuTK;
+using osu.Framework.Bindables;
+
+namespace osu.Game.Overlays.Comments
+{
+ public class DeletedChildsPlaceholder : FillFlowContainer
+ {
+ private const int deleted_placeholder_margin = 80;
+ private const int margin = 10;
+
+ public readonly BindableBool ShowDeleted = new BindableBool();
+
+ private readonly bool canBeVisible;
+
+ public DeletedChildsPlaceholder(int count)
+ {
+ canBeVisible = count != 0;
+
+ AutoSizeAxes = Axes.Both;
+ Direction = FillDirection.Horizontal;
+ Spacing = new Vector2(3, 0);
+ Margin = new MarginPadding { Vertical = margin, Left = deleted_placeholder_margin };
+ Alpha = 0;
+ Children = new Drawable[]
+ {
+ new SpriteIcon
+ {
+ Icon = FontAwesome.Solid.Trash,
+ Size = new Vector2(14),
+ },
+ new SpriteText
+ {
+ Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
+ Text = $@"{count} deleted comments"
+ }
+ };
+ }
+
+ protected override void LoadComplete()
+ {
+ ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
+ base.LoadComplete();
+ }
+
+ private void onShowDeletedChanged(ValueChangedEvent showDeleted)
+ {
+ if (canBeVisible)
+ this.FadeTo(showDeleted.NewValue ? 0 : 1);
+ }
+ }
+}
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 94ec7a861a..4af2e07227 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -26,7 +26,6 @@ namespace osu.Game.Overlays.Comments
private const int chevron_margin = 30;
private const int message_padding = 40;
private const float separator_height = 1.5f;
- private const int deleted_placeholder_margin = 80;
public readonly BindableBool ShowDeleted = new BindableBool();
@@ -175,7 +174,6 @@ namespace osu.Game.Overlays.Comments
},
new DeletedChildsPlaceholder(comment.GetDeletedChildsCount())
{
- Margin = new MarginPadding { Bottom = margin, Left = deleted_placeholder_margin },
ShowDeleted = { BindTarget = ShowDeleted }
}
}
@@ -214,6 +212,8 @@ namespace osu.Game.Overlays.Comments
{
RelativeSizeAxes = Axes.X,
Height = separator_height,
+ Anchor = Anchor.BottomCentre,
+ Origin = Anchor.BottomCentre,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
@@ -269,48 +269,6 @@ namespace osu.Game.Overlays.Comments
}
}
- private class DeletedChildsPlaceholder : FillFlowContainer
- {
- public readonly BindableBool ShowDeleted = new BindableBool();
-
- private readonly bool canBeVisible;
-
- public DeletedChildsPlaceholder(int count)
- {
- canBeVisible = count != 0;
-
- AutoSizeAxes = Axes.Both;
- Direction = FillDirection.Horizontal;
- Spacing = new Vector2(3, 0);
- Alpha = 0;
- Children = new Drawable[]
- {
- new SpriteIcon
- {
- Icon = FontAwesome.Solid.Trash,
- Size = new Vector2(14),
- },
- new SpriteText
- {
- Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
- Text = $@"{count} deleted comments"
- }
- };
- }
-
- protected override void LoadComplete()
- {
- ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
- base.LoadComplete();
- }
-
- private void onShowDeletedChanged(ValueChangedEvent showDeleted)
- {
- if (canBeVisible)
- this.FadeTo(showDeleted.NewValue ? 0 : 1);
- }
- }
-
private class ChevronButton : ShowChildsButton
{
private readonly SpriteIcon icon;
From 003af19e3f039985ec73565cee3d3ad7345e0e9b Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Wed, 9 Oct 2019 23:04:34 +0300
Subject: [PATCH 093/901] Introduce legacy skin configuration
---
osu.Game/Skinning/LegacySkin.cs | 18 ++++++++++++++++--
osu.Game/Skinning/LegacySkinConfiguration.cs | 20 ++++++++++++++++++++
2 files changed, 36 insertions(+), 2 deletions(-)
create mode 100644 osu.Game/Skinning/LegacySkinConfiguration.cs
diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs
index fea15458e4..25703b30dc 100644
--- a/osu.Game/Skinning/LegacySkin.cs
+++ b/osu.Game/Skinning/LegacySkin.cs
@@ -26,6 +26,8 @@ namespace osu.Game.Skinning
[CanBeNull]
protected IResourceStore Samples;
+ protected new LegacySkinConfiguration Configuration => (LegacySkinConfiguration)base.Configuration;
+
public LegacySkin(SkinInfo skin, IResourceStore storage, AudioManager audioManager)
: this(skin, new LegacySkinResourceStore(skin, storage), audioManager, "skin.ini")
{
@@ -37,9 +39,9 @@ namespace osu.Game.Skinning
Stream stream = storage?.GetStream(filename);
if (stream != null)
using (LineBufferedReader reader = new LineBufferedReader(stream))
- Configuration = new LegacySkinDecoder().Decode(reader);
+ base.Configuration = new LegacySkinDecoder().Decode(reader);
else
- Configuration = new DefaultSkinConfiguration();
+ base.Configuration = new LegacySkinConfiguration { LegacyVersion = LegacySkinConfiguration.LATEST_VERSION };
if (storage != null)
{
@@ -71,6 +73,18 @@ namespace osu.Game.Skinning
case GlobalSkinColour colour:
return SkinUtils.As(getCustomColour(colour.ToString()));
+ case LegacySkinConfigurations legacy:
+ switch (legacy)
+ {
+ case LegacySkinConfigurations.Version:
+ if (Configuration.LegacyVersion.HasValue)
+ return SkinUtils.As(new BindableDouble(Configuration.LegacyVersion.Value));
+
+ break;
+ }
+
+ break;
+
case SkinCustomColourLookup customColour:
return SkinUtils.As(getCustomColour(customColour.Lookup.ToString()));
diff --git a/osu.Game/Skinning/LegacySkinConfiguration.cs b/osu.Game/Skinning/LegacySkinConfiguration.cs
new file mode 100644
index 0000000000..022f613562
--- /dev/null
+++ b/osu.Game/Skinning/LegacySkinConfiguration.cs
@@ -0,0 +1,20 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+namespace osu.Game.Skinning
+{
+ public class LegacySkinConfiguration : DefaultSkinConfiguration
+ {
+ public const double LATEST_VERSION = 2.5;
+
+ ///
+ /// Legacy version of this skin.
+ ///
+ public double? LegacyVersion { get; internal set; }
+ }
+
+ public enum LegacySkinConfigurations
+ {
+ Version,
+ }
+}
From 7f6541672c9c3d3e30673e47c7d7a1b0ab630f1b Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Wed, 9 Oct 2019 23:05:50 +0300
Subject: [PATCH 094/901] Parse legacy version of decoded skin to numerical
---
osu.Game/Skinning/LegacySkinDecoder.cs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/osu.Game/Skinning/LegacySkinDecoder.cs b/osu.Game/Skinning/LegacySkinDecoder.cs
index e97664e75e..75cd0a666d 100644
--- a/osu.Game/Skinning/LegacySkinDecoder.cs
+++ b/osu.Game/Skinning/LegacySkinDecoder.cs
@@ -5,14 +5,14 @@ using osu.Game.Beatmaps.Formats;
namespace osu.Game.Skinning
{
- public class LegacySkinDecoder : LegacyDecoder
+ public class LegacySkinDecoder : LegacyDecoder
{
public LegacySkinDecoder()
: base(1)
{
}
- protected override void ParseLine(DefaultSkinConfiguration skin, Section section, string line)
+ protected override void ParseLine(LegacySkinConfiguration skin, Section section, string line)
{
if (section != Section.Colours)
{
@@ -32,6 +32,14 @@ namespace osu.Game.Skinning
case @"Author":
skin.SkinInfo.Creator = pair.Value;
return;
+
+ case @"Version":
+ if (pair.Value == "latest" || pair.Value == "User")
+ skin.LegacyVersion = LegacySkinConfiguration.LATEST_VERSION;
+ else if (double.TryParse(pair.Value, out var version))
+ skin.LegacyVersion = version;
+
+ return;
}
break;
From 01ac19fdbb96cea3f36da3ce4b5ed39d1994658a Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Wed, 9 Oct 2019 23:06:32 +0300
Subject: [PATCH 095/901] Set legacy version of osu!classic skin to 2.0
---
osu.Game/Skinning/DefaultLegacySkin.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/osu.Game/Skinning/DefaultLegacySkin.cs b/osu.Game/Skinning/DefaultLegacySkin.cs
index 4b6eea6b6e..4c68ee938f 100644
--- a/osu.Game/Skinning/DefaultLegacySkin.cs
+++ b/osu.Game/Skinning/DefaultLegacySkin.cs
@@ -20,6 +20,8 @@ namespace osu.Game.Skinning
new Color4(18, 124, 255, 255),
new Color4(242, 24, 57, 255),
});
+
+ Configuration.LegacyVersion = 2.0;
}
public static SkinInfo Info { get; } = new SkinInfo
From d15db378ce2598a66f5bdad3958d964dbd1b869b Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Wed, 9 Oct 2019 23:06:53 +0300
Subject: [PATCH 096/901] Add tests for legacy skin decoding
---
osu.Game.Tests/Resources/skin-20.ini | 2 ++
osu.Game.Tests/Resources/skin-latest.ini | 2 ++
osu.Game.Tests/Skins/LegacySkinDecoderTest.cs | 11 +++++++++++
3 files changed, 15 insertions(+)
create mode 100644 osu.Game.Tests/Resources/skin-20.ini
create mode 100644 osu.Game.Tests/Resources/skin-latest.ini
diff --git a/osu.Game.Tests/Resources/skin-20.ini b/osu.Game.Tests/Resources/skin-20.ini
new file mode 100644
index 0000000000..947b56b2f9
--- /dev/null
+++ b/osu.Game.Tests/Resources/skin-20.ini
@@ -0,0 +1,2 @@
+[General]
+Version: 2
\ No newline at end of file
diff --git a/osu.Game.Tests/Resources/skin-latest.ini b/osu.Game.Tests/Resources/skin-latest.ini
new file mode 100644
index 0000000000..32f500263f
--- /dev/null
+++ b/osu.Game.Tests/Resources/skin-latest.ini
@@ -0,0 +1,2 @@
+[General]
+Version: latest
\ No newline at end of file
diff --git a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
index 0d96dd08da..8c85074456 100644
--- a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
+++ b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
@@ -56,5 +56,16 @@ namespace osu.Game.Tests.Skins
Assert.AreEqual("TestValue", config.ConfigDictionary["TestLookup"]);
}
}
+
+ [TestCase("skin-20.ini", 2.0)]
+ [TestCase("skin-latest.ini", LegacySkinConfiguration.LATEST_VERSION)]
+ [TestCase("skin-empty.ini", null)]
+ public void TestDecodeVersion(string filename, double? expected)
+ {
+ var decoder = new LegacySkinDecoder();
+ using (var resStream = TestResources.OpenResource(filename))
+ using (var stream = new LineBufferedReader(resStream))
+ Assert.AreEqual(expected, decoder.Decode(stream).LegacyVersion);
+ }
}
}
From 2cf17e0bf38455d465d2f59e7c9552255dde2766 Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Wed, 9 Oct 2019 23:33:25 +0300
Subject: [PATCH 097/901] Use decimal data type instead
---
osu.Game.Tests/Skins/LegacySkinDecoderTest.cs | 28 +++++++++++++++----
osu.Game/Skinning/DefaultLegacySkin.cs | 2 +-
osu.Game/Skinning/LegacySkin.cs | 2 +-
osu.Game/Skinning/LegacySkinConfiguration.cs | 4 +--
osu.Game/Skinning/LegacySkinDecoder.cs | 2 +-
5 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
index 8c85074456..4fee6942d0 100644
--- a/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
+++ b/osu.Game.Tests/Skins/LegacySkinDecoderTest.cs
@@ -57,15 +57,31 @@ namespace osu.Game.Tests.Skins
}
}
- [TestCase("skin-20.ini", 2.0)]
- [TestCase("skin-latest.ini", LegacySkinConfiguration.LATEST_VERSION)]
- [TestCase("skin-empty.ini", null)]
- public void TestDecodeVersion(string filename, double? expected)
+ [Test]
+ public void TestDecodeSpecifiedVersion()
{
var decoder = new LegacySkinDecoder();
- using (var resStream = TestResources.OpenResource(filename))
+ using (var resStream = TestResources.OpenResource("skin-20.ini"))
using (var stream = new LineBufferedReader(resStream))
- Assert.AreEqual(expected, decoder.Decode(stream).LegacyVersion);
+ Assert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion);
+ }
+
+ [Test]
+ public void TestDecodeLatestVersion()
+ {
+ var decoder = new LegacySkinDecoder();
+ using (var resStream = TestResources.OpenResource("skin-latest.ini"))
+ using (var stream = new LineBufferedReader(resStream))
+ Assert.AreEqual(LegacySkinConfiguration.LATEST_VERSION, decoder.Decode(stream).LegacyVersion);
+ }
+
+ [Test]
+ public void TestDecodeNoVersion()
+ {
+ var decoder = new LegacySkinDecoder();
+ using (var resStream = TestResources.OpenResource("skin-empty.ini"))
+ using (var stream = new LineBufferedReader(resStream))
+ Assert.IsNull(decoder.Decode(stream).LegacyVersion);
}
}
}
diff --git a/osu.Game/Skinning/DefaultLegacySkin.cs b/osu.Game/Skinning/DefaultLegacySkin.cs
index 4c68ee938f..0caf2d19e9 100644
--- a/osu.Game/Skinning/DefaultLegacySkin.cs
+++ b/osu.Game/Skinning/DefaultLegacySkin.cs
@@ -21,7 +21,7 @@ namespace osu.Game.Skinning
new Color4(242, 24, 57, 255),
});
- Configuration.LegacyVersion = 2.0;
+ Configuration.LegacyVersion = 2.0m;
}
public static SkinInfo Info { get; } = new SkinInfo
diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs
index 25703b30dc..f6a366b21d 100644
--- a/osu.Game/Skinning/LegacySkin.cs
+++ b/osu.Game/Skinning/LegacySkin.cs
@@ -78,7 +78,7 @@ namespace osu.Game.Skinning
{
case LegacySkinConfigurations.Version:
if (Configuration.LegacyVersion.HasValue)
- return SkinUtils.As(new BindableDouble(Configuration.LegacyVersion.Value));
+ return SkinUtils.As(new Bindable(Configuration.LegacyVersion.Value));
break;
}
diff --git a/osu.Game/Skinning/LegacySkinConfiguration.cs b/osu.Game/Skinning/LegacySkinConfiguration.cs
index 022f613562..051d10747b 100644
--- a/osu.Game/Skinning/LegacySkinConfiguration.cs
+++ b/osu.Game/Skinning/LegacySkinConfiguration.cs
@@ -5,12 +5,12 @@ namespace osu.Game.Skinning
{
public class LegacySkinConfiguration : DefaultSkinConfiguration
{
- public const double LATEST_VERSION = 2.5;
+ public const decimal LATEST_VERSION = 2.5m;
///
/// Legacy version of this skin.
///
- public double? LegacyVersion { get; internal set; }
+ public decimal? LegacyVersion { get; internal set; }
}
public enum LegacySkinConfigurations
diff --git a/osu.Game/Skinning/LegacySkinDecoder.cs b/osu.Game/Skinning/LegacySkinDecoder.cs
index 75cd0a666d..ea087353a0 100644
--- a/osu.Game/Skinning/LegacySkinDecoder.cs
+++ b/osu.Game/Skinning/LegacySkinDecoder.cs
@@ -36,7 +36,7 @@ namespace osu.Game.Skinning
case @"Version":
if (pair.Value == "latest" || pair.Value == "User")
skin.LegacyVersion = LegacySkinConfiguration.LATEST_VERSION;
- else if (double.TryParse(pair.Value, out var version))
+ else if (decimal.TryParse(pair.Value, out var version))
skin.LegacyVersion = version;
return;
From f6b78ad6617508f49654c86696585b934c83a8d2 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Thu, 10 Oct 2019 11:43:45 +0300
Subject: [PATCH 098/901] Overall cleanups
---
.../Online/API/Requests/GetCommentsRequest.cs | 8 +--
.../Overlays/Comments/CommentsContainer.cs | 4 +-
osu.Game/Overlays/Comments/CommentsHeader.cs | 3 +-
.../Comments/DeletedChildsPlaceholder.cs | 3 +-
osu.Game/Overlays/Comments/DrawableComment.cs | 59 +++++++------------
osu.Game/Overlays/Comments/SortSelector.cs | 8 ++-
6 files changed, 35 insertions(+), 50 deletions(-)
diff --git a/osu.Game/Online/API/Requests/GetCommentsRequest.cs b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
index 02a36f7aa2..fb30130ee9 100644
--- a/osu.Game/Online/API/Requests/GetCommentsRequest.cs
+++ b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
@@ -4,6 +4,7 @@
using osu.Framework.IO.Network;
using Humanizer;
using osu.Game.Online.API.Requests.Responses;
+using osu.Game.Overlays.Comments;
namespace osu.Game.Online.API.Requests
{
@@ -43,11 +44,4 @@ namespace osu.Game.Online.API.Requests
Beatmapset,
NewsPost
}
-
- public enum SortCommentsBy
- {
- New,
- Old,
- Top
- }
}
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index bf68457988..314376f5ff 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -91,7 +91,9 @@ namespace osu.Game.Overlays.Comments
{
if (c.IsTopLevel)
content.Add(new DrawableComment(c)
- { ShowDeleted = { BindTarget = ShowDeleted } });
+ {
+ ShowDeleted = { BindTarget = ShowDeleted }
+ });
}
int deletedComments = 0;
diff --git a/osu.Game/Overlays/Comments/CommentsHeader.cs b/osu.Game/Overlays/Comments/CommentsHeader.cs
index 90a6f44d6b..6e9864f153 100644
--- a/osu.Game/Overlays/Comments/CommentsHeader.cs
+++ b/osu.Game/Overlays/Comments/CommentsHeader.cs
@@ -3,7 +3,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
-using osu.Game.Online.API.Requests;
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
@@ -62,7 +61,7 @@ namespace osu.Game.Overlays.Comments
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
- Current = { BindTarget = Sort }
+ Current = Sort
}
}
},
diff --git a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs b/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
index d0e6c17ccb..7aae42908e 100644
--- a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
+++ b/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
@@ -7,6 +7,7 @@ using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osuTK;
using osu.Framework.Bindables;
+using System.Linq;
namespace osu.Game.Overlays.Comments
{
@@ -38,7 +39,7 @@ namespace osu.Game.Overlays.Comments
new SpriteText
{
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
- Text = $@"{count} deleted comments"
+ Text = $@"{count} deleted comment{(count.ToString().ToCharArray().Last() == '1' ? "" : "s")}"
}
};
}
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 4af2e07227..fd7f874304 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Comments
private readonly BindableBool childExpanded = new BindableBool(true);
- private readonly Container childCommentsVisibilityContainer;
+ private readonly FillFlowContainer childCommentsVisibilityContainer;
private readonly Comment comment;
public DrawableComment(Comment comment)
@@ -47,7 +47,6 @@ namespace osu.Game.Overlays.Comments
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
- Masking = true;
InternalChild = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
@@ -145,7 +144,9 @@ namespace osu.Game.Overlays.Comments
Text = HumanizerUtils.Humanize(comment.CreatedAt)
},
new RepliesButton(comment.RepliesCount)
- { Expanded = { BindTarget = childExpanded } },
+ {
+ Expanded = { BindTarget = childExpanded }
+ },
}
}
}
@@ -153,29 +154,23 @@ namespace osu.Game.Overlays.Comments
}
}
},
- childCommentsVisibilityContainer = new Container
+ childCommentsVisibilityContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Masking = true,
- Child = new FillFlowContainer
+ Direction = FillDirection.Vertical,
+ Children = new Drawable[]
{
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Direction = FillDirection.Vertical,
- Children = new Drawable[]
+ childCommentsContainer = new FillFlowContainer
{
- childCommentsContainer = new FillFlowContainer
- {
- Margin = new MarginPadding { Left = child_margin },
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Direction = FillDirection.Vertical
- },
- new DeletedChildsPlaceholder(comment.GetDeletedChildsCount())
- {
- ShowDeleted = { BindTarget = ShowDeleted }
- }
+ Margin = new MarginPadding { Left = child_margin },
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical
+ },
+ new DeletedChildsPlaceholder(comment.GetDeletedChildsCount())
+ {
+ ShowDeleted = { BindTarget = ShowDeleted }
}
}
}
@@ -234,7 +229,9 @@ namespace osu.Game.Overlays.Comments
}
comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c)
- { ShowDeleted = { BindTarget = ShowDeleted } }));
+ {
+ ShowDeleted = { BindTarget = ShowDeleted }
+ }));
}
protected override void LoadComplete()
@@ -246,27 +243,13 @@ namespace osu.Game.Overlays.Comments
private void onChildExpandedChanged(ValueChangedEvent expanded)
{
- if (expanded.NewValue)
- childCommentsVisibilityContainer.AutoSizeAxes = Axes.Y;
- else
- {
- childCommentsVisibilityContainer.AutoSizeAxes = Axes.None;
- childCommentsVisibilityContainer.ResizeHeightTo(0);
- }
+ childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0);
}
private void onShowDeletedChanged(ValueChangedEvent show)
{
if (comment.IsDeleted)
- {
- if (show.NewValue)
- AutoSizeAxes = Axes.Y;
- else
- {
- AutoSizeAxes = Axes.None;
- this.ResizeHeightTo(0);
- }
- }
+ this.FadeTo(show.NewValue ? 1 : 0);
}
private class ChevronButton : ShowChildsButton
diff --git a/osu.Game/Overlays/Comments/SortSelector.cs b/osu.Game/Overlays/Comments/SortSelector.cs
index 4425145c3e..cb95a758ff 100644
--- a/osu.Game/Overlays/Comments/SortSelector.cs
+++ b/osu.Game/Overlays/Comments/SortSelector.cs
@@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osu.Game.Online.API.Requests;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
@@ -72,4 +71,11 @@ namespace osu.Game.Overlays.Comments
}
}
}
+
+ public enum SortCommentsBy
+ {
+ New,
+ Old,
+ Top
+ }
}
From 937dbb7bf690c22fff07cade2d4cadd6c8c9128a Mon Sep 17 00:00:00 2001
From: Dean Herbert
Date: Wed, 9 Oct 2019 16:06:16 +0900
Subject: [PATCH 099/901] Initial layout for timing screen
---
.../Visual/Editor/TestSceneTimingScreen.cs | 21 ++++
osu.Game/Screens/Edit/Timing/TimingScreen.cs | 97 ++++++++++++++++++-
2 files changed, 115 insertions(+), 3 deletions(-)
create mode 100644 osu.Game.Tests/Visual/Editor/TestSceneTimingScreen.cs
diff --git a/osu.Game.Tests/Visual/Editor/TestSceneTimingScreen.cs b/osu.Game.Tests/Visual/Editor/TestSceneTimingScreen.cs
new file mode 100644
index 0000000000..be84ae2cf9
--- /dev/null
+++ b/osu.Game.Tests/Visual/Editor/TestSceneTimingScreen.cs
@@ -0,0 +1,21 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Game.Rulesets.Osu;
+using osu.Game.Screens.Edit.Timing;
+
+namespace osu.Game.Tests.Visual.Editor
+{
+ [TestFixture]
+ public class TestSceneTimingScreen : EditorClockTestScene
+ {
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
+ Child = new TimingScreen();
+ }
+ }
+}
diff --git a/osu.Game/Screens/Edit/Timing/TimingScreen.cs b/osu.Game/Screens/Edit/Timing/TimingScreen.cs
index 9ded4207e5..b723ffac9a 100644
--- a/osu.Game/Screens/Edit/Timing/TimingScreen.cs
+++ b/osu.Game/Screens/Edit/Timing/TimingScreen.cs
@@ -1,13 +1,104 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using osu.Framework.Allocation;
+using osu.Framework.Bindables;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
+using osu.Framework.Graphics.Shapes;
+using osu.Game.Beatmaps;
+using osu.Game.Graphics;
+using osu.Game.Graphics.Containers;
+using osu.Game.Graphics.Sprites;
+
namespace osu.Game.Screens.Edit.Timing
{
- public class TimingScreen : EditorScreen
+ public class TimingScreen : EditorScreenWithTimeline
{
- public TimingScreen()
+ protected override Drawable CreateMainContent() => new GridContainer
{
- Child = new ScreenWhiteBox.UnderConstructionMessage("Timing mode");
+ RelativeSizeAxes = Axes.Both,
+ ColumnDimensions = new[]
+ {
+ new Dimension(),
+ new Dimension(GridSizeMode.Absolute, 200),
+ },
+ Content = new[]
+ {
+ new Drawable[]
+ {
+ new ControlPointList(),
+ new ControlPointSettings(),
+ },
+ }
+ };
+
+ public class ControlPointList : CompositeDrawable
+ {
+ [Resolved]
+ protected IBindable Beatmap { get; private set; }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ RelativeSizeAxes = Axes.Both;
+
+ InternalChildren = new Drawable[]
+ {
+ new Box
+ {
+ Colour = colours.Gray0,
+ RelativeSizeAxes = Axes.Both,
+ },
+ new OsuScrollContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Child = new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Direction = FillDirection.Vertical,
+ Children = new Drawable[]
+ {
+ new ControlPointRow(),
+ new ControlPointRow(),
+ new ControlPointRow(),
+ new ControlPointRow(),
+ new ControlPointRow(),
+ new ControlPointRow(),
+ }
+ },
+ }
+ };
+ }
+
+ private class ControlPointRow : CompositeDrawable
+ {
+ public ControlPointRow()
+ {
+ RelativeSizeAxes = Axes.X;
+ AutoSizeAxes = Axes.Y;
+
+ InternalChildren = new Drawable[]
+ {
+ new OsuSpriteText { Text = "sample row" },
+ };
+ }
+ }
+ }
+
+ public class ControlPointSettings : CompositeDrawable
+ {
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ RelativeSizeAxes = Axes.Both;
+
+ InternalChild = new Box
+ {
+ Colour = colours.Gray3,
+ RelativeSizeAxes = Axes.Both,
+ };
+ }
}
}
}
From 6301f837e0b17a8216f2af8a3ee55e064249b16d Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Fri, 11 Oct 2019 15:27:23 +0900
Subject: [PATCH 100/901] Initial implementation of osu! beat snapping grid
---
.../TestSceneOsuBeatSnapGrid.cs | 170 ++++++++++++++++++
1 file changed, 170 insertions(+)
create mode 100644 osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs
new file mode 100644
index 0000000000..9f0d59afab
--- /dev/null
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs
@@ -0,0 +1,170 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using NUnit.Framework;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.Shapes;
+using osu.Framework.Graphics.UserInterface;
+using osu.Framework.Input.Events;
+using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Rulesets.Objects;
+using osu.Game.Rulesets.Osu.Beatmaps;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Screens.Edit;
+using osu.Game.Screens.Edit.Compose.Components;
+using osu.Game.Tests.Visual;
+using osuTK;
+using osuTK.Graphics;
+
+namespace osu.Game.Rulesets.Osu.Tests
+{
+ public class TestSceneOsuBeatSnapGrid : ManualInputManagerTestScene
+ {
+ private const double beat_length = 100;
+ private static readonly Vector2 grid_position = new Vector2(512, 384);
+
+ [Cached(typeof(IEditorBeatmap))]
+ private readonly EditorBeatmap editorBeatmap;
+
+ [Cached]
+ private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
+
+ private OsuBeatSnapGrid grid;
+ private Drawable cursor;
+
+ public TestSceneOsuBeatSnapGrid()
+ {
+ editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+ }
+
+ [SetUp]
+ public void Setup() => Schedule(() =>
+ {
+ Clear();
+
+ editorBeatmap.ControlPointInfo.TimingPoints.Clear();
+ editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
+
+ beatDivisor.Value = 1;
+ });
+
+ protected override bool OnMouseMove(MouseMoveEvent e)
+ {
+ base.OnMouseMove(e);
+
+ if (cursor != null)
+ cursor.Position = grid?.GetSnapPosition(grid.ToLocalSpace(e.ScreenSpaceMousePosition)) ?? e.ScreenSpaceMousePosition;
+
+ return true;
+ }
+
+ [TestCase(1)]
+ [TestCase(2)]
+ [TestCase(3)]
+ [TestCase(4)]
+ [TestCase(6)]
+ [TestCase(8)]
+ [TestCase(12)]
+ [TestCase(16)]
+ public void TestBeatDivisor(int divisor)
+ {
+ AddStep($"set beat divisor = {divisor}", () => beatDivisor.Value = divisor);
+ createGrid();
+ }
+
+ private void createGrid()
+ {
+ AddStep("create grid", () =>
+ {
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = Color4.SlateGray
+ },
+ grid = new OsuBeatSnapGrid(new HitCircle { Position = grid_position }),
+ cursor = new Circle
+ {
+ Origin = Anchor.Centre,
+ Size = new Vector2(50),
+ Colour = Color4.Red
+ }
+ };
+ });
+ }
+
+ private abstract class CircularBeatSnapGrid : BeatSnapGrid
+ {
+ protected override void CreateGrid(Vector2 startPosition)
+ {
+ float maxDistance = Math.Max(
+ Vector2.Distance(startPosition, Vector2.Zero),
+ Math.Max(
+ Vector2.Distance(startPosition, new Vector2(DrawWidth, 0)),
+ Math.Max(
+ Vector2.Distance(startPosition, new Vector2(0, DrawHeight)),
+ Vector2.Distance(startPosition, DrawSize))));
+
+ int requiredCircles = (int)(maxDistance / DistanceSpacing);
+
+ for (int i = 0; i < requiredCircles; i++)
+ {
+ float radius = (i + 1) * DistanceSpacing * 2;
+
+ AddInternal(new CircularProgress
+ {
+ Origin = Anchor.Centre,
+ Position = startPosition,
+ Current = { Value = 1 },
+ Size = new Vector2(radius),
+ InnerRadius = 4 * 1f / radius,
+ Colour = GetColourForBeatIndex(i)
+ });
+ }
+ }
+
+ public override Vector2 GetSnapPosition(Vector2 position)
+ {
+ Vector2 direction = position - StartPosition;
+ float distance = direction.Length;
+
+ float radius = DistanceSpacing;
+ int radialCount = Math.Max(1, (int)Math.Round(distance / radius));
+
+ if (radialCount <= 0)
+ return position;
+
+ Vector2 normalisedDirection = direction * new Vector2(1f / distance);
+
+ return StartPosition + normalisedDirection * radialCount * radius;
+ }
+ }
+
+ private class OsuBeatSnapGrid : CircularBeatSnapGrid
+ {
+ ///
+ /// Scoring distance with a speed-adjusted beat length of 1 second.
+ ///
+ private const float base_scoring_distance = 100;
+
+ public OsuBeatSnapGrid(OsuHitObject hitObject)
+ : base(hitObject, hitObject.StackedEndPosition)
+ {
+ }
+
+ protected override float GetVelocity(double time, ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
+ {
+ TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(time);
+ DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(time);
+
+ double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier;
+
+ return (float)(scoringDistance / timingPoint.BeatLength);
+ }
+ }
+ }
+}
From 4d32a8aa6b5cca76f5b993791ce4e536a4709836 Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Fri, 11 Oct 2019 17:11:37 +0900
Subject: [PATCH 101/901] More tests
---
.../TestSceneOsuBeatSnapGrid.cs | 172 +++++++++++++++---
1 file changed, 145 insertions(+), 27 deletions(-)
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs
index 9f0d59afab..7baa2f0d72 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs
@@ -5,9 +5,11 @@ using System;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
+using osu.Framework.MathUtils;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Objects;
@@ -32,12 +34,13 @@ namespace osu.Game.Rulesets.Osu.Tests
[Cached]
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
- private OsuBeatSnapGrid grid;
- private Drawable cursor;
+ private TestOsuBeatSnapGrid grid;
public TestSceneOsuBeatSnapGrid()
{
editorBeatmap = new EditorBeatmap(new OsuBeatmap());
+
+ createGrid();
}
[SetUp]
@@ -45,22 +48,14 @@ namespace osu.Game.Rulesets.Osu.Tests
{
Clear();
+ editorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 1;
+ editorBeatmap.ControlPointInfo.DifficultyPoints.Clear();
editorBeatmap.ControlPointInfo.TimingPoints.Clear();
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
beatDivisor.Value = 1;
});
- protected override bool OnMouseMove(MouseMoveEvent e)
- {
- base.OnMouseMove(e);
-
- if (cursor != null)
- cursor.Position = grid?.GetSnapPosition(grid.ToLocalSpace(e.ScreenSpaceMousePosition)) ?? e.ScreenSpaceMousePosition;
-
- return true;
- }
-
[TestCase(1)]
[TestCase(2)]
[TestCase(3)]
@@ -75,6 +70,80 @@ namespace osu.Game.Rulesets.Osu.Tests
createGrid();
}
+ [TestCase(100, 100)]
+ [TestCase(200, 100)]
+ public void TestBeatLength(float beatLength, float expectedSpacing)
+ {
+ AddStep($"set beat length = {beatLength}", () =>
+ {
+ editorBeatmap.ControlPointInfo.TimingPoints.Clear();
+ editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beatLength });
+ });
+
+ createGrid();
+ AddAssert($"spacing = {expectedSpacing}", () => Precision.AlmostEquals(expectedSpacing, grid.DistanceSpacing));
+ }
+
+ [TestCase(0.5f, 50)]
+ [TestCase(1, 100)]
+ [TestCase(1.5f, 150)]
+ public void TestSpeedMultiplier(float multiplier, float expectedSpacing)
+ {
+ AddStep($"set speed multiplier = {multiplier}", () =>
+ {
+ editorBeatmap.ControlPointInfo.DifficultyPoints.Clear();
+ editorBeatmap.ControlPointInfo.DifficultyPoints.Add(new DifficultyControlPoint { SpeedMultiplier = multiplier });
+ });
+
+ createGrid();
+ AddAssert($"spacing = {expectedSpacing}", () => Precision.AlmostEquals(expectedSpacing, grid.DistanceSpacing));
+ }
+
+ [TestCase(0.5f, 50)]
+ [TestCase(1, 100)]
+ [TestCase(1.5f, 150)]
+ public void TestSliderMultiplier(float multiplier, float expectedSpacing)
+ {
+ AddStep($"set speed multiplier = {multiplier}", () => editorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = multiplier);
+ createGrid();
+ AddAssert($"spacing = {expectedSpacing}", () => Precision.AlmostEquals(expectedSpacing, grid.DistanceSpacing));
+ }
+
+ [Test]
+ public void TestCursorInCentre()
+ {
+ createGrid();
+
+ AddStep("move mouse to centre", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position)));
+ assertSnappedDistance((float)beat_length);
+ }
+
+ [Test]
+ public void TestCursorBeforeMovementPoint()
+ {
+ createGrid();
+
+ AddStep("move mouse to just before movement point", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position + new Vector2((float)beat_length, 0) * 1.49f)));
+ assertSnappedDistance((float)beat_length);
+ }
+
+ [Test]
+ public void TestCursorAfterMovementPoint()
+ {
+ createGrid();
+
+ AddStep("move mouse to just after movement point", () => InputManager.MoveMouseTo(grid.ToScreenSpace(grid_position + new Vector2((float)beat_length, 0) * 1.51f)));
+ assertSnappedDistance((float)beat_length * 2);
+ }
+
+ private void assertSnappedDistance(float expectedDistance) => AddAssert($"snap distance = {expectedDistance}", () =>
+ {
+ Vector2 snappedPosition = grid.GetSnapPosition(grid.ToLocalSpace(InputManager.CurrentState.Mouse.Position));
+ float distance = Vector2.Distance(snappedPosition, grid_position);
+
+ return Precision.AlmostEquals(expectedDistance, distance);
+ });
+
private void createGrid()
{
AddStep("create grid", () =>
@@ -86,28 +155,77 @@ namespace osu.Game.Rulesets.Osu.Tests
RelativeSizeAxes = Axes.Both,
Colour = Color4.SlateGray
},
- grid = new OsuBeatSnapGrid(new HitCircle { Position = grid_position }),
- cursor = new Circle
- {
- Origin = Anchor.Centre,
- Size = new Vector2(50),
- Colour = Color4.Red
- }
+ grid = new TestOsuBeatSnapGrid(new HitCircle { Position = grid_position }),
+ new SnappingCursorContainer { GetSnapPosition = v => grid.GetSnapPosition(grid.ToLocalSpace(v)) }
};
});
}
+ private class SnappingCursorContainer : CompositeDrawable
+ {
+ public Func GetSnapPosition;
+
+ private readonly Drawable cursor;
+
+ public SnappingCursorContainer()
+ {
+ RelativeSizeAxes = Axes.Both;
+
+ InternalChild = cursor = new Circle
+ {
+ Origin = Anchor.Centre,
+ Size = new Vector2(50),
+ Colour = Color4.Red
+ };
+ }
+
+ protected override void LoadComplete()
+ {
+ base.LoadComplete();
+
+ updatePosition(GetContainingInputManager().CurrentState.Mouse.Position);
+ }
+
+ protected override bool OnMouseMove(MouseMoveEvent e)
+ {
+ base.OnMouseMove(e);
+
+ updatePosition(e.ScreenSpaceMousePosition);
+ return true;
+ }
+
+ private void updatePosition(Vector2 screenSpacePosition)
+ {
+ cursor.Position = GetSnapPosition.Invoke(screenSpacePosition);
+ }
+ }
+
+ private class TestOsuBeatSnapGrid : OsuBeatSnapGrid
+ {
+ public new float DistanceSpacing => base.DistanceSpacing;
+
+ public TestOsuBeatSnapGrid(OsuHitObject hitObject)
+ : base(hitObject)
+ {
+ }
+ }
+
private abstract class CircularBeatSnapGrid : BeatSnapGrid
{
- protected override void CreateGrid(Vector2 startPosition)
+ protected CircularBeatSnapGrid(HitObject hitObject, Vector2 centrePosition)
+ : base(hitObject, centrePosition)
+ {
+ }
+
+ protected override void CreateContent(Vector2 centrePosition)
{
float maxDistance = Math.Max(
- Vector2.Distance(startPosition, Vector2.Zero),
+ Vector2.Distance(centrePosition, Vector2.Zero),
Math.Max(
- Vector2.Distance(startPosition, new Vector2(DrawWidth, 0)),
+ Vector2.Distance(centrePosition, new Vector2(DrawWidth, 0)),
Math.Max(
- Vector2.Distance(startPosition, new Vector2(0, DrawHeight)),
- Vector2.Distance(startPosition, DrawSize))));
+ Vector2.Distance(centrePosition, new Vector2(0, DrawHeight)),
+ Vector2.Distance(centrePosition, DrawSize))));
int requiredCircles = (int)(maxDistance / DistanceSpacing);
@@ -118,7 +236,7 @@ namespace osu.Game.Rulesets.Osu.Tests
AddInternal(new CircularProgress
{
Origin = Anchor.Centre,
- Position = startPosition,
+ Position = centrePosition,
Current = { Value = 1 },
Size = new Vector2(radius),
InnerRadius = 4 * 1f / radius,
@@ -129,7 +247,7 @@ namespace osu.Game.Rulesets.Osu.Tests
public override Vector2 GetSnapPosition(Vector2 position)
{
- Vector2 direction = position - StartPosition;
+ Vector2 direction = position - CentrePosition;
float distance = direction.Length;
float radius = DistanceSpacing;
@@ -140,7 +258,7 @@ namespace osu.Game.Rulesets.Osu.Tests
Vector2 normalisedDirection = direction * new Vector2(1f / distance);
- return StartPosition + normalisedDirection * radialCount * radius;
+ return CentrePosition + normalisedDirection * radialCount * radius;
}
}
From 45835f97a177597fb236793116382f5b8c7918ea Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Fri, 11 Oct 2019 17:13:28 +0900
Subject: [PATCH 102/901] Split out grids into separate files
---
.../TestSceneOsuBeatSnapGrid.cs | 80 +------------------
osu.Game.Rulesets.Osu/Edit/OsuBeatSnapGrid.cs | 33 ++++++++
.../Components/CircularBeatSnapGrid.cs | 63 +++++++++++++++
3 files changed, 97 insertions(+), 79 deletions(-)
create mode 100644 osu.Game.Rulesets.Osu/Edit/OsuBeatSnapGrid.cs
create mode 100644 osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs
index 7baa2f0d72..7399f12372 100644
--- a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs
+++ b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuBeatSnapGrid.cs
@@ -7,16 +7,13 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
-using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.MathUtils;
-using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
-using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Beatmaps;
+using osu.Game.Rulesets.Osu.Edit;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit;
-using osu.Game.Screens.Edit.Compose.Components;
using osu.Game.Tests.Visual;
using osuTK;
using osuTK.Graphics;
@@ -209,80 +206,5 @@ namespace osu.Game.Rulesets.Osu.Tests
{
}
}
-
- private abstract class CircularBeatSnapGrid : BeatSnapGrid
- {
- protected CircularBeatSnapGrid(HitObject hitObject, Vector2 centrePosition)
- : base(hitObject, centrePosition)
- {
- }
-
- protected override void CreateContent(Vector2 centrePosition)
- {
- float maxDistance = Math.Max(
- Vector2.Distance(centrePosition, Vector2.Zero),
- Math.Max(
- Vector2.Distance(centrePosition, new Vector2(DrawWidth, 0)),
- Math.Max(
- Vector2.Distance(centrePosition, new Vector2(0, DrawHeight)),
- Vector2.Distance(centrePosition, DrawSize))));
-
- int requiredCircles = (int)(maxDistance / DistanceSpacing);
-
- for (int i = 0; i < requiredCircles; i++)
- {
- float radius = (i + 1) * DistanceSpacing * 2;
-
- AddInternal(new CircularProgress
- {
- Origin = Anchor.Centre,
- Position = centrePosition,
- Current = { Value = 1 },
- Size = new Vector2(radius),
- InnerRadius = 4 * 1f / radius,
- Colour = GetColourForBeatIndex(i)
- });
- }
- }
-
- public override Vector2 GetSnapPosition(Vector2 position)
- {
- Vector2 direction = position - CentrePosition;
- float distance = direction.Length;
-
- float radius = DistanceSpacing;
- int radialCount = Math.Max(1, (int)Math.Round(distance / radius));
-
- if (radialCount <= 0)
- return position;
-
- Vector2 normalisedDirection = direction * new Vector2(1f / distance);
-
- return CentrePosition + normalisedDirection * radialCount * radius;
- }
- }
-
- private class OsuBeatSnapGrid : CircularBeatSnapGrid
- {
- ///
- /// Scoring distance with a speed-adjusted beat length of 1 second.
- ///
- private const float base_scoring_distance = 100;
-
- public OsuBeatSnapGrid(OsuHitObject hitObject)
- : base(hitObject, hitObject.StackedEndPosition)
- {
- }
-
- protected override float GetVelocity(double time, ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
- {
- TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(time);
- DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(time);
-
- double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier;
-
- return (float)(scoringDistance / timingPoint.BeatLength);
- }
- }
}
}
diff --git a/osu.Game.Rulesets.Osu/Edit/OsuBeatSnapGrid.cs b/osu.Game.Rulesets.Osu/Edit/OsuBeatSnapGrid.cs
new file mode 100644
index 0000000000..d453e3d062
--- /dev/null
+++ b/osu.Game.Rulesets.Osu/Edit/OsuBeatSnapGrid.cs
@@ -0,0 +1,33 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.ControlPoints;
+using osu.Game.Rulesets.Osu.Objects;
+using osu.Game.Screens.Edit.Compose.Components;
+
+namespace osu.Game.Rulesets.Osu.Edit
+{
+ public class OsuBeatSnapGrid : CircularBeatSnapGrid
+ {
+ ///
+ /// Scoring distance with a speed-adjusted beat length of 1 second.
+ ///
+ private const float base_scoring_distance = 100;
+
+ public OsuBeatSnapGrid(OsuHitObject hitObject)
+ : base(hitObject, hitObject.StackedEndPosition)
+ {
+ }
+
+ protected override float GetVelocity(double time, ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
+ {
+ TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(time);
+ DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(time);
+
+ double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier;
+
+ return (float)(scoringDistance / timingPoint.BeatLength);
+ }
+ }
+}
diff --git a/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
new file mode 100644
index 0000000000..8492771808
--- /dev/null
+++ b/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
@@ -0,0 +1,63 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using System;
+using osu.Framework.Graphics;
+using osu.Framework.Graphics.UserInterface;
+using osu.Game.Rulesets.Objects;
+using osuTK;
+
+namespace osu.Game.Screens.Edit.Compose.Components
+{
+ public abstract class CircularBeatSnapGrid : BeatSnapGrid
+ {
+ protected CircularBeatSnapGrid(HitObject hitObject, Vector2 centrePosition)
+ : base(hitObject, centrePosition)
+ {
+ }
+
+ protected override void CreateContent(Vector2 centrePosition)
+ {
+ float maxDistance = Math.Max(
+ Vector2.Distance(centrePosition, Vector2.Zero),
+ Math.Max(
+ Vector2.Distance(centrePosition, new Vector2(DrawWidth, 0)),
+ Math.Max(
+ Vector2.Distance(centrePosition, new Vector2(0, DrawHeight)),
+ Vector2.Distance(centrePosition, DrawSize))));
+
+ int requiredCircles = (int)(maxDistance / DistanceSpacing);
+
+ for (int i = 0; i < requiredCircles; i++)
+ {
+ float radius = (i + 1) * DistanceSpacing * 2;
+
+ AddInternal(new CircularProgress
+ {
+ Origin = Anchor.Centre,
+ Position = centrePosition,
+ Current = { Value = 1 },
+ Size = new Vector2(radius),
+ InnerRadius = 4 * 1f / radius,
+ Colour = GetColourForBeatIndex(i)
+ });
+ }
+ }
+
+ public override Vector2 GetSnapPosition(Vector2 position)
+ {
+ Vector2 direction = position - CentrePosition;
+ float distance = direction.Length;
+
+ float radius = DistanceSpacing;
+ int radialCount = Math.Max(1, (int)Math.Round(distance / radius));
+
+ if (radialCount <= 0)
+ return position;
+
+ Vector2 normalisedDirection = direction * new Vector2(1f / distance);
+
+ return CentrePosition + normalisedDirection * radialCount * radius;
+ }
+ }
+}
From de13320a2debb7c48d46691ea5a34a0b09d722a6 Mon Sep 17 00:00:00 2001
From: Dean Herbert
Date: Fri, 11 Oct 2019 18:46:05 +0900
Subject: [PATCH 103/901] Add initial table display
---
osu.Game/Screens/Edit/Timing/TimingScreen.cs | 187 ++++++++++++++++---
1 file changed, 160 insertions(+), 27 deletions(-)
diff --git a/osu.Game/Screens/Edit/Timing/TimingScreen.cs b/osu.Game/Screens/Edit/Timing/TimingScreen.cs
index b723ffac9a..be7058ae08 100644
--- a/osu.Game/Screens/Edit/Timing/TimingScreen.cs
+++ b/osu.Game/Screens/Edit/Timing/TimingScreen.cs
@@ -1,12 +1,18 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
+using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
+using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
+using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
@@ -15,6 +21,9 @@ namespace osu.Game.Screens.Edit.Timing
{
public class TimingScreen : EditorScreenWithTimeline
{
+ [Cached]
+ private readonly Bindable controlPoint = new Bindable();
+
protected override Drawable CreateMainContent() => new GridContainer
{
RelativeSizeAxes = Axes.Both,
@@ -53,37 +62,13 @@ namespace osu.Game.Screens.Edit.Timing
new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
- Child = new FillFlowContainer
+ Child = new ControlPointTable
{
- RelativeSizeAxes = Axes.Both,
- Direction = FillDirection.Vertical,
- Children = new Drawable[]
- {
- new ControlPointRow(),
- new ControlPointRow(),
- new ControlPointRow(),
- new ControlPointRow(),
- new ControlPointRow(),
- new ControlPointRow(),
- }
- },
+ ControlPoints = Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints
+ }
}
};
}
-
- private class ControlPointRow : CompositeDrawable
- {
- public ControlPointRow()
- {
- RelativeSizeAxes = Axes.X;
- AutoSizeAxes = Axes.Y;
-
- InternalChildren = new Drawable[]
- {
- new OsuSpriteText { Text = "sample row" },
- };
- }
- }
}
public class ControlPointSettings : CompositeDrawable
@@ -101,4 +86,152 @@ namespace osu.Game.Screens.Edit.Timing
}
}
}
+
+ public class ControlPointTable : TableContainer
+ {
+ private const float horizontal_inset = 20;
+ private const float row_height = 25;
+ private const int text_size = 14;
+
+ private readonly FillFlowContainer backgroundFlow;
+
+ [Resolved]
+ private Bindable controlPoint { get; set; }
+
+ public ControlPointTable()
+ {
+ RelativeSizeAxes = Axes.X;
+ AutoSizeAxes = Axes.Y;
+
+ Padding = new MarginPadding { Horizontal = horizontal_inset };
+ RowSize = new Dimension(GridSizeMode.Absolute, row_height);
+
+ AddInternal(backgroundFlow = new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.Both,
+ Depth = 1f,
+ Padding = new MarginPadding { Horizontal = -horizontal_inset },
+ Margin = new MarginPadding { Top = row_height }
+ });
+ }
+
+ public IReadOnlyList ControlPoints
+ {
+ set
+ {
+ Content = null;
+ backgroundFlow.Clear();
+
+ if (value?.Any() != true)
+ return;
+
+ for (int i = 0; i < value.Count; i++)
+ {
+ var cp = value[i];
+ backgroundFlow.Add(new RowBackground { Action = () => controlPoint.Value = cp });
+ }
+
+ Columns = createHeaders();
+ Content = value.Select((s, i) => createContent(i, s)).ToArray().ToRectangular();
+ }
+ }
+
+ private TableColumn[] createHeaders()
+ {
+ var columns = new List
+ {
+ new TableColumn(string.Empty, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
+ new TableColumn("offset", Anchor.Centre),
+ new TableColumn("BPM", Anchor.Centre),
+ new TableColumn("Meter", Anchor.Centre),
+ new TableColumn("Sample Set", Anchor.Centre),
+ new TableColumn("Volume", Anchor.Centre),
+ };
+
+ return columns.ToArray();
+ }
+
+ private Drawable[] createContent(int index, ControlPoint controlPoint)
+ {
+ return new Drawable[]
+ {
+ new OsuSpriteText
+ {
+ Text = $"#{index + 1}",
+ Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
+ },
+ new OsuSpriteText
+ {
+ Text = $"{controlPoint.Time}",
+ Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
+ },
+ new OsuSpriteText
+ {
+ Text = $"{(controlPoint as TimingControlPoint)?.BeatLength.ToString(CultureInfo.InvariantCulture) ?? "-"}",
+ Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
+ },
+ new OsuSpriteText
+ {
+ Text = $"{(controlPoint as TimingControlPoint)?.TimeSignature.ToString() ?? "-"}",
+ Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold)
+ },
+ };
+ }
+
+ protected override Drawable CreateHeader(int index, TableColumn column) => new HeaderText(column?.Header ?? string.Empty);
+
+ private class HeaderText : OsuSpriteText
+ {
+ public HeaderText(string text)
+ {
+ Text = text.ToUpper();
+ Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black);
+ }
+ }
+
+ public class RowBackground : OsuClickableContainer
+ {
+ private const int fade_duration = 100;
+
+ private readonly Box hoveredBackground;
+
+ public RowBackground()
+ {
+ RelativeSizeAxes = Axes.X;
+ Height = 25;
+
+ AlwaysPresent = true;
+
+ CornerRadius = 3;
+ Masking = true;
+
+ Children = new Drawable[]
+ {
+ hoveredBackground = new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Alpha = 0,
+ },
+ };
+ }
+
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colours)
+ {
+ hoveredBackground.Colour = colours.Blue;
+ }
+
+ protected override bool OnHover(HoverEvent e)
+ {
+ hoveredBackground.FadeIn(fade_duration, Easing.OutQuint);
+ return base.OnHover(e);
+ }
+
+ protected override void OnHoverLost(HoverLostEvent e)
+ {
+ hoveredBackground.FadeOut(fade_duration, Easing.OutQuint);
+ base.OnHoverLost(e);
+ }
+ }
+ }
}
From 13924174c4950a173c575217484006046cfaccf4 Mon Sep 17 00:00:00 2001
From: HoLLy-HaCKeR
Date: Sat, 12 Oct 2019 10:04:14 +0200
Subject: [PATCH 104/901] Fix PopIn and PopOut resetting cursor scale
---
osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
index 371c2983fc..2b499064fb 100644
--- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
+++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
@@ -31,6 +31,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
private Bindable cursorScale;
private Bindable autoCursorScale;
+ private float calculatedCursorScale;
private readonly IBindable beatmap = new Bindable();
public OsuCursorContainer()
@@ -69,6 +70,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
scale *= 1f - 0.7f * (1f + beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY;
}
+ calculatedCursorScale = scale;
ActiveCursor.Scale = cursorTrail.Scale = new Vector2(scale);
}
@@ -125,13 +127,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
protected override void PopIn()
{
fadeContainer.FadeTo(1, 300, Easing.OutQuint);
- ActiveCursor.ScaleTo(1, 400, Easing.OutQuint);
+ ActiveCursor.ScaleTo(calculatedCursorScale, 400, Easing.OutQuint);
}
protected override void PopOut()
{
fadeContainer.FadeTo(0.05f, 450, Easing.OutQuint);
- ActiveCursor.ScaleTo(0.8f, 450, Easing.OutQuint);
+ ActiveCursor.ScaleTo(calculatedCursorScale * 0.8f, 450, Easing.OutQuint);
}
private class DefaultCursorTrail : CursorTrail
From fdc17d2adb07d81c22f7d1b6ad3c44f277917429 Mon Sep 17 00:00:00 2001
From: HoLLy-HaCKeR
Date: Sat, 12 Oct 2019 11:51:14 +0200
Subject: [PATCH 105/901] Scale OsuResumeCursor with gameplay cursor
---
.../UI/Cursor/OsuCursorContainer.cs | 13 ++++++++-----
osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 14 +++++++++++---
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
index 2b499064fb..8ea11d0a4b 100644
--- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
+++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
@@ -29,9 +29,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
private readonly Drawable cursorTrail;
+ public IBindable CalculatedCursorScale => calculatedCursorScale;
+ private Bindable calculatedCursorScale;
private Bindable cursorScale;
private Bindable autoCursorScale;
- private float calculatedCursorScale;
private readonly IBindable beatmap = new Bindable();
public OsuCursorContainer()
@@ -57,6 +58,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
autoCursorScale = config.GetBindable(OsuSetting.AutoCursorSize);
autoCursorScale.ValueChanged += _ => calculateScale();
+ calculatedCursorScale = new Bindable();
+ calculatedCursorScale.ValueChanged += e => ActiveCursor.Scale = cursorTrail.Scale = new Vector2(e.NewValue);
+
calculateScale();
}
@@ -70,8 +74,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
scale *= 1f - 0.7f * (1f + beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY;
}
- calculatedCursorScale = scale;
- ActiveCursor.Scale = cursorTrail.Scale = new Vector2(scale);
+ calculatedCursorScale.Value = scale;
}
protected override void LoadComplete()
@@ -127,13 +130,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
protected override void PopIn()
{
fadeContainer.FadeTo(1, 300, Easing.OutQuint);
- ActiveCursor.ScaleTo(calculatedCursorScale, 400, Easing.OutQuint);
+ ActiveCursor.ScaleTo(calculatedCursorScale.Value, 400, Easing.OutQuint);
}
protected override void PopOut()
{
fadeContainer.FadeTo(0.05f, 450, Easing.OutQuint);
- ActiveCursor.ScaleTo(calculatedCursorScale * 0.8f, 450, Easing.OutQuint);
+ ActiveCursor.ScaleTo(calculatedCursorScale.Value * 0.8f, 450, Easing.OutQuint);
}
private class DefaultCursorTrail : CursorTrail
diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
index 9e5df0d6b1..9033817115 100644
--- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
+++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
@@ -38,7 +38,13 @@ namespace osu.Game.Rulesets.Osu.UI
clickToResumeCursor.ShowAt(GameplayCursor.ActiveCursor.Position);
if (localCursorContainer == null)
- Add(localCursorContainer = new OsuCursorContainer());
+ {
+ var newContainer = new OsuCursorContainer();
+ Add(localCursorContainer = newContainer);
+
+ clickToResumeCursor.CursorScale = newContainer.CalculatedCursorScale.Value;
+ newContainer.CalculatedCursorScale.ValueChanged += e => clickToResumeCursor.CursorScale = e.NewValue;
+ }
}
public override void Hide()
@@ -57,6 +63,8 @@ namespace osu.Game.Rulesets.Osu.UI
public Action ResumeRequested;
+ public float CursorScale;
+
public OsuClickToResumeCursor()
{
RelativePositionAxes = Axes.Both;
@@ -82,7 +90,7 @@ namespace osu.Game.Rulesets.Osu.UI
case OsuAction.RightButton:
if (!IsHovered) return false;
- this.ScaleTo(new Vector2(2), TRANSITION_TIME, Easing.OutQuint);
+ this.ScaleTo(2 * CursorScale, TRANSITION_TIME, Easing.OutQuint);
ResumeRequested?.Invoke();
return true;
@@ -97,7 +105,7 @@ namespace osu.Game.Rulesets.Osu.UI
{
updateColour();
this.MoveTo(activeCursorPosition);
- this.ScaleTo(new Vector2(4)).Then().ScaleTo(Vector2.One, 1000, Easing.OutQuint);
+ this.ScaleTo(4 * CursorScale).Then().ScaleTo(CursorScale, 1000, Easing.OutQuint);
});
private void updateColour()
From 7931510d7bda55dc3b54da6d411cd8c4711a7e4e Mon Sep 17 00:00:00 2001
From: HoLLy-HaCKeR
Date: Sat, 12 Oct 2019 11:59:22 +0200
Subject: [PATCH 106/901] Ensure OsuResumeCursor can change scale when it is
being shown
---
osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
index 9033817115..7221e09c35 100644
--- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
+++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
@@ -43,7 +43,13 @@ namespace osu.Game.Rulesets.Osu.UI
Add(localCursorContainer = newContainer);
clickToResumeCursor.CursorScale = newContainer.CalculatedCursorScale.Value;
- newContainer.CalculatedCursorScale.ValueChanged += e => clickToResumeCursor.CursorScale = e.NewValue;
+ clickToResumeCursor.Scale = new Vector2(newContainer.CalculatedCursorScale.Value);
+
+ newContainer.CalculatedCursorScale.ValueChanged += e =>
+ {
+ clickToResumeCursor.CursorScale = e.NewValue;
+ clickToResumeCursor.Scale = new Vector2(e.NewValue);
+ };
}
}
From 4d971e49ff050685a4498cc31b941fd426f41ef1 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Sun, 13 Oct 2019 11:50:27 +0300
Subject: [PATCH 107/901] Colours update
---
osu.Game/Overlays/Comments/CommentsContainer.cs | 2 +-
osu.Game/Overlays/Comments/DrawableComment.cs | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 265793226e..b66374cb69 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -113,7 +113,7 @@ namespace osu.Game.Overlays.Comments
[BackgroundDependencyLoader]
private void load()
{
- background.Colour = colours.Gray3;
+ background.Colour = colours.Gray2;
}
}
}
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index fd7f874304..4617f6f86e 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -13,7 +13,6 @@ using osu.Game.Utils;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
-using osuTK.Graphics;
using System.Linq;
namespace osu.Game.Overlays.Comments
@@ -134,6 +133,7 @@ namespace osu.Game.Overlays.Comments
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10, 0),
+ Colour = OsuColour.Gray(0.7f),
Children = new Drawable[]
{
new SpriteText
@@ -262,6 +262,7 @@ namespace osu.Game.Overlays.Comments
Child = icon = new SpriteIcon
{
Size = new Vector2(12),
+ Colour = OsuColour.Gray(0.7f)
};
}
@@ -340,7 +341,7 @@ namespace osu.Game.Overlays.Comments
new Box
{
RelativeSizeAxes = Axes.Both,
- Colour = Color4.Black
+ Colour = OsuColour.Gray(0.05f)
},
new SpriteText
{
From 795ce8146895f435744a41e929a4621d0a212f16 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Sun, 13 Oct 2019 12:10:01 +0300
Subject: [PATCH 108/901] Use async loading for comment pages
---
.../Overlays/Comments/CommentsContainer.cs | 42 +++++++++++++------
1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index b66374cb69..3b997540c4 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -10,6 +10,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
+using System.Threading;
namespace osu.Game.Overlays.Comments
{
@@ -28,6 +29,7 @@ namespace osu.Game.Overlays.Comments
private OsuColour colours { get; set; }
private GetCommentsRequest request;
+ private CancellationTokenSource loadCancellation;
private readonly Box background;
private readonly FillFlowContainer content;
@@ -79,7 +81,7 @@ namespace osu.Game.Overlays.Comments
private void getComments()
{
request?.Cancel();
- content.Clear();
+ loadCancellation?.Cancel();
request = new GetCommentsRequest(type, id, Sort.Value);
request.Success += onSuccess;
api.Queue(request);
@@ -87,27 +89,43 @@ namespace osu.Game.Overlays.Comments
private void onSuccess(APICommentsController response)
{
+ loadCancellation = new CancellationTokenSource();
+
+ FillFlowContainer page = new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical,
+ };
+
foreach (var c in response.Comments)
{
if (c.IsTopLevel)
- content.Add(new DrawableComment(c)
+ page.Add(new DrawableComment(c)
{
ShowDeleted = { BindTarget = ShowDeleted }
});
}
- int deletedComments = 0;
-
- response.Comments.ForEach(comment =>
+ LoadComponentAsync(page, loaded =>
{
- if (comment.IsDeleted && comment.IsTopLevel)
- deletedComments++;
- });
+ content.Clear();
- content.Add(new DeletedChildsPlaceholder(deletedComments)
- {
- ShowDeleted = { BindTarget = ShowDeleted }
- });
+ content.Add(loaded);
+
+ int deletedComments = 0;
+
+ response.Comments.ForEach(comment =>
+ {
+ if (comment.IsDeleted && comment.IsTopLevel)
+ deletedComments++;
+ });
+
+ content.Add(new DeletedChildsPlaceholder(deletedComments)
+ {
+ ShowDeleted = { BindTarget = ShowDeleted }
+ });
+ }, loadCancellation.Token);
}
[BackgroundDependencyLoader]
From 60954f969d77f6350b0f63903cf2f5696046c248 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Sun, 13 Oct 2019 12:38:50 +0300
Subject: [PATCH 109/901] DeletedChildsPlaceholder refactor
---
.../Overlays/Comments/CommentsContainer.cs | 33 ++++++++++++++++---
.../Comments/DeletedChildsPlaceholder.cs | 30 ++++++++++++-----
osu.Game/Overlays/Comments/DrawableComment.cs | 5 ++-
3 files changed, 55 insertions(+), 13 deletions(-)
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 3b997540c4..1fca9ca5e5 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -33,6 +33,8 @@ namespace osu.Game.Overlays.Comments
private readonly Box background;
private readonly FillFlowContainer content;
+ private readonly FillFlowContainer footer;
+ private readonly DeletedChildsPlaceholder deletedChildsPlaceholder;
public CommentsContainer(CommentableType type, long id)
{
@@ -64,6 +66,32 @@ namespace osu.Game.Overlays.Comments
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
+ },
+ new Container
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Children = new Drawable[]
+ {
+ new Box
+ {
+ RelativeSizeAxes = Axes.Both,
+ Colour = OsuColour.Gray(0.2f)
+ },
+ footer = new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Direction = FillDirection.Vertical,
+ Children = new Drawable[]
+ {
+ deletedChildsPlaceholder = new DeletedChildsPlaceholder
+ {
+ ShowDeleted = { BindTarget = ShowDeleted }
+ }
+ }
+ }
+ }
}
}
}
@@ -121,10 +149,7 @@ namespace osu.Game.Overlays.Comments
deletedComments++;
});
- content.Add(new DeletedChildsPlaceholder(deletedComments)
- {
- ShowDeleted = { BindTarget = ShowDeleted }
- });
+ deletedChildsPlaceholder.DeletedCount.Value = deletedComments;
}, loadCancellation.Token);
}
diff --git a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs b/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
index 7aae42908e..b5dcf433f1 100644
--- a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
+++ b/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
@@ -17,18 +17,18 @@ namespace osu.Game.Overlays.Comments
private const int margin = 10;
public readonly BindableBool ShowDeleted = new BindableBool();
+ public readonly BindableInt DeletedCount = new BindableInt();
- private readonly bool canBeVisible;
+ private bool canBeShown;
- public DeletedChildsPlaceholder(int count)
+ private readonly SpriteText countText;
+
+ public DeletedChildsPlaceholder()
{
- canBeVisible = count != 0;
-
AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal;
Spacing = new Vector2(3, 0);
Margin = new MarginPadding { Vertical = margin, Left = deleted_placeholder_margin };
- Alpha = 0;
Children = new Drawable[]
{
new SpriteIcon
@@ -36,24 +36,38 @@ namespace osu.Game.Overlays.Comments
Icon = FontAwesome.Solid.Trash,
Size = new Vector2(14),
},
- new SpriteText
+ countText = new SpriteText
{
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
- Text = $@"{count} deleted comment{(count.ToString().ToCharArray().Last() == '1' ? "" : "s")}"
}
};
}
protected override void LoadComplete()
{
+ DeletedCount.BindValueChanged(onCountChanged, true);
ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
base.LoadComplete();
}
private void onShowDeletedChanged(ValueChangedEvent showDeleted)
{
- if (canBeVisible)
+ if (canBeShown)
this.FadeTo(showDeleted.NewValue ? 0 : 1);
}
+
+ private void onCountChanged(ValueChangedEvent count)
+ {
+ canBeShown = count.NewValue != 0;
+
+ if (!canBeShown)
+ {
+ Hide();
+ return;
+ }
+
+ countText.Text = $@"{count.NewValue} deleted comment{(count.NewValue.ToString().ToCharArray().Last() == '1' ? "" : "s")}";
+ Show();
+ }
}
}
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 4617f6f86e..8c356a6156 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -32,6 +32,7 @@ namespace osu.Game.Overlays.Comments
private readonly FillFlowContainer childCommentsVisibilityContainer;
private readonly Comment comment;
+ private readonly DeletedChildsPlaceholder deletedChildsPlaceholder;
public DrawableComment(Comment comment)
{
@@ -168,7 +169,7 @@ namespace osu.Game.Overlays.Comments
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical
},
- new DeletedChildsPlaceholder(comment.GetDeletedChildsCount())
+ deletedChildsPlaceholder = new DeletedChildsPlaceholder
{
ShowDeleted = { BindTarget = ShowDeleted }
}
@@ -177,6 +178,8 @@ namespace osu.Game.Overlays.Comments
}
};
+ deletedChildsPlaceholder.DeletedCount.Value = comment.GetDeletedChildsCount();
+
if (comment.UserId == null)
username.AddText(comment.LegacyName);
else
From a44cc2e70baf13f3f90c6635d23bb2645b06841f Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Sun, 13 Oct 2019 14:43:30 +0300
Subject: [PATCH 110/901] Implement CommentsShowMoreButton
---
.../Online/TestSceneCommentsContainer.cs | 6 ++
.../Visual/Online/TestSceneShowMoreButton.cs | 5 +-
.../UserInterface}/ShowMoreButton.cs | 67 ++++++++++---------
.../Overlays/Comments/CommentsContainer.cs | 54 ++++++++++++---
.../Comments/CommentsShowMoreButton.cs | 32 +++++++++
.../Comments/DeletedChildsPlaceholder.cs | 8 ++-
.../Profile/Sections/PaginatedContainer.cs | 4 +-
.../Profile/Sections/ProfileShowMoreButton.cs | 20 ++++++
8 files changed, 151 insertions(+), 45 deletions(-)
rename osu.Game/{Overlays/Profile/Sections => Graphics/UserInterface}/ShowMoreButton.cs (77%)
create mode 100644 osu.Game/Overlays/Comments/CommentsShowMoreButton.cs
create mode 100644 osu.Game/Overlays/Profile/Sections/ProfileShowMoreButton.cs
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index 342ba487f0..a283663a4a 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -47,6 +47,12 @@ namespace osu.Game.Tests.Visual.Online
scrollFlow.Clear();
scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 24313));
});
+
+ AddStep("lazer build comments", () =>
+ {
+ scrollFlow.Clear();
+ scrollFlow.Add(new CommentsContainer(CommentableType.Build, 4772));
+ });
}
}
}
diff --git a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs
index bccb263600..8d4955abf0 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs
@@ -5,6 +5,7 @@ using osu.Game.Overlays.Profile.Sections;
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
+using osu.Game.Graphics.UserInterface;
namespace osu.Game.Tests.Visual.Online
{
@@ -17,11 +18,11 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneShowMoreButton()
{
- ShowMoreButton button = null;
+ ProfileShowMoreButton button = null;
int fireCount = 0;
- Add(button = new ShowMoreButton
+ Add(button = new ProfileShowMoreButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
diff --git a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
similarity index 77%
rename from osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs
rename to osu.Game/Graphics/UserInterface/ShowMoreButton.cs
index cf4e1c0dde..627ad995e8 100644
--- a/osu.Game/Overlays/Profile/Sections/ShowMoreButton.cs
+++ b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
@@ -1,30 +1,36 @@
-// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
-using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
-using osu.Game.Graphics.UserInterface;
using osuTK;
+using osuTK.Graphics;
using System.Collections.Generic;
-namespace osu.Game.Overlays.Profile.Sections
+namespace osu.Game.Graphics.UserInterface
{
public class ShowMoreButton : OsuHoverContainer
{
private const float fade_duration = 200;
- private readonly Box background;
- private readonly LoadingAnimation loading;
- private readonly FillFlowContainer content;
+ private Color4 chevronIconColour;
- protected override IEnumerable EffectTargets => new[] { background };
+ public Color4 ChevronIconColour
+ {
+ get => chevronIconColour;
+ set { chevronIconColour = leftChevron.AccentColour = rightChevron.AccentColour = value; }
+ }
+
+ public string Text
+ {
+ get => text.Text;
+ set { text.Text = value; }
+ }
private bool isLoading;
@@ -33,26 +39,32 @@ namespace osu.Game.Overlays.Profile.Sections
get => isLoading;
set
{
- if (isLoading == value)
- return;
-
isLoading = value;
Enabled.Value = !isLoading;
if (value)
{
- loading.FadeIn(fade_duration, Easing.OutQuint);
+ loading.Show();
content.FadeOut(fade_duration, Easing.OutQuint);
}
else
{
- loading.FadeOut(fade_duration, Easing.OutQuint);
+ loading.Hide();
content.FadeIn(fade_duration, Easing.OutQuint);
}
}
}
+ private readonly Box background;
+ private readonly LoadingAnimation loading;
+ private readonly FillFlowContainer content;
+ private readonly ChevronIcon leftChevron;
+ private readonly ChevronIcon rightChevron;
+ private readonly SpriteText text;
+
+ protected override IEnumerable EffectTargets => new[] { background };
+
public ShowMoreButton()
{
AutoSizeAxes = Axes.Both;
@@ -77,15 +89,15 @@ namespace osu.Game.Overlays.Profile.Sections
Spacing = new Vector2(7),
Children = new Drawable[]
{
- new ChevronIcon(),
- new OsuSpriteText
+ leftChevron = new ChevronIcon(),
+ text = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Text = "show more".ToUpper(),
},
- new ChevronIcon(),
+ rightChevron = new ChevronIcon(),
}
},
loading = new LoadingAnimation
@@ -99,13 +111,6 @@ namespace osu.Game.Overlays.Profile.Sections
};
}
- [BackgroundDependencyLoader]
- private void load(OsuColour colors)
- {
- IdleColour = colors.GreySeafoamDark;
- HoverColour = colors.GreySeafoam;
- }
-
protected override bool OnClick(ClickEvent e)
{
if (!Enabled.Value)
@@ -126,6 +131,14 @@ namespace osu.Game.Overlays.Profile.Sections
{
private const int icon_size = 8;
+ private Color4 accentColour;
+
+ public Color4 AccentColour
+ {
+ get => accentColour;
+ set { accentColour = Colour = value; }
+ }
+
public ChevronIcon()
{
Anchor = Anchor.Centre;
@@ -133,12 +146,6 @@ namespace osu.Game.Overlays.Profile.Sections
Size = new Vector2(icon_size);
Icon = FontAwesome.Solid.ChevronDown;
}
-
- [BackgroundDependencyLoader]
- private void load(OsuColour colors)
- {
- Colour = colors.Yellow;
- }
}
}
}
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 1fca9ca5e5..1111313d7f 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -16,6 +16,8 @@ namespace osu.Game.Overlays.Comments
{
public class CommentsContainer : CompositeDrawable
{
+ private const int more_button_margin = 5;
+
private readonly CommentableType type;
private readonly long id;
@@ -30,11 +32,13 @@ namespace osu.Game.Overlays.Comments
private GetCommentsRequest request;
private CancellationTokenSource loadCancellation;
+ private int currentPage;
+ private int loadedTopLevelComments;
private readonly Box background;
private readonly FillFlowContainer content;
- private readonly FillFlowContainer footer;
private readonly DeletedChildsPlaceholder deletedChildsPlaceholder;
+ private readonly CommentsShowMoreButton moreButton;
public CommentsContainer(CommentableType type, long id)
{
@@ -78,7 +82,7 @@ namespace osu.Game.Overlays.Comments
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f)
},
- footer = new FillFlowContainer
+ new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@@ -88,6 +92,18 @@ namespace osu.Game.Overlays.Comments
deletedChildsPlaceholder = new DeletedChildsPlaceholder
{
ShowDeleted = { BindTarget = ShowDeleted }
+ },
+ new Container
+ {
+ AutoSizeAxes = Axes.Y,
+ RelativeSizeAxes = Axes.X,
+ Child = moreButton = new CommentsShowMoreButton
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Margin = new MarginPadding(more_button_margin),
+ Action = () => getComments(false),
+ }
}
}
}
@@ -106,16 +122,25 @@ namespace osu.Game.Overlays.Comments
private void onSortChanged(ValueChangedEvent sort) => getComments();
- private void getComments()
+ private void getComments(bool initial = true)
{
+ if (initial)
+ {
+ currentPage = 1;
+ loadedTopLevelComments = 0;
+ deletedChildsPlaceholder.DeletedCount.Value = 0;
+ moreButton.IsLoading = true;
+ content.Clear();
+ }
+
request?.Cancel();
loadCancellation?.Cancel();
- request = new GetCommentsRequest(type, id, Sort.Value);
- request.Success += onSuccess;
+ request = new GetCommentsRequest(type, id, Sort.Value, currentPage++);
+ request.Success += response => onSuccess(response, initial);
api.Queue(request);
}
- private void onSuccess(APICommentsController response)
+ private void onSuccess(APICommentsController response, bool initial)
{
loadCancellation = new CancellationTokenSource();
@@ -137,8 +162,6 @@ namespace osu.Game.Overlays.Comments
LoadComponentAsync(page, loaded =>
{
- content.Clear();
-
content.Add(loaded);
int deletedComments = 0;
@@ -149,7 +172,20 @@ namespace osu.Game.Overlays.Comments
deletedComments++;
});
- deletedChildsPlaceholder.DeletedCount.Value = deletedComments;
+ deletedChildsPlaceholder.DeletedCount.Value = initial ? deletedComments : deletedChildsPlaceholder.DeletedCount.Value + deletedComments;
+
+ if (response.HasMore)
+ {
+ response.Comments.ForEach(comment =>
+ {
+ if (comment.IsTopLevel)
+ loadedTopLevelComments++;
+ });
+ moreButton.Current.Value = response.TopLevelCount - loadedTopLevelComments;
+ moreButton.IsLoading = false;
+ }
+ moreButton.FadeTo(response.HasMore ? 1 : 0);
+
}, loadCancellation.Token);
}
diff --git a/osu.Game/Overlays/Comments/CommentsShowMoreButton.cs b/osu.Game/Overlays/Comments/CommentsShowMoreButton.cs
new file mode 100644
index 0000000000..b0174e7b1a
--- /dev/null
+++ b/osu.Game/Overlays/Comments/CommentsShowMoreButton.cs
@@ -0,0 +1,32 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Bindables;
+using osu.Game.Graphics;
+using osu.Game.Graphics.UserInterface;
+
+namespace osu.Game.Overlays.Comments
+{
+ public class CommentsShowMoreButton : ShowMoreButton
+ {
+ public readonly BindableInt Current = new BindableInt();
+
+ public CommentsShowMoreButton()
+ {
+ IdleColour = OsuColour.Gray(0.3f);
+ HoverColour = OsuColour.Gray(0.4f);
+ ChevronIconColour = OsuColour.Gray(0.5f);
+ }
+
+ protected override void LoadComplete()
+ {
+ Current.BindValueChanged(onCurrentChanged, true);
+ base.LoadComplete();
+ }
+
+ private void onCurrentChanged(ValueChangedEvent count)
+ {
+ Text = $@"Show More ({count.NewValue})".ToUpper();
+ }
+ }
+}
diff --git a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs b/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
index b5dcf433f1..d626c13afd 100644
--- a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
+++ b/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
@@ -7,7 +7,6 @@ using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osuTK;
using osu.Framework.Bindables;
-using System.Linq;
namespace osu.Game.Overlays.Comments
{
@@ -66,7 +65,12 @@ namespace osu.Game.Overlays.Comments
return;
}
- countText.Text = $@"{count.NewValue} deleted comment{(count.NewValue.ToString().ToCharArray().Last() == '1' ? "" : "s")}";
+ string str = $@"{count.NewValue} deleted comment";
+
+ if (!(count.NewValue.ToString().EndsWith("1") && !count.NewValue.ToString().EndsWith("11")))
+ str += "s";
+
+ countText.Text = str;
Show();
}
}
diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs
index bb221bd43a..dc1a847b14 100644
--- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs
+++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs
@@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections
{
public abstract class PaginatedContainer : FillFlowContainer
{
- private readonly ShowMoreButton moreButton;
+ private readonly ProfileShowMoreButton moreButton;
private readonly OsuSpriteText missingText;
private APIRequest> retrievalRequest;
private CancellationTokenSource loadCancellation;
@@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Profile.Sections
RelativeSizeAxes = Axes.X,
Spacing = new Vector2(0, 2),
},
- moreButton = new ShowMoreButton
+ moreButton = new ProfileShowMoreButton
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
diff --git a/osu.Game/Overlays/Profile/Sections/ProfileShowMoreButton.cs b/osu.Game/Overlays/Profile/Sections/ProfileShowMoreButton.cs
new file mode 100644
index 0000000000..28486cc743
--- /dev/null
+++ b/osu.Game/Overlays/Profile/Sections/ProfileShowMoreButton.cs
@@ -0,0 +1,20 @@
+// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
+// See the LICENCE file in the repository root for full licence text.
+
+using osu.Framework.Allocation;
+using osu.Game.Graphics;
+using osu.Game.Graphics.UserInterface;
+
+namespace osu.Game.Overlays.Profile.Sections
+{
+ public class ProfileShowMoreButton : ShowMoreButton
+ {
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colors)
+ {
+ IdleColour = colors.GreySeafoamDark;
+ HoverColour = colors.GreySeafoam;
+ ChevronIconColour = colors.Yellow;
+ }
+ }
+}
From 328b4d6863a3002b396b65bbcdde32d0a95568ff Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Sun, 13 Oct 2019 16:22:10 +0300
Subject: [PATCH 111/901] Cancel request on dispose
---
osu.Game/Overlays/Comments/CommentsContainer.cs | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 1111313d7f..4c27c498c3 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -194,5 +194,12 @@ namespace osu.Game.Overlays.Comments
{
background.Colour = colours.Gray2;
}
+
+ protected override void Dispose(bool isDisposing)
+ {
+ request?.Cancel();
+ loadCancellation?.Cancel();
+ base.Dispose(isDisposing);
+ }
}
}
From ae2fe62fd9ed27d1ef5bdd60927795b9d509ca97 Mon Sep 17 00:00:00 2001
From: Dean Herbert
Date: Mon, 14 Oct 2019 17:13:36 +0900
Subject: [PATCH 112/901] Use BindValueChanged
---
osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
index 7221e09c35..1ee2a04a3b 100644
--- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
+++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
@@ -9,7 +9,6 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Osu.UI.Cursor;
-using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
using osuTK;
using osuTK.Graphics;
@@ -20,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.UI
{
private OsuClickToResumeCursor clickToResumeCursor;
- private GameplayCursorContainer localCursorContainer;
+ private OsuCursorContainer localCursorContainer;
public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null;
@@ -39,17 +38,13 @@ namespace osu.Game.Rulesets.Osu.UI
if (localCursorContainer == null)
{
- var newContainer = new OsuCursorContainer();
- Add(localCursorContainer = newContainer);
+ Add(localCursorContainer = new OsuCursorContainer());
- clickToResumeCursor.CursorScale = newContainer.CalculatedCursorScale.Value;
- clickToResumeCursor.Scale = new Vector2(newContainer.CalculatedCursorScale.Value);
-
- newContainer.CalculatedCursorScale.ValueChanged += e =>
+ localCursorContainer.CalculatedCursorScale.BindValueChanged(scale =>
{
- clickToResumeCursor.CursorScale = e.NewValue;
- clickToResumeCursor.Scale = new Vector2(e.NewValue);
- };
+ clickToResumeCursor.CursorScale = scale.NewValue;
+ clickToResumeCursor.Scale = new Vector2(scale.NewValue);
+ }, true);
}
}
From 7cd3f5656d4c7b482fb995ce9ce4489db0a20d3d Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 14 Oct 2019 16:43:43 +0300
Subject: [PATCH 113/901] Cleanups
---
.../Online/TestSceneCommentsContainer.cs | 2 +-
.../Online/API/Requests/Responses/Comment.cs | 6 ++++-
.../Overlays/Comments/CommentsContainer.cs | 4 +--
.../Comments/DeletedChildsPlaceholder.cs | 5 +---
osu.Game/Overlays/Comments/DrawableComment.cs | 27 +++++++------------
.../Overlays/Comments/ShowChildsButton.cs | 2 +-
6 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index a283663a4a..5e4aa27fae 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -20,7 +20,7 @@ namespace osu.Game.Tests.Visual.Online
typeof(CommentsHeader),
typeof(DrawableComment),
typeof(HeaderButton),
- typeof(SortSelector),
+ typeof(SortTabControl),
typeof(ShowChildsButton),
typeof(DeletedChildsPlaceholder)
};
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 2334c86519..d0f7e4fac5 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -6,6 +6,7 @@ using osu.Game.Users;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Text.RegularExpressions;
namespace osu.Game.Online.API.Requests.Responses
{
@@ -90,7 +91,10 @@ namespace osu.Game.Online.API.Requests.Responses
public string GetMessage()
{
- return IsDeleted ? @"deleted" : MessageHTML.Replace("", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace("
", "").Replace(""", "\"");
+ if (IsDeleted)
+ return @"deleted";
+
+ return Regex.Replace(MessageHTML, @"\<.*?\>", "");
}
public int GetDeletedChildsCount()
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 4c27c498c3..8680234d4b 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -16,8 +16,6 @@ namespace osu.Game.Overlays.Comments
{
public class CommentsContainer : CompositeDrawable
{
- private const int more_button_margin = 5;
-
private readonly CommentableType type;
private readonly long id;
@@ -101,7 +99,7 @@ namespace osu.Game.Overlays.Comments
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
- Margin = new MarginPadding(more_button_margin),
+ Margin = new MarginPadding(5),
Action = () => getComments(false),
}
}
diff --git a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs b/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
index d626c13afd..058f8cc750 100644
--- a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
+++ b/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
@@ -12,9 +12,6 @@ namespace osu.Game.Overlays.Comments
{
public class DeletedChildsPlaceholder : FillFlowContainer
{
- private const int deleted_placeholder_margin = 80;
- private const int margin = 10;
-
public readonly BindableBool ShowDeleted = new BindableBool();
public readonly BindableInt DeletedCount = new BindableInt();
@@ -27,7 +24,7 @@ namespace osu.Game.Overlays.Comments
AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal;
Spacing = new Vector2(3, 0);
- Margin = new MarginPadding { Vertical = margin, Left = deleted_placeholder_margin };
+ Margin = new MarginPadding { Vertical = 10, Left = 80 };
Children = new Drawable[]
{
new SpriteIcon
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 8c356a6156..756eb8caf9 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -21,18 +21,14 @@ namespace osu.Game.Overlays.Comments
{
private const int avatar_size = 40;
private const int margin = 10;
- private const int child_margin = 20;
- private const int chevron_margin = 30;
- private const int message_padding = 40;
- private const float separator_height = 1.5f;
public readonly BindableBool ShowDeleted = new BindableBool();
private readonly BindableBool childExpanded = new BindableBool(true);
private readonly FillFlowContainer childCommentsVisibilityContainer;
- private readonly Comment comment;
private readonly DeletedChildsPlaceholder deletedChildsPlaceholder;
+ private readonly Comment comment;
public DrawableComment(Comment comment)
{
@@ -127,7 +123,7 @@ namespace osu.Game.Overlays.Comments
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Padding = new MarginPadding { Right = message_padding }
+ Padding = new MarginPadding { Right = 40 }
},
info = new FillFlowContainer
{
@@ -164,7 +160,7 @@ namespace osu.Game.Overlays.Comments
{
childCommentsContainer = new FillFlowContainer
{
- Margin = new MarginPadding { Left = child_margin },
+ Margin = new MarginPadding { Left = 20 },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical
@@ -180,10 +176,10 @@ namespace osu.Game.Overlays.Comments
deletedChildsPlaceholder.DeletedCount.Value = comment.GetDeletedChildsCount();
- if (comment.UserId == null)
- username.AddText(comment.LegacyName);
- else
+ if (comment.UserId.HasValue)
username.AddUserLink(comment.User);
+ else
+ username.AddText(comment.LegacyName);
if (comment.EditedAt.HasValue)
{
@@ -209,7 +205,7 @@ namespace osu.Game.Overlays.Comments
AddInternal(new Container
{
RelativeSizeAxes = Axes.X,
- Height = separator_height,
+ Height = 1.5f,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Child = new Box
@@ -225,7 +221,7 @@ namespace osu.Game.Overlays.Comments
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
- Margin = new MarginPadding { Right = chevron_margin, Top = margin },
+ Margin = new MarginPadding { Right = 30, Top = margin },
Expanded = { BindTarget = childExpanded }
});
}
@@ -240,15 +236,10 @@ namespace osu.Game.Overlays.Comments
protected override void LoadComplete()
{
ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
- childExpanded.BindValueChanged(onChildExpandedChanged, true);
+ childExpanded.BindValueChanged(expanded => childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0), true);
base.LoadComplete();
}
- private void onChildExpandedChanged(ValueChangedEvent expanded)
- {
- childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0);
- }
-
private void onShowDeletedChanged(ValueChangedEvent show)
{
if (comment.IsDeleted)
diff --git a/osu.Game/Overlays/Comments/ShowChildsButton.cs b/osu.Game/Overlays/Comments/ShowChildsButton.cs
index 81280a71b5..b29e316e80 100644
--- a/osu.Game/Overlays/Comments/ShowChildsButton.cs
+++ b/osu.Game/Overlays/Comments/ShowChildsButton.cs
@@ -28,7 +28,7 @@ namespace osu.Game.Overlays.Comments
protected override bool OnClick(ClickEvent e)
{
Expanded.Value = !Expanded.Value;
- return base.OnClick(e);
+ return true;
}
}
}
From a81d5cd81968fc113f924552c87f728da17d0ef6 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 14 Oct 2019 16:56:07 +0300
Subject: [PATCH 114/901] Handle links in message
---
osu.Game/Overlays/Comments/DrawableComment.cs | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 756eb8caf9..c492e48acf 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -14,6 +14,7 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
using System.Linq;
+using osu.Game.Online.Chat;
namespace osu.Game.Overlays.Comments
{
@@ -35,7 +36,7 @@ namespace osu.Game.Overlays.Comments
LinkFlowContainer username;
FillFlowContainer childCommentsContainer;
FillFlowContainer info;
- TextFlowContainer message;
+ LinkFlowContainer message;
GridContainer content;
VotePill votePill;
@@ -119,7 +120,7 @@ namespace osu.Game.Overlays.Comments
}
}
},
- message = new TextFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
+ message = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@@ -193,7 +194,10 @@ namespace osu.Game.Overlays.Comments
}
if (!comment.IsDeleted)
- message.Text = comment.GetMessage();
+ {
+ var formattedSource = MessageFormatter.FormatText(comment.GetMessage());
+ message.AddLinks(formattedSource.Text, formattedSource.Links);
+ }
else
{
content.FadeColour(OsuColour.Gray(0.5f));
From a4ffd4798dfc76b516f4da2cb8b2f8f58a5f858f Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 14 Oct 2019 17:02:48 +0300
Subject: [PATCH 115/901] Fix escaped html strings not being unescaped
---
osu.Game/Online/API/Requests/Responses/Comment.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index d0f7e4fac5..5e67bff859 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -6,6 +6,7 @@ using osu.Game.Users;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net;
using System.Text.RegularExpressions;
namespace osu.Game.Online.API.Requests.Responses
@@ -94,7 +95,7 @@ namespace osu.Game.Online.API.Requests.Responses
if (IsDeleted)
return @"deleted";
- return Regex.Replace(MessageHTML, @"\<.*?\>", "");
+ return WebUtility.HtmlDecode(Regex.Replace(MessageHTML, @"<(.|\n)*?>", string.Empty));
}
public int GetDeletedChildsCount()
From b53fb0d228ba112044285ca31272432a53938a43 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 14 Oct 2019 17:07:50 +0300
Subject: [PATCH 116/901] Remove empty line
---
osu.Game/Overlays/Comments/CommentsContainer.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 8680234d4b..a5e921e2c0 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -183,7 +183,6 @@ namespace osu.Game.Overlays.Comments
moreButton.IsLoading = false;
}
moreButton.FadeTo(response.HasMore ? 1 : 0);
-
}, loadCancellation.Token);
}
From 139170cdc859f2689e99b0a940f8334b2b46fa19 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 14 Oct 2019 17:26:12 +0300
Subject: [PATCH 117/901] Fix incorrect padding for nested comments
---
osu.Game/Overlays/Comments/DrawableComment.cs | 169 +++++++++---------
1 file changed, 87 insertions(+), 82 deletions(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index c492e48acf..e5258ef3cc 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -51,100 +51,105 @@ namespace osu.Game.Overlays.Comments
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
- content = new GridContainer
+ new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
- Margin = new MarginPadding(margin),
- ColumnDimensions = new[]
+ Padding = new MarginPadding(margin),
+ Child = content = new GridContainer
{
- new Dimension(GridSizeMode.AutoSize),
- new Dimension(),
- },
- RowDimensions = new[]
- {
- new Dimension(GridSizeMode.AutoSize)
- },
- Content = new[]
- {
- new Drawable[]
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ ColumnDimensions = new[]
{
- new FillFlowContainer
+ new Dimension(GridSizeMode.AutoSize),
+ new Dimension(),
+ },
+ RowDimensions = new[]
+ {
+ new Dimension(GridSizeMode.AutoSize)
+ },
+ Content = new[]
+ {
+ new Drawable[]
{
- AutoSizeAxes = Axes.Both,
- Margin = new MarginPadding { Horizontal = margin },
- Direction = FillDirection.Horizontal,
- Spacing = new Vector2(5, 0),
- Children = new Drawable[]
+ new FillFlowContainer
{
- votePill = new VotePill(comment.VotesCount)
+ AutoSizeAxes = Axes.Both,
+ Margin = new MarginPadding { Horizontal = margin },
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(5, 0),
+ Children = new Drawable[]
{
- Anchor = Anchor.Centre,
- Origin = Anchor.Centre,
- AlwaysPresent = true,
- },
- new UpdateableAvatar(comment.User)
- {
- Anchor = Anchor.Centre,
- Origin = Anchor.Centre,
- Size = new Vector2(avatar_size),
- Masking = true,
- CornerRadius = avatar_size / 2,
- },
- }
- },
- new FillFlowContainer
- {
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Spacing = new Vector2(0, 3),
- Children = new Drawable[]
- {
- new FillFlowContainer
- {
- AutoSizeAxes = Axes.Both,
- Direction = FillDirection.Horizontal,
- Spacing = new Vector2(7, 0),
- Children = new Drawable[]
+ votePill = new VotePill(comment.VotesCount)
{
- username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ AlwaysPresent = true,
+ },
+ new UpdateableAvatar(comment.User)
+ {
+ Anchor = Anchor.Centre,
+ Origin = Anchor.Centre,
+ Size = new Vector2(avatar_size),
+ Masking = true,
+ CornerRadius = avatar_size / 2,
+ },
+ }
+ },
+ new FillFlowContainer
+ {
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Spacing = new Vector2(0, 3),
+ Children = new Drawable[]
+ {
+ new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(7, 0),
+ Children = new Drawable[]
{
- AutoSizeAxes = Axes.Both,
- },
- new ParentUsername(comment),
- new SpriteText
- {
- Alpha = comment.IsDeleted? 1 : 0,
- Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
- Text = @"deleted",
+ username = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true))
+ {
+ AutoSizeAxes = Axes.Both,
+ },
+ new ParentUsername(comment),
+ new SpriteText
+ {
+ Alpha = comment.IsDeleted? 1 : 0,
+ Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
+ Text = @"deleted",
+ }
}
- }
- },
- message = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
- {
- RelativeSizeAxes = Axes.X,
- AutoSizeAxes = Axes.Y,
- Padding = new MarginPadding { Right = 40 }
- },
- info = new FillFlowContainer
- {
- AutoSizeAxes = Axes.Both,
- Direction = FillDirection.Horizontal,
- Spacing = new Vector2(10, 0),
- Colour = OsuColour.Gray(0.7f),
- Children = new Drawable[]
+ },
+ message = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 14))
{
- new SpriteText
+ RelativeSizeAxes = Axes.X,
+ AutoSizeAxes = Axes.Y,
+ Padding = new MarginPadding { Right = 40 }
+ },
+ info = new FillFlowContainer
+ {
+ AutoSizeAxes = Axes.Both,
+ Direction = FillDirection.Horizontal,
+ Spacing = new Vector2(10, 0),
+ Colour = OsuColour.Gray(0.7f),
+ Children = new Drawable[]
{
- Anchor = Anchor.CentreLeft,
- Origin = Anchor.CentreLeft,
- Font = OsuFont.GetFont(size: 12),
- Text = HumanizerUtils.Humanize(comment.CreatedAt)
- },
- new RepliesButton(comment.RepliesCount)
- {
- Expanded = { BindTarget = childExpanded }
- },
+ new SpriteText
+ {
+ Anchor = Anchor.CentreLeft,
+ Origin = Anchor.CentreLeft,
+ Font = OsuFont.GetFont(size: 12),
+ Text = HumanizerUtils.Humanize(comment.CreatedAt)
+ },
+ new RepliesButton(comment.RepliesCount)
+ {
+ Expanded = { BindTarget = childExpanded }
+ },
+ }
}
}
}
@@ -161,7 +166,7 @@ namespace osu.Game.Overlays.Comments
{
childCommentsContainer = new FillFlowContainer
{
- Margin = new MarginPadding { Left = 20 },
+ Padding = new MarginPadding { Left = 20 },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical
From d4843285dbf091b6756b71e86599a94ffb8bbde0 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Mon, 14 Oct 2019 17:33:14 +0300
Subject: [PATCH 118/901] CI fixes
---
osu.Game/Graphics/UserInterface/ShowMoreButton.cs | 6 +++---
osu.Game/Online/API/Requests/Responses/Comment.cs | 4 ++--
osu.Game/Overlays/Comments/CommentsContainer.cs | 1 +
osu.Game/Overlays/Comments/DrawableComment.cs | 15 +++++----------
osu.Game/Overlays/Comments/ShowChildsButton.cs | 2 +-
5 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/osu.Game/Graphics/UserInterface/ShowMoreButton.cs b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
index 627ad995e8..8b2eb31d96 100644
--- a/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
+++ b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
@@ -23,13 +23,13 @@ namespace osu.Game.Graphics.UserInterface
public Color4 ChevronIconColour
{
get => chevronIconColour;
- set { chevronIconColour = leftChevron.AccentColour = rightChevron.AccentColour = value; }
+ set => chevronIconColour = leftChevron.AccentColour = rightChevron.AccentColour = value;
}
public string Text
{
get => text.Text;
- set { text.Text = value; }
+ set => text.Text = value;
}
private bool isLoading;
@@ -136,7 +136,7 @@ namespace osu.Game.Graphics.UserInterface
public Color4 AccentColour
{
get => accentColour;
- set { accentColour = Colour = value; }
+ set => accentColour = Colour = value;
}
public ChevronIcon()
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 5e67bff859..6243ea4fb6 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -42,7 +42,7 @@ namespace osu.Game.Online.API.Requests.Responses
public string Message { get; set; }
[JsonProperty(@"message_html")]
- public string MessageHTML { get; set; }
+ public string MessageHtml { get; set; }
[JsonProperty(@"replies_count")]
public int RepliesCount { get; set; }
@@ -95,7 +95,7 @@ namespace osu.Game.Online.API.Requests.Responses
if (IsDeleted)
return @"deleted";
- return WebUtility.HtmlDecode(Regex.Replace(MessageHTML, @"<(.|\n)*?>", string.Empty));
+ return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty));
}
public int GetDeletedChildsCount()
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index a5e921e2c0..6c674678df 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -182,6 +182,7 @@ namespace osu.Game.Overlays.Comments
moreButton.Current.Value = response.TopLevelCount - loadedTopLevelComments;
moreButton.IsLoading = false;
}
+
moreButton.FadeTo(response.HasMore ? 1 : 0);
}, loadCancellation.Token);
}
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index e5258ef3cc..38e45949e1 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -28,13 +28,13 @@ namespace osu.Game.Overlays.Comments
private readonly BindableBool childExpanded = new BindableBool(true);
private readonly FillFlowContainer childCommentsVisibilityContainer;
- private readonly DeletedChildsPlaceholder deletedChildsPlaceholder;
private readonly Comment comment;
public DrawableComment(Comment comment)
{
LinkFlowContainer username;
FillFlowContainer childCommentsContainer;
+ DeletedChildsPlaceholder deletedChildsPlaceholder;
FillFlowContainer info;
LinkFlowContainer message;
GridContainer content;
@@ -93,7 +93,7 @@ namespace osu.Game.Overlays.Comments
Origin = Anchor.Centre,
Size = new Vector2(avatar_size),
Masking = true,
- CornerRadius = avatar_size / 2,
+ CornerRadius = avatar_size / 2f,
},
}
},
@@ -118,7 +118,7 @@ namespace osu.Game.Overlays.Comments
new ParentUsername(comment),
new SpriteText
{
- Alpha = comment.IsDeleted? 1 : 0,
+ Alpha = comment.IsDeleted ? 1 : 0,
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
Text = @"deleted",
}
@@ -299,8 +299,6 @@ namespace osu.Game.Overlays.Comments
private class ParentUsername : FillFlowContainer, IHasTooltip
{
- private const int spacing = 3;
-
public string TooltipText => comment.ParentComment?.GetMessage() ?? "";
private readonly Comment comment;
@@ -311,7 +309,7 @@ namespace osu.Game.Overlays.Comments
AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal;
- Spacing = new Vector2(spacing, 0);
+ Spacing = new Vector2(3, 0);
Alpha = comment.ParentId == null ? 0 : 1;
Children = new Drawable[]
{
@@ -331,13 +329,10 @@ namespace osu.Game.Overlays.Comments
private class VotePill : CircularContainer
{
- private const int height = 20;
- private const int margin = 10;
-
public VotePill(int count)
{
AutoSizeAxes = Axes.X;
- Height = height;
+ Height = 20;
Masking = true;
Children = new Drawable[]
{
diff --git a/osu.Game/Overlays/Comments/ShowChildsButton.cs b/osu.Game/Overlays/Comments/ShowChildsButton.cs
index b29e316e80..464c0a1503 100644
--- a/osu.Game/Overlays/Comments/ShowChildsButton.cs
+++ b/osu.Game/Overlays/Comments/ShowChildsButton.cs
@@ -12,7 +12,7 @@ namespace osu.Game.Overlays.Comments
{
public readonly BindableBool Expanded = new BindableBool(true);
- public ShowChildsButton()
+ protected ShowChildsButton()
{
AutoSizeAxes = Axes.Both;
}
From 6da1b4d0120317643473c61c4e9e9ce6f34f6784 Mon Sep 17 00:00:00 2001
From: miterosan
Date: Mon, 14 Oct 2019 21:46:01 +0200
Subject: [PATCH 119/901] Fix incorrect current directory that accours on some
devices on android.
---
osu.Android/OsuGameActivity.cs | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/osu.Android/OsuGameActivity.cs b/osu.Android/OsuGameActivity.cs
index 762a9c418d..41531617af 100644
--- a/osu.Android/OsuGameActivity.cs
+++ b/osu.Android/OsuGameActivity.cs
@@ -16,6 +16,11 @@ namespace osu.Android
protected override void OnCreate(Bundle savedInstanceState)
{
+ // The default current directory on android is '/'.
+ // On some devices '/' maps to the app data directory. On others it maps to the root of the internal storage.
+ // In order to have a consitend current directory on all devices the full path of the app data directory is set as the current directory.
+ System.Environment.CurrentDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
+
base.OnCreate(savedInstanceState);
Window.AddFlags(WindowManagerFlags.Fullscreen);
From b1f7a673e719ede09fd76bd4e2da36658aaa53bc Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 00:10:02 +0300
Subject: [PATCH 120/901] Simplify chevron icon coloring
---
osu.Game/Graphics/UserInterface/ShowMoreButton.cs | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/osu.Game/Graphics/UserInterface/ShowMoreButton.cs b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
index 8b2eb31d96..854b7abce1 100644
--- a/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
+++ b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
@@ -23,7 +23,7 @@ namespace osu.Game.Graphics.UserInterface
public Color4 ChevronIconColour
{
get => chevronIconColour;
- set => chevronIconColour = leftChevron.AccentColour = rightChevron.AccentColour = value;
+ set => chevronIconColour = leftChevron.Colour = rightChevron.Colour = value;
}
public string Text
@@ -131,14 +131,6 @@ namespace osu.Game.Graphics.UserInterface
{
private const int icon_size = 8;
- private Color4 accentColour;
-
- public Color4 AccentColour
- {
- get => accentColour;
- set => accentColour = Colour = value;
- }
-
public ChevronIcon()
{
Anchor = Anchor.Centre;
From 0676c880b53a612093ef2f0fb8f46c03246f355d Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 00:26:31 +0300
Subject: [PATCH 121/901] Simplify IsTopLevel and IsDeleted properties
---
.../Online/API/Requests/Responses/Comment.cs | 30 ++++---------------
1 file changed, 5 insertions(+), 25 deletions(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 6243ea4fb6..5accd7fd5b 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -16,20 +16,10 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"id")]
public long Id { get; set; }
- private long? parentId;
-
[JsonProperty(@"parent_id")]
- public long? ParentId
- {
- get => parentId;
- set
- {
- parentId = value;
- IsTopLevel = value == null;
- }
- }
+ public long? ParentId { get; set; }
- public List ChildComments = new List();
+ public readonly List ChildComments = new List();
public Comment ParentComment { get; set; }
@@ -65,18 +55,8 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"updated_at")]
public DateTimeOffset? UpdatedAt { get; set; }
- private DateTimeOffset? deletedAt;
-
[JsonProperty(@"deleted_at")]
- public DateTimeOffset? DeletedAt
- {
- get => deletedAt;
- set
- {
- deletedAt = value;
- IsDeleted = value != null;
- }
- }
+ public DateTimeOffset? DeletedAt { get; set; }
[JsonProperty(@"edited_at")]
public DateTimeOffset? EditedAt { get; set; }
@@ -86,9 +66,9 @@ namespace osu.Game.Online.API.Requests.Responses
public User EditedUser { get; set; }
- public bool IsTopLevel { get; set; }
+ public bool IsTopLevel => !ParentId.HasValue;
- public bool IsDeleted { get; set; }
+ public bool IsDeleted => DeletedAt.HasValue;
public string GetMessage()
{
From 09621f066e8fc1ac9b93e755c1fc94b416b8148e Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 00:32:21 +0300
Subject: [PATCH 122/901] Childs -> Children
---
.../Online/TestSceneCommentsContainer.cs | 4 ++--
.../Online/API/Requests/Responses/Comment.cs | 2 +-
.../Overlays/Comments/CommentsContainer.cs | 8 ++++----
...holder.cs => DeletedChildrenPlaceholder.cs} | 4 ++--
osu.Game/Overlays/Comments/DrawableComment.cs | 18 +++++++++---------
...owChildsButton.cs => ShowChildrenButton.cs} | 4 ++--
6 files changed, 20 insertions(+), 20 deletions(-)
rename osu.Game/Overlays/Comments/{DeletedChildsPlaceholder.cs => DeletedChildrenPlaceholder.cs} (95%)
rename osu.Game/Overlays/Comments/{ShowChildsButton.cs => ShowChildrenButton.cs} (89%)
diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
index 5e4aa27fae..436e80d6f5 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
@@ -21,8 +21,8 @@ namespace osu.Game.Tests.Visual.Online
typeof(DrawableComment),
typeof(HeaderButton),
typeof(SortTabControl),
- typeof(ShowChildsButton),
- typeof(DeletedChildsPlaceholder)
+ typeof(ShowChildrenButton),
+ typeof(DeletedChildrenPlaceholder)
};
protected override bool UseOnlineAPI => true;
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 5accd7fd5b..9e8f0cada2 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -78,7 +78,7 @@ namespace osu.Game.Online.API.Requests.Responses
return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty));
}
- public int GetDeletedChildsCount()
+ public int GetDeletedChildrenCount()
{
int count = 0;
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 6c674678df..48b3952093 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Comments
private readonly Box background;
private readonly FillFlowContainer content;
- private readonly DeletedChildsPlaceholder deletedChildsPlaceholder;
+ private readonly DeletedChildrenPlaceholder deletedChildrenPlaceholder;
private readonly CommentsShowMoreButton moreButton;
public CommentsContainer(CommentableType type, long id)
@@ -87,7 +87,7 @@ namespace osu.Game.Overlays.Comments
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
- deletedChildsPlaceholder = new DeletedChildsPlaceholder
+ deletedChildrenPlaceholder = new DeletedChildrenPlaceholder
{
ShowDeleted = { BindTarget = ShowDeleted }
},
@@ -126,7 +126,7 @@ namespace osu.Game.Overlays.Comments
{
currentPage = 1;
loadedTopLevelComments = 0;
- deletedChildsPlaceholder.DeletedCount.Value = 0;
+ deletedChildrenPlaceholder.DeletedCount.Value = 0;
moreButton.IsLoading = true;
content.Clear();
}
@@ -170,7 +170,7 @@ namespace osu.Game.Overlays.Comments
deletedComments++;
});
- deletedChildsPlaceholder.DeletedCount.Value = initial ? deletedComments : deletedChildsPlaceholder.DeletedCount.Value + deletedComments;
+ deletedChildrenPlaceholder.DeletedCount.Value = initial ? deletedComments : deletedChildrenPlaceholder.DeletedCount.Value + deletedComments;
if (response.HasMore)
{
diff --git a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs b/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs
similarity index 95%
rename from osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
rename to osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs
index 058f8cc750..f537141d7f 100644
--- a/osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
+++ b/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs
@@ -10,7 +10,7 @@ using osu.Framework.Bindables;
namespace osu.Game.Overlays.Comments
{
- public class DeletedChildsPlaceholder : FillFlowContainer
+ public class DeletedChildrenPlaceholder : FillFlowContainer
{
public readonly BindableBool ShowDeleted = new BindableBool();
public readonly BindableInt DeletedCount = new BindableInt();
@@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Comments
private readonly SpriteText countText;
- public DeletedChildsPlaceholder()
+ public DeletedChildrenPlaceholder()
{
AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal;
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 38e45949e1..81a6c6a743 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Comments
public readonly BindableBool ShowDeleted = new BindableBool();
- private readonly BindableBool childExpanded = new BindableBool(true);
+ private readonly BindableBool childrenExpanded = new BindableBool(true);
private readonly FillFlowContainer childCommentsVisibilityContainer;
private readonly Comment comment;
@@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Comments
{
LinkFlowContainer username;
FillFlowContainer childCommentsContainer;
- DeletedChildsPlaceholder deletedChildsPlaceholder;
+ DeletedChildrenPlaceholder deletedChildrenPlaceholder;
FillFlowContainer info;
LinkFlowContainer message;
GridContainer content;
@@ -147,7 +147,7 @@ namespace osu.Game.Overlays.Comments
},
new RepliesButton(comment.RepliesCount)
{
- Expanded = { BindTarget = childExpanded }
+ Expanded = { BindTarget = childrenExpanded }
},
}
}
@@ -171,7 +171,7 @@ namespace osu.Game.Overlays.Comments
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical
},
- deletedChildsPlaceholder = new DeletedChildsPlaceholder
+ deletedChildrenPlaceholder = new DeletedChildrenPlaceholder
{
ShowDeleted = { BindTarget = ShowDeleted }
}
@@ -180,7 +180,7 @@ namespace osu.Game.Overlays.Comments
}
};
- deletedChildsPlaceholder.DeletedCount.Value = comment.GetDeletedChildsCount();
+ deletedChildrenPlaceholder.DeletedCount.Value = comment.GetDeletedChildrenCount();
if (comment.UserId.HasValue)
username.AddUserLink(comment.User);
@@ -231,7 +231,7 @@ namespace osu.Game.Overlays.Comments
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Margin = new MarginPadding { Right = 30, Top = margin },
- Expanded = { BindTarget = childExpanded }
+ Expanded = { BindTarget = childrenExpanded }
});
}
}
@@ -245,7 +245,7 @@ namespace osu.Game.Overlays.Comments
protected override void LoadComplete()
{
ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
- childExpanded.BindValueChanged(expanded => childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0), true);
+ childrenExpanded.BindValueChanged(expanded => childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0), true);
base.LoadComplete();
}
@@ -255,7 +255,7 @@ namespace osu.Game.Overlays.Comments
this.FadeTo(show.NewValue ? 1 : 0);
}
- private class ChevronButton : ShowChildsButton
+ private class ChevronButton : ShowChildrenButton
{
private readonly SpriteIcon icon;
@@ -275,7 +275,7 @@ namespace osu.Game.Overlays.Comments
}
}
- private class RepliesButton : ShowChildsButton
+ private class RepliesButton : ShowChildrenButton
{
private readonly SpriteText text;
private readonly int count;
diff --git a/osu.Game/Overlays/Comments/ShowChildsButton.cs b/osu.Game/Overlays/Comments/ShowChildrenButton.cs
similarity index 89%
rename from osu.Game/Overlays/Comments/ShowChildsButton.cs
rename to osu.Game/Overlays/Comments/ShowChildrenButton.cs
index 464c0a1503..be04b6e5de 100644
--- a/osu.Game/Overlays/Comments/ShowChildsButton.cs
+++ b/osu.Game/Overlays/Comments/ShowChildrenButton.cs
@@ -8,11 +8,11 @@ using osu.Framework.Bindables;
namespace osu.Game.Overlays.Comments
{
- public abstract class ShowChildsButton : OsuHoverContainer
+ public abstract class ShowChildrenButton : OsuHoverContainer
{
public readonly BindableBool Expanded = new BindableBool(true);
- protected ShowChildsButton()
+ protected ShowChildrenButton()
{
AutoSizeAxes = Axes.Both;
}
From b84c9dfd84f206d3766b950803116fd687c61c7d Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 00:35:44 +0300
Subject: [PATCH 123/901] Use Humanizer.ToQuantity instead of manual parsing
---
osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs b/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs
index f537141d7f..21cf01f993 100644
--- a/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs
+++ b/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs
@@ -7,6 +7,7 @@ using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osuTK;
using osu.Framework.Bindables;
+using Humanizer;
namespace osu.Game.Overlays.Comments
{
@@ -62,12 +63,7 @@ namespace osu.Game.Overlays.Comments
return;
}
- string str = $@"{count.NewValue} deleted comment";
-
- if (!(count.NewValue.ToString().EndsWith("1") && !count.NewValue.ToString().EndsWith("11")))
- str += "s";
-
- countText.Text = str;
+ countText.Text = @"deleted comment".ToQuantity(count.NewValue);
Show();
}
}
From 0fd6b0c8524912ec9cc4b98cae03434a9db1154c Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 00:55:33 +0300
Subject: [PATCH 124/901] Use linq expression to count deleted comments
---
osu.Game/Online/API/Requests/Responses/Comment.cs | 14 +-------------
osu.Game/Overlays/Comments/CommentsContainer.cs | 9 ++-------
osu.Game/Overlays/Comments/DrawableComment.cs | 2 +-
3 files changed, 4 insertions(+), 21 deletions(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 9e8f0cada2..046de194db 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -78,18 +78,6 @@ namespace osu.Game.Online.API.Requests.Responses
return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty));
}
- public int GetDeletedChildrenCount()
- {
- int count = 0;
-
- if (ChildComments.Any())
- ChildComments.ForEach(child =>
- {
- if (child.IsDeleted)
- count++;
- });
-
- return count;
- }
+ public int GetDeletedChildrenCount => ChildComments.Select(c => c.IsDeleted).Where(c => c).Count();
}
}
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 48b3952093..318422bedb 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using System.Threading;
+using System.Linq;
namespace osu.Game.Overlays.Comments
{
@@ -162,13 +163,7 @@ namespace osu.Game.Overlays.Comments
{
content.Add(loaded);
- int deletedComments = 0;
-
- response.Comments.ForEach(comment =>
- {
- if (comment.IsDeleted && comment.IsTopLevel)
- deletedComments++;
- });
+ int deletedComments = response.Comments.Select(c => c.IsDeleted && c.IsTopLevel).Where(c => c).Count();
deletedChildrenPlaceholder.DeletedCount.Value = initial ? deletedComments : deletedChildrenPlaceholder.DeletedCount.Value + deletedComments;
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 81a6c6a743..13c67b9f5b 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -180,7 +180,7 @@ namespace osu.Game.Overlays.Comments
}
};
- deletedChildrenPlaceholder.DeletedCount.Value = comment.GetDeletedChildrenCount();
+ deletedChildrenPlaceholder.DeletedCount.Value = comment.GetDeletedChildrenCount;
if (comment.UserId.HasValue)
username.AddUserLink(comment.User);
From 42a06a54ffb3779c7079e0b8cbd934e7d204fe77 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 01:08:23 +0300
Subject: [PATCH 125/901] Don't use ProfileShowMoreButton in the test scene to
avoid confusion
---
.../Visual/Online/TestSceneShowMoreButton.cs | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs
index 8d4955abf0..b9fbbfef6b 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs
@@ -1,11 +1,12 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
-using osu.Game.Overlays.Profile.Sections;
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
+using osu.Framework.Allocation;
+using osu.Game.Graphics;
namespace osu.Game.Tests.Visual.Online
{
@@ -18,11 +19,11 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneShowMoreButton()
{
- ProfileShowMoreButton button = null;
+ TestButton button = null;
int fireCount = 0;
- Add(button = new ProfileShowMoreButton
+ Add(button = new TestButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@@ -52,5 +53,16 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("action fired twice", () => fireCount == 2);
AddAssert("is in loading state", () => button.IsLoading);
}
+
+ private class TestButton : ShowMoreButton
+ {
+ [BackgroundDependencyLoader]
+ private void load(OsuColour colors)
+ {
+ IdleColour = colors.YellowDark;
+ HoverColour = colors.Yellow;
+ ChevronIconColour = colors.Red;
+ }
+ }
}
}
From ad32d663652c2432a4f31bb73dc3b555a1e743c4 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 01:10:23 +0300
Subject: [PATCH 126/901] CI fix
---
osu.Game/Online/API/Requests/Responses/Comment.cs | 2 +-
osu.Game/Overlays/Comments/CommentsContainer.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 046de194db..9d011c49c1 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -78,6 +78,6 @@ namespace osu.Game.Online.API.Requests.Responses
return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty));
}
- public int GetDeletedChildrenCount => ChildComments.Select(c => c.IsDeleted).Where(c => c).Count();
+ public int GetDeletedChildrenCount => ChildComments.Select(c => c.IsDeleted).Count(c => c);
}
}
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 318422bedb..49c479f6e5 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -163,7 +163,7 @@ namespace osu.Game.Overlays.Comments
{
content.Add(loaded);
- int deletedComments = response.Comments.Select(c => c.IsDeleted && c.IsTopLevel).Where(c => c).Count();
+ int deletedComments = response.Comments.Select(c => c.IsDeleted && c.IsTopLevel).Count(c => c);
deletedChildrenPlaceholder.DeletedCount.Value = initial ? deletedComments : deletedChildrenPlaceholder.DeletedCount.Value + deletedComments;
From 12cd57744b87d559679e179f5f366ab1e64f6238 Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Tue, 15 Oct 2019 16:14:06 +0900
Subject: [PATCH 127/901] Make RulestStore initialise at construction time
---
.../Background/TestSceneUserDimContainer.cs | 6 ++
.../SongSelect/TestScenePlaySongSelect.cs | 6 ++
osu.Game/OsuGameBase.cs | 6 ++
osu.Game/Rulesets/RulesetStore.cs | 57 +++++++++++--------
4 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs
index 3061a3a542..f858174ff2 100644
--- a/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs
+++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs
@@ -285,6 +285,12 @@ namespace osu.Game.Tests.Visual.Background
});
}
+ protected override void Dispose(bool isDisposing)
+ {
+ base.Dispose(isDisposing);
+ rulesets?.Dispose();
+ }
+
private class DummySongSelect : PlaySongSelect
{
protected override BackgroundScreen CreateBackground()
diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
index a7020b6534..efe7fee5e4 100644
--- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
+++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
@@ -349,5 +349,11 @@ namespace osu.Game.Tests.Visual.SongSelect
DateAdded = DateTimeOffset.UtcNow,
};
}
+
+ protected override void Dispose(bool isDisposing)
+ {
+ base.Dispose(isDisposing);
+ rulesets?.Dispose();
+ }
}
}
diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs
index 8578517a17..194a439b06 100644
--- a/osu.Game/OsuGameBase.cs
+++ b/osu.Game/OsuGameBase.cs
@@ -298,6 +298,12 @@ namespace osu.Game
public string[] HandledExtensions => fileImporters.SelectMany(i => i.HandledExtensions).ToArray();
+ protected override void Dispose(bool isDisposing)
+ {
+ base.Dispose(isDisposing);
+ RulesetStore?.Dispose();
+ }
+
private class OsuUserInputManager : UserInputManager
{
protected override MouseButtonEventManager CreateButtonManagerFor(MouseButton button)
diff --git a/osu.Game/Rulesets/RulesetStore.cs b/osu.Game/Rulesets/RulesetStore.cs
index 47aad43966..1df8568ee1 100644
--- a/osu.Game/Rulesets/RulesetStore.cs
+++ b/osu.Game/Rulesets/RulesetStore.cs
@@ -14,25 +14,22 @@ namespace osu.Game.Rulesets
///
/// Todo: All of this needs to be moved to a RulesetStore.
///
- public class RulesetStore : DatabaseBackedStore
+ public class RulesetStore : DatabaseBackedStore, IDisposable
{
- private static readonly Dictionary loaded_assemblies = new Dictionary();
+ private const string ruleset_library_prefix = "osu.Game.Rulesets";
- static RulesetStore()
- {
- AppDomain.CurrentDomain.AssemblyResolve += currentDomain_AssemblyResolve;
-
- // On android in release configuration assemblies are loaded from the apk directly into memory.
- // We cannot read assemblies from cwd, so should check loaded assemblies instead.
- loadFromAppDomain();
-
- loadFromDisk();
- }
+ private readonly Dictionary loadedAssemblies = new Dictionary();
public RulesetStore(IDatabaseContextFactory factory)
: base(factory)
{
+ // On android in release configuration assemblies are loaded from the apk directly into memory.
+ // We cannot read assemblies from cwd, so should check loaded assemblies instead.
+ loadFromAppDomain();
+ loadFromDisk();
addMissingRulesets();
+
+ AppDomain.CurrentDomain.AssemblyResolve += resolveRulesetAssembly;
}
///
@@ -54,9 +51,7 @@ namespace osu.Game.Rulesets
///
public IEnumerable AvailableRulesets { get; private set; }
- private static Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args) => loaded_assemblies.Keys.FirstOrDefault(a => a.FullName == args.Name);
-
- private const string ruleset_library_prefix = "osu.Game.Rulesets";
+ private Assembly resolveRulesetAssembly(object sender, ResolveEventArgs args) => loadedAssemblies.Keys.FirstOrDefault(a => a.FullName == args.Name);
private void addMissingRulesets()
{
@@ -64,7 +59,7 @@ namespace osu.Game.Rulesets
{
var context = usage.Context;
- var instances = loaded_assemblies.Values.Select(r => (Ruleset)Activator.CreateInstance(r, (RulesetInfo)null)).ToList();
+ var instances = loadedAssemblies.Values.Select(r => (Ruleset)Activator.CreateInstance(r, (RulesetInfo)null)).ToList();
//add all legacy modes in correct order
foreach (var r in instances.Where(r => r.LegacyID != null).OrderBy(r => r.LegacyID))
@@ -113,7 +108,7 @@ namespace osu.Game.Rulesets
}
}
- private static void loadFromAppDomain()
+ private void loadFromAppDomain()
{
foreach (var ruleset in AppDomain.CurrentDomain.GetAssemblies())
{
@@ -126,7 +121,7 @@ namespace osu.Game.Rulesets
}
}
- private static void loadFromDisk()
+ private void loadFromDisk()
{
try
{
@@ -141,11 +136,11 @@ namespace osu.Game.Rulesets
}
}
- private static void loadRulesetFromFile(string file)
+ private void loadRulesetFromFile(string file)
{
var filename = Path.GetFileNameWithoutExtension(file);
- if (loaded_assemblies.Values.Any(t => t.Namespace == filename))
+ if (loadedAssemblies.Values.Any(t => t.Namespace == filename))
return;
try
@@ -158,19 +153,35 @@ namespace osu.Game.Rulesets
}
}
- private static void addRuleset(Assembly assembly)
+ private void addRuleset(Assembly assembly)
{
- if (loaded_assemblies.ContainsKey(assembly))
+ if (loadedAssemblies.ContainsKey(assembly))
return;
try
{
- loaded_assemblies[assembly] = assembly.GetTypes().First(t => t.IsPublic && t.IsSubclassOf(typeof(Ruleset)));
+ loadedAssemblies[assembly] = assembly.GetTypes().First(t => t.IsPublic && t.IsSubclassOf(typeof(Ruleset)));
}
catch (Exception e)
{
Logger.Error(e, $"Failed to add ruleset {assembly}");
}
}
+
+ ~RulesetStore()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ AppDomain.CurrentDomain.AssemblyResolve -= resolveRulesetAssembly;
+ }
}
}
From 96c6aeefe92a864ecd783f253506b899a6a18741 Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Tue, 15 Oct 2019 16:16:33 +0900
Subject: [PATCH 128/901] Remove out-of-date todo
---
osu.Game/Rulesets/RulesetStore.cs | 3 ---
1 file changed, 3 deletions(-)
diff --git a/osu.Game/Rulesets/RulesetStore.cs b/osu.Game/Rulesets/RulesetStore.cs
index 1df8568ee1..0e6e0b8676 100644
--- a/osu.Game/Rulesets/RulesetStore.cs
+++ b/osu.Game/Rulesets/RulesetStore.cs
@@ -11,9 +11,6 @@ using osu.Game.Database;
namespace osu.Game.Rulesets
{
- ///
- /// Todo: All of this needs to be moved to a RulesetStore.
- ///
public class RulesetStore : DatabaseBackedStore, IDisposable
{
private const string ruleset_library_prefix = "osu.Game.Rulesets";
From 3c714dc01307216b23250329c5bc3bf0560138fe Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 11:20:06 +0300
Subject: [PATCH 129/901] APICommentsController -> CommentBundle
---
osu.Game/Online/API/Requests/GetCommentsRequest.cs | 2 +-
.../Responses/{APICommentsController.cs => CommentBundle.cs} | 2 +-
osu.Game/Overlays/Comments/CommentsContainer.cs | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
rename osu.Game/Online/API/Requests/Responses/{APICommentsController.cs => CommentBundle.cs} (98%)
diff --git a/osu.Game/Online/API/Requests/GetCommentsRequest.cs b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
index 834a5106a0..7763501860 100644
--- a/osu.Game/Online/API/Requests/GetCommentsRequest.cs
+++ b/osu.Game/Online/API/Requests/GetCommentsRequest.cs
@@ -8,7 +8,7 @@ using osu.Game.Overlays.Comments;
namespace osu.Game.Online.API.Requests
{
- public class GetCommentsRequest : APIRequest
+ public class GetCommentsRequest : APIRequest
{
private readonly long id;
private readonly int page;
diff --git a/osu.Game/Online/API/Requests/Responses/APICommentsController.cs b/osu.Game/Online/API/Requests/Responses/CommentBundle.cs
similarity index 98%
rename from osu.Game/Online/API/Requests/Responses/APICommentsController.cs
rename to osu.Game/Online/API/Requests/Responses/CommentBundle.cs
index ca6062e371..7063581605 100644
--- a/osu.Game/Online/API/Requests/Responses/APICommentsController.cs
+++ b/osu.Game/Online/API/Requests/Responses/CommentBundle.cs
@@ -7,7 +7,7 @@ using System.Collections.Generic;
namespace osu.Game.Online.API.Requests.Responses
{
- public class APICommentsController
+ public class CommentBundle
{
private List comments;
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 49c479f6e5..62f0ce947b 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -139,7 +139,7 @@ namespace osu.Game.Overlays.Comments
api.Queue(request);
}
- private void onSuccess(APICommentsController response, bool initial)
+ private void onSuccess(CommentBundle response, bool initial)
{
loadCancellation = new CancellationTokenSource();
From eb5dad08aa6a8560d544358776c8e6ab3e18e2ea Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 11:25:58 +0300
Subject: [PATCH 130/901] Remove initial filed
---
.../Online/API/Requests/Responses/Comment.cs | 2 +-
.../Overlays/Comments/CommentsContainer.cs | 36 ++++++++++---------
osu.Game/Overlays/Comments/DrawableComment.cs | 2 +-
3 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 9d011c49c1..68a4c28726 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -78,6 +78,6 @@ namespace osu.Game.Online.API.Requests.Responses
return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty));
}
- public int GetDeletedChildrenCount => ChildComments.Select(c => c.IsDeleted).Count(c => c);
+ public int DeletedChildrenCount => ChildComments.Count(c => c.IsDeleted);
}
}
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 62f0ce947b..824d9822be 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -101,7 +101,7 @@ namespace osu.Game.Overlays.Comments
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Margin = new MarginPadding(5),
- Action = () => getComments(false),
+ Action = getComments
}
}
}
@@ -119,27 +119,31 @@ namespace osu.Game.Overlays.Comments
base.LoadComplete();
}
- private void onSortChanged(ValueChangedEvent sort) => getComments();
-
- private void getComments(bool initial = true)
+ private void onSortChanged(ValueChangedEvent sort)
{
- if (initial)
- {
- currentPage = 1;
- loadedTopLevelComments = 0;
- deletedChildrenPlaceholder.DeletedCount.Value = 0;
- moreButton.IsLoading = true;
- content.Clear();
- }
+ clearComments();
+ getComments();
+ }
+ private void getComments()
+ {
request?.Cancel();
loadCancellation?.Cancel();
request = new GetCommentsRequest(type, id, Sort.Value, currentPage++);
- request.Success += response => onSuccess(response, initial);
+ request.Success += response => onSuccess(response);
api.Queue(request);
}
- private void onSuccess(CommentBundle response, bool initial)
+ private void clearComments()
+ {
+ currentPage = 1;
+ loadedTopLevelComments = 0;
+ deletedChildrenPlaceholder.DeletedCount.Value = 0;
+ moreButton.IsLoading = true;
+ content.Clear();
+ }
+
+ private void onSuccess(CommentBundle response)
{
loadCancellation = new CancellationTokenSource();
@@ -163,9 +167,7 @@ namespace osu.Game.Overlays.Comments
{
content.Add(loaded);
- int deletedComments = response.Comments.Select(c => c.IsDeleted && c.IsTopLevel).Count(c => c);
-
- deletedChildrenPlaceholder.DeletedCount.Value = initial ? deletedComments : deletedChildrenPlaceholder.DeletedCount.Value + deletedComments;
+ deletedChildrenPlaceholder.DeletedCount.Value += response.Comments.Count(c => c.IsDeleted && c.IsTopLevel);
if (response.HasMore)
{
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 13c67b9f5b..b22bd6d426 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -180,7 +180,7 @@ namespace osu.Game.Overlays.Comments
}
};
- deletedChildrenPlaceholder.DeletedCount.Value = comment.GetDeletedChildrenCount;
+ deletedChildrenPlaceholder.DeletedCount.Value = comment.DeletedChildrenCount;
if (comment.UserId.HasValue)
username.AddUserLink(comment.User);
From b2885e7b139b8def41fc532181d2d19f4a871fc3 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 11:26:58 +0300
Subject: [PATCH 131/901] Move load() under the ctor
---
osu.Game/Overlays/Comments/CommentsContainer.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 824d9822be..bd1a8562d3 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -113,6 +113,12 @@ namespace osu.Game.Overlays.Comments
});
}
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ background.Colour = colours.Gray2;
+ }
+
protected override void LoadComplete()
{
Sort.BindValueChanged(onSortChanged, true);
@@ -184,12 +190,6 @@ namespace osu.Game.Overlays.Comments
}, loadCancellation.Token);
}
- [BackgroundDependencyLoader]
- private void load()
- {
- background.Colour = colours.Gray2;
- }
-
protected override void Dispose(bool isDisposing)
{
request?.Cancel();
From 213f00556d30b3f4bededf2c57832bb6e5182802 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 11:30:50 +0300
Subject: [PATCH 132/901] Remove onShowDeletedChanged function
---
osu.Game/Overlays/Comments/DrawableComment.cs | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index b22bd6d426..59d3d08122 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -244,17 +244,15 @@ namespace osu.Game.Overlays.Comments
protected override void LoadComplete()
{
- ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
+ ShowDeleted.BindValueChanged(show =>
+ {
+ if (comment.IsDeleted)
+ this.FadeTo(show.NewValue ? 1 : 0);
+ }, true);
childrenExpanded.BindValueChanged(expanded => childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0), true);
base.LoadComplete();
}
- private void onShowDeletedChanged(ValueChangedEvent show)
- {
- if (comment.IsDeleted)
- this.FadeTo(show.NewValue ? 1 : 0);
- }
-
private class ChevronButton : ShowChildrenButton
{
private readonly SpriteIcon icon;
From 96e31b9cca2b62147354b6608c11857280a7cade Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 12:07:01 +0300
Subject: [PATCH 133/901] Add support for deleted comments with message
---
.../Online/API/Requests/Responses/Comment.cs | 8 ++-----
osu.Game/Overlays/Comments/DrawableComment.cs | 23 +++++++++++++------
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/osu.Game/Online/API/Requests/Responses/Comment.cs b/osu.Game/Online/API/Requests/Responses/Comment.cs
index 68a4c28726..29abaa74e5 100644
--- a/osu.Game/Online/API/Requests/Responses/Comment.cs
+++ b/osu.Game/Online/API/Requests/Responses/Comment.cs
@@ -70,13 +70,9 @@ namespace osu.Game.Online.API.Requests.Responses
public bool IsDeleted => DeletedAt.HasValue;
- public string GetMessage()
- {
- if (IsDeleted)
- return @"deleted";
+ public bool HasMessage => !string.IsNullOrEmpty(MessageHtml);
- return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty));
- }
+ public string GetMessage => HasMessage ? WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty)) : string.Empty;
public int DeletedChildrenCount => ChildComments.Count(c => c.IsDeleted);
}
diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs
index 59d3d08122..89abda92cf 100644
--- a/osu.Game/Overlays/Comments/DrawableComment.cs
+++ b/osu.Game/Overlays/Comments/DrawableComment.cs
@@ -198,12 +198,13 @@ namespace osu.Game.Overlays.Comments
});
}
- if (!comment.IsDeleted)
+ if (comment.HasMessage)
{
- var formattedSource = MessageFormatter.FormatText(comment.GetMessage());
+ var formattedSource = MessageFormatter.FormatText(comment.GetMessage);
message.AddLinks(formattedSource.Text, formattedSource.Links);
}
- else
+
+ if (comment.IsDeleted)
{
content.FadeColour(OsuColour.Gray(0.5f));
votePill.Hide();
@@ -297,13 +298,13 @@ namespace osu.Game.Overlays.Comments
private class ParentUsername : FillFlowContainer, IHasTooltip
{
- public string TooltipText => comment.ParentComment?.GetMessage() ?? "";
+ public string TooltipText => getParentMessage();
- private readonly Comment comment;
+ private readonly Comment parentComment;
public ParentUsername(Comment comment)
{
- this.comment = comment;
+ parentComment = comment.ParentComment;
AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal;
@@ -319,10 +320,18 @@ namespace osu.Game.Overlays.Comments
new SpriteText
{
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
- Text = comment.ParentComment?.User?.Username ?? comment.ParentComment?.LegacyName
+ Text = parentComment?.User?.Username ?? parentComment?.LegacyName
}
};
}
+
+ private string getParentMessage()
+ {
+ if (parentComment == null)
+ return string.Empty;
+
+ return parentComment.HasMessage ? parentComment.GetMessage : parentComment.IsDeleted ? @"deleted" : string.Empty;
+ }
}
private class VotePill : CircularContainer
From d321794ef5b0fefbb2330a3f9e35ef42457e0299 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 12:26:16 +0300
Subject: [PATCH 134/901] Make loadedTopLevelComments a local filed
---
osu.Game/Overlays/Comments/CommentsContainer.cs | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index bd1a8562d3..6ac31b258f 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -12,6 +12,7 @@ using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using System.Threading;
using System.Linq;
+using osu.Framework.Extensions.IEnumerableExtensions;
namespace osu.Game.Overlays.Comments
{
@@ -32,7 +33,6 @@ namespace osu.Game.Overlays.Comments
private GetCommentsRequest request;
private CancellationTokenSource loadCancellation;
private int currentPage;
- private int loadedTopLevelComments;
private readonly Box background;
private readonly FillFlowContainer content;
@@ -143,7 +143,6 @@ namespace osu.Game.Overlays.Comments
private void clearComments()
{
currentPage = 1;
- loadedTopLevelComments = 0;
deletedChildrenPlaceholder.DeletedCount.Value = 0;
moreButton.IsLoading = true;
content.Clear();
@@ -177,11 +176,9 @@ namespace osu.Game.Overlays.Comments
if (response.HasMore)
{
- response.Comments.ForEach(comment =>
- {
- if (comment.IsTopLevel)
- loadedTopLevelComments++;
- });
+ int loadedTopLevelComments = 0;
+ content.Children.OfType().ForEach(p => loadedTopLevelComments += p.Children.OfType().Count());
+
moreButton.Current.Value = response.TopLevelCount - loadedTopLevelComments;
moreButton.IsLoading = false;
}
From 7ba15df0c07f193016e3e4f0a71c00ccd7b99c15 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 12:27:32 +0300
Subject: [PATCH 135/901] Convert to method group
---
osu.Game/Overlays/Comments/CommentsContainer.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs
index 6ac31b258f..abc1b7233d 100644
--- a/osu.Game/Overlays/Comments/CommentsContainer.cs
+++ b/osu.Game/Overlays/Comments/CommentsContainer.cs
@@ -136,7 +136,7 @@ namespace osu.Game.Overlays.Comments
request?.Cancel();
loadCancellation?.Cancel();
request = new GetCommentsRequest(type, id, Sort.Value, currentPage++);
- request.Success += response => onSuccess(response);
+ request.Success += onSuccess;
api.Queue(request);
}
From 2543de22bd4f2bf5c8fe95f46944419312cb9361 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Tue, 15 Oct 2019 12:47:35 +0300
Subject: [PATCH 136/901] Simplify DeletedChildrenPlaceholder behavior
---
.../Comments/DeletedChildrenPlaceholder.cs | 27 +++++++------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs b/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs
index 21cf01f993..e849691597 100644
--- a/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs
+++ b/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs
@@ -16,8 +16,6 @@ namespace osu.Game.Overlays.Comments
public readonly BindableBool ShowDeleted = new BindableBool();
public readonly BindableInt DeletedCount = new BindableInt();
- private bool canBeShown;
-
private readonly SpriteText countText;
public DeletedChildrenPlaceholder()
@@ -42,29 +40,22 @@ namespace osu.Game.Overlays.Comments
protected override void LoadComplete()
{
- DeletedCount.BindValueChanged(onCountChanged, true);
- ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
+ DeletedCount.BindValueChanged(_ => updateDisplay(), true);
+ ShowDeleted.BindValueChanged(_ => updateDisplay(), true);
base.LoadComplete();
}
- private void onShowDeletedChanged(ValueChangedEvent showDeleted)
+ private void updateDisplay()
{
- if (canBeShown)
- this.FadeTo(showDeleted.NewValue ? 0 : 1);
- }
-
- private void onCountChanged(ValueChangedEvent count)
- {
- canBeShown = count.NewValue != 0;
-
- if (!canBeShown)
+ if (DeletedCount.Value != 0)
+ {
+ countText.Text = @"deleted comment".ToQuantity(DeletedCount.Value);
+ this.FadeTo(ShowDeleted.Value ? 0 : 1);
+ }
+ else
{
Hide();
- return;
}
-
- countText.Text = @"deleted comment".ToQuantity(count.NewValue);
- Show();
}
}
}
From 8c671d7fde49cd038378105e029be1fa37113c79 Mon Sep 17 00:00:00 2001
From: HoLLy
Date: Tue, 15 Oct 2019 20:12:08 +0200
Subject: [PATCH 137/901] Rename cursorScale and calculatedCursorScale
---
.../UI/Cursor/OsuCursorContainer.cs | 20 +++++++++----------
osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 2 +-
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
index 8ea11d0a4b..52e2e493d5 100644
--- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
+++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs
@@ -29,9 +29,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
private readonly Drawable cursorTrail;
- public IBindable CalculatedCursorScale => calculatedCursorScale;
- private Bindable calculatedCursorScale;
+ public IBindable CursorScale => cursorScale;
private Bindable cursorScale;
+ private Bindable userCursorScale;
private Bindable autoCursorScale;
private readonly IBindable beatmap = new Bindable();
@@ -52,21 +52,21 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
this.beatmap.BindTo(beatmap);
this.beatmap.ValueChanged += _ => calculateScale();
- cursorScale = config.GetBindable(OsuSetting.GameplayCursorSize);
- cursorScale.ValueChanged += _ => calculateScale();
+ userCursorScale = config.GetBindable(OsuSetting.GameplayCursorSize);
+ userCursorScale.ValueChanged += _ => calculateScale();
autoCursorScale = config.GetBindable(OsuSetting.AutoCursorSize);
autoCursorScale.ValueChanged += _ => calculateScale();
- calculatedCursorScale = new Bindable();
- calculatedCursorScale.ValueChanged += e => ActiveCursor.Scale = cursorTrail.Scale = new Vector2(e.NewValue);
+ cursorScale = new Bindable();
+ cursorScale.ValueChanged += e => ActiveCursor.Scale = cursorTrail.Scale = new Vector2(e.NewValue);
calculateScale();
}
private void calculateScale()
{
- float scale = cursorScale.Value;
+ float scale = userCursorScale.Value;
if (autoCursorScale.Value && beatmap.Value != null)
{
@@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
scale *= 1f - 0.7f * (1f + beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY;
}
- calculatedCursorScale.Value = scale;
+ cursorScale.Value = scale;
}
protected override void LoadComplete()
@@ -130,13 +130,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
protected override void PopIn()
{
fadeContainer.FadeTo(1, 300, Easing.OutQuint);
- ActiveCursor.ScaleTo(calculatedCursorScale.Value, 400, Easing.OutQuint);
+ ActiveCursor.ScaleTo(cursorScale.Value, 400, Easing.OutQuint);
}
protected override void PopOut()
{
fadeContainer.FadeTo(0.05f, 450, Easing.OutQuint);
- ActiveCursor.ScaleTo(calculatedCursorScale.Value * 0.8f, 450, Easing.OutQuint);
+ ActiveCursor.ScaleTo(cursorScale.Value * 0.8f, 450, Easing.OutQuint);
}
private class DefaultCursorTrail : CursorTrail
diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
index 1ee2a04a3b..64821ac24f 100644
--- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
+++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
@@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.UI
{
Add(localCursorContainer = new OsuCursorContainer());
- localCursorContainer.CalculatedCursorScale.BindValueChanged(scale =>
+ localCursorContainer.CursorScale.BindValueChanged(scale =>
{
clickToResumeCursor.CursorScale = scale.NewValue;
clickToResumeCursor.Scale = new Vector2(scale.NewValue);
From 60133ba0c3fa62ef7f7cc6f8f14ea47f886b2015 Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Tue, 15 Oct 2019 23:33:50 +0300
Subject: [PATCH 138/901] Propagate BeatmapSetInfo to tab items with bindable
---
.../BeatmapSet/BeatmapRulesetSelector.cs | 22 +++++++---------
.../BeatmapSet/BeatmapRulesetTabItem.cs | 26 +++++++++----------
2 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
index bfb188a83b..a0bedc848e 100644
--- a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
+++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
+using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
@@ -13,23 +14,17 @@ namespace osu.Game.Overlays.BeatmapSet
{
public class BeatmapRulesetSelector : RulesetSelector
{
- private BeatmapSetInfo beatmapSet;
+ private readonly Bindable beatmapSet = new Bindable();
public BeatmapSetInfo BeatmapSet
{
- get => beatmapSet;
+ get => beatmapSet.Value;
set
{
- if (value == beatmapSet)
- return;
+ // propagate value to tab items first to enable only available rulesets.
+ beatmapSet.Value = value;
- beatmapSet = value;
-
- foreach (var tab in TabContainer.TabItems.OfType())
- tab.SetBeatmaps(beatmapSet?.Beatmaps.FindAll(b => b.Ruleset.Equals(tab.Value)));
-
- var firstRuleset = beatmapSet?.Beatmaps.OrderBy(b => b.Ruleset.ID).FirstOrDefault()?.Ruleset;
- SelectTab(TabContainer.TabItems.FirstOrDefault(t => t.Value.Equals(firstRuleset)));
+ SelectTab(TabContainer.TabItems.FirstOrDefault(t => t.Enabled.Value));
}
}
@@ -38,7 +33,10 @@ namespace osu.Game.Overlays.BeatmapSet
AutoSizeAxes = Axes.Both;
}
- protected override TabItem CreateTabItem(RulesetInfo value) => new BeatmapRulesetTabItem(value);
+ protected override TabItem CreateTabItem(RulesetInfo value) => new BeatmapRulesetTabItem(value)
+ {
+ BeatmapSet = { BindTarget = beatmapSet }
+ };
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs
index 19c9af13d5..5227bec92a 100644
--- a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs
+++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
+using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@@ -15,8 +16,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osuTK;
using osuTK.Graphics;
-using System.Collections.Generic;
-using System.Diagnostics;
+using System.Linq;
namespace osu.Game.Overlays.BeatmapSet
{
@@ -25,6 +25,8 @@ namespace osu.Game.Overlays.BeatmapSet
private readonly OsuSpriteText name, count;
private readonly Box bar;
+ public readonly Bindable BeatmapSet = new Bindable();
+
public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree;
public BeatmapRulesetTabItem(RulesetInfo value)
@@ -90,6 +92,15 @@ namespace osu.Game.Overlays.BeatmapSet
new HoverClickSounds(),
};
+ BeatmapSet.BindValueChanged(setInfo =>
+ {
+ var beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.Equals(Value)) ?? 0;
+ count.Text = beatmapsCount.ToString();
+
+ count.Alpha = beatmapsCount > 0 ? 1f : 0f;
+ Enabled.Value = beatmapsCount > 0;
+ }, true);
+
Enabled.BindValueChanged(v => nameContainer.Alpha = v.NewValue ? 1f : 0.5f, true);
}
@@ -106,17 +117,6 @@ namespace osu.Game.Overlays.BeatmapSet
updateState();
}
- public void SetBeatmaps(List beatmaps)
- {
- Trace.Assert(beatmaps?.TrueForAll(b => b.Ruleset.Equals(Value)) ?? true, "A beatmap has a ruleset not of this tab value");
-
- count.Text = beatmaps?.Count.ToString();
-
- var hasBeatmaps = (beatmaps?.Count ?? 0) > 0;
- count.Alpha = hasBeatmaps ? 1f : 0f;
- Enabled.Value = hasBeatmaps;
- }
-
private void updateState()
{
var isHoveredOrActive = IsHovered || Active.Value;
From 14c72f85fa56387b3932908c616c0de68e3aee36 Mon Sep 17 00:00:00 2001
From: iiSaLMaN
Date: Tue, 15 Oct 2019 23:40:48 +0300
Subject: [PATCH 139/901] Fix incorrect beatmap set info equality check on
non-online set info
---
osu.Game/Beatmaps/BeatmapSetInfo.cs | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/osu.Game/Beatmaps/BeatmapSetInfo.cs b/osu.Game/Beatmaps/BeatmapSetInfo.cs
index 03bc7c7312..90346a8c8b 100644
--- a/osu.Game/Beatmaps/BeatmapSetInfo.cs
+++ b/osu.Game/Beatmaps/BeatmapSetInfo.cs
@@ -63,6 +63,12 @@ namespace osu.Game.Beatmaps
public bool Protected { get; set; }
- public bool Equals(BeatmapSetInfo other) => OnlineBeatmapSetID == other?.OnlineBeatmapSetID;
+ public bool Equals(BeatmapSetInfo other)
+ {
+ if (!OnlineBeatmapSetID.HasValue || !(other?.OnlineBeatmapSetID.HasValue ?? false))
+ return ReferenceEquals(this, other);
+
+ return OnlineBeatmapSetID == other.OnlineBeatmapSetID;
+ }
}
}
From 13e11992296cbacadebe87ae239f84f201739f41 Mon Sep 17 00:00:00 2001
From: HoLLy
Date: Tue, 15 Oct 2019 22:44:04 +0200
Subject: [PATCH 140/901] Move click to resume cursor scaling responsibility to
container
---
osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 25 ++++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
index 64821ac24f..908ad1ce49 100644
--- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
+++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs
@@ -17,6 +17,7 @@ namespace osu.Game.Rulesets.Osu.UI
{
public class OsuResumeOverlay : ResumeOverlay
{
+ private Container cursorScaleContainer;
private OsuClickToResumeCursor clickToResumeCursor;
private OsuCursorContainer localCursorContainer;
@@ -28,23 +29,24 @@ namespace osu.Game.Rulesets.Osu.UI
[BackgroundDependencyLoader]
private void load()
{
- Add(clickToResumeCursor = new OsuClickToResumeCursor { ResumeRequested = Resume });
+ Add(cursorScaleContainer = new Container
+ {
+ RelativePositionAxes = Axes.Both,
+ Child = clickToResumeCursor = new OsuClickToResumeCursor { ResumeRequested = Resume }
+ });
}
public override void Show()
{
base.Show();
- clickToResumeCursor.ShowAt(GameplayCursor.ActiveCursor.Position);
+ cursorScaleContainer.MoveTo(GameplayCursor.ActiveCursor.Position);
+ clickToResumeCursor.Appear();
if (localCursorContainer == null)
{
Add(localCursorContainer = new OsuCursorContainer());
- localCursorContainer.CursorScale.BindValueChanged(scale =>
- {
- clickToResumeCursor.CursorScale = scale.NewValue;
- clickToResumeCursor.Scale = new Vector2(scale.NewValue);
- }, true);
+ localCursorContainer.CursorScale.BindValueChanged(scale => cursorScaleContainer.Scale = new Vector2(scale.NewValue), true);
}
}
@@ -64,8 +66,6 @@ namespace osu.Game.Rulesets.Osu.UI
public Action ResumeRequested;
- public float CursorScale;
-
public OsuClickToResumeCursor()
{
RelativePositionAxes = Axes.Both;
@@ -91,7 +91,7 @@ namespace osu.Game.Rulesets.Osu.UI
case OsuAction.RightButton:
if (!IsHovered) return false;
- this.ScaleTo(2 * CursorScale, TRANSITION_TIME, Easing.OutQuint);
+ this.ScaleTo(2, TRANSITION_TIME, Easing.OutQuint);
ResumeRequested?.Invoke();
return true;
@@ -102,11 +102,10 @@ namespace osu.Game.Rulesets.Osu.UI
public bool OnReleased(OsuAction action) => false;
- public void ShowAt(Vector2 activeCursorPosition) => Schedule(() =>
+ public void Appear() => Schedule(() =>
{
updateColour();
- this.MoveTo(activeCursorPosition);
- this.ScaleTo(4 * CursorScale).Then().ScaleTo(CursorScale, 1000, Easing.OutQuint);
+ this.ScaleTo(4).Then().ScaleTo(1, 1000, Easing.OutQuint);
});
private void updateColour()
From 649951198e800e23b46292f389f1271d899086f6 Mon Sep 17 00:00:00 2001
From: Joehu
Date: Tue, 15 Oct 2019 14:47:48 -0700
Subject: [PATCH 141/901] Make most textbox carets movable
---
osu.Game/Graphics/UserInterface/SearchTextBox.cs | 2 --
osu.Game/Screens/Select/FilterControl.cs | 9 +++++++--
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/osu.Game/Graphics/UserInterface/SearchTextBox.cs b/osu.Game/Graphics/UserInterface/SearchTextBox.cs
index c3efe2ed45..e2b0e1b425 100644
--- a/osu.Game/Graphics/UserInterface/SearchTextBox.cs
+++ b/osu.Game/Graphics/UserInterface/SearchTextBox.cs
@@ -14,8 +14,6 @@ namespace osu.Game.Graphics.UserInterface
{
protected virtual bool AllowCommit => false;
- public override bool HandleLeftRightArrows => false;
-
public SearchTextBox()
{
Height = 35;
diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs
index 8755c3fda6..2c878f8d90 100644
--- a/osu.Game/Screens/Select/FilterControl.cs
+++ b/osu.Game/Screens/Select/FilterControl.cs
@@ -49,7 +49,7 @@ namespace osu.Game.Screens.Select
return criteria;
}
- private readonly SearchTextBox searchTextBox;
+ private readonly SongSelectTextBox searchTextBox;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
base.ReceivePositionalInputAt(screenSpacePos) || groupTabs.ReceivePositionalInputAt(screenSpacePos) || sortTabs.ReceivePositionalInputAt(screenSpacePos);
@@ -73,7 +73,7 @@ namespace osu.Game.Screens.Select
Origin = Anchor.TopRight,
Children = new Drawable[]
{
- searchTextBox = new SearchTextBox { RelativeSizeAxes = Axes.X },
+ searchTextBox = new SongSelectTextBox { RelativeSizeAxes = Axes.X },
new Box
{
RelativeSizeAxes = Axes.X,
@@ -170,5 +170,10 @@ namespace osu.Game.Screens.Select
}
private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria());
+
+ private class SongSelectTextBox : SearchTextBox
+ {
+ public override bool HandleLeftRightArrows => false;
+ }
}
}
From 350d139cbf22fef749454d867b3b716f8e947bf4 Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Wed, 16 Oct 2019 15:54:00 +0900
Subject: [PATCH 142/901] Make chevron icon colour protected
---
osu.Game/Graphics/UserInterface/ShowMoreButton.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/osu.Game/Graphics/UserInterface/ShowMoreButton.cs b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
index 854b7abce1..5296b9dd7f 100644
--- a/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
+++ b/osu.Game/Graphics/UserInterface/ShowMoreButton.cs
@@ -20,7 +20,7 @@ namespace osu.Game.Graphics.UserInterface
private Color4 chevronIconColour;
- public Color4 ChevronIconColour
+ protected Color4 ChevronIconColour
{
get => chevronIconColour;
set => chevronIconColour = leftChevron.Colour = rightChevron.Colour = value;
From 5ac5e34f8585fc0910ef4d6cf81307ca90e51b47 Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Wed, 16 Oct 2019 19:32:45 +0900
Subject: [PATCH 143/901] Use a cleaner distance function
---
.../Edit/Compose/Components/CircularBeatSnapGrid.cs | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
index 8492771808..bf363aeb37 100644
--- a/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
@@ -18,13 +18,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override void CreateContent(Vector2 centrePosition)
{
- float maxDistance = Math.Max(
- Vector2.Distance(centrePosition, Vector2.Zero),
- Math.Max(
- Vector2.Distance(centrePosition, new Vector2(DrawWidth, 0)),
- Math.Max(
- Vector2.Distance(centrePosition, new Vector2(0, DrawHeight)),
- Vector2.Distance(centrePosition, DrawSize))));
+ float dx = Math.Max(centrePosition.X, DrawWidth - centrePosition.X);
+ float dy = Math.Max(centrePosition.Y, DrawHeight - centrePosition.Y);
+ float maxDistance = new Vector2(dx, dy).Length;
int requiredCircles = (int)(maxDistance / DistanceSpacing);
From 2d4b7dc361ca061fd74cef1654ab86875c58d518 Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Wed, 16 Oct 2019 19:33:18 +0900
Subject: [PATCH 144/901] Remove redundant code
---
.../Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs | 4 ----
1 file changed, 4 deletions(-)
diff --git a/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
index bf363aeb37..09679f0553 100644
--- a/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
@@ -48,11 +48,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
float radius = DistanceSpacing;
int radialCount = Math.Max(1, (int)Math.Round(distance / radius));
- if (radialCount <= 0)
- return position;
-
Vector2 normalisedDirection = direction * new Vector2(1f / distance);
-
return CentrePosition + normalisedDirection * radialCount * radius;
}
}
From b6b8098b989383b0402e2efe48476048f9b05f3f Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Wed, 16 Oct 2019 19:44:53 +0900
Subject: [PATCH 145/901] Add an arbitrary offset to prevent div-by-0
---
.../Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
index 09679f0553..5e378f8393 100644
--- a/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/CircularBeatSnapGrid.cs
@@ -43,6 +43,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
public override Vector2 GetSnapPosition(Vector2 position)
{
Vector2 direction = position - CentrePosition;
+
+ if (direction == Vector2.Zero)
+ direction = new Vector2(0.001f, 0.001f);
+
float distance = direction.Length;
float radius = DistanceSpacing;
From 2dac3a6efe89934faa8cc354e5581a83bd182bd3 Mon Sep 17 00:00:00 2001
From: Andrei Zavatski
Date: Wed, 16 Oct 2019 13:58:29 +0300
Subject: [PATCH 146/901] Handle hitting the maximum allowed number of
favourited beatmaps
---
.../BeatmapSet/Buttons/FavouriteButton.cs | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs
index fcea20ef11..e2bc1ee008 100644
--- a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs
+++ b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs
@@ -11,6 +11,7 @@ using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
+using osu.Game.Overlays.Notifications;
using osuTK;
namespace osu.Game.Overlays.BeatmapSet.Buttons
@@ -26,8 +27,8 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
public string TooltipText => (favourited.Value ? "Unfavourite" : "Favourite") + " this beatmapset";
- [BackgroundDependencyLoader]
- private void load(IAPIProvider api)
+ [BackgroundDependencyLoader(true)]
+ private void load(IAPIProvider api, NotificationOverlay notifications)
{
SpriteIcon icon;
AddRange(new Drawable[]
@@ -68,6 +69,18 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
request?.Cancel();
request = new PostBeatmapFavouriteRequest(BeatmapSet.Value?.OnlineBeatmapSetID ?? 0, favourited.Value ? BeatmapFavouriteAction.UnFavourite : BeatmapFavouriteAction.Favourite);
request.Success += () => favourited.Value = !favourited.Value;
+ request.Failure += exception =>
+ {
+ if (exception.Message == "UnprocessableEntity")
+ {
+ notifications.Post(new SimpleNotification
+ {
+ Text = @"You have too many favourited beatmaps! Please unfavourite some before trying again.",
+ Icon = FontAwesome.Solid.Times,
+ });
+ loading.Hide();
+ }
+ };
api.Queue(request);
};
}
From 79b2c7b480f34c2d122f69aed9a69ae413bf7108 Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Wed, 16 Oct 2019 20:04:15 +0900
Subject: [PATCH 147/901] Make BeginPlacement() set the hitobject start time
---
.../Edit/Blueprints/ManiaPlacementBlueprint.cs | 4 +---
.../Edit/Blueprints/HitCircles/HitCirclePlacementBlueprint.cs | 1 -
.../Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs | 2 --
.../Edit/Blueprints/Spinners/SpinnerPlacementBlueprint.cs | 2 --
osu.Game/Rulesets/Edit/PlacementBlueprint.cs | 4 +++-
5 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs
index 3142f22fcd..b28d8bb0e6 100644
--- a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs
+++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs
@@ -49,10 +49,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
if (Column == null)
return base.OnMouseDown(e);
- HitObject.StartTime = TimeAt(e.ScreenSpaceMousePosition);
HitObject.Column = Column.Index;
-
- BeginPlacement();
+ BeginPlacement(TimeAt(e.ScreenSpaceMousePosition));
return true;
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCirclePlacementBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCirclePlacementBlueprint.cs
index 6c08990ad6..bb47c7e464 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCirclePlacementBlueprint.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCirclePlacementBlueprint.cs
@@ -30,7 +30,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
protected override bool OnClick(ClickEvent e)
{
- HitObject.StartTime = EditorClock.CurrentTime;
EndPlacement();
return true;
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs
index fc074ef8af..2fb18bf8ba 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderPlacementBlueprint.cs
@@ -104,8 +104,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
private void beginCurve()
{
BeginPlacement();
-
- HitObject.StartTime = EditorClock.CurrentTime;
setState(PlacementState.Body);
}
diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Spinners/SpinnerPlacementBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Spinners/SpinnerPlacementBlueprint.cs
index 8319f49cbc..5525b8936e 100644
--- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Spinners/SpinnerPlacementBlueprint.cs
+++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Spinners/SpinnerPlacementBlueprint.cs
@@ -41,8 +41,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
}
else
{
- HitObject.StartTime = EditorClock.CurrentTime;
-
isPlacingEnd = true;
piece.FadeTo(1f, 150, Easing.OutQuint);
diff --git a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs
index 290fd8d27d..07283d2245 100644
--- a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs
+++ b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs
@@ -91,8 +91,10 @@ namespace osu.Game.Rulesets.Edit
///
/// Signals that the placement of has started.
///
- protected void BeginPlacement()
+ /// The start time of at the placement point. If null, the current clock time is used.
+ protected void BeginPlacement(double? startTime = null)
{
+ HitObject.StartTime = startTime ?? EditorClock.CurrentTime;
placementHandler.BeginPlacement(HitObject);
PlacementBegun = true;
}
From 4ac2e1c58ee1aab9bbac8cb62dc717a8e03f5d3a Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Wed, 16 Oct 2019 21:41:18 +0900
Subject: [PATCH 148/901] Move load() to below ctor()
---
.../Objects/Drawables/DrawableSlider.cs | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
index 9e8ad9851c..09157d4fdc 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
@@ -94,13 +94,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
}
}
- protected override void UpdateInitialTransforms()
- {
- base.UpdateInitialTransforms();
-
- Body.FadeInFromZero(HitObject.TimeFadeIn);
- }
-
[BackgroundDependencyLoader]
private void load()
{
@@ -129,6 +122,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
}, true);
}
+ protected override void UpdateInitialTransforms()
+ {
+ base.UpdateInitialTransforms();
+
+ Body.FadeInFromZero(HitObject.TimeFadeIn);
+ }
+
public readonly Bindable Tracking = new Bindable();
protected override void Update()
From 8d7453c251b68243ed6a082f815a1d2133e71aa4 Mon Sep 17 00:00:00 2001
From: smoogipoo
Date: Wed, 16 Oct 2019 22:10:50 +0900
Subject: [PATCH 149/901] Rework construction of nested hitobjects
---
.../Objects/Drawables/DrawableSlider.cs | 124 +++++++++++-------
.../Objects/Drawables/DrawableHitObject.cs | 44 +++++--
2 files changed, 111 insertions(+), 57 deletions(-)
diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
index 09157d4fdc..21411259ae 100644
--- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
+++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs
@@ -5,7 +5,6 @@ using osuTK;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
-using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@@ -21,15 +20,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
public class DrawableSlider : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
{
- private readonly Slider slider;
- private readonly List components = new List();
-
- public readonly DrawableHitCircle HeadCircle;
- public readonly DrawableSliderTail TailCircle;
+ public DrawableSliderHead HeadCircle { get; private set; }
+ public DrawableSliderTail TailCircle { get; private set; }
public readonly SnakingSliderBody Body;
public readonly SliderBall Ball;
+ private readonly Container headContainer;
+ private readonly Container tailContainer;
+ private readonly Container tickContainer;
+ private readonly Container repeatContainer;
+
+ private readonly Slider slider;
+
private readonly IBindable positionBindable = new Bindable();
private readonly IBindable