1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-12 22:32:57 +08:00

Merge branch 'master' into comments-buttons

This commit is contained in:
Dan Balasescu 2020-07-15 16:42:17 +09:00 committed by GitHub
commit 4a480d8563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 127 additions and 56 deletions

View File

@ -15,6 +15,7 @@ using osu.Game.Rulesets.Catch;
using osu.Framework.Allocation;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Overlays.Rankings;
namespace osu.Game.Tests.Visual.Online
{
@ -105,7 +106,7 @@ namespace osu.Game.Tests.Visual.Online
{
onLoadStarted();
request = new GetSpotlightRankingsRequest(ruleset, spotlight);
request = new GetSpotlightRankingsRequest(ruleset, spotlight, RankingsSortCriteria.All);
((GetSpotlightRankingsRequest)request).Success += rankings => Schedule(() =>
{
var table = new ScoresTable(1, rankings.Users);

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.IO.Network;
using osu.Game.Overlays.Rankings;
using osu.Game.Rulesets;
namespace osu.Game.Online.API.Requests
@ -9,11 +10,13 @@ namespace osu.Game.Online.API.Requests
public class GetSpotlightRankingsRequest : GetRankingsRequest<GetSpotlightRankingsResponse>
{
private readonly int spotlight;
private readonly RankingsSortCriteria sort;
public GetSpotlightRankingsRequest(RulesetInfo ruleset, int spotlight)
public GetSpotlightRankingsRequest(RulesetInfo ruleset, int spotlight, RankingsSortCriteria sort)
: base(ruleset, 1)
{
this.spotlight = spotlight;
this.sort = sort;
}
protected override WebRequest CreateWebRequest()
@ -21,6 +24,7 @@ namespace osu.Game.Online.API.Requests
var req = base.CreateWebRequest();
req.AddParameter("spotlight", spotlight.ToString());
req.AddParameter("filter", sort.ToString().ToLower());
return req;
}

View File

@ -573,7 +573,9 @@ namespace osu.Game
Origin = Anchor.BottomLeft,
Action = () =>
{
if ((ScreenStack.CurrentScreen as IOsuScreen)?.AllowBackButton == true)
var currentScreen = ScreenStack.CurrentScreen as IOsuScreen;
if (currentScreen?.AllowBackButton == true && !currentScreen.OnBackButton())
ScreenStack.Exit();
}
},

View File

@ -19,6 +19,7 @@ using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Overlays.Mods.Sections;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens;
@ -403,6 +404,8 @@ namespace osu.Game.Overlays.Mods
return base.OnKeyDown(e);
}
public override bool OnPressed(GlobalAction action) => false; // handled by back button
private void availableModsChanged(ValueChangedEvent<Dictionary<ModType, IReadOnlyList<Mod>>> mods)
{
if (mods.NewValue == null) return;

View File

@ -22,10 +22,8 @@ namespace osu.Game.Overlays.Rankings
{
private const int duration = 300;
private readonly Box background;
private readonly SpotlightsDropdown dropdown;
private readonly BindableWithCurrent<APISpotlight> current = new BindableWithCurrent<APISpotlight>();
public readonly Bindable<RankingsSortCriteria> Sort = new Bindable<RankingsSortCriteria>();
public Bindable<APISpotlight> Current
{
@ -41,19 +39,22 @@ namespace osu.Game.Overlays.Rankings
protected override bool StartHidden => true;
private readonly Box background;
private readonly Container content;
private readonly SpotlightsDropdown dropdown;
private readonly InfoColumn startDateColumn;
private readonly InfoColumn endDateColumn;
private readonly InfoColumn mapCountColumn;
private readonly InfoColumn participantsColumn;
private readonly Container content;
public SpotlightSelector()
{
RelativeSizeAxes = Axes.X;
Height = 100;
AutoSizeAxes = Axes.Y;
Add(content = new Container
{
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
background = new Box
@ -62,31 +63,55 @@ namespace osu.Game.Overlays.Rankings
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 },
Children = new Drawable[]
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN },
Child = new FillFlowContainer
{
dropdown = new SpotlightsDropdown
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Current = Current,
Depth = -float.MaxValue
},
new FillFlowContainer
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(15, 0),
Children = new Drawable[]
new Container
{
startDateColumn = new InfoColumn(@"Start Date"),
endDateColumn = new InfoColumn(@"End Date"),
mapCountColumn = new InfoColumn(@"Map Count"),
participantsColumn = new InfoColumn(@"Participants")
Margin = new MarginPadding { Vertical = 20 },
RelativeSizeAxes = Axes.X,
Height = 40,
Depth = -float.MaxValue,
Child = dropdown = new SpotlightsDropdown
{
RelativeSizeAxes = Axes.X,
Current = Current
}
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10, 0),
Margin = new MarginPadding { Bottom = 5 },
Children = new Drawable[]
{
startDateColumn = new InfoColumn(@"Start Date"),
endDateColumn = new InfoColumn(@"End Date"),
mapCountColumn = new InfoColumn(@"Map Count"),
participantsColumn = new InfoColumn(@"Participants")
}
},
new RankingsSortTabControl
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Current = Sort
}
}
}
}
}
@ -128,12 +153,13 @@ namespace osu.Game.Overlays.Rankings
{
AutoSizeAxes = Axes.Both;
Direction = FillDirection.Vertical;
Margin = new MarginPadding { Vertical = 10 };
Children = new Drawable[]
{
new OsuSpriteText
{
Text = name,
Font = OsuFont.GetFont(size: 10),
Font = OsuFont.GetFont(size: 10, weight: FontWeight.Regular),
},
new Container
{
@ -143,7 +169,7 @@ namespace osu.Game.Overlays.Rankings
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Light),
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Light),
}
}
};

View File

@ -24,6 +24,7 @@ namespace osu.Game.Overlays.Rankings
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
private readonly Bindable<APISpotlight> selectedSpotlight = new Bindable<APISpotlight>();
private readonly Bindable<RankingsSortCriteria> sort = new Bindable<RankingsSortCriteria>();
[Resolved]
private IAPIProvider api { get; set; }
@ -72,6 +73,8 @@ namespace osu.Game.Overlays.Rankings
}
}
};
sort.BindTo(selector.Sort);
}
protected override void LoadComplete()
@ -80,7 +83,8 @@ namespace osu.Game.Overlays.Rankings
selector.Show();
selectedSpotlight.BindValueChanged(onSpotlightChanged);
selectedSpotlight.BindValueChanged(_ => onSpotlightChanged());
sort.BindValueChanged(_ => onSpotlightChanged());
Ruleset.BindValueChanged(onRulesetChanged);
getSpotlights();
@ -101,14 +105,14 @@ namespace osu.Game.Overlays.Rankings
selectedSpotlight.TriggerChange();
}
private void onSpotlightChanged(ValueChangedEvent<APISpotlight> spotlight)
private void onSpotlightChanged()
{
loading.Show();
cancellationToken?.Cancel();
getRankingsRequest?.Cancel();
getRankingsRequest = new GetSpotlightRankingsRequest(Ruleset.Value, spotlight.NewValue.Id);
getRankingsRequest = new GetSpotlightRankingsRequest(Ruleset.Value, selectedSpotlight.Value.Id, sort.Value);
getRankingsRequest.Success += onSuccess;
api.Queue(getRankingsRequest);
}

View File

@ -56,5 +56,14 @@ namespace osu.Game.Screens
/// Whether mod rate adjustments are allowed to be applied.
/// </summary>
bool AllowRateAdjustments { get; }
/// <summary>
/// Invoked when the back button has been pressed to close any overlays before exiting this <see cref="IOsuScreen"/>.
/// </summary>
/// <remarks>
/// Return <c>true</c> to block this <see cref="IOsuScreen"/> from being exited after closing an overlay.
/// Return <c>false</c> if this <see cref="IOsuScreen"/> should continue exiting.
/// </remarks>
bool OnBackButton();
}
}

View File

@ -250,12 +250,6 @@ namespace osu.Game.Screens.Multi
{
roomManager.PartRoom();
if (screenStack.CurrentScreen != null && !(screenStack.CurrentScreen is LoungeSubScreen))
{
screenStack.Exit();
return true;
}
waves.Hide();
this.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut();
@ -269,6 +263,20 @@ namespace osu.Game.Screens.Multi
return false;
}
public override bool OnBackButton()
{
if ((screenStack.CurrentScreen as IMultiplayerSubScreen)?.OnBackButton() == true)
return true;
if (screenStack.CurrentScreen != null && !(screenStack.CurrentScreen is LoungeSubScreen))
{
screenStack.Exit();
return true;
}
return false;
}
protected override void LogoExiting(OsuLogo logo)
{
base.LogoExiting(logo);

View File

@ -258,5 +258,7 @@ namespace osu.Game.Screens
/// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause.
/// </summary>
protected virtual BackgroundScreen CreateBackground() => null;
public virtual bool OnBackButton() => false;
}
}

View File

@ -77,11 +77,10 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
Origin = Anchor.Centre,
BlurSigma = new Vector2(35),
BypassAutoSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(200),
CacheDrawnFrameBuffer = true,
Blending = BlendingParameters.Additive,
Alpha = 0,
Size = new Vector2(2f), // increase buffer size to allow for scale
Scale = new Vector2(1.8f),
Children = new[]
{
@ -122,15 +121,18 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
}
flash.Colour = OsuColour.ForRank(rank);
flash.FadeIn().Then().FadeOut(1200, Easing.OutQuint);
if (rank >= ScoreRank.S)
rankText.ScaleTo(1.05f).ScaleTo(1, 3000, Easing.OutQuint);
if (rank >= ScoreRank.X)
{
flash.FadeIn().Then().FadeOut(3000);
superFlash.FadeIn().Then().FadeOut(800, Easing.OutQuint);
flash.FadeOutFromOne(3000);
superFlash.FadeOutFromOne(800, Easing.OutQuint);
}
else
{
flash.FadeOutFromOne(1200, Easing.OutQuint);
}
}
}

View File

@ -194,6 +194,13 @@ namespace osu.Game.Screens.Ranking
}
public override bool OnExiting(IScreen next)
{
Background.FadeTo(1, 250);
return base.OnExiting(next);
}
public override bool OnBackButton()
{
if (statisticsPanel.State.Value == Visibility.Visible)
{
@ -201,9 +208,7 @@ namespace osu.Game.Screens.Ranking
return true;
}
Background.FadeTo(1, 250);
return base.OnExiting(next);
return false;
}
private void addScore(ScoreInfo score)

View File

@ -599,12 +599,6 @@ namespace osu.Game.Screens.Select
public override bool OnExiting(IScreen next)
{
if (ModSelect.State.Value == Visibility.Visible)
{
ModSelect.Hide();
return true;
}
if (base.OnExiting(next))
return true;
@ -620,6 +614,17 @@ namespace osu.Game.Screens.Select
return false;
}
public override bool OnBackButton()
{
if (ModSelect.State.Value == Visibility.Visible)
{
ModSelect.Hide();
return true;
}
return false;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);