mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 01:22:59 +08:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into profile-beatmaps-section
This commit is contained in:
commit
68c4da0810
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Lists;
|
using osu.Framework.Lists;
|
||||||
@ -85,6 +86,9 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
private T binarySearch<T>(SortedList<T> list, double time, T prePoint = null)
|
private T binarySearch<T>(SortedList<T> list, double time, T prePoint = null)
|
||||||
where T : ControlPoint, new()
|
where T : ControlPoint, new()
|
||||||
{
|
{
|
||||||
|
if (list == null)
|
||||||
|
throw new ArgumentNullException(nameof(list));
|
||||||
|
|
||||||
if (list.Count == 0)
|
if (list.Count == 0)
|
||||||
return new T();
|
return new T();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
|
||||||
@ -12,6 +13,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
public BeatmapBackgroundSprite(WorkingBeatmap working)
|
public BeatmapBackgroundSprite(WorkingBeatmap working)
|
||||||
{
|
{
|
||||||
|
if (working == null)
|
||||||
|
throw new ArgumentNullException(nameof(working));
|
||||||
|
|
||||||
this.working = working;
|
this.working = working;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,11 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
public BeatmapGroup(BeatmapSetInfo beatmapSet, BeatmapManager manager)
|
public BeatmapGroup(BeatmapSetInfo beatmapSet, BeatmapManager manager)
|
||||||
{
|
{
|
||||||
|
if (beatmapSet == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmapSet));
|
||||||
|
if (manager == null)
|
||||||
|
throw new ArgumentNullException(nameof(manager));
|
||||||
|
|
||||||
BeatmapSet = beatmapSet;
|
BeatmapSet = beatmapSet;
|
||||||
WorkingBeatmap beatmap = manager.GetWorkingBeatmap(BeatmapSet.Beatmaps.FirstOrDefault());
|
WorkingBeatmap beatmap = manager.GetWorkingBeatmap(BeatmapSet.Beatmaps.FirstOrDefault());
|
||||||
|
|
||||||
|
@ -73,6 +73,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
public BeatmapPanel(BeatmapInfo beatmap)
|
public BeatmapPanel(BeatmapInfo beatmap)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
|
||||||
Beatmap = beatmap;
|
Beatmap = beatmap;
|
||||||
Height *= 0.60f;
|
Height *= 0.60f;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
@ -12,6 +13,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
private readonly BeatmapSetInfo set;
|
private readonly BeatmapSetInfo set;
|
||||||
public BeatmapSetCover(BeatmapSetInfo set)
|
public BeatmapSetCover(BeatmapSetInfo set)
|
||||||
{
|
{
|
||||||
|
if (set == null)
|
||||||
|
throw new ArgumentNullException(nameof(set));
|
||||||
|
|
||||||
this.set = set;
|
this.set = set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
public BeatmapSetHeader(WorkingBeatmap beatmap)
|
public BeatmapSetHeader(WorkingBeatmap beatmap)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -88,6 +91,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(LocalisationEngine localisation)
|
private void load(LocalisationEngine localisation)
|
||||||
{
|
{
|
||||||
|
if (localisation == null)
|
||||||
|
throw new ArgumentNullException(nameof(localisation));
|
||||||
|
|
||||||
title.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title);
|
title.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title);
|
||||||
artist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist);
|
artist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist);
|
||||||
}
|
}
|
||||||
@ -154,6 +160,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
public void AddDifficultyIcons(IEnumerable<BeatmapPanel> panels)
|
public void AddDifficultyIcons(IEnumerable<BeatmapPanel> panels)
|
||||||
{
|
{
|
||||||
|
if (panels == null)
|
||||||
|
throw new ArgumentNullException(nameof(panels));
|
||||||
|
|
||||||
foreach (var p in panels)
|
foreach (var p in panels)
|
||||||
difficultyIcons.Add(new DifficultyIcon(p.Beatmap));
|
difficultyIcons.Add(new DifficultyIcon(p.Beatmap));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
@ -23,6 +24,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour palette)
|
private void load(OsuColour palette)
|
||||||
{
|
{
|
||||||
|
if (palette == null)
|
||||||
|
throw new ArgumentNullException(nameof(palette));
|
||||||
|
|
||||||
this.palette = palette;
|
this.palette = palette;
|
||||||
AccentColour = getColour(beatmap);
|
AccentColour = getColour(beatmap);
|
||||||
}
|
}
|
||||||
@ -39,6 +43,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
private DifficultyRating getDifficultyRating(BeatmapInfo beatmap)
|
private DifficultyRating getDifficultyRating(BeatmapInfo beatmap)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
|
||||||
var rating = beatmap.StarDifficulty;
|
var rating = beatmap.StarDifficulty;
|
||||||
|
|
||||||
if (rating < 1.5) return DifficultyRating.Easy;
|
if (rating < 1.5) return DifficultyRating.Easy;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
@ -15,6 +16,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
public DifficultyIcon(BeatmapInfo beatmap) : base(beatmap)
|
public DifficultyIcon(BeatmapInfo beatmap) : base(beatmap)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
Size = new Vector2(20);
|
Size = new Vector2(20);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
public static BeatmapDecoder GetDecoder(StreamReader stream)
|
public static BeatmapDecoder GetDecoder(StreamReader stream)
|
||||||
{
|
{
|
||||||
|
if (stream == null)
|
||||||
|
throw new ArgumentNullException(nameof(stream));
|
||||||
|
|
||||||
string line;
|
string line;
|
||||||
do { line = stream.ReadLine()?.Trim(); }
|
do { line = stream.ReadLine()?.Trim(); }
|
||||||
while (line != null && line.Length == 0);
|
while (line != null && line.Length == 0);
|
||||||
|
@ -70,6 +70,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private void handleGeneral(Beatmap beatmap, string line)
|
private void handleGeneral(Beatmap beatmap, string line)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
if (line == null)
|
||||||
|
throw new ArgumentNullException(nameof(line));
|
||||||
|
|
||||||
var pair = splitKeyVal(line, ':');
|
var pair = splitKeyVal(line, ':');
|
||||||
|
|
||||||
var metadata = beatmap.BeatmapInfo.Metadata;
|
var metadata = beatmap.BeatmapInfo.Metadata;
|
||||||
@ -129,6 +134,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private void handleEditor(Beatmap beatmap, string line)
|
private void handleEditor(Beatmap beatmap, string line)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
if (line == null)
|
||||||
|
throw new ArgumentNullException(nameof(line));
|
||||||
|
|
||||||
var pair = splitKeyVal(line, ':');
|
var pair = splitKeyVal(line, ':');
|
||||||
|
|
||||||
switch (pair.Key)
|
switch (pair.Key)
|
||||||
@ -153,6 +163,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private void handleMetadata(Beatmap beatmap, string line)
|
private void handleMetadata(Beatmap beatmap, string line)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
if (line == null)
|
||||||
|
throw new ArgumentNullException(nameof(line));
|
||||||
|
|
||||||
var pair = splitKeyVal(line, ':');
|
var pair = splitKeyVal(line, ':');
|
||||||
|
|
||||||
var metadata = beatmap.BeatmapInfo.Metadata;
|
var metadata = beatmap.BeatmapInfo.Metadata;
|
||||||
@ -194,6 +209,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private void handleDifficulty(Beatmap beatmap, string line)
|
private void handleDifficulty(Beatmap beatmap, string line)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
if (line == null)
|
||||||
|
throw new ArgumentNullException(nameof(line));
|
||||||
|
|
||||||
var pair = splitKeyVal(line, ':');
|
var pair = splitKeyVal(line, ':');
|
||||||
|
|
||||||
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
||||||
@ -226,6 +246,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
/// <param name="line">The line which may contains variables.</param>
|
/// <param name="line">The line which may contains variables.</param>
|
||||||
private void decodeVariables(ref string line)
|
private void decodeVariables(ref string line)
|
||||||
{
|
{
|
||||||
|
if (line == null)
|
||||||
|
throw new ArgumentNullException(nameof(line));
|
||||||
|
|
||||||
while (line.IndexOf('$') >= 0)
|
while (line.IndexOf('$') >= 0)
|
||||||
{
|
{
|
||||||
string origLine = line;
|
string origLine = line;
|
||||||
@ -244,6 +267,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private void handleEvents(Beatmap beatmap, string line, ref StoryboardSprite storyboardSprite, ref CommandTimelineGroup timelineGroup)
|
private void handleEvents(Beatmap beatmap, string line, ref StoryboardSprite storyboardSprite, ref CommandTimelineGroup timelineGroup)
|
||||||
{
|
{
|
||||||
|
if (line == null)
|
||||||
|
throw new ArgumentNullException(nameof(line));
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
|
||||||
var depth = 0;
|
var depth = 0;
|
||||||
while (line.StartsWith(" ") || line.StartsWith("_"))
|
while (line.StartsWith(" ") || line.StartsWith("_"))
|
||||||
{
|
{
|
||||||
@ -469,6 +497,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private void handleTimingPoints(Beatmap beatmap, string line)
|
private void handleTimingPoints(Beatmap beatmap, string line)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
if (line == null)
|
||||||
|
throw new ArgumentNullException(nameof(line));
|
||||||
|
|
||||||
string[] split = line.Split(',');
|
string[] split = line.Split(',');
|
||||||
|
|
||||||
double time = double.Parse(split[0].Trim(), NumberFormatInfo.InvariantInfo);
|
double time = double.Parse(split[0].Trim(), NumberFormatInfo.InvariantInfo);
|
||||||
@ -555,6 +588,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private void handleColours(Beatmap beatmap, string line, ref bool hasCustomColours)
|
private void handleColours(Beatmap beatmap, string line, ref bool hasCustomColours)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
if (line == null)
|
||||||
|
throw new ArgumentNullException(nameof(line));
|
||||||
|
|
||||||
var pair = splitKeyVal(line, ':');
|
var pair = splitKeyVal(line, ':');
|
||||||
|
|
||||||
string[] split = pair.Value.Split(',');
|
string[] split = pair.Value.Split(',');
|
||||||
@ -587,6 +625,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private void handleVariables(string line)
|
private void handleVariables(string line)
|
||||||
{
|
{
|
||||||
|
if (line == null)
|
||||||
|
throw new ArgumentNullException(nameof(line));
|
||||||
|
|
||||||
var pair = splitKeyVal(line, '=');
|
var pair = splitKeyVal(line, '=');
|
||||||
variables[pair.Key] = pair.Value;
|
variables[pair.Key] = pair.Value;
|
||||||
}
|
}
|
||||||
@ -603,6 +644,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
protected override void ParseFile(StreamReader stream, Beatmap beatmap)
|
protected override void ParseFile(StreamReader stream, Beatmap beatmap)
|
||||||
{
|
{
|
||||||
|
if (beatmap == null)
|
||||||
|
throw new ArgumentNullException(nameof(beatmap));
|
||||||
|
if (stream == null)
|
||||||
|
throw new ArgumentNullException(nameof(stream));
|
||||||
|
|
||||||
beatmap.BeatmapInfo.BeatmapVersion = beatmapVersion;
|
beatmap.BeatmapInfo.BeatmapVersion = beatmapVersion;
|
||||||
|
|
||||||
Section section = Section.None;
|
Section section = Section.None;
|
||||||
@ -679,6 +725,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private KeyValuePair<string, string> splitKeyVal(string line, char separator)
|
private KeyValuePair<string, string> splitKeyVal(string line, char separator)
|
||||||
{
|
{
|
||||||
|
if (line == null)
|
||||||
|
throw new ArgumentNullException(nameof(line));
|
||||||
|
|
||||||
var split = line.Trim().Split(new[] { separator }, 2);
|
var split = line.Trim().Split(new[] { separator }, 2);
|
||||||
|
|
||||||
return new KeyValuePair<string, string>
|
return new KeyValuePair<string, string>
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -33,6 +32,9 @@ namespace osu.Game.Overlays.Profile
|
|||||||
{
|
{
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
|
int[] userRanks = user.RankHistory?.Data ?? new[] { user.Statistics.Rank };
|
||||||
|
ranks = userRanks.SkipWhile(x => x == 0).ToArray();
|
||||||
|
|
||||||
Padding = new MarginPadding { Vertical = padding };
|
Padding = new MarginPadding { Vertical = padding };
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -58,19 +60,21 @@ namespace osu.Game.Overlays.Profile
|
|||||||
Font = @"Exo2.0-RegularItalic",
|
Font = @"Exo2.0-RegularItalic",
|
||||||
TextSize = secondary_textsize
|
TextSize = secondary_textsize
|
||||||
},
|
},
|
||||||
graph = new RankChartLineGraph
|
};
|
||||||
|
|
||||||
|
if (ranks.Length > 0)
|
||||||
|
{
|
||||||
|
Add(graph = new RankChartLineGraph
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Y = -secondary_textsize,
|
Y = -secondary_textsize,
|
||||||
DefaultValueCount = 90,
|
DefaultValueCount = ranks.Length,
|
||||||
BallRelease = updateRankTexts,
|
});
|
||||||
BallMove = showHistoryRankTexts
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ranks = user.RankHistory?.Data ?? new[] { user.Statistics.Rank };
|
graph.OnBallMove += showHistoryRankTexts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRankTexts()
|
private void updateRankTexts()
|
||||||
@ -82,7 +86,8 @@ namespace osu.Game.Overlays.Profile
|
|||||||
|
|
||||||
private void showHistoryRankTexts(int dayIndex)
|
private void showHistoryRankTexts(int dayIndex)
|
||||||
{
|
{
|
||||||
rankText.Text = ranks[dayIndex] > 0 ? $"#{ranks[dayIndex]:#,0}" : "no rank";
|
rankText.Text = $"#{ranks[dayIndex]:#,0}";
|
||||||
|
dayIndex++;
|
||||||
relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago";
|
relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago";
|
||||||
//plural should be handled in a general way
|
//plural should be handled in a general way
|
||||||
}
|
}
|
||||||
@ -90,14 +95,15 @@ namespace osu.Game.Overlays.Profile
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
graph.Colour = colours.Yellow;
|
if (graph != null)
|
||||||
|
|
||||||
if (user.Statistics.Rank > 0)
|
|
||||||
{
|
{
|
||||||
|
graph.Colour = colours.Yellow;
|
||||||
// use logarithmic coordinates
|
// use logarithmic coordinates
|
||||||
graph.Values = ranks.Select(x => -(float)Math.Log(x));
|
graph.Values = ranks.Select(x => -(float)Math.Log(x));
|
||||||
graph.ResetBall();
|
graph.SetStaticBallPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateRankTexts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||||
@ -110,68 +116,79 @@ namespace osu.Game.Overlays.Profile
|
|||||||
return base.Invalidate(invalidation, source, shallPropagate);
|
return base.Invalidate(invalidation, source, shallPropagate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RankChartLineGraph : LineGraph
|
protected override bool OnHover(InputState state)
|
||||||
{
|
{
|
||||||
private readonly CircularContainer ball;
|
graph?.UpdateBallPosition(state.Mouse.Position.X);
|
||||||
private bool ballShown;
|
graph?.ShowBall();
|
||||||
|
return base.OnHover(state);
|
||||||
private const double transform_duration = 100;
|
|
||||||
|
|
||||||
public Action<int> BallMove;
|
|
||||||
public Action BallRelease;
|
|
||||||
|
|
||||||
public RankChartLineGraph()
|
|
||||||
{
|
|
||||||
Add(ball = new CircularContainer
|
|
||||||
{
|
|
||||||
Size = new Vector2(8),
|
|
||||||
Masking = true,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Alpha = 0,
|
|
||||||
RelativePositionAxes = Axes.Both,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box { RelativeSizeAxes = Axes.Both }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetBall()
|
|
||||||
{
|
|
||||||
ball.MoveTo(new Vector2(1, GetYPosition(Values.Last())), ballShown ? transform_duration : 0, Easing.OutQuint);
|
|
||||||
ball.Show();
|
|
||||||
BallRelease();
|
|
||||||
ballShown = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(InputState state)
|
protected override bool OnMouseMove(InputState state)
|
||||||
{
|
{
|
||||||
if (ballShown)
|
graph?.UpdateBallPosition(state.Mouse.Position.X);
|
||||||
{
|
|
||||||
var values = (IList<float>)Values;
|
|
||||||
var position = ToLocalSpace(state.Mouse.NativeState.Position);
|
|
||||||
int count = Math.Max(values.Count, DefaultValueCount);
|
|
||||||
int index = (int)Math.Round(position.X / DrawWidth * (count - 1));
|
|
||||||
if (index >= count - values.Count)
|
|
||||||
{
|
|
||||||
int i = index + values.Count - count;
|
|
||||||
float y = GetYPosition(values[i]);
|
|
||||||
if (Math.Abs(y * DrawHeight - position.Y) <= 8f)
|
|
||||||
{
|
|
||||||
ball.MoveTo(new Vector2(index / (float)(count - 1), y), transform_duration, Easing.OutQuint);
|
|
||||||
BallMove(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return base.OnMouseMove(state);
|
return base.OnMouseMove(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(InputState state)
|
protected override void OnHoverLost(InputState state)
|
||||||
{
|
{
|
||||||
if (ballShown)
|
if (graph != null)
|
||||||
ResetBall();
|
{
|
||||||
|
graph.HideBall();
|
||||||
|
updateRankTexts();
|
||||||
|
}
|
||||||
base.OnHoverLost(state);
|
base.OnHoverLost(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RankChartLineGraph : LineGraph
|
||||||
|
{
|
||||||
|
private const double fade_duration = 200;
|
||||||
|
|
||||||
|
private readonly CircularContainer staticBall;
|
||||||
|
private readonly CircularContainer movingBall;
|
||||||
|
|
||||||
|
public Action<int> OnBallMove;
|
||||||
|
|
||||||
|
public RankChartLineGraph()
|
||||||
|
{
|
||||||
|
Add(staticBall = new CircularContainer
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(8),
|
||||||
|
Masking = true,
|
||||||
|
RelativePositionAxes = Axes.Both,
|
||||||
|
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||||
|
});
|
||||||
|
Add(movingBall = new CircularContainer
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(8),
|
||||||
|
Alpha = 0,
|
||||||
|
Masking = true,
|
||||||
|
RelativePositionAxes = Axes.Both,
|
||||||
|
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetStaticBallPosition() => staticBall.Position = new Vector2(1, GetYPosition(Values.Last()));
|
||||||
|
|
||||||
|
public void UpdateBallPosition(float mouseXPosition)
|
||||||
|
{
|
||||||
|
int index = calculateIndex(mouseXPosition);
|
||||||
|
movingBall.Position = calculateBallPosition(index);
|
||||||
|
OnBallMove.Invoke(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowBall() => movingBall.FadeIn(fade_duration);
|
||||||
|
|
||||||
|
public void HideBall() => movingBall.FadeOut(fade_duration);
|
||||||
|
|
||||||
|
private int calculateIndex(float mouseXPosition) => (int)Math.Round(mouseXPosition / DrawWidth * (DefaultValueCount - 1));
|
||||||
|
|
||||||
|
private Vector2 calculateBallPosition(int index)
|
||||||
|
{
|
||||||
|
float y = GetYPosition(Values.ElementAt(index));
|
||||||
|
return new Vector2(index / (float)(DefaultValueCount - 1), y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,17 +263,15 @@ namespace osu.Game.Screens.Menu
|
|||||||
logo.ScaleTo(0.5f, 200, Easing.In);
|
logo.ScaleTo(0.5f, 200, Easing.In);
|
||||||
|
|
||||||
trackingPosition = false;
|
trackingPosition = false;
|
||||||
|
|
||||||
logo
|
logo
|
||||||
.MoveTo(iconTrackingPosition, lastState == MenuState.EnteringMode ? 0 : 200, Easing.In)
|
.MoveTo(iconTrackingPosition, lastState == MenuState.EnteringMode ? 0 : 200, Easing.In)
|
||||||
.OnComplete(o =>
|
.OnComplete(o =>
|
||||||
{
|
{
|
||||||
trackingPosition = true;
|
trackingPosition = true;
|
||||||
|
|
||||||
if (logo.Scale.X > 0.5f)
|
|
||||||
{
|
|
||||||
o.Impact();
|
o.Impact();
|
||||||
toolbar?.Show();
|
toolbar?.Show();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -25,6 +26,9 @@ namespace osu.Game.Users
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(TextureStore textures)
|
||||||
{
|
{
|
||||||
|
if (textures == null)
|
||||||
|
throw new ArgumentNullException(nameof(textures));
|
||||||
|
|
||||||
Texture texture = null;
|
Texture texture = null;
|
||||||
if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
|
if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
|
||||||
if (texture == null) texture = textures.Get(@"Online/avatar-guest");
|
if (texture == null) texture = textures.Get(@"Online/avatar-guest");
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -45,6 +46,9 @@ namespace osu.Game.Users
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore ts)
|
private void load(TextureStore ts)
|
||||||
{
|
{
|
||||||
|
if (ts == null)
|
||||||
|
throw new ArgumentNullException(nameof(ts));
|
||||||
|
|
||||||
textures = ts;
|
textures = ts;
|
||||||
sprite.Texture = textures.Get($@"Flags/{flagName}");
|
sprite.Texture = textures.Get($@"Flags/{flagName}");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
@ -19,6 +20,9 @@ namespace osu.Game.Users
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(TextureStore textures)
|
||||||
{
|
{
|
||||||
|
if (textures == null)
|
||||||
|
throw new ArgumentNullException(nameof(textures));
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(user.CoverUrl))
|
if (!string.IsNullOrEmpty(user.CoverUrl))
|
||||||
Texture = textures.Get(user.CoverUrl);
|
Texture = textures.Get(user.CoverUrl);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,9 @@ namespace osu.Game.Users
|
|||||||
|
|
||||||
public UserPanel(User user)
|
public UserPanel(User user)
|
||||||
{
|
{
|
||||||
|
if (user == null)
|
||||||
|
throw new ArgumentNullException(nameof(user));
|
||||||
|
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
Height = height - status_height;
|
Height = height - status_height;
|
||||||
@ -173,6 +176,9 @@ namespace osu.Game.Users
|
|||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(OsuColour colours, UserProfileOverlay profile)
|
private void load(OsuColour colours, UserProfileOverlay profile)
|
||||||
{
|
{
|
||||||
|
if (colours == null)
|
||||||
|
throw new ArgumentNullException(nameof(colours));
|
||||||
|
|
||||||
Status.ValueChanged += displayStatus;
|
Status.ValueChanged += displayStatus;
|
||||||
Status.ValueChanged += status => statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint);
|
Status.ValueChanged += status => statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user