mirror of
https://github.com/ppy/osu.git
synced 2024-12-20 02:12:57 +08:00
commit
af45abb7eb
@ -70,7 +70,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
});
|
||||
|
||||
channelTabControl.OnRequestLeave += channel => channelTabControl.RemoveChannel(channel);
|
||||
channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.NewValue.ToString();
|
||||
channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.NewValue;
|
||||
|
||||
AddStep("Add random private channel", addRandomPrivateChannel);
|
||||
AddAssert("There is only one channels", () => channelTabControl.Items.Count() == 2);
|
||||
|
@ -3,19 +3,18 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.BeatmapSet.Scores;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
@ -30,11 +29,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(ScoreTableRowBackground),
|
||||
};
|
||||
|
||||
private readonly Box background;
|
||||
|
||||
public TestSceneScoresContainer()
|
||||
{
|
||||
ScoresContainer scoresContainer;
|
||||
TestScoresContainer scoresContainer;
|
||||
|
||||
Child = new Container
|
||||
{
|
||||
@ -44,108 +41,137 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Width = 0.8f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box { RelativeSizeAxes = Axes.Both },
|
||||
scoresContainer = new ScoresContainer(),
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
scoresContainer = new TestScoresContainer(),
|
||||
}
|
||||
};
|
||||
|
||||
var scores = new List<ScoreInfo>
|
||||
var allScores = new APILegacyScores
|
||||
{
|
||||
new ScoreInfo
|
||||
Scores = new List<APILegacyScoreInfo>
|
||||
{
|
||||
User = new User
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
Id = 6602580,
|
||||
Username = @"waaiiru",
|
||||
Country = new Country
|
||||
User = new User
|
||||
{
|
||||
FullName = @"Spain",
|
||||
FlagName = @"ES",
|
||||
Id = 6602580,
|
||||
Username = @"waaiiru",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Spain",
|
||||
FlagName = @"ES",
|
||||
},
|
||||
},
|
||||
},
|
||||
Mods = new Mod[]
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModHidden(),
|
||||
new OsuModFlashlight(),
|
||||
new OsuModHardRock(),
|
||||
},
|
||||
Rank = ScoreRank.XH,
|
||||
PP = 200,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234567890,
|
||||
Accuracy = 1,
|
||||
},
|
||||
new ScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 4608074,
|
||||
Username = @"Skycries",
|
||||
Country = new Country
|
||||
Mods = new Mod[]
|
||||
{
|
||||
FullName = @"Brazil",
|
||||
FlagName = @"BR",
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModHidden(),
|
||||
new OsuModFlashlight(),
|
||||
new OsuModHardRock(),
|
||||
},
|
||||
Rank = ScoreRank.XH,
|
||||
PP = 200,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234567890,
|
||||
Accuracy = 1,
|
||||
},
|
||||
Mods = new Mod[]
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModHidden(),
|
||||
new OsuModFlashlight(),
|
||||
},
|
||||
Rank = ScoreRank.S,
|
||||
PP = 190,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234789,
|
||||
Accuracy = 0.9997,
|
||||
},
|
||||
new ScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 1014222,
|
||||
Username = @"eLy",
|
||||
Country = new Country
|
||||
User = new User
|
||||
{
|
||||
FullName = @"Japan",
|
||||
FlagName = @"JP",
|
||||
Id = 4608074,
|
||||
Username = @"Skycries",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Brazil",
|
||||
FlagName = @"BR",
|
||||
},
|
||||
},
|
||||
},
|
||||
Mods = new Mod[]
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModHidden(),
|
||||
},
|
||||
Rank = ScoreRank.B,
|
||||
PP = 180,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 12345678,
|
||||
Accuracy = 0.9854,
|
||||
},
|
||||
new ScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 1541390,
|
||||
Username = @"Toukai",
|
||||
Country = new Country
|
||||
Mods = new Mod[]
|
||||
{
|
||||
FullName = @"Canada",
|
||||
FlagName = @"CA",
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModHidden(),
|
||||
new OsuModFlashlight(),
|
||||
},
|
||||
Rank = ScoreRank.S,
|
||||
PP = 190,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234789,
|
||||
Accuracy = 0.9997,
|
||||
},
|
||||
Mods = new Mod[]
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
User = new User
|
||||
{
|
||||
Id = 1014222,
|
||||
Username = @"eLy",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Japan",
|
||||
FlagName = @"JP",
|
||||
},
|
||||
},
|
||||
Mods = new Mod[]
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModHidden(),
|
||||
},
|
||||
Rank = ScoreRank.B,
|
||||
PP = 180,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 12345678,
|
||||
Accuracy = 0.9854,
|
||||
},
|
||||
Rank = ScoreRank.C,
|
||||
PP = 170,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234567,
|
||||
Accuracy = 0.8765,
|
||||
},
|
||||
new ScoreInfo
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 1541390,
|
||||
Username = @"Toukai",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Canada",
|
||||
FlagName = @"CA",
|
||||
},
|
||||
},
|
||||
Mods = new Mod[]
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
},
|
||||
Rank = ScoreRank.C,
|
||||
PP = 170,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234567,
|
||||
Accuracy = 0.8765,
|
||||
},
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 7151382,
|
||||
Username = @"Mayuri Hana",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Thailand",
|
||||
FlagName = @"TH",
|
||||
},
|
||||
},
|
||||
Rank = ScoreRank.D,
|
||||
PP = 160,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 123456,
|
||||
Accuracy = 0.6543,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var myBestScore = new APILegacyUserTopScoreInfo
|
||||
{
|
||||
Score = new APILegacyScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -163,9 +189,42 @@ namespace osu.Game.Tests.Visual.Online
|
||||
TotalScore = 123456,
|
||||
Accuracy = 0.6543,
|
||||
},
|
||||
Position = 1337,
|
||||
};
|
||||
|
||||
foreach (var s in scores)
|
||||
var oneScore = new APILegacyScores
|
||||
{
|
||||
Scores = new List<APILegacyScoreInfo>
|
||||
{
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 6602580,
|
||||
Username = @"waaiiru",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Spain",
|
||||
FlagName = @"ES",
|
||||
},
|
||||
},
|
||||
Mods = new Mod[]
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModHidden(),
|
||||
new OsuModFlashlight(),
|
||||
new OsuModHardRock(),
|
||||
},
|
||||
Rank = ScoreRank.XH,
|
||||
PP = 200,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234567890,
|
||||
Accuracy = 1,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
foreach (var s in allScores.Scores)
|
||||
{
|
||||
s.Statistics.Add(HitResult.Great, RNG.Next(2000));
|
||||
s.Statistics.Add(HitResult.Good, RNG.Next(2000));
|
||||
@ -173,15 +232,26 @@ namespace osu.Game.Tests.Visual.Online
|
||||
s.Statistics.Add(HitResult.Miss, RNG.Next(2000));
|
||||
}
|
||||
|
||||
AddStep("Load all scores", () => scoresContainer.Scores = scores);
|
||||
AddStep("Load all scores", () =>
|
||||
{
|
||||
allScores.UserScore = null;
|
||||
scoresContainer.Scores = allScores;
|
||||
});
|
||||
AddStep("Load null scores", () => scoresContainer.Scores = null);
|
||||
AddStep("Load only one score", () => scoresContainer.Scores = new[] { scores.First() });
|
||||
AddStep("Load only one score", () => scoresContainer.Scores = oneScore);
|
||||
AddStep("Load scores with my best", () =>
|
||||
{
|
||||
allScores.UserScore = myBestScore;
|
||||
scoresContainer.Scores = allScores;
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private class TestScoresContainer : ScoresContainer
|
||||
{
|
||||
background.Colour = colours.Gray2;
|
||||
public new APILegacyScores Scores
|
||||
{
|
||||
set => base.Scores = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneBackButton : OsuTestScene
|
||||
{
|
||||
private readonly BackButton button;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(TwoLayerButton)
|
||||
@ -23,6 +21,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
public TestSceneBackButton()
|
||||
{
|
||||
BackButton button;
|
||||
|
||||
Child = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
@ -40,11 +40,12 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Action = () => button.Hide(),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
button.Action = () => button.Hide();
|
||||
|
||||
AddStep("show button", () => button.Show());
|
||||
AddStep("hide button", () => button.Hide());
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
},
|
||||
};
|
||||
|
||||
breadcrumbs.Current.ValueChanged += screen => titleText.Text = $"Changed to {screen.NewValue.ToString()}";
|
||||
breadcrumbs.Current.ValueChanged += screen => titleText.Text = $"Changed to {screen.NewValue}";
|
||||
breadcrumbs.Current.TriggerChange();
|
||||
|
||||
waitForCurrent();
|
||||
|
@ -42,6 +42,14 @@ namespace osu.Game.Online.API.Requests
|
||||
score.Beatmap = beatmap;
|
||||
score.Ruleset = ruleset;
|
||||
}
|
||||
|
||||
var userScore = r.UserScore;
|
||||
|
||||
if (userScore != null)
|
||||
{
|
||||
userScore.Score.Beatmap = beatmap;
|
||||
userScore.Score.Ruleset = ruleset;
|
||||
}
|
||||
}
|
||||
|
||||
protected override string Target => $@"beatmaps/{beatmap.OnlineBeatmapID}/scores{createQueryParameters()}";
|
||||
|
@ -72,7 +72,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
StarDifficulty = starDifficulty,
|
||||
OnlineBeatmapID = OnlineBeatmapID,
|
||||
Version = version,
|
||||
Length = TimeSpan.FromSeconds(length).Milliseconds,
|
||||
Length = TimeSpan.FromSeconds(length).TotalMilliseconds,
|
||||
Status = Status,
|
||||
BeatmapSet = set,
|
||||
Metrics = metrics,
|
||||
|
@ -10,5 +10,17 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
[JsonProperty(@"scores")]
|
||||
public List<APILegacyScoreInfo> Scores;
|
||||
|
||||
[JsonProperty(@"userScore")]
|
||||
public APILegacyUserTopScoreInfo UserScore;
|
||||
}
|
||||
|
||||
public class APILegacyUserTopScoreInfo
|
||||
{
|
||||
[JsonProperty(@"position")]
|
||||
public int Position;
|
||||
|
||||
[JsonProperty(@"score")]
|
||||
public APILegacyScoreInfo Score;
|
||||
}
|
||||
}
|
||||
|
@ -203,8 +203,13 @@ namespace osu.Game.Online.Leaderboards
|
||||
|
||||
public void APIStateChanged(IAPIProvider api, APIState state)
|
||||
{
|
||||
if (state == APIState.Online)
|
||||
UpdateScores();
|
||||
switch (state)
|
||||
{
|
||||
case APIState.Online:
|
||||
case APIState.Offline:
|
||||
UpdateScores();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateScores()
|
||||
|
@ -23,10 +23,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
private Color4 backgroundHoveredColour;
|
||||
|
||||
private readonly Box background;
|
||||
private readonly TopScoreUserSection userSection;
|
||||
private readonly TopScoreStatisticsSection statisticsSection;
|
||||
|
||||
public DrawableTopScore()
|
||||
public DrawableTopScore(ScoreInfo score, int position = 1)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
@ -61,16 +59,19 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
userSection = new TopScoreUserSection
|
||||
new TopScoreUserSection
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Score = score,
|
||||
ScorePosition = position,
|
||||
},
|
||||
null,
|
||||
statisticsSection = new TopScoreStatisticsSection
|
||||
new TopScoreStatisticsSection
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Score = score,
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -91,18 +92,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
background.Colour = backgroundIdleColour;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the score to be displayed.
|
||||
/// </summary>
|
||||
public ScoreInfo Score
|
||||
{
|
||||
set
|
||||
{
|
||||
userSection.Score = value;
|
||||
statisticsSection.Score = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
background.FadeColour(backgroundHoveredColour, fade_duration, Easing.OutQuint);
|
||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
Content = null;
|
||||
backgroundFlow.Clear();
|
||||
|
||||
if (value == null || !value.Any())
|
||||
if (value?.Any() != true)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < value.Count; i++)
|
||||
|
@ -5,15 +5,14 @@ using osu.Framework.Allocation;
|
||||
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.UserInterface;
|
||||
using osuTK;
|
||||
using System.Linq;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osuTK;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
{
|
||||
@ -24,18 +23,65 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
|
||||
private readonly Box background;
|
||||
private readonly ScoreTable scoreTable;
|
||||
|
||||
private readonly DrawableTopScore topScore;
|
||||
private readonly FillFlowContainer topScoresContainer;
|
||||
private readonly LoadingAnimation loadingAnimation;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private GetScoresRequest getScoresRequest;
|
||||
|
||||
private BeatmapInfo beatmap;
|
||||
|
||||
public BeatmapInfo Beatmap
|
||||
{
|
||||
get => beatmap;
|
||||
set
|
||||
{
|
||||
if (beatmap == value)
|
||||
return;
|
||||
|
||||
beatmap = value;
|
||||
|
||||
getScores(beatmap);
|
||||
}
|
||||
}
|
||||
|
||||
protected APILegacyScores Scores
|
||||
{
|
||||
set
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
loading = false;
|
||||
|
||||
topScoresContainer.Clear();
|
||||
|
||||
if (value?.Scores.Any() != true)
|
||||
{
|
||||
scoreTable.Scores = null;
|
||||
scoreTable.Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
scoreTable.Scores = value.Scores;
|
||||
scoreTable.Show();
|
||||
|
||||
var topScore = value.Scores.First();
|
||||
var userScore = value.UserScore;
|
||||
|
||||
topScoresContainer.Add(new DrawableTopScore(topScore));
|
||||
|
||||
if (userScore != null && userScore.Score.OnlineScoreID != topScore.OnlineScoreID)
|
||||
topScoresContainer.Add(new DrawableTopScore(userScore.Score, userScore.Position));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ScoresContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
@ -54,7 +100,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
Margin = new MarginPadding { Vertical = spacing },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
topScore = new DrawableTopScore(),
|
||||
topScoresContainer = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
},
|
||||
scoreTable = new ScoreTable
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
@ -65,7 +117,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
loadingAnimation = new LoadingAnimation
|
||||
{
|
||||
Alpha = 0,
|
||||
Margin = new MarginPadding(20)
|
||||
Margin = new MarginPadding(20),
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -74,7 +126,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
background.Colour = colours.Gray2;
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
private bool loading
|
||||
@ -82,62 +133,23 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
set => loadingAnimation.FadeTo(value ? 1 : 0, fade_duration);
|
||||
}
|
||||
|
||||
private GetScoresRequest getScoresRequest;
|
||||
private IReadOnlyList<ScoreInfo> scores;
|
||||
|
||||
public IReadOnlyList<ScoreInfo> Scores
|
||||
{
|
||||
get => scores;
|
||||
set
|
||||
{
|
||||
getScoresRequest?.Cancel();
|
||||
scores = value;
|
||||
|
||||
updateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
private BeatmapInfo beatmap;
|
||||
|
||||
public BeatmapInfo Beatmap
|
||||
{
|
||||
get => beatmap;
|
||||
set
|
||||
{
|
||||
beatmap = value;
|
||||
|
||||
Scores = null;
|
||||
|
||||
if (beatmap?.OnlineBeatmapID.HasValue != true)
|
||||
return;
|
||||
|
||||
loading = true;
|
||||
|
||||
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
||||
getScoresRequest.Success += r => Schedule(() => Scores = r.Scores);
|
||||
api.Queue(getScoresRequest);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
loading = false;
|
||||
|
||||
scoreTable.Scores = scores?.Count > 1 ? scores : new List<ScoreInfo>();
|
||||
scoreTable.FadeTo(scores?.Count > 1 ? 1 : 0);
|
||||
|
||||
if (scores?.Any() == true)
|
||||
{
|
||||
topScore.Score = scores.FirstOrDefault();
|
||||
topScore.Show();
|
||||
}
|
||||
else
|
||||
topScore.Hide();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
private void getScores(BeatmapInfo beatmap)
|
||||
{
|
||||
getScoresRequest?.Cancel();
|
||||
getScoresRequest = null;
|
||||
|
||||
Scores = null;
|
||||
|
||||
if (beatmap?.OnlineBeatmapID.HasValue != true)
|
||||
{
|
||||
loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
||||
getScoresRequest.Success += scores => Scores = scores;
|
||||
api.Queue(getScoresRequest);
|
||||
loading = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,19 +39,28 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
Spacing = new Vector2(10, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
rankText = new OsuSpriteText
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = "#1",
|
||||
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Bold, italics: true)
|
||||
},
|
||||
rank = new UpdateableRank(ScoreRank.D)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(40),
|
||||
FillMode = FillMode.Fit,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
rankText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Bold, italics: true)
|
||||
},
|
||||
rank = new UpdateableRank(ScoreRank.D)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(40),
|
||||
FillMode = FillMode.Fit,
|
||||
},
|
||||
}
|
||||
},
|
||||
avatar = new UpdateableAvatar(hideImmediately: true)
|
||||
{
|
||||
@ -109,6 +118,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
rankText.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
public int ScorePosition
|
||||
{
|
||||
set => rankText.Text = $"#{value}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the score to be displayed.
|
||||
/// </summary>
|
||||
|
@ -21,12 +21,9 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
public class BeatmapSetOverlay : FullscreenOverlay
|
||||
{
|
||||
private const int fade_duration = 300;
|
||||
|
||||
public const float X_PADDING = 40;
|
||||
public const float TOP_PADDING = 25;
|
||||
public const float RIGHT_WIDTH = 275;
|
||||
|
||||
protected readonly Header Header;
|
||||
|
||||
private RulesetStore rulesets;
|
||||
@ -40,7 +37,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
OsuScrollContainer scroll;
|
||||
Info info;
|
||||
ScoresContainer scores;
|
||||
ScoresContainer scoreContainer;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -62,7 +59,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
Header = new Header(),
|
||||
info = new Info(),
|
||||
scores = new ScoresContainer(),
|
||||
scoreContainer = new ScoresContainer(),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -74,7 +71,7 @@ namespace osu.Game.Overlays
|
||||
Header.Picker.Beatmap.ValueChanged += b =>
|
||||
{
|
||||
info.Beatmap = b.NewValue;
|
||||
scores.Beatmap = b.NewValue;
|
||||
scoreContainer.Beatmap = b.NewValue;
|
||||
|
||||
scroll.ScrollToStart();
|
||||
};
|
||||
@ -101,6 +98,7 @@ namespace osu.Game.Overlays
|
||||
public void FetchAndShowBeatmap(int beatmapId)
|
||||
{
|
||||
beatmapSet.Value = null;
|
||||
|
||||
var req = new GetBeatmapSetRequest(beatmapId, BeatmapSetLookupType.BeatmapId);
|
||||
req.Success += res =>
|
||||
{
|
||||
@ -108,15 +106,18 @@ namespace osu.Game.Overlays
|
||||
Header.Picker.Beatmap.Value = Header.BeatmapSet.Value.Beatmaps.First(b => b.OnlineBeatmapID == beatmapId);
|
||||
};
|
||||
API.Queue(req);
|
||||
|
||||
Show();
|
||||
}
|
||||
|
||||
public void FetchAndShowBeatmapSet(int beatmapSetId)
|
||||
{
|
||||
beatmapSet.Value = null;
|
||||
|
||||
var req = new GetBeatmapSetRequest(beatmapSetId);
|
||||
req.Success += res => beatmapSet.Value = res.ToBeatmapSet(rulesets);
|
||||
API.Queue(req);
|
||||
|
||||
Show();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user