1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 10:43:04 +08:00

update to everything

This commit is contained in:
Jorolf 2017-04-10 16:42:23 +02:00
parent bcef1ce2b6
commit 24b4b3ad7d
7 changed files with 140 additions and 173 deletions

View File

@ -41,21 +41,45 @@ namespace osu.Desktop.VisualTests.Tests
DrainRate = 1, DrainRate = 1,
}, },
StarDifficulty = 5.3f, StarDifficulty = 5.3f,
Metric = new BeatmapMetric
{
Ratings = Enumerable.Range(0,10).ToArray(),
Fails = Enumerable.Range(lastRange, 100).Select(i => (i % 12) - 6).ToArray(),
Retries = Enumerable.Range(lastRange - 3, 100).Select(i => (i % 12) - 6).ToArray(),
},
}, },
}); });
AddRepeatStep("new fail values", newRetryAndFailValues, 10); AddRepeatStep("fail values", newRetryAndFailValues, 10);
AddStep("new ratings", () => details.Ratings = Enumerable.Range(1, 10));
AddStep("remove fails", () => details.Fails = null );
AddStep("remove ratings", () => details.Ratings = null );
} }
private int lastRange = 1; private int lastRange = 1;
private void newRetryAndFailValues() private void newRetryAndFailValues()
{ {
details.Fails = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Cos(i) * 100)); details.Beatmap = new BeatmapInfo
details.Retries = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Sin(i) * 100)); {
Version = "VisualTest",
Metadata = new BeatmapMetadata
{
Source = "Some guy",
Tags = "beatmap metadata example with a very very long list of tags and not much creativity",
},
Difficulty = new BeatmapDifficulty
{
CircleSize = 7,
ApproachRate = 3.5f,
OverallDifficulty = 5.7f,
DrainRate = 1,
},
StarDifficulty = 5.3f,
Metric = new BeatmapMetric
{
Ratings = Enumerable.Range(0, 10).ToArray(),
Fails = Enumerable.Range(lastRange, 100).Select(i => (i % 12) - 6).ToArray(),
Retries = Enumerable.Range(lastRange - 3, 100).Select(i => (i % 12) - 6).ToArray(),
},
};
lastRange += 100; lastRange += 100;
} }
} }

View File

@ -41,6 +41,9 @@ namespace osu.Game.Database
[OneToOne(CascadeOperations = CascadeOperation.All)] [OneToOne(CascadeOperations = CascadeOperation.All)]
public BeatmapDifficulty Difficulty { get; set; } public BeatmapDifficulty Difficulty { get; set; }
[Ignore]
public BeatmapMetric Metric { get; set; }
public string Path { get; set; } public string Path { get; set; }
public string Hash { get; set; } public string Hash { get; set; }

View File

@ -0,0 +1,23 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Database
{
public class BeatmapMetric
{
/// <summary>
/// Ratings for a beatmap, length should be 10
/// </summary>
public int[] Ratings { get; set; }
/// <summary>
/// Fails for a beatmap, length should be 100
/// </summary>
public int[] Fails { get; set; }
/// <summary>
/// Retries for a beatmap, length should be 100
/// </summary>
public int[] Retries { get; set; }
}
}

View File

@ -20,6 +20,9 @@ namespace osu.Game.Graphics.UserInterface
private const EasingTypes easing = EasingTypes.InOutCubic; private const EasingTypes easing = EasingTypes.InOutCubic;
private float length; private float length;
/// <summary>
/// Length of the bar, ranges from 0 to 1
/// </summary>
public float Length public float Length
{ {
get get
@ -41,12 +44,6 @@ namespace osu.Game.Graphics.UserInterface
} }
set set
{ {
if (background == null)
Add(background = new Box
{
RelativeSizeAxes = Axes.Both,
Depth = 1,
});
background.Colour = value; background.Colour = value;
} }
} }
@ -81,10 +78,15 @@ namespace osu.Game.Graphics.UserInterface
{ {
Children = new[] Children = new[]
{ {
background = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = new Color4(0,0,0,0)
},
bar = new Box bar = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
} },
}; };
} }

View File

@ -11,6 +11,11 @@ namespace osu.Game.Graphics.UserInterface
{ {
public class BarGraph : FillFlowContainer<Bar> public class BarGraph : FillFlowContainer<Bar>
{ {
/// <summary>
/// Manually sets the max value, if null <see cref="Enumerable.Max(IEnumerable{float})"/> is instead used
/// </summary>
public float? MaxValue { get; set; }
private BarDirection direction = BarDirection.BottomToTop; private BarDirection direction = BarDirection.BottomToTop;
public new BarDirection Direction public new BarDirection Direction
{ {
@ -30,6 +35,9 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
/// <summary>
/// A list of floats that defines the length of each <see cref="Bar"/>
/// </summary>
public IEnumerable<float> Values public IEnumerable<float> Values
{ {
set set
@ -39,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface
for (int i = 0; i < values.Count; i++) for (int i = 0; i < values.Count; i++)
if (graphBars.Count > i) if (graphBars.Count > i)
{ {
graphBars[i].Length = values[i] / values.Max(); graphBars[i].Length = values[i] / (MaxValue ?? values.Max());
graphBars[i].Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1); graphBars[i].Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1);
} }
else else
@ -47,9 +55,10 @@ namespace osu.Game.Graphics.UserInterface
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1), Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1),
Length = values[i] / values.Max(), Length = values[i] / (MaxValue ?? values.Max()),
Direction = Direction, Direction = Direction,
}); });
Remove(Children.Where((bar, index) => index >= values.Count));
} }
} }
} }

View File

@ -47,85 +47,49 @@ namespace osu.Game.Screens.Select
{ {
return beatmap; return beatmap;
} }
set set
{ {
if (beatmap == value) return; if (beatmap == value) return;
beatmap = value; beatmap = value;
description.ContentText = beatmap.Version; description.Text = beatmap.Version;
source.ContentText = beatmap.Metadata.Source; source.Text = beatmap.Metadata.Source;
tags.ContentText = beatmap.Metadata.Tags; tags.Text = beatmap.Metadata.Tags;
circleSize.Value = beatmap.Difficulty.CircleSize; circleSize.Value = beatmap.Difficulty.CircleSize;
drainRate.Value = beatmap.Difficulty.DrainRate; drainRate.Value = beatmap.Difficulty.DrainRate;
overallDifficulty.Value = beatmap.Difficulty.OverallDifficulty; overallDifficulty.Value = beatmap.Difficulty.OverallDifficulty;
approachRate.Value = beatmap.Difficulty.ApproachRate; approachRate.Value = beatmap.Difficulty.ApproachRate;
stars.Value = (float)beatmap.StarDifficulty; stars.Value = (float)beatmap.StarDifficulty;
}
}
private List<int> ratings;
public IEnumerable<int> Ratings List<int> ratings = beatmap.Metric?.Ratings?.ToList() ?? new List<int>();
{ if (ratings.Count == 0)
get ratingsContainer.Hide();
{
return ratings;
}
set
{
ratings = value?.ToList() ?? new List<int>();
if(ratings.Count == 0)
ratingsContainer.FadeOut(250);
else else
{ {
ratingsContainer.FadeIn(250); ratingsContainer.Show();
negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString();
positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString(); positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString();
ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum(); ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum();
ratingsGraph.Values = ratings.Select(rating => (float)rating); ratingsGraph.Values = ratings.Select(rating => (float)rating);
} }
}
}
private List<int> retries; List<int> retries = beatmap.Metric?.Retries?.ToList() ?? new List<int>();
public IEnumerable<int> Retries List<int> fails = beatmap.Metric?.Fails?.ToList() ?? new List<int>();
{
get
{
return retries;
}
set
{
retries = value?.ToList() ?? new List<int>();
calcRetryAndFailGraph();
}
}
private List<int> fails; if ((fails?.Count ?? 0) == 0 || (retries?.Count ?? 0) == 0)
public IEnumerable<int> Fails retryAndFailContainer.Hide();
{ else
get {
{ retryAndFailContainer.Show();
return fails; float maxValue = fails.Select((fail, index) => fail + retries[index]).Max();
} failGraph.MaxValue = maxValue;
set retryGraph.MaxValue = maxValue;
{ failGraph.Values = fails.Select(fail => (float)fail);
fails = value?.ToList() ?? new List<int>(); retryGraph.Values = retries.Select((retry, index) => retry + MathHelper.Clamp(fails[index], 0, maxValue));
calcRetryAndFailGraph(); }
}
}
private void calcRetryAndFailGraph()
{
if ((fails?.Count ?? 0) == 0 || (retries?.Count ?? 0) == 0)
retryAndFailContainer.FadeOut(250);
else
{
retryAndFailContainer.FadeIn(250);
failGraph.Values = fails.Select(fail => (float)fail);
retryGraph.Values = retries?.Select((retry, index) => (float)retry + fails[index]);
} }
} }
@ -152,24 +116,9 @@ namespace osu.Game.Screens.Select
Padding = new MarginPadding(10) { Top = 25 }, Padding = new MarginPadding(10) { Top = 25 },
Children = new [] Children = new []
{ {
description = new MetadataSegment description = new MetadataSegment("Description"),
{ source = new MetadataSegment("Source"),
HeaderText = "Description", tags = new MetadataSegment("Tags")
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
},
source = new MetadataSegment
{
HeaderText = "Source",
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
},
tags = new MetadataSegment
{
HeaderText = "Tags",
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
}
}, },
}, },
new FillFlowContainer new FillFlowContainer
@ -178,7 +127,7 @@ namespace osu.Game.Screens.Select
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Width = 0.6f, Width = 0.6f,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Spacing = new Vector2(0,15), Spacing = new Vector2(0, 15),
Padding = new MarginPadding(10) { Top = 0 }, Padding = new MarginPadding(10) { Top = 0 },
Children = new Drawable[] Children = new Drawable[]
{ {
@ -203,37 +152,11 @@ namespace osu.Game.Screens.Select
Padding = new MarginPadding(15) { Top = 25 }, Padding = new MarginPadding(15) { Top = 25 },
Children = new [] Children = new []
{ {
circleSize = new DifficultyRow circleSize = new DifficultyRow("Circle Size", 7),
{ drainRate = new DifficultyRow("HP Drain"),
DifficultyName = "Circle Size", overallDifficulty = new DifficultyRow("Accuracy"),
AutoSizeAxes = Axes.Y, approachRate = new DifficultyRow("Approach Rate"),
RelativeSizeAxes = Axes.X, stars = new DifficultyRow("Star Diffculty"),
MaxValue = 7,
},
drainRate = new DifficultyRow
{
DifficultyName = "HP Drain",
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
},
overallDifficulty = new DifficultyRow
{
DifficultyName = "Accuracy",
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
},
approachRate = new DifficultyRow
{
DifficultyName = "Approach Rate",
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
},
stars = new DifficultyRow
{
DifficultyName = "Star Difficulty",
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
},
}, },
}, },
}, },
@ -320,7 +243,7 @@ namespace osu.Game.Screens.Select
new OsuSpriteText new OsuSpriteText
{ {
Text = "Points of Failure", Text = "Points of Failure",
Font = @"Exo2.0-Regular", Font = @"Exo2.0-Regular",
}, },
new Container<BarGraph> new Container<BarGraph>
{ {
@ -341,7 +264,7 @@ namespace osu.Game.Screens.Select
} }
}, },
}, },
}, }
}; };
} }
@ -368,8 +291,9 @@ namespace osu.Game.Screens.Select
private readonly Bar bar; private readonly Bar bar;
private readonly OsuSpriteText valueText; private readonly OsuSpriteText valueText;
private float difficultyValue; private readonly float maxValue;
private float difficultyValue;
public float Value public float Value
{ {
get get
@ -384,33 +308,6 @@ namespace osu.Game.Screens.Select
} }
} }
private float maxValue = 10;
public float MaxValue
{
get
{
return maxValue;
}
set
{
maxValue = value;
bar.Length = Value / value;
}
}
public string DifficultyName
{
get
{
return name.Text;
}
set
{
name.Text = value;
}
}
public Color4 AccentColour public Color4 AccentColour
{ {
get get
@ -423,13 +320,17 @@ namespace osu.Game.Screens.Select
} }
} }
public DifficultyRow() public DifficultyRow(string difficultyName, float maxValue = 10)
{ {
this.maxValue = maxValue;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Children = new Drawable[] Children = new Drawable[]
{ {
name = new OsuSpriteText name = new OsuSpriteText
{ {
Font = @"Exo2.0-Regular", Font = @"Exo2.0-Regular",
Text = difficultyName,
}, },
bar = new Bar bar = new Bar
{ {
@ -462,30 +363,30 @@ namespace osu.Game.Screens.Select
private readonly OsuSpriteText header; private readonly OsuSpriteText header;
private readonly FillFlowContainer<OsuSpriteText> content; private readonly FillFlowContainer<OsuSpriteText> content;
private const int fade_time = 250; public string Text
public string HeaderText
{ {
set set
{ {
header.Text = value; if (string.IsNullOrEmpty(value))
} Hide();
}
public string ContentText
{
set
{
if (value == "")
FadeOut(fade_time);
else else
{ {
FadeIn(fade_time); Show();
content.Children = value.Split(' ').Select(text => new OsuSpriteText if (header.Text == "Tags")
{ content.Children = value.Split(' ').Select(text => new OsuSpriteText
Text = text, {
Font = "Exo2.0-Regular", Text = text,
}); Font = "Exo2.0-Regular",
});
else
content.Children = new[]
{
new OsuSpriteText
{
Text = value,
Font = "Exo2.0-Regular",
}
};
} }
} }
} }
@ -502,13 +403,17 @@ namespace osu.Game.Screens.Select
} }
} }
public MetadataSegment() public MetadataSegment(string headerText)
{ {
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Margin = new MarginPadding { Top = 10 };
Children = new Drawable[] Children = new Drawable[]
{ {
header = new OsuSpriteText header = new OsuSpriteText
{ {
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
Text = headerText,
}, },
content = new FillFlowContainer<OsuSpriteText> content = new FillFlowContainer<OsuSpriteText>
{ {

View File

@ -79,6 +79,7 @@
<Compile Include="Beatmaps\Legacy\LegacyBeatmap.cs" /> <Compile Include="Beatmaps\Legacy\LegacyBeatmap.cs" />
<Compile Include="Beatmaps\Timing\TimeSignatures.cs" /> <Compile Include="Beatmaps\Timing\TimeSignatures.cs" />
<Compile Include="Beatmaps\Timing\TimingInfo.cs" /> <Compile Include="Beatmaps\Timing\TimingInfo.cs" />
<Compile Include="Database\BeatmapMetric.cs" />
<Compile Include="Database\ScoreDatabase.cs" /> <Compile Include="Database\ScoreDatabase.cs" />
<Compile Include="Graphics\Backgrounds\Triangles.cs" /> <Compile Include="Graphics\Backgrounds\Triangles.cs" />
<Compile Include="Graphics\Cursor\CursorTrail.cs" /> <Compile Include="Graphics\Cursor\CursorTrail.cs" />