1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:02:55 +08:00

Merge remote-tracking branch 'upstream/master' into fix-back-button-hover-sounds

This commit is contained in:
Dean Herbert 2019-08-07 12:34:30 +09:00
commit f2861c0c7d
13 changed files with 81 additions and 78 deletions

0
.gitmodules vendored
View File

View File

@ -1,2 +0,0 @@
language: csharp
solution: osu.sln

View File

@ -69,28 +69,22 @@ namespace osu.Game.Tests.Visual.Online
}
});
AddStep("null user", () => graph.User.Value = null);
AddStep("null user", () => graph.Statistics.Value = null);
AddStep("rank only", () =>
{
graph.User.Value = new User
graph.Statistics.Value = new UserStatistics
{
Statistics = new UserStatistics
{
Ranks = new UserStatistics.UserRanks { Global = 123456 },
PP = 12345,
}
Ranks = new UserStatistics.UserRanks { Global = 123456 },
PP = 12345,
};
});
AddStep("with rank history", () =>
{
graph.User.Value = new User
graph.Statistics.Value = new UserStatistics
{
Statistics = new UserStatistics
{
Ranks = new UserStatistics.UserRanks { Global = 89000 },
PP = 12345,
},
Ranks = new UserStatistics.UserRanks { Global = 89000 },
PP = 12345,
RankHistory = new User.RankHistoryData
{
Data = data,
@ -100,13 +94,10 @@ namespace osu.Game.Tests.Visual.Online
AddStep("with zero values", () =>
{
graph.User.Value = new User
graph.Statistics.Value = new UserStatistics
{
Statistics = new UserStatistics
{
Ranks = new UserStatistics.UserRanks { Global = 89000 },
PP = 12345,
},
Ranks = new UserStatistics.UserRanks { Global = 89000 },
PP = 12345,
RankHistory = new User.RankHistoryData
{
Data = dataWithZeros,
@ -116,13 +107,10 @@ namespace osu.Game.Tests.Visual.Online
AddStep("small amount of data", () =>
{
graph.User.Value = new User
graph.Statistics.Value = new UserStatistics
{
Statistics = new UserStatistics
{
Ranks = new UserStatistics.UserRanks { Global = 12000 },
PP = 12345,
},
Ranks = new UserStatistics.UserRanks { Global = 12000 },
PP = 12345,
RankHistory = new User.RankHistoryData
{
Data = smallData,
@ -132,13 +120,10 @@ namespace osu.Game.Tests.Visual.Online
AddStep("graph with edges", () =>
{
graph.User.Value = new User
graph.Statistics.Value = new UserStatistics
{
Statistics = new UserStatistics
{
Ranks = new UserStatistics.UserRanks { Global = 12000 },
PP = 12345,
},
Ranks = new UserStatistics.UserRanks { Global = 12000 },
PP = 12345,
RankHistory = new User.RankHistoryData
{
Data = edgyData,

View File

@ -50,12 +50,12 @@ namespace osu.Game.Tests.Visual.Online
{
Current = 727,
Progress = 69,
}
},
RankHistory = new User.RankHistoryData
{
Mode = @"osu",
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
},
RankHistory = new User.RankHistoryData
{
Mode = @"osu",
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
},
},
Badges = new[]
{

View File

@ -256,6 +256,9 @@ namespace osu.Game.Overlays
loadedChannels.Add(loaded);
LoadComponentAsync(loaded, l =>
{
if (currentChannel.Value != e.NewValue)
return;
loading.Hide();
currentChannelContainer.Clear(false);
@ -381,7 +384,18 @@ namespace osu.Game.Overlays
foreach (Channel channel in channels)
{
ChannelTabControl.RemoveChannel(channel);
loadedChannels.Remove(loadedChannels.Find(c => c.Channel == channel));
var loaded = loadedChannels.Find(c => c.Channel == channel);
if (loaded != null)
{
loadedChannels.Remove(loaded);
// Because the container is only cleared in the async load callback of a new channel, it is forcefully cleared
// to ensure that the previous channel doesn't get updated after it's disposed
currentChannelContainer.Remove(loaded);
loaded.Dispose();
}
}
}

View File

@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
private KeyValuePair<int, int>[] ranks;
private int dayIndex;
public Bindable<User> User = new Bindable<User>();
public readonly Bindable<UserStatistics> Statistics = new Bindable<UserStatistics>();
public RankGraph()
{
@ -56,8 +56,6 @@ namespace osu.Game.Overlays.Profile.Header.Components
};
graph.OnBallMove += i => dayIndex = i;
User.ValueChanged += userChanged;
}
[BackgroundDependencyLoader]
@ -66,18 +64,25 @@ namespace osu.Game.Overlays.Profile.Header.Components
graph.LineColour = colours.Yellow;
}
private void userChanged(ValueChangedEvent<User> e)
protected override void LoadComplete()
{
base.LoadComplete();
Statistics.BindValueChanged(statistics => updateStatistics(statistics.NewValue), true);
}
private void updateStatistics(UserStatistics statistics)
{
placeholder.FadeIn(fade_duration, Easing.Out);
if (e.NewValue?.Statistics?.Ranks.Global == null)
if (statistics?.Ranks.Global == null)
{
graph.FadeOut(fade_duration, Easing.Out);
ranks = null;
return;
}
int[] userRanks = e.NewValue.RankHistory?.Data ?? new[] { e.NewValue.Statistics.Ranks.Global.Value };
int[] userRanks = statistics.RankHistory?.Data ?? new[] { statistics.Ranks.Global.Value };
ranks = userRanks.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray();
if (ranks.Length > 1)
@ -191,7 +196,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
}
}
public string TooltipText => User.Value?.Statistics?.Ranks.Global == null ? "" : $"#{ranks[dayIndex].Value:#,##0}|{ranked_days - ranks[dayIndex].Key + 1}";
public string TooltipText => Statistics.Value?.Ranks.Global == null ? "" : $"#{ranks[dayIndex].Value:#,##0}|{ranked_days - ranks[dayIndex].Key + 1}";
public ITooltip GetCustomTooltip() => new RankGraphTooltip();

View File

@ -179,7 +179,7 @@ namespace osu.Game.Overlays.Profile.Header
detailGlobalRank.Content = user?.Statistics?.Ranks.Global?.ToString("\\##,##0") ?? "-";
detailCountryRank.Content = user?.Statistics?.Ranks.Country?.ToString("\\##,##0") ?? "-";
rankGraph.User.Value = user;
rankGraph.Statistics.Value = user?.Statistics;
}
private class ScoreRankInfo : CompositeDrawable

View File

@ -255,7 +255,7 @@ namespace osu.Game.Screens.Play
private void performImmediateExit()
{
// if a restart has been requested, cancel any pending completion (user has shown intent to restart).
onCompletionEvent = null;
completionProgressDelegate?.Cancel();
ValidForResume = false;
@ -275,20 +275,16 @@ namespace osu.Game.Screens.Play
sampleRestart?.Play();
// if a restart has been requested, cancel any pending completion (user has shown intent to restart).
onCompletionEvent = null;
ValidForResume = false;
RestartRequested?.Invoke();
this.Exit();
performImmediateExit();
}
private ScheduledDelegate onCompletionEvent;
private ScheduledDelegate completionProgressDelegate;
private void onCompletion()
{
// Only show the completion screen if the player hasn't failed
if (ScoreProcessor.HasFailed || onCompletionEvent != null)
if (ScoreProcessor.HasFailed || completionProgressDelegate != null)
return;
ValidForResume = false;
@ -297,7 +293,7 @@ namespace osu.Game.Screens.Play
using (BeginDelayedSequence(1000))
{
onCompletionEvent = Schedule(delegate
completionProgressDelegate = Schedule(delegate
{
if (!this.IsCurrentScreen()) return;
@ -306,8 +302,6 @@ namespace osu.Game.Screens.Play
scoreManager.Import(score).Wait();
this.Push(CreateResults(score));
onCompletionEvent = null;
});
}
}
@ -471,10 +465,10 @@ namespace osu.Game.Screens.Play
public override bool OnExiting(IScreen next)
{
if (onCompletionEvent != null)
if (completionProgressDelegate != null && !completionProgressDelegate.Cancelled && !completionProgressDelegate.Completed)
{
// Proceed to result screen if beatmap already finished playing
onCompletionEvent.RunTask();
// proceed to result screen if beatmap already finished playing
completionProgressDelegate.RunTask();
return true;
}

View File

@ -94,7 +94,7 @@ namespace osu.Game.Screens.Select
buttons = new FillFlowContainer<FooterButton>
{
Direction = FillDirection.Horizontal,
Spacing = new Vector2(0.2f, 0),
Spacing = new Vector2(-FooterButton.SHEAR_WIDTH, 0),
AutoSizeAxes = Axes.Both,
}
}

View File

@ -17,7 +17,9 @@ namespace osu.Game.Screens.Select
{
public class FooterButton : OsuClickableContainer
{
private static readonly Vector2 shearing = new Vector2(0.15f, 0);
public static readonly float SHEAR_WIDTH = 7.5f;
protected static readonly Vector2 SHEAR = new Vector2(SHEAR_WIDTH / Footer.HEIGHT, 0);
public string Text
{
@ -59,37 +61,35 @@ namespace osu.Game.Screens.Select
private readonly Box box;
private readonly Box light;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
public FooterButton()
{
AutoSizeAxes = Axes.Both;
Shear = SHEAR;
Children = new Drawable[]
{
TextContainer = new Container
{
Size = new Vector2(100, 50),
Child = SpriteText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
},
box = new Box
{
RelativeSizeAxes = Axes.Both,
Shear = shearing,
EdgeSmoothness = new Vector2(2, 0),
Colour = Color4.White,
Alpha = 0,
},
light = new Box
{
Shear = shearing,
Height = 4,
EdgeSmoothness = new Vector2(2, 0),
RelativeSizeAxes = Axes.X,
},
TextContainer = new Container
{
Size = new Vector2(100 - SHEAR_WIDTH, 50),
Shear = -SHEAR,
Child = SpriteText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
},
};
}

View File

@ -32,6 +32,7 @@ namespace osu.Game.Screens.Select
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Shear = -SHEAR,
Child = modDisplay = new FooterModDisplay
{
DisplayUnrankedText = false,

View File

@ -159,7 +159,10 @@ namespace osu.Game.Users
}
[JsonProperty(@"rankHistory")]
public RankHistoryData RankHistory;
private RankHistoryData rankHistory
{
set => Statistics.RankHistory = value;
}
[JsonProperty("badges")]
public Badge[] Badges;

View File

@ -4,6 +4,7 @@
using System;
using Newtonsoft.Json;
using osu.Game.Scoring;
using static osu.Game.Users.User;
namespace osu.Game.Users
{
@ -113,5 +114,7 @@ namespace osu.Game.Users
[JsonProperty(@"country")]
public int? Country;
}
public RankHistoryData RankHistory;
}
}