mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:25:11 +08:00
Fix TopLocalRank
hacking around presence to hide on null rank
Fixed this here because that blocks `Schedule` from running, and I don't want to add another override to the `IsPresent` flag.
This commit is contained in:
parent
1220250bb6
commit
727fe76b60
@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
});
|
||||
});
|
||||
|
||||
AddAssert("No rank displayed initially", () => topLocalRank.Rank == null);
|
||||
AddAssert("No rank displayed initially", () => topLocalRank.DisplayedRank == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -76,14 +76,14 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
scoreManager.Import(testScoreInfo);
|
||||
});
|
||||
|
||||
AddUntilStep("B rank displayed", () => topLocalRank.Rank == ScoreRank.B);
|
||||
AddUntilStep("B rank displayed", () => topLocalRank.DisplayedRank == ScoreRank.B);
|
||||
|
||||
AddStep("Delete score", () =>
|
||||
{
|
||||
scoreManager.Delete(testScoreInfo);
|
||||
});
|
||||
|
||||
AddUntilStep("No rank displayed", () => topLocalRank.Rank == null);
|
||||
AddUntilStep("No rank displayed", () => topLocalRank.DisplayedRank == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -101,13 +101,13 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
scoreManager.Import(testScoreInfo);
|
||||
});
|
||||
|
||||
AddUntilStep("Wait for initial display", () => topLocalRank.Rank == ScoreRank.B);
|
||||
AddUntilStep("Wait for initial display", () => topLocalRank.DisplayedRank == ScoreRank.B);
|
||||
|
||||
AddStep("Change ruleset", () => Ruleset.Value = rulesets.GetRuleset("fruits"));
|
||||
AddUntilStep("No rank displayed", () => topLocalRank.Rank == null);
|
||||
AddUntilStep("No rank displayed", () => topLocalRank.DisplayedRank == null);
|
||||
|
||||
AddStep("Change ruleset back", () => Ruleset.Value = rulesets.GetRuleset("osu"));
|
||||
AddUntilStep("B rank displayed", () => topLocalRank.Rank == ScoreRank.B);
|
||||
AddUntilStep("B rank displayed", () => topLocalRank.DisplayedRank == ScoreRank.B);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -125,7 +125,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
scoreManager.Import(testScoreInfo);
|
||||
});
|
||||
|
||||
AddUntilStep("B rank displayed", () => topLocalRank.Rank == ScoreRank.B);
|
||||
AddUntilStep("B rank displayed", () => topLocalRank.DisplayedRank == ScoreRank.B);
|
||||
|
||||
AddStep("Add higher score for current user", () =>
|
||||
{
|
||||
@ -147,7 +147,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
scoreManager.Import(testScoreInfo2);
|
||||
});
|
||||
|
||||
AddUntilStep("S rank displayed", () => topLocalRank.Rank == ScoreRank.S);
|
||||
AddUntilStep("S rank displayed", () => topLocalRank.DisplayedRank == ScoreRank.S);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -166,7 +166,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
scoreManager.Import(testScoreInfo);
|
||||
});
|
||||
|
||||
AddUntilStep("B rank displayed", () => topLocalRank.Rank == ScoreRank.B);
|
||||
AddUntilStep("B rank displayed", () => topLocalRank.DisplayedRank == ScoreRank.B);
|
||||
|
||||
AddStep("Add higher score for current user", () =>
|
||||
{
|
||||
@ -192,7 +192,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
scoreManager.Import(testScoreInfo2);
|
||||
});
|
||||
|
||||
AddUntilStep("S rank displayed", () => topLocalRank.Rank == ScoreRank.S);
|
||||
AddUntilStep("S rank displayed", () => topLocalRank.DisplayedRank == ScoreRank.S);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Online.Leaderboards
|
||||
set => Model = value;
|
||||
}
|
||||
|
||||
public UpdateableRank(ScoreRank? rank)
|
||||
public UpdateableRank(ScoreRank? rank = null)
|
||||
{
|
||||
Rank = rank;
|
||||
}
|
||||
|
@ -5,9 +5,12 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Models;
|
||||
@ -20,7 +23,7 @@ using Realms;
|
||||
|
||||
namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
public class TopLocalRank : UpdateableRank
|
||||
public class TopLocalRank : CompositeDrawable
|
||||
{
|
||||
private readonly BeatmapInfo beatmapInfo;
|
||||
|
||||
@ -34,13 +37,25 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private IDisposable scoreSubscription;
|
||||
private CancellationTokenSource scoreOrderCancellationSource;
|
||||
|
||||
private readonly UpdateableRank updateable;
|
||||
|
||||
public ScoreRank? DisplayedRank => updateable.Rank;
|
||||
|
||||
public TopLocalRank(BeatmapInfo beatmapInfo)
|
||||
: base(null)
|
||||
{
|
||||
this.beatmapInfo = beatmapInfo;
|
||||
|
||||
Size = new Vector2(40, 20);
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
InternalChild = updateable = new UpdateableRank
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(40, 20),
|
||||
Alpha = 0,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -59,19 +74,17 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
.OrderByDescending(s => s.TotalScore),
|
||||
(items, _, _) =>
|
||||
{
|
||||
Rank = items.FirstOrDefault()?.Rank;
|
||||
// Required since presence is changed via IsPresent override
|
||||
Invalidate(Invalidation.Presence);
|
||||
updateable.Rank = items.FirstOrDefault()?.Rank;
|
||||
updateable.Alpha = updateable.Rank != null ? 1 : 0;
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
|
||||
public override bool IsPresent => base.IsPresent && Rank != null;
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
scoreOrderCancellationSource?.Cancel();
|
||||
scoreSubscription?.Dispose();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user